@soleri/core 2.4.0 → 2.6.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/intelligence.d.ts +1 -0
- package/dist/brain/intelligence.d.ts.map +1 -1
- package/dist/brain/intelligence.js +164 -148
- package/dist/brain/intelligence.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/control/identity-manager.d.ts +3 -1
- package/dist/control/identity-manager.d.ts.map +1 -1
- package/dist/control/identity-manager.js +49 -51
- package/dist/control/identity-manager.js.map +1 -1
- package/dist/control/intent-router.d.ts +1 -0
- package/dist/control/intent-router.d.ts.map +1 -1
- package/dist/control/intent-router.js +32 -32
- package/dist/control/intent-router.js.map +1 -1
- package/dist/curator/curator.d.ts +9 -1
- package/dist/curator/curator.d.ts.map +1 -1
- package/dist/curator/curator.js +104 -92
- 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/governance/governance.d.ts +1 -0
- package/dist/governance/governance.d.ts.map +1 -1
- package/dist/governance/governance.js +51 -68
- package/dist/governance/governance.js.map +1 -1
- package/dist/index.d.ts +26 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -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 +4 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/index.js +3 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/persistence/postgres-provider.d.ts +46 -0
- package/dist/persistence/postgres-provider.d.ts.map +1 -0
- package/dist/persistence/postgres-provider.js +115 -0
- package/dist/persistence/postgres-provider.js.map +1 -0
- package/dist/persistence/sqlite-provider.d.ts +28 -0
- package/dist/persistence/sqlite-provider.d.ts.map +1 -0
- package/dist/persistence/sqlite-provider.js +97 -0
- package/dist/persistence/sqlite-provider.js.map +1 -0
- package/dist/persistence/types.d.ts +58 -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 +4 -4
- package/dist/project/project-registry.d.ts.map +1 -1
- package/dist/project/project-registry.js +30 -57
- 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 +348 -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 +28 -9
- 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 +4 -2
- package/dist/runtime/vault-extra-ops.d.ts.map +1 -1
- package/dist/runtime/vault-extra-ops.js +383 -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 +52 -32
- package/dist/vault/vault.d.ts.map +1 -1
- package/dist/vault/vault.js +300 -181
- package/dist/vault/vault.js.map +1 -1
- package/package.json +9 -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 +36 -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 +291 -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__/postgres-provider.test.ts +58 -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/__tests__/vault.test.ts +184 -0
- package/src/brain/brain.ts +71 -9
- package/src/brain/intelligence.ts +258 -307
- package/src/brain/types.ts +2 -2
- package/src/cognee/client.ts +18 -0
- package/src/cognee/sync-manager.ts +389 -0
- package/src/control/identity-manager.ts +77 -75
- package/src/control/intent-router.ts +55 -57
- package/src/curator/curator.ts +199 -139
- 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 +90 -107
- package/src/index.ts +116 -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 +9 -0
- package/src/persistence/postgres-provider.ts +157 -0
- package/src/persistence/sqlite-provider.ts +115 -0
- package/src/persistence/types.ts +74 -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 +81 -74
- 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 +391 -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 +36 -10
- package/src/runtime/types.ts +8 -0
- package/src/runtime/vault-extra-ops.ts +425 -4
- package/src/vault/playbook.ts +87 -0
- package/src/vault/vault.ts +419 -235
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Playbook: Test-Driven Development
|
|
3
|
+
*
|
|
4
|
+
* RED -> GREEN -> REFACTOR cycle.
|
|
5
|
+
* Ported from Salvador's TDD playbook with agent-agnostic tool injections.
|
|
6
|
+
*/
|
|
7
|
+
export const tddPlaybook = {
|
|
8
|
+
id: 'generic-tdd',
|
|
9
|
+
tier: 'generic',
|
|
10
|
+
title: 'Test-Driven Development',
|
|
11
|
+
trigger: 'Use when intent is BUILD or FIX and implementation involves writing new code or modifying existing behavior. Activates for any task that produces production code.',
|
|
12
|
+
description: 'Enforces the RED-GREEN-REFACTOR cycle: write a failing test first, implement minimal code to pass it, then refactor. No production code exists without a test that demanded it. Tests drive the design — if something is hard to test, the design needs simplification.',
|
|
13
|
+
steps: `1. RED — Write the test first
|
|
14
|
+
- Write a test that describes the desired behavior
|
|
15
|
+
- Run it and watch it FAIL (read the actual output)
|
|
16
|
+
- If it passes without new code, the test is wrong or the feature already exists
|
|
17
|
+
|
|
18
|
+
2. GREEN — Write minimal code to pass
|
|
19
|
+
- Write the simplest implementation that makes the test pass
|
|
20
|
+
- Do NOT write more code than the test demands
|
|
21
|
+
- Run the test and watch it PASS (read the actual output)
|
|
22
|
+
|
|
23
|
+
3. REFACTOR — Clean up while green
|
|
24
|
+
- Improve structure, naming, duplication — without changing behavior
|
|
25
|
+
- Run tests after every change — they must stay green
|
|
26
|
+
- Commit when clean
|
|
27
|
+
|
|
28
|
+
4. REPEAT — Next behavior, next test
|
|
29
|
+
- Each cycle should take 2-5 minutes
|
|
30
|
+
- If a cycle takes longer, the step is too big — break it down
|
|
31
|
+
|
|
32
|
+
IRON LAW: If you wrote production code before the test, DELETE IT and start over.`,
|
|
33
|
+
expectedOutcome: 'Every piece of production code is demanded by a failing test. Test suite is comprehensive, fast, and trustworthy. Design emerges from testing pressure — simple, decoupled, focused.',
|
|
34
|
+
category: 'methodology',
|
|
35
|
+
tags: ['tdd', 'testing', 'red-green-refactor', 'discipline', 'generic'],
|
|
36
|
+
matchIntents: ['BUILD', 'FIX'],
|
|
37
|
+
matchKeywords: ['implement', 'build', 'create', 'add', 'fix', 'refactor', 'feature', 'code'],
|
|
38
|
+
gates: [
|
|
39
|
+
{
|
|
40
|
+
phase: 'post-task',
|
|
41
|
+
requirement: 'Test must exist and fail before implementation code is written',
|
|
42
|
+
checkType: 'tdd-red',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
phase: 'completion',
|
|
46
|
+
requirement: 'All tests pass with actual output verified (not self-reported)',
|
|
47
|
+
checkType: 'tdd-green',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
taskTemplates: [
|
|
51
|
+
{
|
|
52
|
+
taskType: 'test',
|
|
53
|
+
titleTemplate: 'Write failing tests for: {objective}',
|
|
54
|
+
acceptanceCriteria: [
|
|
55
|
+
'Tests describe desired behavior, not implementation details',
|
|
56
|
+
'Tests run and FAIL (output read and verified)',
|
|
57
|
+
'No production code written yet',
|
|
58
|
+
],
|
|
59
|
+
tools: ['search_intelligent'],
|
|
60
|
+
order: 'before-implementation',
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
toolInjections: ['search_intelligent'],
|
|
64
|
+
verificationCriteria: [
|
|
65
|
+
'Test suite passes (run command, read output)',
|
|
66
|
+
'No skipped or pending tests',
|
|
67
|
+
'Coverage covers the new/modified code paths',
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=tdd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tdd.js","sourceRoot":"","sources":["../../../src/playbooks/generic/tdd.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,CAAC,MAAM,WAAW,GAAuB;IAC7C,EAAE,EAAE,aAAa;IACjB,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,yBAAyB;IAChC,OAAO,EACL,oKAAoK;IACtK,WAAW,EACT,yQAAyQ;IAC3Q,KAAK,EAAE;;;;;;;;;;;;;;;;;;;kFAmByE;IAChF,eAAe,EACb,sLAAsL;IACxL,QAAQ,EAAE,aAAa;IACvB,IAAI,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,YAAY,EAAE,SAAS,CAAC;IACvE,YAAY,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC;IAC9B,aAAa,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC;IAC5F,KAAK,EAAE;QACL;YACE,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,gEAAgE;YAC7E,SAAS,EAAE,SAAS;SACrB;QACD;YACE,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,gEAAgE;YAC7E,SAAS,EAAE,WAAW;SACvB;KACF;IACD,aAAa,EAAE;QACb;YACE,QAAQ,EAAE,MAAM;YAChB,aAAa,EAAE,sCAAsC;YACrD,kBAAkB,EAAE;gBAClB,6DAA6D;gBAC7D,+CAA+C;gBAC/C,gCAAgC;aACjC;YACD,KAAK,EAAE,CAAC,oBAAoB,CAAC;YAC7B,KAAK,EAAE,uBAAuB;SAC/B;KACF;IACD,cAAc,EAAE,CAAC,oBAAoB,CAAC;IACtC,oBAAoB,EAAE;QACpB,8CAA8C;QAC9C,6BAA6B;QAC7B,6CAA6C;KAC9C;CACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Playbook: Verification Before Completion
|
|
3
|
+
*
|
|
4
|
+
* Evidence-based completion — no self-reported success.
|
|
5
|
+
* Ported from Salvador's verification playbook.
|
|
6
|
+
*/
|
|
7
|
+
import type { PlaybookDefinition } from '../playbook-types.js';
|
|
8
|
+
export declare const verificationPlaybook: PlaybookDefinition;
|
|
9
|
+
//# sourceMappingURL=verification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../../src/playbooks/generic/verification.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,eAAO,MAAM,oBAAoB,EAAE,kBAqElC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Playbook: Verification Before Completion
|
|
3
|
+
*
|
|
4
|
+
* Evidence-based completion — no self-reported success.
|
|
5
|
+
* Ported from Salvador's verification playbook.
|
|
6
|
+
*/
|
|
7
|
+
export const verificationPlaybook = {
|
|
8
|
+
id: 'generic-verification',
|
|
9
|
+
tier: 'generic',
|
|
10
|
+
title: 'Verification Before Completion',
|
|
11
|
+
trigger: 'Use at the completion of any task or plan. Activates automatically as a completion gate. Prevents the common failure mode of claiming success without running verification commands.',
|
|
12
|
+
description: 'Every completion claim must be backed by evidence: run the command, read the output, only then assert the result. No self-reported success. No "the tests should pass." Actual output or it didn\'t happen.',
|
|
13
|
+
steps: `1. IDENTIFY VERIFICATION COMMANDS
|
|
14
|
+
- What commands prove this works? (test runner, build, lint, type check)
|
|
15
|
+
- What manual checks are needed? (UI renders, API responds, file exists)
|
|
16
|
+
- What acceptance criteria need evidence?
|
|
17
|
+
|
|
18
|
+
2. RUN EACH COMMAND
|
|
19
|
+
- Execute each verification command
|
|
20
|
+
- READ THE ACTUAL OUTPUT (not just the exit code)
|
|
21
|
+
- If any command fails: the task is NOT complete
|
|
22
|
+
|
|
23
|
+
3. COLLECT EVIDENCE
|
|
24
|
+
- For each claim, record the command and its output
|
|
25
|
+
- "Tests pass" → show the test runner output
|
|
26
|
+
- "Build succeeds" → show the build output
|
|
27
|
+
- "No regressions" → show the full test suite output
|
|
28
|
+
|
|
29
|
+
4. VERIFY AGAINST ACCEPTANCE CRITERIA
|
|
30
|
+
- Check each acceptance criterion against collected evidence
|
|
31
|
+
- Mark each as: VERIFIED (with evidence) or UNVERIFIED
|
|
32
|
+
- If any criterion is UNVERIFIED: the task is NOT complete
|
|
33
|
+
|
|
34
|
+
COMMON FALSE COMPLETIONS:
|
|
35
|
+
| Claim | NOT Sufficient | Required |
|
|
36
|
+
|-------|---------------|----------|
|
|
37
|
+
| "Tests pass" | "I believe tests pass" | npm test output showing all pass |
|
|
38
|
+
| "Build works" | "Should compile fine" | npm run build output with 0 errors |
|
|
39
|
+
| "No regressions" | "Didn't change much" | Full test suite output |
|
|
40
|
+
| "Types correct" | "Looks right to me" | tsc --noEmit output |`,
|
|
41
|
+
expectedOutcome: 'Every completion claim is backed by command output evidence. No ambiguity about whether the work is actually done.',
|
|
42
|
+
category: 'methodology',
|
|
43
|
+
tags: ['verification', 'evidence', 'completion', 'discipline', 'generic'],
|
|
44
|
+
matchIntents: ['BUILD', 'FIX', 'IMPROVE', 'DELIVER'],
|
|
45
|
+
matchKeywords: ['done', 'complete', 'finish', 'ship', 'merge', 'deploy', 'release'],
|
|
46
|
+
gates: [
|
|
47
|
+
{
|
|
48
|
+
phase: 'completion',
|
|
49
|
+
requirement: 'All acceptance criteria must have evidence (command output, not self-report)',
|
|
50
|
+
checkType: 'verification-evidence',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
taskTemplates: [
|
|
54
|
+
{
|
|
55
|
+
taskType: 'verification',
|
|
56
|
+
titleTemplate: 'Verify: {objective}',
|
|
57
|
+
acceptanceCriteria: [
|
|
58
|
+
'All verification commands executed and output read',
|
|
59
|
+
'All acceptance criteria matched against evidence',
|
|
60
|
+
'No unverified claims remain',
|
|
61
|
+
],
|
|
62
|
+
tools: [],
|
|
63
|
+
order: 'after-implementation',
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
toolInjections: [],
|
|
67
|
+
verificationCriteria: [
|
|
68
|
+
'Test suite passes (actual output, not self-report)',
|
|
69
|
+
'Build succeeds (actual output)',
|
|
70
|
+
'Type checking passes (actual output)',
|
|
71
|
+
'All acceptance criteria have matching evidence',
|
|
72
|
+
],
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=verification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verification.js","sourceRoot":"","sources":["../../../src/playbooks/generic/verification.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,CAAC,MAAM,oBAAoB,GAAuB;IACtD,EAAE,EAAE,sBAAsB;IAC1B,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,gCAAgC;IACvC,OAAO,EACL,sLAAsL;IACxL,WAAW,EACT,6MAA6M;IAC/M,KAAK,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;gEA2BuD;IAC9D,eAAe,EACb,oHAAoH;IACtH,QAAQ,EAAE,aAAa;IACvB,IAAI,EAAE,CAAC,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,CAAC;IACzE,YAAY,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC;IACpD,aAAa,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC;IACnF,KAAK,EAAE;QACL;YACE,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,8EAA8E;YAC3F,SAAS,EAAE,uBAAuB;SACnC;KACF;IACD,aAAa,EAAE;QACb;YACE,QAAQ,EAAE,cAAc;YACxB,aAAa,EAAE,qBAAqB;YACpC,kBAAkB,EAAE;gBAClB,oDAAoD;gBACpD,kDAAkD;gBAClD,6BAA6B;aAC9B;YACD,KAAK,EAAE,EAAE;YACT,KAAK,EAAE,sBAAsB;SAC9B;KACF;IACD,cAAc,EAAE,EAAE;IAClB,oBAAoB,EAAE;QACpB,oDAAoD;QACpD,gCAAgC;QAChC,sCAAsC;QACtC,gDAAgD;KACjD;CACF,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { PlaybookTier, PlaybookIntent, BrainstormSection, PlaybookGate, PlaybookTaskTemplate, PlaybookDefinition, MergedPlaybook, PlaybookMatchResult, } from './playbook-types.js';
|
|
2
|
+
export { getBuiltinPlaybook, getAllBuiltinPlaybooks, scorePlaybook, mergePlaybooks, matchPlaybooks, } from './playbook-registry.js';
|
|
3
|
+
export { playbookDefinitionToEntry, entryToPlaybookDefinition, seedDefaultPlaybooks, } from './playbook-seeder.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/playbooks/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// ─── Playbook Registry ──────────────────────────────────────────────
|
|
2
|
+
export { getBuiltinPlaybook, getAllBuiltinPlaybooks, scorePlaybook, mergePlaybooks, matchPlaybooks, } from './playbook-registry.js';
|
|
3
|
+
// ─── Playbook Seeder ────────────────────────────────────────────────
|
|
4
|
+
export { playbookDefinitionToEntry, entryToPlaybookDefinition, seedDefaultPlaybooks, } from './playbook-seeder.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/playbooks/index.ts"],"names":[],"mappings":"AAYA,uEAAuE;AACvE,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,wBAAwB,CAAC;AAEhC,uEAAuE;AACvE,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playbook Registry
|
|
3
|
+
*
|
|
4
|
+
* Matches playbooks to plan context (intent + keywords) and merges
|
|
5
|
+
* generic + domain tiers into a single MergedPlaybook.
|
|
6
|
+
*
|
|
7
|
+
* Resolution order: vault first (user overrides), built-in fallback.
|
|
8
|
+
*/
|
|
9
|
+
import type { PlaybookDefinition, PlaybookMatchResult, MergedPlaybook, PlaybookIntent } from './playbook-types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Get a built-in playbook by ID.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getBuiltinPlaybook(id: string): PlaybookDefinition | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Get all built-in playbooks.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getAllBuiltinPlaybooks(): readonly PlaybookDefinition[];
|
|
18
|
+
/**
|
|
19
|
+
* Score a playbook against the given intent and text.
|
|
20
|
+
* Returns 0 if no match, positive score if matched.
|
|
21
|
+
*/
|
|
22
|
+
export declare function scorePlaybook(playbook: PlaybookDefinition, intent: PlaybookIntent | undefined, text: string): number;
|
|
23
|
+
/**
|
|
24
|
+
* Create a MergedPlaybook from a generic and/or domain match.
|
|
25
|
+
*/
|
|
26
|
+
export declare function mergePlaybooks(generic?: PlaybookDefinition, domain?: PlaybookDefinition): MergedPlaybook;
|
|
27
|
+
/**
|
|
28
|
+
* Match playbooks for a plan based on intent and objective/scope text.
|
|
29
|
+
*
|
|
30
|
+
* Resolution:
|
|
31
|
+
* 1. Search built-in playbooks (vault search is wired separately by the caller)
|
|
32
|
+
* 2. Find best generic match
|
|
33
|
+
* 3. Find best domain match
|
|
34
|
+
* 4. If domain has `extends`, resolve the generic it extends
|
|
35
|
+
* 5. Merge into MergedPlaybook
|
|
36
|
+
*
|
|
37
|
+
* @param intent - The detected intent (BUILD, FIX, REVIEW, etc.)
|
|
38
|
+
* @param text - The plan objective + scope text to match against
|
|
39
|
+
* @param vaultPlaybooks - Optional vault-stored playbooks (searched first, override builtins)
|
|
40
|
+
*/
|
|
41
|
+
export declare function matchPlaybooks(intent: PlaybookIntent | undefined, text: string, vaultPlaybooks?: PlaybookDefinition[]): PlaybookMatchResult;
|
|
42
|
+
//# sourceMappingURL=playbook-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playbook-registry.d.ts","sourceRoot":"","sources":["../../src/playbooks/playbook-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EAGd,cAAc,EACf,MAAM,qBAAqB,CAAC;AAqC7B;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAE7E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,SAAS,kBAAkB,EAAE,CAEtE;AAMD;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,kBAAkB,EAC5B,MAAM,EAAE,cAAc,GAAG,SAAS,EAClC,IAAI,EAAE,MAAM,GACX,MAAM,CAiBR;AA8GD;;GAEG;AACH,wBAAgB,cAAc,CAC5B,OAAO,CAAC,EAAE,kBAAkB,EAC5B,MAAM,CAAC,EAAE,kBAAkB,GAC1B,cAAc,CAUhB;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,cAAc,GAAG,SAAS,EAClC,IAAI,EAAE,MAAM,EACZ,cAAc,CAAC,EAAE,kBAAkB,EAAE,GACpC,mBAAmB,CAqCrB"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playbook Registry
|
|
3
|
+
*
|
|
4
|
+
* Matches playbooks to plan context (intent + keywords) and merges
|
|
5
|
+
* generic + domain tiers into a single MergedPlaybook.
|
|
6
|
+
*
|
|
7
|
+
* Resolution order: vault first (user overrides), built-in fallback.
|
|
8
|
+
*/
|
|
9
|
+
// Built-in generic playbook definitions
|
|
10
|
+
import { tddPlaybook } from './generic/tdd.js';
|
|
11
|
+
import { brainstormingPlaybook } from './generic/brainstorming.js';
|
|
12
|
+
import { codeReviewPlaybook } from './generic/code-review.js';
|
|
13
|
+
import { subagentExecutionPlaybook } from './generic/subagent-execution.js';
|
|
14
|
+
import { systematicDebuggingPlaybook } from './generic/systematic-debugging.js';
|
|
15
|
+
import { verificationPlaybook } from './generic/verification.js';
|
|
16
|
+
// =============================================================================
|
|
17
|
+
// SCORING WEIGHTS
|
|
18
|
+
// =============================================================================
|
|
19
|
+
/** Points awarded when the plan intent matches a playbook's matchIntents. */
|
|
20
|
+
const INTENT_MATCH_SCORE = 10;
|
|
21
|
+
/** Points awarded per keyword hit in the plan text. */
|
|
22
|
+
const KEYWORD_MATCH_SCORE = 5;
|
|
23
|
+
/** Minimum total score for a playbook to be considered a match. */
|
|
24
|
+
const MIN_MATCH_SCORE = 5;
|
|
25
|
+
// =============================================================================
|
|
26
|
+
// BUILT-IN REGISTRY
|
|
27
|
+
// =============================================================================
|
|
28
|
+
const BUILTIN_PLAYBOOKS = [
|
|
29
|
+
// Generic tier
|
|
30
|
+
tddPlaybook,
|
|
31
|
+
brainstormingPlaybook,
|
|
32
|
+
codeReviewPlaybook,
|
|
33
|
+
subagentExecutionPlaybook,
|
|
34
|
+
systematicDebuggingPlaybook,
|
|
35
|
+
verificationPlaybook,
|
|
36
|
+
];
|
|
37
|
+
/**
|
|
38
|
+
* Get a built-in playbook by ID.
|
|
39
|
+
*/
|
|
40
|
+
export function getBuiltinPlaybook(id) {
|
|
41
|
+
return BUILTIN_PLAYBOOKS.find((p) => p.id === id);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get all built-in playbooks.
|
|
45
|
+
*/
|
|
46
|
+
export function getAllBuiltinPlaybooks() {
|
|
47
|
+
return BUILTIN_PLAYBOOKS;
|
|
48
|
+
}
|
|
49
|
+
// =============================================================================
|
|
50
|
+
// MATCHING
|
|
51
|
+
// =============================================================================
|
|
52
|
+
/**
|
|
53
|
+
* Score a playbook against the given intent and text.
|
|
54
|
+
* Returns 0 if no match, positive score if matched.
|
|
55
|
+
*/
|
|
56
|
+
export function scorePlaybook(playbook, intent, text) {
|
|
57
|
+
let score = 0;
|
|
58
|
+
const lowerText = text.toLowerCase();
|
|
59
|
+
// Intent match
|
|
60
|
+
if (intent && playbook.matchIntents.includes(intent)) {
|
|
61
|
+
score += INTENT_MATCH_SCORE;
|
|
62
|
+
}
|
|
63
|
+
// Keyword match
|
|
64
|
+
for (const keyword of playbook.matchKeywords) {
|
|
65
|
+
if (lowerText.includes(keyword.toLowerCase())) {
|
|
66
|
+
score += KEYWORD_MATCH_SCORE;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return score;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Find the best matching playbook from a list for the given context.
|
|
73
|
+
* Returns the highest-scoring playbook above the threshold, or undefined.
|
|
74
|
+
*/
|
|
75
|
+
function findBestMatch(playbooks, intent, text, minScore = MIN_MATCH_SCORE) {
|
|
76
|
+
let best;
|
|
77
|
+
for (const playbook of playbooks) {
|
|
78
|
+
const score = scorePlaybook(playbook, intent, text);
|
|
79
|
+
if (score >= minScore && (!best || score > best.score)) {
|
|
80
|
+
best = { playbook, score };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return best;
|
|
84
|
+
}
|
|
85
|
+
// =============================================================================
|
|
86
|
+
// MERGING
|
|
87
|
+
// =============================================================================
|
|
88
|
+
/**
|
|
89
|
+
* Merge gates from generic and domain playbooks.
|
|
90
|
+
* Domain gates come after generic gates. No deduplication — they serve different purposes.
|
|
91
|
+
*/
|
|
92
|
+
function mergeGates(generic, domain) {
|
|
93
|
+
const gates = [];
|
|
94
|
+
if (generic)
|
|
95
|
+
gates.push(...generic.gates);
|
|
96
|
+
if (domain)
|
|
97
|
+
gates.push(...domain.gates);
|
|
98
|
+
return gates;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Merge task templates from generic and domain playbooks.
|
|
102
|
+
* Domain templates with the same order position override generic ones of the same taskType.
|
|
103
|
+
*/
|
|
104
|
+
function mergeTaskTemplates(generic, domain) {
|
|
105
|
+
const genericTemplates = generic?.taskTemplates ?? [];
|
|
106
|
+
const domainTemplates = domain?.taskTemplates ?? [];
|
|
107
|
+
// Start with generic templates
|
|
108
|
+
const merged = [...genericTemplates];
|
|
109
|
+
for (const domainTemplate of domainTemplates) {
|
|
110
|
+
// Check if domain overrides a generic template at the same order + taskType
|
|
111
|
+
const overrideIndex = merged.findIndex((g) => g.order === domainTemplate.order && g.taskType === domainTemplate.taskType);
|
|
112
|
+
if (overrideIndex >= 0) {
|
|
113
|
+
// Domain overrides generic
|
|
114
|
+
merged[overrideIndex] = domainTemplate;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// Domain adds a new template
|
|
118
|
+
merged.push(domainTemplate);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return merged;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Merge tool injections from generic and domain playbooks.
|
|
125
|
+
* Deduplicated — each tool appears only once.
|
|
126
|
+
*/
|
|
127
|
+
function mergeTools(generic, domain) {
|
|
128
|
+
const tools = new Set();
|
|
129
|
+
if (generic) {
|
|
130
|
+
for (const tool of generic.toolInjections)
|
|
131
|
+
tools.add(tool);
|
|
132
|
+
}
|
|
133
|
+
if (domain) {
|
|
134
|
+
for (const tool of domain.toolInjections)
|
|
135
|
+
tools.add(tool);
|
|
136
|
+
}
|
|
137
|
+
return Array.from(tools);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Merge verification criteria from generic and domain playbooks.
|
|
141
|
+
* All criteria from both tiers — domain typically adds domain-specific checks.
|
|
142
|
+
*/
|
|
143
|
+
function mergeVerification(generic, domain) {
|
|
144
|
+
const criteria = [];
|
|
145
|
+
if (generic)
|
|
146
|
+
criteria.push(...generic.verificationCriteria);
|
|
147
|
+
if (domain)
|
|
148
|
+
criteria.push(...domain.verificationCriteria);
|
|
149
|
+
// Deduplicate exact matches
|
|
150
|
+
return [...new Set(criteria)];
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Build a human-readable label for the merged playbook.
|
|
154
|
+
*/
|
|
155
|
+
function buildLabel(generic, domain) {
|
|
156
|
+
if (generic && domain) {
|
|
157
|
+
return `${domain.title} (extends ${generic.title})`;
|
|
158
|
+
}
|
|
159
|
+
if (domain)
|
|
160
|
+
return domain.title;
|
|
161
|
+
if (generic)
|
|
162
|
+
return generic.title;
|
|
163
|
+
return 'Unknown';
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Create a MergedPlaybook from a generic and/or domain match.
|
|
167
|
+
*/
|
|
168
|
+
export function mergePlaybooks(generic, domain) {
|
|
169
|
+
return {
|
|
170
|
+
generic,
|
|
171
|
+
domain,
|
|
172
|
+
mergedGates: mergeGates(generic, domain),
|
|
173
|
+
mergedTasks: mergeTaskTemplates(generic, domain),
|
|
174
|
+
mergedTools: mergeTools(generic, domain),
|
|
175
|
+
mergedVerification: mergeVerification(generic, domain),
|
|
176
|
+
label: buildLabel(generic, domain),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
// =============================================================================
|
|
180
|
+
// MAIN API
|
|
181
|
+
// =============================================================================
|
|
182
|
+
/**
|
|
183
|
+
* Match playbooks for a plan based on intent and objective/scope text.
|
|
184
|
+
*
|
|
185
|
+
* Resolution:
|
|
186
|
+
* 1. Search built-in playbooks (vault search is wired separately by the caller)
|
|
187
|
+
* 2. Find best generic match
|
|
188
|
+
* 3. Find best domain match
|
|
189
|
+
* 4. If domain has `extends`, resolve the generic it extends
|
|
190
|
+
* 5. Merge into MergedPlaybook
|
|
191
|
+
*
|
|
192
|
+
* @param intent - The detected intent (BUILD, FIX, REVIEW, etc.)
|
|
193
|
+
* @param text - The plan objective + scope text to match against
|
|
194
|
+
* @param vaultPlaybooks - Optional vault-stored playbooks (searched first, override builtins)
|
|
195
|
+
*/
|
|
196
|
+
export function matchPlaybooks(intent, text, vaultPlaybooks) {
|
|
197
|
+
// Combine vault (higher priority) and built-in playbooks
|
|
198
|
+
const allPlaybooks = [...(vaultPlaybooks ?? []), ...BUILTIN_PLAYBOOKS];
|
|
199
|
+
const generics = allPlaybooks.filter((p) => p.tier === 'generic');
|
|
200
|
+
const domains = allPlaybooks.filter((p) => p.tier === 'domain');
|
|
201
|
+
// Find best domain match first (domain is more specific)
|
|
202
|
+
const domainMatch = findBestMatch(domains, intent, text);
|
|
203
|
+
// Find best generic match
|
|
204
|
+
let genericMatch = findBestMatch(generics, intent, text);
|
|
205
|
+
// If domain extends a specific generic, prefer that one
|
|
206
|
+
if (domainMatch?.playbook.extends) {
|
|
207
|
+
const extendedGeneric = allPlaybooks.find((p) => p.id === domainMatch.playbook.extends);
|
|
208
|
+
if (extendedGeneric) {
|
|
209
|
+
genericMatch = { playbook: extendedGeneric, score: domainMatch.score };
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// No match at all
|
|
213
|
+
if (!genericMatch && !domainMatch) {
|
|
214
|
+
return { playbook: null };
|
|
215
|
+
}
|
|
216
|
+
const merged = mergePlaybooks(genericMatch?.playbook, domainMatch?.playbook);
|
|
217
|
+
return {
|
|
218
|
+
playbook: merged,
|
|
219
|
+
genericMatch: genericMatch
|
|
220
|
+
? { id: genericMatch.playbook.id, source: 'builtin', score: genericMatch.score }
|
|
221
|
+
: undefined,
|
|
222
|
+
domainMatch: domainMatch
|
|
223
|
+
? { id: domainMatch.playbook.id, source: 'builtin', score: domainMatch.score }
|
|
224
|
+
: undefined,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=playbook-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playbook-registry.js","sourceRoot":"","sources":["../../src/playbooks/playbook-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH,wCAAwC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAA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AAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE;YAC9E,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playbook Seeder
|
|
3
|
+
*
|
|
4
|
+
* Seeds default playbooks into the vault on activation.
|
|
5
|
+
* Idempotent — only seeds playbooks that don't already exist.
|
|
6
|
+
* Never overwrites user-modified playbooks.
|
|
7
|
+
*
|
|
8
|
+
* Also provides conversion utilities between PlaybookDefinition and
|
|
9
|
+
* IntelligenceEntry for vault storage.
|
|
10
|
+
*/
|
|
11
|
+
import type { IntelligenceEntry } from '../intelligence/types.js';
|
|
12
|
+
import type { PlaybookDefinition } from './playbook-types.js';
|
|
13
|
+
import type { Vault } from '../vault/vault.js';
|
|
14
|
+
/**
|
|
15
|
+
* Convert a PlaybookDefinition to a vault IntelligenceEntry.
|
|
16
|
+
*
|
|
17
|
+
* Field mapping:
|
|
18
|
+
* id -> id title -> title
|
|
19
|
+
* 'playbook' -> type category -> domain
|
|
20
|
+
* 'suggestion' -> severity
|
|
21
|
+
* trigger -> context (prefixed with full definition JSON for reconstruction)
|
|
22
|
+
* description -> description
|
|
23
|
+
* tags -> tags
|
|
24
|
+
* steps -> example
|
|
25
|
+
* expectedOutcome -> why
|
|
26
|
+
*/
|
|
27
|
+
export declare function playbookDefinitionToEntry(def: PlaybookDefinition): IntelligenceEntry;
|
|
28
|
+
/**
|
|
29
|
+
* Extract a PlaybookDefinition from a vault IntelligenceEntry.
|
|
30
|
+
* Returns null if the entry doesn't contain PlaybookDefinition metadata.
|
|
31
|
+
*/
|
|
32
|
+
export declare function entryToPlaybookDefinition(entry: IntelligenceEntry): PlaybookDefinition | null;
|
|
33
|
+
/**
|
|
34
|
+
* Seed default built-in playbooks into the vault.
|
|
35
|
+
* Idempotent — skips playbooks that already exist (never overwrites).
|
|
36
|
+
*/
|
|
37
|
+
export declare function seedDefaultPlaybooks(vault: Vault): {
|
|
38
|
+
seeded: number;
|
|
39
|
+
skipped: number;
|
|
40
|
+
errors: number;
|
|
41
|
+
details: Array<{
|
|
42
|
+
id: string;
|
|
43
|
+
action: 'seeded' | 'skipped' | 'error';
|
|
44
|
+
reason?: string;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=playbook-seeder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playbook-seeder.d.ts","sourceRoot":"","sources":["../../src/playbooks/playbook-seeder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,kBAAkB,GAAG,iBAAiB,CAgBpF;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,IAAI,CAqB7F;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACzF,CAmCA"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playbook Seeder
|
|
3
|
+
*
|
|
4
|
+
* Seeds default playbooks into the vault on activation.
|
|
5
|
+
* Idempotent — only seeds playbooks that don't already exist.
|
|
6
|
+
* Never overwrites user-modified playbooks.
|
|
7
|
+
*
|
|
8
|
+
* Also provides conversion utilities between PlaybookDefinition and
|
|
9
|
+
* IntelligenceEntry for vault storage.
|
|
10
|
+
*/
|
|
11
|
+
import { getAllBuiltinPlaybooks } from './playbook-registry.js';
|
|
12
|
+
/**
|
|
13
|
+
* Convert a PlaybookDefinition to a vault IntelligenceEntry.
|
|
14
|
+
*
|
|
15
|
+
* Field mapping:
|
|
16
|
+
* id -> id title -> title
|
|
17
|
+
* 'playbook' -> type category -> domain
|
|
18
|
+
* 'suggestion' -> severity
|
|
19
|
+
* trigger -> context (prefixed with full definition JSON for reconstruction)
|
|
20
|
+
* description -> description
|
|
21
|
+
* tags -> tags
|
|
22
|
+
* steps -> example
|
|
23
|
+
* expectedOutcome -> why
|
|
24
|
+
*/
|
|
25
|
+
export function playbookDefinitionToEntry(def) {
|
|
26
|
+
// Serialize the full definition as JSON metadata so playbook_match can reconstruct it
|
|
27
|
+
const metadata = JSON.stringify(def);
|
|
28
|
+
return {
|
|
29
|
+
id: def.id,
|
|
30
|
+
type: 'playbook',
|
|
31
|
+
domain: def.category,
|
|
32
|
+
title: def.title,
|
|
33
|
+
severity: 'suggestion',
|
|
34
|
+
description: def.description,
|
|
35
|
+
context: `__PLAYBOOK_DEF__${metadata}__END_DEF__\n${def.trigger}`,
|
|
36
|
+
example: def.steps,
|
|
37
|
+
why: def.expectedOutcome,
|
|
38
|
+
tags: def.tags,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Extract a PlaybookDefinition from a vault IntelligenceEntry.
|
|
43
|
+
* Returns null if the entry doesn't contain PlaybookDefinition metadata.
|
|
44
|
+
*/
|
|
45
|
+
export function entryToPlaybookDefinition(entry) {
|
|
46
|
+
if (entry.type !== 'playbook')
|
|
47
|
+
return null;
|
|
48
|
+
const context = entry.context ?? '';
|
|
49
|
+
const startMarker = '__PLAYBOOK_DEF__';
|
|
50
|
+
const endMarker = '__END_DEF__';
|
|
51
|
+
const startIdx = context.indexOf(startMarker);
|
|
52
|
+
const endIdx = context.indexOf(endMarker);
|
|
53
|
+
if (startIdx < 0 || endIdx < 0)
|
|
54
|
+
return null;
|
|
55
|
+
try {
|
|
56
|
+
const json = context.slice(startIdx + startMarker.length, endIdx);
|
|
57
|
+
const def = JSON.parse(json);
|
|
58
|
+
// Validate it has the essential fields
|
|
59
|
+
if (!def.id || !def.tier || !def.title)
|
|
60
|
+
return null;
|
|
61
|
+
return def;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Seed default built-in playbooks into the vault.
|
|
69
|
+
* Idempotent — skips playbooks that already exist (never overwrites).
|
|
70
|
+
*/
|
|
71
|
+
export function seedDefaultPlaybooks(vault) {
|
|
72
|
+
const result = {
|
|
73
|
+
seeded: 0,
|
|
74
|
+
skipped: 0,
|
|
75
|
+
errors: 0,
|
|
76
|
+
details: [],
|
|
77
|
+
};
|
|
78
|
+
const playbooks = getAllBuiltinPlaybooks();
|
|
79
|
+
for (const playbook of playbooks) {
|
|
80
|
+
try {
|
|
81
|
+
// Check if already exists
|
|
82
|
+
const existing = vault.get(playbook.id);
|
|
83
|
+
if (existing) {
|
|
84
|
+
result.skipped++;
|
|
85
|
+
result.details.push({ id: playbook.id, action: 'skipped', reason: 'already exists' });
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const entry = playbookDefinitionToEntry(playbook);
|
|
89
|
+
vault.add(entry);
|
|
90
|
+
result.seeded++;
|
|
91
|
+
result.details.push({ id: playbook.id, action: 'seeded' });
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
result.errors++;
|
|
95
|
+
result.details.push({
|
|
96
|
+
id: playbook.id,
|
|
97
|
+
action: 'error',
|
|
98
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=playbook-seeder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playbook-seeder.js","sourceRoot":"","sources":["../../src/playbooks/playbook-seeder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAGhE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,yBAAyB,CAAC,GAAuB;IAC/D,sFAAsF;IACtF,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAErC,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,GAAG,CAAC,QAAQ;QACpB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,QAAQ,EAAE,YAAY;QACtB,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,OAAO,EAAE,mBAAmB,QAAQ,gBAAgB,GAAG,CAAC,OAAO,EAAE;QACjE,OAAO,EAAE,GAAG,CAAC,KAAK;QAClB,GAAG,EAAE,GAAG,CAAC,eAAe;QACxB,IAAI,EAAE,GAAG,CAAC,IAAI;KACf,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAwB;IAChE,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC;IAE3C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;IACpC,MAAM,WAAW,GAAG,kBAAkB,CAAC;IACvC,MAAM,SAAS,GAAG,aAAa,CAAC;IAEhC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,C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