sqlew 3.6.5 → 3.6.6

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 (61) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE +52 -52
  3. package/README.md +3 -2
  4. package/assets/sample-agents/sqlew-architect.md +89 -273
  5. package/assets/sample-agents/sqlew-researcher.md +87 -237
  6. package/assets/sample-agents/sqlew-scrum-master.md +105 -108
  7. package/dist/index.js +32 -71
  8. package/dist/index.js.map +1 -1
  9. package/dist/migrations/knex/bootstrap/20251025020452_create_master_tables.d.ts.map +1 -1
  10. package/dist/migrations/knex/bootstrap/20251025020452_create_master_tables.js +49 -34
  11. package/dist/migrations/knex/bootstrap/20251025020452_create_master_tables.js.map +1 -1
  12. package/dist/migrations/knex/bootstrap/20251025021152_create_transaction_tables.d.ts.map +1 -1
  13. package/dist/migrations/knex/bootstrap/20251025021152_create_transaction_tables.js +211 -175
  14. package/dist/migrations/knex/bootstrap/20251025021152_create_transaction_tables.js.map +1 -1
  15. package/dist/tests/all-features.test.js +0 -71
  16. package/dist/tests/all-features.test.js.map +1 -1
  17. package/dist/tests/parameter-validation.test.d.ts +8 -0
  18. package/dist/tests/parameter-validation.test.d.ts.map +1 -0
  19. package/dist/tests/parameter-validation.test.js +461 -0
  20. package/dist/tests/parameter-validation.test.js.map +1 -0
  21. package/dist/tools/constraints.d.ts.map +1 -1
  22. package/dist/tools/constraints.js +7 -8
  23. package/dist/tools/constraints.js.map +1 -1
  24. package/dist/tools/context.d.ts.map +1 -1
  25. package/dist/tools/context.js +68 -39
  26. package/dist/tools/context.js.map +1 -1
  27. package/dist/tools/files.d.ts.map +1 -1
  28. package/dist/tools/files.js +9 -7
  29. package/dist/tools/files.js.map +1 -1
  30. package/dist/tools/help-queries.d.ts.map +1 -1
  31. package/dist/tools/help-queries.js +20 -14
  32. package/dist/tools/help-queries.js.map +1 -1
  33. package/dist/tools/messaging.d.ts +1 -1
  34. package/dist/tools/messaging.js +10 -10
  35. package/dist/tools/tasks.d.ts.map +1 -1
  36. package/dist/tools/tasks.js +13 -0
  37. package/dist/tools/tasks.js.map +1 -1
  38. package/dist/tools/utils.d.ts.map +1 -1
  39. package/dist/tools/utils.js +15 -12
  40. package/dist/tools/utils.js.map +1 -1
  41. package/dist/types.d.ts +93 -1
  42. package/dist/types.d.ts.map +1 -1
  43. package/dist/utils/action-specs.d.ts +46 -0
  44. package/dist/utils/action-specs.d.ts.map +1 -0
  45. package/dist/utils/action-specs.js +527 -0
  46. package/dist/utils/action-specs.js.map +1 -0
  47. package/dist/utils/error-handler.d.ts.map +1 -1
  48. package/dist/utils/error-handler.js +41 -24
  49. package/dist/utils/error-handler.js.map +1 -1
  50. package/dist/utils/parameter-validator.d.ts +53 -0
  51. package/dist/utils/parameter-validator.d.ts.map +1 -0
  52. package/dist/utils/parameter-validator.js +286 -0
  53. package/dist/utils/parameter-validator.js.map +1 -0
  54. package/docs/BEST_PRACTICES.md +69 -0
  55. package/docs/CONFIGURATION.md +35 -19
  56. package/docs/TOOL_REFERENCE.md +178 -0
  57. package/package.json +86 -86
  58. package/dist/tools/config.d.ts +0 -50
  59. package/dist/tools/config.d.ts.map +0 -1
  60. package/dist/tools/config.js +0 -170
  61. package/dist/tools/config.js.map +0 -1
@@ -3,48 +3,63 @@ export async function up(knex) {
3
3
  // Master Tables (m_ prefix) - Normalization Layer
4
4
  // ============================================================================
5
5
  // Agent Management
6
- await knex.schema.createTableIfNotExists('m_agents', (table) => {
7
- table.increments('id').primary();
8
- table.string('name', 100).unique().notNullable();
9
- });
6
+ if (!(await knex.schema.hasTable('m_agents'))) {
7
+ await knex.schema.createTable('m_agents', (table) => {
8
+ table.increments('id').primary();
9
+ table.string('name', 100).unique().notNullable();
10
+ });
11
+ }
10
12
  // File Path Management
11
- await knex.schema.createTableIfNotExists('m_files', (table) => {
12
- table.increments('id').primary();
13
- table.string('path', 1000).unique().notNullable();
14
- });
13
+ if (!(await knex.schema.hasTable('m_files'))) {
14
+ await knex.schema.createTable('m_files', (table) => {
15
+ table.increments('id').primary();
16
+ table.string('path', 1000).unique().notNullable();
17
+ });
18
+ }
15
19
  // Context Key Management
16
- await knex.schema.createTableIfNotExists('m_context_keys', (table) => {
17
- table.increments('id').primary();
18
- table.string('key', 200).unique().notNullable();
19
- });
20
+ if (!(await knex.schema.hasTable('m_context_keys'))) {
21
+ await knex.schema.createTable('m_context_keys', (table) => {
22
+ table.increments('id').primary();
23
+ table.string('key', 200).unique().notNullable();
24
+ });
25
+ }
20
26
  // Constraint Category Management
21
- await knex.schema.createTableIfNotExists('m_constraint_categories', (table) => {
22
- table.increments('id').primary();
23
- table.string('name', 100).unique().notNullable();
24
- });
27
+ if (!(await knex.schema.hasTable('m_constraint_categories'))) {
28
+ await knex.schema.createTable('m_constraint_categories', (table) => {
29
+ table.increments('id').primary();
30
+ table.string('name', 100).unique().notNullable();
31
+ });
32
+ }
25
33
  // Layer Management (5 predefined layers)
26
- await knex.schema.createTableIfNotExists('m_layers', (table) => {
27
- table.increments('id').primary();
28
- table.string('name', 50).unique().notNullable();
29
- });
34
+ if (!(await knex.schema.hasTable('m_layers'))) {
35
+ await knex.schema.createTable('m_layers', (table) => {
36
+ table.increments('id').primary();
37
+ table.string('name', 50).unique().notNullable();
38
+ });
39
+ }
30
40
  // Tag Management
31
- await knex.schema.createTableIfNotExists('m_tags', (table) => {
32
- table.increments('id').primary();
33
- table.string('name', 100).unique().notNullable();
34
- });
41
+ if (!(await knex.schema.hasTable('m_tags'))) {
42
+ await knex.schema.createTable('m_tags', (table) => {
43
+ table.increments('id').primary();
44
+ table.string('name', 100).unique().notNullable();
45
+ });
46
+ }
35
47
  // Scope Management
36
- await knex.schema.createTableIfNotExists('m_scopes', (table) => {
37
- table.increments('id').primary();
38
- table.string('name', 200).unique().notNullable();
39
- });
48
+ if (!(await knex.schema.hasTable('m_scopes'))) {
49
+ await knex.schema.createTable('m_scopes', (table) => {
50
+ table.increments('id').primary();
51
+ table.string('name', 200).unique().notNullable();
52
+ });
53
+ }
40
54
  // Configuration Management (key-value store)
41
- await knex.schema.createTableIfNotExists('m_config', (table) => {
42
- table.string('key').primary();
43
- table.text('value').notNullable();
44
- });
55
+ if (!(await knex.schema.hasTable('m_config'))) {
56
+ await knex.schema.createTable('m_config', (table) => {
57
+ table.string('key').primary();
58
+ table.text('value').notNullable();
59
+ });
60
+ }
45
61
  // Task Statuses (enum-like table)
46
- const hasTaskStatuses = await knex.schema.hasTable('m_task_statuses');
47
- if (!hasTaskStatuses) {
62
+ if (!(await knex.schema.hasTable('m_task_statuses'))) {
48
63
  await knex.schema.createTable('m_task_statuses', (table) => {
49
64
  table.integer('id').primary();
50
65
  table.string('name', 50).unique().notNullable();
@@ -1 +1 @@
1
- {"version":3,"file":"20251025020452_create_master_tables.js","sourceRoot":"","sources":["../../../../src/migrations/knex/bootstrap/20251025020452_create_master_tables.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,IAAU;IACjC,+EAA+E;IAC/E,kDAAkD;IAClD,+EAA+E;IAE/E,mBAAmB;IACnB,MAAM,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE;QAC7D,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QACjC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,uBAAuB;IACvB,MAAM,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QAC5D,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QACjC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;IACpD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AC,UAAU,CAAC,CAAC;IAChD,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC9C,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAChD,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,yBAAyB,CAAC,CAAC;IAC/D,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IACtD,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC/C,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAEhD,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;AACtD,CAAC"}
1
+ {"version":3,"file":"20251025020452_create_master_tables.js","sourceRoot":"","sources":["../../../../src/migrations/knex/bootstrap/20251025020452_create_master_tables.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,IAAU;IACjC,+EAA+E;IAC/E,kDAAkD;IAClD,+EAA+E;IAE/E,mBAAmB;IACnB,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE;YAClD,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;YACjC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;QACnD,CAAC,CAAC,CAAC;IACL,CAAC;IAED,uBAAuB;IACvB,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;QAC7C,MAAM,IAA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/C,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAEhD,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;AACtD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"20251025021152_create_transaction_tables.d.ts","sourceRoot":"","sources":["../../../../src/migrations/knex/bootstrap/20251025021152_create_transaction_tables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAGjC,wBAAsB,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAsOlD;AAGD,wBAAsB,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBpD"}
1
+ {"version":3,"file":"20251025021152_create_transaction_tables.d.ts","sourceRoot":"","sources":["../../../../src/migrations/knex/bootstrap/20251025021152_create_transaction_tables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAGjC,wBAAsB,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA0QlD;AAGD,wBAAsB,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBpD"}
@@ -3,198 +3,234 @@ export async function up(knex) {
3
3
  // Transaction Tables (t_ prefix) - Core Data
4
4
  // ============================================================================
5
5
  // Decisions (String Values)
6
- await knex.schema.createTableIfNotExists('t_decisions', (table) => {
7
- table.integer('key_id').primary();
8
- table.foreign('key_id').references('m_context_keys.id');
9
- table.text('value').notNullable();
10
- table.integer('agent_id');
11
- table.foreign('agent_id').references('m_agents.id');
12
- table.integer('layer_id');
13
- table.foreign('layer_id').references('m_layers.id');
14
- table.string('version', 20).defaultTo('1.0.0');
15
- table.integer('status').defaultTo(1); // 1=active, 2=deprecated, 3=draft
16
- table.integer('ts').notNullable();
17
- });
6
+ if (!(await knex.schema.hasTable('t_decisions'))) {
7
+ await knex.schema.createTable('t_decisions', (table) => {
8
+ table.integer('key_id').primary();
9
+ table.foreign('key_id').references('m_context_keys.id');
10
+ table.text('value').notNullable();
11
+ table.integer('agent_id');
12
+ table.foreign('agent_id').references('m_agents.id');
13
+ table.integer('layer_id');
14
+ table.foreign('layer_id').references('m_layers.id');
15
+ table.string('version', 20).defaultTo('1.0.0');
16
+ table.integer('status').defaultTo(1); // 1=active, 2=deprecated, 3=draft
17
+ table.integer('ts').notNullable();
18
+ });
19
+ }
18
20
  // Decisions (Numeric Values)
19
- await knex.schema.createTableIfNotExists('t_decisions_numeric', (table) => {
20
- table.integer('key_id').primary();
21
- table.foreign('key_id').references('m_context_keys.id');
22
- table.double('value').notNullable();
23
- table.integer('agent_id');
24
- table.foreign('agent_id').references('m_agents.id');
25
- table.integer('layer_id');
26
- table.foreign('layer_id').references('m_layers.id');
27
- table.string('version', 20).defaultTo('1.0.0');
28
- table.integer('status').defaultTo(1);
29
- table.integer('ts').notNullable();
30
- });
21
+ if (!(await knex.schema.hasTable('t_decisions_numeric'))) {
22
+ await knex.schema.createTable('t_decisions_numeric', (table) => {
23
+ table.integer('key_id').primary();
24
+ table.foreign('key_id').references('m_context_keys.id');
25
+ table.double('value').notNullable();
26
+ table.integer('agent_id');
27
+ table.foreign('agent_id').references('m_agents.id');
28
+ table.integer('layer_id');
29
+ table.foreign('layer_id').references('m_layers.id');
30
+ table.string('version', 20).defaultTo('1.0.0');
31
+ table.integer('status').defaultTo(1);
32
+ table.integer('ts').notNullable();
33
+ });
34
+ }
31
35
  // Decision Version History
32
- await knex.schema.createTableIfNotExists('t_decision_history', (table) => {
33
- table.increments('id').primary();
34
- table.integer('key_id');
35
- table.foreign('key_id').references('m_context_keys.id');
36
- table.string('version', 20).notNullable();
37
- table.text('value').notNullable();
38
- table.integer('agent_id');
39
- table.foreign('agent_id').references('m_agents.id');
40
- table.integer('ts').notNullable();
41
- });
36
+ if (!(await knex.schema.hasTable('t_decision_history'))) {
37
+ await knex.schema.createTable('t_decision_history', (table) => {
38
+ table.increments('id').primary();
39
+ table.integer('key_id');
40
+ table.foreign('key_id').references('m_context_keys.id');
41
+ table.string('version', 20).notNullable();
42
+ table.text('value').notNullable();
43
+ table.integer('agent_id');
44
+ table.foreign('agent_id').references('m_agents.id');
45
+ table.integer('ts').notNullable();
46
+ });
47
+ }
42
48
  // Decision Tagging (Many-to-Many)
43
- await knex.schema.createTableIfNotExists('t_decision_tags', (table) => {
44
- table.integer('decision_key_id');
45
- table.foreign('decision_key_id').references('m_context_keys.id');
46
- table.integer('tag_id');
47
- table.foreign('tag_id').references('m_tags.id');
48
- table.primary(['decision_key_id', 'tag_id']);
49
- });
49
+ if (!(await knex.schema.hasTable('t_decision_tags'))) {
50
+ await knex.schema.createTable('t_decision_tags', (table) => {
51
+ table.integer('decision_key_id');
52
+ table.foreign('decision_key_id').references('m_context_keys.id');
53
+ table.integer('tag_id');
54
+ table.foreign('tag_id').references('m_tags.id');
55
+ table.primary(['decision_key_id', 'tag_id']);
56
+ });
57
+ }
50
58
  // Decision Scopes (Many-to-Many)
51
- await knex.schema.createTableIfNotExists('t_decision_scopes', (table) => {
52
- table.integer('decision_key_id');
53
- table.foreign('decision_key_id').references('m_context_keys.id');
54
- table.integer('scope_id');
55
- table.foreign('scope_id').references('m_scopes.id');
56
- table.primary(['decision_key_id', 'scope_id']);
57
- });
59
+ if (!(await knex.schema.hasTable('t_decision_scopes'))) {
60
+ await knex.schema.createTable('t_decision_scopes', (table) => {
61
+ table.integer('decision_key_id');
62
+ table.foreign('decision_key_id').references('m_context_keys.id');
63
+ table.integer('scope_id');
64
+ table.foreign('scope_id').references('m_scopes.id');
65
+ table.primary(['decision_key_id', 'scope_id']);
66
+ });
67
+ }
58
68
  // Agent Messages
59
- await knex.schema.createTableIfNotExists('t_agent_messages', (table) => {
60
- table.increments('id').primary();
61
- table.integer('from_agent_id');
62
- table.foreign('from_agent_id').references('m_agents.id');
63
- table.integer('to_agent_id');
64
- table.foreign('to_agent_id').references('m_agents.id');
65
- table.integer('msg_type').notNullable(); // 1=decision, 2=warning, 3=request, 4=info
66
- table.integer('priority').defaultTo(2); // 1=low, 2=medium, 3=high, 4=critical
67
- table.text('message').notNullable();
68
- table.text('payload'); // JSON stored as TEXT
69
- table.boolean('read').defaultTo(false);
70
- table.integer('ts').notNullable();
71
- });
69
+ if (!(await knex.schema.hasTable('t_agent_messages'))) {
70
+ await knex.schema.createTable('t_agent_messages', (table) => {
71
+ table.increments('id').primary();
72
+ table.integer('from_agent_id');
73
+ table.foreign('from_agent_id').references('m_agents.id');
74
+ table.integer('to_agent_id');
75
+ table.foreign('to_agent_id').references('m_agents.id');
76
+ table.integer('msg_type').notNullable(); // 1=decision, 2=warning, 3=request, 4=info
77
+ table.integer('priority').defaultTo(2); // 1=low, 2=medium, 3=high, 4=critical
78
+ table.text('message').notNullable();
79
+ table.text('payload'); // JSON stored as TEXT
80
+ table.boolean('read').defaultTo(false);
81
+ table.integer('ts').notNullable();
82
+ });
83
+ }
72
84
  // File Change Tracking
73
- await knex.schema.createTableIfNotExists('t_file_changes', (table) => {
74
- table.increments('id').primary();
75
- table.integer('file_id');
76
- table.foreign('file_id').references('m_files.id');
77
- table.integer('change_type').notNullable(); // 1=created, 2=modified, 3=deleted
78
- table.integer('agent_id');
79
- table.foreign('agent_id').references('m_agents.id');
80
- table.integer('layer_id');
81
- table.foreign('layer_id').references('m_layers.id');
82
- table.text('description');
83
- table.integer('ts').notNullable();
84
- });
85
+ if (!(await knex.schema.hasTable('t_file_changes'))) {
86
+ await knex.schema.createTable('t_file_changes', (table) => {
87
+ table.increments('id').primary();
88
+ table.integer('file_id');
89
+ table.foreign('file_id').references('m_files.id');
90
+ table.integer('change_type').notNullable(); // 1=created, 2=modified, 3=deleted
91
+ table.integer('agent_id');
92
+ table.foreign('agent_id').references('m_agents.id');
93
+ table.integer('layer_id');
94
+ table.foreign('layer_id').references('m_layers.id');
95
+ table.text('description');
96
+ table.integer('ts').notNullable();
97
+ });
98
+ }
85
99
  // Constraints
86
- await knex.schema.createTableIfNotExists('t_constraints', (table) => {
87
- table.increments('id').primary();
88
- table.integer('category_id');
89
- table.foreign('category_id').references('m_constraint_categories.id');
90
- table.integer('layer_id');
91
- table.foreign('layer_id').references('m_layers.id');
92
- table.text('constraint_text').notNullable();
93
- table.integer('priority').defaultTo(2); // 1=low, 2=medium, 3=high, 4=critical
94
- table.boolean('active').defaultTo(true);
95
- table.integer('agent_id');
96
- table.foreign('agent_id').references('m_agents.id');
97
- table.integer('ts').notNullable();
98
- });
100
+ if (!(await knex.schema.hasTable('t_constraints'))) {
101
+ await knex.schema.createTable('t_constraints', (table) => {
102
+ table.increments('id').primary();
103
+ table.integer('category_id');
104
+ table.foreign('category_id').references('m_constraint_categories.id');
105
+ table.integer('layer_id');
106
+ table.foreign('layer_id').references('m_layers.id');
107
+ table.text('constraint_text').notNullable();
108
+ table.integer('priority').defaultTo(2); // 1=low, 2=medium, 3=high, 4=critical
109
+ table.boolean('active').defaultTo(true);
110
+ table.integer('agent_id');
111
+ table.foreign('agent_id').references('m_agents.id');
112
+ table.integer('ts').notNullable();
113
+ });
114
+ }
99
115
  // Constraint Tagging (Many-to-Many)
100
- await knex.schema.createTableIfNotExists('t_constraint_tags', (table) => {
101
- table.integer('constraint_id');
102
- table.foreign('constraint_id').references('t_constraints.id');
103
- table.integer('tag_id');
104
- table.foreign('tag_id').references('m_tags.id');
105
- table.primary(['constraint_id', 'tag_id']);
106
- });
116
+ if (!(await knex.schema.hasTable('t_constraint_tags'))) {
117
+ await knex.schema.createTable('t_constraint_tags', (table) => {
118
+ table.integer('constraint_id');
119
+ table.foreign('constraint_id').references('t_constraints.id');
120
+ table.integer('tag_id');
121
+ table.foreign('tag_id').references('m_tags.id');
122
+ table.primary(['constraint_id', 'tag_id']);
123
+ });
124
+ }
107
125
  // Activity Log
108
- await knex.schema.createTableIfNotExists('t_activity_log', (table) => {
109
- table.increments('id').primary();
110
- table.integer('agent_id');
111
- table.foreign('agent_id').references('m_agents.id');
112
- table.string('action_type', 50).notNullable();
113
- table.string('target', 500);
114
- table.integer('layer_id');
115
- table.foreign('layer_id').references('m_layers.id');
116
- table.text('details'); // JSON stored as TEXT
117
- table.integer('ts').notNullable();
118
- });
126
+ if (!(await knex.schema.hasTable('t_activity_log'))) {
127
+ await knex.schema.createTable('t_activity_log', (table) => {
128
+ table.increments('id').primary();
129
+ table.integer('agent_id');
130
+ table.foreign('agent_id').references('m_agents.id');
131
+ table.string('action_type', 50).notNullable();
132
+ table.string('target', 500);
133
+ table.integer('layer_id');
134
+ table.foreign('layer_id').references('m_layers.id');
135
+ table.text('details'); // JSON stored as TEXT
136
+ table.integer('ts').notNullable();
137
+ });
138
+ }
119
139
  // Decision Templates
120
- await knex.schema.createTableIfNotExists('t_decision_templates', (table) => {
121
- table.increments('id').primary();
122
- table.string('name', 200).unique().notNullable();
123
- table.text('description');
124
- table.text('defaults'); // JSON
125
- table.text('required_fields'); // JSON
126
- });
140
+ if (!(await knex.schema.hasTable('t_decision_templates'))) {
141
+ await knex.schema.createTable('t_decision_templates', (table) => {
142
+ table.increments('id').primary();
143
+ table.string('name', 200).unique().notNullable();
144
+ table.text('description');
145
+ table.text('defaults'); // JSON
146
+ table.text('required_fields'); // JSON
147
+ });
148
+ }
127
149
  // Decision Context (v3.2.2)
128
- await knex.schema.createTableIfNotExists('t_decision_context', (table) => {
129
- table.increments('id').primary();
130
- table.integer('decision_key_id');
131
- table.foreign('decision_key_id').references('m_context_keys.id');
132
- table.text('rationale');
133
- table.text('alternatives_considered'); // JSON array
134
- table.text('tradeoffs'); // JSON object
135
- table.integer('decision_date');
136
- table.integer('agent_id');
137
- table.foreign('agent_id').references('m_agents.id');
138
- table.integer('ts').notNullable();
139
- });
150
+ if (!(await knex.schema.hasTable('t_decision_context'))) {
151
+ await knex.schema.createTable('t_decision_context', (table) => {
152
+ table.increments('id').primary();
153
+ table.integer('decision_key_id');
154
+ table.foreign('decision_key_id').references('m_context_keys.id');
155
+ table.text('rationale');
156
+ table.text('alternatives_considered'); // JSON array
157
+ table.text('tradeoffs'); // JSON object
158
+ table.integer('decision_date');
159
+ table.integer('agent_id');
160
+ table.foreign('agent_id').references('m_agents.id');
161
+ table.integer('ts').notNullable();
162
+ });
163
+ }
140
164
  // Tasks (v3.0.0 Kanban system)
141
- await knex.schema.createTableIfNotExists('t_tasks', (table) => {
142
- table.increments('id').primary();
143
- table.string('title', 500).notNullable();
144
- table.integer('status_id').defaultTo(1); // 1=todo
145
- table.foreign('status_id').references('m_task_statuses.id');
146
- table.integer('priority').defaultTo(2);
147
- table.integer('assigned_agent_id');
148
- table.foreign('assigned_agent_id').references('m_agents.id');
149
- table.integer('created_by_agent_id');
150
- table.foreign('created_by_agent_id').references('m_agents.id');
151
- table.integer('layer_id');
152
- table.foreign('layer_id').references('m_layers.id');
153
- table.integer('created_ts').notNullable();
154
- table.integer('updated_ts').notNullable();
155
- table.integer('completed_ts');
156
- });
165
+ if (!(await knex.schema.hasTable('t_tasks'))) {
166
+ await knex.schema.createTable('t_tasks', (table) => {
167
+ table.increments('id').primary();
168
+ table.string('title', 500).notNullable();
169
+ table.integer('status_id').defaultTo(1); // 1=todo
170
+ table.foreign('status_id').references('m_task_statuses.id');
171
+ table.integer('priority').defaultTo(2);
172
+ table.integer('assigned_agent_id');
173
+ table.foreign('assigned_agent_id').references('m_agents.id');
174
+ table.integer('created_by_agent_id');
175
+ table.foreign('created_by_agent_id').references('m_agents.id');
176
+ table.integer('layer_id');
177
+ table.foreign('layer_id').references('m_layers.id');
178
+ table.integer('created_ts').notNullable();
179
+ table.integer('updated_ts').notNullable();
180
+ table.integer('completed_ts');
181
+ });
182
+ }
157
183
  // Task Details
158
- await knex.schema.createTableIfNotExists('t_task_details', (table) => {
159
- table.integer('task_id').primary();
160
- table.foreign('task_id').references('t_tasks.id');
161
- table.text('description');
162
- table.text('acceptance_criteria');
163
- table.text('acceptance_criteria_json'); // JSON
164
- table.text('notes');
165
- });
184
+ if (!(await knex.schema.hasTable('t_task_details'))) {
185
+ await knex.schema.createTable('t_task_details', (table) => {
186
+ table.integer('task_id').primary();
187
+ table.foreign('task_id').references('t_tasks.id');
188
+ table.text('description');
189
+ table.text('acceptance_criteria');
190
+ table.text('acceptance_criteria_json'); // JSON
191
+ table.text('notes');
192
+ });
193
+ }
166
194
  // Task Tagging (Many-to-Many)
167
- await knex.schema.createTableIfNotExists('t_task_tags', (table) => {
168
- table.integer('task_id');
169
- table.foreign('task_id').references('t_tasks.id');
170
- table.integer('tag_id');
171
- table.foreign('tag_id').references('m_tags.id');
172
- table.primary(['task_id', 'tag_id']);
173
- });
195
+ if (!(await knex.schema.hasTable('t_task_tags'))) {
196
+ await knex.schema.createTable('t_task_tags', (table) => {
197
+ table.integer('task_id');
198
+ table.foreign('task_id').references('t_tasks.id');
199
+ table.integer('tag_id');
200
+ table.foreign('tag_id').references('m_tags.id');
201
+ table.primary(['task_id', 'tag_id']);
202
+ });
203
+ }
174
204
  // Task-Decision Links
175
- await knex.schema.createTableIfNotExists('t_task_decision_links', (table) => {
176
- table.integer('task_id');
177
- table.foreign('task_id').references('t_tasks.id');
178
- table.integer('decision_key_id');
179
- table.foreign('decision_key_id').references('m_context_keys.id');
180
- table.primary(['task_id', 'decision_key_id']);
181
- });
205
+ if (!(await knex.schema.hasTable('t_task_decision_links'))) {
206
+ await knex.schema.createTable('t_task_decision_links', (table) => {
207
+ table.integer('task_id');
208
+ table.foreign('task_id').references('t_tasks.id');
209
+ table.integer('decision_key_id');
210
+ table.foreign('decision_key_id').references('m_context_keys.id');
211
+ table.primary(['task_id', 'decision_key_id']);
212
+ });
213
+ }
182
214
  // Task-Constraint Links
183
- await knex.schema.createTableIfNotExists('t_task_constraint_links', (table) => {
184
- table.integer('task_id');
185
- table.foreign('task_id').references('t_tasks.id');
186
- table.integer('constraint_id');
187
- table.foreign('constraint_id').references('t_constraints.id');
188
- table.primary(['task_id', 'constraint_id']);
189
- });
215
+ if (!(await knex.schema.hasTable('t_task_constraint_links'))) {
216
+ await knex.schema.createTable('t_task_constraint_links', (table) => {
217
+ table.integer('task_id');
218
+ table.foreign('task_id').references('t_tasks.id');
219
+ table.integer('constraint_id');
220
+ table.foreign('constraint_id').references('t_constraints.id');
221
+ table.primary(['task_id', 'constraint_id']);
222
+ });
223
+ }
190
224
  // Task-File Links
191
- await knex.schema.createTableIfNotExists('t_task_file_links', (table) => {
192
- table.integer('task_id');
193
- table.foreign('task_id').references('t_tasks.id');
194
- table.integer('file_id');
195
- table.foreign('file_id').references('m_files.id');
196
- table.primary(['task_id', 'file_id']);
197
- });
225
+ if (!(await knex.schema.hasTable('t_task_file_links'))) {
226
+ await knex.schema.createTable('t_task_file_links', (table) => {
227
+ table.integer('task_id');
228
+ table.foreign('task_id').references('t_tasks.id');
229
+ table.integer('file_id');
230
+ table.foreign('file_id').references('m_files.id');
231
+ table.primary(['task_id', 'file_id']);
232
+ });
233
+ }
198
234
  // Task Dependencies (v3.2.0) - with CASCADE delete
199
235
  // Note: Using raw SQL because Knex doesn't properly generate ON DELETE CASCADE for SQLite
200
236
  await knex.raw(`