@rawsql-ts/ztd-cli 0.13.2 → 0.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -75,7 +75,7 @@ const SAMPLE_SCHEMA = `CREATE TABLE public.example (
75
75
  );
76
76
  `;
77
77
  const README_TEMPLATE = 'README.md';
78
- const TESTS_CONFIG_TEMPLATE = 'tests/generated/ztd-layout.generated.ts';
78
+ const TESTS_CONFIG_TEMPLATE = 'tests/ztd-layout.generated.ts';
79
79
  const TESTKIT_CLIENT_TEMPLATE = 'tests/support/testkit-client.ts';
80
80
  const GLOBAL_SETUP_TEMPLATE = 'tests/support/global-setup.ts';
81
81
  const VITEST_CONFIG_TEMPLATE = 'vitest.config.ts';
@@ -85,7 +85,25 @@ const NEXT_STEPS = [
85
85
  ' 3. Run npx ztd ztd-config',
86
86
  ' 4. Run ZTD tests with pg-testkit'
87
87
  ];
88
- const TEMPLATE_DIRECTORY = node_path_1.default.resolve(__dirname, '..', '..', 'templates');
88
+ function resolveTemplateDirectory() {
89
+ const candidates = [
90
+ // Prefer the installed package layout: <pkg>/dist/commands → <pkg>/templates.
91
+ node_path_1.default.resolve(__dirname, '..', '..', '..', 'templates'),
92
+ // Support legacy layouts that copied templates into dist/.
93
+ node_path_1.default.resolve(__dirname, '..', '..', 'templates'),
94
+ // Support running tests directly from the monorepo source tree.
95
+ node_path_1.default.resolve(process.cwd(), 'packages', 'ztd-cli', 'templates')
96
+ ];
97
+ // Pick the first directory that contains the expected template entrypoint.
98
+ for (const candidate of candidates) {
99
+ if ((0, node_fs_1.existsSync)(node_path_1.default.join(candidate, README_TEMPLATE))) {
100
+ return candidate;
101
+ }
102
+ }
103
+ return candidates[0];
104
+ }
105
+ // Resolve templates from a shipped directory so `ztd init` works after `npm install`.
106
+ const TEMPLATE_DIRECTORY = resolveTemplateDirectory();
89
107
  const DEFAULT_DEPENDENCIES = {
90
108
  ensureDirectory: fs_1.ensureDirectory,
91
109
  writeFile: (filePath, contents) => (0, node_fs_1.writeFileSync)(filePath, contents, 'utf8'),
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":";;;;;AAoBA,sDA0DC;AAmFD,wCAgRC;AAySD,kDAYC;AAruBD,2DAA+C;AAC/C,qCAAkE;AAClE,0DAA6B;AAC7B,sEAA8C;AAE9C,oCAA8C;AAC9C,4CAAqD;AACrD,gEAA4G;AAC5G,2CAAoF;AACpF,iCAA+D;AAC/D,uCAA+C;AAS/C,SAAgB,qBAAqB;IACnC,MAAM,EAAE,GAAG,kBAAQ,CAAC,eAAe,CAAC;QAClC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK;KAC/B,CAAC,CAAC;IAEH,KAAK,UAAU,WAAW,CAAC,QAAgB;QACzC,OAAO,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;IAED,OAAO;QACL,KAAK,CAAC,YAAY,CAAC,QAAgB,EAAE,OAAiB;YACpD,OAAO,IAAI,EAAE,CAAC;gBACZ,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC3C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC3C,CAAC;gBAED,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,oBAAoB,CAAC,CAAC;gBACvD,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;gBAChC,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAA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AC;IAC7C,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,mBAAmB,CAAC,OAAgB;IAClD,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,4DAA4D,CAAC;SACzE,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,MAAM,QAAQ,GAAG,qBAAqB,EAAE,CAAC;QACzC,IAAI,CAAC;YACH,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;gBAAS,CAAC;YACT,QAAQ,CAAC,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -9,10 +9,27 @@ const node_path_1 = __importDefault(require("node:path"));
9
9
  const fs_1 = require("./fs");
10
10
  const TEMPLATE_NAME = 'AGENTS.md';
11
11
  const TARGET_FILES = ['AGENTS.md', 'AGENTS_ztd.md'];
12
+ function resolveAgentsTemplatePath() {
13
+ const candidates = [
14
+ // Prefer the installed package layout: <pkg>/dist/utils → <pkg>/templates.
15
+ node_path_1.default.resolve(__dirname, '..', '..', '..', 'templates', TEMPLATE_NAME),
16
+ // Support legacy layouts that copied templates into dist/.
17
+ node_path_1.default.resolve(__dirname, '..', '..', 'templates', TEMPLATE_NAME),
18
+ // Support running tests directly from the monorepo source tree.
19
+ node_path_1.default.resolve(process.cwd(), 'packages', 'ztd-cli', 'templates', TEMPLATE_NAME)
20
+ ];
21
+ // Avoid overwriting when the CLI package was installed without its template bundle.
22
+ for (const candidate of candidates) {
23
+ if ((0, node_fs_1.existsSync)(candidate)) {
24
+ return candidate;
25
+ }
26
+ }
27
+ return null;
28
+ }
12
29
  function copyAgentsTemplate(projectRoot) {
13
30
  // Use the shared template bundle so generated AGENTS.md matches the distributable templates directory.
14
- const templatePath = node_path_1.default.resolve(__dirname, '..', '..', 'templates', TEMPLATE_NAME);
15
- if (!(0, node_fs_1.existsSync)(templatePath)) {
31
+ const templatePath = resolveAgentsTemplatePath();
32
+ if (!templatePath) {
16
33
  return null;
17
34
  }
18
35
  const contents = (0, node_fs_1.readFileSync)(templatePath, 'utf8');
@@ -1 +1 @@
1
- {"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/utils/agents.ts"],"names":[],"mappings":";;;;;AAOA,gDAsBC;AA7BD,qCAAkE;AAClE,0DAA6B;AAC7B,6BAAuC;AAEvC,MAAM,aAAa,GAAG,WAAW,CAAC;AAClC,MAAM,YAAY,GAAG,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;AAEpD,SAAgB,kBAAkB,CAAC,WAAmB;IACpD,uGAAuG;IACvG,MAAM,YAAY,GAAG,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;IACrF,IAAI,CAAC,IAAA,oBAAU,EAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAG,IAAA,sBAAY,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAEpD,wFAAwF;IACxF,KAAK,MAAM,QAAQ,IAAI,YAAY,EAAE,CAAC;QACpC,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QACpD,IAAI,IAAA,oBAAU,EAAC,UAAU,CAAC,EAAE,CAAC;YAC3B,SAAS;QACX,CAAC;QAED,IAAA,oBAAe,EAAC,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;QAC1C,IAAA,uBAAa,EAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC5C,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
1
+ {"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/utils/agents.ts"],"names":[],"mappings":";;;;;AA2BA,gDAsBC;AAjDD,qCAAkE;AAClE,0DAA6B;AAC7B,6BAAuC;AAEvC,MAA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QAC1C,IAAA,uBAAa,EAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC5C,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rawsql-ts/ztd-cli",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "description": "DB-agnostic scaffolding and DDL helpers for Zero Table Dependency projects",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -22,8 +22,8 @@
22
22
  "chokidar": "^5.0.0",
23
23
  "commander": "^12.0.0",
24
24
  "diff": "^5.1.0",
25
- "@rawsql-ts/testkit-core": "0.13.2",
26
- "rawsql-ts": "0.13.2"
25
+ "@rawsql-ts/testkit-core": "0.13.3",
26
+ "rawsql-ts": "0.13.3"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/diff": "^5.0.1",
@@ -33,6 +33,7 @@
33
33
  },
34
34
  "files": [
35
35
  "dist",
36
+ "templates",
36
37
  "AGENTS.md",
37
38
  "README.md"
38
39
  ],
@@ -0,0 +1,16 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ indent_style = space
7
+ indent_size = 2
8
+ tab_width = 2
9
+ insert_final_newline = true
10
+ trim_trailing_whitespace = true
11
+
12
+ [*.md]
13
+ trim_trailing_whitespace = false
14
+
15
+ [*.sql]
16
+ indent_size = 2
@@ -0,0 +1,2 @@
1
+ tests/generated/**
2
+
@@ -0,0 +1,24 @@
1
+ {
2
+ "semi": true,
3
+ "singleQuote": true,
4
+ "trailingComma": "all",
5
+ "tabWidth": 2,
6
+ "printWidth": 100,
7
+ "bracketSpacing": true,
8
+ "arrowParens": "always",
9
+ "plugins": ["prettier-plugin-sql"],
10
+ "overrides": [
11
+ {
12
+ "files": "*.sql",
13
+ "options": {
14
+ "parser": "sql"
15
+ }
16
+ },
17
+ {
18
+ "files": "*.md",
19
+ "options": {
20
+ "parser": "markdown"
21
+ }
22
+ }
23
+ ]
24
+ }
@@ -0,0 +1,235 @@
1
+ # Appendix: Development Workflow Using Zero Table Dependency (ZTD)
2
+
3
+ This application uses **Zero Table Dependency (ZTD)** as an internal development workflow for writing, testing, and maintaining SQL logic.
4
+ ZTD is not part of the application's runtime behavior; rather, it provides a framework for:
5
+
6
+ - Maintaining consistent SQL across the project
7
+ - Keeping schema, domain specifications, and enums synchronized
8
+ - Ensuring deterministic SQL unit tests
9
+ - Enabling structured collaboration between humans and AI
10
+
11
+ This section documents how ZTD is used *inside this repository* as a development methodology.
12
+
13
+ ---
14
+
15
+ ## Generated files (important)
16
+
17
+ - `tests/generated/` is auto-generated and must never be committed.
18
+ - After cloning the repository (or in a clean environment), run `npx ztd ztd-config`.
19
+ - If TypeScript reports missing modules or type errors because `tests/generated/` is missing, run `npx ztd ztd-config`.
20
+
21
+ ## ZTD Implementation Guide (src/)
22
+
23
+ The `src/` directory should contain pure TypeScript logic that operates on the row interfaces generated by `tests/generated/ztd-row-map.generated.ts`. Tests should import the row map, repositories should import DTOs, and fixtures must stay under `tests/`. Keep production code decoupled from the generated row map to preserve the distinction between implementation and test scaffolding.
24
+
25
+ ---
26
+
27
+ ## ZTD Test Guide (tests/)
28
+
29
+ Fixtures come from the `ztd/ddl/` definitions and power `pg-testkit`. Always import table types from `tests/generated/ztd-row-map.generated.ts` when constructing scenarios, and rerun `npx ztd ztd-config` whenever schema changes to keep the fixtures and row map synchronized.
30
+
31
+ If you are working inside this repository's `ztd-playground`, regenerate the generated artifacts with `pnpm --filter ztd-playground exec ztd ztd-config`.
32
+
33
+ ## Parallel test policy (important)
34
+
35
+ - ZTD tests should be safe to run in parallel against a single Postgres instance because pg-testkit rewrites CRUD into fixture-backed SELECT queries (no physical schema changes).
36
+ - Do not start multiple Postgres instances per test file/worker, and do not isolate tests by creating per-test databases or schemas. This is unnecessary for ZTD and adds failure modes.
37
+ - Prefer one shared Postgres instance + multiple connections, limited only by your DB resources.
38
+
39
+ ---
40
+
41
+ # ZTD Directory Layout
42
+
43
+ ```
44
+ /ztd
45
+ /ddl
46
+ *.sql <- physical schema definitions
47
+
48
+ /domain-specs
49
+ *.md <- one behavioral SELECT per file (one SQL block)
50
+
51
+ /enums
52
+ *.md <- one enum definition per file (one SQL block)
53
+
54
+ README.md <- documentation for the layout
55
+ AGENTS.md <- combined guidance for DDL, enums, and specs
56
+
57
+ /src <- application & repository logic
58
+ /tests <- ZTD tests, fixtures, row-maps
59
+ ```
60
+
61
+ The file `tests/generated/ztd-layout.generated.ts` ensures ZTD CLI always points to the correct directories.
62
+
63
+ ---
64
+
65
+ # Principles of ZTD in This Repository
66
+
67
+ ### 1. Humans own the **definitions**
68
+ - Physical schema (DDL)
69
+ - Domain semantics (domain-specs)
70
+ - Enumerations (enums)
71
+ - Repository interfaces
72
+
73
+ ### 2. AI assists with **implementation**
74
+ - Generating repository SQL
75
+ - Updating fixtures
76
+ - Producing intermediate TypeScript structures
77
+ - Ensuring SQL adheres to DDL, enums, and domain-specs
78
+
79
+ ### 3. ZTD enforces **consistency**
80
+ ZTD tests verify that:
81
+ - SQL logic matches DDL shapes
82
+ - SQL semantics match domain-specs
83
+ - SQL values match enumerations
84
+
85
+ If anything diverges, ZTD failures surface immediately and deterministically.
86
+
87
+ ---
88
+
89
+ # Development Workflows
90
+
91
+ Different types of changes start from different entry points. Use the workflow appropriate for your situation.
92
+
93
+ ---
94
+
95
+ # Workflow A — Starting From *DDL Changes*
96
+ Modifying tables, columns, constraints, indexes.
97
+
98
+ 1. Edit DDL files in `ztd/ddl/`.
99
+ 2. Run:
100
+
101
+ ```bash
102
+ npx ztd ztd-config
103
+ ```
104
+
105
+ This regenerates `tests/generated/ztd-row-map.generated.ts` from the updated schema.
106
+
107
+ 3. Update repository SQL to match the new schema.
108
+ 4. Update fixtures if result shapes changed.
109
+ 5. Run tests.
110
+
111
+ **Flow:** DDL -> Repository SQL -> Fixtures/Tests -> Application
112
+
113
+ ---
114
+
115
+ # Workflow B — Starting From *Repository Interface Changes*
116
+ Changing method signatures, adding new repository methods, etc.
117
+
118
+ 1. Modify the repository interface or implementation in `/src`.
119
+ 2. Use AI assistance to generate or update the SQL implementation.
120
+ 3. If the generated SQL conflicts with domain-specs or enums, update definitions first.
121
+ 4. Run ZTD tests.
122
+ 5. Regenerate config if SQL output shape changed.
123
+
124
+ **Flow:** Interface -> SQL -> Specs (if needed) -> Tests
125
+
126
+ ---
127
+
128
+ # Workflow C — Starting From *Repository SQL Logic Changes*
129
+ Bug fixes, refactoring, rewriting queries.
130
+
131
+ 1. Edit SQL inside the repository.
132
+ 2. Run ZTD tests.
133
+ 3. If intended behavior changes, update the appropriate file in `ztd/domain-specs/`.
134
+ 4. Update fixtures as needed.
135
+ 5. Regenerate config if result shape changed.
136
+
137
+ **Flow:** SQL -> Domain-specs -> Tests
138
+
139
+ ---
140
+
141
+ # Workflow D — Starting From *Enum or Domain Specification Changes*
142
+ Business rule changes or conceptual model updates.
143
+
144
+ ## Editing enums:
145
+
146
+ 1. Update the relevant `.md` file under `ztd/enums/`.
147
+ 2. Run:
148
+
149
+ ```bash
150
+ npx ztd ztd-config
151
+ ```
152
+
153
+ 3. Update repository SQL referencing enum values.
154
+ 4. Update fixtures/tests.
155
+
156
+ ## Editing domain-specs:
157
+
158
+ 1. Update the relevant `.md` file under `ztd/domain-specs/`.
159
+ 2. Update repository SQL to reflect the new semantics.
160
+ 3. Update or add tests.
161
+ 4. Update DDL only if the new rules require schema changes.
162
+
163
+ **Flow:** Specs/Enums -> SQL -> Tests -> (DDL if required)
164
+
165
+ ---
166
+
167
+ # Combined Real-World Examples
168
+
169
+ - Adding a new contract state:
170
+ enums -> domain-spec -> SQL -> config -> tests
171
+
172
+ - Adding a new table:
173
+ DDL -> config -> SQL -> fixtures -> tests
174
+
175
+ - Fixing business logic:
176
+ SQL -> domain-spec -> tests
177
+
178
+ ZTD ensures the development always converges into a consistent, validated workflow.
179
+
180
+ ---
181
+
182
+ # Human Responsibilities
183
+
184
+ Humans maintain:
185
+
186
+ - Schema definitions (`ztd/ddl`)
187
+ - Domain logic definitions (`ztd/domain-specs`)
188
+ - Domain enumerations (`ztd/enums`)
189
+ - Repository interfaces and architectural decisions
190
+ - Acceptance/review of AI-generated patches
191
+
192
+ Humans decide **what is correct**.
193
+
194
+ ---
195
+
196
+ # AI Responsibilities
197
+
198
+ AI must:
199
+
200
+ - Use domain-specs as the semantic source of truth
201
+ - Use enums as the canonical vocabulary source
202
+ - Use DDL as the physical structure constraint
203
+ - Generate SQL consistent with all definitions
204
+ - Update fixtures when needed
205
+ - Never modify `ztd/AGENTS.md` or `ztd/README.md` without explicit instruction
206
+
207
+ AI decides **how to implement**, but not **what is correct**.
208
+
209
+ ---
210
+
211
+ # ZTD CLI Responsibilities
212
+
213
+ ZTD CLI:
214
+
215
+ - Parses DDL to compute schema shapes
216
+ - Rewrites SQL via CTE shadowing for testing
217
+ - Generates `ztd-row-map.generated.ts`
218
+ - Enables deterministic, parallel SQL unit tests
219
+
220
+ ZTD is the verification engine that validates correctness beyond static typing.
221
+
222
+ ---
223
+
224
+ # Summary
225
+
226
+ This appendix documents how ZTD is used strictly as an **internal implementation and maintenance guide**.
227
+ It does not affect the runtime behavior of the application.
228
+ Its purpose is ensuring:
229
+
230
+ - Schema integrity
231
+ - SQL correctness
232
+ - Domain consistency
233
+ - Reliable AI-assisted development
234
+
235
+ With ZTD, **humans define the meaning**, **AI writes the implementation**, and **tests guarantee correctness**.
@@ -0,0 +1,207 @@
1
+ # Zero Table Dependency Project
2
+
3
+ This project organizes all SQL‑related artifacts under the `ztd/` directory, separating concerns so both humans and AI can collaborate effectively without interfering with each other's responsibilities.
4
+
5
+ ```
6
+ /ztd
7
+ /ddl
8
+ *.sql <- schema definitions
9
+ /domain-specs
10
+ *.md <- one behavior per file (one SQL block)
11
+ /enums
12
+ *.md <- one enum per file (one SQL block)
13
+ README.md <- documentation for the layout
14
+ AGENTS.md <- combined guidance for people and agents
15
+
16
+ /src <- application & repository code
17
+ /tests <- ZTD tests, fixtures, generated maps
18
+ ```
19
+
20
+ ## Generated files (important)
21
+
22
+ `tests/generated/` is auto-generated and must never be committed to git.
23
+
24
+ After cloning the repository (or in a clean environment), run:
25
+
26
+ ```bash
27
+ npx ztd ztd-config
28
+ ```
29
+
30
+ If TypeScript reports missing modules or type errors because `tests/generated/` is missing, run `npx ztd ztd-config`.
31
+
32
+ `tests/generated/ztd-layout.generated.ts` declares the directories above so the CLI and your tests always point at the correct files.
33
+
34
+ ---
35
+
36
+ # Principles
37
+
38
+ ### 1. Humans own the *definitions*
39
+ - DDL (physical schema)
40
+ - Domain specifications (business logic -> SQL semantics)
41
+ - Enums (canonical domain values)
42
+
43
+ ### 2. AI owns the *implementation*
44
+ - Repository SQL generation
45
+ - Test fixture updates
46
+ - Intermediate TypeScript structures
47
+ - SQL rewriting, parameter binding, shape resolution
48
+
49
+ ### 3. ZTD ensures these stay in sync
50
+ ZTD acts as the consistency layer ensuring:
51
+ - DDL ↔ SQL shape consistency
52
+ - domain-specs ↔ query logic consistency
53
+ - enums ↔ code‑level constants consistency
54
+
55
+ If any part diverges, ZTD tests fail deterministically.
56
+
57
+ ---
58
+
59
+ # Workflow Overview
60
+
61
+ Different tasks start from different entry points. Choose the workflow that matches what you want to change.
62
+
63
+ ---
64
+
65
+ # Workflow A — Starting From *DDL Changes*
66
+ (Adding tables/columns, changing constraints)
67
+
68
+ 1. Edit files under `ztd/ddl/`.
69
+ 2. Run:
70
+
71
+ ```bash
72
+ npx ztd ztd-config
73
+ ```
74
+
75
+ This regenerates `tests/generated/ztd-row-map.generated.ts` from the new schema.
76
+
77
+ 3. Update repository SQL so it matches the new schema.
78
+ 4. Update fixtures if shapes changed.
79
+ 5. Run tests. Any schema mismatch will fail fast.
80
+
81
+ **Flow:**
82
+ **DDL -> repository SQL -> fixtures/tests -> application**
83
+
84
+ ---
85
+
86
+ # Workflow B — Starting From *Repository Interface Changes*
87
+ (Adding a method, changing return types, etc.)
88
+
89
+ 1. Modify the repository interface or class in `/src`.
90
+ 2. Allow AI to generate the SQL needed to satisfy the interface.
91
+ 3. If the query contradicts domain-specs or enums, update specs first.
92
+ 4. Run ZTD tests to confirm logic is consistent.
93
+ 5. Regenerate ZTD config if result shapes changed.
94
+
95
+ **Flow:**
96
+ **repository interface -> SQL -> (update specs if needed) -> tests**
97
+
98
+ ---
99
+
100
+ # Workflow C — Starting From *Repository SQL Logic Changes*
101
+ (Fixing a bug, optimizing logic, rewriting a query)
102
+
103
+ 1. Edit SQL inside the repository.
104
+ 2. Run existing ZTD tests.
105
+ 3. If the intended behavior changes, update `ztd/domain-specs/`.
106
+ 4. Update fixtures if necessary.
107
+ 5. If SQL result shape changed, run:
108
+
109
+ ```bash
110
+ npx ztd ztd-config
111
+ ```
112
+
113
+ **Flow:**
114
+ **SQL -> domain-specs (if needed) -> fixtures/tests**
115
+
116
+ ---
117
+
118
+ # Workflow D — Starting From *Enums or Domain Spec Changes*
119
+ (Business rules change, new status added, new definition created)
120
+
121
+ ## For enums:
122
+
123
+ 1. Update the relevant `.md` file under `ztd/enums/`.
124
+ 2. Regenerate row-map:
125
+
126
+ ```bash
127
+ npx ztd ztd-config
128
+ ```
129
+
130
+ 3. Update SQL referencing enum values.
131
+ 4. Update domain-specs or repository SQL if behaviors change.
132
+ 5. Update fixtures and tests.
133
+
134
+ ## For domain-specs:
135
+
136
+ 1. Modify the `.md` spec in `ztd/domain-specs/`.
137
+ 2. Update SQL in `/src` to follow the new semantics.
138
+ 3. Update tests and fixtures.
139
+ 4. Update DDL only if the new behavior requires schema changes.
140
+
141
+ **Flow:**
142
+ **spec/enums -> SQL -> tests -> (DDL if required)**
143
+
144
+ ---
145
+
146
+ # Combined Real‑World Flow Examples
147
+
148
+ - **Add a new contract status**
149
+ enums -> domain-spec -> SQL -> config -> tests
150
+
151
+ - **Add a new table**
152
+ DDL -> config -> SQL -> fixtures -> tests
153
+
154
+ - **Fix business logic**
155
+ SQL -> domain-spec -> tests
156
+
157
+ ZTD ensures all changes converge into the same consistency pipeline.
158
+
159
+ ---
160
+
161
+ # Human Responsibilities
162
+
163
+ Humans maintain:
164
+
165
+ - Business logic definitions (`domain-specs`)
166
+ - Physical schema (`ddl`)
167
+ - Domain vocabularies (`enums`)
168
+ - High‑level repository interfaces
169
+ - Acceptance of AI-generated changes
170
+
171
+ Humans decide “what is correct.”
172
+
173
+ ---
174
+
175
+ # AI Responsibilities
176
+
177
+ AI must:
178
+
179
+ - Use domain-specs as the **semantic source of truth**
180
+ - Use enums as the **canonical vocabulary source**
181
+ - Use DDL as the **physical shape constraint**
182
+ - Generate repository SQL consistent with all three
183
+ - Regenerate fixtures and tests as instructed
184
+ - Never modify `ztd/AGENTS.md` or `ztd/README.md` unless explicitly asked
185
+
186
+ AI decides “how to implement” within those constraints.
187
+
188
+ ---
189
+
190
+ # ZTD CLI Responsibilities
191
+
192
+ ZTD CLI:
193
+
194
+ - Parses DDL files to build accurate table/column shapes
195
+ - Rewrites SQL with fixture-based CTE shadowing (via testkit adapters)
196
+ - Generates `ztd-row-map.generated.ts`
197
+ - Produces deterministic, parallelizable tests
198
+
199
+ ZTD is the verification engine guaranteeing correctness.
200
+
201
+ ---
202
+
203
+ # Summary
204
+
205
+ ZTD enables a workflow where **humans define meaning**, **AI writes implementation**, and **tests guarantee correctness**.
206
+
207
+ The project layout and workflows above ensure long-term maintainability, clarity, and full reproducibility of SQL logic independent of physical database state.
@@ -0,0 +1,30 @@
1
+ import { PostgreSqlContainer } from '@testcontainers/postgresql';
2
+
3
+ /**
4
+ * Vitest global setup.
5
+ *
6
+ * ZTD tests are safe to run in parallel against a single Postgres instance because pg-testkit
7
+ * rewrites CRUD into fixture-backed SELECT queries (no physical tables are created/mutated).
8
+ *
9
+ * This setup starts exactly one disposable Postgres container when DATABASE_URL is not provided,
10
+ * and shares the resulting DATABASE_URL with all Vitest workers.
11
+ */
12
+ export default async function globalSetup() {
13
+ const configuredUrl = process.env.DATABASE_URL;
14
+ if (configuredUrl && configuredUrl.length > 0) {
15
+ return () => undefined;
16
+ }
17
+
18
+ const container = new PostgreSqlContainer('postgres:18-alpine')
19
+ .withDatabase('ztd_playground')
20
+ .withUsername('postgres')
21
+ .withPassword('postgres');
22
+
23
+ const started = await container.start();
24
+ process.env.DATABASE_URL = started.getConnectionUri();
25
+
26
+ return async () => {
27
+ await started.stop();
28
+ };
29
+ }
30
+
@@ -0,0 +1,112 @@
1
+ // ZTD testkit helper - AUTO GENERATED
2
+ // ztd-cli emits this file during project bootstrapping to wire pg-testkit.
3
+ // Regenerate via npx ztd init (choose overwrite when prompted); avoid manual edits.
4
+
5
+ import path from 'node:path';
6
+ import { Client, types } from 'pg';
7
+ import type { ClientConfig, QueryResultRow } from 'pg';
8
+ import { createPgTestkitClient } from '@rawsql-ts/pg-testkit';
9
+ import type { PgQueryInput, PgQueryable } from '@rawsql-ts/pg-testkit';
10
+ import type { TableFixture } from '@rawsql-ts/testkit-core';
11
+
12
+ const ddlDirectories = [path.resolve(__dirname, '../../ztd/ddl')];
13
+
14
+ let sharedPgClient: Client | undefined;
15
+ let sharedQueryable: PgQueryable | undefined;
16
+
17
+ const { INT2, INT4, INT8, NUMERIC, DATE } = types.builtins;
18
+ const parseInteger = (value: string | null) => (value === null ? null : Number(value));
19
+ const parseNumeric = (value: string | null) => (value === null ? null : Number(value));
20
+
21
+ // Align pg parsers with the primitive shapes the fixtures assert in tests.
22
+ types.setTypeParser(INT2, parseInteger);
23
+ types.setTypeParser(INT4, parseInteger);
24
+ types.setTypeParser(INT8, parseInteger);
25
+ types.setTypeParser(NUMERIC, parseNumeric);
26
+ types.setTypeParser(DATE, (value) => value);
27
+
28
+ async function resolveDatabaseUrl(): Promise<string> {
29
+ const configuredUrl = process.env.DATABASE_URL;
30
+ if (configuredUrl) {
31
+ return configuredUrl;
32
+ }
33
+
34
+ throw new Error('DATABASE_URL is required. It should be provided by Vitest globalSetup or your environment.');
35
+ }
36
+
37
+ async function getPgClient(): Promise<Client> {
38
+ if (sharedPgClient) {
39
+ return sharedPgClient;
40
+ }
41
+
42
+ const databaseUrl = await resolveDatabaseUrl();
43
+
44
+ const clientConfig: ClientConfig = { connectionString: databaseUrl };
45
+ sharedPgClient = new Client(clientConfig);
46
+
47
+ // Keep the shared Client connected for the duration of the test run.
48
+ await sharedPgClient.connect();
49
+ sharedPgClient.once('end', () => {
50
+ sharedPgClient = undefined;
51
+ sharedQueryable = undefined;
52
+ });
53
+ process.once('exit', () => {
54
+ if (!sharedPgClient) {
55
+ return;
56
+ }
57
+
58
+ // Ensure node exits cleanly by closing the connection if tests end early.
59
+ void sharedPgClient.end();
60
+ });
61
+
62
+ return sharedPgClient;
63
+ }
64
+
65
+ async function getPgQueryable(): Promise<PgQueryable> {
66
+ if (sharedQueryable) {
67
+ return sharedQueryable;
68
+ }
69
+
70
+ const client = await getPgClient();
71
+
72
+ // Wrap the pg.Client to expose only the subset needed by pg-testkit.
73
+ const wrappedQueryable: PgQueryable = {
74
+ query: <T extends QueryResultRow>(textOrConfig: PgQueryInput, values?: unknown[]) =>
75
+ client.query<T>(textOrConfig as never, values),
76
+ release: () => {
77
+ // Release is intentionally a no-op because the shared client should stay open.
78
+ return;
79
+ }
80
+ };
81
+
82
+ sharedQueryable = wrappedQueryable;
83
+ return wrappedQueryable;
84
+ }
85
+
86
+ export type ZtdPlaygroundQueryResult<T extends QueryResultRow = QueryResultRow> = Promise<T[]>;
87
+
88
+ export type ZtdPlaygroundClient = {
89
+ query<T extends QueryResultRow = QueryResultRow>(text: string, values?: unknown[]): ZtdPlaygroundQueryResult<T>;
90
+ close(): Promise<void>;
91
+ };
92
+
93
+ export async function createTestkitClient(fixtures: TableFixture[]): Promise<ZtdPlaygroundClient> {
94
+ const queryable = await getPgQueryable();
95
+ // TableNameResolver keeps DDL and fixtures aligned on canonical schema-qualified identifiers like 'public.table_name'.
96
+ const driver = createPgTestkitClient({
97
+ connectionFactory: () => queryable,
98
+ tableRows: fixtures,
99
+ ddl: { directories: ddlDirectories }
100
+ });
101
+
102
+ // Expose a simplified query API so tests can assert on plain row arrays.
103
+ return {
104
+ async query<T extends QueryResultRow>(text: string, values?: unknown[]) {
105
+ const result = await driver.query<T>(text, values);
106
+ return result.rows;
107
+ },
108
+ close() {
109
+ return driver.close();
110
+ }
111
+ };
112
+ }
@@ -0,0 +1,8 @@
1
+ // GENERATED FILE. DO NOT EDIT.
2
+
3
+ export default {
4
+ ztdRootDir: 'ztd',
5
+ ddlDir: 'ztd/ddl',
6
+ enumsDir: 'ztd/enums',
7
+ domainSpecsDir: 'ztd/domain-specs',
8
+ };
@@ -0,0 +1,13 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ include: ['tests/**/*.test.ts'],
6
+ environment: 'node',
7
+ globals: true,
8
+ globalSetup: ['tests/support/global-setup.ts'],
9
+ // Starting a Postgres testcontainer can exceed the default 5s timeout on some machines.
10
+ testTimeout: 60_000,
11
+ hookTimeout: 60_000,
12
+ },
13
+ });
@@ -0,0 +1,103 @@
1
+ # AGENTS: Zero Table Dependency Definitions
2
+
3
+ ## Generated files (important)
4
+
5
+ - `tests/generated/` is auto-generated and must never be committed.
6
+ - After cloning the repository (or in a clean environment), run `npx ztd ztd-config`.
7
+ - If TypeScript reports missing modules or type errors because `tests/generated/` is missing, run `npx ztd ztd-config`.
8
+
9
+ ## DDL Specifications
10
+
11
+ You are an AI assistant responsible for reading and respecting the contents of this /ztd/ddl directory.
12
+
13
+ ### Purpose
14
+
15
+ This directory contains all canonical definitions of database structure, including CREATE TABLE, ALTER TABLE, constraints, and indexes. It is considered the **single source of truth** for database schema as interpreted by the ztd-cli.
16
+
17
+ ### Behavior Rules
18
+
19
+ - **Never modify files in this folder unless explicitly instructed by a human.**
20
+ - You may propose edits, reviews, or new DDL structures when asked, but you must preserve all human-authored structure, naming, and intent.
21
+ - All DDL statements **must be semicolon-terminated** and valid PostgreSQL syntax.
22
+ - You must not reorder statements arbitrarily; semantic meaning and dependency order must be preserved.
23
+ - Respect formatting conventions, identifier styles, and comments written by humans.
24
+ - When generating new tables or columns, infer types and constraints based on other schema examples or enums (if available).
25
+ - Maintain consistency in column ordering, naming style, and constraint patterns.
26
+ - When adding to existing definitions, do not remove human-authored comments unless told to.
27
+ - Do not introduce structural changes that conflict with domain-specs or enums.
28
+
29
+ ### Interaction with Other Sources
30
+
31
+ - Refer to /ztd/domain-specs for domain logic and behavioral definitions. These dictate *what* should exist in the schema.
32
+ - Refer to /ztd/enums for allowable value sets when defining enum-like columns or constraints.
33
+ - Always use those definitions as context when writing or editing this schema.
34
+
35
+ If uncertain, defer to human authorship and request clarification.
36
+
37
+ ## Domain Specifications
38
+
39
+ You are an AI agent reading this directory to interpret domain logic.
40
+
41
+ ### Instructions
42
+
43
+ - Treat each Markdown file as defining **one domain behavior**.
44
+ - Use the embedded SQL block (`sql ... `) as the **reference SELECT**.
45
+ - Only the first top-level SELECT block should be considered executable logic.
46
+ - Parameters may be written in :named format (e.g., :as_of). You must bind them as positional placeholders (e.g., $1, $2, ?) in generated code.
47
+ - Do not generate or modify files in this directory unless explicitly asked.
48
+
49
+ ### Assumptions
50
+
51
+ - `ztd-config` parses only DDL (`ztd/ddl/**/*.sql`) to generate row shapes.
52
+ - These specifications are for **humans and AI consumption** (documentation + reference SQL).
53
+ - Comments and descriptions exist to help you interpret logic correctly.
54
+
55
+ ### Rules
56
+
57
+ - Never ignore the human-written description above the SQL block.
58
+ - Keep exactly one executable SQL block per file (one file = one behavior).
59
+ - Do not reorder or optimize the SQL unless explicitly instructed.
60
+ - Preserve the semantic meaning as given in the specification.
61
+ - This folder defines **what** logic means. Your job is to reproduce that logic elsewhere (e.g., in src/ or tests).
62
+
63
+ If in doubt, ask for clarification or defer to human judgment.
64
+
65
+ ## Domain Enums
66
+
67
+ You are an AI assistant responsible for reading domain enum definitions from this folder.
68
+
69
+ ### Purpose
70
+
71
+ This directory defines canonical value sets (enums) such as status codes and plan tiers. These definitions inform your code generation logic, constraint enforcement, and vocabulary use.
72
+
73
+ ### Behavior Guidelines
74
+
75
+ - Read from the Markdown file containing SQL select ... from (values ...) blocks.
76
+ - Never invent magic numbers or enum values. Always use those explicitly defined here.
77
+ - Do not modify or append new enums unless explicitly instructed by a human.
78
+
79
+ ### SQL Rules
80
+
81
+ - Each SQL block defines an enum set.
82
+ - Keep exactly one executable SQL block per file (one file = one enum set).
83
+ - All blocks follow the form:
84
+
85
+ `sql
86
+ select v.*
87
+ from (
88
+ values
89
+ (1, 'some_code', 'some_label')
90
+ ) v(key, value, display_name);
91
+ `
92
+
93
+ - You must extract key and value pairs as the authoritative mapping.
94
+ - display_name,
95
+ ranking, or other metadata may be used where helpful (e.g., UI rendering or sorting).
96
+
97
+ ### Use in Code Generation
98
+
99
+ - Use these enums when generating SQL WHERE clauses, conditionals, or constants.
100
+ - When translating logic from /ztd/domain-specs, map references like :status__established to corresponding values here.
101
+ - Maintain full consistency with enum names and intent.
102
+
103
+ If a required enum is missing, raise an error or ask for human clarification.
@@ -0,0 +1,84 @@
1
+ # ZTD Definitions
2
+
3
+ This directory hosts the schema, domain-spec, and enum definitions that feed native ZTD workflows.
4
+
5
+ ## DDL Definitions
6
+
7
+ The ztd/ddl/ directory stores **Data Definition Language (DDL)** files that describe the database schema. These files include CREATE TABLE, ALTER TABLE, index declarations, and constraint definitions. ZTD treats the SQL files here as the single source of truth for schemas, so both humans and AI must reference this directory when evolving the structure.
8
+
9
+ ### Allowed Content and Structure
10
+
11
+ - **Schema Definition Files:** Core table structures live in ztd/ddl/ using CREATE TABLE statements, but you may also add related DDL such as ALTER TABLE commands or explicit index declarations that contribute to the schema contract.
12
+ - **Semantic Flexibility:** The directory supports multiple ways to describe schema changes (e.g., altering tables inline or via subsequent ALTER TABLE statements). The key is clarity and correctness so the CLI tooling can interpret the intended shape.
13
+
14
+ ### File Format and Execution
15
+
16
+ - **Executable SQL Scripts:** Every file should be valid PostgreSQL with semicolon-terminated statements and a consistent dependency ordering.
17
+ - **Integration with ZTD CLI:** The CLI parses these files to understand schema shapes. Treat this directory as authoritative: every schema change should be captured here as if it were applied to a clean database.
18
+
19
+ ### Maintenance Guidelines
20
+
21
+ - **Human-Maintained Schema:** Developers own the schema structure; AI tooling may only assist with targeted edits.
22
+ - **Conventions:** Follow the established naming, formatting, and typing patterns. Include comments to explain non-obvious schema choices.
23
+
24
+ ### Relationships
25
+
26
+ - /ztd/domain-specs: Translates schema structures into behavioral expectations.
27
+ - /ztd/enums: Provides the enum sets referenced by constraints or column defaults.
28
+
29
+ ## Domain Specifications
30
+
31
+ The ztd/domain-specs/ directory documents key domain behaviors as human-readable specifications.
32
+
33
+ ### Purpose
34
+
35
+ Each Markdown file describes one business concept, explains it in natural language, and pairs it with an example SELECT query inside a fenced SQL block. These specifications help AI agents understand **what** the domain logic should do without prescribing implementation details.
36
+
37
+ ### Format and Best Practices
38
+
39
+ - One file per concept with a prose explanation followed by an example SELECT.
40
+ - Keep exactly one executable SQL block per file (one file = one behavior).
41
+ - Named parameters (e.g., :as_of) signal intent; you may translate them into positional placeholders when generating code.
42
+ - Focus on semantics—use Markdown structuring (tables, bullets, etc.) to clarify the behavior.
43
+ - Always update the description before touching the SQL when the behavior evolves.
44
+
45
+ ### Relationships
46
+
47
+ - /ztd/ddl: Supplies the physical schema that backs the behavior.
48
+ - /ztd/enums: Provides the vocabularies referenced in the domain logic.
49
+
50
+ ## Domain Enums
51
+
52
+ The ztd/enums/ directory contains enumerated value sets such as statuses, tiers, or lifecycle states.
53
+
54
+ ### Purpose
55
+
56
+ These enums are human-maintained and support:
57
+
58
+ - AI-assisted SQL/code generation
59
+ - TypeScript constant generation
60
+ - Schema enforcement (e.g., CHECK constraints)
61
+ - Frontend label rendering via display names
62
+
63
+ ### Format and Structure
64
+
65
+ - The folder uses Markdown to keep the definitions readable.
66
+ - Each enum is documented in a single file using SELECT ... FROM (VALUES ...) blocks with explicit column aliases.
67
+
68
+ ### Required Structure
69
+
70
+ - Each row must include at least key and value columns.
71
+ - Optional metadata like display_name,
72
+ ranking, or sort_order may be added for UI/logic purposes.
73
+
74
+ ### Guidelines
75
+
76
+ - Keep naming conventions consistent and avoid duplicate value identifiers across unrelated enums.
77
+ - Ensure compatibility with /ztd/domain-specs and /ztd/ddl when expanding enums.
78
+ - Preserve human-readable display_name values as needed for front-end contexts.
79
+
80
+ ### Relationships
81
+
82
+ - /ztd/ddl: Referenced by constraints or lookup tables.
83
+ - /ztd/domain-specs: Provides the vocabulary for behavioral rules.
84
+ - src/: Maps enums to generated constants or query logic.