@soleri/core 2.1.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 +10 -1
- package/dist/brain/brain.d.ts.map +1 -1
- package/dist/brain/brain.js +116 -13
- package/dist/brain/brain.js.map +1 -1
- package/dist/brain/intelligence.d.ts +36 -1
- package/dist/brain/intelligence.d.ts.map +1 -1
- package/dist/brain/intelligence.js +119 -14
- package/dist/brain/intelligence.js.map +1 -1
- package/dist/brain/types.d.ts +34 -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/control/identity-manager.d.ts +22 -0
- package/dist/control/identity-manager.d.ts.map +1 -0
- package/dist/control/identity-manager.js +233 -0
- package/dist/control/identity-manager.js.map +1 -0
- package/dist/control/intent-router.d.ts +32 -0
- package/dist/control/intent-router.d.ts.map +1 -0
- package/dist/control/intent-router.js +242 -0
- package/dist/control/intent-router.js.map +1 -0
- package/dist/control/types.d.ts +68 -0
- package/dist/control/types.d.ts.map +1 -0
- package/dist/control/types.js +9 -0
- package/dist/control/types.js.map +1 -0
- package/dist/curator/curator.d.ts +37 -1
- package/dist/curator/curator.d.ts.map +1 -1
- package/dist/curator/curator.js +199 -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/facades/types.d.ts +1 -1
- package/dist/governance/governance.d.ts +42 -0
- package/dist/governance/governance.d.ts.map +1 -0
- package/dist/governance/governance.js +488 -0
- package/dist/governance/governance.js.map +1 -0
- package/dist/governance/index.d.ts +3 -0
- package/dist/governance/index.d.ts.map +1 -0
- package/dist/governance/index.js +2 -0
- package/dist/governance/index.js.map +1 -0
- package/dist/governance/types.d.ts +102 -0
- package/dist/governance/types.d.ts.map +1 -0
- package/dist/governance/types.js +3 -0
- package/dist/governance/types.js.map +1 -0
- package/dist/index.d.ts +52 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -1
- 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/logging/logger.d.ts +37 -0
- package/dist/logging/logger.d.ts.map +1 -0
- package/dist/logging/logger.js +145 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/logging/types.d.ts +19 -0
- package/dist/logging/types.d.ts.map +1 -0
- package/dist/logging/types.js +2 -0
- package/dist/logging/types.js.map +1 -0
- package/dist/loop/loop-manager.d.ts +100 -0
- package/dist/loop/loop-manager.d.ts.map +1 -0
- package/dist/loop/loop-manager.js +379 -0
- package/dist/loop/loop-manager.js.map +1 -0
- package/dist/loop/types.d.ts +103 -0
- package/dist/loop/types.d.ts.map +1 -0
- package/dist/loop/types.js +11 -0
- package/dist/loop/types.js.map +1 -0
- 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 +72 -0
- package/dist/planning/gap-analysis.d.ts.map +1 -0
- package/dist/planning/gap-analysis.js +442 -0
- package/dist/planning/gap-analysis.js.map +1 -0
- package/dist/planning/gap-types.d.ts +29 -0
- package/dist/planning/gap-types.d.ts.map +1 -0
- package/dist/planning/gap-types.js +28 -0
- package/dist/planning/gap-types.js.map +1 -0
- package/dist/planning/planner.d.ts +421 -4
- package/dist/planning/planner.d.ts.map +1 -1
- package/dist/planning/planner.js +949 -21
- 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 +79 -0
- package/dist/project/project-registry.d.ts.map +1 -0
- package/dist/project/project-registry.js +274 -0
- package/dist/project/project-registry.js.map +1 -0
- package/dist/project/types.d.ts +28 -0
- package/dist/project/types.d.ts.map +1 -0
- package/dist/project/types.js +5 -0
- package/dist/project/types.js.map +1 -0
- 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 +15 -0
- package/dist/runtime/admin-extra-ops.d.ts.map +1 -0
- package/dist/runtime/admin-extra-ops.js +595 -0
- package/dist/runtime/admin-extra-ops.js.map +1 -0
- package/dist/runtime/admin-ops.d.ts +15 -0
- package/dist/runtime/admin-ops.d.ts.map +1 -0
- package/dist/runtime/admin-ops.js +329 -0
- package/dist/runtime/admin-ops.js.map +1 -0
- package/dist/runtime/capture-ops.d.ts +15 -0
- package/dist/runtime/capture-ops.d.ts.map +1 -0
- package/dist/runtime/capture-ops.js +363 -0
- package/dist/runtime/capture-ops.js.map +1 -0
- 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 +9 -3
- package/dist/runtime/core-ops.d.ts.map +1 -1
- package/dist/runtime/core-ops.js +693 -10
- package/dist/runtime/core-ops.js.map +1 -1
- package/dist/runtime/curator-extra-ops.d.ts +9 -0
- package/dist/runtime/curator-extra-ops.d.ts.map +1 -0
- package/dist/runtime/curator-extra-ops.js +71 -0
- package/dist/runtime/curator-extra-ops.js.map +1 -0
- package/dist/runtime/domain-ops.d.ts.map +1 -1
- package/dist/runtime/domain-ops.js +61 -15
- package/dist/runtime/domain-ops.js.map +1 -1
- package/dist/runtime/grading-ops.d.ts +14 -0
- package/dist/runtime/grading-ops.d.ts.map +1 -0
- package/dist/runtime/grading-ops.js +105 -0
- package/dist/runtime/grading-ops.js.map +1 -0
- 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 +14 -0
- package/dist/runtime/loop-ops.d.ts.map +1 -0
- package/dist/runtime/loop-ops.js +251 -0
- package/dist/runtime/loop-ops.js.map +1 -0
- package/dist/runtime/memory-cross-project-ops.d.ts +12 -0
- package/dist/runtime/memory-cross-project-ops.d.ts.map +1 -0
- package/dist/runtime/memory-cross-project-ops.js +165 -0
- package/dist/runtime/memory-cross-project-ops.js.map +1 -0
- package/dist/runtime/memory-extra-ops.d.ts +13 -0
- package/dist/runtime/memory-extra-ops.d.ts.map +1 -0
- package/dist/runtime/memory-extra-ops.js +173 -0
- package/dist/runtime/memory-extra-ops.js.map +1 -0
- package/dist/runtime/orchestrate-ops.d.ts +17 -0
- package/dist/runtime/orchestrate-ops.d.ts.map +1 -0
- package/dist/runtime/orchestrate-ops.js +246 -0
- package/dist/runtime/orchestrate-ops.js.map +1 -0
- package/dist/runtime/planning-extra-ops.d.ts +25 -0
- package/dist/runtime/planning-extra-ops.d.ts.map +1 -0
- package/dist/runtime/planning-extra-ops.js +663 -0
- package/dist/runtime/planning-extra-ops.js.map +1 -0
- 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 +15 -0
- package/dist/runtime/project-ops.d.ts.map +1 -0
- package/dist/runtime/project-ops.js +186 -0
- package/dist/runtime/project-ops.js.map +1 -0
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +65 -3
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/types.d.ts +29 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/vault-extra-ops.d.ts +10 -0
- package/dist/runtime/vault-extra-ops.d.ts.map +1 -0
- package/dist/runtime/vault-extra-ops.js +536 -0
- package/dist/runtime/vault-extra-ops.js.map +1 -0
- package/dist/telemetry/telemetry.d.ts +48 -0
- package/dist/telemetry/telemetry.d.ts.map +1 -0
- package/dist/telemetry/telemetry.js +87 -0
- package/dist/telemetry/telemetry.js.map +1 -0
- 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 +97 -4
- package/dist/vault/vault.d.ts.map +1 -1
- package/dist/vault/vault.js +424 -65
- package/dist/vault/vault.js.map +1 -1
- package/package.json +7 -3
- package/src/__tests__/admin-extra-ops.test.ts +467 -0
- package/src/__tests__/admin-ops.test.ts +271 -0
- package/src/__tests__/brain-intelligence.test.ts +205 -0
- package/src/__tests__/brain.test.ts +134 -3
- package/src/__tests__/capture-ops.test.ts +509 -0
- 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 +292 -2
- package/src/__tests__/curator-extra-ops.test.ts +381 -0
- package/src/__tests__/domain-ops.test.ts +66 -0
- package/src/__tests__/errors.test.ts +388 -0
- package/src/__tests__/governance.test.ts +522 -0
- package/src/__tests__/grading-ops.test.ts +361 -0
- package/src/__tests__/identity-manager.test.ts +243 -0
- package/src/__tests__/intake-pipeline.test.ts +162 -0
- package/src/__tests__/intent-router.test.ts +222 -0
- package/src/__tests__/logger.test.ts +200 -0
- package/src/__tests__/loop-ops.test.ts +469 -0
- package/src/__tests__/memory-cross-project-ops.test.ts +248 -0
- package/src/__tests__/memory-extra-ops.test.ts +352 -0
- package/src/__tests__/orchestrate-ops.test.ts +289 -0
- package/src/__tests__/persistence.test.ts +225 -0
- package/src/__tests__/planner.test.ts +416 -7
- package/src/__tests__/planning-extra-ops.test.ts +706 -0
- 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 +381 -0
- package/src/__tests__/template-manager.test.ts +222 -0
- package/src/__tests__/vault-extra-ops.test.ts +482 -0
- package/src/brain/brain.ts +185 -16
- package/src/brain/intelligence.ts +179 -10
- package/src/brain/types.ts +40 -2
- package/src/cognee/client.ts +18 -0
- package/src/cognee/sync-manager.ts +389 -0
- package/src/control/identity-manager.ts +354 -0
- package/src/control/intent-router.ts +326 -0
- package/src/control/types.ts +102 -0
- package/src/curator/curator.ts +295 -1
- 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/governance/governance.ts +698 -0
- package/src/governance/index.ts +18 -0
- package/src/governance/types.ts +111 -0
- package/src/index.ts +213 -2
- 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/logging/logger.ts +154 -0
- package/src/logging/types.ts +21 -0
- package/src/loop/loop-manager.ts +448 -0
- package/src/loop/types.ts +115 -0
- 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 +775 -0
- package/src/planning/gap-types.ts +61 -0
- package/src/planning/planner.ts +1273 -24
- 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 +370 -0
- package/src/project/types.ts +31 -0
- 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 +652 -0
- package/src/runtime/admin-ops.ts +340 -0
- package/src/runtime/capture-ops.ts +404 -0
- package/src/runtime/cognee-sync-ops.ts +63 -0
- package/src/runtime/core-ops.ts +787 -9
- package/src/runtime/curator-extra-ops.ts +85 -0
- package/src/runtime/domain-ops.ts +67 -15
- package/src/runtime/grading-ops.ts +130 -0
- package/src/runtime/intake-ops.ts +126 -0
- package/src/runtime/loop-ops.ts +277 -0
- package/src/runtime/memory-cross-project-ops.ts +191 -0
- package/src/runtime/memory-extra-ops.ts +186 -0
- package/src/runtime/orchestrate-ops.ts +278 -0
- package/src/runtime/planning-extra-ops.ts +718 -0
- package/src/runtime/playbook-ops.ts +169 -0
- package/src/runtime/project-ops.ts +202 -0
- package/src/runtime/runtime.ts +77 -3
- package/src/runtime/types.ts +29 -0
- package/src/runtime/vault-extra-ops.ts +606 -0
- package/src/telemetry/telemetry.ts +118 -0
- package/src/vault/playbook.ts +87 -0
- package/src/vault/vault.ts +575 -98
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
scorePlaybook,
|
|
4
|
+
matchPlaybooks,
|
|
5
|
+
mergePlaybooks,
|
|
6
|
+
getBuiltinPlaybook,
|
|
7
|
+
getAllBuiltinPlaybooks,
|
|
8
|
+
} from '../playbooks/playbook-registry.js';
|
|
9
|
+
import type { PlaybookDefinition } from '../playbooks/playbook-types.js';
|
|
10
|
+
|
|
11
|
+
describe('scorePlaybook', () => {
|
|
12
|
+
it('should add 10 for intent match', () => {
|
|
13
|
+
const pb = getBuiltinPlaybook('generic-tdd')!;
|
|
14
|
+
expect(scorePlaybook(pb, 'BUILD', '')).toBe(10);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should add 5 per keyword match', () => {
|
|
18
|
+
const pb = getBuiltinPlaybook('generic-tdd')!;
|
|
19
|
+
// 'implement' and 'build' are keywords
|
|
20
|
+
expect(scorePlaybook(pb, undefined, 'implement and build')).toBe(10);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should combine intent + keyword scores', () => {
|
|
24
|
+
const pb = getBuiltinPlaybook('generic-tdd')!;
|
|
25
|
+
// BUILD intent (10) + 'implement' (5) + 'feature' (5) = 20
|
|
26
|
+
expect(scorePlaybook(pb, 'BUILD', 'implement a feature')).toBe(20);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should return 0 for unrelated content', () => {
|
|
30
|
+
const pb = getBuiltinPlaybook('generic-tdd')!;
|
|
31
|
+
expect(scorePlaybook(pb, 'REVIEW', 'nothing related here')).toBe(0);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should be case-insensitive for keywords', () => {
|
|
35
|
+
const pb = getBuiltinPlaybook('generic-systematic-debugging')!;
|
|
36
|
+
expect(scorePlaybook(pb, undefined, 'FIX THE BUG')).toBeGreaterThan(0);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('matchPlaybooks', () => {
|
|
41
|
+
it('should match TDD for BUILD intent with "implement"', () => {
|
|
42
|
+
const result = matchPlaybooks('BUILD', 'implement the new feature');
|
|
43
|
+
expect(result.playbook).not.toBeNull();
|
|
44
|
+
expect(result.genericMatch?.id).toBe('generic-tdd');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('should match systematic-debugging for FIX intent', () => {
|
|
48
|
+
const result = matchPlaybooks('FIX', 'fix the broken authentication bug');
|
|
49
|
+
expect(result.playbook).not.toBeNull();
|
|
50
|
+
expect(result.genericMatch?.id).toBe('generic-systematic-debugging');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should match brainstorming for PLAN intent', () => {
|
|
54
|
+
const result = matchPlaybooks('PLAN', 'design a new architecture from scratch');
|
|
55
|
+
expect(result.playbook).not.toBeNull();
|
|
56
|
+
expect(result.genericMatch?.id).toBe('generic-brainstorming');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should match code-review for REVIEW intent', () => {
|
|
60
|
+
const result = matchPlaybooks('REVIEW', 'review this pull request');
|
|
61
|
+
expect(result.playbook).not.toBeNull();
|
|
62
|
+
expect(result.genericMatch?.id).toBe('generic-code-review');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should return null playbook for unrelated text with no intent', () => {
|
|
66
|
+
const result = matchPlaybooks(undefined, 'random unrelated text xyz');
|
|
67
|
+
expect(result.playbook).toBeNull();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should prefer vault playbooks over builtins', () => {
|
|
71
|
+
const vaultPlaybook: PlaybookDefinition = {
|
|
72
|
+
id: 'custom-tdd',
|
|
73
|
+
tier: 'generic',
|
|
74
|
+
title: 'Custom TDD',
|
|
75
|
+
trigger: 'Custom TDD trigger',
|
|
76
|
+
description: 'Custom TDD description',
|
|
77
|
+
steps: 'Custom steps',
|
|
78
|
+
expectedOutcome: 'Custom outcome',
|
|
79
|
+
category: 'methodology',
|
|
80
|
+
tags: ['tdd'],
|
|
81
|
+
matchIntents: ['BUILD', 'FIX'],
|
|
82
|
+
matchKeywords: [
|
|
83
|
+
'implement',
|
|
84
|
+
'build',
|
|
85
|
+
'create',
|
|
86
|
+
'add',
|
|
87
|
+
'fix',
|
|
88
|
+
'refactor',
|
|
89
|
+
'feature',
|
|
90
|
+
'code',
|
|
91
|
+
'custom-unique-keyword',
|
|
92
|
+
],
|
|
93
|
+
gates: [],
|
|
94
|
+
taskTemplates: [],
|
|
95
|
+
toolInjections: [],
|
|
96
|
+
verificationCriteria: [],
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// The vault playbook should score higher because it has more keyword matches
|
|
100
|
+
const result = matchPlaybooks(
|
|
101
|
+
'BUILD',
|
|
102
|
+
'implement and build and create with custom-unique-keyword',
|
|
103
|
+
[vaultPlaybook],
|
|
104
|
+
);
|
|
105
|
+
expect(result.genericMatch?.id).toBe('custom-tdd');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('should resolve domain extends to correct generic', () => {
|
|
109
|
+
const domainPlaybook: PlaybookDefinition = {
|
|
110
|
+
id: 'domain-component-build',
|
|
111
|
+
tier: 'domain',
|
|
112
|
+
title: 'Component Build',
|
|
113
|
+
trigger: 'Build a component',
|
|
114
|
+
description: 'Build with design tokens',
|
|
115
|
+
steps: 'Domain steps',
|
|
116
|
+
expectedOutcome: 'Component built with tokens',
|
|
117
|
+
extends: 'generic-tdd',
|
|
118
|
+
category: 'design-system',
|
|
119
|
+
tags: ['component', 'build'],
|
|
120
|
+
matchIntents: ['BUILD'],
|
|
121
|
+
matchKeywords: ['component', 'build'],
|
|
122
|
+
gates: [{ phase: 'completion', requirement: 'Tokens validated', checkType: 'token-check' }],
|
|
123
|
+
taskTemplates: [],
|
|
124
|
+
toolInjections: ['validate_tokens'],
|
|
125
|
+
verificationCriteria: ['All tokens are semantic'],
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const result = matchPlaybooks('BUILD', 'build a component', [domainPlaybook]);
|
|
129
|
+
expect(result.domainMatch?.id).toBe('domain-component-build');
|
|
130
|
+
// Should resolve the extended generic
|
|
131
|
+
expect(result.genericMatch?.id).toBe('generic-tdd');
|
|
132
|
+
expect(result.playbook?.label).toContain('extends');
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe('mergePlaybooks', () => {
|
|
137
|
+
it('should concatenate gates (generic first, then domain)', () => {
|
|
138
|
+
const generic = getBuiltinPlaybook('generic-tdd')!;
|
|
139
|
+
const domain: PlaybookDefinition = {
|
|
140
|
+
id: 'domain-test',
|
|
141
|
+
tier: 'domain',
|
|
142
|
+
title: 'Domain Test',
|
|
143
|
+
trigger: '',
|
|
144
|
+
description: '',
|
|
145
|
+
steps: '',
|
|
146
|
+
expectedOutcome: '',
|
|
147
|
+
category: 'test',
|
|
148
|
+
tags: [],
|
|
149
|
+
matchIntents: [],
|
|
150
|
+
matchKeywords: [],
|
|
151
|
+
gates: [{ phase: 'completion', requirement: 'Domain gate', checkType: 'domain-gate' }],
|
|
152
|
+
taskTemplates: [],
|
|
153
|
+
toolInjections: [],
|
|
154
|
+
verificationCriteria: [],
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const merged = mergePlaybooks(generic, domain);
|
|
158
|
+
expect(merged.mergedGates.length).toBe(generic.gates.length + 1);
|
|
159
|
+
expect(merged.mergedGates[0]).toEqual(generic.gates[0]);
|
|
160
|
+
expect(merged.mergedGates[merged.mergedGates.length - 1].checkType).toBe('domain-gate');
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('should override tasks at same order+taskType', () => {
|
|
164
|
+
const generic: PlaybookDefinition = {
|
|
165
|
+
id: 'g',
|
|
166
|
+
tier: 'generic',
|
|
167
|
+
title: 'G',
|
|
168
|
+
trigger: '',
|
|
169
|
+
description: '',
|
|
170
|
+
steps: '',
|
|
171
|
+
expectedOutcome: '',
|
|
172
|
+
category: 'test',
|
|
173
|
+
tags: [],
|
|
174
|
+
matchIntents: [],
|
|
175
|
+
matchKeywords: [],
|
|
176
|
+
gates: [],
|
|
177
|
+
taskTemplates: [
|
|
178
|
+
{
|
|
179
|
+
taskType: 'test',
|
|
180
|
+
titleTemplate: 'Generic test',
|
|
181
|
+
acceptanceCriteria: ['generic'],
|
|
182
|
+
tools: [],
|
|
183
|
+
order: 'before-implementation',
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
toolInjections: [],
|
|
187
|
+
verificationCriteria: [],
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const domain: PlaybookDefinition = {
|
|
191
|
+
...generic,
|
|
192
|
+
id: 'd',
|
|
193
|
+
tier: 'domain',
|
|
194
|
+
title: 'D',
|
|
195
|
+
taskTemplates: [
|
|
196
|
+
{
|
|
197
|
+
taskType: 'test',
|
|
198
|
+
titleTemplate: 'Domain test',
|
|
199
|
+
acceptanceCriteria: ['domain'],
|
|
200
|
+
tools: ['custom_tool'],
|
|
201
|
+
order: 'before-implementation',
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const merged = mergePlaybooks(generic, domain);
|
|
207
|
+
// Domain should override the same order+taskType
|
|
208
|
+
expect(merged.mergedTasks).toHaveLength(1);
|
|
209
|
+
expect(merged.mergedTasks[0].titleTemplate).toBe('Domain test');
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('should deduplicate tools', () => {
|
|
213
|
+
const generic: PlaybookDefinition = {
|
|
214
|
+
id: 'g',
|
|
215
|
+
tier: 'generic',
|
|
216
|
+
title: 'G',
|
|
217
|
+
trigger: '',
|
|
218
|
+
description: '',
|
|
219
|
+
steps: '',
|
|
220
|
+
expectedOutcome: '',
|
|
221
|
+
category: 'test',
|
|
222
|
+
tags: [],
|
|
223
|
+
matchIntents: [],
|
|
224
|
+
matchKeywords: [],
|
|
225
|
+
gates: [],
|
|
226
|
+
taskTemplates: [],
|
|
227
|
+
toolInjections: ['search_intelligent', 'shared_tool'],
|
|
228
|
+
verificationCriteria: [],
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const domain: PlaybookDefinition = {
|
|
232
|
+
...generic,
|
|
233
|
+
id: 'd',
|
|
234
|
+
tier: 'domain',
|
|
235
|
+
title: 'D',
|
|
236
|
+
toolInjections: ['shared_tool', 'domain_tool'],
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const merged = mergePlaybooks(generic, domain);
|
|
240
|
+
expect(merged.mergedTools).toHaveLength(3);
|
|
241
|
+
expect(merged.mergedTools).toContain('search_intelligent');
|
|
242
|
+
expect(merged.mergedTools).toContain('shared_tool');
|
|
243
|
+
expect(merged.mergedTools).toContain('domain_tool');
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('should deduplicate verification criteria', () => {
|
|
247
|
+
const generic: PlaybookDefinition = {
|
|
248
|
+
id: 'g',
|
|
249
|
+
tier: 'generic',
|
|
250
|
+
title: 'G',
|
|
251
|
+
trigger: '',
|
|
252
|
+
description: '',
|
|
253
|
+
steps: '',
|
|
254
|
+
expectedOutcome: '',
|
|
255
|
+
category: 'test',
|
|
256
|
+
tags: [],
|
|
257
|
+
matchIntents: [],
|
|
258
|
+
matchKeywords: [],
|
|
259
|
+
gates: [],
|
|
260
|
+
taskTemplates: [],
|
|
261
|
+
toolInjections: [],
|
|
262
|
+
verificationCriteria: ['Tests pass', 'Build succeeds'],
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
const domain: PlaybookDefinition = {
|
|
266
|
+
...generic,
|
|
267
|
+
id: 'd',
|
|
268
|
+
tier: 'domain',
|
|
269
|
+
title: 'D',
|
|
270
|
+
verificationCriteria: ['Tests pass', 'Tokens validated'],
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
const merged = mergePlaybooks(generic, domain);
|
|
274
|
+
expect(merged.mergedVerification).toHaveLength(3);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('should build correct label for generic + domain', () => {
|
|
278
|
+
const generic = getBuiltinPlaybook('generic-tdd')!;
|
|
279
|
+
const domain: PlaybookDefinition = {
|
|
280
|
+
id: 'd',
|
|
281
|
+
tier: 'domain',
|
|
282
|
+
title: 'Component Build',
|
|
283
|
+
trigger: '',
|
|
284
|
+
description: '',
|
|
285
|
+
steps: '',
|
|
286
|
+
expectedOutcome: '',
|
|
287
|
+
category: 'test',
|
|
288
|
+
tags: [],
|
|
289
|
+
matchIntents: [],
|
|
290
|
+
matchKeywords: [],
|
|
291
|
+
gates: [],
|
|
292
|
+
taskTemplates: [],
|
|
293
|
+
toolInjections: [],
|
|
294
|
+
verificationCriteria: [],
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
const merged = mergePlaybooks(generic, domain);
|
|
298
|
+
expect(merged.label).toBe('Component Build (extends Test-Driven Development)');
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
it('should handle generic-only merge', () => {
|
|
302
|
+
const generic = getBuiltinPlaybook('generic-tdd')!;
|
|
303
|
+
const merged = mergePlaybooks(generic, undefined);
|
|
304
|
+
expect(merged.label).toBe(generic.title);
|
|
305
|
+
expect(merged.generic).toBe(generic);
|
|
306
|
+
expect(merged.domain).toBeUndefined();
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
describe('getAllBuiltinPlaybooks', () => {
|
|
311
|
+
it('should return 6 built-in playbooks', () => {
|
|
312
|
+
const all = getAllBuiltinPlaybooks();
|
|
313
|
+
expect(all).toHaveLength(6);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it('should all be generic tier', () => {
|
|
317
|
+
const all = getAllBuiltinPlaybooks();
|
|
318
|
+
expect(all.every((p) => p.tier === 'generic')).toBe(true);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it('should have unique IDs', () => {
|
|
322
|
+
const all = getAllBuiltinPlaybooks();
|
|
323
|
+
const ids = all.map((p) => p.id);
|
|
324
|
+
expect(new Set(ids).size).toBe(ids.length);
|
|
325
|
+
});
|
|
326
|
+
});
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { Vault } from '../vault/vault.js';
|
|
3
|
+
import {
|
|
4
|
+
seedDefaultPlaybooks,
|
|
5
|
+
playbookDefinitionToEntry,
|
|
6
|
+
entryToPlaybookDefinition,
|
|
7
|
+
} from '../playbooks/playbook-seeder.js';
|
|
8
|
+
import { getAllBuiltinPlaybooks } from '../playbooks/playbook-registry.js';
|
|
9
|
+
|
|
10
|
+
describe('playbookDefinitionToEntry', () => {
|
|
11
|
+
it('should convert a PlaybookDefinition to IntelligenceEntry', () => {
|
|
12
|
+
const def = getAllBuiltinPlaybooks()[0];
|
|
13
|
+
const entry = playbookDefinitionToEntry(def);
|
|
14
|
+
|
|
15
|
+
expect(entry.id).toBe(def.id);
|
|
16
|
+
expect(entry.type).toBe('playbook');
|
|
17
|
+
expect(entry.domain).toBe(def.category);
|
|
18
|
+
expect(entry.title).toBe(def.title);
|
|
19
|
+
expect(entry.severity).toBe('suggestion');
|
|
20
|
+
expect(entry.description).toBe(def.description);
|
|
21
|
+
expect(entry.example).toBe(def.steps);
|
|
22
|
+
expect(entry.why).toBe(def.expectedOutcome);
|
|
23
|
+
expect(entry.tags).toEqual(def.tags);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should embed the full definition in context', () => {
|
|
27
|
+
const def = getAllBuiltinPlaybooks()[0];
|
|
28
|
+
const entry = playbookDefinitionToEntry(def);
|
|
29
|
+
expect(entry.context).toContain('__PLAYBOOK_DEF__');
|
|
30
|
+
expect(entry.context).toContain('__END_DEF__');
|
|
31
|
+
expect(entry.context).toContain(def.trigger);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('entryToPlaybookDefinition', () => {
|
|
36
|
+
it('should round-trip through entry and back', () => {
|
|
37
|
+
const original = getAllBuiltinPlaybooks()[0];
|
|
38
|
+
const entry = playbookDefinitionToEntry(original);
|
|
39
|
+
const restored = entryToPlaybookDefinition(entry);
|
|
40
|
+
|
|
41
|
+
expect(restored).not.toBeNull();
|
|
42
|
+
expect(restored!.id).toBe(original.id);
|
|
43
|
+
expect(restored!.tier).toBe(original.tier);
|
|
44
|
+
expect(restored!.title).toBe(original.title);
|
|
45
|
+
expect(restored!.matchIntents).toEqual(original.matchIntents);
|
|
46
|
+
expect(restored!.matchKeywords).toEqual(original.matchKeywords);
|
|
47
|
+
expect(restored!.gates).toEqual(original.gates);
|
|
48
|
+
expect(restored!.taskTemplates).toEqual(original.taskTemplates);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should return null for non-playbook entry', () => {
|
|
52
|
+
const result = entryToPlaybookDefinition({
|
|
53
|
+
id: 'pat-1',
|
|
54
|
+
type: 'pattern',
|
|
55
|
+
domain: 'test',
|
|
56
|
+
title: 'Test',
|
|
57
|
+
severity: 'warning',
|
|
58
|
+
description: 'Test',
|
|
59
|
+
tags: [],
|
|
60
|
+
});
|
|
61
|
+
expect(result).toBeNull();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should return null for playbook entry without metadata', () => {
|
|
65
|
+
const result = entryToPlaybookDefinition({
|
|
66
|
+
id: 'pb-1',
|
|
67
|
+
type: 'playbook',
|
|
68
|
+
domain: 'test',
|
|
69
|
+
title: 'Test',
|
|
70
|
+
severity: 'suggestion',
|
|
71
|
+
description: 'Test',
|
|
72
|
+
context: 'plain text without markers',
|
|
73
|
+
tags: [],
|
|
74
|
+
});
|
|
75
|
+
expect(result).toBeNull();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should return null for malformed JSON in metadata', () => {
|
|
79
|
+
const result = entryToPlaybookDefinition({
|
|
80
|
+
id: 'pb-1',
|
|
81
|
+
type: 'playbook',
|
|
82
|
+
domain: 'test',
|
|
83
|
+
title: 'Test',
|
|
84
|
+
severity: 'suggestion',
|
|
85
|
+
description: 'Test',
|
|
86
|
+
context: '__PLAYBOOK_DEF__{not valid json}__END_DEF__',
|
|
87
|
+
tags: [],
|
|
88
|
+
});
|
|
89
|
+
expect(result).toBeNull();
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe('seedDefaultPlaybooks', () => {
|
|
94
|
+
let vault: Vault;
|
|
95
|
+
|
|
96
|
+
beforeEach(() => {
|
|
97
|
+
vault = new Vault(':memory:');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
afterEach(() => {
|
|
101
|
+
vault.close();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('should seed 6 built-in playbooks into empty vault', () => {
|
|
105
|
+
const result = seedDefaultPlaybooks(vault);
|
|
106
|
+
expect(result.seeded).toBe(6);
|
|
107
|
+
expect(result.skipped).toBe(0);
|
|
108
|
+
expect(result.errors).toBe(0);
|
|
109
|
+
expect(result.details).toHaveLength(6);
|
|
110
|
+
expect(result.details.every((d) => d.action === 'seeded')).toBe(true);
|
|
111
|
+
|
|
112
|
+
// Verify they're in the vault
|
|
113
|
+
const entries = vault.list({ type: 'playbook' });
|
|
114
|
+
expect(entries).toHaveLength(6);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('should be idempotent — second call skips all', () => {
|
|
118
|
+
seedDefaultPlaybooks(vault);
|
|
119
|
+
const result = seedDefaultPlaybooks(vault);
|
|
120
|
+
|
|
121
|
+
expect(result.seeded).toBe(0);
|
|
122
|
+
expect(result.skipped).toBe(6);
|
|
123
|
+
expect(result.errors).toBe(0);
|
|
124
|
+
expect(result.details.every((d) => d.action === 'skipped')).toBe(true);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('should not overwrite user modifications', () => {
|
|
128
|
+
// Seed first
|
|
129
|
+
seedDefaultPlaybooks(vault);
|
|
130
|
+
|
|
131
|
+
// Simulate user modifying a playbook by removing and re-adding with different content
|
|
132
|
+
const builtins = getAllBuiltinPlaybooks();
|
|
133
|
+
vault.remove(builtins[0].id);
|
|
134
|
+
vault.add({
|
|
135
|
+
id: builtins[0].id,
|
|
136
|
+
type: 'playbook',
|
|
137
|
+
domain: 'user-custom',
|
|
138
|
+
title: 'User Modified Playbook',
|
|
139
|
+
severity: 'suggestion',
|
|
140
|
+
description: 'Modified by user',
|
|
141
|
+
tags: ['custom'],
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Re-seed should skip this one
|
|
145
|
+
const result = seedDefaultPlaybooks(vault);
|
|
146
|
+
expect(result.skipped).toBe(6); // all exist, including user-modified one
|
|
147
|
+
|
|
148
|
+
// Verify user's version is preserved
|
|
149
|
+
const entry = vault.get(builtins[0].id);
|
|
150
|
+
expect(entry?.title).toBe('User Modified Playbook');
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('should report correct counts in details', () => {
|
|
154
|
+
const result = seedDefaultPlaybooks(vault);
|
|
155
|
+
const ids = result.details.map((d) => d.id);
|
|
156
|
+
expect(ids).toContain('generic-tdd');
|
|
157
|
+
expect(ids).toContain('generic-brainstorming');
|
|
158
|
+
expect(ids).toContain('generic-code-review');
|
|
159
|
+
expect(ids).toContain('generic-subagent-execution');
|
|
160
|
+
expect(ids).toContain('generic-systematic-debugging');
|
|
161
|
+
expect(ids).toContain('generic-verification');
|
|
162
|
+
});
|
|
163
|
+
});
|