@tudeorangbiasa/sdd-multiagent-opencode 0.2.3 → 0.3.1
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/.opencode/plugins/sdd-register.js +869 -3
- package/bin/sdd-opencode.js +476 -164
- package/opencode.json +1 -2
- package/package.json +4 -2
|
@@ -4,11 +4,809 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
|
|
5
5
|
const __filename = fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = path.dirname(__filename);
|
|
7
|
-
const packageRoot = path.resolve(__dirname, "
|
|
7
|
+
const packageRoot = path.resolve(__dirname, "../..");
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const globalConfigDir = path.join(
|
|
10
|
+
process.env.HOME || process.env.USERPROFILE || "",
|
|
11
|
+
".config",
|
|
12
|
+
"opencode"
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
// ─── Auto-Migration: Remove old symlinks from v0.2.x ────────────────────────
|
|
16
|
+
|
|
17
|
+
function removeOldSymlinks() {
|
|
18
|
+
const MIGRATION_MARKER = ".sdd-migrated-v030";
|
|
19
|
+
const markerPath = path.join(globalConfigDir, MIGRATION_MARKER);
|
|
20
|
+
|
|
21
|
+
if (fs.existsSync(markerPath)) return;
|
|
22
|
+
|
|
23
|
+
const symlinkTargets = [
|
|
24
|
+
{ dir: "commands", prefix: "sdd-" },
|
|
25
|
+
{ dir: "agents", prefix: "sdd-" },
|
|
26
|
+
{ dir: "rules", prefix: null },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
let migrated = false;
|
|
30
|
+
|
|
31
|
+
for (const { dir, prefix } of symlinkTargets) {
|
|
32
|
+
const dirPath = path.join(globalConfigDir, dir);
|
|
33
|
+
if (!fs.existsSync(dirPath)) continue;
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
37
|
+
for (const entry of entries) {
|
|
38
|
+
const fullPath = path.join(dirPath, entry.name);
|
|
39
|
+
try {
|
|
40
|
+
const stat = fs.lstatSync(fullPath);
|
|
41
|
+
if (!stat.isSymbolicLink()) continue;
|
|
42
|
+
|
|
43
|
+
if (prefix && !entry.name.startsWith(prefix)) continue;
|
|
44
|
+
|
|
45
|
+
const linkTarget = fs.readlinkSync(fullPath);
|
|
46
|
+
if (linkTarget.includes("sdd-multiagent-opencode") || linkTarget.includes("opencode-agent-rules")) {
|
|
47
|
+
fs.unlinkSync(fullPath);
|
|
48
|
+
migrated = true;
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
// skip
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} catch {
|
|
55
|
+
// skip
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (migrated) {
|
|
60
|
+
try {
|
|
61
|
+
fs.writeFileSync(markerPath, new Date().toISOString());
|
|
62
|
+
} catch {
|
|
63
|
+
// skip
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
removeOldSymlinks();
|
|
69
|
+
|
|
70
|
+
// ─── Agent Definitions (inlined to avoid sync I/O at boot) ───────────────────
|
|
71
|
+
|
|
72
|
+
const AGENTS = {
|
|
73
|
+
"sdd-orchestrator": {
|
|
74
|
+
mode: "subagent",
|
|
75
|
+
temperature: 0.3,
|
|
76
|
+
permission: {
|
|
77
|
+
edit: "allow",
|
|
78
|
+
bash: "allow",
|
|
79
|
+
task: {
|
|
80
|
+
"sdd-explorer": "allow",
|
|
81
|
+
"sdd-planner": "allow",
|
|
82
|
+
"sdd-implementer": "allow",
|
|
83
|
+
"sdd-reviewer": "allow",
|
|
84
|
+
"sdd-verifier": "allow",
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
color: "accent",
|
|
88
|
+
prompt: `You are an SDD Orchestrator — an internal coordination agent for complex changes.
|
|
89
|
+
|
|
90
|
+
## Mission
|
|
91
|
+
|
|
92
|
+
Coordinate multiple SDD subagents when one change is too large for a single linear pass.
|
|
93
|
+
|
|
94
|
+
## Rules
|
|
95
|
+
|
|
96
|
+
- Use this agent only when explicitly requested by a core command or parent agent.
|
|
97
|
+
- Keep the user-facing workflow unchanged: /sdd-explore, /sdd-propose, /sdd-apply, /sdd-ship.
|
|
98
|
+
- Prefer sequential execution when files overlap.
|
|
99
|
+
- Only parallelize work when touched files are clearly disjoint.
|
|
100
|
+
- Do not invent extra slash commands or hidden phases.
|
|
101
|
+
|
|
102
|
+
## Coordination Pattern
|
|
103
|
+
|
|
104
|
+
1. Read the relevant specs/active/<change-id>/ artifacts.
|
|
105
|
+
2. Split work into safe batches.
|
|
106
|
+
3. Dispatch at most 3 implementer/reviewer/verifier subagents at once.
|
|
107
|
+
4. Collect results and reconcile conflicts.
|
|
108
|
+
5. Update the change artifacts with status, blockers, and verification evidence.
|
|
109
|
+
|
|
110
|
+
## Output
|
|
111
|
+
|
|
112
|
+
Return a concise coordination summary with completed work, blocked work, file conflicts, and recommended next action.`,
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
"sdd-planner": {
|
|
116
|
+
mode: "subagent",
|
|
117
|
+
temperature: 0.3,
|
|
118
|
+
permission: {
|
|
119
|
+
edit: "allow",
|
|
120
|
+
bash: "allow",
|
|
121
|
+
task: {
|
|
122
|
+
"sdd-explorer": "allow",
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
color: "info",
|
|
126
|
+
prompt: `You are an SDD Planner — a specialized agent for technical architecture and planning.
|
|
127
|
+
|
|
128
|
+
## Mission
|
|
129
|
+
|
|
130
|
+
Transform a focused change request into reviewable SDD artifacts with requirements, design, task breakdowns, and risk assessment.
|
|
131
|
+
|
|
132
|
+
## Protocol
|
|
133
|
+
|
|
134
|
+
### 1. Understand the Specification
|
|
135
|
+
- Read existing proposal.md, spec.md, design.md, or exploration findings when present
|
|
136
|
+
- Identify functional/non-functional requirements and acceptance criteria
|
|
137
|
+
|
|
138
|
+
### 2. Analyze Context
|
|
139
|
+
- Review exploration findings from sdd-explorer or /sdd-explore
|
|
140
|
+
- Use codebase-memory-mcp to understand existing architecture constraints via get_architecture and query_graph
|
|
141
|
+
- Understand integration points
|
|
142
|
+
|
|
143
|
+
### 3. Design Architecture
|
|
144
|
+
- Define component boundaries and responsibilities
|
|
145
|
+
- Design data flow and API contracts
|
|
146
|
+
- Create architecture diagrams (Mermaid format)
|
|
147
|
+
|
|
148
|
+
### 4. Break Down Tasks
|
|
149
|
+
- Organize into phases: Setup -> Core -> Integration -> Polish
|
|
150
|
+
- Estimate effort (2-8 hours per task)
|
|
151
|
+
- Define dependencies and DAG structure for parallel execution
|
|
152
|
+
- For parallel execution: Prefer tasks that touch disjoint file sets. Flag or merge tasks that share files — run those sequentially. Populate sdd.touchedFiles for implementation tasks.
|
|
153
|
+
|
|
154
|
+
### 5. Assess Risks
|
|
155
|
+
- Identify technical risks with mitigations
|
|
156
|
+
- Note assumptions and open questions
|
|
157
|
+
|
|
158
|
+
## Output
|
|
159
|
+
|
|
160
|
+
Generate compact artifacts: proposal.md, spec.md, design.md, and tasks.md.
|
|
161
|
+
|
|
162
|
+
For heavy apps (monorepo, microservices, multi-team): Include optional sections: Monorepo/Multi-Package, Team/Ownership, Integration Contracts, Deployment Topology. Set HEAVY_APP: true and populate those fields.
|
|
163
|
+
|
|
164
|
+
## Key Behaviors
|
|
165
|
+
|
|
166
|
+
- Always read the full spec before planning
|
|
167
|
+
- Design for extensibility and maintainability
|
|
168
|
+
- Provide rationale for technology choices
|
|
169
|
+
- Create realistic estimates based on complexity
|
|
170
|
+
- Use the question tool for ambiguous requirements`,
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
"sdd-explorer": {
|
|
174
|
+
mode: "subagent",
|
|
175
|
+
temperature: 0.1,
|
|
176
|
+
permission: {
|
|
177
|
+
edit: "deny",
|
|
178
|
+
bash: {
|
|
179
|
+
"*": "ask",
|
|
180
|
+
"git status*": "allow",
|
|
181
|
+
"git log*": "allow",
|
|
182
|
+
"ls*": "allow",
|
|
183
|
+
"find*": "allow",
|
|
184
|
+
},
|
|
185
|
+
skill: "allow",
|
|
186
|
+
},
|
|
187
|
+
color: "secondary",
|
|
188
|
+
prompt: `You are an SDD Explorer — a specialized agent for deep codebase investigation before planning.
|
|
189
|
+
|
|
190
|
+
## Mission
|
|
191
|
+
|
|
192
|
+
Explore the codebase to discover existing patterns, reusable components, technical constraints, and integration points.
|
|
193
|
+
|
|
194
|
+
## Tools
|
|
195
|
+
|
|
196
|
+
- codebase-memory-mcp: Use search_graph for function/class discovery, trace_path for call chains, get_code_snippet for reading source, query_graph for complex patterns. Prefer these over grep/glob.
|
|
197
|
+
- exa_web_search_exa: For external pattern research and documentation lookup.
|
|
198
|
+
- webfetch: For reading specific URLs found during research.
|
|
199
|
+
|
|
200
|
+
## Strategy
|
|
201
|
+
|
|
202
|
+
### Phase 1: Breadth-First Discovery
|
|
203
|
+
1. Use search_graph with natural language queries for similar functionality
|
|
204
|
+
2. Identify relevant directories and modules via get_architecture
|
|
205
|
+
3. Map dependency graph via query_graph for affected areas
|
|
206
|
+
|
|
207
|
+
### Phase 2: Depth Investigation
|
|
208
|
+
1. Use get_code_snippet to read key files from Phase 1
|
|
209
|
+
2. Understand interfaces and contracts
|
|
210
|
+
3. Document patterns and conventions
|
|
211
|
+
|
|
212
|
+
### Phase 3: External Context
|
|
213
|
+
1. Check related documentation via exa_web_search_exa
|
|
214
|
+
2. Review existing specs in specs/
|
|
215
|
+
|
|
216
|
+
## Output Format
|
|
217
|
+
|
|
218
|
+
Return findings as:
|
|
219
|
+
- Relevant Existing Code: [file path]: [what it does, why relevant]
|
|
220
|
+
- Patterns Discovered: [pattern]: [where used, how it works]
|
|
221
|
+
- Reusable Components: [component]: [how to leverage]
|
|
222
|
+
- Technical Constraints: [constraint]: [impact on approach]
|
|
223
|
+
- Recommended Approach: [Technical direction based on findings]
|
|
224
|
+
- Open Questions: [Questions needing human input]
|
|
225
|
+
|
|
226
|
+
## Key Behaviors
|
|
227
|
+
|
|
228
|
+
- Run multiple parallel searches for coverage
|
|
229
|
+
- Focus on understanding, not implementation
|
|
230
|
+
- Flag uncertainties rather than guessing
|
|
231
|
+
- Use the question tool if critical information is missing`,
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
"sdd-implementer": {
|
|
235
|
+
mode: "subagent",
|
|
236
|
+
temperature: 0.3,
|
|
237
|
+
permission: {
|
|
238
|
+
edit: "allow",
|
|
239
|
+
bash: "allow",
|
|
240
|
+
task: {
|
|
241
|
+
"sdd-verifier": "allow",
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
color: "success",
|
|
245
|
+
prompt: `You are an SDD Implementer — a specialized agent for systematic code execution.
|
|
246
|
+
|
|
247
|
+
## Mission
|
|
248
|
+
|
|
249
|
+
Execute approved SDD changes by following tasks.md in order and tracking progress.
|
|
250
|
+
|
|
251
|
+
## Protocol
|
|
252
|
+
|
|
253
|
+
### Before Starting
|
|
254
|
+
1. Read proposal.md, spec.md, design.md, and tasks.md
|
|
255
|
+
|
|
256
|
+
### Execution Rules
|
|
257
|
+
1. Sequential order — respect task dependencies
|
|
258
|
+
2. Mark progress — update [ ] to [x] immediately after completion
|
|
259
|
+
3. Document blockers — never skip silently, add [BLOCKED: reason]
|
|
260
|
+
4. Follow patterns — match existing codebase conventions
|
|
261
|
+
5. Use codebase-memory-mcp — prefer search_graph and get_code_snippet over grep to understand existing patterns before implementing
|
|
262
|
+
|
|
263
|
+
### After Completion
|
|
264
|
+
Spawn sdd-verifier as a child subagent to validate the implementation before reporting done.
|
|
265
|
+
|
|
266
|
+
## Blocker Handling
|
|
267
|
+
|
|
268
|
+
- [ ] [BLOCKED: reason] Task description
|
|
269
|
+
- Attempted: [what you tried]
|
|
270
|
+
- Needs: [what's required to unblock]
|
|
271
|
+
|
|
272
|
+
Use the question tool for ambiguous requirements or missing information.
|
|
273
|
+
|
|
274
|
+
## Key Behaviors
|
|
275
|
+
|
|
276
|
+
- Never implement differently than planned without documenting why
|
|
277
|
+
- Always update tasks.md checkboxes immediately
|
|
278
|
+
- Preserve existing patterns in the codebase
|
|
279
|
+
- Surface blockers early rather than getting stuck
|
|
280
|
+
- Spawn sdd-verifier after completing implementation`,
|
|
281
|
+
},
|
|
282
|
+
|
|
283
|
+
"sdd-verifier": {
|
|
284
|
+
mode: "subagent",
|
|
285
|
+
temperature: 0.1,
|
|
286
|
+
permission: {
|
|
287
|
+
edit: "deny",
|
|
288
|
+
bash: "allow",
|
|
289
|
+
skill: "allow",
|
|
290
|
+
},
|
|
291
|
+
color: "warning",
|
|
292
|
+
prompt: `You are an SDD Verifier — a skeptical validator that independently confirms work is truly complete.
|
|
293
|
+
|
|
294
|
+
## Mission
|
|
295
|
+
|
|
296
|
+
Verify that claimed work actually works: implementation exists, tests pass, spec is met, edge cases handled.
|
|
297
|
+
|
|
298
|
+
## Tools
|
|
299
|
+
|
|
300
|
+
- chrome-devtools: Use navigate_page, take_screenshot, take_snapshot, list_console_messages for visual/UI verification.
|
|
301
|
+
- codebase-memory-mcp: Use search_graph, trace_path, get_code_snippet for structural code verification.
|
|
302
|
+
- exa_web_search_exa: For validating external API patterns or library usage.
|
|
303
|
+
|
|
304
|
+
## Protocol
|
|
305
|
+
|
|
306
|
+
### 1. Understand Claims
|
|
307
|
+
- Read tasks.md for what was marked complete
|
|
308
|
+
- Read spec.md for requirements and design.md for intended approach
|
|
309
|
+
|
|
310
|
+
### 2. Verify Implementation
|
|
311
|
+
For each claimed completion:
|
|
312
|
+
- File existence — do expected files exist?
|
|
313
|
+
- Code review — use codebase-memory-mcp to verify code structure
|
|
314
|
+
- Integration — is it properly connected?
|
|
315
|
+
- Error handling — are edge cases covered?
|
|
316
|
+
|
|
317
|
+
### 3. Visual/UI Verification (Chrome DevTools)
|
|
318
|
+
For UI features:
|
|
319
|
+
- Navigate to the relevant page
|
|
320
|
+
- Take screenshots and analyze visual output
|
|
321
|
+
- Check console for errors
|
|
322
|
+
- Verify interactive elements
|
|
323
|
+
|
|
324
|
+
### 4. Run Tests
|
|
325
|
+
- Execute relevant test commands
|
|
326
|
+
- Check for test coverage
|
|
327
|
+
- Verify edge cases are tested
|
|
328
|
+
|
|
329
|
+
### 5. Compare to Spec
|
|
330
|
+
For each acceptance criterion, find implementing code and verify it meets the criterion.
|
|
331
|
+
|
|
332
|
+
## Key Behaviors
|
|
333
|
+
|
|
334
|
+
- Be skeptical — don't accept claims at face value
|
|
335
|
+
- Test everything that can be tested
|
|
336
|
+
- Check edge cases, not just happy paths
|
|
337
|
+
- Report honestly even if news is bad
|
|
338
|
+
- Provide specific, actionable feedback`,
|
|
339
|
+
},
|
|
340
|
+
|
|
341
|
+
"sdd-reviewer": {
|
|
342
|
+
mode: "subagent",
|
|
343
|
+
temperature: 0.2,
|
|
344
|
+
permission: {
|
|
345
|
+
edit: "deny",
|
|
346
|
+
bash: {
|
|
347
|
+
"*": "ask",
|
|
348
|
+
"git diff*": "allow",
|
|
349
|
+
"git log*": "allow",
|
|
350
|
+
"grep*": "allow",
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
color: "error",
|
|
354
|
+
prompt: `You are an SDD Reviewer — a specialized agent for comprehensive code review.
|
|
355
|
+
|
|
356
|
+
## Mission
|
|
357
|
+
|
|
358
|
+
Review code for spec compliance, security vulnerabilities, performance bottlenecks, and maintainability.
|
|
359
|
+
|
|
360
|
+
## Protocol
|
|
361
|
+
|
|
362
|
+
### 1. Context
|
|
363
|
+
- Read spec.md for requirements, plan.md for intended approach
|
|
364
|
+
- Identify files changed in implementation
|
|
365
|
+
|
|
366
|
+
### 2. Security Review
|
|
367
|
+
Check: input validation, auth/authz, secrets exposure, injection/XSS/CSRF, secure data handling.
|
|
368
|
+
|
|
369
|
+
### 3. Performance Review
|
|
370
|
+
Check: N+1 queries, unnecessary re-renders, memory leaks, inefficient algorithms, missing caching.
|
|
371
|
+
|
|
372
|
+
### 4. Code Quality Review
|
|
373
|
+
Check: naming conventions, error handling, duplication, complex functions, test coverage.
|
|
374
|
+
|
|
375
|
+
### 5. Spec Compliance
|
|
376
|
+
For each requirement: is it implemented, does it meet acceptance criteria, are edge cases handled?
|
|
377
|
+
|
|
378
|
+
## Key Behaviors
|
|
379
|
+
|
|
380
|
+
- Review objectively without personal preference bias
|
|
381
|
+
- Provide specific, actionable feedback with line references
|
|
382
|
+
- Acknowledge good patterns, not just problems
|
|
383
|
+
- Prioritize issues by impact`,
|
|
384
|
+
},
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
// ─── Command Definitions (inlined to avoid sync I/O at boot) ─────────────────
|
|
388
|
+
|
|
389
|
+
const COMMANDS = {
|
|
390
|
+
"sdd-construct": {
|
|
391
|
+
description: "Initialize SDD workflow for a new or existing project — explore stack, grill vision, scaffold config, create CONTEXT.md and ADRs",
|
|
392
|
+
agent: "sdd-planner",
|
|
393
|
+
template: `Initialize the "spine" of an SDD-driven project. This is a one-time setup command that creates the foundational artifacts every AI-assisted project needs.
|
|
394
|
+
|
|
395
|
+
## Usage
|
|
396
|
+
|
|
397
|
+
/sdd-construct
|
|
398
|
+
/sdd-construct "e-commerce platform for digital goods"
|
|
399
|
+
/sdd-construct --existing
|
|
400
|
+
|
|
401
|
+
## Philosophy
|
|
402
|
+
|
|
403
|
+
Inspired by Matt Pocock's setup-matt-pocock-skills + grill-with-docs workflow. The goal is not to generate boilerplate — it is to force clarity before code.
|
|
404
|
+
|
|
405
|
+
Before any implementation artifact exists, the project must have:
|
|
406
|
+
- A detected and verified stack profile
|
|
407
|
+
- A domain glossary (CONTEXT.md) with agreed terminology
|
|
408
|
+
- Architectural Decision Records for load-bearing choices
|
|
409
|
+
- Model routing and reasoning profiles tuned to project complexity
|
|
410
|
+
- Type-specific guardrails (design system for frontend, API contract for backend, etc.)
|
|
411
|
+
|
|
412
|
+
## Phase 1: Stack Detection and Classification
|
|
413
|
+
|
|
414
|
+
### Step 0: Empty Directory Guard
|
|
415
|
+
|
|
416
|
+
Check if the directory contains ANY files:
|
|
417
|
+
- ls -la at repo root
|
|
418
|
+
- Check for hidden files: .gitignore, .env, .git/
|
|
419
|
+
|
|
420
|
+
If ZERO files found (truly empty):
|
|
421
|
+
1. Report: "This directory is empty. I cannot auto-detect a stack."
|
|
422
|
+
2. Ask user to choose project type explicitly: frontend, backend, library/sdk, cli, fullstack
|
|
423
|
+
3. Ask user to choose initial stack details: Framework, language, package manager, styling
|
|
424
|
+
4. Generate minimal starter files based on chosen type
|
|
425
|
+
5. Proceed to Phase 2 with user-provided stack info
|
|
426
|
+
6. DO NOT spawn sdd-explorer (nothing to explore).
|
|
427
|
+
|
|
428
|
+
### Step 1: Quick Sniff Test (no subagent yet)
|
|
429
|
+
|
|
430
|
+
Read these files directly to determine if exploration is needed:
|
|
431
|
+
1. package.json (first 50 lines) — check for framework dependencies and config fields
|
|
432
|
+
2. ls -la at root — check for config files and directory structure
|
|
433
|
+
|
|
434
|
+
Decision Matrix: Spawn explorer or skip?
|
|
435
|
+
|
|
436
|
+
| Sniff Result | Decision | Reason |
|
|
437
|
+
| No package.json + random files | Spawn explorer | Unclear pattern |
|
|
438
|
+
| package.json + next.config.* | Skip | Clear: Next.js |
|
|
439
|
+
| package.json + nuxt.config.* | Skip | Clear: Nuxt |
|
|
440
|
+
| package.json + vite.config.* + src/ + no server deps | Skip | Clear: Vite frontend |
|
|
441
|
+
| package.json + laravel/ dir | Skip | Clear: Laravel |
|
|
442
|
+
| package.json + django/ or manage.py | Skip | Clear: Django |
|
|
443
|
+
| package.json + express/fastify/hono deps | Skip | Clear: backend |
|
|
444
|
+
| package.json + "exports" field + no server deps | Skip | Clear: library |
|
|
445
|
+
| package.json + "bin" field + no server | Skip | Clear: CLI |
|
|
446
|
+
| package.json + unknown config + 3+ config files | Spawn explorer | Complex or custom |
|
|
447
|
+
| pnpm-workspace.yaml or monorepo structure | Spawn explorer | Monorepo needs deep scan |
|
|
448
|
+
| 10+ config files at root | Spawn explorer | Too many signals to classify from sniff |
|
|
449
|
+
|
|
450
|
+
If decision is SKIP: Classify project type directly from sniff results. Proceed to Step 3.
|
|
451
|
+
If decision is SPAWN: Proceed to Step 2 (Subagent exploration).
|
|
452
|
+
|
|
453
|
+
### Step 2: Subagent Exploration (only if sniff test is unclear)
|
|
454
|
+
|
|
455
|
+
Spawn sdd-explorer subagent to return a structured stack profile written to .sdd/stack-profile.json.
|
|
456
|
+
|
|
457
|
+
Timeout and Error Handling (Three-Layer Fallback):
|
|
458
|
+
- Layer 1: Spawn sdd-explorer with 60-second timeout.
|
|
459
|
+
- Layer 2: If Layer 1 times out → sdd-planner reads files directly.
|
|
460
|
+
- Layer 3: If Layer 2 also fails → ask user to provide stack info.
|
|
461
|
+
|
|
462
|
+
### Step 3: Present Findings
|
|
463
|
+
|
|
464
|
+
Summarize what is present, what is missing, and the classified type.
|
|
465
|
+
|
|
466
|
+
## Phase 2: Grilling Session
|
|
467
|
+
|
|
468
|
+
After presenting findings, walk the user through decisions one at a time. Do not dump all questions at once.
|
|
469
|
+
|
|
470
|
+
### Section A — Project Vision (ALL types)
|
|
471
|
+
1. What are you building? (one sentence)
|
|
472
|
+
2. Who is the target User?
|
|
473
|
+
3. What is the single most important feature?
|
|
474
|
+
|
|
475
|
+
### Section B — Constraints & Preferences (ALL types)
|
|
476
|
+
1. Any libraries or frameworks you refuse to use?
|
|
477
|
+
2. Any libraries you insist on?
|
|
478
|
+
3. Team size: solo, small team (2-5), or large team (5+)?
|
|
479
|
+
|
|
480
|
+
### Section C — Model Budget (ALL types)
|
|
481
|
+
Present the default model profile and ask about paid model subscriptions.
|
|
482
|
+
|
|
483
|
+
### Section D — Issue Tracker (ALL types)
|
|
484
|
+
Options: GitHub, GitLab, Local markdown, Other.
|
|
485
|
+
|
|
486
|
+
### Section E — Domain Glossary (CONTEXT.md) (ALL types)
|
|
487
|
+
1. What are the key domain terms?
|
|
488
|
+
2. Any terms that are commonly confused?
|
|
489
|
+
|
|
490
|
+
### Section F — Type-Specific Guardrails (conditional)
|
|
491
|
+
- frontend/fullstack: Design System Lock (DESIGN.md)
|
|
492
|
+
- backend: API Contract (API_CONTRACT.md, SECURITY_RULES.md)
|
|
493
|
+
- library/sdk: Public API (PUBLIC_API.md, VERSIONING.md)
|
|
494
|
+
- cli: Command Structure (COMMAND_STRUCTURE.md)
|
|
495
|
+
|
|
496
|
+
## Phase 3: Scaffold Artifacts
|
|
497
|
+
|
|
498
|
+
Generate: .sdd/project-profile.json, .sdd/stack-profile.json, .sdd/model-profile.json, .sdd/reasoning-profile.json, CONTEXT.md, docs/adr/0001-project-initialization.md, type-specific artifacts, docs/agents/issue-tracker.md, and update AGENTS.md with agent skills block.
|
|
499
|
+
|
|
500
|
+
## Phase 4: Verification
|
|
501
|
+
|
|
502
|
+
Verify all universal and type-specific checks before reporting completion.
|
|
503
|
+
|
|
504
|
+
## Anti-Generic Gate
|
|
505
|
+
|
|
506
|
+
Before final output, verify all checklist items. Report any failures.
|
|
507
|
+
|
|
508
|
+
## Output
|
|
509
|
+
|
|
510
|
+
End with:
|
|
511
|
+
changed: SDD project initialized
|
|
512
|
+
|
|
513
|
+
Artifacts created:
|
|
514
|
+
- .sdd/stack-profile.json, .sdd/project-profile.json, .sdd/model-profile.json, .sdd/reasoning-profile.json
|
|
515
|
+
- CONTEXT.md, docs/adr/0001-project-initialization.md, docs/agents/issue-tracker.md
|
|
516
|
+
- AGENTS.md (agent skills block)
|
|
517
|
+
- <type-specific artifacts>
|
|
518
|
+
|
|
519
|
+
Project type: <frontend|backend|library|cli|fullstack>
|
|
520
|
+
Next: run /sdd-propose "<your first feature>" to start building.`,
|
|
521
|
+
},
|
|
522
|
+
|
|
523
|
+
"sdd-explore": {
|
|
524
|
+
description: "Investigate an idea, bug, or code area without changing source code",
|
|
525
|
+
agent: "sdd-explorer",
|
|
526
|
+
template: `Explore the request safely before committing to a change.
|
|
527
|
+
|
|
528
|
+
## Usage
|
|
529
|
+
|
|
530
|
+
/sdd-explore "what you want to understand"
|
|
531
|
+
/sdd-explore change-id "what you want to understand"
|
|
532
|
+
|
|
533
|
+
## Rules
|
|
534
|
+
|
|
535
|
+
- Do not edit source code.
|
|
536
|
+
- Do not implement fixes.
|
|
537
|
+
- Do not create a change unless the user explicitly asks.
|
|
538
|
+
- Use codebase search first for project-specific questions.
|
|
539
|
+
- Use web research only when external facts, libraries, or current docs matter.
|
|
540
|
+
- If an explicit first token is a slug, treat it as the optional change id.
|
|
541
|
+
- For project-specific exploration, cite real files, functions, routes, commands, or config paths.
|
|
542
|
+
- If a finding is inferred rather than verified from code, label it "assumption:".
|
|
543
|
+
- If external research is used, include source URLs and reliability: high, medium, or low.
|
|
544
|
+
|
|
545
|
+
## Depth Control
|
|
546
|
+
|
|
547
|
+
Infer depth from the request:
|
|
548
|
+
- Quick: answer the immediate question with enough code context.
|
|
549
|
+
- Deep: multi-pass internal and external research for comparison, architecture, risk, framework design.
|
|
550
|
+
- Blocked: state what is missing and recommend next steps.
|
|
551
|
+
|
|
552
|
+
## Output
|
|
553
|
+
|
|
554
|
+
Return a concise investigation report:
|
|
555
|
+
- Findings with real file paths
|
|
556
|
+
- Options with tradeoffs
|
|
557
|
+
- Recommendation
|
|
558
|
+
- Evidence (file paths + source URLs)
|
|
559
|
+
- Next Command: /sdd-propose <change-id> "<focused change>"`,
|
|
560
|
+
},
|
|
561
|
+
|
|
562
|
+
"sdd-propose": {
|
|
563
|
+
description: "Create one focused SDD change with proposal, spec, design, and tasks",
|
|
564
|
+
agent: "sdd-planner",
|
|
565
|
+
template: `Create a compact, reviewable change plan. Stop before implementation.
|
|
566
|
+
|
|
567
|
+
## Usage
|
|
568
|
+
|
|
569
|
+
/sdd-propose "what should change"
|
|
570
|
+
/sdd-propose change-id "what should change"
|
|
571
|
+
|
|
572
|
+
## Behavior
|
|
573
|
+
|
|
574
|
+
- Parse the full request from the command text.
|
|
575
|
+
- If the first token is a lowercase slug, use it as change-id.
|
|
576
|
+
- Create artifacts in specs/active/<change-id>/.
|
|
577
|
+
- Generate: proposal.md, spec.md, design.md, tasks.md (and progress.md for large changes).
|
|
578
|
+
- Do not write implementation code.
|
|
579
|
+
- Ask at most 3 clarifying questions only if too ambiguous.
|
|
580
|
+
|
|
581
|
+
## Sizing
|
|
582
|
+
|
|
583
|
+
- Small: 1-5 tasks, existing pattern, low risk.
|
|
584
|
+
- Medium: 6-12 tasks, several files, moderate integration risk.
|
|
585
|
+
- Large: 13+ tasks, cross-cutting changes. Include progress.md.
|
|
586
|
+
|
|
587
|
+
## Required Codebase Grounding
|
|
588
|
+
|
|
589
|
+
- Find existing patterns, related modules, commands, tests, and config.
|
|
590
|
+
- Cite concrete paths in design.md.
|
|
591
|
+
- Do not claim a file exists unless verified.
|
|
592
|
+
|
|
593
|
+
## Artifact Standards
|
|
594
|
+
|
|
595
|
+
proposal.md: Problem, Goals, Non-goals, User impact, Success criteria
|
|
596
|
+
spec.md: Requirements, Acceptance criteria, Edge cases, Out of scope
|
|
597
|
+
design.md: Existing patterns found, Proposed approach, Files likely to change, File conflict map, Risks, Verification commands
|
|
598
|
+
tasks.md: Ordered checkboxes, dependencies, test steps, parallelization groups, Test Spec tables (Scenario, Input, Expected Output, Mock Requirement)
|
|
599
|
+
|
|
600
|
+
## Anti-Generic Gate
|
|
601
|
+
|
|
602
|
+
Before final output, verify:
|
|
603
|
+
- design.md references real project paths or says "not found"
|
|
604
|
+
- tasks.md contains concrete file-oriented actions
|
|
605
|
+
- Acceptance criteria are observable and testable
|
|
606
|
+
- Verification commands are project-specific
|
|
607
|
+
- Risks mention concrete failure modes
|
|
608
|
+
|
|
609
|
+
## Output
|
|
610
|
+
|
|
611
|
+
End with:
|
|
612
|
+
changed: Created specs/active/<change-id>/
|
|
613
|
+
Artifacts: proposal.md, spec.md, design.md, tasks.md, progress.md (large only)
|
|
614
|
+
Next: review the artifacts, then run /sdd-apply <change-id>.`,
|
|
615
|
+
},
|
|
616
|
+
|
|
617
|
+
"sdd-apply": {
|
|
618
|
+
description: "Implement an approved SDD change from tasks.md",
|
|
619
|
+
agent: "sdd-implementer",
|
|
620
|
+
template: `Implement an existing change from specs/active/<change-id>/.
|
|
621
|
+
|
|
622
|
+
## Usage
|
|
623
|
+
|
|
624
|
+
/sdd-apply change-id
|
|
625
|
+
|
|
626
|
+
## Preconditions
|
|
627
|
+
|
|
628
|
+
- specs/active/<change-id>/tasks.md must exist.
|
|
629
|
+
- Read proposal.md, spec.md, design.md, tasks.md, and progress.md if present.
|
|
630
|
+
- If artifacts are missing or contradictory, stop and ask.
|
|
631
|
+
|
|
632
|
+
## Rules
|
|
633
|
+
|
|
634
|
+
- Make the smallest correct code changes.
|
|
635
|
+
- Follow existing project patterns.
|
|
636
|
+
- Do not broaden scope beyond accepted artifacts.
|
|
637
|
+
- Update tasks.md checkboxes as work completes.
|
|
638
|
+
- Stop on blockers. Do not silently skip tasks.
|
|
639
|
+
|
|
640
|
+
## Test Integrity
|
|
641
|
+
|
|
642
|
+
- Source of Truth: The Test Spec table in tasks.md defines exact test cases.
|
|
643
|
+
- No Weakening: FORBIDDEN from modifying test assertions to make tests pass.
|
|
644
|
+
- Fix Implementation, Not Test: If a test fails, fix the source code, NOT the test.
|
|
645
|
+
- Report Mismatches: If the Test Spec is incorrect, STOP and report as blocker.
|
|
646
|
+
|
|
647
|
+
## Context Safety
|
|
648
|
+
|
|
649
|
+
- Treat tasks.md and progress.md as the source of truth, not chat history.
|
|
650
|
+
- Checkpoint after every 3-5 completed tasks.
|
|
651
|
+
|
|
652
|
+
## Parallel Execution
|
|
653
|
+
|
|
654
|
+
Parallelize only when touched files do not overlap. Spawn at most 3 implementer subagents per batch.
|
|
655
|
+
|
|
656
|
+
## Workflow
|
|
657
|
+
|
|
658
|
+
1. Summarize scope in 3-6 bullets.
|
|
659
|
+
2. Identify files likely to change.
|
|
660
|
+
3. Implement tasks in order.
|
|
661
|
+
4. Mark completed tasks in tasks.md.
|
|
662
|
+
5. Run targeted verification.
|
|
663
|
+
6. Report changed files and verification results.
|
|
664
|
+
|
|
665
|
+
## Output
|
|
666
|
+
|
|
667
|
+
End with:
|
|
668
|
+
changed: Implemented <change-id>
|
|
669
|
+
verified: <command> passed
|
|
670
|
+
Summary of what changed and what remains.
|
|
671
|
+
Next: run /sdd-ship <change-id> for final review.`,
|
|
672
|
+
},
|
|
673
|
+
|
|
674
|
+
"sdd-ship": {
|
|
675
|
+
description: "Final verification and readiness review for an SDD change",
|
|
676
|
+
agent: "sdd-reviewer",
|
|
677
|
+
template: `Verify a completed change before considering it ready.
|
|
678
|
+
|
|
679
|
+
## Usage
|
|
680
|
+
|
|
681
|
+
/sdd-ship change-id
|
|
682
|
+
/sdd-ship change-id "finalize"
|
|
683
|
+
|
|
684
|
+
## Behavior
|
|
685
|
+
|
|
686
|
+
- Read specs/active/<change-id>/ artifacts.
|
|
687
|
+
- Inspect implementation against artifacts.
|
|
688
|
+
- Run or recommend relevant test, lint, typecheck, build commands.
|
|
689
|
+
- Create or update verification.md.
|
|
690
|
+
- Do not make product code changes unless explicitly asked.
|
|
691
|
+
|
|
692
|
+
## Asymmetric Verification
|
|
693
|
+
|
|
694
|
+
Strict audit comparing Test Spec tables in tasks.md against actual test files:
|
|
695
|
+
- Completeness: Every row has a corresponding test case.
|
|
696
|
+
- Assertion Strength: No weakening of assertions.
|
|
697
|
+
- Mock Accuracy: Mocks match spec requirements.
|
|
698
|
+
- Halt on Violation: Report mismatches, do not auto-correct.
|
|
699
|
+
|
|
700
|
+
## Review Focus
|
|
701
|
+
|
|
702
|
+
- Requirements satisfied
|
|
703
|
+
- Tasks completed or intentionally deferred
|
|
704
|
+
- Bugs, regressions, security risks, missing tests
|
|
705
|
+
- Verification evidence
|
|
706
|
+
- Release readiness
|
|
707
|
+
|
|
708
|
+
## Finalize Behavior
|
|
709
|
+
|
|
710
|
+
When request includes "finalize", "complete", or "archive":
|
|
711
|
+
- If ready is yes, create status.md with final status.
|
|
712
|
+
- If ready is no, report blockers.
|
|
713
|
+
|
|
714
|
+
## Evidence Requirements
|
|
715
|
+
|
|
716
|
+
- Every finding must include file path, command output, browser evidence, or "assumption:" label.
|
|
717
|
+
|
|
718
|
+
## Output
|
|
719
|
+
|
|
720
|
+
Findings first (critical, major, minor), Verification results, Decision (ready: yes|no).`,
|
|
721
|
+
},
|
|
722
|
+
|
|
723
|
+
"sdd-quick": {
|
|
724
|
+
description: "Quick one-shot fix for cosmetic/config changes with CLI wrapper for deterministic checks",
|
|
725
|
+
agent: "sdd-implementer",
|
|
726
|
+
template: `Execute a small, safe change with minimal overhead. Uses CLI wrapper for classification, pre-flight, verification, and ledger. LLM is only used for the actual edit.
|
|
727
|
+
|
|
728
|
+
## Usage
|
|
729
|
+
|
|
730
|
+
/sdd-quick "fix typo: succesful -> successful"
|
|
731
|
+
/sdd-quick "rename isLoading to isFetching in auth.ts"
|
|
732
|
+
|
|
733
|
+
## Architecture: Hybrid CLI + LLM
|
|
734
|
+
|
|
735
|
+
CLI (0 tokens) -> Phase 1a: Keyword scan -> PASS/FAIL
|
|
736
|
+
LLM (~50 tokens) -> Phase 1b: Context-aware classification (if needed)
|
|
737
|
+
CLI (0 tokens) -> Phase 2: Pre-flight (lock, grep, string delta)
|
|
738
|
+
LLM (~150 tokens) -> Phase 3: Edit
|
|
739
|
+
CLI (0 tokens) -> Phase 4: Post-flight (diff, lint, typecheck, auto-revert)
|
|
740
|
+
CLI (0 tokens) -> Phase 5: Atomic ledger append
|
|
741
|
+
|
|
742
|
+
Total token cost: ~200 tokens.
|
|
743
|
+
|
|
744
|
+
## Phase 1: Classification
|
|
745
|
+
|
|
746
|
+
Run: sdd-quick classify "<request>"
|
|
747
|
+
CLI checks for operators, control flow keywords, contract path patterns.
|
|
748
|
+
If blocking keywords detected -> FAIL immediately, suggest /sdd-propose.
|
|
749
|
+
|
|
750
|
+
## Phase 2: Pre-Flight Checks
|
|
751
|
+
|
|
752
|
+
Run: sdd-quick preflight "<request>" [file-path] [old-string] [new-string]
|
|
753
|
+
Checks: lock file, cross-file scan, string length delta.
|
|
754
|
+
If FAILS -> abort. If WARNS -> show user, ask confirmation.
|
|
755
|
+
Acquire lock before proceeding.
|
|
756
|
+
|
|
757
|
+
## Phase 3: Edit
|
|
758
|
+
|
|
759
|
+
Run: sdd-quick edit-prompt "<request>" <file-path>
|
|
760
|
+
CLI reads file and generates optimized prompt.
|
|
761
|
+
Backup file, send prompt to LLM, write response.
|
|
762
|
+
If write fails -> restore from backup, FAIL.
|
|
763
|
+
|
|
764
|
+
## Phase 4: Post-Flight Verification
|
|
765
|
+
|
|
766
|
+
Run: sdd-quick postflight <backup-path> <target-path>
|
|
767
|
+
Checks: file actually changed, no extra lines beyond request.
|
|
768
|
+
Run: sdd-quick lint, sdd-quick typecheck
|
|
769
|
+
Decision: Both pass -> continue. Lint fails -> auto-revert. Typecheck fails -> auto-revert.
|
|
770
|
+
Cleanup: Remove backup, release lock.
|
|
771
|
+
|
|
772
|
+
## Phase 5: Ledger Append
|
|
773
|
+
|
|
774
|
+
Run: sdd-quick ledger append "<entry>"
|
|
775
|
+
Atomic write with temp file + rename. Auto-archive if ledger exceeds 50 entries.
|
|
776
|
+
|
|
777
|
+
## Execution Mode: Silent
|
|
778
|
+
|
|
779
|
+
Do NOT report intermediate steps. All Phase 1-4 checks performed silently via CLI calls.
|
|
780
|
+
Output ONLY the final result.
|
|
781
|
+
|
|
782
|
+
## Anti-Generic Gate
|
|
783
|
+
|
|
784
|
+
Before final output, verify all checklist items.
|
|
785
|
+
|
|
786
|
+
## Output
|
|
787
|
+
|
|
788
|
+
If successful:
|
|
789
|
+
changed: Quick fix applied — <slug>
|
|
790
|
+
type: Cosmetic | Config
|
|
791
|
+
verified: lint + typecheck passed
|
|
792
|
+
cross-file refs: <count> files
|
|
793
|
+
Log: specs/QUICKFIX_LOG.md
|
|
794
|
+
|
|
795
|
+
If aborted:
|
|
796
|
+
aborted: Quick fix rejected — <slug>
|
|
797
|
+
reason: <specific rule that blocked it>
|
|
798
|
+
suggestion: Run /sdd-propose "<request>" for full workflow.`,
|
|
799
|
+
},
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
// ─── Plugin Export ───────────────────────────────────────────────────────────
|
|
803
|
+
|
|
804
|
+
export default async ({ client, project, directory, $ }) => {
|
|
10
805
|
return {
|
|
806
|
+
agent: AGENTS,
|
|
807
|
+
|
|
11
808
|
config(cfg) {
|
|
809
|
+
// Register SDD skills path
|
|
12
810
|
const skillsDir = path.join(packageRoot, ".opencode", "skills");
|
|
13
811
|
if (fs.existsSync(skillsDir)) {
|
|
14
812
|
cfg.skills = cfg.skills || {};
|
|
@@ -17,6 +815,74 @@ export default (async ({ client, project, directory, $ }) => {
|
|
|
17
815
|
cfg.skills.paths.push(skillsDir);
|
|
18
816
|
}
|
|
19
817
|
}
|
|
818
|
+
|
|
819
|
+
// Register commands
|
|
820
|
+
cfg.command = cfg.command || {};
|
|
821
|
+
for (const [name, cmd] of Object.entries(COMMANDS)) {
|
|
822
|
+
if (!cfg.command[name]) {
|
|
823
|
+
cfg.command[name] = cmd;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// Register SDD permissions (skill: sdd-* allow)
|
|
828
|
+
if (!cfg.permission) {
|
|
829
|
+
cfg.permission = {};
|
|
830
|
+
}
|
|
831
|
+
if (!cfg.permission.skill) {
|
|
832
|
+
cfg.permission.skill = {};
|
|
833
|
+
}
|
|
834
|
+
if (!cfg.permission.skill["sdd-*"]) {
|
|
835
|
+
cfg.permission.skill["sdd-*"] = "allow";
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
// Chain other SDD plugins via config hook
|
|
839
|
+
// Load sdd-model-router
|
|
840
|
+
try {
|
|
841
|
+
const modelRouterPath = path.join(__dirname, "sdd-model-router.js");
|
|
842
|
+
if (fs.existsSync(modelRouterPath)) {
|
|
843
|
+
import(modelRouterPath).then(async (mod) => {
|
|
844
|
+
const pluginFn = mod.default;
|
|
845
|
+
if (pluginFn) {
|
|
846
|
+
const result = await pluginFn({ client, project, directory, $ });
|
|
847
|
+
if (result.config) {
|
|
848
|
+
result.config(cfg);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
} catch {
|
|
854
|
+
// sdd-model-router not available, skip
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
// Load sdd-auto-reasoning
|
|
858
|
+
try {
|
|
859
|
+
const reasoningPath = path.join(__dirname, "sdd-auto-reasoning.js");
|
|
860
|
+
if (fs.existsSync(reasoningPath)) {
|
|
861
|
+
import(reasoningPath).then(async (mod) => {
|
|
862
|
+
const pluginFn = mod.default;
|
|
863
|
+
if (pluginFn) {
|
|
864
|
+
const result = await pluginFn({ client, project, directory, $ });
|
|
865
|
+
// Merge all hooks from auto-reasoning
|
|
866
|
+
for (const [hookName, hookFn] of Object.entries(result)) {
|
|
867
|
+
if (hookName !== "config" && typeof hookFn === "function") {
|
|
868
|
+
// Chain hook — call existing then new
|
|
869
|
+
const existing = cfg[hookName];
|
|
870
|
+
if (typeof existing === "function") {
|
|
871
|
+
cfg[hookName] = async (...args) => {
|
|
872
|
+
await existing(...args);
|
|
873
|
+
await hookFn(...args);
|
|
874
|
+
};
|
|
875
|
+
} else {
|
|
876
|
+
cfg[hookName] = hookFn;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
} catch {
|
|
884
|
+
// sdd-auto-reasoning not available, skip
|
|
885
|
+
}
|
|
20
886
|
},
|
|
21
887
|
};
|
|
22
|
-
}
|
|
888
|
+
};
|