@soleri/core 2.4.0 → 2.5.0
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/dist/brain/brain.d.ts +7 -0
- package/dist/brain/brain.d.ts.map +1 -1
- package/dist/brain/brain.js +56 -9
- package/dist/brain/brain.js.map +1 -1
- package/dist/brain/types.d.ts +2 -2
- package/dist/brain/types.d.ts.map +1 -1
- package/dist/cognee/client.d.ts +3 -0
- package/dist/cognee/client.d.ts.map +1 -1
- package/dist/cognee/client.js +17 -0
- package/dist/cognee/client.js.map +1 -1
- package/dist/cognee/sync-manager.d.ts +94 -0
- package/dist/cognee/sync-manager.d.ts.map +1 -0
- package/dist/cognee/sync-manager.js +293 -0
- package/dist/cognee/sync-manager.js.map +1 -0
- package/dist/curator/curator.d.ts +8 -1
- package/dist/curator/curator.d.ts.map +1 -1
- package/dist/curator/curator.js +64 -1
- package/dist/curator/curator.js.map +1 -1
- package/dist/errors/classify.d.ts +13 -0
- package/dist/errors/classify.d.ts.map +1 -0
- package/dist/errors/classify.js +97 -0
- package/dist/errors/classify.js.map +1 -0
- package/dist/errors/index.d.ts +6 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +4 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/retry.d.ts +40 -0
- package/dist/errors/retry.d.ts.map +1 -0
- package/dist/errors/retry.js +97 -0
- package/dist/errors/retry.js.map +1 -0
- package/dist/errors/types.d.ts +48 -0
- package/dist/errors/types.d.ts.map +1 -0
- package/dist/errors/types.js +59 -0
- package/dist/errors/types.js.map +1 -0
- package/dist/index.d.ts +25 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/dist/intake/content-classifier.d.ts +14 -0
- package/dist/intake/content-classifier.d.ts.map +1 -0
- package/dist/intake/content-classifier.js +125 -0
- package/dist/intake/content-classifier.js.map +1 -0
- package/dist/intake/dedup-gate.d.ts +17 -0
- package/dist/intake/dedup-gate.d.ts.map +1 -0
- package/dist/intake/dedup-gate.js +66 -0
- package/dist/intake/dedup-gate.js.map +1 -0
- package/dist/intake/intake-pipeline.d.ts +63 -0
- package/dist/intake/intake-pipeline.d.ts.map +1 -0
- package/dist/intake/intake-pipeline.js +373 -0
- package/dist/intake/intake-pipeline.js.map +1 -0
- package/dist/intake/types.d.ts +65 -0
- package/dist/intake/types.d.ts.map +1 -0
- package/dist/intake/types.js +3 -0
- package/dist/intake/types.js.map +1 -0
- package/dist/intelligence/loader.js +1 -1
- package/dist/intelligence/loader.js.map +1 -1
- package/dist/intelligence/types.d.ts +3 -1
- package/dist/intelligence/types.d.ts.map +1 -1
- package/dist/loop/loop-manager.d.ts +58 -7
- package/dist/loop/loop-manager.d.ts.map +1 -1
- package/dist/loop/loop-manager.js +280 -6
- package/dist/loop/loop-manager.js.map +1 -1
- package/dist/loop/types.d.ts +69 -1
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/types.js +4 -1
- package/dist/loop/types.js.map +1 -1
- package/dist/persistence/index.d.ts +3 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/index.js +2 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/persistence/sqlite-provider.d.ts +25 -0
- package/dist/persistence/sqlite-provider.d.ts.map +1 -0
- package/dist/persistence/sqlite-provider.js +59 -0
- package/dist/persistence/sqlite-provider.js.map +1 -0
- package/dist/persistence/types.d.ts +36 -0
- package/dist/persistence/types.d.ts.map +1 -0
- package/dist/persistence/types.js +8 -0
- package/dist/persistence/types.js.map +1 -0
- package/dist/planning/gap-analysis.d.ts +47 -4
- package/dist/planning/gap-analysis.d.ts.map +1 -1
- package/dist/planning/gap-analysis.js +190 -13
- package/dist/planning/gap-analysis.js.map +1 -1
- package/dist/planning/gap-types.d.ts +1 -1
- package/dist/planning/gap-types.d.ts.map +1 -1
- package/dist/planning/gap-types.js.map +1 -1
- package/dist/planning/planner.d.ts +277 -9
- package/dist/planning/planner.d.ts.map +1 -1
- package/dist/planning/planner.js +611 -46
- package/dist/planning/planner.js.map +1 -1
- package/dist/playbooks/generic/brainstorming.d.ts +9 -0
- package/dist/playbooks/generic/brainstorming.d.ts.map +1 -0
- package/dist/playbooks/generic/brainstorming.js +105 -0
- package/dist/playbooks/generic/brainstorming.js.map +1 -0
- package/dist/playbooks/generic/code-review.d.ts +11 -0
- package/dist/playbooks/generic/code-review.d.ts.map +1 -0
- package/dist/playbooks/generic/code-review.js +176 -0
- package/dist/playbooks/generic/code-review.js.map +1 -0
- package/dist/playbooks/generic/subagent-execution.d.ts +9 -0
- package/dist/playbooks/generic/subagent-execution.d.ts.map +1 -0
- package/dist/playbooks/generic/subagent-execution.js +68 -0
- package/dist/playbooks/generic/subagent-execution.js.map +1 -0
- package/dist/playbooks/generic/systematic-debugging.d.ts +9 -0
- package/dist/playbooks/generic/systematic-debugging.d.ts.map +1 -0
- package/dist/playbooks/generic/systematic-debugging.js +87 -0
- package/dist/playbooks/generic/systematic-debugging.js.map +1 -0
- package/dist/playbooks/generic/tdd.d.ts +9 -0
- package/dist/playbooks/generic/tdd.d.ts.map +1 -0
- package/dist/playbooks/generic/tdd.js +70 -0
- package/dist/playbooks/generic/tdd.js.map +1 -0
- package/dist/playbooks/generic/verification.d.ts +9 -0
- package/dist/playbooks/generic/verification.d.ts.map +1 -0
- package/dist/playbooks/generic/verification.js +74 -0
- package/dist/playbooks/generic/verification.js.map +1 -0
- package/dist/playbooks/index.d.ts +4 -0
- package/dist/playbooks/index.d.ts.map +1 -0
- package/dist/playbooks/index.js +5 -0
- package/dist/playbooks/index.js.map +1 -0
- package/dist/playbooks/playbook-registry.d.ts +42 -0
- package/dist/playbooks/playbook-registry.d.ts.map +1 -0
- package/dist/playbooks/playbook-registry.js +227 -0
- package/dist/playbooks/playbook-registry.js.map +1 -0
- package/dist/playbooks/playbook-seeder.d.ts +47 -0
- package/dist/playbooks/playbook-seeder.d.ts.map +1 -0
- package/dist/playbooks/playbook-seeder.js +104 -0
- package/dist/playbooks/playbook-seeder.js.map +1 -0
- package/dist/playbooks/playbook-types.d.ts +132 -0
- package/dist/playbooks/playbook-types.d.ts.map +1 -0
- package/dist/playbooks/playbook-types.js +12 -0
- package/dist/playbooks/playbook-types.js.map +1 -0
- package/dist/project/project-registry.d.ts.map +1 -1
- package/dist/project/project-registry.js +9 -11
- package/dist/project/project-registry.js.map +1 -1
- package/dist/prompts/index.d.ts +4 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +3 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/parser.d.ts +17 -0
- package/dist/prompts/parser.d.ts.map +1 -0
- package/dist/prompts/parser.js +47 -0
- package/dist/prompts/parser.js.map +1 -0
- package/dist/prompts/template-manager.d.ts +25 -0
- package/dist/prompts/template-manager.d.ts.map +1 -0
- package/dist/prompts/template-manager.js +71 -0
- package/dist/prompts/template-manager.js.map +1 -0
- package/dist/prompts/types.d.ts +26 -0
- package/dist/prompts/types.d.ts.map +1 -0
- package/dist/prompts/types.js +5 -0
- package/dist/prompts/types.js.map +1 -0
- package/dist/runtime/admin-extra-ops.d.ts +5 -3
- package/dist/runtime/admin-extra-ops.d.ts.map +1 -1
- package/dist/runtime/admin-extra-ops.js +322 -11
- package/dist/runtime/admin-extra-ops.js.map +1 -1
- package/dist/runtime/admin-ops.d.ts.map +1 -1
- package/dist/runtime/admin-ops.js +10 -3
- package/dist/runtime/admin-ops.js.map +1 -1
- package/dist/runtime/capture-ops.d.ts.map +1 -1
- package/dist/runtime/capture-ops.js +20 -2
- package/dist/runtime/capture-ops.js.map +1 -1
- package/dist/runtime/cognee-sync-ops.d.ts +12 -0
- package/dist/runtime/cognee-sync-ops.d.ts.map +1 -0
- package/dist/runtime/cognee-sync-ops.js +55 -0
- package/dist/runtime/cognee-sync-ops.js.map +1 -0
- package/dist/runtime/core-ops.d.ts +8 -6
- package/dist/runtime/core-ops.d.ts.map +1 -1
- package/dist/runtime/core-ops.js +226 -9
- package/dist/runtime/core-ops.js.map +1 -1
- package/dist/runtime/curator-extra-ops.d.ts +2 -2
- package/dist/runtime/curator-extra-ops.d.ts.map +1 -1
- package/dist/runtime/curator-extra-ops.js +15 -3
- package/dist/runtime/curator-extra-ops.js.map +1 -1
- package/dist/runtime/domain-ops.js +2 -2
- package/dist/runtime/domain-ops.js.map +1 -1
- package/dist/runtime/grading-ops.d.ts.map +1 -1
- package/dist/runtime/grading-ops.js.map +1 -1
- package/dist/runtime/intake-ops.d.ts +14 -0
- package/dist/runtime/intake-ops.d.ts.map +1 -0
- package/dist/runtime/intake-ops.js +110 -0
- package/dist/runtime/intake-ops.js.map +1 -0
- package/dist/runtime/loop-ops.d.ts +5 -4
- package/dist/runtime/loop-ops.d.ts.map +1 -1
- package/dist/runtime/loop-ops.js +84 -12
- package/dist/runtime/loop-ops.js.map +1 -1
- package/dist/runtime/memory-cross-project-ops.d.ts.map +1 -1
- package/dist/runtime/memory-cross-project-ops.js.map +1 -1
- package/dist/runtime/memory-extra-ops.js +5 -5
- package/dist/runtime/memory-extra-ops.js.map +1 -1
- package/dist/runtime/orchestrate-ops.d.ts.map +1 -1
- package/dist/runtime/orchestrate-ops.js +8 -2
- package/dist/runtime/orchestrate-ops.js.map +1 -1
- package/dist/runtime/planning-extra-ops.d.ts +13 -5
- package/dist/runtime/planning-extra-ops.d.ts.map +1 -1
- package/dist/runtime/planning-extra-ops.js +381 -18
- package/dist/runtime/planning-extra-ops.js.map +1 -1
- package/dist/runtime/playbook-ops.d.ts +14 -0
- package/dist/runtime/playbook-ops.d.ts.map +1 -0
- package/dist/runtime/playbook-ops.js +141 -0
- package/dist/runtime/playbook-ops.js.map +1 -0
- package/dist/runtime/project-ops.d.ts.map +1 -1
- package/dist/runtime/project-ops.js +7 -2
- package/dist/runtime/project-ops.js.map +1 -1
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +27 -8
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/types.d.ts +8 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/vault-extra-ops.d.ts +3 -2
- package/dist/runtime/vault-extra-ops.d.ts.map +1 -1
- package/dist/runtime/vault-extra-ops.js +345 -4
- package/dist/runtime/vault-extra-ops.js.map +1 -1
- package/dist/vault/playbook.d.ts +34 -0
- package/dist/vault/playbook.d.ts.map +1 -0
- package/dist/vault/playbook.js +60 -0
- package/dist/vault/playbook.js.map +1 -0
- package/dist/vault/vault.d.ts +31 -32
- package/dist/vault/vault.d.ts.map +1 -1
- package/dist/vault/vault.js +201 -181
- package/dist/vault/vault.js.map +1 -1
- package/package.json +7 -3
- package/src/__tests__/admin-extra-ops.test.ts +62 -15
- package/src/__tests__/admin-ops.test.ts +2 -2
- package/src/__tests__/brain.test.ts +3 -3
- package/src/__tests__/cognee-integration.test.ts +80 -0
- package/src/__tests__/cognee-sync-manager.test.ts +103 -0
- package/src/__tests__/core-ops.test.ts +30 -4
- package/src/__tests__/curator-extra-ops.test.ts +24 -2
- package/src/__tests__/errors.test.ts +388 -0
- package/src/__tests__/grading-ops.test.ts +28 -7
- package/src/__tests__/intake-pipeline.test.ts +162 -0
- package/src/__tests__/loop-ops.test.ts +74 -3
- package/src/__tests__/memory-cross-project-ops.test.ts +3 -1
- package/src/__tests__/orchestrate-ops.test.ts +8 -3
- package/src/__tests__/persistence.test.ts +225 -0
- package/src/__tests__/planner.test.ts +99 -21
- package/src/__tests__/planning-extra-ops.test.ts +168 -10
- package/src/__tests__/playbook-registry.test.ts +326 -0
- package/src/__tests__/playbook-seeder.test.ts +163 -0
- package/src/__tests__/playbook.test.ts +389 -0
- package/src/__tests__/project-ops.test.ts +18 -4
- package/src/__tests__/template-manager.test.ts +222 -0
- package/src/__tests__/vault-extra-ops.test.ts +82 -7
- package/src/brain/brain.ts +71 -9
- package/src/brain/types.ts +2 -2
- package/src/cognee/client.ts +18 -0
- package/src/cognee/sync-manager.ts +389 -0
- package/src/curator/curator.ts +88 -7
- package/src/errors/classify.ts +102 -0
- package/src/errors/index.ts +5 -0
- package/src/errors/retry.ts +132 -0
- package/src/errors/types.ts +81 -0
- package/src/index.ts +114 -3
- package/src/intake/content-classifier.ts +146 -0
- package/src/intake/dedup-gate.ts +92 -0
- package/src/intake/intake-pipeline.ts +503 -0
- package/src/intake/types.ts +69 -0
- package/src/intelligence/loader.ts +1 -1
- package/src/intelligence/types.ts +3 -1
- package/src/loop/loop-manager.ts +325 -7
- package/src/loop/types.ts +72 -1
- package/src/persistence/index.ts +7 -0
- package/src/persistence/sqlite-provider.ts +62 -0
- package/src/persistence/types.ts +44 -0
- package/src/planning/gap-analysis.ts +286 -17
- package/src/planning/gap-types.ts +4 -1
- package/src/planning/planner.ts +828 -55
- package/src/playbooks/generic/brainstorming.ts +110 -0
- package/src/playbooks/generic/code-review.ts +181 -0
- package/src/playbooks/generic/subagent-execution.ts +74 -0
- package/src/playbooks/generic/systematic-debugging.ts +92 -0
- package/src/playbooks/generic/tdd.ts +75 -0
- package/src/playbooks/generic/verification.ts +79 -0
- package/src/playbooks/index.ts +27 -0
- package/src/playbooks/playbook-registry.ts +284 -0
- package/src/playbooks/playbook-seeder.ts +119 -0
- package/src/playbooks/playbook-types.ts +162 -0
- package/src/project/project-registry.ts +29 -17
- package/src/prompts/index.ts +3 -0
- package/src/prompts/parser.ts +59 -0
- package/src/prompts/template-manager.ts +77 -0
- package/src/prompts/types.ts +28 -0
- package/src/runtime/admin-extra-ops.ts +358 -13
- package/src/runtime/admin-ops.ts +17 -6
- package/src/runtime/capture-ops.ts +25 -6
- package/src/runtime/cognee-sync-ops.ts +63 -0
- package/src/runtime/core-ops.ts +258 -8
- package/src/runtime/curator-extra-ops.ts +17 -3
- package/src/runtime/domain-ops.ts +2 -2
- package/src/runtime/grading-ops.ts +11 -2
- package/src/runtime/intake-ops.ts +126 -0
- package/src/runtime/loop-ops.ts +96 -13
- package/src/runtime/memory-cross-project-ops.ts +1 -2
- package/src/runtime/memory-extra-ops.ts +5 -5
- package/src/runtime/orchestrate-ops.ts +8 -2
- package/src/runtime/planning-extra-ops.ts +414 -23
- package/src/runtime/playbook-ops.ts +169 -0
- package/src/runtime/project-ops.ts +9 -3
- package/src/runtime/runtime.ts +35 -9
- package/src/runtime/types.ts +8 -0
- package/src/runtime/vault-extra-ops.ts +385 -4
- package/src/vault/playbook.ts +87 -0
- package/src/vault/vault.ts +301 -235
package/dist/loop/types.d.ts
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* Loop system types — iterative validation loop state tracking.
|
|
3
3
|
*
|
|
4
4
|
* Loops let agents run validate-fix-validate cycles (e.g. token migration,
|
|
5
|
-
* contrast fixes, component builds).
|
|
5
|
+
* contrast fixes, component builds).
|
|
6
|
+
*
|
|
7
|
+
* Ported from Salvador's loop.facade.ts with full gate decision system,
|
|
8
|
+
* output scanning, and completion promise detection.
|
|
6
9
|
*/
|
|
7
10
|
/** Supported loop modes — each maps to a different validation strategy. */
|
|
8
11
|
export type LoopMode = 'token-migration' | 'contrast-fix' | 'component-build' | 'plan-iteration' | 'custom';
|
|
@@ -11,7 +14,16 @@ export interface LoopConfig {
|
|
|
11
14
|
mode: LoopMode;
|
|
12
15
|
prompt: string;
|
|
13
16
|
maxIterations: number;
|
|
17
|
+
/** Target validation score for score-based modes (token-migration, component-build). */
|
|
14
18
|
targetScore?: number;
|
|
19
|
+
/** Target grade for plan-iteration mode (e.g., 'A', 'A+'). */
|
|
20
|
+
targetGrade?: string;
|
|
21
|
+
/** Completion promise text — loop completes when this appears in output. */
|
|
22
|
+
completionPromise?: string;
|
|
23
|
+
/** Validation instructions appended to the prompt each iteration. */
|
|
24
|
+
validationInstructions?: string;
|
|
25
|
+
/** Detected intent for this loop (e.g., 'BUILD', 'FIX'). Used for brain session recording. */
|
|
26
|
+
intent?: string;
|
|
15
27
|
}
|
|
16
28
|
/** A single iteration result within a loop. */
|
|
17
29
|
export interface LoopIteration {
|
|
@@ -20,9 +32,23 @@ export interface LoopIteration {
|
|
|
20
32
|
validationScore?: number;
|
|
21
33
|
validationResult?: string;
|
|
22
34
|
passed: boolean;
|
|
35
|
+
/** Duration of this iteration in milliseconds. */
|
|
36
|
+
durationMs?: number;
|
|
23
37
|
}
|
|
24
38
|
/** Loop lifecycle status. */
|
|
25
39
|
export type LoopStatus = 'active' | 'completed' | 'cancelled' | 'max-iterations';
|
|
40
|
+
/**
|
|
41
|
+
* Knowledge items tracked during loop execution.
|
|
42
|
+
* Ported from Salvador's loop knowledge tracking for brain session recording.
|
|
43
|
+
*/
|
|
44
|
+
export interface LoopKnowledge {
|
|
45
|
+
/** Knowledge items discovered during the loop. */
|
|
46
|
+
items?: string[];
|
|
47
|
+
/** Patterns successfully applied during the loop. */
|
|
48
|
+
patternsApplied?: string[];
|
|
49
|
+
/** Anti-patterns intentionally avoided during the loop. */
|
|
50
|
+
antiPatternsAvoided?: string[];
|
|
51
|
+
}
|
|
26
52
|
/** Full state of a loop (active or historical). */
|
|
27
53
|
export interface LoopState {
|
|
28
54
|
id: string;
|
|
@@ -31,5 +57,47 @@ export interface LoopState {
|
|
|
31
57
|
status: LoopStatus;
|
|
32
58
|
startedAt: string;
|
|
33
59
|
completedAt?: string;
|
|
60
|
+
/** Knowledge accumulated during the loop. */
|
|
61
|
+
knowledge?: LoopKnowledge;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Loop history entry — stored after loop completion.
|
|
65
|
+
* Ported from Salvador's LoopHistoryEntry.
|
|
66
|
+
*/
|
|
67
|
+
export interface LoopHistoryEntry {
|
|
68
|
+
id: string;
|
|
69
|
+
mode: LoopMode;
|
|
70
|
+
intent?: string;
|
|
71
|
+
prompt: string;
|
|
72
|
+
iterations: number;
|
|
73
|
+
outcome: 'completed' | 'cancelled' | 'max_iterations';
|
|
74
|
+
startedAt: string;
|
|
75
|
+
completedAt: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Gate decision returned by iterateWithGate().
|
|
79
|
+
* Ported from Salvador's LoopIterateDecision.
|
|
80
|
+
*
|
|
81
|
+
* - 'allow': Loop has ended (completed, max_iterations, or error). Exit the loop.
|
|
82
|
+
* - 'block': Loop continues. The returned prompt and systemMessage are injected
|
|
83
|
+
* into the next iteration of the Stop hook.
|
|
84
|
+
*/
|
|
85
|
+
export interface LoopIterateDecision {
|
|
86
|
+
/** Gate decision: 'allow' to exit loop, 'block' to continue iterating. */
|
|
87
|
+
decision: 'allow' | 'block';
|
|
88
|
+
/** Human-readable reason for this decision. */
|
|
89
|
+
reason: string;
|
|
90
|
+
/** Full prompt for the next iteration (only when decision = 'block'). */
|
|
91
|
+
prompt?: string;
|
|
92
|
+
/** System message for the next iteration (only when decision = 'block'). */
|
|
93
|
+
systemMessage?: string;
|
|
94
|
+
/** Current iteration number. */
|
|
95
|
+
iteration?: number;
|
|
96
|
+
/** Outcome when loop ends (only when decision = 'allow'). */
|
|
97
|
+
outcome?: 'completed' | 'max_iterations';
|
|
98
|
+
/** Whether completion was auto-detected (heuristic, not explicit promise). */
|
|
99
|
+
autoCompleted?: boolean;
|
|
100
|
+
/** Warning if anomalous patterns detected in this iteration. */
|
|
101
|
+
anomalyWarning?: string;
|
|
34
102
|
}
|
|
35
103
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/loop/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/loop/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/loop/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,2EAA2E;AAC3E,MAAM,MAAM,QAAQ,GAChB,iBAAiB,GACjB,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,QAAQ,CAAC;AAEb,6CAA6C;AAC7C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,wFAAwF;IACxF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qEAAqE;IACrE,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,8FAA8F;IAC9F,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,+CAA+C;AAC/C,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,6BAA6B;AAC7B,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAEjF;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,qDAAqD;IACrD,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,2DAA2D;IAC3D,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;CAChC;AAED,mDAAmD;AACnD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,aAAa,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,gBAAgB,CAAC;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC;IAC5B,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,WAAW,GAAG,gBAAgB,CAAC;IACzC,8EAA8E;IAC9E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gEAAgE;IAChE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
|
package/dist/loop/types.js
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* Loop system types — iterative validation loop state tracking.
|
|
3
3
|
*
|
|
4
4
|
* Loops let agents run validate-fix-validate cycles (e.g. token migration,
|
|
5
|
-
* contrast fixes, component builds).
|
|
5
|
+
* contrast fixes, component builds).
|
|
6
|
+
*
|
|
7
|
+
* Ported from Salvador's loop.facade.ts with full gate decision system,
|
|
8
|
+
* output scanning, and completion promise detection.
|
|
6
9
|
*/
|
|
7
10
|
export {};
|
|
8
11
|
//# sourceMappingURL=types.js.map
|
package/dist/loop/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/loop/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/loop/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/persistence/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/persistence/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite persistence provider backed by better-sqlite3.
|
|
3
|
+
*
|
|
4
|
+
* Supports both positional (array) and named (object) parameters.
|
|
5
|
+
* Exposes getDatabase() for backward-compat consumers that need the raw db.
|
|
6
|
+
*/
|
|
7
|
+
import Database from 'better-sqlite3';
|
|
8
|
+
import type { PersistenceProvider, PersistenceParams, RunResult } from './types.js';
|
|
9
|
+
export declare class SQLitePersistenceProvider implements PersistenceProvider {
|
|
10
|
+
private db;
|
|
11
|
+
constructor(path?: string);
|
|
12
|
+
execSql(sql: string): void;
|
|
13
|
+
run(sql: string, params?: PersistenceParams): RunResult;
|
|
14
|
+
get<T = Record<string, unknown>>(sql: string, params?: PersistenceParams): T | undefined;
|
|
15
|
+
all<T = Record<string, unknown>>(sql: string, params?: PersistenceParams): T[];
|
|
16
|
+
transaction<T>(fn: () => T): T;
|
|
17
|
+
close(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Escape hatch: get the raw better-sqlite3 Database.
|
|
20
|
+
* Used by modules that need direct db access (ProjectRegistry, BrainIntelligence, etc.).
|
|
21
|
+
* Will be deprecated once those modules migrate to PersistenceProvider.
|
|
22
|
+
*/
|
|
23
|
+
getDatabase(): Database.Database;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=sqlite-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-provider.d.ts","sourceRoot":"","sources":["../../src/persistence/sqlite-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEpF,qBAAa,yBAA0B,YAAW,mBAAmB;IACnE,OAAO,CAAC,EAAE,CAAoB;gBAElB,IAAI,GAAE,MAAmB;IAKrC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI1B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,SAAS;IAOvD,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,CAAC,GAAG,SAAS;IAOxF,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,CAAC,EAAE;IAO9E,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAI9B,KAAK,IAAI,IAAI;IAIb;;;;OAIG;IACH,WAAW,IAAI,QAAQ,CAAC,QAAQ;CAGjC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite persistence provider backed by better-sqlite3.
|
|
3
|
+
*
|
|
4
|
+
* Supports both positional (array) and named (object) parameters.
|
|
5
|
+
* Exposes getDatabase() for backward-compat consumers that need the raw db.
|
|
6
|
+
*/
|
|
7
|
+
import Database from 'better-sqlite3';
|
|
8
|
+
import { mkdirSync } from 'node:fs';
|
|
9
|
+
import { dirname } from 'node:path';
|
|
10
|
+
export class SQLitePersistenceProvider {
|
|
11
|
+
db;
|
|
12
|
+
constructor(path = ':memory:') {
|
|
13
|
+
if (path !== ':memory:')
|
|
14
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
15
|
+
this.db = new Database(path);
|
|
16
|
+
}
|
|
17
|
+
execSql(sql) {
|
|
18
|
+
this.db.exec(sql);
|
|
19
|
+
}
|
|
20
|
+
run(sql, params) {
|
|
21
|
+
const stmt = this.db.prepare(sql);
|
|
22
|
+
if (!params)
|
|
23
|
+
return stmt.run();
|
|
24
|
+
if (Array.isArray(params))
|
|
25
|
+
return stmt.run(...params);
|
|
26
|
+
return stmt.run(params);
|
|
27
|
+
}
|
|
28
|
+
get(sql, params) {
|
|
29
|
+
const stmt = this.db.prepare(sql);
|
|
30
|
+
if (!params)
|
|
31
|
+
return stmt.get();
|
|
32
|
+
if (Array.isArray(params))
|
|
33
|
+
return stmt.get(...params);
|
|
34
|
+
return stmt.get(params);
|
|
35
|
+
}
|
|
36
|
+
all(sql, params) {
|
|
37
|
+
const stmt = this.db.prepare(sql);
|
|
38
|
+
if (!params)
|
|
39
|
+
return stmt.all();
|
|
40
|
+
if (Array.isArray(params))
|
|
41
|
+
return stmt.all(...params);
|
|
42
|
+
return stmt.all(params);
|
|
43
|
+
}
|
|
44
|
+
transaction(fn) {
|
|
45
|
+
return this.db.transaction(fn)();
|
|
46
|
+
}
|
|
47
|
+
close() {
|
|
48
|
+
this.db.close();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Escape hatch: get the raw better-sqlite3 Database.
|
|
52
|
+
* Used by modules that need direct db access (ProjectRegistry, BrainIntelligence, etc.).
|
|
53
|
+
* Will be deprecated once those modules migrate to PersistenceProvider.
|
|
54
|
+
*/
|
|
55
|
+
getDatabase() {
|
|
56
|
+
return this.db;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=sqlite-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-provider.js","sourceRoot":"","sources":["../../src/persistence/sqlite-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,OAAO,yBAAyB;IAC5B,EAAE,CAAoB;IAE9B,YAAY,OAAe,UAAU;QACnC,IAAI,IAAI,KAAK,UAAU;YAAE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvE,IAAI,CAAC,EAAE,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,CAAC,GAAW;QACjB,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,MAA0B;QACzC,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;QAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,GAAG,CAA8B,GAAW,EAAE,MAA0B;QACtE,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC,GAAG,EAAmB,CAAC;QAChD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAkB,CAAC;QACvE,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAkB,CAAC;IAC3C,CAAC;IAED,GAAG,CAA8B,GAAW,EAAE,MAA0B;QACtE,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC,GAAG,EAAS,CAAC;QACtC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAQ,CAAC;QAC7D,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAQ,CAAC;IACjC,CAAC;IAED,WAAW,CAAI,EAAW;QACxB,OAAO,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC;IACnC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract persistence layer.
|
|
3
|
+
*
|
|
4
|
+
* Decouples Vault (and future modules) from any specific database engine.
|
|
5
|
+
* The default implementation is SQLitePersistenceProvider (better-sqlite3).
|
|
6
|
+
*/
|
|
7
|
+
export type PersistenceParams = unknown[] | Record<string, unknown>;
|
|
8
|
+
export interface RunResult {
|
|
9
|
+
changes: number;
|
|
10
|
+
lastInsertRowid: number | bigint;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Minimal database provider interface.
|
|
14
|
+
*
|
|
15
|
+
* Supports both positional (`?`) and named (`@param`) parameter styles.
|
|
16
|
+
* Implementations must handle both array and object params.
|
|
17
|
+
*/
|
|
18
|
+
export interface PersistenceProvider {
|
|
19
|
+
/** Run raw SQL (DDL, multi-statement). No return value. */
|
|
20
|
+
execSql(sql: string): void;
|
|
21
|
+
/** Run a parameterized statement (INSERT, UPDATE, DELETE). */
|
|
22
|
+
run(sql: string, params?: PersistenceParams): RunResult;
|
|
23
|
+
/** Get a single row. Returns undefined if no match. */
|
|
24
|
+
get<T = Record<string, unknown>>(sql: string, params?: PersistenceParams): T | undefined;
|
|
25
|
+
/** Get all matching rows. */
|
|
26
|
+
all<T = Record<string, unknown>>(sql: string, params?: PersistenceParams): T[];
|
|
27
|
+
/** Run a function inside a transaction. Commits on success, rolls back on error. */
|
|
28
|
+
transaction<T>(fn: () => T): T;
|
|
29
|
+
/** Close the connection. */
|
|
30
|
+
close(): void;
|
|
31
|
+
}
|
|
32
|
+
export interface PersistenceConfig {
|
|
33
|
+
type: 'sqlite';
|
|
34
|
+
path: string;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/persistence/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,iBAAiB,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpE,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC;CAClC;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,2DAA2D;IAC3D,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3B,8DAA8D;IAC9D,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAExD,uDAAuD;IACvD,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,CAAC,GAAG,SAAS,CAAC;IAEzF,6BAA6B;IAC7B,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,CAAC,EAAE,CAAC;IAE/E,oFAAoF;IACpF,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAE/B,4BAA4B;IAC5B,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/persistence/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -1,23 +1,66 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Ported from Salvador MCP's plan-gap-content.ts / plan-gap-technical.ts
|
|
2
|
+
* Gap analysis engine for plan grading.
|
|
3
|
+
* Ported from Salvador MCP's plan-gap-content.ts / plan-gap-technical.ts /
|
|
4
|
+
* plan-gap-domain.ts / plan-gap-antipattern.ts.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
+
* 6 built-in passes (always run):
|
|
6
7
|
* 1. Structure — required fields present and sufficiently long
|
|
7
8
|
* 2. Completeness — measurable objectives, decision rationale, scope exclusions
|
|
8
9
|
* 3. Feasibility — overly broad scope, missing dependency awareness
|
|
9
10
|
* 4. Risk — breaking changes without mitigation, missing verification
|
|
10
11
|
* 5. Clarity — ambiguous language, vague criteria
|
|
11
12
|
* 6. Semantic Quality — generic objectives, shallow rationale, non-concrete approach
|
|
13
|
+
*
|
|
14
|
+
* Opt-in pass factories (registered via customPasses):
|
|
15
|
+
* - createToolFeasibilityPass — validates tool_chain entries and ordering
|
|
16
|
+
* - createFlowAlignmentPass — validates flow and target_mode against registries
|
|
17
|
+
* - createAntiPatternPass — detects content anti-patterns and vague criteria
|
|
12
18
|
*/
|
|
13
19
|
import type { Plan } from './planner.js';
|
|
14
|
-
import type { PlanGap } from './gap-types.js';
|
|
20
|
+
import type { PlanGap, GapSeverity } from './gap-types.js';
|
|
15
21
|
/** A custom gap analysis pass that agents can register. */
|
|
16
22
|
export type GapAnalysisPass = (plan: Plan) => PlanGap[];
|
|
17
23
|
export interface GapAnalysisOptions {
|
|
18
24
|
/** Custom gap analysis passes appended after the 6 built-in passes. */
|
|
19
25
|
customPasses?: GapAnalysisPass[];
|
|
20
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Factory: tool chain feasibility pass.
|
|
29
|
+
* Validates that tool_chain entries are known and ordering rules are respected.
|
|
30
|
+
* Ported from Salvador's analyzeToolFeasibility.
|
|
31
|
+
*
|
|
32
|
+
* @param validTools - Set of valid tool names for this agent
|
|
33
|
+
* @param orderingRules - Ordering constraints (e.g., search before create)
|
|
34
|
+
*/
|
|
35
|
+
export declare function createToolFeasibilityPass(validTools: Set<string>, orderingRules?: Array<{
|
|
36
|
+
before: string;
|
|
37
|
+
after: string;
|
|
38
|
+
reason: string;
|
|
39
|
+
}>): GapAnalysisPass;
|
|
40
|
+
/**
|
|
41
|
+
* Factory: flow and mode alignment pass.
|
|
42
|
+
* Validates flow and target_mode against known values and intent alignment.
|
|
43
|
+
* Ported from Salvador's analyzeFlowAlignment.
|
|
44
|
+
*
|
|
45
|
+
* @param validFlows - Set of valid flow names for this agent
|
|
46
|
+
* @param validModes - Set of valid operational modes for this agent
|
|
47
|
+
* @param intentFlowMap - Maps detected intents to expected flows
|
|
48
|
+
*/
|
|
49
|
+
export declare function createFlowAlignmentPass(validFlows: Set<string>, validModes: Set<string>, intentFlowMap?: Record<string, string[]>): GapAnalysisPass;
|
|
50
|
+
/**
|
|
51
|
+
* Factory: content anti-pattern pass.
|
|
52
|
+
* Detects common anti-patterns in plan content.
|
|
53
|
+
* Ported from Salvador's analyzeContentAntiPatterns.
|
|
54
|
+
*
|
|
55
|
+
* @param antiPatterns - Regex patterns to check against approach text
|
|
56
|
+
* @param mitigationPatterns - Patterns that indicate the plan is already mitigating
|
|
57
|
+
*/
|
|
58
|
+
export declare function createAntiPatternPass(antiPatterns?: Array<{
|
|
59
|
+
pattern: RegExp;
|
|
60
|
+
severity: GapSeverity;
|
|
61
|
+
description: string;
|
|
62
|
+
recommendation: string;
|
|
63
|
+
}>, mitigationPatterns?: RegExp[]): GapAnalysisPass;
|
|
21
64
|
/**
|
|
22
65
|
* Run all 6 built-in gap analysis passes on a plan, plus any custom passes.
|
|
23
66
|
* Returns a combined list of all gaps found, ordered by pass.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gap-analysis.d.ts","sourceRoot":"","sources":["../../src/planning/gap-analysis.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"gap-analysis.d.ts","sourceRoot":"","sources":["../../src/planning/gap-analysis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAgB,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAe,MAAM,gBAAgB,CAAC;AAqfxE,2DAA2D;AAC3D,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,EAAE,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;CAClC;AAOD;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,EACvB,aAAa,CAAC,EAAE,KAAK,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GACvE,eAAe,CA2CjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,EACvB,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,EACvB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GACvC,eAAe,CAoEjB;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,CAAC,EAAE,KAAK,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,WAAW,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC,EACF,kBAAkB,CAAC,EAAE,MAAM,EAAE,GAC5B,eAAe,CAwDjB;AAID;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,EAAE,CAkBlF"}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Ported from Salvador MCP's plan-gap-content.ts / plan-gap-technical.ts
|
|
2
|
+
* Gap analysis engine for plan grading.
|
|
3
|
+
* Ported from Salvador MCP's plan-gap-content.ts / plan-gap-technical.ts /
|
|
4
|
+
* plan-gap-domain.ts / plan-gap-antipattern.ts.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
+
* 6 built-in passes (always run):
|
|
6
7
|
* 1. Structure — required fields present and sufficiently long
|
|
7
8
|
* 2. Completeness — measurable objectives, decision rationale, scope exclusions
|
|
8
9
|
* 3. Feasibility — overly broad scope, missing dependency awareness
|
|
9
10
|
* 4. Risk — breaking changes without mitigation, missing verification
|
|
10
11
|
* 5. Clarity — ambiguous language, vague criteria
|
|
11
12
|
* 6. Semantic Quality — generic objectives, shallow rationale, non-concrete approach
|
|
13
|
+
*
|
|
14
|
+
* Opt-in pass factories (registered via customPasses):
|
|
15
|
+
* - createToolFeasibilityPass — validates tool_chain entries and ordering
|
|
16
|
+
* - createFlowAlignmentPass — validates flow and target_mode against registries
|
|
17
|
+
* - createAntiPatternPass — detects content anti-patterns and vague criteria
|
|
12
18
|
*/
|
|
13
19
|
import { generateGapId, MIN_OBJECTIVE_LENGTH, MIN_SCOPE_LENGTH, MIN_DECISION_LENGTH, } from './gap-types.js';
|
|
14
20
|
// ─── Helpers ─────────────────────────────────────────────────────
|
|
@@ -27,6 +33,14 @@ function gap(severity, category, description, recommendation, location, trigger)
|
|
|
27
33
|
function taskText(plan) {
|
|
28
34
|
return plan.tasks.map((t) => `${t.title} ${t.description}`).join(' ');
|
|
29
35
|
}
|
|
36
|
+
/** Extract text from a decision (supports both string and structured format). */
|
|
37
|
+
function decisionText(d) {
|
|
38
|
+
return typeof d === 'string' ? d : `${d.decision} ${d.rationale}`;
|
|
39
|
+
}
|
|
40
|
+
/** Combine all decisions into a single text blob. */
|
|
41
|
+
function decisionsText(plan) {
|
|
42
|
+
return plan.decisions.map(decisionText).join(' ');
|
|
43
|
+
}
|
|
30
44
|
/** Check if text contains any of the given patterns (case-insensitive). */
|
|
31
45
|
function containsAny(text, patterns) {
|
|
32
46
|
const lower = text.toLowerCase();
|
|
@@ -63,7 +77,16 @@ const METRIC_PATTERNS = [
|
|
|
63
77
|
/metric/i,
|
|
64
78
|
/benchmark/i,
|
|
65
79
|
];
|
|
66
|
-
const EXCLUSION_KEYWORDS = [
|
|
80
|
+
const EXCLUSION_KEYWORDS = [
|
|
81
|
+
'not',
|
|
82
|
+
'exclude',
|
|
83
|
+
'outside',
|
|
84
|
+
'beyond',
|
|
85
|
+
'limit',
|
|
86
|
+
'except',
|
|
87
|
+
"won't",
|
|
88
|
+
'will not',
|
|
89
|
+
];
|
|
67
90
|
function analyzeCompleteness(plan) {
|
|
68
91
|
const gaps = [];
|
|
69
92
|
// Objective lacks measurable indicators
|
|
@@ -74,8 +97,9 @@ function analyzeCompleteness(plan) {
|
|
|
74
97
|
if (plan.decisions.length > 0) {
|
|
75
98
|
for (let i = 0; i < plan.decisions.length; i++) {
|
|
76
99
|
const d = plan.decisions[i];
|
|
77
|
-
|
|
78
|
-
|
|
100
|
+
const text = decisionText(d);
|
|
101
|
+
if (text.trim().length < MIN_DECISION_LENGTH) {
|
|
102
|
+
gaps.push(gap('major', 'completeness', `Decision ${i + 1} is too short (${text.trim().length} chars) — lacks rationale.`, 'Expand each decision to include the reasoning (why this choice over alternatives).', `decisions[${i}]`, 'short_decision'));
|
|
79
103
|
}
|
|
80
104
|
}
|
|
81
105
|
}
|
|
@@ -95,7 +119,14 @@ const OVERLY_BROAD_PATTERNS = [
|
|
|
95
119
|
'total overhaul',
|
|
96
120
|
'rewrite everything',
|
|
97
121
|
];
|
|
98
|
-
const DEPENDENCY_KEYWORDS = [
|
|
122
|
+
const DEPENDENCY_KEYWORDS = [
|
|
123
|
+
'depends',
|
|
124
|
+
'dependency',
|
|
125
|
+
'prerequisite',
|
|
126
|
+
'requires',
|
|
127
|
+
'blocked',
|
|
128
|
+
'before',
|
|
129
|
+
];
|
|
99
130
|
function analyzeFeasibility(plan) {
|
|
100
131
|
const gaps = [];
|
|
101
132
|
const scopeAndTasks = `${plan.scope} ${taskText(plan)}`;
|
|
@@ -135,12 +166,22 @@ const MITIGATION_KEYWORDS = [
|
|
|
135
166
|
'canary',
|
|
136
167
|
'blue-green',
|
|
137
168
|
];
|
|
138
|
-
const VERIFICATION_KEYWORDS = [
|
|
169
|
+
const VERIFICATION_KEYWORDS = [
|
|
170
|
+
'test',
|
|
171
|
+
'verify',
|
|
172
|
+
'validate',
|
|
173
|
+
'check',
|
|
174
|
+
'assert',
|
|
175
|
+
'confirm',
|
|
176
|
+
'spec',
|
|
177
|
+
'coverage',
|
|
178
|
+
];
|
|
139
179
|
function analyzeRisk(plan) {
|
|
140
180
|
const gaps = [];
|
|
141
|
-
const allText = `${plan.objective} ${plan.scope} ${taskText(plan)} ${plan
|
|
181
|
+
const allText = `${plan.objective} ${plan.scope} ${taskText(plan)} ${decisionsText(plan)}`;
|
|
142
182
|
// Breaking changes without mitigation
|
|
143
|
-
if (containsAny(allText, BREAKING_CHANGE_KEYWORDS) &&
|
|
183
|
+
if (containsAny(allText, BREAKING_CHANGE_KEYWORDS) &&
|
|
184
|
+
!containsAny(allText, MITIGATION_KEYWORDS)) {
|
|
144
185
|
gaps.push(gap('major', 'risk', 'Plan involves breaking changes but mentions no mitigation strategy.', 'Add a rollback plan, feature flags, or phased migration approach.', undefined, 'breaking_without_mitigation'));
|
|
145
186
|
}
|
|
146
187
|
// No verification/testing mentioned
|
|
@@ -169,7 +210,7 @@ const AMBIGUOUS_WORDS = [
|
|
|
169
210
|
];
|
|
170
211
|
function analyzeClarity(plan) {
|
|
171
212
|
const gaps = [];
|
|
172
|
-
const allText = `${plan.objective} ${plan.scope} ${plan
|
|
213
|
+
const allText = `${plan.objective} ${plan.scope} ${decisionsText(plan)}`;
|
|
173
214
|
const lower = allText.toLowerCase();
|
|
174
215
|
// Ambiguous language
|
|
175
216
|
const found = AMBIGUOUS_WORDS.filter((w) => {
|
|
@@ -192,7 +233,15 @@ const GENERIC_OBJECTIVE_PATTERNS = [
|
|
|
192
233
|
/^fix\s+\w+$/i,
|
|
193
234
|
/^update\s+\w+$/i,
|
|
194
235
|
];
|
|
195
|
-
const RATIONALE_INDICATORS = [
|
|
236
|
+
const RATIONALE_INDICATORS = [
|
|
237
|
+
'because',
|
|
238
|
+
'since',
|
|
239
|
+
'due to',
|
|
240
|
+
'in order to',
|
|
241
|
+
'so that',
|
|
242
|
+
'given that',
|
|
243
|
+
'as a result',
|
|
244
|
+
];
|
|
196
245
|
const SHALLOW_INDICATORS = ['better', 'good', 'best', 'nice', 'great', 'improved'];
|
|
197
246
|
function analyzeSemanticQuality(plan) {
|
|
198
247
|
const gaps = [];
|
|
@@ -213,7 +262,7 @@ function analyzeSemanticQuality(plan) {
|
|
|
213
262
|
}
|
|
214
263
|
// Decisions with shallow rationale (uses "better/good" without "because/since")
|
|
215
264
|
for (let i = 0; i < plan.decisions.length; i++) {
|
|
216
|
-
const d = plan.decisions[i];
|
|
265
|
+
const d = decisionText(plan.decisions[i]);
|
|
217
266
|
const hasShallow = containsAny(d, SHALLOW_INDICATORS);
|
|
218
267
|
const hasRationale = containsAny(d, RATIONALE_INDICATORS);
|
|
219
268
|
if (hasShallow && !hasRationale) {
|
|
@@ -237,6 +286,134 @@ function analyzeSemanticQuality(plan) {
|
|
|
237
286
|
}
|
|
238
287
|
return gaps;
|
|
239
288
|
}
|
|
289
|
+
// ─── Opt-In Pass Factories ──────────────────────────────────────
|
|
290
|
+
// Ported from Salvador's plan-gap-technical.ts, plan-gap-domain.ts,
|
|
291
|
+
// and plan-gap-antipattern.ts. These are parameterized factories that
|
|
292
|
+
// agents register via customPasses.
|
|
293
|
+
/**
|
|
294
|
+
* Factory: tool chain feasibility pass.
|
|
295
|
+
* Validates that tool_chain entries are known and ordering rules are respected.
|
|
296
|
+
* Ported from Salvador's analyzeToolFeasibility.
|
|
297
|
+
*
|
|
298
|
+
* @param validTools - Set of valid tool names for this agent
|
|
299
|
+
* @param orderingRules - Ordering constraints (e.g., search before create)
|
|
300
|
+
*/
|
|
301
|
+
export function createToolFeasibilityPass(validTools, orderingRules) {
|
|
302
|
+
return (plan) => {
|
|
303
|
+
const gaps = [];
|
|
304
|
+
const toolChain = plan.tool_chain;
|
|
305
|
+
if (!toolChain || toolChain.length === 0)
|
|
306
|
+
return gaps;
|
|
307
|
+
// Validate tool names
|
|
308
|
+
const invalidTools = toolChain.filter((t) => !validTools.has(t));
|
|
309
|
+
if (invalidTools.length > 0) {
|
|
310
|
+
gaps.push(gap('critical', 'tool-feasibility', `Invalid tool names in tool_chain: ${invalidTools.join(', ')}`, 'Use valid tool names. Check available tools for this agent.', 'tool_chain', `invalid_tools:${invalidTools.join(',')}`));
|
|
311
|
+
}
|
|
312
|
+
// Validate ordering rules
|
|
313
|
+
if (orderingRules) {
|
|
314
|
+
for (const rule of orderingRules) {
|
|
315
|
+
const beforeIndex = toolChain.indexOf(rule.before);
|
|
316
|
+
const afterIndex = toolChain.indexOf(rule.after);
|
|
317
|
+
if (beforeIndex !== -1 && afterIndex !== -1 && beforeIndex > afterIndex) {
|
|
318
|
+
gaps.push(gap('major', 'tool-feasibility', `Tool ordering violation: ${rule.before} must come before ${rule.after}`, rule.reason, 'tool_chain', `ordering:${rule.before}>${rule.after}`));
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return gaps;
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Factory: flow and mode alignment pass.
|
|
327
|
+
* Validates flow and target_mode against known values and intent alignment.
|
|
328
|
+
* Ported from Salvador's analyzeFlowAlignment.
|
|
329
|
+
*
|
|
330
|
+
* @param validFlows - Set of valid flow names for this agent
|
|
331
|
+
* @param validModes - Set of valid operational modes for this agent
|
|
332
|
+
* @param intentFlowMap - Maps detected intents to expected flows
|
|
333
|
+
*/
|
|
334
|
+
export function createFlowAlignmentPass(validFlows, validModes, intentFlowMap) {
|
|
335
|
+
return (plan) => {
|
|
336
|
+
const gaps = [];
|
|
337
|
+
if (plan.flow && !validFlows.has(plan.flow)) {
|
|
338
|
+
gaps.push(gap('major', 'flow-alignment', `Invalid flow: ${plan.flow}`, `Valid flows are: ${Array.from(validFlows).join(', ')}`, 'flow', `invalid_flow:${plan.flow}`));
|
|
339
|
+
}
|
|
340
|
+
if (plan.target_mode && !validModes.has(plan.target_mode)) {
|
|
341
|
+
gaps.push(gap('major', 'flow-alignment', `Invalid target_mode: ${plan.target_mode}`, `Valid modes are: ${Array.from(validModes).join(', ')}`, 'target_mode', `invalid_mode:${plan.target_mode}`));
|
|
342
|
+
}
|
|
343
|
+
// Intent-flow alignment (optional)
|
|
344
|
+
if (intentFlowMap && plan.flow) {
|
|
345
|
+
const objectiveLower = (plan.objective || '').toLowerCase();
|
|
346
|
+
let detectedIntent = null;
|
|
347
|
+
if (/\b(create|build|implement|add|new)\b/.test(objectiveLower)) {
|
|
348
|
+
detectedIntent = 'CREATE';
|
|
349
|
+
}
|
|
350
|
+
else if (/\b(fix|debug|repair|resolve|bug)\b/.test(objectiveLower)) {
|
|
351
|
+
detectedIntent = 'FIX';
|
|
352
|
+
}
|
|
353
|
+
else if (/\b(review|audit|check|validate|inspect)\b/.test(objectiveLower)) {
|
|
354
|
+
detectedIntent = 'REVIEW';
|
|
355
|
+
}
|
|
356
|
+
else if (/\b(plan|design|architect|structure)\b/.test(objectiveLower)) {
|
|
357
|
+
detectedIntent = 'PLAN';
|
|
358
|
+
}
|
|
359
|
+
else if (/\b(enhance|improve|refactor|optimize)\b/.test(objectiveLower)) {
|
|
360
|
+
detectedIntent = 'ENHANCE';
|
|
361
|
+
}
|
|
362
|
+
else if (/\b(deliver|package|publish|deploy|release)\b/.test(objectiveLower)) {
|
|
363
|
+
detectedIntent = 'DELIVER';
|
|
364
|
+
}
|
|
365
|
+
if (detectedIntent) {
|
|
366
|
+
const expectedFlows = intentFlowMap[detectedIntent] || [];
|
|
367
|
+
if (expectedFlows.length > 0 && !expectedFlows.includes(plan.flow)) {
|
|
368
|
+
gaps.push(gap('minor', 'flow-alignment', `Flow '${plan.flow}' may not align with detected intent '${detectedIntent}'`, `Consider using flow: ${expectedFlows.join(' or ')}`, 'flow', `intent_flow_mismatch:${detectedIntent}->${plan.flow}`));
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return gaps;
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Factory: content anti-pattern pass.
|
|
377
|
+
* Detects common anti-patterns in plan content.
|
|
378
|
+
* Ported from Salvador's analyzeContentAntiPatterns.
|
|
379
|
+
*
|
|
380
|
+
* @param antiPatterns - Regex patterns to check against approach text
|
|
381
|
+
* @param mitigationPatterns - Patterns that indicate the plan is already mitigating
|
|
382
|
+
*/
|
|
383
|
+
export function createAntiPatternPass(antiPatterns, mitigationPatterns) {
|
|
384
|
+
const VAGUE_CRITERIA_PATTERNS = [
|
|
385
|
+
/^it (looks?|works?|is) (good|nice|fine|great|ok|correct)/i,
|
|
386
|
+
/^(looks?|works?) (good|nice|fine|great|ok)/i,
|
|
387
|
+
/^it('s| is) (done|complete|finished)/i,
|
|
388
|
+
/\bmy machine\b/i,
|
|
389
|
+
];
|
|
390
|
+
return (plan) => {
|
|
391
|
+
const gaps = [];
|
|
392
|
+
const approach = (plan.approach || '').toLowerCase();
|
|
393
|
+
const criteria = plan.success_criteria || [];
|
|
394
|
+
const fullText = [approach, ...criteria].join(' ').toLowerCase();
|
|
395
|
+
// Check if plan is actively mitigating known anti-patterns
|
|
396
|
+
const isMitigating = mitigationPatterns
|
|
397
|
+
? mitigationPatterns.some((p) => p.test(fullText))
|
|
398
|
+
: false;
|
|
399
|
+
// Custom anti-pattern checks
|
|
400
|
+
if (!isMitigating && antiPatterns) {
|
|
401
|
+
for (const ap of antiPatterns) {
|
|
402
|
+
if (ap.pattern.test(approach)) {
|
|
403
|
+
gaps.push(gap(ap.severity, 'anti-pattern', ap.description, ap.recommendation, 'approach', `anti_pattern:${ap.description}`));
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
// Vague success criteria (generic — always checked)
|
|
408
|
+
for (const criterion of criteria) {
|
|
409
|
+
const isVague = VAGUE_CRITERIA_PATTERNS.some((p) => p.test(criterion));
|
|
410
|
+
if (isVague) {
|
|
411
|
+
gaps.push(gap('minor', 'anti-pattern', `Success criterion is not measurable: "${criterion}"`, 'Rewrite as a verifiable assertion: "Component renders X", "All Y pass Z", "No A in B".', 'success_criteria', `vague_criterion:${criterion}`));
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return gaps;
|
|
415
|
+
};
|
|
416
|
+
}
|
|
240
417
|
// ─── Orchestrator ────────────────────────────────────────────────
|
|
241
418
|
/**
|
|
242
419
|
* Run all 6 built-in gap analysis passes on a plan, plus any custom passes.
|