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.
- package/CHANGELOG.md +41 -0
- package/LICENSE +52 -52
- package/README.md +3 -2
- package/assets/sample-agents/sqlew-architect.md +89 -273
- package/assets/sample-agents/sqlew-researcher.md +87 -237
- package/assets/sample-agents/sqlew-scrum-master.md +105 -108
- package/dist/index.js +32 -71
- package/dist/index.js.map +1 -1
- package/dist/migrations/knex/bootstrap/20251025020452_create_master_tables.d.ts.map +1 -1
- package/dist/migrations/knex/bootstrap/20251025020452_create_master_tables.js +49 -34
- package/dist/migrations/knex/bootstrap/20251025020452_create_master_tables.js.map +1 -1
- package/dist/migrations/knex/bootstrap/20251025021152_create_transaction_tables.d.ts.map +1 -1
- package/dist/migrations/knex/bootstrap/20251025021152_create_transaction_tables.js +211 -175
- package/dist/migrations/knex/bootstrap/20251025021152_create_transaction_tables.js.map +1 -1
- package/dist/tests/all-features.test.js +0 -71
- package/dist/tests/all-features.test.js.map +1 -1
- package/dist/tests/parameter-validation.test.d.ts +8 -0
- package/dist/tests/parameter-validation.test.d.ts.map +1 -0
- package/dist/tests/parameter-validation.test.js +461 -0
- package/dist/tests/parameter-validation.test.js.map +1 -0
- package/dist/tools/constraints.d.ts.map +1 -1
- package/dist/tools/constraints.js +7 -8
- package/dist/tools/constraints.js.map +1 -1
- package/dist/tools/context.d.ts.map +1 -1
- package/dist/tools/context.js +68 -39
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/files.d.ts.map +1 -1
- package/dist/tools/files.js +9 -7
- package/dist/tools/files.js.map +1 -1
- package/dist/tools/help-queries.d.ts.map +1 -1
- package/dist/tools/help-queries.js +20 -14
- package/dist/tools/help-queries.js.map +1 -1
- package/dist/tools/messaging.d.ts +1 -1
- package/dist/tools/messaging.js +10 -10
- package/dist/tools/tasks.d.ts.map +1 -1
- package/dist/tools/tasks.js +13 -0
- package/dist/tools/tasks.js.map +1 -1
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +15 -12
- package/dist/tools/utils.js.map +1 -1
- package/dist/types.d.ts +93 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/action-specs.d.ts +46 -0
- package/dist/utils/action-specs.d.ts.map +1 -0
- package/dist/utils/action-specs.js +527 -0
- package/dist/utils/action-specs.js.map +1 -0
- package/dist/utils/error-handler.d.ts.map +1 -1
- package/dist/utils/error-handler.js +41 -24
- package/dist/utils/error-handler.js.map +1 -1
- package/dist/utils/parameter-validator.d.ts +53 -0
- package/dist/utils/parameter-validator.d.ts.map +1 -0
- package/dist/utils/parameter-validator.js +286 -0
- package/dist/utils/parameter-validator.js.map +1 -0
- package/docs/BEST_PRACTICES.md +69 -0
- package/docs/CONFIGURATION.md +35 -19
- package/docs/TOOL_REFERENCE.md +178 -0
- package/package.json +86 -86
- package/dist/tools/config.d.ts +0 -50
- package/dist/tools/config.d.ts.map +0 -1
- package/dist/tools/config.js +0 -170
- 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.
|
|
7
|
-
|
|
8
|
-
|
|
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.
|
|
12
|
-
|
|
13
|
-
|
|
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.
|
|
17
|
-
|
|
18
|
-
|
|
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.
|
|
22
|
-
|
|
23
|
-
|
|
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.
|
|
27
|
-
|
|
28
|
-
|
|
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.
|
|
32
|
-
|
|
33
|
-
|
|
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.
|
|
37
|
-
|
|
38
|
-
|
|
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.
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
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,
|
|
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,CA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C,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 +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,
|
|
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.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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.
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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.
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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(`
|