@tudeorangbiasa/sdd-multiagent-opencode 0.2.2 → 0.3.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.
@@ -1,9 +1,9 @@
1
1
  ---
2
- description: Quick one-shot fix for cosmetic/config changes with lightweight verification
2
+ description: Quick one-shot fix for cosmetic/config changes with CLI wrapper for deterministic checks
3
3
  agent: sdd-implementer
4
4
  ---
5
5
 
6
- Execute a small, safe change with minimal overhead. No full spec artifacts required.
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
7
 
8
8
  ## Usage
9
9
 
@@ -12,138 +12,169 @@ Execute a small, safe change with minimal overhead. No full spec artifacts requi
12
12
  /sdd-quick "rename isLoading to isFetching in auth.ts"
13
13
  ```
14
14
 
15
- ## Phase 1: Rule-Based Change Classification
16
-
17
- Do NOT guess the change type. Classify using these deterministic rules, evaluated in order. The first matching rule wins.
18
-
19
- ### Force → CONTRACT ( Abort → suggest `/sdd-propose`)
20
- - Change to any exported function, class, interface, or type name
21
- - Change to any file matching: `**/api/**`, `**/dto/**`, `**/schema/**`, `**/types/public-api.ts`, `**/graphql/types.ts`
22
- - Change to function signature (add/remove/rename parameter)
23
- - Change to any file explicitly marked as `@public` or `@api` in JSDoc
24
-
25
- ### Force → LOGIC (❌ Abort → suggest `/sdd-propose`)
26
- - ANY change to operators: `>`, `<`, `>=`, `<=`, `==`, `===`, `!=`, `!==`, `&&`, `||`, `!`, `?:`
27
- - ANY change to control flow keywords: `if`, `else`, `switch`, `case`, `for`, `while`, `return`, `throw`, `try`, `catch`, `finally`
28
- - ANY change to a condition expression or boolean logic
29
- - ANY change to calculation or math expression
30
- - Adding or removing a function call
31
- - Changing a function's return value
32
-
33
- ### Force CONFIG (⚠️ Allowed with warning)
34
- - Change to constant value, env var, feature flag, or config file (`*.config.*`, `.env`, `*.json`)
35
- - Change to a string that is NOT rendered in a UI component
36
-
37
- ### Default COSMETIC (✅ Allowed)
38
- - Typo fix in string literal or comment
39
- - Whitespace or formatting change
40
- - Internal variable rename (not exported)
41
- - Import reordering or unused import removal
42
- - Dead code removal
43
- - Comment addition or update
44
-
45
- If the change matches CONTRACT or LOGIC, STOP immediately. Do not proceed. Report why and suggest `/sdd-propose`.
46
-
47
- ## Phase 2: Pre-Flight Checks
48
-
49
- ### Lock File Check
50
- 1. Check if `specs/.sdd-lock` exists.
51
- 2. If it exists:
52
- - Read the PID from the lock file.
53
- - Check if that process is still running (`ps -p <PID>` or equivalent).
54
- - If PID is alive → Warn: "Another SDD process is active. Proceed anyway? (yes/no)"
55
- - If PID is dead Remove stale lock and continue.
56
- 3. If no lock exists → Create `specs/.sdd-lock` with current PID and command name.
57
-
58
- ### Cross-File Impact Scan
59
- 1. Identify the symbol, string, or pattern that will change.
60
- 2. Run a project-wide grep for that pattern.
61
- 3. Count references:
62
- - 5 references Continue
63
- - > 5 references → ⚠️ Flag as "Ripple Risk", show user the affected files, ask for confirmation before proceeding.
64
-
65
- ### String Length Check (for string changes only)
66
- 1. Calculate the length delta: `|new_length - old_length|`
67
- 2. Calculate percentage change: `delta / old_length * 100`
68
- 3. If delta > 20 characters OR percentage increase > 50%:
69
- - Flag as "UI Layout Risk"
70
- - Check if the string is in a UI component file (`.tsx`, `.vue`, `.jsx`, `.svelte`)
71
- - If in UI component Require explicit user confirmation before proceeding
72
- 4. If the string is in a non-UI file (`.ts` logic, config, etc.)Allow without flag
73
-
74
- ## Phase 3: Execute Change
75
-
76
- - Make the smallest possible change that satisfies the request.
77
- - Do NOT touch any file beyond what is strictly necessary.
78
- - Do NOT create new files.
79
- - Do NOT refactor or "improve" surrounding code.
80
- - Do NOT change logic, only what was explicitly requested.
81
-
82
- ## Phase 4: Verification
83
-
84
- ### Mandatory Checks
85
- Run the project's available verification commands. Check `package.json` scripts or equivalent:
86
-
87
- 1. **Lint**: `npm run lint` (or `pnpm lint`, `yarn lint`, etc.)
88
- 2. **Typecheck**: `npm run typecheck` (or `tsc --noEmit`, `vue-tsc`, etc.)
89
-
90
- ### Decision Table
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 > 5WARN (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
+
91
119
  | Result | Action |
92
120
  |--------|--------|
93
- | Both pass | Continue to Phase 5 |
94
- | Lint fails | Auto-revert all changes, report failure |
95
- | Typecheck fails | Auto-revert all changes, report failure |
96
- | Test fails (if run) | ⚠️ Check if failure is pre-existing or caused by this change. If caused by this change → auto-revert. If pre-existing → allow with warning. |
97
-
98
- If the project has NO lint or typecheck script → ❌ Reject, suggest `/sdd-propose` (project lacks safety net for quick changes).
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 |
99
125
 
100
- ## Phase 5: Atomic Ledger Append
126
+ ### Step 4c: Cleanup
101
127
 
102
- Do NOT create individual files per change. Append to a single ledger file.
128
+ - Remove backup file.
129
+ - Release lock: `sdd-quick lock release`
103
130
 
104
- ### Ledger File: `specs/QUICKFIX_LOG.md`
131
+ ## Phase 5: Ledger Append (CLI, 0 tokens)
105
132
 
106
- Format for each entry:
133
+ Run: `sdd-quick ledger append "<entry>"`
107
134
 
135
+ Entry format:
108
136
  ```markdown
109
137
  ## YYYY-MM-DD HH:MM — <kebab-case-slug>
110
138
 
111
139
  - **Trigger:** `/sdd-quick "<original request>"`
112
140
  - **Files:** `<file-path>` (L<line>, L<line>)
113
141
  - **Type:** Cosmetic | Config
114
- - **Verification:** `npm run lint` passed, `npm run typecheck` passed
115
- - **Cross-file refs:** <count> files affected (list if > 3)
142
+ - **Verification:** lint passed, typecheck passed
143
+ - **Cross-file refs:** <count> files affected
116
144
  - **Status:** ✅ Applied | ❌ Reverted (reason)
117
145
  ```
118
146
 
119
- ### Atomic Write Procedure
120
- 1. Read current content of `specs/QUICKFIX_LOG.md` (create if not exists, with header `# Quick Change Log`)
121
- 2. Append new entry at the END of the file
122
- 3. Write to temp file: `specs/QUICKFIX_LOG.md.tmp`
123
- 4. Atomic rename: replace `specs/QUICKFIX_LOG.md` with temp file
124
- 5. Remove `specs/.sdd-lock`
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".
125
156
 
126
- ### Ledger Maintenance
127
- If the ledger exceeds 50 entries:
128
- - Move the oldest 25 entries to `specs/QUICKFIX_LOG_ARCHIVE.md`
129
- - Keep only the most recent 25 entries in the main ledger
157
+ If a gate fails → output ONLY the abort message.
158
+ If all gates pass output ONLY the success message.
130
159
 
131
160
  ## Anti-Generic Gate
132
161
 
133
162
  Before final output, verify:
134
163
 
135
- - [ ] Change type was classified using deterministic rules, not AI judgment.
164
+ - [ ] Classification was done via CLI (not AI judgment).
136
165
  - [ ] Lock file was checked and cleaned up.
137
- - [ ] Cross-file scan was performed.
138
- - [ ] Lint and typecheck were run and passed.
139
- - [ ] Ledger was updated atomically.
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.
140
170
  - [ ] No logic, contract, or new files were touched.
171
+ - [ ] No extra lines were added beyond the requested change.
141
172
 
142
173
  If any item fails, report the failure and do not claim success.
143
174
 
144
175
  ## Output
145
176
 
146
- End with:
177
+ If successful:
147
178
 
148
179
  ```markdown
149
180
  changed: Quick fix applied — <slug>