@tudeorangbiasa/sdd-multiagent-opencode 0.2.1 → 0.2.3

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.
@@ -0,0 +1,196 @@
1
+ ---
2
+ description: Quick one-shot fix for cosmetic/config changes with CLI wrapper for deterministic checks
3
+ agent: sdd-implementer
4
+ ---
5
+
6
+ Execute a small, safe change with minimal overhead. Uses CLI wrapper for Phase 1-2 (classification, pre-flight) and Phase 4-5 (verification, ledger). LLM is only used for Phase 3 (the actual edit).
7
+
8
+ ## Usage
9
+
10
+ ```text
11
+ /sdd-quick "fix typo: succesful -> successful"
12
+ /sdd-quick "rename isLoading to isFetching in auth.ts"
13
+ ```
14
+
15
+ ## Architecture: Hybrid CLI + LLM
16
+
17
+ ```
18
+ CLI (0 tokens) → Phase 1a: Keyword scan → PASS/FAIL
19
+ ↓ (if ambiguous)
20
+ LLM (~50 tokens) → Phase 1b: Context-aware classification
21
+
22
+ CLI (0 tokens) → Phase 2: Pre-flight (lock, grep, string delta)
23
+
24
+ LLM (~150 tokens) → Phase 3: Edit (full file return for < 500 lines)
25
+
26
+ CLI (0 tokens) → Phase 4: Post-flight (actual diff, lint, typecheck, auto-revert)
27
+
28
+ CLI (0 tokens) → Phase 5: Atomic ledger append
29
+ ```
30
+
31
+ Total token cost: ~200 tokens (vs ~1000 for all-LLM approach).
32
+
33
+ ## Phase 1: Classification
34
+
35
+ ### Step 1a: CLI Keyword Scan (0 tokens)
36
+
37
+ Run: `sdd-quick classify "<request>"`
38
+
39
+ The CLI checks for:
40
+ - Operators: `>`, `<`, `>=`, `<=`, `==`, `===`, `!=`, `!==`, `&&`, `||`, `!`, `?:`
41
+ - Control flow keywords: `if`, `else`, `switch`, `case`, `for`, `while`, `return`, `throw`, `try`, `catch`, `finally`
42
+ - Contract path patterns: `**/api/**`, `**/dto/**`, `**/schema/**`, `**/types/public-api.ts`
43
+
44
+ **If CLI detects blocking keywords → FAIL immediately.** Output:
45
+ ```
46
+ aborted: Quick fix rejected — <slug>
47
+ reason: Request contains <operator/keyword> which indicates a logic change.
48
+ suggestion: Run `/sdd-propose "<request>"` for full workflow.
49
+ ```
50
+
51
+ **If CLI detects no blocking keywords → proceed to Step 1b only if a file path was provided and the file exists.**
52
+
53
+ ### Step 1b: Context-Aware Classification (~50 tokens, only if needed)
54
+
55
+ If the CLI found ambiguous keywords but a file path was provided, run:
56
+ ```
57
+ sdd-quick classify "<request>" <file-path>
58
+ ```
59
+
60
+ The CLI returns a prompt. Send this prompt to the LLM and get back a classification result.
61
+
62
+ **If LLM says `{"safe": false}` → FAIL.** Report reason and suggest `/sdd-propose`.
63
+ **If LLM says `{"safe": true}` → proceed to Phase 2.**
64
+
65
+ ## Phase 2: Pre-Flight Checks (CLI, 0 tokens)
66
+
67
+ Run: `sdd-quick preflight "<request>" [file-path] [old-string] [new-string]`
68
+
69
+ The CLI checks:
70
+ 1. **Lock file**: Is another SDD process active? If yes → FAIL.
71
+ 2. **Cross-file scan**: How many files reference the pattern? If > 5 → WARN (show user, ask confirmation).
72
+ 3. **String length delta**: If old/new strings provided, check delta > 20 chars or > 50% increase → WARN (UI layout risk).
73
+
74
+ **If preflight FAILS → abort.**
75
+ **If preflight PASSES → proceed to Phase 3.**
76
+ **If preflight WARNS → show user, ask "Proceed? (yes/no)".**
77
+
78
+ Before proceeding, acquire lock:
79
+ ```
80
+ sdd-quick lock acquire "sdd-quick" "<slug>"
81
+ ```
82
+
83
+ ## Phase 3: Edit (LLM, ~150 tokens)
84
+
85
+ ### Step 3a: Generate Edit Prompt
86
+
87
+ Run: `sdd-quick edit-prompt "<request>" <file-path>`
88
+
89
+ The CLI reads the file and generates an optimized prompt:
90
+ - If file < 500 lines → "Return the ENTIRE file content with the change applied."
91
+ - If file >= 500 lines → "Use search-replace blocks: <<<SEARCH ... >>> <<<REPLACE ... >>>"
92
+
93
+ ### Step 3b: Apply Edit
94
+
95
+ 1. **Backup the file**: Copy to `<file>.sdd-quick-backup`
96
+ 2. **Send the prompt to LLM** and get the response.
97
+ 3. **Write the response** to the target file.
98
+ - For full-file return: write directly.
99
+ - For search-replace blocks: parse and apply each block.
100
+ 4. **If write fails** (parse error, etc.) → restore from backup, FAIL.
101
+
102
+ ## Phase 4: Post-Flight Verification (CLI, 0 tokens)
103
+
104
+ ### Step 4a: Verify Actual Changes
105
+
106
+ Run: `sdd-quick postflight <backup-path> <target-path>`
107
+
108
+ The CLI checks:
109
+ - Was the file actually changed? If no → FAIL (nothing to commit).
110
+ - Did the LLM add extra lines beyond the request? If > 3 extra lines → AUTO-REVERT, FAIL.
111
+
112
+ ### Step 4b: Run Lint and Typecheck
113
+
114
+ Run: `sdd-quick lint`
115
+ Run: `sdd-quick typecheck`
116
+
117
+ **Decision table:**
118
+
119
+ | Result | Action |
120
+ |--------|--------|
121
+ | Both pass | Continue to Phase 5 |
122
+ | Lint fails | Auto-revert from backup, FAIL |
123
+ | Typecheck fails | Auto-revert from backup, FAIL |
124
+ | Neither available | WARN (project lacks safety net), continue |
125
+
126
+ ### Step 4c: Cleanup
127
+
128
+ - Remove backup file.
129
+ - Release lock: `sdd-quick lock release`
130
+
131
+ ## Phase 5: Ledger Append (CLI, 0 tokens)
132
+
133
+ Run: `sdd-quick ledger append "<entry>"`
134
+
135
+ Entry format:
136
+ ```markdown
137
+ ## YYYY-MM-DD HH:MM — <kebab-case-slug>
138
+
139
+ - **Trigger:** `/sdd-quick "<original request>"`
140
+ - **Files:** `<file-path>` (L<line>, L<line>)
141
+ - **Type:** Cosmetic | Config
142
+ - **Verification:** lint passed, typecheck passed
143
+ - **Cross-file refs:** <count> files affected
144
+ - **Status:** ✅ Applied | ❌ Reverted (reason)
145
+ ```
146
+
147
+ The CLI handles atomic write (via temp file + rename) and automatic archiving if ledger exceeds 50 entries.
148
+
149
+ ## Execution Mode: Silent
150
+
151
+ Do NOT report intermediate steps. Do NOT narrate your process.
152
+ All Phase 1-4 checks must be performed silently via CLI calls.
153
+
154
+ Output ONLY the final result in the format below.
155
+ No chain of thought. No step-by-step. No "I'm now checking X".
156
+
157
+ If a gate fails → output ONLY the abort message.
158
+ If all gates pass → output ONLY the success message.
159
+
160
+ ## Anti-Generic Gate
161
+
162
+ Before final output, verify:
163
+
164
+ - [ ] Classification was done via CLI (not AI judgment).
165
+ - [ ] Lock file was checked and cleaned up.
166
+ - [ ] Pre-flight checks passed (or user confirmed warnings).
167
+ - [ ] Edit was applied and post-flight verification passed.
168
+ - [ ] Lint and typecheck were run (or project lacks them).
169
+ - [ ] Ledger was updated atomically via CLI.
170
+ - [ ] No logic, contract, or new files were touched.
171
+ - [ ] No extra lines were added beyond the requested change.
172
+
173
+ If any item fails, report the failure and do not claim success.
174
+
175
+ ## Output
176
+
177
+ If successful:
178
+
179
+ ```markdown
180
+ changed: Quick fix applied — <slug>
181
+ type: Cosmetic | Config
182
+ verified: lint + typecheck passed
183
+ cross-file refs: <count> files
184
+
185
+ Log: specs/QUICKFIX_LOG.md
186
+
187
+ Next: commit the change or run `/sdd-quick` again.
188
+ ```
189
+
190
+ If aborted:
191
+
192
+ ```markdown
193
+ aborted: Quick fix rejected — <slug>
194
+ reason: <specific rule that blocked it>
195
+ suggestion: Run `/sdd-propose "<request>"` for full workflow.
196
+ ```
@@ -21,6 +21,15 @@ Verify a completed change before considering it ready.
21
21
  - Do not make product code changes unless the user explicitly asks for fixes.
22
22
  - If the user asks to finalize, mark the change complete only when readiness is `yes`.
23
23
 
24
+ ## Asymmetric Verification
25
+
26
+ Perform a strict audit comparing the "Test Spec" tables in `tasks.md` against the actual test files (`*.test.ts`):
27
+
28
+ - **Completeness**: Ensure every row in the Test Spec table has a corresponding test case in the code.
29
+ - **Assertion Strength**: Check for "weakening" (e.g., spec says `expect(status).toBe(401)` but code says `expect(status).toBeGreaterThan(400)`). This is a VIOLATION.
30
+ - **Mock Accuracy**: Verify mocks match the "Mock Requirement" column in the spec.
31
+ - **Halt on Violation**: If you find a violation, DO NOT attempt to auto-correct. Mark `ready: no` and report the specific mismatch in findings.
32
+
24
33
  ## Review Focus
25
34
 
26
35
  - Requirements satisfied
@@ -13,7 +13,8 @@
13
13
  "explorer": "FREE: DeepSeek v4 Flash — fast readonly exploration, token-efficient",
14
14
  "implementer": "FREE: DeepSeek v4 Flash — code generation, high token usage",
15
15
  "verifier": "FREE: Qwen3.6 Plus — multimodal for Chrome DevTools screenshots",
16
- "reviewer": "FREE: MiniMax M2.5 — structured code review output"
16
+ "reviewer": "FREE: MiniMax M2.5 — structured code review output",
17
+ "quick": "FREE: Qwen3.6 Plus or DeepSeek v4 Flash — minimal prompt for small edits"
17
18
  }
18
19
  },
19
20
  "defaultPrimary": "openai/gpt-5.5",
@@ -24,6 +25,7 @@
24
25
  "sdd-explorer": "opencode/deepseek-v4-flash-free",
25
26
  "sdd-implementer": "opencode/deepseek-v4-flash-free",
26
27
  "sdd-verifier": "opencode/qwen3.6-plus-free",
27
- "sdd-reviewer": "opencode/minimax-m2.5-free"
28
+ "sdd-reviewer": "opencode/minimax-m2.5-free",
29
+ "sdd-quick": "opencode/qwen3.6-plus-free"
28
30
  }
29
31
  }
@@ -10,12 +10,14 @@
10
10
  "sdd-explorer": "low",
11
11
  "sdd-implementer": "medium",
12
12
  "sdd-verifier": "medium",
13
- "sdd-reviewer": "medium"
13
+ "sdd-reviewer": "medium",
14
+ "sdd-quick": "low"
14
15
  },
15
16
  "commands": {
16
17
  "sdd-explore": "medium",
17
18
  "sdd-propose": "high",
18
19
  "sdd-apply": "medium",
19
- "sdd-ship": "medium"
20
+ "sdd-ship": "medium",
21
+ "sdd-quick": "low"
20
22
  }
21
23
  }
package/GUIDE.md CHANGED
@@ -1,21 +1,77 @@
1
1
  # SDD Multi-Agent OpenCode Guide
2
2
 
3
- This kit exposes one small workflow for OpenCode:
3
+ This kit exposes five core commands for OpenCode:
4
4
 
5
5
  ```text
6
- /sdd-explore -> /sdd-propose -> /sdd-apply -> /sdd-ship
6
+ /sdd-construct -> /sdd-explore -> /sdd-propose -> /sdd-apply -> /sdd-ship
7
+ /sdd-quick (standalone for small fixes)
7
8
  ```
8
9
 
9
- It is inspired by spec-driven development, but it is not a port of another tool. The goal is to make OpenCode safer on real projects by separating investigation, planning, implementation, and final verification.
10
+ It is inspired by spec-driven development and Matt Pocock's skill-driven engineering workflow. The goal is to make OpenCode safer on real projects by separating investigation, planning, implementation, and final verification — with type-aware guardrails for different project types.
10
11
 
11
12
  ## Commands
12
13
 
13
14
  | Command | Purpose | Writes Code? |
14
15
  |---------|---------|--------------|
16
+ | `/sdd-construct` | Initialize SDD workflow for a new or existing project | Yes (config files) |
15
17
  | `/sdd-explore` | Investigate unclear ideas, bugs, or code areas | No |
16
18
  | `/sdd-propose` | Create one focused change plan | No |
17
19
  | `/sdd-apply` | Implement an approved change | Yes |
18
20
  | `/sdd-ship` | Verify readiness before merge/release | No, unless explicitly asked |
21
+ | `/sdd-quick` | Lightweight cosmetic/config fix (~200 tokens) | Yes |
22
+
23
+ ## One-Time Project Setup
24
+
25
+ ### `/sdd-construct`
26
+
27
+ Run this once at the start of a project to set up the "spine" — stack detection, domain glossary, model routing, and type-specific guardrails.
28
+
29
+ ```text
30
+ /sdd-construct
31
+ /sdd-construct "e-commerce platform for digital goods"
32
+ ```
33
+
34
+ **What it does:**
35
+
36
+ 1. **Phase 1: Stack Detection**
37
+ - Empty directory guard → asks user for project type
38
+ - Quick sniff test → classifies clear patterns (Next.js, Laravel, etc.) instantly
39
+ - Conditional subagent exploration → only for unclear/complex projects
40
+ - Three-layer fallback: explorer → direct read → user input
41
+
42
+ 2. **Phase 2: Grilling Session** (one question at a time)
43
+ - Section A: Project Vision (all types)
44
+ - Section B: Constraints & Preferences (all types)
45
+ - Section C: Model Budget (all types)
46
+ - Section D: Issue Tracker (all types)
47
+ - Section E: Domain Glossary (all types)
48
+ - Section F: Type-specific guardrails (conditional)
49
+
50
+ 3. **Phase 3: Scaffold Artifacts**
51
+ - `.sdd/project-profile.json`, `.sdd/model-profile.json`, `.sdd/reasoning-profile.json`
52
+ - `CONTEXT.md` (domain glossary)
53
+ - `docs/adr/0001-project-initialization.md`
54
+ - Type-specific artifacts (conditional):
55
+
56
+ | Project Type | Artifacts |
57
+ |-------------|-----------|
58
+ | **frontend** | `DESIGN.md` (locked tokens), design rules in `AGENTS.md` |
59
+ | **backend** | `API_CONTRACT.md`, `SECURITY_RULES.md` |
60
+ | **library/sdk** | `PUBLIC_API.md`, `VERSIONING.md` |
61
+ | **cli** | `COMMAND_STRUCTURE.md` |
62
+ | **fullstack** | `DESIGN.md` + `API_CONTRACT.md` |
63
+
64
+ 4. **Phase 4: Verification** — checks all artifacts exist
65
+
66
+ **Project Type Classification:**
67
+
68
+ | Type | Signal Pattern | Example |
69
+ |------|---------------|---------|
70
+ | **frontend** | UI framework + styling + component dir, NO server | React + Tailwind + `components/` |
71
+ | **backend** | Server framework + NO UI framework | Express, Fastify, Laravel, Django |
72
+ | **library/sdk** | `exports` in package.json + NO entry point + NO server | Utility package, SDK |
73
+ | **cli** | `bin` in package.json + NO server + NO UI framework | CLI tool, scaffolding tool |
74
+ | **fullstack** | UI framework + server framework | Next.js App Router + API routes |
19
75
 
20
76
  ## Default Flow
21
77
 
@@ -61,6 +117,15 @@ specs/active/<change-id>/
61
117
  └── progress.md optional for large changes
62
118
  ```
63
119
 
120
+ **Test Spec Tables:** For tasks involving logic, `tasks.md` includes structured Test Spec tables:
121
+
122
+ | Scenario | Input | Expected Output | Mock Requirement |
123
+ |----------|-------|-----------------|------------------|
124
+ | Invalid email | `email: "abc"` | `400 Bad Request` | No mock needed |
125
+ | Valid login | `email: "a@b.c", pass: "123"` | `200 OK + token` | Mock DB query |
126
+
127
+ The implementer must translate this table exactly into test code.
128
+
64
129
  Review these files before applying. This is the agreement point.
65
130
 
66
131
  ### `/sdd-apply`
@@ -73,6 +138,12 @@ Use this after the proposal is accepted.
73
138
 
74
139
  It reads the artifacts, implements `tasks.md`, updates checkboxes, and runs targeted verification when possible.
75
140
 
141
+ **Test Integrity Rules:**
142
+ - **Source of Truth**: The Test Spec table in `tasks.md` defines exact test cases
143
+ - **No Weakening**: Forbidden from modifying assertions to make tests pass
144
+ - **Fix Implementation, Not Test**: If a test fails, fix source code, not the test
145
+ - **Report Mismatches**: If the Test Spec is incorrect, STOP and report it
146
+
76
147
  For large changes, it uses `progress.md` as a checkpoint so work can resume without relying on chat history. If tasks touch disjoint files, it can run safe batches in parallel through subagents; otherwise it runs sequentially.
77
148
 
78
149
  ### `/sdd-ship`
@@ -89,6 +160,54 @@ It audits the implementation against the artifacts and writes:
89
160
  specs/active/<change-id>/verification.md
90
161
  ```
91
162
 
163
+ **Asymmetric Verification:**
164
+ - **Completeness**: Every row in the Test Spec table has a corresponding test case
165
+ - **Assertion Strength**: Detects "weakening" (e.g., spec says `toBe(401)` but code says `toBeTruthy()`)
166
+ - **Mock Accuracy**: Verifies mocks match the spec
167
+ - **Halt on Violation**: If a violation is found, marks `ready: no` and reports — NO auto-correction
168
+
169
+ ### `/sdd-quick`
170
+
171
+ Use this for small, safe cosmetic/config changes — typo fixes, variable renames, config value changes.
172
+
173
+ ```text
174
+ /sdd-quick "fix typo: succesful -> successful"
175
+ /sdd-quick "rename isLoading to isFetching in auth.ts"
176
+ /sdd-quick "change MAX_RETRIES from 3 to 5"
177
+ ```
178
+
179
+ **What it does (hybrid CLI + LLM, ~200 tokens):**
180
+
181
+ 1. **Phase 1a**: CLI keyword scan (0 tokens) — detects operators, control flow keywords
182
+ 2. **Phase 1b**: Context-aware classification (~50 tokens) — only if ambiguous
183
+ 3. **Phase 2**: CLI pre-flight (0 tokens) — lock check, grep scan, string delta
184
+ 4. **Phase 3**: LLM edit (~150 tokens) — full file return for < 500 lines
185
+ 5. **Phase 4**: CLI post-flight (0 tokens) — actual diff, lint, typecheck, auto-revert
186
+ 6. **Phase 5**: CLI ledger append (0 tokens) — atomic write to `specs/QUICKFIX_LOG.md`
187
+
188
+ **Blocked automatically** (no LLM invoked):
189
+ - Logic changes (operators, control flow)
190
+ - Contract boundary files (`**/api/**`, `**/dto/**`, `**/schema/**`)
191
+ - Exported function/class/type name changes
192
+
193
+ **Warns and asks confirmation:**
194
+ - Cross-file references > 5
195
+ - String length delta > 20 chars or > 50% increase (UI layout risk)
196
+ - Another SDD process is active (lock file)
197
+
198
+ ## Example: New Project
199
+
200
+ ```text
201
+ /sdd-construct "task management app for teams"
202
+ -> detects Next.js + TypeScript + Tailwind
203
+ -> classifies as: fullstack
204
+ -> asks: vision, constraints, model budget, issue tracker, domain terms
205
+ -> generates: DESIGN.md (locked tokens), API_CONTRACT.md, CONTEXT.md, ADR
206
+ /sdd-propose auth-login "add email/password login with JWT"
207
+ /sdd-apply auth-login
208
+ /sdd-ship auth-login
209
+ ```
210
+
92
211
  ## Example: New Feature
93
212
 
94
213
  ```text
@@ -115,9 +234,24 @@ specs/active/<change-id>/verification.md
115
234
  /sdd-ship admin-ui-components
116
235
  ```
117
236
 
237
+ ## Example: Quick Fix
238
+
239
+ ```text
240
+ /sdd-quick "fix typo: 'succesful' -> 'successful'"
241
+ -> CLI: no blocking keywords, no contract path, 1 cross-file ref
242
+ -> LLM: change string in src/messages.ts
243
+ -> CLI: lint passed, typecheck passed, ledger updated
244
+ -> ✅ Applied (~200 tokens)
245
+
246
+ /sdd-quick "Ganti > jadi >= di validator.ts"
247
+ -> CLI: detected operator '>' → blocked
248
+ -> ❌ Abort: "Request contains operators which indicates a logic change."
249
+ -> Suggestion: Run `/sdd-propose "Ganti > jadi >= di validator.ts"`
250
+ ```
251
+
118
252
  ## Design Principles
119
253
 
120
- - Four commands only by default.
254
+ - Five commands + one quick-fix command.
121
255
  - No fake flags like `--deep` or `--until-finish`.
122
256
  - No source code changes during explore/propose.
123
257
  - One change folder per unit of work.
@@ -126,3 +260,6 @@ specs/active/<change-id>/verification.md
126
260
  - Long-running apply work must checkpoint to `progress.md`.
127
261
  - Parallel execution is a capability inside `/sdd-apply`, not a separate command.
128
262
  - Verification is a first-class step, not a vague final message.
263
+ - Type-aware scaffolding: frontend gets DESIGN.md, backend gets API_CONTRACT.md, library gets PUBLIC_API.md.
264
+ - Test-driven: Test Spec tables in tasks.md, Test Integrity rules in apply, Asymmetric Verification in ship.
265
+ - CLI-first for quick fixes: deterministic checks in Node.js, LLM only for the edit.