feat: introduce pg-testkit driver and ztd-cli scaffolding - #287
Conversation
… with templates and tests
…logy - Updated database schema to replace 'users', 'products', 'orders', and 'order_items' with 'customer', 'product', 'sales_order', and 'sales_order_item'. - Created new customer_summary query to aggregate orders and spend per customer. - Modified sales_summary and product_ranking queries to align with new schema. - Removed user_summary query and its associated tests. - Added tests for customer_summary and updated tests for sales_summary and product_ranking. - Updated README and documentation to reflect changes in schema and queries. - Introduced new domain specifications for active orders and order status enumeration.
…(update ztd-cli init and playground)
WalkthroughRestructures ZTD layout: moves schema/artifacts from sql/ to ztd/, places generated test artifacts under tests/generated/, updates ztd-cli defaults/templates/init/watch behavior, adds Vitest global-setup/config templates, updates pg-testkit docs, and migrates playground schema, queries, and tests to the new layout and names. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Potential focus areas:
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 8
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (7)
packages/ztd-cli/tests/cliCommands.test.ts (1)
72-100: Test description doesn't match actual behavior.The test name references
tests/generated/ztd-row-map.generated.ts, but the actual test outputs to a temporary directory (outDircreated on line 92), not to atests/generated/path. The test verifies that the CLI generates the file correctly in isolation, but the description is misleading about where the output goes.Update the test description to accurately reflect what it tests:
-test('ztd-config CLI produces the expected tests/generated/ztd-row-map.generated.ts snapshot', () => { +test('ztd-config CLI produces the expected ztd-row-map.generated.ts snapshot', () => {Alternatively, if the intent is to verify the file lands in
tests/generated/within an actual project context, the test logic should be updated to use a real project structure rather than temp directories.packages/ztd-cli/src/commands/ztdConfigCommand.ts (3)
81-85: Watch-mode comment is misleading when--outis set.
Right now it implies onlytests/generated/ztd-row-map.generated.tsis overwritten, but watch regenerates whateveroptions.outis.- // Only the tests/generated/ztd-row-map.generated.ts output is overwritten while watching DDL changes. + // Only the configured output file (`options.out`) is overwritten while watching DDL changes.
104-114: Don’t hardcodetests/generated/...in the watch regeneration error; useoptions.out.
With--out, the current message points users to the wrong file.const executeReload = async (changedPath: string | null): Promise<void> => { @@ } catch (error) { console.error( - `[watch] Failed to regenerate tests/generated/ztd-row-map.generated.ts: ${error instanceof Error ? error.message : String(error)}` + `[watch] Failed to regenerate ${options.out}: ${error instanceof Error ? error.message : String(error)}` ); } };
19-23: Add English JSDoc for exportedregisterZtdConfigCommand(public API insrc/). As per coding guidelines, exported symbols undersrc/must have clear English JSDoc.-export function registerZtdConfigCommand(program: Command): void { +/** + * Registers the `ztd-config` CLI command which generates the canonical ZTD TestRowMap from DDL sources. + */ +export function registerZtdConfigCommand(program: Command): void {packages/drivers/pg-testkit/README.md (1)
110-115: Docs inconsistency: prose saysztd/ddl, but example still usessql/ddlThe section updates the recommended location, but the sample code later still builds
ddlPathfrom.../sql/ddl(Line 123). Please update the example toztd/ddlto match the guidance.packages/ztd-cli/src/commands/init.ts (2)
259-273: Bug risk:runGenerateZtdConfig(...)should be awaited (Promise-returning dependency).
Right nowrunInitCommand()can finish before the row-map is actually generated.- dependencies.runGenerateZtdConfig({ + await dependencies.runGenerateZtdConfig({ directories: [path.resolve(path.dirname(absolutePaths.schema))], extensions: DEFAULT_EXTENSIONS, out: absolutePaths.ztdConfig, defaultSchema: projectConfig.ddl.defaultSchema, searchPath: projectConfig.ddl.searchPath });
14-21: Public exports insrc/should have English JSDoc (per repo guidelines).
This file’s exported API surface was modified in this PR; consider adding concise JSDoc forPrompter,createConsolePrompter,runInitCommand,registerInitCommand.Also applies to: 160-166, 705-717
🧹 Nitpick comments (15)
packages/ztd-cli/src/commands/genEntities.ts (1)
32-37: Header path update looks correct; add/confirm JSDoc for exported CLI API nearby.The
tests/generated/ztd-row-map.generated.tsreference aligns with the new generated layout. Separately,export interface GenerateEntitiesOptions(Line 8) andexport function runGenerateEntities(Line 14) are public exports undersrc/and should have brief English JSDoc per guidelines.playgrounds/ztd-playground/README.md (3)
31-33: Tighten wording: CRUD is rewritten; no DDL is issuedThe intent is right, but “fixtures are rewritten into Postgres
SELECTqueries” (Line 31) reads like fixtures themselves are rewritten. Consider wording like “CRUD statements are rewritten into fixture-backedSELECTs” (also consistent with Line 56) to avoid user confusion.Also applies to: 56-56
49-51: Align README guidance with generated helper usageLine 49 says prefer importing from
tests/generated/ztd-row-map.generated.ts—good. Since this is central to the playground workflow, consider explicitly naming the recommended imports (ZtdConfig,ZtdRowShapes,ZtdTableName,tableFixture) to match the established convention. Based on learnings, ...
52-52: “TableNameResolver” is introduced without contextLine 52 references
TableNameResolverbut doesn’t define where it lives or how users interact with it. If it’s internal-only, consider rephrasing generically (“the resolver normalizes…”) or add a short pointer to the module/file so readers can find it.playgrounds/ztd-playground/AGENTS.md (1)
11-16: Parallel-test policy is good; consider adding one line about shared container lifetime + worker count.This is aligned with “single Postgres instance, many connections”. A small addition like “global setup runs once per Vitest run (not per worker)” / “avoid per-file setup” would further reduce accidental regressions.
playgrounds/ztd-playground/tests/support/global-setup.ts (1)
12-29: Prefer returning an async no-op teardown for the “DATABASE_URL already set” pathThis avoids any subtle mismatch with Vitest’s expected teardown signature and keeps both branches symmetric.
export default async function globalSetup() { const configuredUrl = process.env.DATABASE_URL; if (configuredUrl && configuredUrl.length > 0) { - return () => undefined; + return async () => {}; }packages/ztd-cli/templates/tests/support/testkit-client.ts (1)
17-26: INT8 →Numbercan lose precision; confirm IDs won’t exceedNumber.MAX_SAFE_INTEGER.
If fixtures ever use BIGINT values beyond 2^53-1, assertions will get flaky/wrong. If you want to keep “number” shapes, consider documenting the constraint (or parsing tobigint/string instead).playgrounds/ztd-playground/tests/support/testkit-client.ts (1)
13-22: INT8 →Numberprecision risk; validate fixture ID ranges.
If you ever assert on BIGINTs above 2^53-1 you’ll get incorrect values. If that’s out of scope for the playground, a brief comment noting the safe-range assumption would help.playgrounds/ztd-playground/ztd/ddl/ecommerce.sql (1)
1-29: DDL looks coherent; consider a couple optional Postgres best-practice tweaks.
Optional ideas (only if you want the playground schema to model “real-ish” production patterns):
registered_at: considertimestamptz(avoids implicit timezone assumptions).- Add indexes on FK columns (
sales_order.customer_id,sales_order_item.sales_order_id,sales_order_item.product_id) for join-heavy queries.playgrounds/ztd-playground/tests/customer_summary.test.ts (1)
120-120: Minor correction: update comment to reflect customer entity.The comment refers to "per user" but the entity is now "customer". Consider updating for consistency.
Apply this diff:
- // Query the SQL string and assert the aggregate columns per user. + // Query the SQL string and assert the aggregate columns per customer.packages/ztd-cli/templates/AGENTS.md (2)
37-54: Consider adding language identifier to the code block.The fenced code block at line 37 would benefit from a language identifier for better syntax highlighting and tooling support.
Apply this diff:
-``` +```plaintext /ztd /ddl
61-61: Heading level increment.Line 61 jumps from h2 to h3, skipping a level. Consider adjusting to h2 for consistency with markdown best practices.
Apply this diff:
-### 1. Humans own the **definitions** +## 1. Humans own the **definitions**And similarly for the following "### 2." and "### 3." headings.
packages/ztd-cli/templates/README.md (1)
106-130: Optional: reword the repeated “Update …” steps for readability.
(LanguageTool’s “successive sentences begin with the same word” is reasonable here.)packages/ztd-cli/tests/init.command.test.ts (1)
11-16: Optional: consider cleaning up tmp workspaces after tests to avoidtmp/buildup.packages/ztd-cli/src/commands/init.ts (1)
135-140: Optional: derive NEXT_STEPS paths from config (avoid hardcodingztd/ddl).
This keeps messaging correct if defaults change (or users customize dirs).
| const defaultOut = path.join( | ||
| projectConfig.testsDir ?? DEFAULT_TESTS_DIRECTORY, | ||
| 'generated', | ||
| 'ztd-row-map.generated.ts' | ||
| ); | ||
| const output = options.out ?? defaultOut; |
There was a problem hiding this comment.
Ensure parent directory exists for the new tests/generated/... default output path.
If generated/ doesn’t exist, generation can fail depending on how runGenerateZtdConfig() writes the file.
import chokidar from 'chokidar';
+import fs from 'node:fs';
import path from 'node:path';
import { Command } from 'commander';
@@
const output = options.out ?? defaultOut;
+ fs.mkdirSync(path.dirname(output), { recursive: true });📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const defaultOut = path.join( | |
| projectConfig.testsDir ?? DEFAULT_TESTS_DIRECTORY, | |
| 'generated', | |
| 'ztd-row-map.generated.ts' | |
| ); | |
| const output = options.out ?? defaultOut; | |
| import chokidar from 'chokidar'; | |
| import fs from 'node:fs'; | |
| import path from 'node:path'; | |
| import { Command } from 'commander'; | |
| // ... other code ... | |
| const defaultOut = path.join( | |
| projectConfig.testsDir ?? DEFAULT_TESTS_DIRECTORY, | |
| 'generated', | |
| 'ztd-row-map.generated.ts' | |
| ); | |
| const output = options.out ?? defaultOut; | |
| fs.mkdirSync(path.dirname(output), { recursive: true }); |
🤖 Prompt for AI Agents
In packages/ztd-cli/src/commands/ztdConfigCommand.ts around lines 33 to 38, the
code builds a default output path under tests/generated but does not ensure the
parent directory exists; update the logic so that after computing output (or
when output equals the default) you create the parent directory (use
path.dirname(output)) with fs.mkdirSync(dir, { recursive: true }) or the async
equivalent before calling runGenerateZtdConfig(), so file creation won’t fail if
tests/generated is missing.
| export const DEFAULT_ZTD_CONFIG: ZtdProjectConfig = { | ||
| dialect: 'postgres', | ||
| ddlDir: 'sql/ddl', | ||
| ddlDir: 'ztd/ddl', | ||
| testsDir: 'tests', | ||
| ddl: { ...DEFAULT_DDL_PROPERTIES } | ||
| }; |
There was a problem hiding this comment.
Default ddlDir change may break existing projects that relied on defaults
If a repo doesn’t have ztd.config.json (or omits ddlDir), it will now look in ztd/ddl rather than sql/ddl. Consider a migration-friendly fallback (e.g., if ztd/ddl missing but sql/ddl exists) or ensure init always writes an explicit ddlDir into ztd.config.json so upgrades are deterministic. Based on learnings, keep ztd.config.json aligned with the rewrite pipeline search path.
| # AGENTS: Zero Table Dependency Definitions | ||
|
|
There was a problem hiding this comment.
Fix BOM/markdownlint issues (MD038) in the template doc too.
Same as the playground doc: remove BOM, trim code-span spacing, and prefer fenced SQL blocks for the example.
-# AGENTS: Zero Table Dependency Definitions
+# AGENTS: Zero Table Dependency Definitions
@@
-- Use the embedded SQL block (`sql ... `) as the **reference SELECT**.
+- Use the embedded SQL block (`sql ...`) as the **reference SELECT**.
@@
-`sql
-select v.*
-from (
- values
- (1, 'some_code', 'some_label')
-) v(key, value, display_name);
-`
+```sql
+select v.*
+from (
+ values
+ (1, 'some_code', 'some_label')
+) v(key, value, display_name);
+```Also applies to: 37-41, 77-86
🤖 Prompt for AI Agents
In packages/ztd-cli/templates/ztd/AGENTS.md around lines 1-2 (and also apply
changes at 37-41 and 77-86), the template contains a BOM and Markdown lint
issues (MD038), untrimmed code-span spacing, and an inline/non-fenced SQL
example; remove the BOM from the file start, trim unnecessary spaces inside code
spans, and replace the inline SQL example with a properly fenced SQL code block
(```sql ... ```), converting the shown example into a fenced block and ensuring
syntax/indentation is correct for the values(...) example and other similar
examples at the specified line ranges.
| - `sql/enums/` captures domain enums and value lists so downstream tooling uses the same symbols as the fixtures. | ||
| - `sql/domain-specs/` hosts executable SELECT-based specs that describe domain behaviors for humans and AI agents. | ||
| - `tests/ztd-layout.generated.ts` records this layout so the CLI and your tests all resolve DDL, enum, and domain-spec directories consistently when they regenerate `tests/ztd-row-map.generated.ts`. | ||
| - `ztd/ddl/` keeps every CREATE/ALTER TABLE statement along with indexes, constraints, and optional seed rows that make the rewrite pipeline deterministic. Each namespace lives in `ztd/ddl/<schema>.sql`. |
There was a problem hiding this comment.
Clarify “optional seed rows” vs. “don’t put test rows in DDL”
Line 24 implies rows may live in ztd/ddl/*.sql, but the pg-testkit guidance is typically “DDL defines structure; tests provide rows via tableFixture(...) / withFixtures()”. Suggest clarifying that any rows in DDL are baseline/static fixtures only (if supported), and test-specific data must still be provided via fixtures/overlays. Based on learnings, ...
Also applies to: 56-56
🤖 Prompt for AI Agents
In playgrounds/ztd-playground/README.md around lines 24 and 56, the sentence
that says ztd/ddl/ may include "optional seed rows" is ambiguous and conflicts
with the pg-testkit guidance that DDL should only define structure; update both
lines to clarify that any rows in ztd/ddl/<schema>.sql are strictly
baseline/static fixtures used only to make the rewrite pipeline deterministic
(e.g., essential lookup or reference rows), and explicitly state that
test-specific or transient test data must not be placed in DDL files and instead
must be provided via tableFixture(...)/withFixtures() in tests.
| // Provides a per-customer rollup of orders and spend for the EC sample domain. | ||
| export const customerSummarySql = ` | ||
| SELECT | ||
| c.customer_id, | ||
| c.customer_name, | ||
| c.customer_email, | ||
| COUNT(DISTINCT o.sales_order_id) AS total_orders, | ||
| COALESCE(SUM(oi.quantity * oi.unit_price), 0) AS total_amount, | ||
| MAX(o.sales_order_date) AS last_order_date | ||
| FROM customer c | ||
| LEFT JOIN sales_order o ON o.customer_id = c.customer_id | ||
| LEFT JOIN sales_order_item oi ON oi.sales_order_id = o.sales_order_id | ||
| GROUP BY c.customer_id, c.customer_name, c.customer_email | ||
| ORDER BY c.customer_id; | ||
| `; |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Add JSDoc for the exported constant.
The exported constant customerSummarySql in src/ is part of the public API and requires JSDoc documentation per the coding guidelines.
As per coding guidelines, all exported symbols in src/ must have clear English JSDoc. Apply this diff:
-// Provides a per-customer rollup of orders and spend for the EC sample domain.
-export const customerSummarySql = `
+/**
+ * SQL query that provides a per-customer rollup of orders and spend for the EC sample domain.
+ *
+ * Returns columns: customer_id, customer_name, customer_email, total_orders, total_amount, last_order_date.
+ * Includes customers with zero orders via LEFT JOIN.
+ */
+export const customerSummarySql = `📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Provides a per-customer rollup of orders and spend for the EC sample domain. | |
| export const customerSummarySql = ` | |
| SELECT | |
| c.customer_id, | |
| c.customer_name, | |
| c.customer_email, | |
| COUNT(DISTINCT o.sales_order_id) AS total_orders, | |
| COALESCE(SUM(oi.quantity * oi.unit_price), 0) AS total_amount, | |
| MAX(o.sales_order_date) AS last_order_date | |
| FROM customer c | |
| LEFT JOIN sales_order o ON o.customer_id = c.customer_id | |
| LEFT JOIN sales_order_item oi ON oi.sales_order_id = o.sales_order_id | |
| GROUP BY c.customer_id, c.customer_name, c.customer_email | |
| ORDER BY c.customer_id; | |
| `; | |
| /** | |
| * SQL query that provides a per-customer rollup of orders and spend for the EC sample domain. | |
| * | |
| * Returns columns: customer_id, customer_name, customer_email, total_orders, total_amount, last_order_date. | |
| * Includes customers with zero orders via LEFT JOIN. | |
| */ | |
| export const customerSummarySql = ` | |
| SELECT | |
| c.customer_id, | |
| c.customer_name, | |
| c.customer_email, | |
| COUNT(DISTINCT o.sales_order_id) AS total_orders, | |
| COALESCE(SUM(oi.quantity * oi.unit_price), 0) AS total_amount, | |
| MAX(o.sales_order_date) AS last_order_date | |
| FROM customer c | |
| LEFT JOIN sales_order o ON o.customer_id = c.customer_id | |
| LEFT JOIN sales_order_item oi ON oi.sales_order_id = o.sales_order_id | |
| GROUP BY c.customer_id, c.customer_name, c.customer_email | |
| ORDER BY c.customer_id; | |
| `; |
🤖 Prompt for AI Agents
In playgrounds/ztd-playground/src/customer_summary.ts around lines 1 to 15 the
exported constant customerSummarySql has no JSDoc; add a JSDoc block immediately
above the export that briefly describes this constant as the SQL query returning
a per-customer rollup of orders and spend for the EC sample domain, list the
returned columns (customer_id, customer_name, customer_email, total_orders,
total_amount, last_order_date), and include tags such as @constant, @export, and
@type {string} so the exported symbol meets the project's documentation
guidelines.
| // Lists products ordered by cumulative revenue to highlight best sellers. | ||
| export const productRankingSql = ` |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Add JSDoc on exported productRankingSql (public API in src/).
The leading // comment isn’t JSDoc attached to the export; per repo guidelines, exported symbols in src/ should have English JSDoc. As per coding guidelines, ...
-// Lists products ordered by cumulative revenue to highlight best sellers.
+/** Lists products ordered by cumulative revenue to highlight best sellers. */
export const productRankingSql = `📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Lists products ordered by cumulative revenue to highlight best sellers. | |
| export const productRankingSql = ` | |
| /** Lists products ordered by cumulative revenue to highlight best sellers. */ | |
| export const productRankingSql = ` |
🤖 Prompt for AI Agents
In playgrounds/ztd-playground/src/product_ranking.ts around lines 1 to 2, the
exported constant productRankingSql lacks an English JSDoc comment (the current
leading // comment is not JSDoc attached to the export). Add a JSDoc block
directly above the export (/** ... */) describing what productRankingSql
contains, its format (SQL string), and its purpose (lists products ordered by
cumulative revenue to highlight best sellers), and ensure the comment is in
English and follows the repo JSDoc style for exported symbols.
| // Aggregates monthly revenue for the EC domain using order items and order dates. | ||
| export const salesSummarySql = ` |
There was a problem hiding this comment.
Fix stale description + add JSDoc on exported salesSummarySql (public API in src/).
Line 1 is now misleading (uses sales_order_*), and the export should have attached English JSDoc. As per coding guidelines, ...
-// Aggregates monthly revenue for the EC domain using order items and order dates.
+/** Aggregates monthly revenue for the EC domain using sales order items and sales order dates. */
export const salesSummarySql = `📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Aggregates monthly revenue for the EC domain using order items and order dates. | |
| export const salesSummarySql = ` | |
| /** Aggregates monthly revenue for the EC domain using sales order items and sales order dates. */ | |
| export const salesSummarySql = ` |
🤖 Prompt for AI Agents
In playgrounds/ztd-playground/src/sales_summary.ts around lines 1 to 2, the
file-level comment is stale and misleading (references monthly EC domain revenue
but the SQL uses sales_order_* tables) and the exported salesSummarySql lacks a
JSDoc block; update the top-line description to accurately reflect the SQL’s
purpose and source tables, then add an English JSDoc comment immediately above
the export describing what the SQL returns, the fact it’s a string of SQL (no
runtime parameters), expected columns/semantics, and its public API usage; keep
the JSDoc concise and follow existing codebase style.
| # AGENTS: Zero Table Dependency Definitions | ||
|
|
There was a problem hiding this comment.
Fix BOM/markdownlint issues (MD038) to keep docs clean.
- Line 1 appears to include a BOM before
#(can cause odd diffs/rendering). - “
sql ...” has a trailing space inside the code span (MD038). - Consider using a fenced block for the SQL example to avoid ambiguity.
-# AGENTS: Zero Table Dependency Definitions
+# AGENTS: Zero Table Dependency Definitions
@@
-- Use the embedded SQL block (`sql ... `) as the **reference SELECT**.
+- Use the embedded SQL block (`sql ...`) as the **reference SELECT**.
@@
-`sql
-select v.*
-from (
- values
- (1, 'some_code', 'some_label')
-) v(key, value, display_name);
-`
+```sql
+select v.*
+from (
+ values
+ (1, 'some_code', 'some_label')
+) v(key, value, display_name);
+```Also applies to: 37-41, 77-86
🤖 Prompt for AI Agents
In playgrounds/ztd-playground/ztd/AGENTS.md around lines 1-2 (and also apply
changes at lines 37-41 and 77-86): remove the leading BOM from the file so the
first line begins with a plain "#" character, fix any inline code spans like
"sql ... " by removing trailing spaces inside the backticks, and replace the
ambiguous inline/indented SQL snippet with a proper fenced code block (triple
backticks with the language identifier, e.g., ```sql) containing the full
SELECT/VALUES example so there is no trailing-space inside the code span and
markdownlint MD038 is satisfied.
There was a problem hiding this comment.
Actionable comments posted: 7
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/ztd-cli/src/commands/ztdConfigCommand.ts (1)
118-152: Don’t hardcodetests/generated/...in watch logs/errors when--outis customized.
The watch comment + error message imply onlytests/generated/ztd-row-map.generated.tsis overwritten, butoptions.outcan point elsewhere.@@ - // Only the tests/generated/ztd-row-map.generated.ts output is overwritten while watching DDL changes. + // Only the generated output file is overwritten while watching DDL changes. @@ - runGenerateZtdConfig(options); + await runGenerateZtdConfig(options); writeZtdLayoutFile(layoutOut, layoutConfig); console.log(`[watch] Updated: ${options.out}`); } catch (error) { console.error( - `[watch] Failed to regenerate tests/generated/ztd-row-map.generated.ts: ${error instanceof Error ? error.message : String(error)}` + `[watch] Failed to regenerate ${options.out}: ${error instanceof Error ? error.message : String(error)}` ); }Also, since
executeReloadis async, considervoid executeReload(...)at Line 136 to make intent explicit.
♻️ Duplicate comments (3)
playgrounds/ztd-playground/README.md (1)
39-39: Clarify “optional seed rows” vs “no test rows in DDL”
This wording is still easy to read as “it’s OK to put test data in DDL”. Please explicitly state seed rows inztd/ddl/<schema>.sqlare baseline/static only (if supported) and that test-specific/transient rows must be provided viatableFixture(...)/withFixtures()in tests. Based on learnings, ...packages/ztd-cli/templates/ztd/AGENTS.md (1)
1-2: Remove BOM + replace inlinesql ...blocks with fenced ```sql (markdownlint/MD038).Same as the earlier review: remove the BOM at file start, trim the code-span spacing at Line 44, and convert the inline SQL example to a proper fenced SQL block (also applies to the enum example section).
-# AGENTS: Zero Table Dependency Definitions +# AGENTS: Zero Table Dependency Definitions @@ -- Use the embedded SQL block (`sql ... `) as the **reference SELECT**. +- Use the embedded SQL block (`sql ...`) as the **reference SELECT**. @@ -`sql -select v.* -from ( - values - (1, 'some_code', 'some_label') -) v(key, value, display_name); -` +```sql +select v.* +from ( + values + (1, 'some_code', 'some_label') +) v(key, value, display_name); +```Also applies to: 43-46, 84-92
packages/ztd-cli/src/commands/ztdConfigCommand.ts (1)
63-70: Ensuretests/generated/exists before generating the row-map (still a potential failure).
Right nowwriteZtdLayoutFile()creates the directory, but it runs afterrunGenerateZtdConfig(), so the row-map generation can still fail on a fresh project. This matches the earlier review note.@@ const output = options.out ?? defaultOut; const layoutOut = path.join(path.dirname(output), 'ztd-layout.generated.ts'); + ensureDirectory(path.dirname(output)); @@ - runGenerateZtdConfig(generationOptions); + await runGenerateZtdConfig(generationOptions); const layoutConfig: ZtdProjectConfig = { ...projectConfig, ddl: ddlOverrides }; writeZtdLayoutFile(layoutOut, layoutConfig);Also applies to: 97-100
🧹 Nitpick comments (9)
.github/workflows/pr-check.yml (2)
29-46: Duplicate build work inquick-check(targeted builds +pnpm -r run build).
Right now you buildrawsql-ts,@rawsql-ts/testkit-core,@rawsql-ts/ztd-cli, and then later build everything again withpnpm -r run build, which likely increases CI time a lot.Options:
- drop the targeted build step and rely on
pnpm -r run build, or- keep targeted builds and remove the recursive build, or
- narrow the recursive build to what you actually need for “quick-check”.
50-52: Remove “prisma-integration removed” placeholder steps (or gate them).
These steps don’t validate anything and can be dropped to reduce noise; if you want a reminder, consider tracking it in a PR/issue instead.Also applies to: 80-81
packages/ztd-cli/templates/README.md (1)
20-33: Iftests/generated/“must never be committed”, also call out.gitignore.Right now it’s easy for users to miss the practical enforcement step. Consider a one-liner like: “Ensure
tests/generated/is in.gitignore(the template should already do this).”packages/ztd-cli/README.md (1)
42-43: Consider explicitly mentioning.gitignorefortests/generated/here too (optional).You already say “never commit”; a short pointer like “(ensure it’s gitignored)” reduces accidental commits.
playgrounds/ztd-playground/AGENTS.md (2)
25-30: Consider adding an explicit “exception/guardrail” note for parallelismPolicy reads good, but it’d be stronger if it explicitly called out that any test bypassing pg-testkit (direct
pgqueries / DDL) breaks the parallel-safety assumption—optionally link to the helper as the enforced path.
35-41: Minor clarity: distinguish “canonical typed API” vs “source inputs”Calling
tests/generated/ztd-row-map.generated.tsthe “canonical source” (Line 36) may confuse readers since the real inputs live underztd/. Consider wording like “canonical typed fixture API for tests.”packages/ztd-cli/src/commands/ztdConfigCommand.ts (1)
21-47: Make layout snapshot emission resilient to edge ddlDir shapes (e.g.,ddlDir=ddl, trailing slashes).
path.posix.dirname()will yield'.'for single-segment paths; consider normalizing to avoid emittingztdRootDir: "."unexpectedly.packages/ztd-cli/src/commands/init.ts (2)
289-375: Template-vs-generator drift risk fortests/generated/ztd-layout.generated.ts.
ztd-confignow emits a canonical layout snapshot, butinitalso seeds a layout file from a template; if the template ever diverges, users will see confusing diffs/overwrites right after runningnpx ztd ztd-config. Consider generating this via the same render logic (shared util) instead of a static template.
Based on learnings (layout file should be CLI-generated, not hand-edited).
618-682: Fallback write behavior is reasonable; tightenisRootMarkdown()to be path-separator agnostic.
isRootMarkdown()checks!relative.includes('/'); if any caller ever passes un-normalized Windows separators, fallback won’t trigger. Consider normalizing or checking both separators.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
packages/ztd-cli/templates/tests/generated/ztd-layout.generated.tsis excluded by!**/generated/**packages/ztd-cli/tests/__snapshots__/cliCommands.test.ts.snapis excluded by!**/*.snappackages/ztd-cli/tests/__snapshots__/init.command.test.ts.snapis excluded by!**/*.snappackages/ztd-cli/tests/__snapshots__/ztdConfig.unit.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (17)
.github/workflows/pr-check.yml(4 hunks).gitignore(1 hunks)eslint.config.mjs(1 hunks)packages/ztd-cli/README.md(3 hunks)packages/ztd-cli/src/commands/init.ts(10 hunks)packages/ztd-cli/src/commands/ztdConfig.ts(1 hunks)packages/ztd-cli/src/commands/ztdConfigCommand.ts(5 hunks)packages/ztd-cli/templates/.gitignore(1 hunks)packages/ztd-cli/templates/.prettierignore(1 hunks)packages/ztd-cli/templates/AGENTS.md(1 hunks)packages/ztd-cli/templates/README.md(1 hunks)packages/ztd-cli/templates/tests/support/testkit-client.ts(3 hunks)packages/ztd-cli/templates/ztd/AGENTS.md(1 hunks)playgrounds/ztd-playground/.gitignore(1 hunks)playgrounds/ztd-playground/.prettierignore(1 hunks)playgrounds/ztd-playground/AGENTS.md(2 hunks)playgrounds/ztd-playground/README.md(2 hunks)
✅ Files skipped from review due to trivial changes (5)
- packages/ztd-cli/templates/.gitignore
- packages/ztd-cli/templates/.prettierignore
- playgrounds/ztd-playground/.gitignore
- .gitignore
- playgrounds/ztd-playground/.prettierignore
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Remove console debugging before committing.
Files:
packages/ztd-cli/src/commands/ztdConfig.tspackages/ztd-cli/src/commands/ztdConfigCommand.tspackages/ztd-cli/templates/tests/support/testkit-client.tspackages/ztd-cli/src/commands/init.ts
**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/src/**/*.{ts,tsx}: All exported classes, functions, and types insrc/are considered part of the public API and must have clear English JSDoc attached to their declaration.
When adding a new exported symbol insrc/(class, function, type, interface, enum, etc.), always add English JSDoc in the same commit that briefly explains the role of the API and how to consume it.
When modifying an exported symbol, update the existing docstring to keep it truthful and never delete a docstring merely to keep the diff small.
If a helper is not meant to be public, make it non-exported or add@internalto its docstring rather than leaving an undocumented export.
Files:
packages/ztd-cli/src/commands/ztdConfig.tspackages/ztd-cli/src/commands/ztdConfigCommand.tspackages/ztd-cli/src/commands/init.ts
🧠 Learnings (68)
📓 Common learnings
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Adapt `testkit-core` rewrite results to PostgreSQL in pg-testkit implementation
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Load DDL-based fixtures using DDLToFixtureConverter when projects contain `tests/ztd-row-map.generated.ts` and `sql/ddl/` directory
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Rewrite all CRUD statements (INSERT, UPDATE, DELETE) to fixture-backed SELECT queries before execution in pg-testkit
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Execute rewritten SELECT queries against a live pg client/pool in pg-testkit
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Implement `.withFixtures()` overlay on pg-testkit clients to apply scenario-specific rows while maintaining fixture precedence
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Use `createPgTestkitClient` to lazily open a pg connection and ensure every `.query` call goes through rewrite + fixture application
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{tests,test,__tests__}/**/*.{ts,tsx,js} : Provide test-specific rows via `tableRows` or `withFixtures()` rather than in DDL schema files when using pg-testkit
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Maintain fixture precedence order in pg-testkit: DDL fixtures (schema + shared seed rows) → Manual fixtures (`tableDefinitions`, `tableRows`) → Scoped fixtures (`client.withFixtures()`), where later layers override earlier ones
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{tests,test,__tests__}/**/*.{ts,tsx,js} : Ensure all added features have tests in `tests/` directory when contributing to pg-testkit
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.{ts,tsx} : Always wire Postgres execution through `tests/testkit-client.ts`, which opens a `pg.Client`, passes it into `rawsql-ts/pg-testkit`, and shares the connection across tests.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Treat `tests/ztd-row-map.generated.ts` and `sql/ddl/` (or legacy `ddl/`) directory as canonical schema and row map; load fixtures from them rather than reverse-engineering the database structure
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/sql/**/*.sql : Keep every table definition inside `sql/ddl/<schema>.sql`, enums under `sql/enums/*.sql`, and executable specs inside `sql/domain-specs/*.sql`.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Keep the playground minimal by only including DDL files, minimal SQL examples in `src/`, and ZTD-focused tests under `tests/`; avoid adding application logic, persistence layers, or business services.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.{ts,tsx} : Import `ZtdConfig`, `ZtdRowShapes`, `ZtdTableName`, and `tableFixture()` from `tests/ztd-row-map.generated.ts` and trust the generated helpers for row shapes instead of duplicating row interfaces inside tests.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/sql/ddl/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:47.153Z
Learning: Applies to playgrounds/ztd-playground/sql/ddl/sql/ddl/**/*.sql : Store table structure definitions (CREATE TABLE, ALTER TABLE, indexes, constraints) in SQL files under `sql/ddl/<schema>.sql`
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Applies to ztd.config.json : Update `ztd.config.json` whenever you change the target schema or search path so the rewrite pipeline still matches tables as expected.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Applies to ztd.config.json : Application SQL can omit schema qualifiers (e.g., `SELECT ... FROM users`). pg-testkit maps those references to canonical `schema.table` keys by consulting the `ddl.defaultSchema` / `ddl.searchPath` block in `ztd.config.json` before looking up fixtures or DDL metadata.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/ztd-layout.generated.ts : Do not hand-edit `tests/ztd-layout.generated.ts`; regenerate it with `pnpm playground:gen-config` (or `pnpm --filter ztd-playground exec ztd ztd-config`) so the CLI and tests stay aligned.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/ztd-cli/templates/sql/ddl/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:22.166Z
Learning: Applies to packages/ztd-cli/templates/sql/ddl/**/*ddl*/**/*.sql : SQL files in the DDL Definitions folder are the single source of truth for table structures (CREATE TABLE, ALTER TABLE, indexes, constraints)
📚 Learning: 2025-12-02T22:58:15.347Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/testkit-core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:58:15.347Z
Learning: Applies to packages/testkit-core/src/**/*.{ts,tsx} : Add metadata to SelectAnalyzer instead of re-parsing or creating ad-hoc regex logic when extending rewrite capability in testkit-core
Applied to files:
eslint.config.mjs
📚 Learning: 2025-12-02T22:58:15.347Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/testkit-core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:58:15.347Z
Learning: Applies to packages/testkit-core/src/**/*.{ts,tsx} : Preserve original whitespace between statements and do not reorder statements when reassembling multi-statement rewrites in testkit-core
Applied to files:
eslint.config.mjspackages/ztd-cli/src/commands/ztdConfig.ts
📚 Learning: 2025-12-02T22:58:15.347Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/testkit-core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:58:15.347Z
Learning: Applies to packages/testkit-core/tests/**/*.{test,spec}.{ts,tsx} : Add test coverage for fixture resolution paths, CRUD rewrite transformations, CTE + multi-statement handling, fallback logic, identifier casing rules, and error diagnostics in testkit-core
Applied to files:
eslint.config.mjsplaygrounds/ztd-playground/AGENTS.md.github/workflows/pr-check.ymlpackages/ztd-cli/src/commands/ztdConfigCommand.tspackages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-10T22:55:41.604Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/ztd-layout.generated.ts : Do not hand-edit `tests/ztd-layout.generated.ts`; regenerate it with `pnpm playground:gen-config` (or `pnpm --filter ztd-playground exec ztd ztd-config`) so the CLI and tests stay aligned.
Applied to files:
eslint.config.mjspackages/ztd-cli/README.mdpackages/ztd-cli/templates/README.mdpackages/ztd-cli/src/commands/ztdConfig.tsplaygrounds/ztd-playground/README.mdplaygrounds/ztd-playground/AGENTS.md.github/workflows/pr-check.ymlpackages/ztd-cli/src/commands/ztdConfigCommand.tspackages/ztd-cli/templates/ztd/AGENTS.mdpackages/ztd-cli/src/commands/init.tspackages/ztd-cli/templates/AGENTS.md
📚 Learning: 2025-12-02T22:57:21.022Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:21.022Z
Learning: Applies to packages/core/**/*.{test,spec}.ts : Add or update tests whenever adding features or fixing bugs
Applied to files:
eslint.config.mjspackages/ztd-cli/src/commands/ztdConfigCommand.ts
📚 Learning: 2025-12-02T22:57:21.022Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:21.022Z
Learning: Applies to packages/core/build.*.js : Use esbuild with --minify-syntax --minify-whitespace for bundling; avoid --minify-identifiers as it breaks comment bookkeeping and named exports
Applied to files:
eslint.config.mjs
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Do not reconstruct DDL or row-type definitions inside pg-testkit when the project already ships `tests/ztd-row-map.generated.ts`; rely on the generated TestRowMap instead
Applied to files:
eslint.config.mjspackages/ztd-cli/README.mdpackages/ztd-cli/templates/README.mdpackages/ztd-cli/src/commands/ztdConfig.tsplaygrounds/ztd-playground/README.mdplaygrounds/ztd-playground/AGENTS.md.github/workflows/pr-check.ymlpackages/ztd-cli/src/commands/ztdConfigCommand.tspackages/ztd-cli/templates/tests/support/testkit-client.tspackages/ztd-cli/src/commands/init.tspackages/ztd-cli/templates/AGENTS.md
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Emit debug traces in pg-testkit when fallback paths trigger, analyzer limitations appear, or fixture mismatches surface
Applied to files:
eslint.config.mjspackages/ztd-cli/src/commands/ztdConfigCommand.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{tests,test,__tests__}/**/*.{ts,tsx,js} : Ensure all added features have tests in `tests/` directory when contributing to pg-testkit
Applied to files:
eslint.config.mjs.github/workflows/pr-check.ymlpackages/ztd-cli/src/commands/ztdConfigCommand.tspackages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-02T22:57:55.637Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/sqlite-testkit/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:55.637Z
Learning: Applies to packages/drivers/sqlite-testkit/src/**/*.{ts,tsx,js} : No stray console.log or temp files outside ./tmp/ directory
Applied to files:
eslint.config.mjspackages/ztd-cli/src/commands/ztdConfigCommand.tspackages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Support full parallel test execution in pg-testkit with no shared state
Applied to files:
eslint.config.mjspackages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-08T14:13:45.136Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Remove console debugging before committing.
Applied to files:
eslint.config.mjs
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Never create or mutate real tables in pg-testkit; prohibit `CREATE TABLE`, `ALTER TABLE`, and migrations
Applied to files:
eslint.config.mjs
📚 Learning: 2025-12-02T22:57:21.022Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:21.022Z
Learning: Applies to packages/core/src/**/*.ts : Ensure TypeScript errors stay at zero before running tests
Applied to files:
eslint.config.mjs
📚 Learning: 2025-12-02T22:57:55.637Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/sqlite-testkit/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:55.637Z
Learning: Applies to packages/drivers/sqlite-testkit/src/**/*.{ts,tsx} : No code path bypasses testkit-core's rewrite pipeline
Applied to files:
eslint.config.mjs
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Do not introduce rewrite logic inside pg-testkit; rewrite logic belongs exclusively in testkit-core
Applied to files:
eslint.config.mjspackages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-10T22:55:41.604Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.{ts,tsx} : Import `ZtdConfig`, `ZtdRowShapes`, `ZtdTableName`, and `tableFixture()` from `tests/ztd-row-map.generated.ts` and trust the generated helpers for row shapes instead of duplicating row interfaces inside tests.
Applied to files:
packages/ztd-cli/README.mdpackages/ztd-cli/templates/README.mdpackages/ztd-cli/src/commands/ztdConfig.tsplaygrounds/ztd-playground/README.mdplaygrounds/ztd-playground/AGENTS.md.github/workflows/pr-check.ymlpackages/ztd-cli/src/commands/ztdConfigCommand.tspackages/ztd-cli/src/commands/init.tspackages/ztd-cli/templates/AGENTS.md
📚 Learning: 2025-12-08T14:13:45.136Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Applies to ztd.config.json : Update `ztd.config.json` whenever you change the target schema or search path so the rewrite pipeline still matches tables as expected.
Applied to files:
packages/ztd-cli/README.mdpackages/ztd-cli/templates/README.mdpackages/ztd-cli/src/commands/ztdConfig.tspackages/ztd-cli/src/commands/ztdConfigCommand.tspackages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Load DDL-based fixtures using DDLToFixtureConverter when projects contain `tests/ztd-row-map.generated.ts` and `sql/ddl/` directory
Applied to files:
packages/ztd-cli/README.mdpackages/ztd-cli/templates/README.mdpackages/ztd-cli/src/commands/ztdConfig.tsplaygrounds/ztd-playground/README.mdplaygrounds/ztd-playground/AGENTS.md.github/workflows/pr-check.ymlpackages/ztd-cli/src/commands/ztdConfigCommand.tspackages/ztd-cli/templates/tests/support/testkit-client.tspackages/ztd-cli/templates/ztd/AGENTS.mdpackages/ztd-cli/src/commands/init.tspackages/ztd-cli/templates/AGENTS.md
📚 Learning: 2025-12-10T22:55:41.604Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Keep the playground minimal by only including DDL files, minimal SQL examples in `src/`, and ZTD-focused tests under `tests/`; avoid adding application logic, persistence layers, or business services.
Applied to files:
packages/ztd-cli/README.mdpackages/ztd-cli/templates/README.mdplaygrounds/ztd-playground/README.mdplaygrounds/ztd-playground/AGENTS.mdpackages/ztd-cli/templates/ztd/AGENTS.mdpackages/ztd-cli/templates/AGENTS.md
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Treat `tests/ztd-row-map.generated.ts` and `sql/ddl/` (or legacy `ddl/`) directory as canonical schema and row map; load fixtures from them rather than reverse-engineering the database structure
Applied to files:
packages/ztd-cli/README.mdpackages/ztd-cli/templates/README.mdpackages/ztd-cli/src/commands/ztdConfig.tsplaygrounds/ztd-playground/README.mdplaygrounds/ztd-playground/AGENTS.mdpackages/ztd-cli/src/commands/ztdConfigCommand.tspackages/ztd-cli/templates/ztd/AGENTS.mdpackages/ztd-cli/src/commands/init.tspackages/ztd-cli/templates/AGENTS.md
📚 Learning: 2025-12-10T22:55:22.166Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/ztd-cli/templates/sql/ddl/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:22.166Z
Learning: Applies to packages/ztd-cli/templates/sql/ddl/**/*ddl*/**/*.sql : SQL files in the DDL Definitions folder are the single source of truth for table structures (CREATE TABLE, ALTER TABLE, indexes, constraints)
Applied to files:
packages/ztd-cli/README.mdpackages/ztd-cli/templates/README.mdpackages/ztd-cli/src/commands/ztdConfigCommand.tspackages/ztd-cli/templates/ztd/AGENTS.mdpackages/ztd-cli/templates/AGENTS.md
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Rewrite all CRUD statements (INSERT, UPDATE, DELETE) to fixture-backed SELECT queries before execution in pg-testkit
Applied to files:
packages/ztd-cli/README.md.github/workflows/pr-check.ymlpackages/ztd-cli/templates/tests/support/testkit-client.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Parse DDL files once per client/pool instance in pg-testkit to produce fixture schema and baseline fixture rows deterministically
Applied to files:
packages/ztd-cli/README.mdpackages/ztd-cli/src/commands/ztdConfig.tsplaygrounds/ztd-playground/README.mdplaygrounds/ztd-playground/AGENTS.mdpackages/ztd-cli/src/commands/ztdConfigCommand.tspackages/ztd-cli/templates/tests/support/testkit-client.tspackages/ztd-cli/templates/ztd/AGENTS.mdpackages/ztd-cli/src/commands/init.tspackages/ztd-cli/templates/AGENTS.md
📚 Learning: 2025-12-02T22:58:15.347Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/testkit-core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:58:15.347Z
Learning: The core role of rawsql-ts/testkit-core is to rewrite all CRUD SQL into fixture-backed SELECT queries without creating, reading, or mutating physical tables
Applied to files:
packages/ztd-cli/README.md
📚 Learning: 2025-12-10T22:55:41.604Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.{ts,tsx} : Never issue DDL statements against Postgres from the playground. All CRUD operations must flow through pg-testkit so they resolve to fixture-backed `SELECT` queries.
Applied to files:
packages/ztd-cli/README.mdplaygrounds/ztd-playground/README.mdplaygrounds/ztd-playground/AGENTS.mdpackages/ztd-cli/templates/tests/support/testkit-client.tspackages/ztd-cli/templates/AGENTS.md
📚 Learning: 2025-12-08T14:13:45.136Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Applies to ztd.config.json : Application SQL can omit schema qualifiers (e.g., `SELECT ... FROM users`). pg-testkit maps those references to canonical `schema.table` keys by consulting the `ddl.defaultSchema` / `ddl.searchPath` block in `ztd.config.json` before looking up fixtures or DDL metadata.
Applied to files:
packages/ztd-cli/README.mdpackages/ztd-cli/templates/README.mdplaygrounds/ztd-playground/README.mdpackages/ztd-cli/src/commands/init.tspackages/ztd-cli/templates/AGENTS.md
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{tests,test,__tests__}/**/*.{ts,tsx,js} : Provide test-specific rows via `tableRows` or `withFixtures()` rather than in DDL schema files when using pg-testkit
Applied to files:
packages/ztd-cli/README.mdpackages/ztd-cli/src/commands/ztdConfig.tsplaygrounds/ztd-playground/README.mdplaygrounds/ztd-playground/AGENTS.mdpackages/ztd-cli/src/commands/ztdConfigCommand.tspackages/ztd-cli/templates/tests/support/testkit-client.tspackages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-10T22:55:47.153Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/sql/ddl/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:47.153Z
Learning: Applies to playgrounds/ztd-playground/sql/ddl/sql/ddl/**/*.sql : Store table structure definitions (CREATE TABLE, ALTER TABLE, indexes, constraints) in SQL files under `sql/ddl/<schema>.sql`
Applied to files:
packages/ztd-cli/README.mdpackages/ztd-cli/templates/README.mdplaygrounds/ztd-playground/AGENTS.mdpackages/ztd-cli/templates/ztd/AGENTS.md
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/sql/ddl/**/*.sql : Use DDL files only for canonical schema information and true shared baseline data; do not put per-test seeds inside schema files in pg-testkit
Applied to files:
packages/ztd-cli/README.mdplaygrounds/ztd-playground/README.md
📚 Learning: 2025-12-10T22:55:41.604Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/sql/**/*.sql : Keep every table definition inside `sql/ddl/<schema>.sql`, enums under `sql/enums/*.sql`, and executable specs inside `sql/domain-specs/*.sql`.
Applied to files:
packages/ztd-cli/README.mdpackages/ztd-cli/templates/README.mdplaygrounds/ztd-playground/README.mdplaygrounds/ztd-playground/AGENTS.mdpackages/ztd-cli/templates/ztd/AGENTS.mdpackages/ztd-cli/templates/AGENTS.md
📚 Learning: 2025-12-10T22:55:47.153Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/sql/ddl/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:47.153Z
Learning: Reference the `sql/ddl/` directory when modifying or understanding table structures
Applied to files:
packages/ztd-cli/README.mdpackages/ztd-cli/templates/README.mdpackages/ztd-cli/templates/ztd/AGENTS.md
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Only allow `CREATE TEMP TABLE … AS SELECT` DDL; block or ignore all other DDL statements in pg-testkit
Applied to files:
packages/ztd-cli/README.md
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Maintain fixture precedence order in pg-testkit: DDL fixtures (schema + shared seed rows) → Manual fixtures (`tableDefinitions`, `tableRows`) → Scoped fixtures (`client.withFixtures()`), where later layers override earlier ones
Applied to files:
packages/ztd-cli/README.mdplaygrounds/ztd-playground/README.mdpackages/ztd-cli/src/commands/ztdConfigCommand.tspackages/ztd-cli/templates/tests/support/testkit-client.ts
📚 Learning: 2025-12-02T22:57:21.022Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:21.022Z
Learning: Applies to packages/core/src/**/*.ts : Keep all comments and identifiers in English
Applied to files:
packages/ztd-cli/src/commands/ztdConfig.ts
📚 Learning: 2025-12-02T22:57:21.022Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:21.022Z
Learning: Applies to packages/core/**/*.{test,spec}.ts : Regression testing for complex SQL should achieve ≥95% comment preservation, no token splits like table. /* comment */ column, and CASE expression comments preserved in evaluation order
Applied to files:
packages/ztd-cli/src/commands/ztdConfig.ts
📚 Learning: 2025-12-02T22:58:15.347Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/testkit-core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:58:15.347Z
Learning: Applies to packages/testkit-core/src/**/*.{ts,tsx} : UPDATE rewrites should apply updates to fixture snapshot and project updated rows via SELECT
Applied to files:
packages/ztd-cli/src/commands/ztdConfig.tspackages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-10T22:55:41.604Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.{ts,tsx} : Provide explicit fixtures for each test using `tableFixture('schema.table', [{ ... }])`; do not reuse shared mutable data between tests and do not insert, update, or delete data directly; rely on the rewrite helper instead.
Applied to files:
packages/ztd-cli/src/commands/ztdConfig.tsplaygrounds/ztd-playground/README.mdplaygrounds/ztd-playground/AGENTS.mdpackages/ztd-cli/templates/tests/support/testkit-client.tspackages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-02T22:58:15.347Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/testkit-core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:58:15.347Z
Learning: Applies to packages/testkit-core/src/**/*.{ts,tsx} : FixtureStore.describeColumns must surface table names, available columns, and suggested hints for error diagnostics
Applied to files:
packages/ztd-cli/src/commands/ztdConfig.ts
📚 Learning: 2025-12-02T22:57:55.637Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/sqlite-testkit/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:55.637Z
Learning: Applies to packages/drivers/sqlite-testkit/src/**/*.{ts,tsx} : Do not rely on real table state between queries even for in-memory databases; all perceived state must originate from fixtures supplied to the driver
Applied to files:
packages/ztd-cli/src/commands/ztdConfig.ts
📚 Learning: 2025-12-10T22:55:41.604Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.{ts,tsx} : Always wire Postgres execution through `tests/testkit-client.ts`, which opens a `pg.Client`, passes it into `rawsql-ts/pg-testkit`, and shares the connection across tests.
Applied to files:
playgrounds/ztd-playground/README.mdplaygrounds/ztd-playground/AGENTS.mdpackages/ztd-cli/templates/tests/support/testkit-client.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Use `createPgTestkitClient` to lazily open a pg connection and ensure every `.query` call goes through rewrite + fixture application
Applied to files:
playgrounds/ztd-playground/README.mdpackages/ztd-cli/templates/tests/support/testkit-client.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Adapt `testkit-core` rewrite results to PostgreSQL in pg-testkit implementation
Applied to files:
playgrounds/ztd-playground/AGENTS.mdpackages/ztd-cli/templates/tests/support/testkit-client.tspackages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-08T14:13:45.136Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Validation checklist: Run `pnpm lint`, `pnpm test` or `pnpm --filter <pkg> test`, `pnpm build`, and run benchmarks for SQL-rewriter changes when relevant.
Applied to files:
playgrounds/ztd-playground/AGENTS.md.github/workflows/pr-check.yml
📚 Learning: 2025-12-08T14:13:45.136Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Applies to packages/pg-testkit/src/**/*.{ts,tsx} : Application SQL may freely use normal CRUD (`INSERT`, `UPDATE`, `DELETE`). pg-testkit will automatically rewrite them into `SELECT` queries. Library code must never bypass the rewriter.
Applied to files:
playgrounds/ztd-playground/AGENTS.md
📚 Learning: 2025-12-08T14:13:45.136Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Applies to {packages/core,packages/testkit-core,packages/pg-testkit,packages/sqlite-testkit}/src/**/*.{ts,tsx} : All SQL rewrites must rely on `rawsql-ts` AST utilities (parser, analyzer, splitQueries). Regex-based rewrites are allowed only as guarded fallbacks with comments explaining why. Block contributions introducing regex parsing when an AST alternative exists.
Applied to files:
playgrounds/ztd-playground/AGENTS.md
📚 Learning: 2025-12-02T22:57:55.637Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/sqlite-testkit/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:55.637Z
Learning: Applies to packages/drivers/sqlite-testkit/src/**/*.{ts,tsx,js} : All SQL must flow through the testkit-core AST rewriter before execution; new rewrite behavior must be added to testkit-core first, then threaded into sqlite-testkit
Applied to files:
playgrounds/ztd-playground/AGENTS.mdpackages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-08T14:13:45.136Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Ensure `packages/core/dist` outputs stay synchronized with the pnpm store copy that CLI tests consume. Run `pnpm --filter rawsql-ts build` which executes `scripts/sync-rawsql-dist.js` as a `postbuild` step.
Applied to files:
.github/workflows/pr-check.yml
📚 Learning: 2025-12-02T22:57:21.022Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:21.022Z
Learning: Run pnpm --filter rawsql-ts test && pnpm --filter rawsql-ts build && pnpm --filter rawsql-ts lint before committing
Applied to files:
.github/workflows/pr-check.yml
📚 Learning: 2025-12-02T22:57:21.022Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:21.022Z
Learning: Applies to packages/core/src/**/*.ts : Refactor for clarity and document public APIs before running the validation pipeline
Applied to files:
.github/workflows/pr-check.ymlpackages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-08T14:13:45.136Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Use `pnpm` and `pnpm --filter <package>` for scoped tasks.
Applied to files:
.github/workflows/pr-check.yml
📚 Learning: 2025-12-02T22:57:21.022Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:21.022Z
Learning: After formatter export changes, run pnpm --filter rawsql-ts build:browser
Applied to files:
.github/workflows/pr-check.yml
📚 Learning: 2025-12-02T22:58:15.347Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/testkit-core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:58:15.347Z
Learning: Applies to packages/testkit-core/src/**/*.{ts,tsx} : In rawsql-ts/testkit-core, remain DBMS-agnostic with no Postgres/SQLite conditionals or behavior
Applied to files:
packages/ztd-cli/templates/tests/support/testkit-client.tspackages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-08T14:13:45.136Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Applies to {packages/pg-testkit,packages/sqlite-testkit}/**/*.test.{ts,tsx} : Do not treat the backing DB as a migration target. The DB engine is only for planning/type-checking. Never execute `CREATE TABLE`, `ALTER TABLE`, or seed `INSERT`s over a pg-testkit connection.
Applied to files:
packages/ztd-cli/templates/tests/support/testkit-client.ts
📚 Learning: 2025-12-02T22:58:15.347Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/testkit-core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:58:15.347Z
Learning: Applies to packages/testkit-core/src/**/*.{ts,tsx} : Do not use DBMS branching (if postgres, if sqlite, etc.) in testkit-core implementation
Applied to files:
packages/ztd-cli/templates/tests/support/testkit-client.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{tests,test,__tests__}/**/*.{ts,tsx,js} : Use a real PostgreSQL Testcontainers instance (`testcontainers/postgresql`) for pg-testkit tests
Applied to files:
packages/ztd-cli/templates/tests/support/testkit-client.ts
📚 Learning: 2025-12-10T22:55:41.604Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Set `DATABASE_URL` environment variable before running `pnpm playground:test` or any spec that touches the testkit helper; the helper throws a clear error when it is missing.
Applied to files:
packages/ztd-cli/templates/tests/support/testkit-client.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Execute rewritten SELECT queries against a live pg client/pool in pg-testkit
Applied to files:
packages/ztd-cli/templates/tests/support/testkit-client.ts
📚 Learning: 2025-12-02T22:57:55.637Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/sqlite-testkit/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:55.637Z
Learning: Applies to packages/drivers/sqlite-testkit/src/**/*.{ts,tsx} : Supported runtime is Node 20+; optional features must degrade gracefully on other platforms or Node versions
Applied to files:
packages/ztd-cli/templates/tests/support/testkit-client.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Preserve full API surface (`.query`, `.connect`, `.release`) when wrapping an existing client or pool with `wrapPgClient`
Applied to files:
packages/ztd-cli/templates/tests/support/testkit-client.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Implement `.withFixtures()` overlay on pg-testkit clients to apply scenario-specific rows while maintaining fixture precedence
Applied to files:
packages/ztd-cli/templates/tests/support/testkit-client.ts
📚 Learning: 2025-12-02T22:57:55.637Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/sqlite-testkit/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:55.637Z
Learning: Applies to packages/drivers/sqlite-testkit/src/**/*.{ts,tsx} : Validate fixtures at construction time to keep per-query interception fast; respect passthrough tables and wildcard overrides driven by testkit-core
Applied to files:
packages/ztd-cli/templates/tests/support/testkit-client.ts
📚 Learning: 2025-12-08T14:13:45.136Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Document any deviations from the standard formatting workflow in AGENTS so AI contributors understand that formatting is owned by the scripts, not by hand edits.
Applied to files:
packages/ztd-cli/templates/ztd/AGENTS.mdpackages/ztd-cli/templates/AGENTS.md
📚 Learning: 2025-12-10T22:55:31.019Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/ztd-cli/templates/sql/enums/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:31.019Z
Learning: Applies to packages/ztd-cli/templates/sql/enums/**/domain/**/*.{sql,values} : Store ENUM-like domain definitions using simple SQL-like VALUES syntax in domain enum files
Applied to files:
packages/ztd-cli/templates/ztd/AGENTS.md
📚 Learning: 2025-12-09T12:47:43.264Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/sql/domain-specs/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:43.264Z
Learning: Applies to playgrounds/ztd-playground/sql/domain-specs/sql/domain-specs/** : Store SQL SELECT specifications that describe domain behaviors under `sql/domain-specs/`. Each file must contain a complete executable SELECT statement.
Applied to files:
packages/ztd-cli/templates/ztd/AGENTS.md
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Include actionable hints (table/column names) in error messages for pg-testkit
Applied to files:
packages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-02T22:57:55.637Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/sqlite-testkit/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:55.637Z
Learning: Applies to packages/drivers/sqlite-testkit/src/**/*.test.{ts,tsx} : Ensure tests remain deterministic regardless of file-backed vs. memory-backed SQLite configurations
Applied to files:
packages/ztd-cli/src/commands/init.ts
🧬 Code graph analysis (1)
packages/ztd-cli/src/commands/ztdConfigCommand.ts (4)
packages/ztd-cli/src/utils/ztdProjectConfig.ts (1)
ZtdProjectConfig(13-22)packages/ztd-cli/src/utils/fs.ts (1)
ensureDirectory(3-10)packages/ztd-cli/src/commands/options.ts (1)
DEFAULT_TESTS_DIRECTORY(3-3)packages/ztd-cli/src/commands/ztdConfig.ts (1)
ZtdConfigGenerationOptions(14-20)
🪛 LanguageTool
packages/ztd-cli/README.md
[grammar] ~176-~176: Ensure spelling is correct
Context: ...ventions for AI agents, including which testkit to use, how to treat `tests/generated/z...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
packages/ztd-cli/templates/README.md
[style] ~132-~132: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... repository SQL if behaviors change. 5. Update fixtures and tests. ## For domain-spec...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~139-~139: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ntics. 3. Update tests and fixtures. 4. Update DDL only if the new behavior requires s...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/ztd-cli/templates/ztd/AGENTS.md
[grammar] ~97-~97: Ensure spelling is correct
Context: ...rendering or sorting). ### Use in Code Generation - Use these enums when generating SQL WHE...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
packages/ztd-cli/templates/AGENTS.md
[style] ~160-~160: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ry SQL to reflect the new semantics. 3. Update or add tests. 4. Update DDL only if the...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~161-~161: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...w semantics. 3. Update or add tests. 4. Update DDL only if the new rules require schem...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
🪛 markdownlint-cli2 (0.18.1)
packages/ztd-cli/templates/README.md
5-5: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
38-38: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
packages/ztd-cli/templates/AGENTS.md
43-43: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
67-67: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build-and-test (20.x)
🔇 Additional comments (16)
eslint.config.mjs (1)
22-28: LGTM! Appropriate exclusion of generated test artifacts.Excluding
**/tests/generated/**from linting aligns with the repository-wide restructuring of generated artifacts and follows the best practice of not linting generated code.packages/ztd-cli/templates/tests/support/testkit-client.ts (4)
1-3: Excellent documentation for template files.The auto-generated header clearly communicates the file's purpose and regeneration workflow, helping users understand they should use
npx ztd initrather than manual edits.
12-12: DDL path correctly updated to reflect the new layout.The path change from
../sql/ddlto../../ztd/ddlaligns with the PR's restructuring fromsql/toztd/directories.
34-34: Clear and actionable error message.The updated error message appropriately references Vitest globalSetup, aligning with the PR's introduction of global test setup and providing users with clear guidance on where to configure DATABASE_URL.
95-95: Good refinement to use generic placeholder.Updating the comment from a specific example ('public.users') to a generic placeholder ('public.table_name') makes it more appropriate for template documentation.
playgrounds/ztd-playground/README.md (2)
46-48: Nice: clear statement that the shared client issues no DDL
This is a good, crisp reinforcement of the pg-testkit contract for the playground. Based on learnings, ...
64-68: Format and tighten the “TableNameResolver” note
IfTableNameResolveris an exported symbol/type, wrap it in backticks; if not, consider rephrasing to avoid implying a public API name in docs. Also, the guidance “prefer schema-qualified names end-to-end” is a bit at odds with the broader “SQL can omit qualifiers” story—worth confirming that the playground specifically wants fully-qualified names everywhere (fixtures + queries + assertions). Based on learnings, ...packages/ztd-cli/src/commands/ztdConfig.ts (1)
141-142: LGTM! Clearer generated file header.The updated header is more concise and follows standard conventions for generated files. The "DO NOT EDIT" warning is clear and the simplified structure improves readability.
packages/ztd-cli/README.md (2)
3-6: Clear separation of responsibilities betweenztd-cliand drivers.
34-52: Docs correctly anchor the workflow aroundztd/ddl/+tests/generated/+ driver wiring.Also applies to: 56-67
playgrounds/ztd-playground/AGENTS.md (3)
19-23: No action needed. The testcontainer singleton guarantee is correctly implemented: Vitest'sglobalSetuphook runs once per session (not per-worker), and the setup properly starts one container, stores itsDATABASE_URLin the environment for all workers to inherit, and cleans up at session end. The AGENTS.md guidance is accurate.
62-66: The claim aboutpnpm formatscope is accurate and requires no changes.The
.prettierrcconfiguration in playgrounds/ztd-playground confirms thatpnpm format(which runsprettier . --write) covers:
- TypeScript: Default prettier behavior
- SQL: Via
prettier-plugin-sql- Markdown: Explicit override in config
- Config files (.json, .yaml, .yml): Default prettier behavior
The review comment correctly documents the formatter's scope. No issues found.
31-37: No changes needed—the review comment is accurate as written.The paths
ztd/enums/*.mdandztd/domain-specs/*.mdare correct and already implemented in the repository. The actual files confirm the convention: enums and domain specs are stored as Markdown files with embedded SQL code blocks. The ztd-cli derives these directory paths mechanically from theddlDirconfiguration without enforcing file extensions, making the.mdformat a documentation and tooling choice rather than a CLI requirement. All statements in the review comment align with the codebase structure and ztd-cli behavior.packages/ztd-cli/src/commands/init.ts (3)
81-97: Good consolidation of new ZTD artifact locations undertests/generated/and test support undertests/support/.
The target map + summary ordering read cleanly and match the new layout.Also applies to: 171-188
447-453: Nice: keepingAGENTS_ztd.mdcompatibility + adding new summary keys.
This makes the scaffolding more robust across older repos while surfacing the new files in the init summary.Also applies to: 693-729
263-277: Remove theawaitsuggestion; the actual implementation is synchronous.
runGenerateZtdConfigis defined asexport function runGenerateZtdConfig(options: ZtdConfigGenerationOptions): void(packages/ztd-cli/src/commands/ztdConfig.ts:34) and uses only synchronous operations (writeFileSync,ensureDirectory, etc.). While the interface ininit.tsdeclares the dependency as(options: ZtdConfigGenerationOptions) => Promise<void> | voidto allow flexibility for future async implementations, the concrete function returnsvoid, not a Promise. The call at line 266 is correct as written and does not requireawait.
| - name: Build ZTD CLI dependencies | ||
| run: | | ||
| pnpm --filter rawsql-ts run build | ||
| pnpm --filter @rawsql-ts/testkit-core run build | ||
| pnpm --filter @rawsql-ts/ztd-cli run build | ||
|
|
||
| - name: Generate ZTD artifacts (playground) | ||
| run: pnpm --filter ztd-playground exec ztd ztd-config | ||
|
|
||
| - name: Verify working tree is clean after generation | ||
| run: git diff --exit-code |
There was a problem hiding this comment.
git diff --exit-code doesn’t catch untracked generated files; strengthen the “clean tree” check.
If ztd-config creates new files that aren’t tracked yet, git diff --exit-code can still pass.
Suggested change:
- name: Verify working tree is clean after generation
- run: git diff --exit-code
+ run: |
+ git diff --exit-code
+ test -z "$(git status --porcelain)"🤖 Prompt for AI Agents
In .github/workflows/pr-check.yml around lines 29 to 39, the current "Verify
working tree is clean after generation" step uses "git diff --exit-code" which
does not detect untracked files; replace that check with a stronger one that
fails the job if there are any unstaged/committed changes or untracked files.
Concretely, run a command that checks both tracked diffs and untracked files
(for example use git status --porcelain or git ls-files --others
--exclude-standard and fail if output is non-empty) so the workflow fails when
ztd-config creates new untracked generated files.
| ``` | ||
| /ztd | ||
| /ddl | ||
| *.sql <- physical schema definitions | ||
|
|
||
| /domain-specs | ||
| *.md <- one behavioral SELECT per file (one SQL block) | ||
|
|
||
| /enums | ||
| *.md <- one enum definition per file (one SQL block) | ||
|
|
||
| README.md <- documentation for the layout | ||
| AGENTS.md <- combined guidance for DDL, enums, and specs | ||
|
|
||
| /src <- application & repository logic | ||
| /tests <- ZTD tests, fixtures, row-maps | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Add a language to the directory-layout code fence (MD040).
-```
+```text
/ztd
/ddl
*.sql <- physical schema definitions
@@
/tests <- ZTD tests, fixtures, row-maps
<details>
<summary>🧰 Tools</summary>
<details>
<summary>🪛 markdownlint-cli2 (0.18.1)</summary>
43-43: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
</details>
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
In packages/ztd-cli/templates/AGENTS.md around lines 43 to 60, the markdown code
fence is missing a language identifier which triggers MD040; update the opening
fence to include a language (e.g., change totext) so the block is
explicitly marked as plain text, keep the closing fence unchanged, and ensure
spacing/indentation inside the block is preserved.
</details>
<!-- fingerprinting:phantom:triton:falcon -->
<!-- This is an auto-generated comment by CodeRabbit -->
| # Principles of ZTD in This Repository | ||
|
|
||
| ### 1. Humans own the **definitions** | ||
| - Physical schema (DDL) | ||
| - Domain semantics (domain-specs) | ||
| - Enumerations (enums) | ||
| - Repository interfaces | ||
|
|
||
| ### 2. AI assists with **implementation** | ||
| - Generating repository SQL | ||
| - Updating fixtures | ||
| - Producing intermediate TypeScript structures | ||
| - Ensuring SQL adheres to DDL, enums, and domain-specs | ||
|
|
||
| ### 3. ZTD enforces **consistency** | ||
| ZTD tests verify that: | ||
| - SQL logic matches DDL shapes | ||
| - SQL semantics match domain-specs | ||
| - SQL values match enumerations | ||
|
|
||
| If anything diverges, ZTD failures surface immediately and deterministically. | ||
|
|
There was a problem hiding this comment.
Fix heading level increment under “Principles” (MD001).
You have # Principles of ZTD... then ### 1.... Either make “Principles...” an ## section or promote the numbered items to ## to keep the hierarchy valid.
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
67-67: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
🤖 Prompt for AI Agents
In packages/ztd-cli/templates/AGENTS.md around lines 65 to 86, the Markdown
heading hierarchy is invalid: you have a top-level H1 ("# Principles of ZTD...")
followed immediately by H3 ("### 1. Humans own the **definitions**"), which
violates MD001; fix it by making the hierarchy consistent — either change the
"Principles of ZTD in This Repository" heading from H1 to H2, or promote each
numbered principle from H3 to H2, and ensure subsequent subheadings (if any) use
lower levels accordingly so the document has a valid, logical heading nesting.
| ``` | ||
| /ztd | ||
| /ddl | ||
| *.sql <- schema definitions | ||
| /domain-specs | ||
| *.md <- one behavior per file (one SQL block) | ||
| /enums | ||
| *.md <- one enum per file (one SQL block) | ||
| README.md <- documentation for the layout | ||
| AGENTS.md <- combined guidance for people and agents | ||
|
|
||
| ## Workflow | ||
| /src <- application & repository code | ||
| /tests <- ZTD tests, fixtures, generated maps | ||
| ``` |
There was a problem hiding this comment.
Add a language to the directory-layout code fence (MD040).
markdownlint is right here—specify a language for the layout block (e.g., text) so lint passes.
-```
+```text
/ztd
/ddl
*.sql <- schema definitions
@@
/tests <- ZTD tests, fixtures, generated maps
<details>
<summary>🧰 Tools</summary>
<details>
<summary>🪛 markdownlint-cli2 (0.18.1)</summary>
5-5: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
</details>
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
packages/ztd-cli/templates/README.md lines 5-18: the fenced code block showing
directory layout lacks a language tag which triggers markdownlint MD040; update
the opening fence to include a language (for example use ```text) so the block
is treated as plain text and lint passes, ensure the closing fence remains
unchanged.
</details>
<!-- fingerprinting:phantom:triton:falcon -->
<!-- This is an auto-generated comment by CodeRabbit -->
| # Principles | ||
|
|
||
| ### 1. Humans own the *definitions* | ||
| - DDL (physical schema) | ||
| - Domain specifications (business logic -> SQL semantics) | ||
| - Enums (canonical domain values) | ||
|
|
||
| ### 2. AI owns the *implementation* | ||
| - Repository SQL generation | ||
| - Test fixture updates | ||
| - Intermediate TypeScript structures | ||
| - SQL rewriting, parameter binding, shape resolution | ||
|
|
There was a problem hiding this comment.
Fix heading level increment (MD001).
You jump from # Principles to ### 1.... Make “Principles” an ## section (or promote the numbered items to ##) to keep heading hierarchy valid.
-# Principles
+## Principles
-### 1. Humans own the *definitions*
+### 1. Humans own the *definitions*🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
38-38: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
🤖 Prompt for AI Agents
In packages/ztd-cli/templates/README.md around lines 36 to 48, the heading
hierarchy jumps from a top-level H1 (# Principles) to H3 (### 1...), which
violates MD001; fix by making the "Principles" heading H2 (change `# Principles`
to `## Principles`) or alternatively promote the numbered items to H2 (change
`### 1.` etc. to `## 1.`), and ensure all subsequent subheadings under this
section use consistent incremental levels.
| ## Generated files (important) | ||
|
|
||
| - `tests/generated/` is auto-generated and must never be committed. | ||
| - After cloning the repository (or in a clean environment), run: | ||
| - `pnpm --filter rawsql-ts run build` | ||
| - `pnpm --filter @rawsql-ts/testkit-core run build` | ||
| - `pnpm --filter @rawsql-ts/ztd-cli run build` | ||
| - `pnpm --filter ztd-playground exec ztd ztd-config` | ||
| - If TypeScript reports missing modules or type errors because `tests/generated/` is missing, run: | ||
| - `pnpm --filter rawsql-ts run build` | ||
| - `pnpm --filter @rawsql-ts/testkit-core run build` | ||
| - `pnpm --filter @rawsql-ts/ztd-cli run build` | ||
| - `pnpm --filter ztd-playground exec ztd ztd-config` | ||
|
|
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check .gitignore rules for tests/generated/ in ztd-playground and repo root
echo "=== Checking .gitignore entries ==="
echo ""
echo "Root .gitignore:"
if [ -f .gitignore ]; then
grep -n "tests/generated" .gitignore || echo "(no match)"
grep -n "generated" .gitignore | head -10 || echo "(no generated entries)"
else
echo "(no root .gitignore)"
fi
echo ""
echo "playgrounds/ztd-playground/.gitignore:"
if [ -f playgrounds/ztd-playground/.gitignore ]; then
cat playgrounds/ztd-playground/.gitignore
else
echo "(no .gitignore in ztd-playground)"
fi
echo ""
echo "=== Directory structure of playgrounds/ztd-playground/tests ==="
if [ -d playgrounds/ztd-playground/tests ]; then
ls -la playgrounds/ztd-playground/tests/ | head -20
else
echo "(tests directory does not exist)"
fiRepository: mk3008/rawsql-ts
Length of output: 831
🏁 Script executed:
#!/bin/bash
# Search for any tests/generated directory or similar patterns
echo "=== Searching for generated directories in ztd-playground ==="
find playgrounds/ztd-playground -type d -name "*generated*" 2>/dev/null || echo "(no generated dirs found)"
echo ""
echo "=== Check AGENTS.md content for exact command duplication ==="
if [ -f playgrounds/ztd-playground/AGENTS.md ]; then
cat -n playgrounds/ztd-playground/AGENTS.md | sed -n '5,18p'
fiRepository: mk3008/rawsql-ts
Length of output: 943
🏁 Script executed:
#!/bin/bash
# Look for CI/workflow files that might validate generated files
echo "=== CI/workflow files ==="
find . -type f \( -name "*.yml" -o -name "*.yaml" \) -path "*/.github/workflows/*" 2>/dev/null | head -10
echo ""
echo "=== Checking for lint/test scripts that validate generated files ==="
if [ -f .github/workflows/*.yml ] || [ -f .github/workflows/*.yaml ]; then
ls -la .github/workflows/ 2>/dev/null
else
echo "(checking for workflow files...)"
find . -path "*/.github/workflows/*" -type f 2>/dev/null | head -5
fiRepository: mk3008/rawsql-ts
Length of output: 496
🏁 Script executed:
#!/bin/bash
# Check CI workflows for validation of generated files or pre-commit hooks
echo "=== pr-check.yml ==="
cat .github/workflows/pr-check.yml | head -60
echo ""
echo "=== Checking for pre-commit or lint-staged config ==="
ls -la | grep -E "\.prettierignore|\.eslintignore|\.gitignore|lint-staged|husky"
test -f .husky/_/pre-commit && echo "Found pre-commit hook" && cat .husky/_/pre-commitRepository: mk3008/rawsql-ts
Length of output: 1650
🏁 Script executed:
#!/bin/bash
# Check if .gitignore is enforced in any CI workflow
echo "=== Searching for 'generated' or 'gitignore' in CI workflows ==="
grep -n "generated\|gitignore" .github/workflows/*.yml || echo "(no matches for generated/gitignore in CI)"
echo ""
echo "=== Check for any 'git status' or diff checks in workflows ==="
grep -n "git status\|git diff\|git check-ignore" .github/workflows/*.yml || echo "(no git validation checks found)"Repository: mk3008/rawsql-ts
Length of output: 399
Deduplicate the command instructions; gitignore is already enforced by CI.
The commands in lines 8-12 and 13-17 are identical. Consolidate them into a single block with a brief note about when to regenerate. The .gitignore rule is already enforced by pr-check.yml (git diff --exit-code), so the "must never be committed" statement is sufficient without additional CI enforcement notes.
Suggested structure:
- State that
tests/generated/is auto-generated and never committed (lines 7) - Single command block with the 4 build/regen steps
- Optional: add a note that TypeScript errors about missing modules typically resolve after running these commands
🤖 Prompt for AI Agents
In playgrounds/ztd-playground/AGENTS.md around lines 5 to 18, the build/regen
command instructions are duplicated into two identical blocks; consolidate them
into a single command block listing the four steps (pnpm --filter rawsql-ts run
build, pnpm --filter @rawsql-ts/testkit-core run build, pnpm --filter
@rawsql-ts/ztd-cli run build, pnpm --filter ztd-playground exec ztd ztd-config),
keep the single sentence that tests/generated/ is auto-generated and must never
be committed, and add a short note that TypeScript missing-module/type errors
are typically resolved after running the listed commands.
| After cloning the repository (or in a clean environment), run: | ||
|
|
||
| ```bash | ||
| pnpm --filter rawsql-ts run build | ||
| pnpm --filter @rawsql-ts/testkit-core run build | ||
| pnpm --filter @rawsql-ts/ztd-cli run build | ||
| pnpm --filter ztd-playground exec ztd ztd-config | ||
| ``` | ||
|
|
||
| If TypeScript reports missing modules or type errors because `tests/generated/` is missing, run the same command. |
There was a problem hiding this comment.
Clarify which “same command” to rerun (Line 18)
Line 18 is ambiguous: does it mean rerun only ... exec ztd ztd-config or the full build+config sequence from Lines 12–16? Consider spelling out the minimal fix path (e.g., “rerun pnpm --filter ztd-playground exec ztd ztd-config (and rebuild deps if you changed them)”).
🤖 Prompt for AI Agents
In playgrounds/ztd-playground/README.md around lines 9 to 18, the phrase "run
the same command" is ambiguous; replace it with an explicit instruction stating
to rerun the playground config command and when to rebuild dependencies — e.g.,
change the sentence to something like: "If TypeScript reports missing modules or
type errors because tests/generated/ is missing, rerun `pnpm --filter
ztd-playground exec ztd ztd-config`; if you changed dependencies, rerun the full
build sequence (the three `pnpm --filter ... run build` commands) then `pnpm
--filter ztd-playground exec ztd ztd-config`."
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
.github/workflows/pr-check.yml (1)
39-40: “Clean tree” check won’t fail on newly generated untracked files; strengthen it.
git diff --exit-codeignores untracked outputs, so generation can still “pass” while producing new files.- - name: Verify working tree is clean after generation - run: git diff --exit-code + - name: Verify working tree is clean after generation + run: | + git diff --exit-code + test -z "$(git status --porcelain)"
🧹 Nitpick comments (2)
.github/workflows/pr-check.yml (2)
29-33: Avoid double-building inquick-check(filtered builds +pnpm -r run build).
Right now the workflow builds specific packages (Line 29-33) and later builds everything again (Line 45-46), which is extra CI time and noise.Options:
- Drop the filtered build step and rely on
pnpm -r run build, or- Keep filtered builds and remove/limit the later recursive build (e.g., only build packages that need TS compilation verification in this job).
Also applies to: 45-46
51-53: Consider removing “prisma-integration removed” steps (or gate them) to reduce churn.
Echo-only steps add noise and can confuse future contributors scanning CI logs; if the package is gone, deleting the steps is cleaner.Also applies to: 81-82
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/pr-check.yml(4 hunks)
🧰 Additional context used
🧠 Learnings (14)
📓 Common learnings
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Adapt `testkit-core` rewrite results to PostgreSQL in pg-testkit implementation
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Load DDL-based fixtures using DDLToFixtureConverter when projects contain `tests/ztd-row-map.generated.ts` and `sql/ddl/` directory
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Implement `.withFixtures()` overlay on pg-testkit clients to apply scenario-specific rows while maintaining fixture precedence
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Use `createPgTestkitClient` to lazily open a pg connection and ensure every `.query` call goes through rewrite + fixture application
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Rewrite all CRUD statements (INSERT, UPDATE, DELETE) to fixture-backed SELECT queries before execution in pg-testkit
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Execute rewritten SELECT queries against a live pg client/pool in pg-testkit
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{tests,test,__tests__}/**/*.{ts,tsx,js} : Provide test-specific rows via `tableRows` or `withFixtures()` rather than in DDL schema files when using pg-testkit
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.{ts,tsx} : Always wire Postgres execution through `tests/testkit-client.ts`, which opens a `pg.Client`, passes it into `rawsql-ts/pg-testkit`, and shares the connection across tests.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{tests,test,__tests__}/**/*.{ts,tsx,js} : Ensure all added features have tests in `tests/` directory when contributing to pg-testkit
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Parse DDL files once per client/pool instance in pg-testkit to produce fixture schema and baseline fixture rows deterministically
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Treat `tests/ztd-row-map.generated.ts` and `sql/ddl/` (or legacy `ddl/`) directory as canonical schema and row map; load fixtures from them rather than reverse-engineering the database structure
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/sql/**/*.sql : Keep every table definition inside `sql/ddl/<schema>.sql`, enums under `sql/enums/*.sql`, and executable specs inside `sql/domain-specs/*.sql`.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/sql/ddl/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:47.153Z
Learning: Applies to playgrounds/ztd-playground/sql/ddl/sql/ddl/**/*.sql : Store table structure definitions (CREATE TABLE, ALTER TABLE, indexes, constraints) in SQL files under `sql/ddl/<schema>.sql`
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.{ts,tsx} : Import `ZtdConfig`, `ZtdRowShapes`, `ZtdTableName`, and `tableFixture()` from `tests/ztd-row-map.generated.ts` and trust the generated helpers for row shapes instead of duplicating row interfaces inside tests.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Do not reconstruct DDL or row-type definitions inside pg-testkit when the project already ships `tests/ztd-row-map.generated.ts`; rely on the generated TestRowMap instead
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Keep the playground minimal by only including DDL files, minimal SQL examples in `src/`, and ZTD-focused tests under `tests/`; avoid adding application logic, persistence layers, or business services.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/ztd-layout.generated.ts : Do not hand-edit `tests/ztd-layout.generated.ts`; regenerate it with `pnpm playground:gen-config` (or `pnpm --filter ztd-playground exec ztd ztd-config`) so the CLI and tests stay aligned.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/ztd-cli/templates/sql/ddl/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:22.166Z
Learning: Applies to packages/ztd-cli/templates/sql/ddl/**/*ddl*/**/*.sql : SQL files in the DDL Definitions folder are the single source of truth for table structures (CREATE TABLE, ALTER TABLE, indexes, constraints)
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Applies to ztd.config.json : Application SQL can omit schema qualifiers (e.g., `SELECT ... FROM users`). pg-testkit maps those references to canonical `schema.table` keys by consulting the `ddl.defaultSchema` / `ddl.searchPath` block in `ztd.config.json` before looking up fixtures or DDL metadata.
📚 Learning: 2025-12-08T14:13:45.136Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Validation checklist: Run `pnpm lint`, `pnpm test` or `pnpm --filter <pkg> test`, `pnpm build`, and run benchmarks for SQL-rewriter changes when relevant.
Applied to files:
.github/workflows/pr-check.yml
📚 Learning: 2025-12-10T22:55:41.604Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/ztd-layout.generated.ts : Do not hand-edit `tests/ztd-layout.generated.ts`; regenerate it with `pnpm playground:gen-config` (or `pnpm --filter ztd-playground exec ztd ztd-config`) so the CLI and tests stay aligned.
Applied to files:
.github/workflows/pr-check.yml
📚 Learning: 2025-12-02T22:58:15.347Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/testkit-core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:58:15.347Z
Learning: Applies to packages/testkit-core/tests/**/*.{test,spec}.{ts,tsx} : Add test coverage for fixture resolution paths, CRUD rewrite transformations, CTE + multi-statement handling, fallback logic, identifier casing rules, and error diagnostics in testkit-core
Applied to files:
.github/workflows/pr-check.yml
📚 Learning: 2025-12-10T22:55:41.604Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.{ts,tsx} : Import `ZtdConfig`, `ZtdRowShapes`, `ZtdTableName`, and `tableFixture()` from `tests/ztd-row-map.generated.ts` and trust the generated helpers for row shapes instead of duplicating row interfaces inside tests.
Applied to files:
.github/workflows/pr-check.yml
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Do not reconstruct DDL or row-type definitions inside pg-testkit when the project already ships `tests/ztd-row-map.generated.ts`; rely on the generated TestRowMap instead
Applied to files:
.github/workflows/pr-check.yml
📚 Learning: 2025-12-02T22:57:21.022Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:21.022Z
Learning: Run pnpm --filter rawsql-ts test && pnpm --filter rawsql-ts build && pnpm --filter rawsql-ts lint before committing
Applied to files:
.github/workflows/pr-check.yml
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{tests,test,__tests__}/**/*.{ts,tsx,js} : Ensure all added features have tests in `tests/` directory when contributing to pg-testkit
Applied to files:
.github/workflows/pr-check.yml
📚 Learning: 2025-12-08T14:13:45.136Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Ensure `packages/core/dist` outputs stay synchronized with the pnpm store copy that CLI tests consume. Run `pnpm --filter rawsql-ts build` which executes `scripts/sync-rawsql-dist.js` as a `postbuild` step.
Applied to files:
.github/workflows/pr-check.yml
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Load DDL-based fixtures using DDLToFixtureConverter when projects contain `tests/ztd-row-map.generated.ts` and `sql/ddl/` directory
Applied to files:
.github/workflows/pr-check.yml
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Rewrite all CRUD statements (INSERT, UPDATE, DELETE) to fixture-backed SELECT queries before execution in pg-testkit
Applied to files:
.github/workflows/pr-check.yml
📚 Learning: 2025-12-02T22:57:21.022Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:21.022Z
Learning: Applies to packages/core/src/**/*.ts : Refactor for clarity and document public APIs before running the validation pipeline
Applied to files:
.github/workflows/pr-check.yml
📚 Learning: 2025-12-08T14:13:45.136Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Use `pnpm` and `pnpm --filter <package>` for scoped tasks.
Applied to files:
.github/workflows/pr-check.yml
📚 Learning: 2025-12-02T22:57:21.022Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:21.022Z
Learning: After formatter export changes, run pnpm --filter rawsql-ts build:browser
Applied to files:
.github/workflows/pr-check.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build-and-test (20.x)
| - name: Generate ZTD artifacts (playground) | ||
| working-directory: ./playgrounds/ztd-playground | ||
| run: node ../../packages/ztd-cli/dist/index.js ztd-config | ||
|
|
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, find and examine the relevant package.json files
fd "package.json" --path "*/ztd-cli/*" --path "*/ztd-playground/*" -x cat -n {} \;Repository: mk3008/rawsql-ts
Length of output: 275
🏁 Script executed:
# Check the root pnpm workspace configuration
cat -n pnpm-workspace.yaml 2>/dev/null || cat -n pnpm-workspace.yml 2>/dev/null || echo "Checking root package.json for workspaces"
head -50 package.jsonRepository: mk3008/rawsql-ts
Length of output: 2217
🏁 Script executed:
# Examine ztd-cli package.json for bin definition
cat -n packages/ztd-cli/package.json 2>/dev/null | head -40Repository: mk3008/rawsql-ts
Length of output: 1295
🏁 Script executed:
# Check playgrounds/ztd-playground package.json
cat -n playgrounds/ztd-playground/package.json 2>/dev/null | head -40Repository: mk3008/rawsql-ts
Length of output: 1384
🏁 Script executed:
# Look for existing pnpm exec usage in workflows
rg "pnpm.*exec" .github/workflows/ -A 2 -B 2Repository: mk3008/rawsql-ts
Length of output: 42
🏁 Script executed:
# Check how ztd-config generation is currently done in the codebase
rg "ztd-config|ztd ztd-config" --type-list | head -20
rg "ztd-config|ztd ztd-config" -g "*.md" -g "*.yml" -g "*.yaml" -g "*.ts" -g "*.js"Repository: mk3008/rawsql-ts
Length of output: 4956
Use pnpm --filter ztd-playground exec ztd ztd-config to invoke the ztd-config command.
Hardcoding the dist path is brittle—if the build output structure changes, the workflow breaks. The pnpm workspace pattern ensures the binary is resolved correctly with proper workspace context.
- name: Generate ZTD artifacts (playground)
working-directory: ./playgrounds/ztd-playground
- run: node ../../packages/ztd-cli/dist/index.js ztd-config
+ run: pnpm exec ztd ztd-configAlternatively, since the working directory is already ./playgrounds/ztd-playground, you can omit the filter and use pnpm exec directly (which resolves binaries from the current package's dependencies).
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - name: Generate ZTD artifacts (playground) | |
| working-directory: ./playgrounds/ztd-playground | |
| run: node ../../packages/ztd-cli/dist/index.js ztd-config | |
| - name: Generate ZTD artifacts (playground) | |
| working-directory: ./playgrounds/ztd-playground | |
| run: pnpm exec ztd ztd-config |
🤖 Prompt for AI Agents
In .github/workflows/pr-check.yml around lines 35 to 38, the job currently
invokes the built JS file directly which hardcodes the dist path and is brittle;
replace the node call with the pnpm workspace invocation so the ztd binary is
resolved via the workspace (use pnpm --filter ztd-playground exec ztd
ztd-config) while keeping the same working-directory, or alternatively use pnpm
exec ztd ztd-config if you prefer resolving from the package's local deps.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/ztd-cli/src/commands/init.ts (2)
162-162: Add JSDoc for exported function.The exported function
runInitCommandis missing JSDoc documentation. Per coding guidelines, all exported functions insrc/must have clear English JSDoc explaining the role of the API and how to consume it.As per coding guidelines, add JSDoc:
+/** + * Executes the interactive init workflow to scaffold a ZTD project. + * Prompts the user for configuration choices and emits the required project files. + * + * @param prompter - Interface for user interaction (prompts, confirmations) + * @param options - Optional configuration for root directory and dependencies + * @returns Summary of created/modified files + */ export async function runInitCommand(prompter: Prompter, options?: InitCommandOptions): Promise<InitResult> {
731-743: Add JSDoc for exported function.The exported function
registerInitCommandis missing JSDoc documentation. Per coding guidelines, all exported functions insrc/must have clear English JSDoc explaining the role of the API and how to consume it.As per coding guidelines, add JSDoc:
+/** + * Registers the `init` CLI command with the Commander program. + * The init command scaffolds a new ZTD project with templates and configuration. + * + * @param program - Commander program instance + */ export function registerInitCommand(program: Command): void {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
packages/ztd-cli/tests/__snapshots__/cliCommands.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (4)
packages/drivers/pg-testkit/README.md(2 hunks)packages/ztd-cli/src/commands/init.ts(9 hunks)packages/ztd-cli/src/commands/ztdConfigCommand.ts(6 hunks)packages/ztd-cli/tests/cliCommands.test.ts(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- packages/drivers/pg-testkit/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/ztd-cli/tests/cliCommands.test.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Remove console debugging before committing.
Files:
packages/ztd-cli/src/commands/init.tspackages/ztd-cli/src/commands/ztdConfigCommand.ts
**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/src/**/*.{ts,tsx}: All exported classes, functions, and types insrc/are considered part of the public API and must have clear English JSDoc attached to their declaration.
When adding a new exported symbol insrc/(class, function, type, interface, enum, etc.), always add English JSDoc in the same commit that briefly explains the role of the API and how to consume it.
When modifying an exported symbol, update the existing docstring to keep it truthful and never delete a docstring merely to keep the diff small.
If a helper is not meant to be public, make it non-exported or add@internalto its docstring rather than leaving an undocumented export.
Files:
packages/ztd-cli/src/commands/init.tspackages/ztd-cli/src/commands/ztdConfigCommand.ts
🧠 Learnings (26)
📓 Common learnings
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Adapt `testkit-core` rewrite results to PostgreSQL in pg-testkit implementation
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Load DDL-based fixtures using DDLToFixtureConverter when projects contain `tests/ztd-row-map.generated.ts` and `sql/ddl/` directory
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Rewrite all CRUD statements (INSERT, UPDATE, DELETE) to fixture-backed SELECT queries before execution in pg-testkit
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Implement `.withFixtures()` overlay on pg-testkit clients to apply scenario-specific rows while maintaining fixture precedence
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Execute rewritten SELECT queries against a live pg client/pool in pg-testkit
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Use `createPgTestkitClient` to lazily open a pg connection and ensure every `.query` call goes through rewrite + fixture application
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{tests,test,__tests__}/**/*.{ts,tsx,js} : Provide test-specific rows via `tableRows` or `withFixtures()` rather than in DDL schema files when using pg-testkit
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{tests,test,__tests__}/**/*.{ts,tsx,js} : Ensure all added features have tests in `tests/` directory when contributing to pg-testkit
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.{ts,tsx} : Always wire Postgres execution through `tests/testkit-client.ts`, which opens a `pg.Client`, passes it into `rawsql-ts/pg-testkit`, and shares the connection across tests.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Ensure result types follow PostgreSQL casting rules in pg-testkit to maintain parity with real-world applications
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/sql/**/*.sql : Keep every table definition inside `sql/ddl/<schema>.sql`, enums under `sql/enums/*.sql`, and executable specs inside `sql/domain-specs/*.sql`.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Treat `tests/ztd-row-map.generated.ts` and `sql/ddl/` (or legacy `ddl/`) directory as canonical schema and row map; load fixtures from them rather than reverse-engineering the database structure
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/ztd-layout.generated.ts : Do not hand-edit `tests/ztd-layout.generated.ts`; regenerate it with `pnpm playground:gen-config` (or `pnpm --filter ztd-playground exec ztd ztd-config`) so the CLI and tests stay aligned.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.{ts,tsx} : Import `ZtdConfig`, `ZtdRowShapes`, `ZtdTableName`, and `tableFixture()` from `tests/ztd-row-map.generated.ts` and trust the generated helpers for row shapes instead of duplicating row interfaces inside tests.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Keep the playground minimal by only including DDL files, minimal SQL examples in `src/`, and ZTD-focused tests under `tests/`; avoid adding application logic, persistence layers, or business services.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Applies to ztd.config.json : Application SQL can omit schema qualifiers (e.g., `SELECT ... FROM users`). pg-testkit maps those references to canonical `schema.table` keys by consulting the `ddl.defaultSchema` / `ddl.searchPath` block in `ztd.config.json` before looking up fixtures or DDL metadata.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Applies to ztd.config.json : Update `ztd.config.json` whenever you change the target schema or search path so the rewrite pipeline still matches tables as expected.
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/sql/ddl/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:47.153Z
Learning: Applies to playgrounds/ztd-playground/sql/ddl/sql/ddl/**/*.sql : Store table structure definitions (CREATE TABLE, ALTER TABLE, indexes, constraints) in SQL files under `sql/ddl/<schema>.sql`
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Do not reconstruct DDL or row-type definitions inside pg-testkit when the project already ships `tests/ztd-row-map.generated.ts`; rely on the generated TestRowMap instead
📚 Learning: 2025-12-10T22:55:41.604Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/ztd-layout.generated.ts : Do not hand-edit `tests/ztd-layout.generated.ts`; regenerate it with `pnpm playground:gen-config` (or `pnpm --filter ztd-playground exec ztd ztd-config`) so the CLI and tests stay aligned.
Applied to files:
packages/ztd-cli/src/commands/init.tspackages/ztd-cli/src/commands/ztdConfigCommand.ts
📚 Learning: 2025-12-02T22:57:21.022Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:21.022Z
Learning: Applies to packages/core/src/**/*.ts : Refactor for clarity and document public APIs before running the validation pipeline
Applied to files:
packages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-02T22:58:15.347Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/testkit-core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:58:15.347Z
Learning: Applies to packages/testkit-core/tests/**/*.{test,spec}.{ts,tsx} : Add test coverage for fixture resolution paths, CRUD rewrite transformations, CTE + multi-statement handling, fallback logic, identifier casing rules, and error diagnostics in testkit-core
Applied to files:
packages/ztd-cli/src/commands/init.tspackages/ztd-cli/src/commands/ztdConfigCommand.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Do not reconstruct DDL or row-type definitions inside pg-testkit when the project already ships `tests/ztd-row-map.generated.ts`; rely on the generated TestRowMap instead
Applied to files:
packages/ztd-cli/src/commands/init.tspackages/ztd-cli/src/commands/ztdConfigCommand.ts
📚 Learning: 2025-12-10T22:55:41.604Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.{ts,tsx} : Import `ZtdConfig`, `ZtdRowShapes`, `ZtdTableName`, and `tableFixture()` from `tests/ztd-row-map.generated.ts` and trust the generated helpers for row shapes instead of duplicating row interfaces inside tests.
Applied to files:
packages/ztd-cli/src/commands/init.tspackages/ztd-cli/src/commands/ztdConfigCommand.ts
📚 Learning: 2025-12-02T22:58:15.347Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/testkit-core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:58:15.347Z
Learning: Applies to packages/testkit-core/src/**/*.{ts,tsx} : UPDATE rewrites should apply updates to fixture snapshot and project updated rows via SELECT
Applied to files:
packages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Adapt `testkit-core` rewrite results to PostgreSQL in pg-testkit implementation
Applied to files:
packages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Load DDL-based fixtures using DDLToFixtureConverter when projects contain `tests/ztd-row-map.generated.ts` and `sql/ddl/` directory
Applied to files:
packages/ztd-cli/src/commands/init.tspackages/ztd-cli/src/commands/ztdConfigCommand.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Maintain fixture precedence order in pg-testkit: DDL fixtures (schema + shared seed rows) → Manual fixtures (`tableDefinitions`, `tableRows`) → Scoped fixtures (`client.withFixtures()`), where later layers override earlier ones
Applied to files:
packages/ztd-cli/src/commands/init.tspackages/ztd-cli/src/commands/ztdConfigCommand.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Emit debug traces in pg-testkit when fallback paths trigger, analyzer limitations appear, or fixture mismatches surface
Applied to files:
packages/ztd-cli/src/commands/init.tspackages/ztd-cli/src/commands/ztdConfigCommand.ts
📚 Learning: 2025-12-02T22:57:55.637Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/sqlite-testkit/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:55.637Z
Learning: Applies to packages/drivers/sqlite-testkit/src/**/*.{ts,tsx,js} : No stray console.log or temp files outside ./tmp/ directory
Applied to files:
packages/ztd-cli/src/commands/init.tspackages/ztd-cli/src/commands/ztdConfigCommand.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{tests,test,__tests__}/**/*.{ts,tsx,js} : Ensure all added features have tests in `tests/` directory when contributing to pg-testkit
Applied to files:
packages/ztd-cli/src/commands/init.tspackages/ztd-cli/src/commands/ztdConfigCommand.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Parse DDL files once per client/pool instance in pg-testkit to produce fixture schema and baseline fixture rows deterministically
Applied to files:
packages/ztd-cli/src/commands/init.tspackages/ztd-cli/src/commands/ztdConfigCommand.ts
📚 Learning: 2025-12-02T22:58:15.347Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/testkit-core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:58:15.347Z
Learning: Applies to packages/testkit-core/src/**/*.{ts,tsx} : In rawsql-ts/testkit-core, remain DBMS-agnostic with no Postgres/SQLite conditionals or behavior
Applied to files:
packages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Include actionable hints (table/column names) in error messages for pg-testkit
Applied to files:
packages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Support full parallel test execution in pg-testkit with no shared state
Applied to files:
packages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{src,lib}/**/*.{ts,tsx,js} : Do not introduce rewrite logic inside pg-testkit; rewrite logic belongs exclusively in testkit-core
Applied to files:
packages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Treat `tests/ztd-row-map.generated.ts` and `sql/ddl/` (or legacy `ddl/`) directory as canonical schema and row map; load fixtures from them rather than reverse-engineering the database structure
Applied to files:
packages/ztd-cli/src/commands/init.tspackages/ztd-cli/src/commands/ztdConfigCommand.ts
📚 Learning: 2025-12-09T12:47:23.717Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/pg-testkit/AGENTS.md:0-0
Timestamp: 2025-12-09T12:47:23.717Z
Learning: Applies to packages/drivers/pg-testkit/**/{tests,test,__tests__}/**/*.{ts,tsx,js} : Provide test-specific rows via `tableRows` or `withFixtures()` rather than in DDL schema files when using pg-testkit
Applied to files:
packages/ztd-cli/src/commands/init.tspackages/ztd-cli/src/commands/ztdConfigCommand.ts
📚 Learning: 2025-12-02T22:57:55.637Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/sqlite-testkit/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:55.637Z
Learning: Applies to packages/drivers/sqlite-testkit/src/**/*.{ts,tsx,js} : All SQL must flow through the testkit-core AST rewriter before execution; new rewrite behavior must be added to testkit-core first, then threaded into sqlite-testkit
Applied to files:
packages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-10T22:55:41.604Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: playgrounds/ztd-playground/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:41.604Z
Learning: Applies to playgrounds/ztd-playground/tests/**/*.{ts,tsx} : Provide explicit fixtures for each test using `tableFixture('schema.table', [{ ... }])`; do not reuse shared mutable data between tests and do not insert, update, or delete data directly; rely on the rewrite helper instead.
Applied to files:
packages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-02T22:57:55.637Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/drivers/sqlite-testkit/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:55.637Z
Learning: Applies to packages/drivers/sqlite-testkit/src/**/*.test.{ts,tsx} : Ensure tests remain deterministic regardless of file-backed vs. memory-backed SQLite configurations
Applied to files:
packages/ztd-cli/src/commands/init.ts
📚 Learning: 2025-12-08T14:13:45.136Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T14:13:45.136Z
Learning: Applies to ztd.config.json : Update `ztd.config.json` whenever you change the target schema or search path so the rewrite pipeline still matches tables as expected.
Applied to files:
packages/ztd-cli/src/commands/init.tspackages/ztd-cli/src/commands/ztdConfigCommand.ts
📚 Learning: 2025-12-10T22:55:22.166Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/ztd-cli/templates/sql/ddl/AGENTS.md:0-0
Timestamp: 2025-12-10T22:55:22.166Z
Learning: Applies to packages/ztd-cli/templates/sql/ddl/**/*ddl*/**/*.sql : SQL files in the DDL Definitions folder are the single source of truth for table structures (CREATE TABLE, ALTER TABLE, indexes, constraints)
Applied to files:
packages/ztd-cli/src/commands/ztdConfigCommand.ts
📚 Learning: 2025-12-02T22:57:21.022Z
Learnt from: CR
Repo: mk3008/rawsql-ts PR: 0
File: packages/core/AGENTS.md:0-0
Timestamp: 2025-12-02T22:57:21.022Z
Learning: Applies to packages/core/**/*.{test,spec}.ts : Add or update tests whenever adding features or fixing bugs
Applied to files:
packages/ztd-cli/src/commands/ztdConfigCommand.ts
🧬 Code graph analysis (2)
packages/ztd-cli/src/commands/init.ts (2)
packages/ztd-cli/src/utils/ztdProjectConfig.ts (1)
DEFAULT_ZTD_CONFIG(31-36)packages/ztd-cli/src/commands/options.ts (1)
DEFAULT_EXTENSIONS(1-1)
packages/ztd-cli/src/commands/ztdConfigCommand.ts (4)
packages/ztd-cli/src/utils/ztdProjectConfig.ts (1)
ZtdProjectConfig(13-22)packages/ztd-cli/src/utils/fs.ts (1)
ensureDirectory(3-10)packages/ztd-cli/src/commands/options.ts (1)
DEFAULT_TESTS_DIRECTORY(3-3)packages/ztd-cli/src/commands/ztdConfig.ts (2)
runGenerateZtdConfig(34-54)ZtdConfigGenerationOptions(14-20)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build-and-test (20.x)
🔇 Additional comments (7)
packages/ztd-cli/src/commands/ztdConfigCommand.ts (3)
21-41: LGTM!The layout file generation logic correctly derives the ZTD root directory and computes deterministic paths for sibling directories.
43-47: LGTM!The function properly ensures the parent directory exists before emitting the layout file.
111-115: LGTM!The watch flow consistently regenerates both the row map and layout files, maintaining parity with the initial generation flow.
Also applies to: 148-149
packages/ztd-cli/src/commands/init.ts (4)
81-97: LGTM!The updated
FileKeytype andabsolutePathsmapping correctly reflect the new project structure withtests/generated/subdirectories and additional documentation artifacts.Also applies to: 171-188
289-374: LGTM!The new template emissions for Vitest configuration, global setup, and ZTD documentation follow a consistent pattern. The
allowFallbackparameter enables graceful handling when a README already exists by creating aREADME_ztd.mdvariant.
396-414: LGTM!The
.gitignoreand.prettierignorefiles are emitted usingcopyTemplateFileIfMissing, which appropriately preserves existing user configurations.
618-682: LGTM!The updated
writeTemplateFilefunction and helper functions implement a sensible fallback mechanism. When a root-level Markdown file already exists, the template is emitted with a_ztdsuffix to preserve the user's existing documentation.
| const defaultOut = path.join( | ||
| projectConfig.testsDir ?? DEFAULT_TESTS_DIRECTORY, | ||
| 'generated', | ||
| 'ztd-row-map.generated.ts' | ||
| ); | ||
| const output = options.out ?? defaultOut; | ||
| const layoutOut = path.join(path.dirname(output), 'ztd-layout.generated.ts'); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# Find test files in ztd-cli package
fd -t f '\.test\.(ts|tsx)$|\.spec\.(ts|tsx)$' packages/ztd-cli/tests/ 2>/dev/null || echo "No test directory found"
# Also check if tests directory exists at all
ls -la packages/ztd-cli/ | grep -i test
# Search for any tests related to ztdConfigCommand
rg -l 'ztdConfigCommand|ztd-config' packages/ztd-cli/ --type=ts -iRepository: mk3008/rawsql-ts
Length of output: 688
🏁 Script executed:
# Read the test file that covers ztd config
wc -l packages/ztd-cli/tests/ztdConfig.unit.test.ts
# Read the test file
cat -n packages/ztd-cli/tests/ztdConfig.unit.test.tsRepository: mk3008/rawsql-ts
Length of output: 4240
🏁 Script executed:
# Read the CLI commands test file
wc -l packages/ztd-cli/tests/cliCommands.test.ts
# Show the file content
cat -n packages/ztd-cli/tests/cliCommands.test.tsRepository: mk3008/rawsql-ts
Length of output: 6550
🏁 Script executed:
# Search for tests that use ztd-config without --out flag (default path behavior)
rg -n 'ztd-config' packages/ztd-cli/tests/ --type=ts -A 3 -B 3
# Also search for any tests that mention 'tests/generated' or default output path
rg -n 'tests/generated|defaultOut|layoutOut|ztd-layout' packages/ztd-cli/tests/ --type=tsRepository: mk3008/rawsql-ts
Length of output: 1922
🏁 Script executed:
# Read the init command test file to understand what's being tested
wc -l packages/ztd-cli/tests/init.command.test.ts
# Show relevant sections around the tests/generated checks
cat -n packages/ztd-cli/tests/init.command.test.ts | head -130Repository: mk3008/rawsql-ts
Length of output: 6486
🏁 Script executed:
# Check the actual ztdConfigCommand.ts file to see the full implementation
cat -n packages/ztd-cli/src/commands/ztdConfigCommand.ts | head -110
# Also search for any other test files that might test default path behavior
rg -n 'runGenerateZtdConfig|defaultOut' packages/ztd-cli/tests/ --type=tsRepository: mk3008/rawsql-ts
Length of output: 5218
🏁 Script executed:
# Search more thoroughly for any test that runs ztd-config without --out
rg -n "runCli.*ztd-config" packages/ztd-cli/tests/ --type=ts -A 2
# Also check if init command internally calls ztd-config with defaults
rg -n "runGenerateZtdConfig|writeZtdLayoutFile" packages/ztd-cli/src/ --type=ts -B 3 -A 3Repository: mk3008/rawsql-ts
Length of output: 6671
🏁 Script executed:
# Check if runGenerateZtdConfig function itself handles directory creation
cat -n packages/ztd-cli/src/commands/ztdConfig.ts | head -80Repository: mk3008/rawsql-ts
Length of output: 3150
Add test coverage for ztd-config command with default output path.
The code correctly handles directory creation via ensureDirectory() in both runGenerateZtdConfig() (line 51 of ztdConfig.ts) and writeZtdLayoutFile() (line 45 of ztdConfigCommand.ts). However, there is no test in cliCommands.test.ts that exercises the ztd-config command without the --out flag to verify the default path behavior (tests/generated/ztd-row-map.generated.ts) and layout file generation work correctly. The existing test at line 72 always provides an explicit --out parameter. Add a test that runs ztd-config without --out to confirm the default directory structure is created and both output files are generated.
🤖 Prompt for AI Agents
In packages/ztd-cli/src/commands/ztdConfigCommand.ts around lines 66 to 72, add
test coverage in the test suite (cliCommands.test.ts) that runs the `ztd-config`
command without the `--out` flag to exercise the default output path logic;
create a test that invokes the CLI with no `--out`, then assert the default
files exist at tests/generated/ztd-row-map.generated.ts and
tests/generated/ztd-layout.generated.ts (or the layout file in the same
dirname), ensure any required directories are cleaned/created via the test
setup/teardown, and verify both generation functions executed by checking file
existence and contents where appropriate.
Introduces pg-testkit driver and ztd-cli for project scaffolding with templates and tests. Also updates docs to unify driver terminology.
Summary by CodeRabbit
New Features
Refactor
Documentation
Chores
✏️ Tip: You can customize this high-level summary in your review settings.