@yunhozz/arc 0.3.2 → 0.3.4
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/MANIFEST.sha256 +105 -147
- package/README.md +3 -3
- package/claude/agents/arc-implementer.md +4 -4
- package/claude/agents/arc-planner.md +5 -5
- package/claude/agents/arc-qa.md +4 -4
- package/claude/agents/arc-reviewer.md +4 -4
- package/claude/agents/arc-scouter.md +5 -5
- package/claude/skill/SKILL.md +13 -8
- package/claude/skill/references/arc-visual-companion.md +5 -5
- package/claude/skill/references/commit.md +8 -8
- package/claude/skill/references/coordination.md +23 -21
- package/claude/skill/references/git-recovery.md +9 -4
- package/claude/skill/references/handoff-prep.md +13 -15
- package/claude/skill/references/handoff.md +22 -22
- package/claude/skill/references/limits.md +2 -2
- package/claude/skill/references/planning.md +20 -15
- package/claude/skill/references/verification.md +9 -9
- package/claude/skill/references/worktree-creation.md +14 -0
- package/codex/agents/arc-implementer.toml +4 -4
- package/codex/agents/arc-planner.toml +4 -4
- package/codex/agents/arc-qa.toml +4 -4
- package/codex/agents/arc-reviewer.toml +4 -4
- package/codex/agents/arc-scouter.toml +4 -4
- package/codex/skill/SKILL.md +12 -8
- package/codex/skill/references/arc-visual-companion.md +2 -2
- package/codex/skill/references/commit.md +8 -8
- package/codex/skill/references/coordination.md +22 -20
- package/codex/skill/references/git-recovery.md +5 -9
- package/codex/skill/references/handoff-prep.md +9 -9
- package/codex/skill/references/handoff.md +20 -20
- package/codex/skill/references/limits.md +2 -2
- package/codex/skill/references/planning.md +15 -15
- package/codex/skill/references/verification.md +10 -10
- package/codex/skill/references/worktree-creation.md +20 -0
- package/lib/installer/global-config.mjs +2 -2
- package/lib/installer/manifest.mjs +10 -9
- package/lib/installer/package-references.mjs +2 -2
- package/lib/installer/plan.mjs +3 -1
- package/lib/installer/skill-sources.mjs +23 -0
- package/lib/installer/superpowers.mjs +5 -5
- package/lib/policy/role-policy.json +10 -10
- package/lib/prompts/agent-fragments.json +16 -16
- package/lib/runtime/bootstrap.mjs +1 -1
- package/lib/runtime/local-cli.mjs +10 -20
- package/lib/runtime/role-bridge.mjs +2 -4
- package/lib/runtime/role-dispatch-policy.mjs +4 -9
- package/lib/runtime/role-routing.mjs +1 -2
- package/lib/watch/dispatch.mjs +10 -2
- package/lib/watch/git.mjs +4 -2
- package/lib/watch/index.mjs +16 -8
- package/lib/watch/model.mjs +8 -4
- package/lib/watch/normalize-claude.mjs +89 -7
- package/lib/watch/normalize-codex.mjs +15 -11
- package/lib/watch/render.mjs +73 -19
- package/lib/watch/scope.mjs +5 -5
- package/lib/watch/watcher.mjs +110 -10
- package/package.json +2 -1
- package/scripts/check-installer-parity.mjs +3 -1
- package/scripts/update-manifest.mjs +1 -1
- package/scripts/update-runtime-assets.mjs +1 -1
- package/{codex → shared}/skill/references/handoff-worktree.md +21 -20
- package/{codex → shared}/skill/runtime/bootstrap.mjs +1 -1
- package/{codex → shared}/skill/runtime/local-cli.mjs +10 -20
- package/{codex → shared}/skill/runtime/role-bridge.mjs +2 -4
- package/{claude → shared}/skill/runtime/role-dispatch-policy.mjs +4 -9
- package/{claude → shared}/skill/runtime/role-policy.json +10 -10
- package/{claude → shared}/skill/runtime/role-routing.mjs +1 -2
- package/claude/skill/runtime/bootstrap.mjs +0 -38
- package/claude/skill/runtime/local-cli.mjs +0 -248
- package/claude/skill/runtime/role-bridge.mjs +0 -227
- package/codex/skill/references/brainstorming.md +0 -316
- package/codex/skill/references/builder-check-prompt.md +0 -23
- package/codex/skill/references/scripts/frame-template.html +0 -213
- package/codex/skill/references/scripts/helper.js +0 -167
- package/codex/skill/references/scripts/server.cjs +0 -723
- package/codex/skill/references/scripts/start-server.sh +0 -216
- package/codex/skill/references/scripts/stop-server.sh +0 -120
- package/codex/skill/references/superpowers-LICENSE +0 -21
- package/codex/skill/references/superpowers-provenance.json +0 -26
- package/codex/skill/references/test-driven-development.md +0 -330
- package/codex/skill/references/visual-companion.md +0 -299
- package/codex/skill/references/writing-good-tests.md +0 -198
- package/codex/skill/references/writing-plans.md +0 -204
- package/codex/skill/runtime/acceptance.mjs +0 -68
- package/codex/skill/runtime/adapters/claude.mjs +0 -86
- package/codex/skill/runtime/adapters/codex.mjs +0 -65
- package/codex/skill/runtime/assignment.mjs +0 -42
- package/codex/skill/runtime/capabilities.mjs +0 -44
- package/codex/skill/runtime/cli.mjs +0 -8
- package/codex/skill/runtime/command.mjs +0 -38
- package/codex/skill/runtime/cooperative-schema.mjs +0 -87
- package/codex/skill/runtime/cooperative.mjs +0 -239
- package/codex/skill/runtime/evaluate.mjs +0 -331
- package/codex/skill/runtime/external.mjs +0 -51
- package/codex/skill/runtime/gate.mjs +0 -71
- package/codex/skill/runtime/git-evidence.mjs +0 -258
- package/codex/skill/runtime/git-query.mjs +0 -88
- package/codex/skill/runtime/identity.mjs +0 -49
- package/codex/skill/runtime/operations.mjs +0 -6
- package/codex/skill/runtime/role-bridge-args.mjs +0 -148
- package/codex/skill/runtime/role-dispatch-policy.mjs +0 -110
- package/codex/skill/runtime/role-dispatch-store.mjs +0 -134
- package/codex/skill/runtime/role-observe.mjs +0 -299
- package/codex/skill/runtime/role-policy.json +0 -654
- package/codex/skill/runtime/role-routing-config.mjs +0 -19
- package/codex/skill/runtime/role-routing.mjs +0 -233
- package/codex/skill/runtime/role-supervisor.mjs +0 -356
- package/codex/skill/runtime/schema.mjs +0 -98
- package/codex/skill/runtime/scope.mjs +0 -36
- package/codex/skill/runtime/store.mjs +0 -94
- package/codex/skill/runtime/target-preparation.mjs +0 -110
- package/codex/skill/runtime/verification.mjs +0 -125
- /package/{claude → shared}/skill/references/brainstorming.md +0 -0
- /package/{claude → shared}/skill/references/builder-check-prompt.md +0 -0
- /package/{claude → shared}/skill/references/scripts/frame-template.html +0 -0
- /package/{claude → shared}/skill/references/scripts/helper.js +0 -0
- /package/{claude → shared}/skill/references/scripts/server.cjs +0 -0
- /package/{claude → shared}/skill/references/scripts/start-server.sh +0 -0
- /package/{claude → shared}/skill/references/scripts/stop-server.sh +0 -0
- /package/{claude → shared}/skill/references/superpowers-LICENSE +0 -0
- /package/{claude → shared}/skill/references/superpowers-provenance.json +0 -0
- /package/{claude → shared}/skill/references/test-driven-development.md +0 -0
- /package/{claude → shared}/skill/references/visual-companion.md +0 -0
- /package/{claude → shared}/skill/references/writing-good-tests.md +0 -0
- /package/{claude → shared}/skill/references/writing-plans.md +0 -0
- /package/{claude → shared}/skill/runtime/acceptance.mjs +0 -0
- /package/{claude → shared}/skill/runtime/adapters/claude.mjs +0 -0
- /package/{claude → shared}/skill/runtime/adapters/codex.mjs +0 -0
- /package/{claude → shared}/skill/runtime/assignment.mjs +0 -0
- /package/{claude → shared}/skill/runtime/capabilities.mjs +0 -0
- /package/{claude → shared}/skill/runtime/cli.mjs +0 -0
- /package/{claude → shared}/skill/runtime/command.mjs +0 -0
- /package/{claude → shared}/skill/runtime/cooperative-schema.mjs +0 -0
- /package/{claude → shared}/skill/runtime/cooperative.mjs +0 -0
- /package/{claude → shared}/skill/runtime/evaluate.mjs +0 -0
- /package/{claude → shared}/skill/runtime/external.mjs +0 -0
- /package/{claude → shared}/skill/runtime/gate.mjs +0 -0
- /package/{claude → shared}/skill/runtime/git-evidence.mjs +0 -0
- /package/{claude → shared}/skill/runtime/git-query.mjs +0 -0
- /package/{claude → shared}/skill/runtime/identity.mjs +0 -0
- /package/{claude → shared}/skill/runtime/operations.mjs +0 -0
- /package/{claude → shared}/skill/runtime/role-bridge-args.mjs +0 -0
- /package/{claude → shared}/skill/runtime/role-dispatch-store.mjs +0 -0
- /package/{claude → shared}/skill/runtime/role-observe.mjs +0 -0
- /package/{claude → shared}/skill/runtime/role-routing-config.mjs +0 -0
- /package/{claude → shared}/skill/runtime/role-supervisor.mjs +0 -0
- /package/{claude → shared}/skill/runtime/schema.mjs +0 -0
- /package/{claude → shared}/skill/runtime/scope.mjs +0 -0
- /package/{claude → shared}/skill/runtime/store.mjs +0 -0
- /package/{claude → shared}/skill/runtime/target-preparation.mjs +0 -0
- /package/{claude → shared}/skill/runtime/verification.mjs +0 -0
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: test-driven-development
|
|
3
|
-
description: Use when implementing any feature or bugfix, before writing implementation code
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Test-Driven Development (TDD)
|
|
7
|
-
|
|
8
|
-
## Overview
|
|
9
|
-
|
|
10
|
-
Write the test first. Watch it fail. Write minimal code to pass.
|
|
11
|
-
|
|
12
|
-
**Core principle:** If you didn't watch the test fail, you don't know if it tests the right thing.
|
|
13
|
-
|
|
14
|
-
**Violating the letter of the rules is violating the spirit of the rules.**
|
|
15
|
-
|
|
16
|
-
## When to Use
|
|
17
|
-
|
|
18
|
-
**Always:**
|
|
19
|
-
- New features
|
|
20
|
-
- Bug fixes
|
|
21
|
-
- Refactoring
|
|
22
|
-
- Behavior changes
|
|
23
|
-
|
|
24
|
-
**Exceptions (ask your human partner):**
|
|
25
|
-
- Throwaway prototypes
|
|
26
|
-
- Generated code
|
|
27
|
-
- Configuration files
|
|
28
|
-
|
|
29
|
-
Thinking "skip TDD just this once"? Stop. That's rationalization.
|
|
30
|
-
|
|
31
|
-
## The Iron Law
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Write code before the test? Delete it. Start over.
|
|
38
|
-
|
|
39
|
-
**No exceptions:**
|
|
40
|
-
- Don't keep it as "reference"
|
|
41
|
-
- Don't "adapt" it while writing tests
|
|
42
|
-
- Don't look at it
|
|
43
|
-
- Delete means delete
|
|
44
|
-
|
|
45
|
-
Implement fresh from tests. Period.
|
|
46
|
-
|
|
47
|
-
## Red-Green-Refactor
|
|
48
|
-
|
|
49
|
-
```dot
|
|
50
|
-
digraph tdd_cycle {
|
|
51
|
-
rankdir=LR;
|
|
52
|
-
red [label="RED\nWrite failing test", shape=box, style=filled, fillcolor="#ffcccc"];
|
|
53
|
-
verify_red [label="Verify fails\ncorrectly", shape=diamond];
|
|
54
|
-
green [label="GREEN\nMinimal code", shape=box, style=filled, fillcolor="#ccffcc"];
|
|
55
|
-
verify_green [label="Verify passes\nAll green", shape=diamond];
|
|
56
|
-
refactor [label="REFACTOR\nClean up", shape=box, style=filled, fillcolor="#ccccff"];
|
|
57
|
-
next [label="Next", shape=ellipse];
|
|
58
|
-
|
|
59
|
-
red -> verify_red;
|
|
60
|
-
verify_red -> green [label="yes"];
|
|
61
|
-
verify_red -> red [label="wrong\nfailure"];
|
|
62
|
-
green -> verify_green;
|
|
63
|
-
verify_green -> refactor [label="yes"];
|
|
64
|
-
verify_green -> green [label="no"];
|
|
65
|
-
refactor -> verify_green [label="stay\ngreen"];
|
|
66
|
-
verify_green -> next;
|
|
67
|
-
next -> red;
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### RED - Write Failing Test
|
|
72
|
-
|
|
73
|
-
Write one minimal test showing what should happen.
|
|
74
|
-
|
|
75
|
-
<Good>
|
|
76
|
-
```typescript
|
|
77
|
-
test('retries failed operations 3 times', async () => {
|
|
78
|
-
let attempts = 0;
|
|
79
|
-
const operation = () => {
|
|
80
|
-
attempts++;
|
|
81
|
-
if (attempts < 3) throw new Error('fail');
|
|
82
|
-
return 'success';
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const result = await retryOperation(operation);
|
|
86
|
-
|
|
87
|
-
expect(result).toBe('success');
|
|
88
|
-
expect(attempts).toBe(3);
|
|
89
|
-
});
|
|
90
|
-
```
|
|
91
|
-
Clear name, tests real behavior, one thing
|
|
92
|
-
</Good>
|
|
93
|
-
|
|
94
|
-
<Bad>
|
|
95
|
-
```typescript
|
|
96
|
-
test('retry works', async () => {
|
|
97
|
-
const mock = jest.fn()
|
|
98
|
-
.mockRejectedValueOnce(new Error())
|
|
99
|
-
.mockRejectedValueOnce(new Error())
|
|
100
|
-
.mockResolvedValueOnce('success');
|
|
101
|
-
await retryOperation(mock);
|
|
102
|
-
expect(mock).toHaveBeenCalledTimes(3);
|
|
103
|
-
});
|
|
104
|
-
```
|
|
105
|
-
Vague name, tests mock not code
|
|
106
|
-
</Bad>
|
|
107
|
-
|
|
108
|
-
**Requirements:**
|
|
109
|
-
- One behavior
|
|
110
|
-
- Clear name
|
|
111
|
-
- Real code (no mocks unless unavoidable)
|
|
112
|
-
|
|
113
|
-
### Verify RED - Watch It Fail
|
|
114
|
-
|
|
115
|
-
**MANDATORY. Never skip.**
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
npm test path/to/test.test.ts
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Confirm:
|
|
122
|
-
- Test fails (not errors)
|
|
123
|
-
- Failure message is expected
|
|
124
|
-
- Fails because feature missing (not typos)
|
|
125
|
-
|
|
126
|
-
**Test passes?** You're testing existing behavior. Fix test.
|
|
127
|
-
|
|
128
|
-
**Test errors?** Fix error, re-run until it fails correctly.
|
|
129
|
-
|
|
130
|
-
### GREEN - Minimal Code
|
|
131
|
-
|
|
132
|
-
Write simplest code to pass the test.
|
|
133
|
-
|
|
134
|
-
<Good>
|
|
135
|
-
```typescript
|
|
136
|
-
async function retryOperation<T>(fn: () => Promise<T>): Promise<T> {
|
|
137
|
-
for (let i = 0; i < 3; i++) {
|
|
138
|
-
try {
|
|
139
|
-
return await fn();
|
|
140
|
-
} catch (e) {
|
|
141
|
-
if (i === 2) throw e;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
throw new Error('unreachable');
|
|
145
|
-
}
|
|
146
|
-
```
|
|
147
|
-
Just enough to pass
|
|
148
|
-
</Good>
|
|
149
|
-
|
|
150
|
-
<Bad>
|
|
151
|
-
```typescript
|
|
152
|
-
async function retryOperation<T>(
|
|
153
|
-
fn: () => Promise<T>,
|
|
154
|
-
options?: {
|
|
155
|
-
maxRetries?: number;
|
|
156
|
-
backoff?: 'linear' | 'exponential';
|
|
157
|
-
onRetry?: (attempt: number) => void;
|
|
158
|
-
}
|
|
159
|
-
): Promise<T> {
|
|
160
|
-
// YAGNI
|
|
161
|
-
}
|
|
162
|
-
```
|
|
163
|
-
Over-engineered
|
|
164
|
-
</Bad>
|
|
165
|
-
|
|
166
|
-
Don't add features, refactor other code, or "improve" beyond the test.
|
|
167
|
-
|
|
168
|
-
### Verify GREEN - Watch It Pass
|
|
169
|
-
|
|
170
|
-
**MANDATORY.**
|
|
171
|
-
|
|
172
|
-
```bash
|
|
173
|
-
npm test path/to/test.test.ts
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
Confirm:
|
|
177
|
-
- Test passes
|
|
178
|
-
- Other tests still pass
|
|
179
|
-
- Output pristine (no errors, warnings)
|
|
180
|
-
|
|
181
|
-
**Test fails?** Fix code, not test.
|
|
182
|
-
|
|
183
|
-
**Other tests fail?** Fix now.
|
|
184
|
-
|
|
185
|
-
**"Other tests" means the project's suite, not just your file.** A
|
|
186
|
-
green run of the test you wrote is not a green suite. Before you call
|
|
187
|
-
the change done, run the project's test command (bare `pytest`,
|
|
188
|
-
`npm test`, `cargo test` — whatever the repo uses) even when your task
|
|
189
|
-
named only one test file. A scope statement in your task bounds the
|
|
190
|
-
deliverable, not your verification. Any failure that run shows —
|
|
191
|
-
including one you didn't cause — goes in your report by name; a red
|
|
192
|
-
test you watched scroll past and didn't mention is a report falsified
|
|
193
|
-
by omission.
|
|
194
|
-
|
|
195
|
-
### REFACTOR - Clean Up
|
|
196
|
-
|
|
197
|
-
After green only:
|
|
198
|
-
- Remove duplication
|
|
199
|
-
- Improve names
|
|
200
|
-
- Extract helpers
|
|
201
|
-
|
|
202
|
-
Keep tests green. Don't add behavior.
|
|
203
|
-
|
|
204
|
-
### Repeat
|
|
205
|
-
|
|
206
|
-
Next failing test for next feature.
|
|
207
|
-
|
|
208
|
-
## Good Tests
|
|
209
|
-
|
|
210
|
-
| Quality | Good | Bad |
|
|
211
|
-
|---------|------|-----|
|
|
212
|
-
| **Minimal** | One thing. "and" in name? Split it. | `test('validates email and domain and whitespace')` |
|
|
213
|
-
| **Clear** | Name describes behavior | `test('test1')` |
|
|
214
|
-
| **Shows intent** | Demonstrates desired API | Obscures what code should do |
|
|
215
|
-
|
|
216
|
-
When writing or changing any test, read [writing-good-tests.md](writing-good-tests.md) for the rules that keep tests honest:
|
|
217
|
-
- Name the production change that would make the test fail — before writing it
|
|
218
|
-
- Assert on real behavior, never on mock behavior
|
|
219
|
-
- Keep test-only code in test utilities, out of production classes
|
|
220
|
-
- Understand a dependency's side effects before mocking it
|
|
221
|
-
|
|
222
|
-
## Common Rationalizations
|
|
223
|
-
|
|
224
|
-
| Excuse | Reality |
|
|
225
|
-
|--------|---------|
|
|
226
|
-
| "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
|
|
227
|
-
| "I'll test after" | Tests written after pass immediately — which proves nothing. They may test the wrong thing, test the implementation instead of the behavior, or miss the edge case you forgot. You never watched it fail, so you never proved it can catch the bug. Test-first forces that failure. |
|
|
228
|
-
| "Tests after achieve same goals (spirit not ritual)" | Tests-after answer "what does this do?"; tests-first answer "what should this do?" Tests written after are biased by the code you already wrote — you verify the cases you remembered, not the ones you'd have discovered. Coverage without proof the tests work. |
|
|
229
|
-
| "Already manually tested" | Manual testing is ad-hoc: no record of what you covered, no way to re-run it when the code changes, easy to forget cases under pressure. "Worked when I tried it" ≠ comprehensive. Automated tests run the same way every time. |
|
|
230
|
-
| "Deleting X hours is wasteful" | Sunk cost fallacy — that time is already spent either way. The real choice: rewrite with TDD (high confidence) vs. keep it and bolt tests on after (low confidence, likely bugs). Keeping code you can't trust is the waste. |
|
|
231
|
-
| "Keep as reference, write tests first" | You'll adapt it. That's testing after. Delete means delete. |
|
|
232
|
-
| "Need to explore first" | Fine. Throw away exploration, start with TDD. |
|
|
233
|
-
| "Test hard = design unclear" | Listen to test. Hard to test = hard to use. |
|
|
234
|
-
| "TDD will slow me down" | TDD IS the pragmatic path: catches bugs before commit, prevents regressions, lets you refactor without fear. "Pragmatic" shortcuts mean debugging in production — slower, not faster. |
|
|
235
|
-
| "Manual test faster" | Manual doesn't prove edge cases. You'll re-test every change. |
|
|
236
|
-
| "Existing code has no tests" | You're improving it. Add tests for existing code. |
|
|
237
|
-
|
|
238
|
-
## Red Flags - STOP and Start Over
|
|
239
|
-
|
|
240
|
-
- Code before test
|
|
241
|
-
- Test after implementation
|
|
242
|
-
- Test passes immediately
|
|
243
|
-
- Can't explain why test failed
|
|
244
|
-
- Tests added "later"
|
|
245
|
-
- Rationalizing "just this once"
|
|
246
|
-
- "I already manually tested it"
|
|
247
|
-
- "Tests after achieve the same purpose"
|
|
248
|
-
- "It's about spirit not ritual"
|
|
249
|
-
- "Keep as reference" or "adapt existing code"
|
|
250
|
-
- "Already spent X hours, deleting is wasteful"
|
|
251
|
-
- "TDD is dogmatic, I'm being pragmatic"
|
|
252
|
-
- "This is different because..."
|
|
253
|
-
|
|
254
|
-
**All of these mean: Delete code. Start over with TDD.**
|
|
255
|
-
|
|
256
|
-
## Example: Bug Fix
|
|
257
|
-
|
|
258
|
-
**Bug:** Empty email accepted
|
|
259
|
-
|
|
260
|
-
**RED**
|
|
261
|
-
```typescript
|
|
262
|
-
test('rejects empty email', async () => {
|
|
263
|
-
const result = await submitForm({ email: '' });
|
|
264
|
-
expect(result.error).toBe('Email required');
|
|
265
|
-
});
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
**Verify RED**
|
|
269
|
-
```bash
|
|
270
|
-
$ npm test
|
|
271
|
-
FAIL: expected 'Email required', got undefined
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
**GREEN**
|
|
275
|
-
```typescript
|
|
276
|
-
function submitForm(data: FormData) {
|
|
277
|
-
if (!data.email?.trim()) {
|
|
278
|
-
return { error: 'Email required' };
|
|
279
|
-
}
|
|
280
|
-
// ...
|
|
281
|
-
}
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
**Verify GREEN**
|
|
285
|
-
```bash
|
|
286
|
-
$ npm test
|
|
287
|
-
PASS
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
**REFACTOR**
|
|
291
|
-
Extract validation for multiple fields if needed.
|
|
292
|
-
|
|
293
|
-
## Verification Checklist
|
|
294
|
-
|
|
295
|
-
Before marking work complete:
|
|
296
|
-
|
|
297
|
-
- [ ] Every new function/method has a test
|
|
298
|
-
- [ ] Watched each test fail before implementing
|
|
299
|
-
- [ ] Each test failed for expected reason (feature missing, not typo)
|
|
300
|
-
- [ ] Wrote minimal code to pass each test
|
|
301
|
-
- [ ] All tests pass
|
|
302
|
-
- [ ] Output pristine (no errors, warnings)
|
|
303
|
-
- [ ] Tests use real code (mocks only if unavoidable)
|
|
304
|
-
- [ ] Edge cases and errors covered
|
|
305
|
-
|
|
306
|
-
Can't check all boxes? You skipped TDD. Start over.
|
|
307
|
-
|
|
308
|
-
## When Stuck
|
|
309
|
-
|
|
310
|
-
| Problem | Solution |
|
|
311
|
-
|---------|----------|
|
|
312
|
-
| Don't know how to test | Write wished-for API. Write assertion first. Ask your human partner. |
|
|
313
|
-
| Test too complicated | Design too complicated. Simplify interface. |
|
|
314
|
-
| Must mock everything | Code too coupled. Use dependency injection. |
|
|
315
|
-
| Test setup huge | Extract helpers. Still complex? Simplify design. |
|
|
316
|
-
|
|
317
|
-
## Debugging Integration
|
|
318
|
-
|
|
319
|
-
Bug found? Write failing test reproducing it. Follow TDD cycle. Test proves fix and prevents regression.
|
|
320
|
-
|
|
321
|
-
Never fix bugs without a test.
|
|
322
|
-
|
|
323
|
-
## Final Rule
|
|
324
|
-
|
|
325
|
-
```
|
|
326
|
-
Production code → test exists and failed first
|
|
327
|
-
Otherwise → not TDD
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
No exceptions without your human partner's permission.
|
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
# Visual Companion Guide
|
|
2
|
-
|
|
3
|
-
Browser-based visual brainstorming companion for showing mockups, diagrams, and options.
|
|
4
|
-
|
|
5
|
-
## When to Use
|
|
6
|
-
|
|
7
|
-
Decide per-question, not per-session. The test: **would the user understand this better by seeing it than reading it?**
|
|
8
|
-
|
|
9
|
-
**Use the browser** when the content itself is visual:
|
|
10
|
-
|
|
11
|
-
- **UI mockups** — wireframes, layouts, navigation structures, component designs
|
|
12
|
-
- **Architecture diagrams** — system components, data flow, relationship maps
|
|
13
|
-
- **Side-by-side visual comparisons** — comparing two layouts, two color schemes, two design directions
|
|
14
|
-
- **Design polish** — when the question is about look and feel, spacing, visual hierarchy
|
|
15
|
-
- **Spatial relationships** — state machines, flowcharts, entity relationships rendered as diagrams
|
|
16
|
-
|
|
17
|
-
**Use the terminal** when the content is text or tabular:
|
|
18
|
-
|
|
19
|
-
- **Requirements and scope questions** — "what does X mean?", "which features are in scope?"
|
|
20
|
-
- **Conceptual A/B/C choices** — picking between approaches described in words
|
|
21
|
-
- **Tradeoff lists** — pros/cons, comparison tables
|
|
22
|
-
- **Technical decisions** — API design, data modeling, architectural approach selection
|
|
23
|
-
- **Clarifying questions** — anything where the answer is words, not a visual preference
|
|
24
|
-
|
|
25
|
-
A question *about* a UI topic is not automatically a visual question. "What kind of wizard do you want?" is conceptual — use the terminal. "Which of these wizard layouts feels right?" is visual — use the browser.
|
|
26
|
-
|
|
27
|
-
## How It Works
|
|
28
|
-
|
|
29
|
-
The server watches a directory for HTML files and serves the newest one to the browser. You write HTML content to `screen_dir`, the user sees it in their browser and can click to select options. Selections are recorded to `state_dir/events` that you read on your next turn.
|
|
30
|
-
|
|
31
|
-
**Content fragments vs full documents:** If your HTML file starts with `<!DOCTYPE` or `<html`, the server serves it as-is (just injects the helper script). Otherwise, the server automatically wraps your content in the frame template — adding the header, CSS theme, connection status, and all interactive infrastructure. **Write content fragments by default.** Only write full documents when you need complete control over the page.
|
|
32
|
-
|
|
33
|
-
## Starting a Session
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
# Start AFTER the user approves the companion. --open auto-opens their browser on
|
|
37
|
-
# the first screen; --project-dir persists mockups and enables same-port restart.
|
|
38
|
-
bash scripts/start-server.sh --project-dir /path/to/project --open
|
|
39
|
-
|
|
40
|
-
# Returns: {"type":"server-started","port":52341,
|
|
41
|
-
# "url":"http://localhost:52341/?key=ab12…",
|
|
42
|
-
# "screen_dir":"/path/to/project/.superpowers/brainstorm/12345-1706000000/content",
|
|
43
|
-
# "state_dir":"/path/to/project/.superpowers/brainstorm/12345-1706000000/state"}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Save `screen_dir` and `state_dir` from the response. With `--open`, the browser opens itself when you push the first screen — you don't need to ask the user to open it, but still share the URL as a fallback (headless/remote setups won't auto-open).
|
|
47
|
-
|
|
48
|
-
**The URL contains a session key (`?key=…`).** The server rejects any request
|
|
49
|
-
without it, so always give the user the **complete** URL from the `url` field —
|
|
50
|
-
never strip the query string, and never hand out a bare `http://host:port`. The
|
|
51
|
-
key gates HTTP and WebSocket access so a stray browser tab or another machine on
|
|
52
|
-
the network can't read the screens or inject events. After the first load the
|
|
53
|
-
browser remembers the key via a cookie, so reloads and `/files/*` assets work
|
|
54
|
-
without repeating it.
|
|
55
|
-
|
|
56
|
-
**Finding connection info:** The server writes its startup JSON to `$STATE_DIR/server-info`. If you launched the server in the background and didn't capture stdout, read that file to get the URL and port. When using `--project-dir`, check `<project>/.superpowers/brainstorm/` for the session directory.
|
|
57
|
-
|
|
58
|
-
**Note:** Pass the project root as `--project-dir` so mockups persist in `.superpowers/brainstorm/` and survive server restarts. Without it, files go to `/tmp` and get cleaned up. Remind the user to add `.superpowers/` to `.gitignore` if it's not already there.
|
|
59
|
-
|
|
60
|
-
**Launching the server by platform:**
|
|
61
|
-
|
|
62
|
-
**Claude Code:**
|
|
63
|
-
```bash
|
|
64
|
-
# Default mode works — the script backgrounds the server itself.
|
|
65
|
-
bash scripts/start-server.sh --project-dir /path/to/project --open
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
On Windows, the script auto-detects and switches to foreground mode (which blocks the tool call). Use `run_in_background: true` on the Bash tool call so the server survives across conversation turns, then read `$STATE_DIR/server-info` on the next turn to get the URL and port.
|
|
69
|
-
|
|
70
|
-
**Codex:**
|
|
71
|
-
```bash
|
|
72
|
-
# Codex reaps background processes. The script auto-detects CODEX_CI and
|
|
73
|
-
# switches to foreground mode. Run it normally — no extra flags needed.
|
|
74
|
-
bash scripts/start-server.sh --project-dir /path/to/project --open
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
**Gemini CLI:**
|
|
78
|
-
```bash
|
|
79
|
-
# Use --foreground and set is_background: true on your shell tool call
|
|
80
|
-
# so the process survives across turns
|
|
81
|
-
bash scripts/start-server.sh --project-dir /path/to/project --open --foreground
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
**Copilot CLI:**
|
|
85
|
-
```bash
|
|
86
|
-
# Start it with Copilot CLI's non-blocking/background shell mechanism so the
|
|
87
|
-
# server survives across turns. Keep --foreground so the harness, not the
|
|
88
|
-
# script, owns backgrounding. The launcher is a .sh, so invoke it via bash
|
|
89
|
-
# (on Windows, call Git Bash's bash.exe from the PowerShell tool).
|
|
90
|
-
bash scripts/start-server.sh --project-dir /path/to/project --open --foreground
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
**Other environments:** The server must keep running in the background across conversation turns. If your environment reaps detached processes, use `--foreground` and launch the command with your platform's background execution mechanism.
|
|
94
|
-
|
|
95
|
-
If the URL is unreachable from your browser (common in remote/containerized setups), bind a non-loopback host:
|
|
96
|
-
|
|
97
|
-
```bash
|
|
98
|
-
bash scripts/start-server.sh \
|
|
99
|
-
--project-dir /path/to/project \
|
|
100
|
-
--host 0.0.0.0 \
|
|
101
|
-
--url-host localhost
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Use `--url-host` to control what hostname is printed in the returned URL JSON.
|
|
105
|
-
|
|
106
|
-
## The Loop
|
|
107
|
-
|
|
108
|
-
1. **Check server is alive**, then **write HTML** to a new file in `screen_dir`:
|
|
109
|
-
- **Required: confirm the server is alive before referring to the URL or pushing a screen.** Check that `$STATE_DIR/server-info` exists and `$STATE_DIR/server-stopped` does not. If it has shut down, restart it with `start-server.sh` using the **same `--project-dir`** — it reuses the same port, so the user's open tab reconnects on its own (it shows a "paused" overlay while the server is down) and you don't need to send a new URL. The server auto-exits after 4 hours idle (configurable with `--idle-timeout-minutes`).
|
|
110
|
-
- Use semantic filenames: `platform.html`, `visual-style.html`, `layout.html`
|
|
111
|
-
- **Never reuse filenames** — each screen gets a fresh file
|
|
112
|
-
- Use your file-creation tool — **never use cat/heredoc** (dumps noise into terminal)
|
|
113
|
-
- Server automatically serves the newest file
|
|
114
|
-
|
|
115
|
-
2. **Tell user what to expect and end your turn:**
|
|
116
|
-
- Remind them of the URL (every step, not just first)
|
|
117
|
-
- Give a brief text summary of what's on screen (e.g., "Showing 3 layout options for the homepage")
|
|
118
|
-
- Ask them to respond in the terminal: "Take a look and let me know what you think. Click to select an option if you'd like."
|
|
119
|
-
|
|
120
|
-
3. **On your next turn** — after the user responds in the terminal:
|
|
121
|
-
- Read `$STATE_DIR/events` if it exists — this contains the user's browser interactions (clicks, selections) as JSON lines
|
|
122
|
-
- Merge with the user's terminal text to get the full picture
|
|
123
|
-
- The terminal message is the primary feedback; `state_dir/events` provides structured interaction data
|
|
124
|
-
|
|
125
|
-
4. **Iterate or advance** — if feedback changes current screen, write a new file (e.g., `layout-v2.html`). Only move to the next question when the current step is validated.
|
|
126
|
-
|
|
127
|
-
5. **Unload when returning to terminal** — when the next step doesn't need the browser (e.g., a clarifying question, a tradeoff discussion), push a waiting screen to clear the stale content:
|
|
128
|
-
|
|
129
|
-
```html
|
|
130
|
-
<!-- filename: waiting.html (or waiting-2.html, etc.) -->
|
|
131
|
-
<div style="display:flex;align-items:center;justify-content:center;min-height:60vh">
|
|
132
|
-
<p class="subtitle">Continuing in terminal...</p>
|
|
133
|
-
</div>
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
This prevents the user from staring at a resolved choice while the conversation has moved on. When the next visual question comes up, push a new content file as usual.
|
|
137
|
-
|
|
138
|
-
6. Repeat until done.
|
|
139
|
-
|
|
140
|
-
## Writing Content Fragments
|
|
141
|
-
|
|
142
|
-
Write just the content that goes inside the page. The server wraps it in the frame template automatically (header, theme CSS, connection status, and all interactive infrastructure).
|
|
143
|
-
|
|
144
|
-
**Minimal example:**
|
|
145
|
-
|
|
146
|
-
```html
|
|
147
|
-
<h2>Which layout works better?</h2>
|
|
148
|
-
<p class="subtitle">Consider readability and visual hierarchy</p>
|
|
149
|
-
|
|
150
|
-
<div class="options">
|
|
151
|
-
<div class="option" data-choice="a" onclick="toggleSelect(this)">
|
|
152
|
-
<div class="letter">A</div>
|
|
153
|
-
<div class="content">
|
|
154
|
-
<h3>Single Column</h3>
|
|
155
|
-
<p>Clean, focused reading experience</p>
|
|
156
|
-
</div>
|
|
157
|
-
</div>
|
|
158
|
-
<div class="option" data-choice="b" onclick="toggleSelect(this)">
|
|
159
|
-
<div class="letter">B</div>
|
|
160
|
-
<div class="content">
|
|
161
|
-
<h3>Two Column</h3>
|
|
162
|
-
<p>Sidebar navigation with main content</p>
|
|
163
|
-
</div>
|
|
164
|
-
</div>
|
|
165
|
-
</div>
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
That's it. No `<html>`, no CSS, no `<script>` tags needed. The server provides all of that.
|
|
169
|
-
|
|
170
|
-
## CSS Classes Available
|
|
171
|
-
|
|
172
|
-
The frame template provides these CSS classes for your content:
|
|
173
|
-
|
|
174
|
-
### Options (A/B/C choices)
|
|
175
|
-
|
|
176
|
-
```html
|
|
177
|
-
<div class="options">
|
|
178
|
-
<div class="option" data-choice="a" onclick="toggleSelect(this)">
|
|
179
|
-
<div class="letter">A</div>
|
|
180
|
-
<div class="content">
|
|
181
|
-
<h3>Title</h3>
|
|
182
|
-
<p>Description</p>
|
|
183
|
-
</div>
|
|
184
|
-
</div>
|
|
185
|
-
</div>
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
**Multi-select:** Add `data-multiselect` to the container to let users select multiple options. Each click toggles the item's selected styling.
|
|
189
|
-
|
|
190
|
-
```html
|
|
191
|
-
<div class="options" data-multiselect>
|
|
192
|
-
<!-- same option markup — users can select/deselect multiple -->
|
|
193
|
-
</div>
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
### Cards (visual designs)
|
|
197
|
-
|
|
198
|
-
```html
|
|
199
|
-
<div class="cards">
|
|
200
|
-
<div class="card" data-choice="design1" onclick="toggleSelect(this)">
|
|
201
|
-
<div class="card-image"><!-- mockup content --></div>
|
|
202
|
-
<div class="card-body">
|
|
203
|
-
<h3>Name</h3>
|
|
204
|
-
<p>Description</p>
|
|
205
|
-
</div>
|
|
206
|
-
</div>
|
|
207
|
-
</div>
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
### Mockup container
|
|
211
|
-
|
|
212
|
-
```html
|
|
213
|
-
<div class="mockup">
|
|
214
|
-
<div class="mockup-header">Preview: Dashboard Layout</div>
|
|
215
|
-
<div class="mockup-body"><!-- your mockup HTML --></div>
|
|
216
|
-
</div>
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
### Split view (side-by-side)
|
|
220
|
-
|
|
221
|
-
```html
|
|
222
|
-
<div class="split">
|
|
223
|
-
<div class="mockup"><!-- left --></div>
|
|
224
|
-
<div class="mockup"><!-- right --></div>
|
|
225
|
-
</div>
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
### Pros/Cons
|
|
229
|
-
|
|
230
|
-
```html
|
|
231
|
-
<div class="pros-cons">
|
|
232
|
-
<div class="pros"><h4>Pros</h4><ul><li>Benefit</li></ul></div>
|
|
233
|
-
<div class="cons"><h4>Cons</h4><ul><li>Drawback</li></ul></div>
|
|
234
|
-
</div>
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
### Mock elements (wireframe building blocks)
|
|
238
|
-
|
|
239
|
-
```html
|
|
240
|
-
<div class="mock-nav">Logo | Home | About | Contact</div>
|
|
241
|
-
<div style="display: flex;">
|
|
242
|
-
<div class="mock-sidebar">Navigation</div>
|
|
243
|
-
<div class="mock-content">Main content area</div>
|
|
244
|
-
</div>
|
|
245
|
-
<button class="mock-button">Action Button</button>
|
|
246
|
-
<input class="mock-input" placeholder="Input field">
|
|
247
|
-
<div class="placeholder">Placeholder area</div>
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
### Typography and sections
|
|
251
|
-
|
|
252
|
-
- `h2` — page title
|
|
253
|
-
- `h3` — section heading
|
|
254
|
-
- `.subtitle` — secondary text below title
|
|
255
|
-
- `.section` — content block with bottom margin
|
|
256
|
-
- `.label` — small uppercase label text
|
|
257
|
-
|
|
258
|
-
## Browser Events Format
|
|
259
|
-
|
|
260
|
-
When the user clicks options in the browser, their interactions are recorded to `$STATE_DIR/events` (one JSON object per line). The file is cleared automatically when you push a new screen.
|
|
261
|
-
|
|
262
|
-
```jsonl
|
|
263
|
-
{"type":"click","choice":"a","text":"Option A - Simple Layout","timestamp":1706000101}
|
|
264
|
-
{"type":"click","choice":"c","text":"Option C - Complex Grid","timestamp":1706000108}
|
|
265
|
-
{"type":"click","choice":"b","text":"Option B - Hybrid","timestamp":1706000115}
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
The full event stream shows the user's exploration path — they may click multiple options before settling. The last `choice` event is typically the final selection, but the pattern of clicks can reveal hesitation or preferences worth asking about.
|
|
269
|
-
|
|
270
|
-
If `$STATE_DIR/events` doesn't exist, the user didn't interact with the browser — use only their terminal text.
|
|
271
|
-
|
|
272
|
-
## Design Tips
|
|
273
|
-
|
|
274
|
-
- **Scale fidelity to the question** — wireframes for layout, polish for polish questions
|
|
275
|
-
- **Explain the question on each page** — "Which layout feels more professional?" not just "Pick one"
|
|
276
|
-
- **Iterate before advancing** — if feedback changes current screen, write a new version
|
|
277
|
-
- **2-4 options max** per screen
|
|
278
|
-
- **Use real content when it matters** — for a photography portfolio, use actual images (Unsplash). Placeholder content obscures design issues.
|
|
279
|
-
- **Keep mockups simple** — focus on layout and structure, not pixel-perfect design
|
|
280
|
-
|
|
281
|
-
## File Naming
|
|
282
|
-
|
|
283
|
-
- Use semantic names: `platform.html`, `visual-style.html`, `layout.html`
|
|
284
|
-
- Never reuse filenames — each screen must be a new file
|
|
285
|
-
- For iterations: append version suffix like `layout-v2.html`, `layout-v3.html`
|
|
286
|
-
- Server serves newest file by modification time
|
|
287
|
-
|
|
288
|
-
## Cleaning Up
|
|
289
|
-
|
|
290
|
-
```bash
|
|
291
|
-
bash scripts/stop-server.sh $SESSION_DIR
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
If the session used `--project-dir`, mockup files persist in `.superpowers/brainstorm/` for later reference. Only `/tmp` sessions get deleted on stop.
|
|
295
|
-
|
|
296
|
-
## Reference
|
|
297
|
-
|
|
298
|
-
- Frame template (CSS reference): `scripts/frame-template.html`
|
|
299
|
-
- Helper script (client-side): `scripts/helper.js`
|