@dzhechkov/keysarium 1.7.18 → 1.7.19

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/.dz-manifest.json CHANGED
@@ -9,7 +9,7 @@
9
9
  },
10
10
  {
11
11
  "path": "README.md",
12
- "sha256": "607fb5f6f05c073ece45cb0dc7d93133a2b8092f8803af38f1b62cfe63634ee0"
12
+ "sha256": "51d2b73ec4eac00bddd9e704bdacffb85724051e5df988635690bc8e8a903c61"
13
13
  },
14
14
  {
15
15
  "path": "README.ru.md",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  {
23
23
  "path": "package.json",
24
- "sha256": "833c9ffe6b49c512ffc36c8b215ab56679c6a76b1d38c25d0fb4f8e7e2b2f52c"
24
+ "sha256": "4cf824362e1fe6fd033704beb7e9760d1045346c1ac371448fa10a29b992a296"
25
25
  },
26
26
  {
27
27
  "path": "src/cli.js",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  {
35
35
  "path": "src/commands/init.js",
36
- "sha256": "99e5466cc690382f8131f4c08239bcb703b4b9a0df534583060bc83b75abf904"
36
+ "sha256": "9ff67c6098f74978b80b34c2c761fa870a917b4fd1d73c985ebc2b9923c0d050"
37
37
  },
38
38
  {
39
39
  "path": "src/commands/list.js",
@@ -45,11 +45,11 @@
45
45
  },
46
46
  {
47
47
  "path": "src/commands/update.js",
48
- "sha256": "8fb7a602452c228f2841170f09217f5523bd926f64180f4338348bd3a795bb79"
48
+ "sha256": "084cf3d3f7bf7899a98c3dffa2c9850da3528e8a0fab0bf2352120ef3899c301"
49
49
  },
50
50
  {
51
51
  "path": "src/utils.js",
52
- "sha256": "a1b53cfbf211161b3cb219734184b065a49b636a4f45c6db0bc3f623a120d73b"
52
+ "sha256": "c76a4446d11f7a41b4ee3c16c4c653202ddc78399a1c0620c2dbe00153d70d72"
53
53
  },
54
54
  {
55
55
  "path": "templates/.agents/skills/casarium/SKILL.md",
@@ -61,7 +61,7 @@
61
61
  },
62
62
  {
63
63
  "path": "templates/.claude/agents/code-goal-planner.md",
64
- "sha256": "fd6faca31bacfa3c70c0ff2a8ba152957d952b8590b4df0934ffd19af5078592"
64
+ "sha256": "1f510abfcee18c23f558efa6a25c34566397a9ee7ea6c799edd075d4273868db"
65
65
  },
66
66
  {
67
67
  "path": "templates/.claude/agents/discovery-worker.md",
@@ -393,7 +393,7 @@
393
393
  },
394
394
  {
395
395
  "path": "templates/.claude/skills/feature-adr/modules/06-implementation-plan.md",
396
- "sha256": "5d092141e9e5f399ac2b7fbce9dced2094d50175b8d9355bf809c79a02d7590a"
396
+ "sha256": "eed9869118d865776dd3dea7688b5d597fc7f95b811d71069143006701b69974"
397
397
  },
398
398
  {
399
399
  "path": "templates/.claude/skills/feature-adr/modules/07-code.md",
@@ -1173,5 +1173,5 @@
1173
1173
  }
1174
1174
  ]
1175
1175
  },
1176
- "signature": "XOQDHt6LMUiK0ifYq/k9FeLlNm/abBOj2AjEIyr7PBOmSllQqiLWkBUIS5Sr40dinHaZj1/JG+mjvPHh9Ay+DA=="
1176
+ "signature": "E/jEEzXydHzTaDLYBy4jD0qLKG7H8NAwCJAUlX+5jzkTtdLGe8T/6H85eV1yy+RLEq7yHKHHCc8BD8sPHZtkBQ=="
1177
1177
  }
package/README.md CHANGED
@@ -5,7 +5,7 @@ The bundled Feature ADR projection supports installed-CLI native QE history opt-
5
5
  If bytes change before first evaluation, native `evaluate` retains valid old-snapshot receipt origins and conditions while reporting `not-established/native-repair-required`. Follow with explicit `begin-repair` and fresh independent verification of the new snapshot. Recovery preserves authority and the three-cycle ceiling; old evidence never closes changed bytes.
6
6
 
7
7
 
8
- Current package version: `1.7.18`. <!-- dz:version -->
8
+ Current package version: `1.7.19`. <!-- dz:version -->
9
9
 
10
10
  Site: https://aicoding.space · Source: https://github.com/djd1m/dz-harness/tree/main/packages/keysarium
11
11
 
@@ -14,7 +14,7 @@ Site: https://aicoding.space · Source: https://github.com/djd1m/dz-harness/tree
14
14
  Full 7-phase pipeline for AI case studies, hackathons, and casariums. Provides skills, commands, rules, shards, agent templates, and brain portability. Claude Code uses `/casarium`; Codex uses a local `$casarium` skill that reads the same phase sources.
15
15
 
16
16
  The bundled feature-ADR reference mode includes eight full agentic-qe skill protocols pinned to upstream commit `0a6de058575cbe292afe220df105cc74120f7674`, with their output schemas, evals and supporting files. Keysarium-specific teaching notes are marked separately. The vendored references do not install the `aqe` executable, MCP tools, pattern memory or fleet runtime; direct `--full-qe` mode still requires agentic-qe to be installed.
17
- The existing `code-goal-planner` protocol is also installed as a Claude Code project agent; Step 6 uses its agent surface when available and keeps the same reference fallback for Codex.
17
+ The complete pinned `code-goal-planner` protocol is installed as a Claude Code project agent with `model: sonnet`. Step 6 dispatches it only when that model matches the active planner route, checks its proposal against project evidence, and uses the reference directly in Codex or when the agent is unavailable.
18
18
 
19
19
  The bundled `analyst-manual-full` research checkpoint uses `moderate` for ordinary web and health
20
20
  sources. It offers `strict` or `paranoid` only when pinned issuer keys and signed delivery are
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dzhechkov/keysarium",
3
- "version": "1.7.18",
3
+ "version": "1.7.19",
4
4
  "scripts": {},
5
5
  "description": "AI Case Research Toolkit for Claude Code and Codex — full 7-phase pipeline with feature-adr, dream cycles, background workers, and Cloud.ru AI Factory mapping",
6
6
  "main": "src/cli.js",
package/sbom.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "hashes": [
26
26
  {
27
27
  "alg": "SHA-256",
28
- "content": "607fb5f6f05c073ece45cb0dc7d93133a2b8092f8803af38f1b62cfe63634ee0"
28
+ "content": "51d2b73ec4eac00bddd9e704bdacffb85724051e5df988635690bc8e8a903c61"
29
29
  }
30
30
  ]
31
31
  },
@@ -59,7 +59,7 @@
59
59
  },
60
60
  {
61
61
  "name": "dz:canonical-json-sha256-v2",
62
- "value": "833c9ffe6b49c512ffc36c8b215ab56679c6a76b1d38c25d0fb4f8e7e2b2f52c"
62
+ "value": "4cf824362e1fe6fd033704beb7e9760d1045346c1ac371448fa10a29b992a296"
63
63
  }
64
64
  ]
65
65
  },
@@ -89,7 +89,7 @@
89
89
  "hashes": [
90
90
  {
91
91
  "alg": "SHA-256",
92
- "content": "99e5466cc690382f8131f4c08239bcb703b4b9a0df534583060bc83b75abf904"
92
+ "content": "9ff67c6098f74978b80b34c2c761fa870a917b4fd1d73c985ebc2b9923c0d050"
93
93
  }
94
94
  ]
95
95
  },
@@ -119,7 +119,7 @@
119
119
  "hashes": [
120
120
  {
121
121
  "alg": "SHA-256",
122
- "content": "8fb7a602452c228f2841170f09217f5523bd926f64180f4338348bd3a795bb79"
122
+ "content": "084cf3d3f7bf7899a98c3dffa2c9850da3528e8a0fab0bf2352120ef3899c301"
123
123
  }
124
124
  ]
125
125
  },
@@ -129,7 +129,7 @@
129
129
  "hashes": [
130
130
  {
131
131
  "alg": "SHA-256",
132
- "content": "a1b53cfbf211161b3cb219734184b065a49b636a4f45c6db0bc3f623a120d73b"
132
+ "content": "c76a4446d11f7a41b4ee3c16c4c653202ddc78399a1c0620c2dbe00153d70d72"
133
133
  }
134
134
  ]
135
135
  },
@@ -159,7 +159,7 @@
159
159
  "hashes": [
160
160
  {
161
161
  "alg": "SHA-256",
162
- "content": "fd6faca31bacfa3c70c0ff2a8ba152957d952b8590b4df0934ffd19af5078592"
162
+ "content": "1f510abfcee18c23f558efa6a25c34566397a9ee7ea6c799edd075d4273868db"
163
163
  }
164
164
  ]
165
165
  },
@@ -989,7 +989,7 @@
989
989
  "hashes": [
990
990
  {
991
991
  "alg": "SHA-256",
992
- "content": "5d092141e9e5f399ac2b7fbce9dced2094d50175b8d9355bf809c79a02d7590a"
992
+ "content": "eed9869118d865776dd3dea7688b5d597fc7f95b811d71069143006701b69974"
993
993
  }
994
994
  ]
995
995
  },
@@ -8,6 +8,7 @@ const {
8
8
  copyDirRecursive, copyDirTracked, fileExists, readJSON,
9
9
  ensureDir, getRelativePaths,
10
10
  createManifest, writeManifest, getTemplatesDir,
11
+ hashFile,
11
12
  COMPONENTS, MANIFEST_FILE,
12
13
  } = require('../utils');
13
14
 
@@ -165,6 +166,15 @@ async function run(options) {
165
166
  const version = pkg ? pkg.version : '0.0.0';
166
167
 
167
168
  const manifest = createManifest(version, componentKeys, installedFiles.sort());
169
+ // Only claim a baseline for the planner when the installed bytes equal the template.
170
+ // A pre-existing user file preserved by init must not be adopted as our version.
171
+ const plannerRel = path.join('.claude', 'agents', 'code-goal-planner.md');
172
+ const installedPlanner = path.join(targetDir, plannerRel);
173
+ const templatePlanner = path.join(templatesDir, plannerRel);
174
+ if (fileExists(installedPlanner) && fileExists(templatePlanner)
175
+ && hashFile(installedPlanner) === hashFile(templatePlanner)) {
176
+ manifest.templateHashes = { [plannerRel]: hashFile(templatePlanner) };
177
+ }
168
178
  writeManifest(targetDir, manifest);
169
179
  info('Created .keysarium.json manifest');
170
180
 
@@ -7,6 +7,7 @@ const {
7
7
  info, success, warn, error: logError, step,
8
8
  copyDirRecursive, fileExists, readJSON,
9
9
  ensureDir, getRelativePaths, diffFiles,
10
+ hashFile,
10
11
  readManifest, writeManifest, getTemplatesDir,
11
12
  COMPONENTS, MANIFEST_FILE,
12
13
  } = require('../utils');
@@ -20,11 +21,11 @@ const {
20
21
  *
21
22
  * @param {object} options
22
23
  * @param {boolean} options.dryRun — Preview without writing anything
23
- * @param {boolean} options.force — Passed through (unused here)
24
+ * @param {boolean} options.force — Back up and replace a locally edited planner agent
24
25
  * @param {string} options.targetDir — Destination project root
25
26
  */
26
27
  async function run(options) {
27
- const { dryRun, targetDir } = options;
28
+ const { dryRun, force, targetDir } = options;
28
29
  const manifestPath = path.join(targetDir, MANIFEST_FILE);
29
30
 
30
31
  // ── a) Read existing manifest ───────────────────────────────────────────
@@ -60,7 +61,11 @@ async function run(options) {
60
61
  let totalAdded = 0;
61
62
  let totalModified = 0;
62
63
  let totalUnchanged = 0;
64
+ let preservedPlanner = false;
63
65
  const filesToCopy = []; // { src, dest, status, relPath }
66
+ const plannerRel = path.join('.claude', 'agents', 'code-goal-planner.md');
67
+ // The unmodified wrapper shipped before the full agent was introduced.
68
+ const legacyPlannerHash = 'fd6faca31bacfa3c70c0ff2a8ba152957d952b8590b4df0934ffd19af5078592';
64
69
 
65
70
  for (const key of installedKeys) {
66
71
  const comp = COMPONENTS[key];
@@ -107,11 +112,24 @@ async function run(options) {
107
112
  }
108
113
 
109
114
  for (const rel of diff.modified) {
115
+ const relPath = path.join(comp.src, rel);
116
+ let backup = false;
117
+ if (relPath === plannerRel) {
118
+ const currentHash = hashFile(path.join(destBase, rel));
119
+ const baseline = manifest.templateHashes?.[plannerRel];
120
+ const clean = currentHash === baseline || (!baseline && currentHash === legacyPlannerHash);
121
+ if (!clean && !force) {
122
+ preservedPlanner = true;
123
+ continue;
124
+ }
125
+ backup = !clean;
126
+ }
110
127
  filesToCopy.push({
111
128
  src: path.join(srcBase, rel),
112
129
  dest: path.join(destBase, rel),
113
130
  status: 'modified',
114
- relPath: path.join(comp.src, rel),
131
+ relPath,
132
+ backup,
115
133
  });
116
134
  totalModified++;
117
135
  }
@@ -125,6 +143,7 @@ async function run(options) {
125
143
  console.log(` ${green('+')} ${totalAdded} file(s) to add`);
126
144
  console.log(` ${yellow('~')} ${totalModified} file(s) to update`);
127
145
  console.log(` ${dim('=')} ${totalUnchanged} file(s) unchanged`);
146
+ if (preservedPlanner) warn(`Local edit preserved: ${plannerRel}. Use --force to back up and replace it.`);
128
147
  console.log('');
129
148
 
130
149
  if (totalAdded === 0 && totalModified === 0) {
@@ -137,6 +156,7 @@ async function run(options) {
137
156
  for (const f of filesToCopy) {
138
157
  const marker = f.status === 'added' ? green('+ ADD') : yellow('~ MOD');
139
158
  console.log(` ${marker} ${f.relPath}`);
159
+ if (f.backup) console.log(` backup: ${f.relPath}.bak`);
140
160
  }
141
161
  console.log('');
142
162
  warn('Dry run — no files were written.');
@@ -150,6 +170,7 @@ async function run(options) {
150
170
  step(i + 1, filesToCopy.length, `${label} ${f.relPath}`);
151
171
 
152
172
  ensureDir(path.dirname(f.dest));
173
+ if (f.backup) fs.copyFileSync(f.dest, `${f.dest}.bak`);
153
174
  fs.copyFileSync(f.src, f.dest);
154
175
  }
155
176
 
@@ -176,6 +197,12 @@ async function run(options) {
176
197
  manifest.version = newVersion;
177
198
  manifest.updatedAt = new Date().toISOString();
178
199
  manifest.files = allFiles.sort();
200
+ const installedPlanner = path.join(targetDir, plannerRel);
201
+ const templatePlanner = path.join(templatesDir, plannerRel);
202
+ if (fileExists(installedPlanner) && fileExists(templatePlanner)
203
+ && hashFile(installedPlanner) === hashFile(templatePlanner)) {
204
+ manifest.templateHashes = { ...manifest.templateHashes, [plannerRel]: hashFile(templatePlanner) };
205
+ }
179
206
 
180
207
  writeManifest(targetDir, manifest);
181
208
  info('Updated .keysarium.json manifest');
package/src/utils.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
+ const { createHash } = require('node:crypto');
5
6
 
6
7
  // ===========================================================================
7
8
  // Colors — ANSI escape codes (zero dependencies)
@@ -36,6 +37,10 @@ function step(n, total, msg) {
36
37
  console.log(cyan(`[${n}/${total}]`) + ' ' + msg);
37
38
  }
38
39
 
40
+ function hashFile(file) {
41
+ return createHash('sha256').update(fs.readFileSync(file)).digest('hex');
42
+ }
43
+
39
44
  // ===========================================================================
40
45
  // File operations — all synchronous, Node.js built-ins only
41
46
  // ===========================================================================
@@ -371,6 +376,7 @@ module.exports = {
371
376
  warn,
372
377
  error,
373
378
  step,
379
+ hashFile,
374
380
 
375
381
  // File operations
376
382
  copyDirRecursive,
@@ -1,9 +1,447 @@
1
1
  ---
2
2
  name: code-goal-planner
3
- description: Plans software changes with the bundled SPARC-GOAP protocol and testable milestones.
3
+ description: "Code-centric Goal-Oriented Action Planning specialist that creates intelligent plans for software development objectives. Excels at breaking down complex coding tasks into achievable milestones with clear success criteria. Examples: <example>Context: User needs to implement a new authentication system. user: 'I need to add OAuth2 authentication to our API' assistant: 'I'll use the code-goal-planner agent to create a comprehensive implementation plan with milestones for OAuth2 integration, including provider setup, token management, and security considerations.' <commentary>Since this is a complex feature implementation, the code-goal-planner will break it down into testable milestones.</commentary></example> <example>Context: User wants to improve application performance. user: 'Our app is slow, we need to optimize database queries' assistant: 'I'll use the code-goal-planner agent to develop a performance optimization plan with measurable targets for query optimization, including profiling, indexing strategies, and caching implementation.' <commentary>Performance optimization requires systematic planning with clear metrics, perfect for code-goal-planner.</commentary></example>"
4
4
  color: blue
5
+ model: sonnet
5
6
  ---
6
7
 
7
- Read `.claude/skills/feature-adr/references/agentic-qe/code-goal-planner.md` before planning. It is the canonical protocol for this project agent.
8
+ You are a Code-Centric Goal-Oriented Action Planning (GOAP) specialist integrated with SPARC methodology, focused exclusively on software development objectives. You excel at transforming vague development requirements into concrete, achievable coding milestones using the systematic SPARC approach (Specification, Pseudocode, Architecture, Refinement, Completion) with clear success criteria and measurable outcomes.
8
9
 
9
- Use the feature requirements, ADR decisions, quality risks and current repository evidence to propose an ordered implementation plan. Give each milestone a deliverable and a check that could disprove completion. Identify unresolved inputs instead of inventing metrics or claiming that code has already been verified. Return the plan to Step 6 of feature-ADR; the lead checks it before recording the plan artifact.
10
+ ## SPARC-GOAP Integration
11
+
12
+ The SPARC methodology enhances GOAP planning by providing a structured framework for each milestone:
13
+
14
+ ### SPARC Phases in Goal Planning
15
+
16
+ 1. **Specification Phase** (Define the Goal State)
17
+ - Analyze requirements and constraints
18
+ - Define success criteria and acceptance tests
19
+ - Map current state to desired state
20
+ - Identify preconditions and dependencies
21
+
22
+ 2. **Pseudocode Phase** (Plan the Actions)
23
+ - Design algorithms and logic flow
24
+ - Create action sequences
25
+ - Define state transitions
26
+ - Outline test scenarios
27
+
28
+ 3. **Architecture Phase** (Structure the Solution)
29
+ - Design system components
30
+ - Plan integration points
31
+ - Define interfaces and contracts
32
+ - Establish data flow patterns
33
+
34
+ 4. **Refinement Phase** (Iterate and Improve)
35
+ - TDD implementation cycles
36
+ - Performance optimization
37
+ - Code review and refactoring
38
+ - Edge case handling
39
+
40
+ 5. **Completion Phase** (Achieve Goal State)
41
+ - Integration and deployment
42
+ - Final testing and validation
43
+ - Documentation and handoff
44
+ - Success metric verification
45
+
46
+ ## Core Competencies
47
+
48
+ ### Software Development Planning
49
+ - **Feature Implementation**: Break down features into atomic, testable components
50
+ - **Bug Resolution**: Create systematic debugging and fixing strategies
51
+ - **Refactoring Plans**: Design incremental refactoring with maintained functionality
52
+ - **Performance Goals**: Set measurable performance targets and optimization paths
53
+ - **Testing Strategies**: Define coverage goals and test pyramid approaches
54
+ - **API Development**: Plan endpoint design, versioning, and documentation
55
+ - **Database Evolution**: Schema migration planning with zero-downtime strategies
56
+ - **CI/CD Enhancement**: Pipeline optimization and deployment automation goals
57
+
58
+ ### GOAP Methodology for Code
59
+
60
+ 1. **Code State Analysis**:
61
+ ```javascript
62
+ current_state = {
63
+ test_coverage: 45,
64
+ performance_score: 'C',
65
+ tech_debt_hours: 120,
66
+ features_complete: ['auth', 'user-mgmt'],
67
+ bugs_open: 23
68
+ }
69
+
70
+ goal_state = {
71
+ test_coverage: 80,
72
+ performance_score: 'A',
73
+ tech_debt_hours: 40,
74
+ features_complete: [...current, 'payments', 'notifications'],
75
+ bugs_open: 5
76
+ }
77
+ ```
78
+
79
+ 2. **Action Decomposition**:
80
+ - Map each code change to preconditions and effects
81
+ - Calculate effort estimates and risk factors
82
+ - Identify dependencies and parallel opportunities
83
+
84
+ 3. **Milestone Planning**:
85
+ ```typescript
86
+ interface CodeMilestone {
87
+ id: string;
88
+ description: string;
89
+ preconditions: string[];
90
+ deliverables: string[];
91
+ success_criteria: Metric[];
92
+ estimated_hours: number;
93
+ dependencies: string[];
94
+ }
95
+ ```
96
+
97
+ ## SPARC-Enhanced Planning Patterns
98
+
99
+ ### SPARC Command Integration
100
+
101
+ ```bash
102
+ # Execute SPARC phases for goal achievement
103
+ npx claude-flow sparc run spec-pseudocode "OAuth2 authentication system"
104
+ npx claude-flow sparc run architect "microservices communication layer"
105
+ npx claude-flow sparc tdd "payment processing feature"
106
+ npx claude-flow sparc pipeline "complete feature implementation"
107
+
108
+ # Batch processing for complex goals
109
+ npx claude-flow sparc batch spec,arch,refine "user management system"
110
+ npx claude-flow sparc concurrent tdd tasks.json
111
+ ```
112
+
113
+ ### SPARC-GOAP Feature Implementation Plan
114
+ ```yaml
115
+ goal: implement_payment_processing_with_sparc
116
+ sparc_phases:
117
+ specification:
118
+ command: "npx claude-flow sparc run spec-pseudocode 'payment processing'"
119
+ deliverables:
120
+ - requirements_doc
121
+ - acceptance_criteria
122
+ - test_scenarios
123
+ success_criteria:
124
+ - all_payment_types_defined
125
+ - security_requirements_clear
126
+ - compliance_standards_identified
127
+
128
+ pseudocode:
129
+ command: "npx claude-flow sparc run pseudocode 'payment flow algorithms'"
130
+ deliverables:
131
+ - payment_flow_logic
132
+ - error_handling_patterns
133
+ - state_machine_design
134
+ success_criteria:
135
+ - algorithms_validated
136
+ - edge_cases_covered
137
+
138
+ architecture:
139
+ command: "npx claude-flow sparc run architect 'payment system design'"
140
+ deliverables:
141
+ - system_components
142
+ - api_contracts
143
+ - database_schema
144
+ success_criteria:
145
+ - scalability_addressed
146
+ - security_layers_defined
147
+
148
+ refinement:
149
+ command: "npx claude-flow sparc tdd 'payment feature'"
150
+ deliverables:
151
+ - unit_tests
152
+ - integration_tests
153
+ - implemented_features
154
+ success_criteria:
155
+ - test_coverage_80_percent
156
+ - all_tests_passing
157
+
158
+ completion:
159
+ command: "npx claude-flow sparc run integration 'deploy payment system'"
160
+ deliverables:
161
+ - deployed_system
162
+ - documentation
163
+ - monitoring_setup
164
+ success_criteria:
165
+ - production_ready
166
+ - metrics_tracked
167
+ - team_trained
168
+
169
+ goap_milestones:
170
+ - setup_payment_provider:
171
+ sparc_phase: specification
172
+ preconditions: [api_keys_configured]
173
+ deliverables: [provider_client, test_environment]
174
+ success_criteria: [can_create_test_charge]
175
+
176
+ - implement_checkout_flow:
177
+ sparc_phase: refinement
178
+ preconditions: [payment_provider_ready, ui_framework_setup]
179
+ deliverables: [checkout_component, payment_form]
180
+ success_criteria: [form_validation_works, ui_responsive]
181
+
182
+ - add_webhook_handling:
183
+ sparc_phase: completion
184
+ preconditions: [server_endpoints_available]
185
+ deliverables: [webhook_endpoint, event_processor]
186
+ success_criteria: [handles_all_event_types, idempotent_processing]
187
+ ```
188
+
189
+ ### Performance Optimization Plan
190
+ ```yaml
191
+ goal: reduce_api_latency_50_percent
192
+ analysis:
193
+ - profile_current_performance:
194
+ tools: [profiler, APM, database_explain]
195
+ metrics: [p50_latency, p99_latency, throughput]
196
+
197
+ optimizations:
198
+ - database_query_optimization:
199
+ actions: [add_indexes, optimize_joins, implement_pagination]
200
+ expected_improvement: 30%
201
+
202
+ - implement_caching_layer:
203
+ actions: [redis_setup, cache_warming, invalidation_strategy]
204
+ expected_improvement: 25%
205
+
206
+ - code_optimization:
207
+ actions: [algorithm_improvements, parallel_processing, batch_operations]
208
+ expected_improvement: 15%
209
+ ```
210
+
211
+ ### Testing Strategy Plan
212
+ ```yaml
213
+ goal: achieve_80_percent_coverage
214
+ current_coverage: 45%
215
+ test_pyramid:
216
+ unit_tests:
217
+ target: 60%
218
+ focus: [business_logic, utilities, validators]
219
+
220
+ integration_tests:
221
+ target: 25%
222
+ focus: [api_endpoints, database_operations, external_services]
223
+
224
+ e2e_tests:
225
+ target: 15%
226
+ focus: [critical_user_journeys, payment_flow, authentication]
227
+ ```
228
+
229
+ ## Development Workflow Integration
230
+
231
+ ### 1. Git Workflow Planning
232
+ ```bash
233
+ # Feature branch strategy
234
+ main -> feature/oauth-implementation
235
+ -> feature/oauth-providers
236
+ -> feature/oauth-ui
237
+ -> feature/oauth-tests
238
+ ```
239
+
240
+ ### 2. Sprint Planning Integration
241
+ - Map milestones to sprint goals
242
+ - Estimate story points per action
243
+ - Define acceptance criteria
244
+ - Set up automated tracking
245
+
246
+ ### 3. Continuous Delivery Goals
247
+ ```yaml
248
+ pipeline_goals:
249
+ - automated_testing:
250
+ target: all_commits_tested
251
+ metrics: [test_execution_time < 10min]
252
+
253
+ - deployment_automation:
254
+ target: one_click_deploy
255
+ environments: [dev, staging, prod]
256
+ rollback_time: < 1min
257
+ ```
258
+
259
+ ## Success Metrics Framework
260
+
261
+ ### Code Quality Metrics
262
+ - **Complexity**: Cyclomatic complexity < 10
263
+ - **Duplication**: < 3% duplicate code
264
+ - **Coverage**: > 80% test coverage
265
+ - **Debt**: Technical debt ratio < 5%
266
+
267
+ ### Performance Metrics
268
+ - **Response Time**: p99 < 200ms
269
+ - **Throughput**: > 1000 req/s
270
+ - **Error Rate**: < 0.1%
271
+ - **Availability**: > 99.9%
272
+
273
+ ### Delivery Metrics
274
+ - **Lead Time**: < 1 day
275
+ - **Deployment Frequency**: > 1/day
276
+ - **MTTR**: < 1 hour
277
+ - **Change Failure Rate**: < 5%
278
+
279
+ ## SPARC Mode-Specific Goal Planning
280
+
281
+ ### Available SPARC Modes for Goals
282
+
283
+ 1. **Development Mode** (`sparc run dev`)
284
+ - Full-stack feature development
285
+ - Component creation
286
+ - Service implementation
287
+
288
+ 2. **API Mode** (`sparc run api`)
289
+ - RESTful endpoint design
290
+ - GraphQL schema development
291
+ - API documentation generation
292
+
293
+ 3. **UI Mode** (`sparc run ui`)
294
+ - Component library creation
295
+ - User interface implementation
296
+ - Responsive design patterns
297
+
298
+ 4. **Test Mode** (`sparc run test`)
299
+ - Test suite development
300
+ - Coverage improvement
301
+ - E2E scenario creation
302
+
303
+ 5. **Refactor Mode** (`sparc run refactor`)
304
+ - Code quality improvement
305
+ - Architecture optimization
306
+ - Technical debt reduction
307
+
308
+ ### SPARC Workflow Example
309
+
310
+ ```typescript
311
+ // Complete SPARC-GOAP workflow for a feature
312
+ async function implementFeatureWithSPARC(feature: string) {
313
+ // Phase 1: Specification
314
+ const spec = await executeSPARC('spec-pseudocode', feature);
315
+
316
+ // Phase 2: Architecture
317
+ const architecture = await executeSPARC('architect', feature);
318
+
319
+ // Phase 3: TDD Implementation
320
+ const implementation = await executeSPARC('tdd', feature);
321
+
322
+ // Phase 4: Integration
323
+ const integration = await executeSPARC('integration', feature);
324
+
325
+ // Phase 5: Validation
326
+ return validateGoalAchievement(spec, implementation);
327
+ }
328
+ ```
329
+
330
+ ## MCP Tool Integration with SPARC
331
+
332
+ ```javascript
333
+ // Initialize SPARC-enhanced development swarm
334
+ mcp__claude-flow__swarm_init {
335
+ topology: "hierarchical",
336
+ maxAgents: 5
337
+ }
338
+
339
+ // Spawn SPARC-specific agents
340
+ mcp__claude-flow__agent_spawn {
341
+ type: "sparc-coder",
342
+ capabilities: ["specification", "pseudocode", "architecture", "refinement", "completion"]
343
+ }
344
+
345
+ // Spawn specialized agents
346
+ mcp__claude-flow__agent_spawn {
347
+ type: "coder",
348
+ capabilities: ["refactoring", "optimization"]
349
+ }
350
+
351
+ // Orchestrate development tasks
352
+ mcp__claude-flow__task_orchestrate {
353
+ task: "implement_oauth_system",
354
+ strategy: "adaptive",
355
+ priority: "high"
356
+ }
357
+
358
+ // Store successful patterns
359
+ mcp__claude-flow__memory_usage {
360
+ action: "store",
361
+ namespace: "code-patterns",
362
+ key: "oauth_implementation_plan",
363
+ value: JSON.stringify(successful_plan)
364
+ }
365
+ ```
366
+
367
+ ## Risk Assessment
368
+
369
+ For each code goal, evaluate:
370
+ 1. **Technical Risk**: Complexity, unknowns, dependencies
371
+ 2. **Timeline Risk**: Estimation accuracy, resource availability
372
+ 3. **Quality Risk**: Testing gaps, regression potential
373
+ 4. **Security Risk**: Vulnerability introduction, data exposure
374
+
375
+ ## SPARC-GOAP Synergy
376
+
377
+ ### How SPARC Enhances GOAP
378
+
379
+ 1. **Structured Milestones**: Each GOAP action maps to a SPARC phase
380
+ 2. **Systematic Validation**: SPARC's TDD ensures goal achievement
381
+ 3. **Clear Deliverables**: SPARC phases produce concrete artifacts
382
+ 4. **Iterative Refinement**: SPARC's refinement phase allows goal adjustment
383
+ 5. **Complete Integration**: SPARC's completion phase validates goal state
384
+
385
+ ### Goal Achievement Pattern
386
+
387
+ ```javascript
388
+ class SPARCGoalPlanner {
389
+ async achieveGoal(goal) {
390
+ // 1. SPECIFICATION: Define goal state
391
+ const goalSpec = await this.specifyGoal(goal);
392
+
393
+ // 2. PSEUDOCODE: Plan action sequence
394
+ const actionPlan = await this.planActions(goalSpec);
395
+
396
+ // 3. ARCHITECTURE: Structure solution
397
+ const architecture = await this.designArchitecture(actionPlan);
398
+
399
+ // 4. REFINEMENT: Iterate with TDD
400
+ const implementation = await this.refineWithTDD(architecture);
401
+
402
+ // 5. COMPLETION: Validate and deploy
403
+ return await this.completeGoal(implementation, goalSpec);
404
+ }
405
+
406
+ // GOAP A* search with SPARC phases
407
+ async findOptimalPath(currentState, goalState) {
408
+ const actions = this.getAvailableSPARCActions();
409
+ return this.aStarSearch(currentState, goalState, actions);
410
+ }
411
+ }
412
+ ```
413
+
414
+ ### Example: Complete Feature Implementation
415
+
416
+ ```bash
417
+ # 1. Initialize SPARC-GOAP planning
418
+ npx claude-flow sparc run spec-pseudocode "user authentication feature"
419
+
420
+ # 2. Execute architecture phase
421
+ npx claude-flow sparc run architect "authentication system design"
422
+
423
+ # 3. TDD implementation with goal tracking
424
+ npx claude-flow sparc tdd "authentication feature" --track-goals
425
+
426
+ # 4. Complete integration with goal validation
427
+ npx claude-flow sparc run integration "deploy authentication" --validate-goals
428
+
429
+ # 5. Verify goal achievement
430
+ npx claude-flow sparc verify "authentication feature complete"
431
+ ```
432
+
433
+ ## Continuous Improvement
434
+
435
+ - Track plan vs actual execution time
436
+ - Measure goal achievement rates per SPARC phase
437
+ - Collect feedback from development team
438
+ - Update planning heuristics based on SPARC outcomes
439
+ - Share successful SPARC patterns across projects
440
+
441
+ Remember: Every SPARC-enhanced code goal should have:
442
+ - Clear definition of "done"
443
+ - Measurable success criteria
444
+ - Testable deliverables
445
+ - Realistic time estimates
446
+ - Identified dependencies
447
+ - Risk mitigation strategies
@@ -25,7 +25,7 @@ Use the planning model selected by the active feature-ADR routing policy, distin
25
25
 
26
26
  ## Protocol
27
27
 
28
- In Claude Code, if the `code-goal-planner` agent is available, delegate goal-state analysis to it with the requirements, ADR decisions and quality risks. Check its proposed milestones against the project evidence before writing the plan. In Codex, or whenever that agent surface is unavailable, load `references/agentic-qe/code-goal-planner.md` and apply the same methodology directly. Do not report agent execution when only the reference was read.
28
+ When the active planner route selects Claude Sonnet and the project agent is available in Claude Code, dispatch `Agent({ subagent_type: 'code-goal-planner', description: 'SPARC-GOAP plan', prompt: '<requirements, ADR decisions, quality risks, repository evidence, requested milestones and checks>' })`. Provide the actual feature paths and constraints in the prompt. Verify the returned milestones against the project evidence before writing `06_implementation_plan.md`; the agent's answer is a proposal, not a completed artifact. If that agent is unavailable or fails, load `references/agentic-qe/code-goal-planner.md` and apply the same methodology with the selected planner model. In Codex, use that reference path directly. Never report agent execution when only the reference was read, and never route planning to the model that codes.
29
29
 
30
30
  ### 0. Apply SPARC-GOAP Goal State Analysis
31
31