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.
Files changed (57) hide show
  1. package/CHANGELOG.md +2140 -2110
  2. package/LICENSE +190 -190
  3. package/NOTICE +24 -24
  4. package/README.md +204 -199
  5. package/dist/adapters/mysql-adapter.js +3 -3
  6. package/dist/adapters/postgresql-adapter.js +3 -3
  7. package/dist/cli/db-export.js +32 -32
  8. package/dist/cli/db-import.js +30 -30
  9. package/dist/cli/hooks/codex-transcript.d.ts +23 -0
  10. package/dist/cli/hooks/codex-transcript.d.ts.map +1 -0
  11. package/dist/cli/hooks/codex-transcript.js +134 -0
  12. package/dist/cli/hooks/codex-transcript.js.map +1 -0
  13. package/dist/cli/hooks/on-exit-plan.d.ts.map +1 -1
  14. package/dist/cli/hooks/on-exit-plan.js +30 -3
  15. package/dist/cli/hooks/on-exit-plan.js.map +1 -1
  16. package/dist/cli/hooks/on-prompt.d.ts.map +1 -1
  17. package/dist/cli/hooks/on-prompt.js +33 -16
  18. package/dist/cli/hooks/on-prompt.js.map +1 -1
  19. package/dist/cli/hooks/pr-adr.js +5 -5
  20. package/dist/cli/hooks/stdin-parser.d.ts +4 -2
  21. package/dist/cli/hooks/stdin-parser.d.ts.map +1 -1
  22. package/dist/cli/hooks/stdin-parser.js +79 -9
  23. package/dist/cli/hooks/stdin-parser.js.map +1 -1
  24. package/dist/cli/hooks/track-plan.js +15 -15
  25. package/dist/cli.js +48 -48
  26. package/dist/config/global-config.js +19 -19
  27. package/dist/database/migrations/v4/20251126000000_v4_bootstrap.js +32 -32
  28. package/dist/database/migrations/v4/20260102204000_v4_fix_decision_set_example.js +3 -3
  29. package/dist/help-data/constraint.toml +259 -259
  30. package/dist/help-data/decision.toml +845 -845
  31. package/dist/help-data/queue.toml +134 -134
  32. package/dist/server/tool-schemas.js +30 -30
  33. package/dist/tests/docker/native/db-init.js +9 -9
  34. package/dist/tests/unit/hooks/codex-hook-normalization.test.d.ts +7 -0
  35. package/dist/tests/unit/hooks/codex-hook-normalization.test.d.ts.map +1 -0
  36. package/dist/tests/unit/hooks/codex-hook-normalization.test.js +112 -0
  37. package/dist/tests/unit/hooks/codex-hook-normalization.test.js.map +1 -0
  38. package/dist/tests/unit/hooks/grok-hook-normalization.test.js +45 -7
  39. package/dist/tests/unit/hooks/grok-hook-normalization.test.js.map +1 -1
  40. package/dist/tests/utils/db-schema.js +48 -48
  41. package/dist/tests/utils/test-helpers.js +48 -48
  42. package/dist/tools/constraints/actions/get.js +5 -5
  43. package/dist/utils/project-root.d.ts +1 -0
  44. package/dist/utils/project-root.d.ts.map +1 -1
  45. package/dist/utils/project-root.js +6 -0
  46. package/dist/utils/project-root.js.map +1 -1
  47. package/docs/ADR_CONCEPTS.md +152 -152
  48. package/docs/CLI_USAGE.md +392 -392
  49. package/docs/CONFIGURATION.md +157 -157
  50. package/docs/CROSS_DATABASE.md +66 -66
  51. package/docs/DATABASE_AUTH.md +135 -135
  52. package/docs/HOOKS_GUIDE.md +116 -101
  53. package/docs/MIGRATION_TO_SAAS.md +176 -176
  54. package/docs/SHARED_DATABASE.md +108 -108
  55. package/package.json +88 -88
  56. package/scripts/copy-help-data.js +19 -19
  57. package/scripts/filter-test-output.js +78 -78
package/dist/cli.js CHANGED
@@ -111,54 +111,54 @@ function formatTable(data, headers) {
111
111
  * Show help message
112
112
  */
113
113
  function showHelp() {
114
- console.log(`
115
- sqlew CLI - Query and database migration tool for mcp-sqlew
116
-
117
- USAGE:
118
- sqlew <command> [options]
119
-
120
- RECOMMENDED SETUP (v5.0.0+):
121
- The sqlew-plugin is now the recommended way to install Skills, Hooks, and Agents.
122
-
123
- /plugin marketplace add sqlew-io/sqlew-plugin
124
- /plugin add sqlew
125
-
126
- For more info: https://github.com/sqlew-io/sqlew-plugin
127
-
128
- LEGACY COMMANDS:
129
- Setup (deprecated - use sqlew-plugin instead):
130
- --init Legacy initialization (global rules + gitignore)
131
-
132
- Database:
133
- db:export Export project data to JSON format (data-only, for append-import)
134
- db:import Import project data from JSON export (append to existing database)
135
-
136
- Claude Code Hooks (internal use):
137
- suggest Find related decisions (PreToolUse hook for Task)
138
- track-plan Track plan files (PreToolUse hook for Write)
139
- save Save decisions on code edit (PostToolUse hook for Edit|Write)
140
- check-completion Check task completion (PostToolUse hook for TodoWrite)
141
- mark-done Mark decisions as implemented (Git hooks or manual)
142
-
143
- Plan Mode Hooks (internal use):
144
- on-enter-plan Inject TOML template (PostToolUse hook for EnterPlanMode)
145
- on-exit-plan Prompt TOML documentation (PostToolUse hook for ExitPlanMode)
146
- on-subagent-stop Process Plan agent completion (SubagentStop hook)
147
- on-stop Process main agent stop (Stop hook)
148
- on-prompt Plan mode enforcement (UserPromptSubmit hook)
149
- pr-adr PR ADR enforcement (PreToolUse hook for Bash)
150
-
151
- OPTIONS:
152
- --init Legacy initialization
153
- --help Show this help message
154
-
155
- EXAMPLES:
156
- # Legacy initialization (prefer sqlew-plugin instead)
157
- sqlew --init
158
-
159
- For more information on commands, run:
160
- npm run db:export -- --help
161
- npm run db:import -- --help
114
+ console.log(`
115
+ sqlew CLI - Query and database migration tool for mcp-sqlew
116
+
117
+ USAGE:
118
+ sqlew <command> [options]
119
+
120
+ RECOMMENDED SETUP (v5.0.0+):
121
+ The sqlew-plugin is now the recommended way to install Skills, Hooks, and Agents.
122
+
123
+ /plugin marketplace add sqlew-io/sqlew-plugin
124
+ /plugin add sqlew
125
+
126
+ For more info: https://github.com/sqlew-io/sqlew-plugin
127
+
128
+ LEGACY COMMANDS:
129
+ Setup (deprecated - use sqlew-plugin instead):
130
+ --init Legacy initialization (global rules + gitignore)
131
+
132
+ Database:
133
+ db:export Export project data to JSON format (data-only, for append-import)
134
+ db:import Import project data from JSON export (append to existing database)
135
+
136
+ Claude Code Hooks (internal use):
137
+ suggest Find related decisions (PreToolUse hook for Task)
138
+ track-plan Track plan files (PreToolUse hook for Write)
139
+ save Save decisions on code edit (PostToolUse hook for Edit|Write)
140
+ check-completion Check task completion (PostToolUse hook for TodoWrite)
141
+ mark-done Mark decisions as implemented (Git hooks or manual)
142
+
143
+ Plan Mode Hooks (internal use):
144
+ on-enter-plan Inject TOML template (PostToolUse hook for EnterPlanMode)
145
+ on-exit-plan Prompt TOML documentation (PostToolUse hook for ExitPlanMode)
146
+ on-subagent-stop Process Plan agent completion (SubagentStop hook)
147
+ on-stop Process main agent stop (Stop hook)
148
+ on-prompt Plan mode enforcement (UserPromptSubmit hook)
149
+ pr-adr PR ADR enforcement (PreToolUse hook for Bash)
150
+
151
+ OPTIONS:
152
+ --init Legacy initialization
153
+ --help Show this help message
154
+
155
+ EXAMPLES:
156
+ # Legacy initialization (prefer sqlew-plugin instead)
157
+ sqlew --init
158
+
159
+ For more information on commands, run:
160
+ npm run db:export -- --help
161
+ npm run db:import -- --help
162
162
  `);
163
163
  }
164
164
  // ============================================================================
@@ -179,25 +179,25 @@ export function getSessionCacheDir() {
179
179
  // Configuration Loading
180
180
  // ============================================================================
181
181
  /** Default config.toml template for new installations */
182
- const CONFIG_TOML_TEMPLATE = `# ~/.config/sqlew/config.toml - Global sqlew configuration
183
- # This config applies to all projects unless overridden by project-local config
184
-
185
- [database]
186
- # Default database type: sqlite | mysql | postgresql | cloud
187
- # type = "sqlite"
188
-
189
- # SQLite: default path (uncomment to customize)
190
- # path = "~/.config/sqlew/sqlew-shared.db"
191
-
192
- # MySQL example:
193
- # type = "mysql"
194
- # [database.connection]
195
- # host = "127.0.0.1"
196
- # port = 3306
197
- # database = "sqlew"
198
-
199
- # SaaS/Cloud mode:
200
- # type = "cloud"
182
+ const CONFIG_TOML_TEMPLATE = `# ~/.config/sqlew/config.toml - Global sqlew configuration
183
+ # This config applies to all projects unless overridden by project-local config
184
+
185
+ [database]
186
+ # Default database type: sqlite | mysql | postgresql | cloud
187
+ # type = "sqlite"
188
+
189
+ # SQLite: default path (uncomment to customize)
190
+ # path = "~/.config/sqlew/sqlew-shared.db"
191
+
192
+ # MySQL example:
193
+ # type = "mysql"
194
+ # [database.connection]
195
+ # host = "127.0.0.1"
196
+ # port = 3306
197
+ # database = "sqlew"
198
+
199
+ # SaaS/Cloud mode:
200
+ # type = "cloud"
201
201
  `;
202
202
  /**
203
203
  * Ensure global config directory exists
@@ -484,18 +484,18 @@ export async function up(knex) {
484
484
  const existingLayers = await knex('v4_layers').count('* as count').first();
485
485
  if (!existingLayers || Number(existingLayers.count) === 0) {
486
486
  if (db.isPostgreSQL) {
487
- await knex.raw(`
488
- INSERT INTO v4_layers (id, name) VALUES
489
- (1, 'presentation'), (2, 'business'), (3, 'data'), (4, 'infrastructure'),
490
- (5, 'cross-cutting'), (6, 'documentation'), (7, 'planning'), (8, 'coordination'), (9, 'review')
491
- ON CONFLICT (id) DO NOTHING
487
+ await knex.raw(`
488
+ INSERT INTO v4_layers (id, name) VALUES
489
+ (1, 'presentation'), (2, 'business'), (3, 'data'), (4, 'infrastructure'),
490
+ (5, 'cross-cutting'), (6, 'documentation'), (7, 'planning'), (8, 'coordination'), (9, 'review')
491
+ ON CONFLICT (id) DO NOTHING
492
492
  `);
493
493
  }
494
494
  else {
495
- await knex.raw(`
496
- INSERT ${insertIgnore} INTO v4_layers (id, name) VALUES
497
- (1, 'presentation'), (2, 'business'), (3, 'data'), (4, 'infrastructure'),
498
- (5, 'cross-cutting'), (6, 'documentation'), (7, 'planning'), (8, 'coordination'), (9, 'review')
495
+ await knex.raw(`
496
+ INSERT ${insertIgnore} INTO v4_layers (id, name) VALUES
497
+ (1, 'presentation'), (2, 'business'), (3, 'data'), (4, 'infrastructure'),
498
+ (5, 'cross-cutting'), (6, 'documentation'), (7, 'planning'), (8, 'coordination'), (9, 'review')
499
499
  `);
500
500
  }
501
501
  console.error(' ✓ Layers seeded (9)');
@@ -504,16 +504,16 @@ export async function up(knex) {
504
504
  const existingCategories = await knex('v4_constraint_categories').count('* as count').first();
505
505
  if (!existingCategories || Number(existingCategories.count) === 0) {
506
506
  if (db.isPostgreSQL) {
507
- await knex.raw(`
508
- INSERT INTO v4_constraint_categories (name) VALUES
509
- ('architecture'), ('security'), ('performance'), ('compatibility'), ('maintainability')
510
- ON CONFLICT (name) DO NOTHING
507
+ await knex.raw(`
508
+ INSERT INTO v4_constraint_categories (name) VALUES
509
+ ('architecture'), ('security'), ('performance'), ('compatibility'), ('maintainability')
510
+ ON CONFLICT (name) DO NOTHING
511
511
  `);
512
512
  }
513
513
  else {
514
- await knex.raw(`
515
- INSERT ${insertIgnore} INTO v4_constraint_categories (name) VALUES
516
- ('architecture'), ('security'), ('performance'), ('compatibility'), ('maintainability')
514
+ await knex.raw(`
515
+ INSERT ${insertIgnore} INTO v4_constraint_categories (name) VALUES
516
+ ('architecture'), ('security'), ('performance'), ('compatibility'), ('maintainability')
517
517
  `);
518
518
  }
519
519
  console.error(' ✓ Constraint categories seeded (5)');
@@ -522,16 +522,16 @@ export async function up(knex) {
522
522
  const existingStatuses = await knex('v4_task_statuses').count('* as count').first();
523
523
  if (!existingStatuses || Number(existingStatuses.count) === 0) {
524
524
  if (db.isPostgreSQL) {
525
- await knex.raw(`
526
- INSERT INTO v4_task_statuses (id, name) VALUES
527
- (1, 'todo'), (2, 'in_progress'), (3, 'waiting_review'), (4, 'blocked'), (5, 'done'), (6, 'archived'), (7, 'rejected')
528
- ON CONFLICT (id) DO NOTHING
525
+ await knex.raw(`
526
+ INSERT INTO v4_task_statuses (id, name) VALUES
527
+ (1, 'todo'), (2, 'in_progress'), (3, 'waiting_review'), (4, 'blocked'), (5, 'done'), (6, 'archived'), (7, 'rejected')
528
+ ON CONFLICT (id) DO NOTHING
529
529
  `);
530
530
  }
531
531
  else {
532
- await knex.raw(`
533
- INSERT ${insertIgnore} INTO v4_task_statuses (id, name) VALUES
534
- (1, 'todo'), (2, 'in_progress'), (3, 'waiting_review'), (4, 'blocked'), (5, 'done'), (6, 'archived'), (7, 'rejected')
532
+ await knex.raw(`
533
+ INSERT ${insertIgnore} INTO v4_task_statuses (id, name) VALUES
534
+ (1, 'todo'), (2, 'in_progress'), (3, 'waiting_review'), (4, 'blocked'), (5, 'done'), (6, 'archived'), (7, 'rejected')
535
535
  `);
536
536
  }
537
537
  console.error(' ✓ Task statuses seeded (7)');
@@ -554,18 +554,18 @@ export async function up(knex) {
554
554
  const existingTags = await knex('v4_tags').count('* as count').first();
555
555
  if (!existingTags || Number(existingTags.count) === 0) {
556
556
  if (db.isPostgreSQL) {
557
- await knex.raw(`
558
- INSERT INTO v4_tags (project_id, name) VALUES
559
- (1, 'authentication'), (1, 'authorization'), (1, 'validation'), (1, 'error-handling'),
560
- (1, 'logging'), (1, 'performance'), (1, 'security'), (1, 'testing')
561
- ON CONFLICT (project_id, name) DO NOTHING
557
+ await knex.raw(`
558
+ INSERT INTO v4_tags (project_id, name) VALUES
559
+ (1, 'authentication'), (1, 'authorization'), (1, 'validation'), (1, 'error-handling'),
560
+ (1, 'logging'), (1, 'performance'), (1, 'security'), (1, 'testing')
561
+ ON CONFLICT (project_id, name) DO NOTHING
562
562
  `);
563
563
  }
564
564
  else {
565
- await knex.raw(`
566
- INSERT ${insertIgnore} INTO v4_tags (project_id, name) VALUES
567
- (1, 'authentication'), (1, 'authorization'), (1, 'validation'), (1, 'error-handling'),
568
- (1, 'logging'), (1, 'performance'), (1, 'security'), (1, 'testing')
565
+ await knex.raw(`
566
+ INSERT ${insertIgnore} INTO v4_tags (project_id, name) VALUES
567
+ (1, 'authentication'), (1, 'authorization'), (1, 'validation'), (1, 'error-handling'),
568
+ (1, 'logging'), (1, 'performance'), (1, 'security'), (1, 'testing')
569
569
  `);
570
570
  }
571
571
  console.error(' ✓ Common tags seeded (8)');
@@ -27,9 +27,9 @@ export async function up(knex) {
27
27
  tags: ['database', 'orm'],
28
28
  layer: 'data'
29
29
  }, null, 2);
30
- const contextNote = `
31
-
32
- // To add context (rationale, alternatives, tradeoffs), use add_decision_context:
30
+ const contextNote = `
31
+
32
+ // To add context (rationale, alternatives, tradeoffs), use add_decision_context:
33
33
  ${JSON.stringify({
34
34
  action: 'add_decision_context',
35
35
  key: 'database/orm',