sqlew 3.2.5 → 3.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +815 -13
- package/README.md +53 -2
- package/assets/schema.sql +6 -1
- package/dist/config/loader.d.ts +46 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +151 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/types.d.ts +77 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +28 -0
- package/dist/config/types.js.map +1 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +10 -0
- package/dist/constants.js.map +1 -1
- package/dist/database.d.ts +1 -1
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +77 -10
- package/dist/database.js.map +1 -1
- package/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/dist/migrations/add-v3.5.0-pruned-files.d.ts +26 -0
- package/dist/migrations/add-v3.5.0-pruned-files.d.ts.map +1 -0
- package/dist/migrations/add-v3.5.0-pruned-files.js +107 -0
- package/dist/migrations/add-v3.5.0-pruned-files.js.map +1 -0
- package/dist/migrations/index.d.ts +2 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +16 -1
- package/dist/migrations/index.js.map +1 -1
- package/dist/tests/git-aware-completion.test.d.ts +6 -0
- package/dist/tests/git-aware-completion.test.d.ts.map +1 -0
- package/dist/tests/git-aware-completion.test.js +141 -0
- package/dist/tests/git-aware-completion.test.js.map +1 -0
- package/dist/tests/tasks.auto-pruning-decision-link.test.d.ts +6 -0
- package/dist/tests/tasks.auto-pruning-decision-link.test.d.ts.map +1 -0
- package/dist/tests/tasks.auto-pruning-decision-link.test.js +250 -0
- package/dist/tests/tasks.auto-pruning-decision-link.test.js.map +1 -0
- package/dist/tests/tasks.auto-pruning-partial.test.d.ts +6 -0
- package/dist/tests/tasks.auto-pruning-partial.test.d.ts.map +1 -0
- package/dist/tests/tasks.auto-pruning-partial.test.js +274 -0
- package/dist/tests/tasks.auto-pruning-partial.test.js.map +1 -0
- package/dist/tests/tasks.auto-pruning-persistence.test.d.ts +6 -0
- package/dist/tests/tasks.auto-pruning-persistence.test.d.ts.map +1 -0
- package/dist/tests/tasks.auto-pruning-persistence.test.js +232 -0
- package/dist/tests/tasks.auto-pruning-persistence.test.js.map +1 -0
- package/dist/tests/tasks.auto-pruning-safety.test.d.ts +12 -0
- package/dist/tests/tasks.auto-pruning-safety.test.d.ts.map +1 -0
- package/dist/tests/tasks.auto-pruning-safety.test.js +196 -0
- package/dist/tests/tasks.auto-pruning-safety.test.js.map +1 -0
- package/dist/tests/tasks.link-file-backward-compat.test.d.ts +6 -0
- package/dist/tests/tasks.link-file-backward-compat.test.d.ts.map +1 -0
- package/dist/tests/tasks.link-file-backward-compat.test.js +235 -0
- package/dist/tests/tasks.link-file-backward-compat.test.js.map +1 -0
- package/dist/tests/tasks.watch-files-action.test.d.ts +6 -0
- package/dist/tests/tasks.watch-files-action.test.d.ts.map +1 -0
- package/dist/tests/tasks.watch-files-action.test.js +351 -0
- package/dist/tests/tasks.watch-files-action.test.js.map +1 -0
- package/dist/tests/tasks.watch-files-parameter.test.d.ts +6 -0
- package/dist/tests/tasks.watch-files-parameter.test.d.ts.map +1 -0
- package/dist/tests/tasks.watch-files-parameter.test.js +249 -0
- package/dist/tests/tasks.watch-files-parameter.test.js.map +1 -0
- package/dist/tests/two-step-git-completion.test.d.ts +6 -0
- package/dist/tests/two-step-git-completion.test.d.ts.map +1 -0
- package/dist/tests/two-step-git-completion.test.js +283 -0
- package/dist/tests/two-step-git-completion.test.js.map +1 -0
- package/dist/tests/vcs-staging.test.d.ts +6 -0
- package/dist/tests/vcs-staging.test.d.ts.map +1 -0
- package/dist/tests/vcs-staging.test.js +137 -0
- package/dist/tests/vcs-staging.test.js.map +1 -0
- package/dist/tools/config.d.ts +4 -2
- package/dist/tools/config.d.ts.map +1 -1
- package/dist/tools/config.js +13 -11
- package/dist/tools/config.js.map +1 -1
- package/dist/tools/constraints.d.ts +7 -4
- package/dist/tools/constraints.d.ts.map +1 -1
- package/dist/tools/constraints.js +19 -16
- package/dist/tools/constraints.js.map +1 -1
- package/dist/tools/context.d.ts +33 -17
- package/dist/tools/context.d.ts.map +1 -1
- package/dist/tools/context.js +84 -68
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/files.d.ts +9 -5
- package/dist/tools/files.d.ts.map +1 -1
- package/dist/tools/files.js +19 -15
- package/dist/tools/files.js.map +1 -1
- package/dist/tools/messaging.d.ts +9 -5
- package/dist/tools/messaging.d.ts.map +1 -1
- package/dist/tools/messaging.js +20 -16
- package/dist/tools/messaging.js.map +1 -1
- package/dist/tools/tasks.d.ts +40 -12
- package/dist/tools/tasks.d.ts.map +1 -1
- package/dist/tools/tasks.js +475 -87
- package/dist/tools/tasks.js.map +1 -1
- package/dist/tools/utils.d.ts +11 -6
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +56 -44
- package/dist/tools/utils.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/file-pruning.d.ts +69 -0
- package/dist/utils/file-pruning.d.ts.map +1 -0
- package/dist/utils/file-pruning.js +185 -0
- package/dist/utils/file-pruning.js.map +1 -0
- package/dist/utils/quality-checks.d.ts +60 -0
- package/dist/utils/quality-checks.d.ts.map +1 -0
- package/dist/utils/quality-checks.js +228 -0
- package/dist/utils/quality-checks.js.map +1 -0
- package/dist/utils/retention.d.ts +8 -0
- package/dist/utils/retention.d.ts.map +1 -1
- package/dist/utils/retention.js +12 -0
- package/dist/utils/retention.js.map +1 -1
- package/dist/utils/task-stale-detection.d.ts +69 -1
- package/dist/utils/task-stale-detection.d.ts.map +1 -1
- package/dist/utils/task-stale-detection.js +494 -17
- package/dist/utils/task-stale-detection.js.map +1 -1
- package/dist/utils/vcs-adapter.d.ts +68 -0
- package/dist/utils/vcs-adapter.d.ts.map +1 -0
- package/dist/utils/vcs-adapter.js +187 -0
- package/dist/utils/vcs-adapter.js.map +1 -0
- package/dist/watcher/file-watcher.d.ts +54 -4
- package/dist/watcher/file-watcher.d.ts.map +1 -1
- package/dist/watcher/file-watcher.js +312 -30
- package/dist/watcher/file-watcher.js.map +1 -1
- package/dist/watcher/gitignore-parser.d.ts +70 -0
- package/dist/watcher/gitignore-parser.d.ts.map +1 -0
- package/dist/watcher/gitignore-parser.js +191 -0
- package/dist/watcher/gitignore-parser.js.map +1 -0
- package/dist/watcher/index.d.ts +1 -0
- package/dist/watcher/index.d.ts.map +1 -1
- package/dist/watcher/index.js +1 -0
- package/dist/watcher/index.js.map +1 -1
- package/docs/AI_AGENT_GUIDE.md +1 -1
- package/docs/ARCHITECTURE.md +12 -0
- package/docs/AUTO_FILE_TRACKING.md +486 -82
- package/docs/CONFIGURATION.md +908 -0
- package/docs/GIT_AWARE_AUTO_COMPLETE.md +645 -0
- package/docs/MIGRATION_v3.3.md +602 -0
- package/docs/SHARED_CONCEPTS.md +2 -1
- package/docs/TASK_ACTIONS.md +12 -0
- package/docs/TASK_OVERVIEW.md +124 -23
- package/docs/TASK_PRUNING.md +589 -0
- package/docs/TASK_SYSTEM.md +83 -13
- package/docs/TOOL_REFERENCE.md +94 -6
- package/package.json +8 -6
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VCS Staging Detection Tests (v3.5.2)
|
|
3
|
+
* Tests for getStagedFiles() method across Git, Mercurial, and SVN adapters
|
|
4
|
+
*/
|
|
5
|
+
import { describe, it, before, after } from 'node:test';
|
|
6
|
+
import assert from 'node:assert';
|
|
7
|
+
import { mkdirSync, rmSync, existsSync, writeFileSync } from 'fs';
|
|
8
|
+
import { join } from 'path';
|
|
9
|
+
import { execSync } from 'child_process';
|
|
10
|
+
import { GitAdapter, MercurialAdapter, SVNAdapter } from '../utils/vcs-adapter.js';
|
|
11
|
+
const TEST_DIR = join(process.cwd(), 'test-vcs-staging');
|
|
12
|
+
// Helper to clean up test directory
|
|
13
|
+
function cleanupTestDir() {
|
|
14
|
+
if (existsSync(TEST_DIR)) {
|
|
15
|
+
rmSync(TEST_DIR, { recursive: true, force: true });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
describe('VCS Staging Detection Tests', () => {
|
|
19
|
+
before(() => {
|
|
20
|
+
cleanupTestDir();
|
|
21
|
+
mkdirSync(TEST_DIR, { recursive: true });
|
|
22
|
+
});
|
|
23
|
+
after(() => {
|
|
24
|
+
cleanupTestDir();
|
|
25
|
+
});
|
|
26
|
+
describe('GitAdapter - getStagedFiles()', () => {
|
|
27
|
+
let gitDir;
|
|
28
|
+
let adapter;
|
|
29
|
+
before(() => {
|
|
30
|
+
gitDir = join(TEST_DIR, 'git-test');
|
|
31
|
+
mkdirSync(gitDir, { recursive: true });
|
|
32
|
+
// Initialize git repo
|
|
33
|
+
execSync('git init', { cwd: gitDir });
|
|
34
|
+
execSync('git config user.email "test@example.com"', { cwd: gitDir });
|
|
35
|
+
execSync('git config user.name "Test User"', { cwd: gitDir });
|
|
36
|
+
adapter = new GitAdapter(gitDir);
|
|
37
|
+
});
|
|
38
|
+
it('should return empty array when no files are staged', async () => {
|
|
39
|
+
const stagedFiles = await adapter.getStagedFiles();
|
|
40
|
+
assert.deepStrictEqual(stagedFiles, []);
|
|
41
|
+
});
|
|
42
|
+
it('should detect staged files', async () => {
|
|
43
|
+
// Create and stage files
|
|
44
|
+
writeFileSync(join(gitDir, 'file1.txt'), 'content1');
|
|
45
|
+
writeFileSync(join(gitDir, 'file2.txt'), 'content2');
|
|
46
|
+
execSync('git add file1.txt file2.txt', { cwd: gitDir });
|
|
47
|
+
const stagedFiles = await adapter.getStagedFiles();
|
|
48
|
+
assert.strictEqual(stagedFiles.length, 2);
|
|
49
|
+
assert.ok(stagedFiles.includes('file1.txt'));
|
|
50
|
+
assert.ok(stagedFiles.includes('file2.txt'));
|
|
51
|
+
});
|
|
52
|
+
it('should return only staged files, not modified unstaged files', async () => {
|
|
53
|
+
// Commit previously staged files
|
|
54
|
+
execSync('git commit -m "Initial commit"', { cwd: gitDir });
|
|
55
|
+
// Create new file but don't stage it
|
|
56
|
+
writeFileSync(join(gitDir, 'file3.txt'), 'content3');
|
|
57
|
+
// Modify existing file but don't stage it
|
|
58
|
+
writeFileSync(join(gitDir, 'file1.txt'), 'modified content');
|
|
59
|
+
const stagedFiles = await adapter.getStagedFiles();
|
|
60
|
+
// Should be empty since nothing is staged
|
|
61
|
+
assert.deepStrictEqual(stagedFiles, []);
|
|
62
|
+
});
|
|
63
|
+
it('should detect partially staged files', async () => {
|
|
64
|
+
// Stage only file3
|
|
65
|
+
execSync('git add file3.txt', { cwd: gitDir });
|
|
66
|
+
const stagedFiles = await adapter.getStagedFiles();
|
|
67
|
+
assert.strictEqual(stagedFiles.length, 1);
|
|
68
|
+
assert.strictEqual(stagedFiles[0], 'file3.txt');
|
|
69
|
+
});
|
|
70
|
+
it('should handle non-git directory gracefully', async () => {
|
|
71
|
+
const nonGitAdapter = new GitAdapter(TEST_DIR);
|
|
72
|
+
const stagedFiles = await nonGitAdapter.getStagedFiles();
|
|
73
|
+
// Should return empty array, not throw
|
|
74
|
+
assert.deepStrictEqual(stagedFiles, []);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
describe('SVNAdapter - getStagedFiles()', () => {
|
|
78
|
+
it('should return modified and added files as "staged"', async () => {
|
|
79
|
+
// SVN doesn't have staging - all modified/added files are considered "staged"
|
|
80
|
+
const adapter = new SVNAdapter(TEST_DIR);
|
|
81
|
+
// Mock SVN status output
|
|
82
|
+
// In real scenario, this would query actual SVN repo
|
|
83
|
+
// For now, test that it returns empty for non-SVN directory
|
|
84
|
+
const stagedFiles = await adapter.getStagedFiles();
|
|
85
|
+
// Should return empty for non-SVN directory
|
|
86
|
+
assert.ok(Array.isArray(stagedFiles));
|
|
87
|
+
});
|
|
88
|
+
it('should handle non-SVN directory gracefully', async () => {
|
|
89
|
+
const adapter = new SVNAdapter(TEST_DIR);
|
|
90
|
+
const stagedFiles = await adapter.getStagedFiles();
|
|
91
|
+
// Should return empty array, not throw
|
|
92
|
+
assert.deepStrictEqual(stagedFiles, []);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
describe('MercurialAdapter - getStagedFiles()', () => {
|
|
96
|
+
it('should return modified, added, and removed files as "staged"', async () => {
|
|
97
|
+
// Mercurial doesn't have staging - all modified/added/removed files are considered "staged"
|
|
98
|
+
const adapter = new MercurialAdapter(TEST_DIR);
|
|
99
|
+
const stagedFiles = await adapter.getStagedFiles();
|
|
100
|
+
// Should return empty for non-Mercurial directory
|
|
101
|
+
assert.ok(Array.isArray(stagedFiles));
|
|
102
|
+
});
|
|
103
|
+
it('should handle non-Mercurial directory gracefully', async () => {
|
|
104
|
+
const adapter = new MercurialAdapter(TEST_DIR);
|
|
105
|
+
const stagedFiles = await adapter.getStagedFiles();
|
|
106
|
+
// Should return empty array, not throw
|
|
107
|
+
assert.deepStrictEqual(stagedFiles, []);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
describe('Edge Cases', () => {
|
|
111
|
+
it('should handle empty repository', async () => {
|
|
112
|
+
const emptyGitDir = join(TEST_DIR, 'empty-git');
|
|
113
|
+
mkdirSync(emptyGitDir, { recursive: true });
|
|
114
|
+
execSync('git init', { cwd: emptyGitDir });
|
|
115
|
+
execSync('git config user.email "test@example.com"', { cwd: emptyGitDir });
|
|
116
|
+
execSync('git config user.name "Test User"', { cwd: emptyGitDir });
|
|
117
|
+
const adapter = new GitAdapter(emptyGitDir);
|
|
118
|
+
const stagedFiles = await adapter.getStagedFiles();
|
|
119
|
+
assert.deepStrictEqual(stagedFiles, []);
|
|
120
|
+
});
|
|
121
|
+
it('should handle files with spaces in names', async () => {
|
|
122
|
+
const gitDir = join(TEST_DIR, 'git-spaces');
|
|
123
|
+
mkdirSync(gitDir, { recursive: true });
|
|
124
|
+
execSync('git init', { cwd: gitDir });
|
|
125
|
+
execSync('git config user.email "test@example.com"', { cwd: gitDir });
|
|
126
|
+
execSync('git config user.name "Test User"', { cwd: gitDir });
|
|
127
|
+
// Create file with space in name
|
|
128
|
+
writeFileSync(join(gitDir, 'file with spaces.txt'), 'content');
|
|
129
|
+
execSync('git add "file with spaces.txt"', { cwd: gitDir });
|
|
130
|
+
const adapter = new GitAdapter(gitDir);
|
|
131
|
+
const stagedFiles = await adapter.getStagedFiles();
|
|
132
|
+
assert.strictEqual(stagedFiles.length, 1);
|
|
133
|
+
assert.strictEqual(stagedFiles[0], 'file with spaces.txt');
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
//# sourceMappingURL=vcs-staging.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vcs-staging.test.js","sourceRoot":"","sources":["../../src/tests/vcs-staging.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEnF,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAC;AAEzD,oCAAoC;AACpC,SAAS,cAAc;IACrB,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC;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;YACxD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YAC5C,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACvC,QAAQ,CAAC,UAAU,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;YACtC,QAAQ,CAAC,0CAA0C,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;YACtE,QAAQ,CAAC,kCAAkC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;YAE9D,iCAAiC;YACjC,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,sBAAsB,CAAC,EAAE,SAAS,CAAC,CAAC;YAC/D,QAAQ,CAAC,gCAAgC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;YAE5D,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;YACvC,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,cAAc,EAAE,CAAC;YAEnD,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YAC1C,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/tools/config.d.ts
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Get current configuration settings
|
|
7
7
|
*
|
|
8
|
+
* @param db - Optional database instance (for testing)
|
|
8
9
|
* @returns Current configuration values
|
|
9
10
|
*/
|
|
10
|
-
export declare function getConfig(): {
|
|
11
|
+
export declare function getConfig(db?: import('../types.js').Database): {
|
|
11
12
|
ignoreWeekend: boolean;
|
|
12
13
|
messageRetentionHours: number;
|
|
13
14
|
fileHistoryRetentionDays: number;
|
|
@@ -17,13 +18,14 @@ export declare function getConfig(): {
|
|
|
17
18
|
* Validates values before updating
|
|
18
19
|
*
|
|
19
20
|
* @param params - Configuration parameters to update
|
|
21
|
+
* @param db - Optional database instance (for testing)
|
|
20
22
|
* @returns Updated configuration
|
|
21
23
|
*/
|
|
22
24
|
export declare function updateConfig(params: {
|
|
23
25
|
ignoreWeekend?: boolean;
|
|
24
26
|
messageRetentionHours?: number;
|
|
25
27
|
fileHistoryRetentionDays?: number;
|
|
26
|
-
}): {
|
|
28
|
+
}, db?: import('../types.js').Database): {
|
|
27
29
|
success: boolean;
|
|
28
30
|
config: {
|
|
29
31
|
ignoreWeekend: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/tools/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/tools/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EAAE,CAAC,EAAE,OAAO,aAAa,EAAE,QAAQ,GAAG;IAC9D,aAAa,EAAE,OAAO,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,wBAAwB,EAAE,MAAM,CAAC;CAClC,CAYA;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE;IACnC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC,EAAE,EAAE,CAAC,EAAE,OAAO,aAAa,EAAE,QAAQ,GAAG;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE;QACN,aAAa,EAAE,OAAO,CAAC;QACvB,qBAAqB,EAAE,MAAM,CAAC;QAC9B,wBAAwB,EAAE,MAAM,CAAC;KAClC,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;CACjB,CAqCA;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,GAAG,CAmBhC;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,GAAG,CA4EnC"}
|
package/dist/tools/config.js
CHANGED
|
@@ -7,13 +7,14 @@ import { CONFIG_KEYS } from '../constants.js';
|
|
|
7
7
|
/**
|
|
8
8
|
* Get current configuration settings
|
|
9
9
|
*
|
|
10
|
+
* @param db - Optional database instance (for testing)
|
|
10
11
|
* @returns Current configuration values
|
|
11
12
|
*/
|
|
12
|
-
export function getConfig() {
|
|
13
|
-
const
|
|
14
|
-
const ignoreWeekend = getConfigBool(
|
|
15
|
-
const messageRetentionHours = getConfigInt(
|
|
16
|
-
const fileHistoryRetentionDays = getConfigInt(
|
|
13
|
+
export function getConfig(db) {
|
|
14
|
+
const actualDb = db ?? getDatabase();
|
|
15
|
+
const ignoreWeekend = getConfigBool(actualDb, CONFIG_KEYS.AUTODELETE_IGNORE_WEEKEND, false);
|
|
16
|
+
const messageRetentionHours = getConfigInt(actualDb, CONFIG_KEYS.AUTODELETE_MESSAGE_HOURS, 24);
|
|
17
|
+
const fileHistoryRetentionDays = getConfigInt(actualDb, CONFIG_KEYS.AUTODELETE_FILE_HISTORY_DAYS, 7);
|
|
17
18
|
return {
|
|
18
19
|
ignoreWeekend,
|
|
19
20
|
messageRetentionHours,
|
|
@@ -25,10 +26,11 @@ export function getConfig() {
|
|
|
25
26
|
* Validates values before updating
|
|
26
27
|
*
|
|
27
28
|
* @param params - Configuration parameters to update
|
|
29
|
+
* @param db - Optional database instance (for testing)
|
|
28
30
|
* @returns Updated configuration
|
|
29
31
|
*/
|
|
30
|
-
export function updateConfig(params) {
|
|
31
|
-
const
|
|
32
|
+
export function updateConfig(params, db) {
|
|
33
|
+
const actualDb = db ?? getDatabase();
|
|
32
34
|
// Validate values
|
|
33
35
|
if (params.messageRetentionHours !== undefined) {
|
|
34
36
|
if (params.messageRetentionHours < 1 || params.messageRetentionHours > 168) {
|
|
@@ -42,16 +44,16 @@ export function updateConfig(params) {
|
|
|
42
44
|
}
|
|
43
45
|
// Update values
|
|
44
46
|
if (params.ignoreWeekend !== undefined) {
|
|
45
|
-
setConfigValue(
|
|
47
|
+
setConfigValue(actualDb, CONFIG_KEYS.AUTODELETE_IGNORE_WEEKEND, params.ignoreWeekend ? '1' : '0');
|
|
46
48
|
}
|
|
47
49
|
if (params.messageRetentionHours !== undefined) {
|
|
48
|
-
setConfigValue(
|
|
50
|
+
setConfigValue(actualDb, CONFIG_KEYS.AUTODELETE_MESSAGE_HOURS, String(params.messageRetentionHours));
|
|
49
51
|
}
|
|
50
52
|
if (params.fileHistoryRetentionDays !== undefined) {
|
|
51
|
-
setConfigValue(
|
|
53
|
+
setConfigValue(actualDb, CONFIG_KEYS.AUTODELETE_FILE_HISTORY_DAYS, String(params.fileHistoryRetentionDays));
|
|
52
54
|
}
|
|
53
55
|
// Get updated config
|
|
54
|
-
const updatedConfig = getConfig();
|
|
56
|
+
const updatedConfig = getConfig(actualDb);
|
|
55
57
|
return {
|
|
56
58
|
success: true,
|
|
57
59
|
config: updatedConfig,
|
package/dist/tools/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/tools/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAgB,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACxG,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/tools/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAgB,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACxG,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,UAAU,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,kBAAkB,EAAE;gBAClB,KAAK,EAAE,+BAA+B;gBACtC,OAAO,EAAE;oBACP,OAAO,EAAE,oGAAoG;oBAC7G,WAAW,EAAE,gFAAgF;iBAC9F;aACF;YACD,aAAa,EAAE;gBACb,KAAK,EAAE,yBAAyB;gBAChC,OAAO,EAAE;oBACP,OAAO,EAAE,mGAAmG;oBAC5G,WAAW,EAAE,mDAAmD;oBAChE,QAAQ,EAAE,yEAAyE;iBACpF;aACF;YACD,kBAAkB,EAAE;gBAClB,KAAK,EAAE,6BAA6B;gBACpC,OAAO,EAAE;oBACP,OAAO,EAAE,gFAAgF;oBACzF,WAAW,EAAE,8DAA8D;oBAC3E,QAAQ,EAAE,gDAAgD;iBAC3D;aACF;SACF;QACD,kBAAkB,EAAE;YAClB,mBAAmB,EAAE;gBACnB,WAAW,EAAE,+BAA+B;gBAC5C,QAAQ,EAAE;oBACR,uCAAuC;oBACvC,yCAAyC;oBACzC,wCAAwC;iBACzC;aACF;YACD,kBAAkB,EAAE;gBAClB,WAAW,EAAE,0CAA0C;gBACvD,QAAQ,EAAE;oBACR,wCAAwC;oBACxC,yBAAyB;oBACzB,0BAA0B;oBAC1B,iCAAiC;oBACjC,iDAAiD;iBAClD;aACF;SACF;QACD,cAAc,EAAE;YACd,kBAAkB,EAAE;gBAClB,+CAA+C;gBAC/C,iDAAiD;gBACjD,4DAA4D;gBAC5D,uDAAuD;aACxD;YACD,MAAM,EAAE;gBACN,iDAAiD;gBACjD,gCAAgC;gBAChC,mEAAmE;aACpE;YACD,YAAY,EAAE;gBACZ,oDAAoD;gBACpD,yFAAyF;gBACzF,0DAA0D;aAC3D;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Constraint management tools for MCP Shared Context Server
|
|
3
3
|
* Handles constraint tracking with priority, layer assignment, and tags
|
|
4
4
|
*/
|
|
5
|
-
import type { AddConstraintParams, AddConstraintResponse, GetConstraintsParams, GetConstraintsResponse, DeactivateConstraintParams, DeactivateConstraintResponse } from '../types.js';
|
|
5
|
+
import type { AddConstraintParams, AddConstraintResponse, GetConstraintsParams, GetConstraintsResponse, DeactivateConstraintParams, DeactivateConstraintResponse, Database } from '../types.js';
|
|
6
6
|
/**
|
|
7
7
|
* Get or create constraint category ID
|
|
8
8
|
* Uses INSERT OR IGNORE for idempotent operation
|
|
@@ -11,25 +11,28 @@ import type { AddConstraintParams, AddConstraintResponse, GetConstraintsParams,
|
|
|
11
11
|
* Add a constraint with priority, layer, and tags
|
|
12
12
|
*
|
|
13
13
|
* @param params - Constraint parameters
|
|
14
|
+
* @param db - Optional database instance (for testing)
|
|
14
15
|
* @returns Constraint ID and timestamp
|
|
15
16
|
*/
|
|
16
|
-
export declare function addConstraint(params: AddConstraintParams): AddConstraintResponse;
|
|
17
|
+
export declare function addConstraint(params: AddConstraintParams, db?: Database): AddConstraintResponse;
|
|
17
18
|
/**
|
|
18
19
|
* Retrieve t_constraints with advanced filtering
|
|
19
20
|
* Uses v_tagged_constraints view for token efficiency
|
|
20
21
|
*
|
|
21
22
|
* @param params - Filter parameters
|
|
23
|
+
* @param db - Optional database instance (for testing)
|
|
22
24
|
* @returns Array of t_constraints matching filters
|
|
23
25
|
*/
|
|
24
|
-
export declare function getConstraints(params: GetConstraintsParams): GetConstraintsResponse;
|
|
26
|
+
export declare function getConstraints(params: GetConstraintsParams, db?: Database): GetConstraintsResponse;
|
|
25
27
|
/**
|
|
26
28
|
* Deactivate a constraint (soft delete)
|
|
27
29
|
* Idempotent - deactivating already-inactive constraint is safe
|
|
28
30
|
*
|
|
29
31
|
* @param params - Constraint ID to deactivate
|
|
32
|
+
* @param db - Optional database instance (for testing)
|
|
30
33
|
* @returns Success status
|
|
31
34
|
*/
|
|
32
|
-
export declare function deactivateConstraint(params: DeactivateConstraintParams): DeactivateConstraintResponse;
|
|
35
|
+
export declare function deactivateConstraint(params: DeactivateConstraintParams, db?: Database): DeactivateConstraintResponse;
|
|
33
36
|
/**
|
|
34
37
|
* Get help documentation for constraint tool
|
|
35
38
|
* @returns Help documentation object
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constraints.d.ts","sourceRoot":"","sources":["../../src/tools/constraints.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,EAC1B,4BAA4B,
|
|
1
|
+
{"version":3,"file":"constraints.d.ts","sourceRoot":"","sources":["../../src/tools/constraints.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,EAC1B,4BAA4B,EAG5B,QAAQ,EACT,MAAM,aAAa,CAAC;AAErB;;;GAGG;AAEH;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,qBAAqB,CAoE/F;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,oBAAoB,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,sBAAsB,CAmElG;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,0BAA0B,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,4BAA4B,CA0BpH;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,GAAG,CAsBpC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,GAAG,CAuIvC"}
|
|
@@ -13,10 +13,11 @@ import { validateCategory, validatePriority } from '../utils/validators.js';
|
|
|
13
13
|
* Add a constraint with priority, layer, and tags
|
|
14
14
|
*
|
|
15
15
|
* @param params - Constraint parameters
|
|
16
|
+
* @param db - Optional database instance (for testing)
|
|
16
17
|
* @returns Constraint ID and timestamp
|
|
17
18
|
*/
|
|
18
|
-
export function addConstraint(params) {
|
|
19
|
-
const
|
|
19
|
+
export function addConstraint(params, db) {
|
|
20
|
+
const actualDb = db ?? getDatabase();
|
|
20
21
|
try {
|
|
21
22
|
// Validate required parameters
|
|
22
23
|
if (!params.category || !params.constraint_text) {
|
|
@@ -35,29 +36,29 @@ export function addConstraint(params) {
|
|
|
35
36
|
if (!validLayers.includes(params.layer)) {
|
|
36
37
|
throw new Error(`Invalid layer. Must be one of: ${validLayers.join(', ')}`);
|
|
37
38
|
}
|
|
38
|
-
layerId = getLayerId(
|
|
39
|
+
layerId = getLayerId(actualDb, params.layer);
|
|
39
40
|
if (!layerId) {
|
|
40
41
|
throw new Error(`Layer not found: ${params.layer}`);
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
// Use transaction for multi-table insert
|
|
44
|
-
const result = transaction(
|
|
45
|
+
const result = transaction(actualDb, () => {
|
|
45
46
|
// Get or create category
|
|
46
|
-
const categoryId = getOrCreateCategoryId(
|
|
47
|
+
const categoryId = getOrCreateCategoryId(actualDb, params.category);
|
|
47
48
|
// Get or create created_by agent
|
|
48
49
|
const createdBy = params.created_by || 'system';
|
|
49
|
-
const agentId = getOrCreateAgent(
|
|
50
|
+
const agentId = getOrCreateAgent(actualDb, createdBy);
|
|
50
51
|
// Insert constraint
|
|
51
|
-
const insertResult =
|
|
52
|
+
const insertResult = actualDb.prepare(`
|
|
52
53
|
INSERT INTO t_constraints (category_id, layer_id, constraint_text, priority, active, created_by, ts)
|
|
53
54
|
VALUES (?, ?, ?, ?, ?, ?, unixepoch())
|
|
54
55
|
`).run(categoryId, layerId, params.constraint_text, priority, SQLITE_TRUE, agentId);
|
|
55
56
|
const constraintId = insertResult.lastInsertRowid;
|
|
56
57
|
// Insert m_tags if provided
|
|
57
58
|
if (params.tags && params.tags.length > 0) {
|
|
58
|
-
const tagStmt =
|
|
59
|
+
const tagStmt = actualDb.prepare('INSERT INTO t_constraint_tags (constraint_id, tag_id) VALUES (?, ?)');
|
|
59
60
|
for (const tagName of params.tags) {
|
|
60
|
-
const tagId = getOrCreateTag(
|
|
61
|
+
const tagId = getOrCreateTag(actualDb, tagName);
|
|
61
62
|
tagStmt.run(constraintId, tagId);
|
|
62
63
|
}
|
|
63
64
|
}
|
|
@@ -78,10 +79,11 @@ export function addConstraint(params) {
|
|
|
78
79
|
* Uses v_tagged_constraints view for token efficiency
|
|
79
80
|
*
|
|
80
81
|
* @param params - Filter parameters
|
|
82
|
+
* @param db - Optional database instance (for testing)
|
|
81
83
|
* @returns Array of t_constraints matching filters
|
|
82
84
|
*/
|
|
83
|
-
export function getConstraints(params) {
|
|
84
|
-
const
|
|
85
|
+
export function getConstraints(params, db) {
|
|
86
|
+
const actualDb = db ?? getDatabase();
|
|
85
87
|
try {
|
|
86
88
|
// Build query conditions
|
|
87
89
|
const conditions = [];
|
|
@@ -122,7 +124,7 @@ export function getConstraints(params) {
|
|
|
122
124
|
sql += ' LIMIT ?';
|
|
123
125
|
values.push(limit);
|
|
124
126
|
// Execute query
|
|
125
|
-
const rows =
|
|
127
|
+
const rows = actualDb.prepare(sql).all(...values);
|
|
126
128
|
// Parse m_tags from comma-separated to array for consistency
|
|
127
129
|
const constraints = rows.map(row => ({
|
|
128
130
|
...row,
|
|
@@ -143,22 +145,23 @@ export function getConstraints(params) {
|
|
|
143
145
|
* Idempotent - deactivating already-inactive constraint is safe
|
|
144
146
|
*
|
|
145
147
|
* @param params - Constraint ID to deactivate
|
|
148
|
+
* @param db - Optional database instance (for testing)
|
|
146
149
|
* @returns Success status
|
|
147
150
|
*/
|
|
148
|
-
export function deactivateConstraint(params) {
|
|
149
|
-
const
|
|
151
|
+
export function deactivateConstraint(params, db) {
|
|
152
|
+
const actualDb = db ?? getDatabase();
|
|
150
153
|
try {
|
|
151
154
|
// Validate constraint_id
|
|
152
155
|
if (!params.constraint_id || typeof params.constraint_id !== 'number') {
|
|
153
156
|
throw new Error('constraint_id is required and must be a number');
|
|
154
157
|
}
|
|
155
158
|
// Check if constraint exists
|
|
156
|
-
const constraint =
|
|
159
|
+
const constraint = actualDb.prepare('SELECT id, active FROM t_constraints WHERE id = ?').get(params.constraint_id);
|
|
157
160
|
if (!constraint) {
|
|
158
161
|
throw new Error(`Constraint not found: ${params.constraint_id}`);
|
|
159
162
|
}
|
|
160
163
|
// Update constraint to inactive (idempotent)
|
|
161
|
-
|
|
164
|
+
actualDb.prepare('UPDATE t_constraints SET active = ? WHERE id = ?').run(SQLITE_FALSE, params.constraint_id);
|
|
162
165
|
return {
|
|
163
166
|
success: true,
|
|
164
167
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constraints.js","sourceRoot":"","sources":["../../src/tools/constraints.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC/H,OAAO,EACL,kBAAkB,EAElB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAa5E;;;GAGG;AAEH
|
|
1
|
+
{"version":3,"file":"constraints.js","sourceRoot":"","sources":["../../src/tools/constraints.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC/H,OAAO,EACL,kBAAkB,EAElB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAa5E;;;GAGG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,MAA2B,EAAE,EAAa;IACtE,MAAM,QAAQ,GAAG,EAAE,IAAI,WAAW,EAAE,CAA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|
|
|
2
2
|
* Context management tools for MCP Shared Context Server
|
|
3
3
|
* Implements set_decision, get_context, and get_decision tools
|
|
4
4
|
*/
|
|
5
|
-
import type { SetDecisionParams, GetContextParams, GetDecisionParams, SetDecisionResponse, GetContextResponse, GetDecisionResponse, SearchByTagsParams, SearchByTagsResponse, GetVersionsParams, GetVersionsResponse, SearchByLayerParams, SearchByLayerResponse, QuickSetDecisionParams, QuickSetDecisionResponse, SearchAdvancedParams, SearchAdvancedResponse, SetDecisionBatchParams, SetDecisionBatchResponse, SetFromTemplateParams, SetFromTemplateResponse, CreateTemplateParams, CreateTemplateResponse, ListTemplatesParams, ListTemplatesResponse, HasUpdatesParams, HasUpdatesResponse, HardDeleteDecisionParams, HardDeleteDecisionResponse } from '../types.js';
|
|
5
|
+
import type { SetDecisionParams, GetContextParams, GetDecisionParams, SetDecisionResponse, GetContextResponse, GetDecisionResponse, Database, SearchByTagsParams, SearchByTagsResponse, GetVersionsParams, GetVersionsResponse, SearchByLayerParams, SearchByLayerResponse, QuickSetDecisionParams, QuickSetDecisionResponse, SearchAdvancedParams, SearchAdvancedResponse, SetDecisionBatchParams, SetDecisionBatchResponse, SetFromTemplateParams, SetFromTemplateResponse, CreateTemplateParams, CreateTemplateResponse, ListTemplatesParams, ListTemplatesResponse, HasUpdatesParams, HasUpdatesResponse, HardDeleteDecisionParams, HardDeleteDecisionResponse } from '../types.js';
|
|
6
6
|
/**
|
|
7
7
|
* Set or update a decision in the context
|
|
8
8
|
* Auto-detects numeric vs string values and routes to appropriate table
|
|
9
9
|
* Supports tags, layers, scopes, and version tracking
|
|
10
10
|
*
|
|
11
11
|
* @param params - Decision parameters
|
|
12
|
+
* @param db - Optional database instance (for testing)
|
|
12
13
|
* @returns Response with success status and metadata
|
|
13
14
|
*/
|
|
14
|
-
export declare function setDecision(params: SetDecisionParams): SetDecisionResponse;
|
|
15
|
+
export declare function setDecision(params: SetDecisionParams, db?: Database): SetDecisionResponse;
|
|
15
16
|
/**
|
|
16
17
|
* Get context t_decisions with advanced filtering
|
|
17
18
|
* Uses v_tagged_decisions view for token efficiency
|
|
18
19
|
* Supports filtering by status, layer, tags, and scope
|
|
19
20
|
*
|
|
20
21
|
* @param params - Filter parameters
|
|
22
|
+
* @param db - Optional database instance (for testing)
|
|
21
23
|
* @returns Array of t_decisions with metadata
|
|
22
24
|
*/
|
|
23
|
-
export declare function getContext(params?: GetContextParams): GetContextResponse;
|
|
25
|
+
export declare function getContext(params?: GetContextParams, db?: Database): GetContextResponse;
|
|
24
26
|
/**
|
|
25
27
|
* Get a specific decision by key
|
|
26
28
|
* Returns full metadata including tags, layer, scopes, version
|
|
27
29
|
* Optionally includes decision context (v3.2.2)
|
|
28
30
|
*
|
|
29
31
|
* @param params - Decision key and optional include_context flag
|
|
32
|
+
* @param db - Optional database instance (for testing)
|
|
30
33
|
* @returns Decision details or not found
|
|
31
34
|
*/
|
|
32
35
|
export declare function getDecision(params: GetDecisionParams & {
|
|
33
36
|
include_context?: boolean;
|
|
34
|
-
}): GetDecisionResponse;
|
|
37
|
+
}, db?: Database): GetDecisionResponse;
|
|
35
38
|
/**
|
|
36
39
|
* Search for t_decisions by m_tags with AND/OR logic
|
|
37
40
|
* Provides flexible tag-based filtering with status and layer support
|
|
38
41
|
*
|
|
39
42
|
* @param params - Search parameters (tags, match_mode, status, layer)
|
|
43
|
+
* @param db - Optional database instance (for testing)
|
|
40
44
|
* @returns Array of t_decisions matching tag criteria
|
|
41
45
|
*/
|
|
42
|
-
export declare function searchByTags(params: SearchByTagsParams): SearchByTagsResponse;
|
|
46
|
+
export declare function searchByTags(params: SearchByTagsParams, db?: Database): SearchByTagsResponse;
|
|
43
47
|
/**
|
|
44
48
|
* Get version history for a specific decision key
|
|
45
49
|
* Returns all historical versions ordered by timestamp (newest first)
|
|
46
50
|
*
|
|
47
51
|
* @param params - Decision key to get history for
|
|
52
|
+
* @param db - Optional database instance (for testing)
|
|
48
53
|
* @returns Array of historical versions with metadata
|
|
49
54
|
*/
|
|
50
|
-
export declare function getVersions(params: GetVersionsParams): GetVersionsResponse;
|
|
55
|
+
export declare function getVersions(params: GetVersionsParams, db?: Database): GetVersionsResponse;
|
|
51
56
|
/**
|
|
52
57
|
* Search for t_decisions within a specific architecture layer
|
|
53
58
|
* Supports status filtering and optional tag inclusion
|
|
54
59
|
*
|
|
55
60
|
* @param params - Layer name, optional status and include_tags
|
|
61
|
+
* @param db - Optional database instance (for testing)
|
|
56
62
|
* @returns Array of t_decisions in the specified layer
|
|
57
63
|
*/
|
|
58
|
-
export declare function searchByLayer(params: SearchByLayerParams): SearchByLayerResponse;
|
|
64
|
+
export declare function searchByLayer(params: SearchByLayerParams, db?: Database): SearchByLayerResponse;
|
|
59
65
|
/**
|
|
60
66
|
* Quick set decision with smart defaults and inference
|
|
61
67
|
* Reduces required parameters from 7 to 2 (key + value only)
|
|
@@ -81,9 +87,10 @@ export declare function searchByLayer(params: SearchByLayerParams): SearchByLaye
|
|
|
81
87
|
* All inferred fields can be overridden via optional parameters.
|
|
82
88
|
*
|
|
83
89
|
* @param params - Quick set parameters (key and value required)
|
|
90
|
+
* @param db - Optional database instance (for testing)
|
|
84
91
|
* @returns Response with success status and inferred metadata
|
|
85
92
|
*/
|
|
86
|
-
export declare function quickSetDecision(params: QuickSetDecisionParams): QuickSetDecisionResponse;
|
|
93
|
+
export declare function quickSetDecision(params: QuickSetDecisionParams, db?: Database): QuickSetDecisionResponse;
|
|
87
94
|
/**
|
|
88
95
|
* Advanced query composition with complex filtering capabilities
|
|
89
96
|
* Supports multiple filter types, sorting, and pagination
|
|
@@ -100,52 +107,58 @@ export declare function quickSetDecision(params: QuickSetDecisionParams): QuickS
|
|
|
100
107
|
* - search_text: Full-text search in value field
|
|
101
108
|
*
|
|
102
109
|
* @param params - Advanced search parameters with filtering, sorting, pagination
|
|
110
|
+
* @param db - Optional database instance (for testing)
|
|
103
111
|
* @returns Filtered decisions with total count for pagination
|
|
104
112
|
*/
|
|
105
|
-
export declare function searchAdvanced(params?: SearchAdvancedParams): SearchAdvancedResponse;
|
|
113
|
+
export declare function searchAdvanced(params?: SearchAdvancedParams, db?: Database): SearchAdvancedResponse;
|
|
106
114
|
/**
|
|
107
115
|
* Set multiple decisions in a single batch operation (FR-005)
|
|
108
116
|
* Supports atomic (all succeed or all fail) and non-atomic modes
|
|
109
117
|
* Limit: 50 items per batch (constraint #3)
|
|
110
118
|
*
|
|
111
119
|
* @param params - Batch parameters with array of decisions and atomic flag
|
|
120
|
+
* @param db - Optional database instance (for testing)
|
|
112
121
|
* @returns Response with success status and detailed results for each item
|
|
113
122
|
*/
|
|
114
|
-
export declare function setDecisionBatch(params: SetDecisionBatchParams): SetDecisionBatchResponse;
|
|
123
|
+
export declare function setDecisionBatch(params: SetDecisionBatchParams, db?: Database): SetDecisionBatchResponse;
|
|
115
124
|
/**
|
|
116
125
|
* Check for updates since a given timestamp (FR-003 Phase A)
|
|
117
126
|
* Lightweight polling mechanism using COUNT queries
|
|
118
127
|
* Token cost: ~5-10 tokens per check
|
|
119
128
|
*
|
|
120
129
|
* @param params - Agent name and since_timestamp (ISO 8601)
|
|
130
|
+
* @param db - Optional database instance (for testing)
|
|
121
131
|
* @returns Boolean flag and counts for decisions, messages, files
|
|
122
132
|
*/
|
|
123
|
-
export declare function hasUpdates(params: HasUpdatesParams): HasUpdatesResponse;
|
|
133
|
+
export declare function hasUpdates(params: HasUpdatesParams, db?: Database): HasUpdatesResponse;
|
|
124
134
|
/**
|
|
125
135
|
* Set decision from template with defaults and required field validation (FR-006)
|
|
126
136
|
* Applies template defaults while allowing overrides
|
|
127
137
|
* Validates required fields if template specifies any
|
|
128
138
|
*
|
|
129
139
|
* @param params - Template name, key, value, and optional overrides
|
|
140
|
+
* @param db - Optional database instance (for testing)
|
|
130
141
|
* @returns Response with success status and applied defaults metadata
|
|
131
142
|
*/
|
|
132
|
-
export declare function setFromTemplate(params: SetFromTemplateParams): SetFromTemplateResponse;
|
|
143
|
+
export declare function setFromTemplate(params: SetFromTemplateParams, db?: Database): SetFromTemplateResponse;
|
|
133
144
|
/**
|
|
134
145
|
* Create a new decision template (FR-006)
|
|
135
146
|
* Defines reusable defaults and required fields for decisions
|
|
136
147
|
*
|
|
137
148
|
* @param params - Template name, defaults, required fields, and creator
|
|
149
|
+
* @param db - Optional database instance (for testing)
|
|
138
150
|
* @returns Response with success status and template ID
|
|
139
151
|
*/
|
|
140
|
-
export declare function createTemplate(params: CreateTemplateParams): CreateTemplateResponse;
|
|
152
|
+
export declare function createTemplate(params: CreateTemplateParams, db?: Database): CreateTemplateResponse;
|
|
141
153
|
/**
|
|
142
154
|
* List all available decision templates (FR-006)
|
|
143
155
|
* Returns all templates with their defaults and metadata
|
|
144
156
|
*
|
|
145
157
|
* @param params - No parameters required
|
|
158
|
+
* @param db - Optional database instance (for testing)
|
|
146
159
|
* @returns Array of all templates with parsed JSON fields
|
|
147
160
|
*/
|
|
148
|
-
export declare function listTemplates(params?: ListTemplatesParams): ListTemplatesResponse;
|
|
161
|
+
export declare function listTemplates(params?: ListTemplatesParams, db?: Database): ListTemplatesResponse;
|
|
149
162
|
/**
|
|
150
163
|
* Permanently delete a decision and all related data (hard delete)
|
|
151
164
|
* Unlike soft delete (status=deprecated), this removes all records from database
|
|
@@ -159,25 +172,28 @@ export declare function listTemplates(params?: ListTemplatesParams): ListTemplat
|
|
|
159
172
|
* (tags, scopes) will also be deleted due to CASCADE constraints.
|
|
160
173
|
*
|
|
161
174
|
* @param params - Decision key to delete
|
|
175
|
+
* @param db - Optional database instance (for testing)
|
|
162
176
|
* @returns Response with success status
|
|
163
177
|
*/
|
|
164
|
-
export declare function hardDeleteDecision(params: HardDeleteDecisionParams): HardDeleteDecisionResponse;
|
|
178
|
+
export declare function hardDeleteDecision(params: HardDeleteDecisionParams, db?: Database): HardDeleteDecisionResponse;
|
|
165
179
|
/**
|
|
166
180
|
* Add decision context action
|
|
167
181
|
* Adds rich context (rationale, alternatives, tradeoffs) to a decision
|
|
168
182
|
*
|
|
169
183
|
* @param params - Context parameters
|
|
184
|
+
* @param db - Optional database instance (for testing)
|
|
170
185
|
* @returns Response with success status
|
|
171
186
|
*/
|
|
172
|
-
export declare function addDecisionContextAction(params: any): any;
|
|
187
|
+
export declare function addDecisionContextAction(params: any, db?: Database): any;
|
|
173
188
|
/**
|
|
174
189
|
* List decision contexts action
|
|
175
190
|
* Query decision contexts with optional filters
|
|
176
191
|
*
|
|
177
192
|
* @param params - Filter parameters
|
|
193
|
+
* @param db - Optional database instance (for testing)
|
|
178
194
|
* @returns Array of decision contexts
|
|
179
195
|
*/
|
|
180
|
-
export declare function listDecisionContextsAction(params: any): any;
|
|
196
|
+
export declare function listDecisionContextsAction(params: any, db?: Database): any;
|
|
181
197
|
/**
|
|
182
198
|
* Help action for decision tool
|
|
183
199
|
*/
|