sqlew 5.2.0 → 5.2.1
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.
- package/CHANGELOG.md +2140 -2110
- package/LICENSE +190 -190
- package/NOTICE +24 -24
- package/README.md +204 -199
- package/dist/adapters/mysql-adapter.js +3 -3
- package/dist/adapters/postgresql-adapter.js +3 -3
- package/dist/cli/db-export.js +32 -32
- package/dist/cli/db-import.js +30 -30
- package/dist/cli/hooks/codex-transcript.d.ts +23 -0
- package/dist/cli/hooks/codex-transcript.d.ts.map +1 -0
- package/dist/cli/hooks/codex-transcript.js +134 -0
- package/dist/cli/hooks/codex-transcript.js.map +1 -0
- package/dist/cli/hooks/on-exit-plan.d.ts.map +1 -1
- package/dist/cli/hooks/on-exit-plan.js +30 -3
- package/dist/cli/hooks/on-exit-plan.js.map +1 -1
- package/dist/cli/hooks/on-prompt.d.ts.map +1 -1
- package/dist/cli/hooks/on-prompt.js +33 -16
- package/dist/cli/hooks/on-prompt.js.map +1 -1
- package/dist/cli/hooks/pr-adr.js +5 -5
- package/dist/cli/hooks/stdin-parser.d.ts +4 -2
- package/dist/cli/hooks/stdin-parser.d.ts.map +1 -1
- package/dist/cli/hooks/stdin-parser.js +79 -9
- package/dist/cli/hooks/stdin-parser.js.map +1 -1
- package/dist/cli/hooks/track-plan.js +15 -15
- package/dist/cli.js +48 -48
- package/dist/config/global-config.js +19 -19
- package/dist/database/migrations/v4/20251126000000_v4_bootstrap.js +32 -32
- package/dist/database/migrations/v4/20260102204000_v4_fix_decision_set_example.js +3 -3
- package/dist/help-data/constraint.toml +259 -259
- package/dist/help-data/decision.toml +845 -845
- package/dist/help-data/queue.toml +134 -134
- package/dist/server/tool-schemas.js +30 -30
- package/dist/tests/docker/native/db-init.js +9 -9
- package/dist/tests/unit/hooks/codex-hook-normalization.test.d.ts +7 -0
- package/dist/tests/unit/hooks/codex-hook-normalization.test.d.ts.map +1 -0
- package/dist/tests/unit/hooks/codex-hook-normalization.test.js +112 -0
- package/dist/tests/unit/hooks/codex-hook-normalization.test.js.map +1 -0
- package/dist/tests/unit/hooks/grok-hook-normalization.test.js +45 -7
- package/dist/tests/unit/hooks/grok-hook-normalization.test.js.map +1 -1
- package/dist/tests/utils/db-schema.js +48 -48
- package/dist/tests/utils/test-helpers.js +48 -48
- package/dist/tools/constraints/actions/get.js +5 -5
- package/dist/utils/project-root.d.ts +1 -0
- package/dist/utils/project-root.d.ts.map +1 -1
- package/dist/utils/project-root.js +6 -0
- package/dist/utils/project-root.js.map +1 -1
- package/docs/ADR_CONCEPTS.md +152 -152
- package/docs/CLI_USAGE.md +392 -392
- package/docs/CONFIGURATION.md +157 -157
- package/docs/CROSS_DATABASE.md +66 -66
- package/docs/DATABASE_AUTH.md +135 -135
- package/docs/HOOKS_GUIDE.md +116 -101
- package/docs/MIGRATION_TO_SAAS.md +176 -176
- package/docs/SHARED_DATABASE.md +108 -108
- package/package.json +88 -88
- package/scripts/copy-help-data.js +19 -19
- package/scripts/filter-test-output.js +78 -78
|
@@ -36,9 +36,9 @@ export async function disconnectDb(db) {
|
|
|
36
36
|
export async function dropAllTables(db, type) {
|
|
37
37
|
if (type === 'sqlite') {
|
|
38
38
|
// SQLite: Get all tables and views, then drop them
|
|
39
|
-
const objects = await db.raw(`
|
|
40
|
-
SELECT name, type FROM sqlite_master
|
|
41
|
-
WHERE type IN ('table', 'view') AND name NOT LIKE 'sqlite_%'
|
|
39
|
+
const objects = await db.raw(`
|
|
40
|
+
SELECT name, type FROM sqlite_master
|
|
41
|
+
WHERE type IN ('table', 'view') AND name NOT LIKE 'sqlite_%'
|
|
42
42
|
`);
|
|
43
43
|
await db.raw('PRAGMA foreign_keys = OFF');
|
|
44
44
|
for (const row of objects) {
|
|
@@ -55,19 +55,19 @@ export async function dropAllTables(db, type) {
|
|
|
55
55
|
// MySQL/MariaDB: Drop all views first, then tables
|
|
56
56
|
await db.raw('SET FOREIGN_KEY_CHECKS=0');
|
|
57
57
|
// Drop views
|
|
58
|
-
const views = await db.raw(`
|
|
59
|
-
SELECT TABLE_NAME
|
|
60
|
-
FROM INFORMATION_SCHEMA.TABLES
|
|
61
|
-
WHERE TABLE_SCHEMA = 'mcp_test' AND TABLE_TYPE = 'VIEW'
|
|
58
|
+
const views = await db.raw(`
|
|
59
|
+
SELECT TABLE_NAME
|
|
60
|
+
FROM INFORMATION_SCHEMA.TABLES
|
|
61
|
+
WHERE TABLE_SCHEMA = 'mcp_test' AND TABLE_TYPE = 'VIEW'
|
|
62
62
|
`);
|
|
63
63
|
for (const row of views[0]) {
|
|
64
64
|
await db.raw(`DROP VIEW IF EXISTS ??`, [row.TABLE_NAME]);
|
|
65
65
|
}
|
|
66
66
|
// Drop tables
|
|
67
|
-
const tables = await db.raw(`
|
|
68
|
-
SELECT TABLE_NAME
|
|
69
|
-
FROM INFORMATION_SCHEMA.TABLES
|
|
70
|
-
WHERE TABLE_SCHEMA = 'mcp_test' AND TABLE_TYPE = 'BASE TABLE'
|
|
67
|
+
const tables = await db.raw(`
|
|
68
|
+
SELECT TABLE_NAME
|
|
69
|
+
FROM INFORMATION_SCHEMA.TABLES
|
|
70
|
+
WHERE TABLE_SCHEMA = 'mcp_test' AND TABLE_TYPE = 'BASE TABLE'
|
|
71
71
|
`);
|
|
72
72
|
for (const row of tables[0]) {
|
|
73
73
|
await db.raw(`DROP TABLE IF EXISTS ??`, [row.TABLE_NAME]);
|
|
@@ -85,30 +85,30 @@ export async function dropAllTables(db, type) {
|
|
|
85
85
|
*/
|
|
86
86
|
export async function getTables(db, type) {
|
|
87
87
|
if (type === 'sqlite') {
|
|
88
|
-
const result = await db.raw(`
|
|
89
|
-
SELECT name FROM sqlite_master
|
|
90
|
-
WHERE type='table' AND name NOT LIKE 'sqlite_%' AND name != 'knex_migrations'
|
|
91
|
-
ORDER BY name
|
|
88
|
+
const result = await db.raw(`
|
|
89
|
+
SELECT name FROM sqlite_master
|
|
90
|
+
WHERE type='table' AND name NOT LIKE 'sqlite_%' AND name != 'knex_migrations'
|
|
91
|
+
ORDER BY name
|
|
92
92
|
`);
|
|
93
93
|
return result.map((r) => r.name);
|
|
94
94
|
}
|
|
95
95
|
else if (type === 'mysql' || type === 'mariadb') {
|
|
96
|
-
const result = await db.raw(`
|
|
97
|
-
SELECT TABLE_NAME
|
|
98
|
-
FROM INFORMATION_SCHEMA.TABLES
|
|
99
|
-
WHERE TABLE_SCHEMA = 'mcp_test'
|
|
100
|
-
AND TABLE_TYPE = 'BASE TABLE'
|
|
101
|
-
AND TABLE_NAME != 'knex_migrations'
|
|
102
|
-
ORDER BY TABLE_NAME
|
|
96
|
+
const result = await db.raw(`
|
|
97
|
+
SELECT TABLE_NAME
|
|
98
|
+
FROM INFORMATION_SCHEMA.TABLES
|
|
99
|
+
WHERE TABLE_SCHEMA = 'mcp_test'
|
|
100
|
+
AND TABLE_TYPE = 'BASE TABLE'
|
|
101
|
+
AND TABLE_NAME != 'knex_migrations'
|
|
102
|
+
ORDER BY TABLE_NAME
|
|
103
103
|
`);
|
|
104
104
|
return result[0].map((r) => r.TABLE_NAME);
|
|
105
105
|
}
|
|
106
106
|
else if (type === 'postgresql') {
|
|
107
|
-
const result = await db.raw(`
|
|
108
|
-
SELECT tablename
|
|
109
|
-
FROM pg_tables
|
|
110
|
-
WHERE schemaname = 'public' AND tablename != 'knex_migrations'
|
|
111
|
-
ORDER BY tablename
|
|
107
|
+
const result = await db.raw(`
|
|
108
|
+
SELECT tablename
|
|
109
|
+
FROM pg_tables
|
|
110
|
+
WHERE schemaname = 'public' AND tablename != 'knex_migrations'
|
|
111
|
+
ORDER BY tablename
|
|
112
112
|
`);
|
|
113
113
|
return result.rows.map((r) => r.tablename);
|
|
114
114
|
}
|
|
@@ -161,15 +161,15 @@ export async function getFKConstraints(db, type, tableName) {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
else if (type === 'mysql' || type === 'mariadb') {
|
|
164
|
-
const result = await db.raw(`
|
|
165
|
-
SELECT
|
|
166
|
-
COLUMN_NAME,
|
|
167
|
-
REFERENCED_TABLE_NAME,
|
|
168
|
-
REFERENCED_COLUMN_NAME
|
|
169
|
-
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
|
|
170
|
-
WHERE TABLE_SCHEMA = 'mcp_test'
|
|
171
|
-
AND TABLE_NAME = ?
|
|
172
|
-
AND REFERENCED_TABLE_NAME IS NOT NULL
|
|
164
|
+
const result = await db.raw(`
|
|
165
|
+
SELECT
|
|
166
|
+
COLUMN_NAME,
|
|
167
|
+
REFERENCED_TABLE_NAME,
|
|
168
|
+
REFERENCED_COLUMN_NAME
|
|
169
|
+
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
|
|
170
|
+
WHERE TABLE_SCHEMA = 'mcp_test'
|
|
171
|
+
AND TABLE_NAME = ?
|
|
172
|
+
AND REFERENCED_TABLE_NAME IS NOT NULL
|
|
173
173
|
`, [tableName]);
|
|
174
174
|
for (const fk of result[0]) {
|
|
175
175
|
constraints.push({
|
|
@@ -181,18 +181,18 @@ export async function getFKConstraints(db, type, tableName) {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
else if (type === 'postgresql') {
|
|
184
|
-
const result = await db.raw(`
|
|
185
|
-
SELECT
|
|
186
|
-
kcu.column_name,
|
|
187
|
-
ccu.table_name AS referenced_table,
|
|
188
|
-
ccu.column_name AS referenced_column
|
|
189
|
-
FROM information_schema.table_constraints AS tc
|
|
190
|
-
JOIN information_schema.key_column_usage AS kcu
|
|
191
|
-
ON tc.constraint_name = kcu.constraint_name
|
|
192
|
-
JOIN information_schema.constraint_column_usage AS ccu
|
|
193
|
-
ON ccu.constraint_name = tc.constraint_name
|
|
194
|
-
WHERE tc.constraint_type = 'FOREIGN KEY'
|
|
195
|
-
AND tc.table_name = ?
|
|
184
|
+
const result = await db.raw(`
|
|
185
|
+
SELECT
|
|
186
|
+
kcu.column_name,
|
|
187
|
+
ccu.table_name AS referenced_table,
|
|
188
|
+
ccu.column_name AS referenced_column
|
|
189
|
+
FROM information_schema.table_constraints AS tc
|
|
190
|
+
JOIN information_schema.key_column_usage AS kcu
|
|
191
|
+
ON tc.constraint_name = kcu.constraint_name
|
|
192
|
+
JOIN information_schema.constraint_column_usage AS ccu
|
|
193
|
+
ON ccu.constraint_name = tc.constraint_name
|
|
194
|
+
WHERE tc.constraint_type = 'FOREIGN KEY'
|
|
195
|
+
AND tc.table_name = ?
|
|
196
196
|
`, [tableName]);
|
|
197
197
|
for (const fk of result.rows) {
|
|
198
198
|
constraints.push({
|
|
@@ -92,9 +92,9 @@ export async function disconnectDb(db) {
|
|
|
92
92
|
export async function dropAllTables(db, type) {
|
|
93
93
|
if (type === 'sqlite') {
|
|
94
94
|
// SQLite: Get all tables and views, then drop them
|
|
95
|
-
const objects = await db.raw(`
|
|
96
|
-
SELECT name, type FROM sqlite_master
|
|
97
|
-
WHERE type IN ('table', 'view') AND name NOT LIKE 'sqlite_%'
|
|
95
|
+
const objects = await db.raw(`
|
|
96
|
+
SELECT name, type FROM sqlite_master
|
|
97
|
+
WHERE type IN ('table', 'view') AND name NOT LIKE 'sqlite_%'
|
|
98
98
|
`);
|
|
99
99
|
await db.raw('PRAGMA foreign_keys = OFF');
|
|
100
100
|
for (const row of objects) {
|
|
@@ -109,18 +109,18 @@ export async function dropAllTables(db, type) {
|
|
|
109
109
|
}
|
|
110
110
|
else if (type === 'mysql' || type === 'mariadb') {
|
|
111
111
|
await db.raw('SET FOREIGN_KEY_CHECKS=0');
|
|
112
|
-
const views = await db.raw(`
|
|
113
|
-
SELECT TABLE_NAME
|
|
114
|
-
FROM INFORMATION_SCHEMA.TABLES
|
|
115
|
-
WHERE TABLE_SCHEMA = 'mcp_test' AND TABLE_TYPE = 'VIEW'
|
|
112
|
+
const views = await db.raw(`
|
|
113
|
+
SELECT TABLE_NAME
|
|
114
|
+
FROM INFORMATION_SCHEMA.TABLES
|
|
115
|
+
WHERE TABLE_SCHEMA = 'mcp_test' AND TABLE_TYPE = 'VIEW'
|
|
116
116
|
`);
|
|
117
117
|
for (const row of views[0]) {
|
|
118
118
|
await db.raw(`DROP VIEW IF EXISTS ??`, [row.TABLE_NAME]);
|
|
119
119
|
}
|
|
120
|
-
const tables = await db.raw(`
|
|
121
|
-
SELECT TABLE_NAME
|
|
122
|
-
FROM INFORMATION_SCHEMA.TABLES
|
|
123
|
-
WHERE TABLE_SCHEMA = 'mcp_test' AND TABLE_TYPE = 'BASE TABLE'
|
|
120
|
+
const tables = await db.raw(`
|
|
121
|
+
SELECT TABLE_NAME
|
|
122
|
+
FROM INFORMATION_SCHEMA.TABLES
|
|
123
|
+
WHERE TABLE_SCHEMA = 'mcp_test' AND TABLE_TYPE = 'BASE TABLE'
|
|
124
124
|
`);
|
|
125
125
|
for (const row of tables[0]) {
|
|
126
126
|
await db.raw(`DROP TABLE IF EXISTS ??`, [row.TABLE_NAME]);
|
|
@@ -138,30 +138,30 @@ export async function dropAllTables(db, type) {
|
|
|
138
138
|
*/
|
|
139
139
|
export async function getTables(db, type) {
|
|
140
140
|
if (type === 'sqlite') {
|
|
141
|
-
const result = await db.raw(`
|
|
142
|
-
SELECT name FROM sqlite_master
|
|
143
|
-
WHERE type='table' AND name NOT LIKE 'sqlite_%' AND name != 'knex_migrations'
|
|
144
|
-
ORDER BY name
|
|
141
|
+
const result = await db.raw(`
|
|
142
|
+
SELECT name FROM sqlite_master
|
|
143
|
+
WHERE type='table' AND name NOT LIKE 'sqlite_%' AND name != 'knex_migrations'
|
|
144
|
+
ORDER BY name
|
|
145
145
|
`);
|
|
146
146
|
return result.map((r) => r.name);
|
|
147
147
|
}
|
|
148
148
|
else if (type === 'mysql' || type === 'mariadb') {
|
|
149
|
-
const result = await db.raw(`
|
|
150
|
-
SELECT TABLE_NAME
|
|
151
|
-
FROM INFORMATION_SCHEMA.TABLES
|
|
152
|
-
WHERE TABLE_SCHEMA = 'mcp_test'
|
|
153
|
-
AND TABLE_TYPE = 'BASE TABLE'
|
|
154
|
-
AND TABLE_NAME != 'knex_migrations'
|
|
155
|
-
ORDER BY TABLE_NAME
|
|
149
|
+
const result = await db.raw(`
|
|
150
|
+
SELECT TABLE_NAME
|
|
151
|
+
FROM INFORMATION_SCHEMA.TABLES
|
|
152
|
+
WHERE TABLE_SCHEMA = 'mcp_test'
|
|
153
|
+
AND TABLE_TYPE = 'BASE TABLE'
|
|
154
|
+
AND TABLE_NAME != 'knex_migrations'
|
|
155
|
+
ORDER BY TABLE_NAME
|
|
156
156
|
`);
|
|
157
157
|
return result[0].map((r) => r.TABLE_NAME);
|
|
158
158
|
}
|
|
159
159
|
else if (type === 'postgresql') {
|
|
160
|
-
const result = await db.raw(`
|
|
161
|
-
SELECT tablename
|
|
162
|
-
FROM pg_tables
|
|
163
|
-
WHERE schemaname = 'public' AND tablename != 'knex_migrations'
|
|
164
|
-
ORDER BY tablename
|
|
160
|
+
const result = await db.raw(`
|
|
161
|
+
SELECT tablename
|
|
162
|
+
FROM pg_tables
|
|
163
|
+
WHERE schemaname = 'public' AND tablename != 'knex_migrations'
|
|
164
|
+
ORDER BY tablename
|
|
165
165
|
`);
|
|
166
166
|
return result.rows.map((r) => r.tablename);
|
|
167
167
|
}
|
|
@@ -214,15 +214,15 @@ export async function getFKConstraints(db, type, tableName) {
|
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
else if (type === 'mysql' || type === 'mariadb') {
|
|
217
|
-
const result = await db.raw(`
|
|
218
|
-
SELECT
|
|
219
|
-
COLUMN_NAME,
|
|
220
|
-
REFERENCED_TABLE_NAME,
|
|
221
|
-
REFERENCED_COLUMN_NAME
|
|
222
|
-
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
|
|
223
|
-
WHERE TABLE_SCHEMA = 'mcp_test'
|
|
224
|
-
AND TABLE_NAME = ?
|
|
225
|
-
AND REFERENCED_TABLE_NAME IS NOT NULL
|
|
217
|
+
const result = await db.raw(`
|
|
218
|
+
SELECT
|
|
219
|
+
COLUMN_NAME,
|
|
220
|
+
REFERENCED_TABLE_NAME,
|
|
221
|
+
REFERENCED_COLUMN_NAME
|
|
222
|
+
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
|
|
223
|
+
WHERE TABLE_SCHEMA = 'mcp_test'
|
|
224
|
+
AND TABLE_NAME = ?
|
|
225
|
+
AND REFERENCED_TABLE_NAME IS NOT NULL
|
|
226
226
|
`, [tableName]);
|
|
227
227
|
for (const fk of result[0]) {
|
|
228
228
|
constraints.push({
|
|
@@ -234,18 +234,18 @@ export async function getFKConstraints(db, type, tableName) {
|
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
else if (type === 'postgresql') {
|
|
237
|
-
const result = await db.raw(`
|
|
238
|
-
SELECT
|
|
239
|
-
kcu.column_name,
|
|
240
|
-
ccu.table_name AS referenced_table,
|
|
241
|
-
ccu.column_name AS referenced_column
|
|
242
|
-
FROM information_schema.table_constraints AS tc
|
|
243
|
-
JOIN information_schema.key_column_usage AS kcu
|
|
244
|
-
ON tc.constraint_name = kcu.constraint_name
|
|
245
|
-
JOIN information_schema.constraint_column_usage AS ccu
|
|
246
|
-
ON ccu.constraint_name = tc.constraint_name
|
|
247
|
-
WHERE tc.constraint_type = 'FOREIGN KEY'
|
|
248
|
-
AND tc.table_name = ?
|
|
237
|
+
const result = await db.raw(`
|
|
238
|
+
SELECT
|
|
239
|
+
kcu.column_name,
|
|
240
|
+
ccu.table_name AS referenced_table,
|
|
241
|
+
ccu.column_name AS referenced_column
|
|
242
|
+
FROM information_schema.table_constraints AS tc
|
|
243
|
+
JOIN information_schema.key_column_usage AS kcu
|
|
244
|
+
ON tc.constraint_name = kcu.constraint_name
|
|
245
|
+
JOIN information_schema.constraint_column_usage AS ccu
|
|
246
|
+
ON ccu.constraint_name = tc.constraint_name
|
|
247
|
+
WHERE tc.constraint_type = 'FOREIGN KEY'
|
|
248
|
+
AND tc.table_name = ?
|
|
249
249
|
`, [tableName]);
|
|
250
250
|
for (const fk of result.rows) {
|
|
251
251
|
constraints.push({
|
|
@@ -86,11 +86,11 @@ export async function getConstraints(params, adapter) {
|
|
|
86
86
|
'c.priority',
|
|
87
87
|
knex.raw(`${db.dateFunction('c.ts')} as created_at`),
|
|
88
88
|
// Tags subquery
|
|
89
|
-
knex.raw(`(
|
|
90
|
-
SELECT ${db.stringAgg('t2.name', ',')}
|
|
91
|
-
FROM t_constraint_tags ct2
|
|
92
|
-
JOIN m_tags t2 ON ct2.tag_id = t2.id
|
|
93
|
-
WHERE ct2.constraint_id = c.id
|
|
89
|
+
knex.raw(`(
|
|
90
|
+
SELECT ${db.stringAgg('t2.name', ',')}
|
|
91
|
+
FROM t_constraint_tags ct2
|
|
92
|
+
JOIN m_tags t2 ON ct2.tag_id = t2.id
|
|
93
|
+
WHERE ct2.constraint_id = c.id
|
|
94
94
|
) as tags`),
|
|
95
95
|
]);
|
|
96
96
|
// Convert priority integer to string and parse tags
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Determines the project root directory with correct priority order:
|
|
5
5
|
* 0. CLAUDE_PROJECT_DIR environment variable (Claude Code / Grok Build hooks)
|
|
6
6
|
* 0b. GROK_WORKSPACE_ROOT environment variable (Grok Build hooks / MCP)
|
|
7
|
+
* 0c. CODEX_CWD environment variable (Codex hooks / MCP)
|
|
7
8
|
* 1. SQLEW_PROJECT_ROOT environment variable (MCP client can set this)
|
|
8
9
|
* 2. CLI --db-path argument (absolute path) → use dirname
|
|
9
10
|
* 3. CLI --config-path argument (absolute path) → use dirname
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-root.d.ts","sourceRoot":"","sources":["../../src/utils/project-root.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"project-root.d.ts","sourceRoot":"","sources":["../../src/utils/project-root.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,kBAAuB,GAAG,MAAM,CAuD7E;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAiB1D"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Determines the project root directory with correct priority order:
|
|
5
5
|
* 0. CLAUDE_PROJECT_DIR environment variable (Claude Code / Grok Build hooks)
|
|
6
6
|
* 0b. GROK_WORKSPACE_ROOT environment variable (Grok Build hooks / MCP)
|
|
7
|
+
* 0c. CODEX_CWD environment variable (Codex hooks / MCP)
|
|
7
8
|
* 1. SQLEW_PROJECT_ROOT environment variable (MCP client can set this)
|
|
8
9
|
* 2. CLI --db-path argument (absolute path) → use dirname
|
|
9
10
|
* 3. CLI --config-path argument (absolute path) → use dirname
|
|
@@ -72,6 +73,11 @@ export function determineProjectRoot(options = {}) {
|
|
|
72
73
|
if (grokWorkspaceRoot && path.isAbsolute(grokWorkspaceRoot)) {
|
|
73
74
|
return grokWorkspaceRoot.replace(/\\/g, '/');
|
|
74
75
|
}
|
|
76
|
+
// Priority 0c: CODEX_CWD (Codex hooks inject workspace cwd)
|
|
77
|
+
const codexCwd = process.env.CODEX_CWD;
|
|
78
|
+
if (codexCwd && path.isAbsolute(codexCwd)) {
|
|
79
|
+
return codexCwd.replace(/\\/g, '/');
|
|
80
|
+
}
|
|
75
81
|
// Priority 1: SQLEW_PROJECT_ROOT environment variable
|
|
76
82
|
// MCP clients (Junie, Claude Desktop, etc.) can set this to specify project directory
|
|
77
83
|
const envProjectRoot = process.env.SQLEW_PROJECT_ROOT;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-root.js","sourceRoot":"","sources":["../../src/utils/project-root.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"project-root.js","sourceRoot":"","sources":["../../src/utils/project-root.ts"],"names":[],"mappings":"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"}
|
package/docs/ADR_CONCEPTS.md
CHANGED
|
@@ -1,152 +1,152 @@
|
|
|
1
|
-
# Decisions & Constraints for AI Development
|
|
2
|
-
|
|
3
|
-
Persistent design context — decisions and constraints recorded as structured data — gives AI agents architectural memory across sessions. sqlew makes this zero-effort: plan normally, and hooks capture your decisions automatically.
|
|
4
|
-
|
|
5
|
-
## Why Persistent Design Context Matters
|
|
6
|
-
|
|
7
|
-
Research shows that recording design intent dramatically improves LLM code generation:
|
|
8
|
-
|
|
9
|
-
- **22.4% reduction** in overall development time
|
|
10
|
-
- **80% of tasks** completed faster with design intent available
|
|
11
|
-
- **50%+ improvement** in feature-addition and architectural-change tasks
|
|
12
|
-
- **137% increase** in design decision references by final tasks — AI learns to leverage past context more over time
|
|
13
|
-
|
|
14
|
-
> Kitayama, S. (2026). *Rediscovering Architectural Decision Records: How Persistent Design Context Improves LLM Code Generation*. [DOI](https://doi.org/10.36227/techrxiv.177205025.54351571/v1)
|
|
15
|
-
>
|
|
16
|
-
> Blog post: [Recording Design Intent for AI Efficiency](https://blog.sqlew.io/recording-design-intent-for-ai-efficiency)
|
|
17
|
-
|
|
18
|
-
## Key Benefits for AI-Driven Development
|
|
19
|
-
|
|
20
|
-
### Persistent Architectural Memory
|
|
21
|
-
- **Zero context loss** – AI agents remember every architectural decision across sessions
|
|
22
|
-
- **Rationale preservation** – Never forget WHY a decision was made, not just WHAT
|
|
23
|
-
- **Alternative tracking** – Document rejected options to prevent circular debates
|
|
24
|
-
- **Evolution history** – See how decisions changed over time with full version history
|
|
25
|
-
|
|
26
|
-
### Prevent Architectural Drift
|
|
27
|
-
- **Constraint enforcement** – Define architectural rules once, AI follows them forever
|
|
28
|
-
- **Pattern consistency** – AI generates code matching established patterns automatically
|
|
29
|
-
- **Anti-pattern prevention** – Document "what NOT to do" as enforceable constraints
|
|
30
|
-
- **Regression prevention** – AI won't reintroduce previously rejected approaches
|
|
31
|
-
|
|
32
|
-
### Intelligent Decision Discovery
|
|
33
|
-
- **Three-tier duplicate detection** – Gentle nudge (35-44), hard block (45-59), or auto-update (60+) based on similarity score
|
|
34
|
-
- **Similarity detection** – AI identifies duplicate or related decisions before creating new ones
|
|
35
|
-
- **Context-aware search** – Query by layer, tags, or relationships to find relevant decisions
|
|
36
|
-
- **Conflict detection** – Find decisions that contradict or supersede each other
|
|
37
|
-
|
|
38
|
-
### Extreme Efficiency
|
|
39
|
-
- **60-75% token reduction** – Query only relevant decisions instead of reading full files
|
|
40
|
-
- **Millisecond queries** – 2-50ms response times even with thousands of decisions
|
|
41
|
-
- **Scalable architecture** – Perform well with large decision histories
|
|
42
|
-
|
|
43
|
-
## How sqlew Works
|
|
44
|
-
|
|
45
|
-
```mermaid
|
|
46
|
-
flowchart LR
|
|
47
|
-
subgraph Claude Code
|
|
48
|
-
A[Plan Mode] -->|Create Plan| B[User Approval]
|
|
49
|
-
B -->|ExitPlanMode| C[Hook Triggered]
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
subgraph sqlew
|
|
53
|
-
C -->|Enqueue| D[Queue File]
|
|
54
|
-
D -->|QueueWatcher| E[(SQL Database)]
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
subgraph Next Session
|
|
58
|
-
F[AI Agent] -->|Query| E
|
|
59
|
-
E -->|Past Decisions| F
|
|
60
|
-
end
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
**Zero-effort knowledge accumulation:**
|
|
64
|
-
1. You plan your work normally in Claude Code
|
|
65
|
-
2. Hooks automatically capture decisions
|
|
66
|
-
3. Next session, AI queries past decisions via SQL
|
|
67
|
-
|
|
68
|
-
## Core Concepts
|
|
69
|
-
|
|
70
|
-
**Decisions** capture architectural choices with full context:
|
|
71
|
-
- **What** was decided (the decision itself)
|
|
72
|
-
- **Why** it was chosen (rationale, trade-offs)
|
|
73
|
-
- **What else** was considered (alternatives rejected)
|
|
74
|
-
- **Impact** on the system (consequences, affected components)
|
|
75
|
-
|
|
76
|
-
**Constraints** define architectural principles and rules:
|
|
77
|
-
- **Performance requirements** (response time limits, throughput goals)
|
|
78
|
-
- **Technology choices** ("must use PostgreSQL", "avoid microservices")
|
|
79
|
-
- **Coding standards** ("async/await only", "no any types")
|
|
80
|
-
- **Security policies** (authentication patterns, data handling rules)
|
|
81
|
-
|
|
82
|
-
**Lifecycle tracking:**
|
|
83
|
-
- **Status evolution** tracks decision lifecycle (draft → active → deprecated)
|
|
84
|
-
- **Auto-capture via Hooks** records decisions automatically from Plan Mode
|
|
85
|
-
|
|
86
|
-
```mermaid
|
|
87
|
-
erDiagram
|
|
88
|
-
DECISION ||--o{ TAG : has
|
|
89
|
-
DECISION {
|
|
90
|
-
string key
|
|
91
|
-
string value
|
|
92
|
-
string layer
|
|
93
|
-
string status
|
|
94
|
-
timestamp updated
|
|
95
|
-
}
|
|
96
|
-
CONSTRAINT ||--o{ TAG : has
|
|
97
|
-
CONSTRAINT {
|
|
98
|
-
string text
|
|
99
|
-
string category
|
|
100
|
-
int priority
|
|
101
|
-
}
|
|
102
|
-
TAG {
|
|
103
|
-
string name
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## SQL vs Markdown
|
|
108
|
-
|
|
109
|
-
| Traditional approach (Markdown) | sqlew approach (SQL) |
|
|
110
|
-
|--------------------------------|---------------------|
|
|
111
|
-
| Read entire files | Query specific decisions |
|
|
112
|
-
| Manual duplicate checking | Automatic similarity detection |
|
|
113
|
-
| Text parsing required | Structured, typed data |
|
|
114
|
-
| Linear token scaling | Constant-time lookups |
|
|
115
|
-
| File-based organization | Relational queries with JOINs |
|
|
116
|
-
|
|
117
|
-
### Why SQL?
|
|
118
|
-
|
|
119
|
-
Traditional text-based records force AI to:
|
|
120
|
-
- Read complete files even for simple queries
|
|
121
|
-
- Parse unstructured text to find relationships
|
|
122
|
-
- Manually detect duplicate or conflicting decisions
|
|
123
|
-
|
|
124
|
-
sqlew's **SQL-backed decision repository** enables AI to:
|
|
125
|
-
- Query by layer, tags, status in milliseconds (2-50ms)
|
|
126
|
-
- Join decisions with constraints
|
|
127
|
-
- Leverage similarity algorithms to prevent duplicates
|
|
128
|
-
- Scale to thousands of decisions without context explosion
|
|
129
|
-
|
|
130
|
-
**Token efficiency**: 60-75% reduction compared to reading Markdown files
|
|
131
|
-
|
|
132
|
-
### Why RDBMS + MCP?
|
|
133
|
-
|
|
134
|
-
**RDBMS (Relational Database)** provides efficient structured queries:
|
|
135
|
-
- **Indexed searches** – Find decisions by tags/layers in milliseconds, not seconds
|
|
136
|
-
- **JOIN operations** – Query related decisions and constraints in a single operation
|
|
137
|
-
- **Transaction support** – ACID guarantees ensure data integrity across concurrent AI agents
|
|
138
|
-
- **Scalability** – Handle thousands of decisions without performance degradation
|
|
139
|
-
|
|
140
|
-
**MCP (Model Context Protocol)** enables seamless AI integration:
|
|
141
|
-
- **Seamless DB connection** – AI agents access the database through a standardized protocol without direct DB setup
|
|
142
|
-
- **Self-documenting tools** – Tool descriptions teach AI how to use each operation, no manual onboarding needed
|
|
143
|
-
- **Type safety** – Structured parameters prevent errors and guide correct usage
|
|
144
|
-
- **Cross-session persistence** – Decisions survive beyond individual chat sessions
|
|
145
|
-
|
|
146
|
-
**Together**: AI agents gain SQL-powered decision capabilities without managing databases directly.
|
|
147
|
-
|
|
148
|
-
## References
|
|
149
|
-
|
|
150
|
-
- Kitayama, S. (2026). *Rediscovering Architectural Decision Records: How Persistent Design Context Improves LLM Code Generation*. [DOI](https://doi.org/10.36227/techrxiv.177205025.54351571/v1)
|
|
151
|
-
- Blog: [Recording Design Intent for AI Efficiency](https://blog.sqlew.io/recording-design-intent-for-ai-efficiency)
|
|
152
|
-
- The concept of Architecture Decision Records was originally proposed by Michael Nygard in 2011.
|
|
1
|
+
# Decisions & Constraints for AI Development
|
|
2
|
+
|
|
3
|
+
Persistent design context — decisions and constraints recorded as structured data — gives AI agents architectural memory across sessions. sqlew makes this zero-effort: plan normally, and hooks capture your decisions automatically.
|
|
4
|
+
|
|
5
|
+
## Why Persistent Design Context Matters
|
|
6
|
+
|
|
7
|
+
Research shows that recording design intent dramatically improves LLM code generation:
|
|
8
|
+
|
|
9
|
+
- **22.4% reduction** in overall development time
|
|
10
|
+
- **80% of tasks** completed faster with design intent available
|
|
11
|
+
- **50%+ improvement** in feature-addition and architectural-change tasks
|
|
12
|
+
- **137% increase** in design decision references by final tasks — AI learns to leverage past context more over time
|
|
13
|
+
|
|
14
|
+
> Kitayama, S. (2026). *Rediscovering Architectural Decision Records: How Persistent Design Context Improves LLM Code Generation*. [DOI](https://doi.org/10.36227/techrxiv.177205025.54351571/v1)
|
|
15
|
+
>
|
|
16
|
+
> Blog post: [Recording Design Intent for AI Efficiency](https://blog.sqlew.io/recording-design-intent-for-ai-efficiency)
|
|
17
|
+
|
|
18
|
+
## Key Benefits for AI-Driven Development
|
|
19
|
+
|
|
20
|
+
### Persistent Architectural Memory
|
|
21
|
+
- **Zero context loss** – AI agents remember every architectural decision across sessions
|
|
22
|
+
- **Rationale preservation** – Never forget WHY a decision was made, not just WHAT
|
|
23
|
+
- **Alternative tracking** – Document rejected options to prevent circular debates
|
|
24
|
+
- **Evolution history** – See how decisions changed over time with full version history
|
|
25
|
+
|
|
26
|
+
### Prevent Architectural Drift
|
|
27
|
+
- **Constraint enforcement** – Define architectural rules once, AI follows them forever
|
|
28
|
+
- **Pattern consistency** – AI generates code matching established patterns automatically
|
|
29
|
+
- **Anti-pattern prevention** – Document "what NOT to do" as enforceable constraints
|
|
30
|
+
- **Regression prevention** – AI won't reintroduce previously rejected approaches
|
|
31
|
+
|
|
32
|
+
### Intelligent Decision Discovery
|
|
33
|
+
- **Three-tier duplicate detection** – Gentle nudge (35-44), hard block (45-59), or auto-update (60+) based on similarity score
|
|
34
|
+
- **Similarity detection** – AI identifies duplicate or related decisions before creating new ones
|
|
35
|
+
- **Context-aware search** – Query by layer, tags, or relationships to find relevant decisions
|
|
36
|
+
- **Conflict detection** – Find decisions that contradict or supersede each other
|
|
37
|
+
|
|
38
|
+
### Extreme Efficiency
|
|
39
|
+
- **60-75% token reduction** – Query only relevant decisions instead of reading full files
|
|
40
|
+
- **Millisecond queries** – 2-50ms response times even with thousands of decisions
|
|
41
|
+
- **Scalable architecture** – Perform well with large decision histories
|
|
42
|
+
|
|
43
|
+
## How sqlew Works
|
|
44
|
+
|
|
45
|
+
```mermaid
|
|
46
|
+
flowchart LR
|
|
47
|
+
subgraph Claude Code
|
|
48
|
+
A[Plan Mode] -->|Create Plan| B[User Approval]
|
|
49
|
+
B -->|ExitPlanMode| C[Hook Triggered]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
subgraph sqlew
|
|
53
|
+
C -->|Enqueue| D[Queue File]
|
|
54
|
+
D -->|QueueWatcher| E[(SQL Database)]
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
subgraph Next Session
|
|
58
|
+
F[AI Agent] -->|Query| E
|
|
59
|
+
E -->|Past Decisions| F
|
|
60
|
+
end
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Zero-effort knowledge accumulation:**
|
|
64
|
+
1. You plan your work normally in Claude Code
|
|
65
|
+
2. Hooks automatically capture decisions
|
|
66
|
+
3. Next session, AI queries past decisions via SQL
|
|
67
|
+
|
|
68
|
+
## Core Concepts
|
|
69
|
+
|
|
70
|
+
**Decisions** capture architectural choices with full context:
|
|
71
|
+
- **What** was decided (the decision itself)
|
|
72
|
+
- **Why** it was chosen (rationale, trade-offs)
|
|
73
|
+
- **What else** was considered (alternatives rejected)
|
|
74
|
+
- **Impact** on the system (consequences, affected components)
|
|
75
|
+
|
|
76
|
+
**Constraints** define architectural principles and rules:
|
|
77
|
+
- **Performance requirements** (response time limits, throughput goals)
|
|
78
|
+
- **Technology choices** ("must use PostgreSQL", "avoid microservices")
|
|
79
|
+
- **Coding standards** ("async/await only", "no any types")
|
|
80
|
+
- **Security policies** (authentication patterns, data handling rules)
|
|
81
|
+
|
|
82
|
+
**Lifecycle tracking:**
|
|
83
|
+
- **Status evolution** tracks decision lifecycle (draft → active → deprecated)
|
|
84
|
+
- **Auto-capture via Hooks** records decisions automatically from Plan Mode
|
|
85
|
+
|
|
86
|
+
```mermaid
|
|
87
|
+
erDiagram
|
|
88
|
+
DECISION ||--o{ TAG : has
|
|
89
|
+
DECISION {
|
|
90
|
+
string key
|
|
91
|
+
string value
|
|
92
|
+
string layer
|
|
93
|
+
string status
|
|
94
|
+
timestamp updated
|
|
95
|
+
}
|
|
96
|
+
CONSTRAINT ||--o{ TAG : has
|
|
97
|
+
CONSTRAINT {
|
|
98
|
+
string text
|
|
99
|
+
string category
|
|
100
|
+
int priority
|
|
101
|
+
}
|
|
102
|
+
TAG {
|
|
103
|
+
string name
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## SQL vs Markdown
|
|
108
|
+
|
|
109
|
+
| Traditional approach (Markdown) | sqlew approach (SQL) |
|
|
110
|
+
|--------------------------------|---------------------|
|
|
111
|
+
| Read entire files | Query specific decisions |
|
|
112
|
+
| Manual duplicate checking | Automatic similarity detection |
|
|
113
|
+
| Text parsing required | Structured, typed data |
|
|
114
|
+
| Linear token scaling | Constant-time lookups |
|
|
115
|
+
| File-based organization | Relational queries with JOINs |
|
|
116
|
+
|
|
117
|
+
### Why SQL?
|
|
118
|
+
|
|
119
|
+
Traditional text-based records force AI to:
|
|
120
|
+
- Read complete files even for simple queries
|
|
121
|
+
- Parse unstructured text to find relationships
|
|
122
|
+
- Manually detect duplicate or conflicting decisions
|
|
123
|
+
|
|
124
|
+
sqlew's **SQL-backed decision repository** enables AI to:
|
|
125
|
+
- Query by layer, tags, status in milliseconds (2-50ms)
|
|
126
|
+
- Join decisions with constraints
|
|
127
|
+
- Leverage similarity algorithms to prevent duplicates
|
|
128
|
+
- Scale to thousands of decisions without context explosion
|
|
129
|
+
|
|
130
|
+
**Token efficiency**: 60-75% reduction compared to reading Markdown files
|
|
131
|
+
|
|
132
|
+
### Why RDBMS + MCP?
|
|
133
|
+
|
|
134
|
+
**RDBMS (Relational Database)** provides efficient structured queries:
|
|
135
|
+
- **Indexed searches** – Find decisions by tags/layers in milliseconds, not seconds
|
|
136
|
+
- **JOIN operations** – Query related decisions and constraints in a single operation
|
|
137
|
+
- **Transaction support** – ACID guarantees ensure data integrity across concurrent AI agents
|
|
138
|
+
- **Scalability** – Handle thousands of decisions without performance degradation
|
|
139
|
+
|
|
140
|
+
**MCP (Model Context Protocol)** enables seamless AI integration:
|
|
141
|
+
- **Seamless DB connection** – AI agents access the database through a standardized protocol without direct DB setup
|
|
142
|
+
- **Self-documenting tools** – Tool descriptions teach AI how to use each operation, no manual onboarding needed
|
|
143
|
+
- **Type safety** – Structured parameters prevent errors and guide correct usage
|
|
144
|
+
- **Cross-session persistence** – Decisions survive beyond individual chat sessions
|
|
145
|
+
|
|
146
|
+
**Together**: AI agents gain SQL-powered decision capabilities without managing databases directly.
|
|
147
|
+
|
|
148
|
+
## References
|
|
149
|
+
|
|
150
|
+
- Kitayama, S. (2026). *Rediscovering Architectural Decision Records: How Persistent Design Context Improves LLM Code Generation*. [DOI](https://doi.org/10.36227/techrxiv.177205025.54351571/v1)
|
|
151
|
+
- Blog: [Recording Design Intent for AI Efficiency](https://blog.sqlew.io/recording-design-intent-for-ai-efficiency)
|
|
152
|
+
- The concept of Architecture Decision Records was originally proposed by Michael Nygard in 2011.
|