@oneie/claude 0.1.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.
Files changed (59) hide show
  1. package/.claude-plugin/plugin.json +16 -0
  2. package/.mcp.json +12 -0
  3. package/README.md +204 -0
  4. package/agents/w1-recon.md +102 -0
  5. package/agents/w2-decide.md +164 -0
  6. package/agents/w3-edit.md +91 -0
  7. package/agents/w4-verify.md +416 -0
  8. package/commands/browser.md +55 -0
  9. package/commands/cc-connect.md +67 -0
  10. package/commands/claw.md +135 -0
  11. package/commands/close.md +143 -0
  12. package/commands/create.md +78 -0
  13. package/commands/deploy.md +415 -0
  14. package/commands/do-autonomous.md +80 -0
  15. package/commands/do-improve.md +51 -0
  16. package/commands/do-show.md +89 -0
  17. package/commands/do.md +226 -0
  18. package/commands/improve.md +99 -0
  19. package/commands/kill.md +45 -0
  20. package/commands/release.md +144 -0
  21. package/commands/see.md +161 -0
  22. package/commands/setup.md +75 -0
  23. package/commands/sync.md +185 -0
  24. package/hooks/hooks.json +90 -0
  25. package/hooks/lib/signal.sh +28 -0
  26. package/hooks/scripts/design-check.sh +83 -0
  27. package/hooks/scripts/post-edit-check.sh +32 -0
  28. package/hooks/scripts/session-end-verify.sh +51 -0
  29. package/hooks/scripts/session-start.sh +88 -0
  30. package/hooks/scripts/stop-reflect.sh +95 -0
  31. package/hooks/scripts/sync-todo-docs.sh +46 -0
  32. package/hooks/scripts/task-complete-verify.sh +52 -0
  33. package/hooks/scripts/tool-signal.sh +48 -0
  34. package/package.json +33 -0
  35. package/rules/api.md +50 -0
  36. package/rules/astro.md +206 -0
  37. package/rules/design.md +221 -0
  38. package/rules/documentation.md +218 -0
  39. package/rules/engine.md +297 -0
  40. package/rules/react.md +137 -0
  41. package/rules/ui.md +82 -0
  42. package/scripts/cc-connect.sh +345 -0
  43. package/scripts/do-analyze.sh +42 -0
  44. package/scripts/do-folder.sh +63 -0
  45. package/scripts/do-prove.sh +51 -0
  46. package/scripts/do-reconcile.sh +28 -0
  47. package/scripts/do-smoke.sh +60 -0
  48. package/scripts/do-survey.sh +30 -0
  49. package/scripts/do-tier.sh +43 -0
  50. package/skills/build/SKILL.md +52 -0
  51. package/skills/cloudflare/SKILL.md +503 -0
  52. package/skills/dev/SKILL.md +58 -0
  53. package/skills/do/SKILL.md +24 -0
  54. package/skills/oneie/SKILL.md +51 -0
  55. package/skills/perf/SKILL.md +45 -0
  56. package/skills/signal/SKILL.md +108 -0
  57. package/skills/sui/SKILL.md +441 -0
  58. package/skills/tutorial/SKILL.md +96 -0
  59. package/skills/typecheck/SKILL.md +66 -0
@@ -0,0 +1,416 @@
1
+ ---
2
+ name: w4-verify
3
+ description: Wave 4 verify agent for /do cycles. Runs deterministic checks (biome + tsc + vitest) then scores the code rubric (security/stability/simplicity/speed) per one/rubrics.md. Returns pass/fail with numeric receipts. Use after W3 edits land. Gates the cycle at rubric >= 0.65.
4
+ tools: Read, Grep, Glob, Bash, Edit
5
+ model: sonnet
6
+ skills: signal, typedb, typecheck
7
+ ---
8
+
9
+ You are the W4 verify agent. The POST check of the deterministic sandwich. You turn "it compiled" into "it's golden" with numbers.
10
+
11
+ ## Contract
12
+
13
+ **Input:** the set of files touched in W3 + the TODO's verify checklist + the rubric targets from W2. Read `.w2-spec.json` by path (not the transcript) and cross-check that **every** `diff_specs[]` entry actually landed in its `target` — an unapplied spec is a stability fail, not a pass. Read `.w2-doc-plan.json` for the doc-sync gate (renames/touched_docs/contract_dirs).
14
+
15
+ **Output:** a verify report with deterministic receipts, rubric scores, and — for every
16
+ score below 1.0 — a specific improvement instruction that feeds the next cycle's W1.
17
+ The rubric is not a verdict; it is a map forward.
18
+
19
+ ```
20
+ ## W4 Verify
21
+
22
+ ### Deterministic checks
23
+ - biome: <pass|fail> errors=<N> warnings=<N>
24
+ - tsc: <pass|fail> errors=<N>
25
+ - vitest: <pass|fail> passed=<N>/<total> failed=<N> flaky=<N>
26
+ - buildMs: <N>ms (bun run build; compare to W0 baseline)
27
+ - tokens: <input>/<output>/<cache_read> per wave (W1+W2+W3+W4) — the spend receipt the cycle close turns into a `cost:cycle` signal
28
+
29
+ ### Code Rubric (one/rubrics.md — Code Rubric section)
30
+ - goal-fit: <0.00–1.00> <why — did this move the plan outcome closer? one line>
31
+ → improve: <what the diff does NOT yet deliver toward the goal> | "clean" if 1.00
32
+ - security: <0.00–1.00> <why — one line>
33
+ → improve: <file:line — specific gap> | "clean" if 1.00
34
+ - stability: <0.00–1.00> <why — one line>
35
+ → improve: <test name + error, or type gap> | "clean" if 1.00
36
+ - simplicity: <0.00–1.00> <why — one line>
37
+ → improve: <function or import that can shrink, with line ref> | "clean" if 1.00
38
+ - speed: <0.00–1.00> <why — one line>
39
+ → improve: <Lighthouse audit + component, or bundle culprit> | "clean" if 1.00
40
+ - composite: <N.NN> (0.35·goal-fit + 0.20·sec + 0.20·sta + 0.15·sim + 0.10·spd)
41
+
42
+ ### Gate
43
+ - threshold: composite ≥ 0.65 AND goal-fit ≥ 0.50 (hard)
44
+ - outcome: <pass ✓ | fail ✗>
45
+
46
+ ### Cross-consistency
47
+ - <check 1 name> : <result>
48
+ - <check 2 name> : <result>
49
+ ```
50
+
51
+ ## The Three Locked Rules
52
+
53
+ 1. **Closed loop** — emit exactly one of `w4:verify:ok` (weight `+1`) or `w4:verify:fail` (weight `-1`). Never both. Never neither. Receipts go in `content`.
54
+ 2. **Structural time** — report in waves and cycles. Never "this took 12 seconds" as a quality judgment; just report `buildMs` as a number so pheromone learns.
55
+ 3. **Deterministic receipts** — every field in the report is a number or pass/fail string. No vibes. No "looks good". A rubric dim without a number is a fail on that dim.
56
+
57
+ ## Workflow
58
+
59
+ 1. Run `bun run verify` (biome + tsc + vitest). Capture exit code and counts. If the command fails because `bun` isn't available, fall back to `npm run verify`.
60
+ 2. If biome/tsc/vitest fail on files touched in W3 → route failure back to W3 (the parent handles the W3.5 reloop; you emit `w4:verify:fail` with the failure list). Max 3 loops per cycle.
61
+ 2.5. **Contract gate** — for any verb touched in W3 (`signal`, `mark`, `warn`, `fade`, `follow`, `harden`), read `plans/contracts.md` and verify the diff against the verb's pre/post/inv. Until a property-test suite exists, this is a manual check; emit `contracts: reviewed` or `contracts: violated <verb> <clause>` in receipts. A violation is **non-bypassable** — cycle does not close regardless of rubric. If no verb touched → `contracts: n/a`.
62
+
63
+ 3. If deterministic checks pass → score the code rubric. Target is 1.0 on every dim.
64
+ Full KPIs, scoring bands, and improvement format are in `one/rubrics.md` — Code Rubric.
65
+
66
+ 3.5. **Goal-fit (0.35 — the heaviest dim, hard gate ≥ 0.50):** re-read the cycle's
67
+ `Goal delta:` / plan `outcome:` and verify the shipped diff actually moves it. Confirm the
68
+ deliverable proof is present (curl / screenshot / log) and the `ux_after` journey is reachable.
69
+ Clean, fast, safe code that does NOT advance the goal scores low here and **cannot close** —
70
+ goal-fit < 0.50 fails the cycle regardless of the other four dims. `→ improve:` names what the
71
+ goal still needs.
72
+
73
+ 4. **Security (0.20):** grep the diff for `/api[_-]?key|secret|password|token/i`, `eval(`,
74
+ `dangerouslySetInnerHTML`. Check every `src/pages/api/*.ts` route validates input with Zod
75
+ at the boundary. CF Worker env via `context.env` only. No wildcard CORS headers.
76
+ Score 1.0 = all greps return 0. For every gap, emit `→ improve: file:line — what`.
77
+
78
+ 5. **Stability (0.20):** biome + tsc + vitest already ran. Now check: no new `any`, no
79
+ `@ts-ignore` without WHY comment, no silent returns (Rule 1), no wall-clock units in new
80
+ code or docs (Rule 2), no retired names `knowledge|connections|people|node|scent|alarm|
81
+ trail|colony`. Score 1.0 = all zero. For each gap, emit `→ improve: exact location`.
82
+
83
+ 6. **Simplicity (0.15):** the philosophy is small, focused files. The substrate — the
84
+ entire schema + engine — is 200 lines total. Use that as your reference point.
85
+
86
+ ```bash
87
+ # Report line counts for every touched file — not to enforce a number,
88
+ # but to prompt the question: "is this file doing one thing?"
89
+ git diff HEAD --name-only | while read f; do
90
+ lines=$(wc -l < "$f" 2>/dev/null)
91
+ echo "$lines $f"
92
+ done | sort -rn | head -20
93
+
94
+ # Functions over 20 lines in touched TypeScript files — flag each
95
+ git diff HEAD --name-only | grep -E '\.(ts|tsx)$' | xargs grep -c '' 2>/dev/null
96
+
97
+ # Net LOC delta
98
+ git diff HEAD --stat | tail -1
99
+
100
+ # Ceremony: backwards-compat shims, WHAT comments, token leaks
101
+ git diff HEAD | grep -E '^\+.*_unused|re-export|// (The|This|It |We )' | head -10
102
+ git diff HEAD | grep -E '^\+.*(bg-zinc|bg-slate|bg-indigo|#[0-9a-fA-F]{3,6})' | head -5
103
+ ```
104
+
105
+ For any file noticeably large, ask: "does this file have two responsibilities?"
106
+ If yes → name the split in the improvement instruction.
107
+ If no → it's focused; carry on.
108
+
109
+ Score 1.0 = all files feel focused and single-purpose; functions tight; zero ceremony.
110
+ For each gap, name what to split or delete.
111
+
112
+ 7. **Speed (0.10):** Three sub-checks, all must pass for 1.0.
113
+
114
+ **Lighthouse:** run against all pages derived from the file→route map. Target 100 on all
115
+ four categories. For each audit below 100, name it and the component responsible.
116
+
117
+ **Bundle + build:** compare bundle KB and buildMs to `.w0-baseline.json`. Flag any increase.
118
+ Check hydration: any new `client:load` that could be `client:idle` or `client:visible`.
119
+
120
+ **Token efficiency:**
121
+ ```bash
122
+ # Agent/skill body line delta vs baseline
123
+ AGENT_LINES_NOW=$(find agents -name '*.md' 2>/dev/null | xargs wc -l 2>/dev/null | tail -1 | awk '{print $1}')
124
+ AGENT_LINES_W0=$(jq '.agentLines' .w0-baseline.json)
125
+ AGENT_DELTA=$((AGENT_LINES_NOW - AGENT_LINES_W0))
126
+
127
+ # Flag any single .md file over 300 lines (token bloat per activation)
128
+ find agents one.ie/web/src -name '*.md' 2>/dev/null | xargs wc -l | sort -rn | head -10
129
+
130
+ # Check for context stuffing in chat.ts — full file trees injected per request?
131
+ git diff HEAD | grep -E '^\+.*listFiles|readdir|readdirSync' | grep -i 'prompt\|system\|context'
132
+ ```
133
+
134
+ Prompt cache hit rate: if available from API response headers (`anthropic-cache-read-input-tokens`),
135
+ report it. Target ≥ 80%. If not measurable, note "cache: not instrumented" and flag as improvement.
136
+
137
+ Score 1.0 = all Lighthouse 100, bundle ≤ W0, agent lines ≤ W0, no context stuffing, cache ≥ 80%.
138
+ For each gap, name the audit, component, or file.
139
+
140
+ 8. Composite = `0.35·goal-fit + 0.20·security + 0.20·stability + 0.15·simplicity + 0.10·speed`. Gate: composite ≥ 0.65 AND goal-fit ≥ 0.50 (hard).
141
+
142
+ 9. Must-not checks (bypass composite — immediate warn):
143
+ - Hardcoded secret or API key → `warn(1)` on security, cycle fails.
144
+ - `eval()` or unsanitized `dangerouslySetInnerHTML` → `warn(1)`, cycle fails.
145
+ - Test failure on W3-touched files → `warn(1)` on stability, route to W3.5.
146
+ - Lighthouse any category drops > 5 pts from baseline → `warn(1)` on speed.
147
+
148
+ 10. Cross-consistency checks from the TODO's verify checklist (doc terms match code identifiers,
149
+ no 404 links, no retired names leaked).
150
+
151
+ ---
152
+
153
+ ## Verification Tools
154
+
155
+ Use these to produce the numbers — not estimates.
156
+
157
+ ### Lighthouse (Speed dim)
158
+
159
+ **File → route map** (derive pages to audit from files touched in W3):
160
+
161
+ | Touched path pattern | Audit URL |
162
+ |---------------------|-----------|
163
+ | `src/pages/index.astro` | `http://localhost:4321/` |
164
+ | `src/pages/get-yours.astro` | `http://localhost:4321/get-yours` |
165
+ | `src/pages/u/**` | `http://localhost:4321/u/demo` |
166
+ | `src/components/chat/**` | `http://localhost:4321/chat` |
167
+ | `src/components/**` | `http://localhost:4321/` + `/chat` |
168
+ | `src/layouts/**` | all pages |
169
+ | `src/pages/api/**` | skip (server routes — no Lighthouse) |
170
+
171
+ **Pre-flight check before running:**
172
+
173
+ ```bash
174
+ # 1. Check lighthouse is installed
175
+ which lighthouse || npx lighthouse --version 2>/dev/null
176
+ LIGHTHOUSE_OK=$?
177
+
178
+ # 2. Check dev server is up (start it if needed)
179
+ curl -sf http://localhost:4321/ > /dev/null 2>&1
180
+ SERVER_OK=$?
181
+
182
+ if [ $SERVER_OK -ne 0 ]; then
183
+ bun run dev > /tmp/dev-server.log 2>&1 &
184
+ DEV_PID=$!
185
+ # Poll until ready (max 15s)
186
+ for i in $(seq 1 15); do
187
+ sleep 1
188
+ curl -sf http://localhost:4321/ > /dev/null 2>&1 && break
189
+ done
190
+ curl -sf http://localhost:4321/ > /dev/null 2>&1
191
+ SERVER_OK=$?
192
+ fi
193
+ ```
194
+
195
+ **If both available — run Lighthouse:**
196
+
197
+ ```bash
198
+ # Run against each derived page URL
199
+ npx lighthouse http://localhost:4321/chat --output=json --quiet \
200
+ --chrome-flags="--headless --no-sandbox" \
201
+ | jq '{
202
+ perf: (.categories.performance.score * 100 | round),
203
+ a11y: (.categories.accessibility.score * 100 | round),
204
+ bp: (.categories["best-practices"].score * 100 | round),
205
+ seo: (.categories.seo.score * 100 | round),
206
+ failing_audits: [.audits | to_entries[]
207
+ | select(.value.score != null and .value.score < 1)
208
+ | {audit: .key, score: .value.score, desc: .value.description}]
209
+ }'
210
+ ```
211
+
212
+ Scores are 0–1 from Lighthouse; multiply by 100. Target is 100 on all four.
213
+ The `failing_audits` array tells you exactly which audit to fix — include these in the
214
+ `→ improve:` instruction so the next cycle knows precisely what to address.
215
+
216
+ **If Lighthouse unavailable — fallback scoring:**
217
+
218
+ ```
219
+ Score speed on what IS measurable:
220
+ - Bundle size vs .w0-baseline.json: bundleKB delta
221
+ - Build time vs .w0-baseline.json: buildMs delta
222
+ - Hydration grep: no new client:load where client:idle suffices
223
+
224
+ Cap speed score at 0.80 when Lighthouse skipped.
225
+ Flag in receipt: "lighthouse: skipped — run manually to confirm 100%"
226
+ Do NOT score 1.0 for speed without a real Lighthouse number.
227
+ ```
228
+
229
+ ### Playwright (functional + a11y verification)
230
+
231
+ ```bash
232
+ # If playwright tests exist
233
+ npx playwright test --reporter=line 2>&1 | tail -20
234
+
235
+ # Quick a11y scan (axe-playwright) on touched pages — if configured
236
+ npx playwright test tests/a11y --reporter=line
237
+ ```
238
+
239
+ Playwright failures are stability failures — they join the vitest gate.
240
+ A11y failures from playwright count against the Accessibility Lighthouse category.
241
+
242
+ ### Bundle size (Speed dim)
243
+
244
+ ```bash
245
+ # Check CF Worker bundle size
246
+ npx wrangler deploy --dry-run --outdir=.wrangler/output 2>&1 | grep -E 'Total|gzip'
247
+
248
+ # Or check Astro build output
249
+ bun run build 2>&1 | grep -E 'dist/|\.js|\.css|kB'
250
+
251
+ # Delta vs W0: compare to the buildMs + sizes recorded in W0
252
+ ```
253
+
254
+ ### TypeScript strict check (Stability dim)
255
+
256
+ ```bash
257
+ npx tsc --noEmit --strict 2>&1 | grep -c 'error TS' # 0 = pass
258
+ ```
259
+
260
+ ### Security grep (Security dim)
261
+
262
+ ```bash
263
+ # Run against the diff only (staged + unstaged changes from W3)
264
+ # secrets
265
+ git diff HEAD | grep -E '^\+' | grep -iE 'api[_-]?key|secret|password|token' \
266
+ | grep -vE '^\+\+\+|zod|schema|type |interface |//|process\.env\.PUBLIC'
267
+
268
+ # injection vectors
269
+ git diff HEAD | grep -E '^\+.*eval\(' | grep -v '// allow'
270
+ git diff HEAD | grep -E '^\+.*dangerouslySetInnerHTML' | grep -v 'sanitize\|DOMPurify'
271
+
272
+ # Worker env access
273
+ git diff HEAD | grep -E '^\+.*process\.env' | grep -v '// allow\|PUBLIC_'
274
+
275
+ # CORS wildcard
276
+ git diff HEAD | grep -E '^\+.*Access-Control-Allow-Origin.*\*'
277
+
278
+ # TypeDB string concatenation in queries (parameterized form required)
279
+ git diff HEAD | grep -E '^\+' | grep -E 'define|match|insert' \
280
+ | grep -E '\+\s*[`"\x27]|\.concat\(|\$\{' | grep -iE 'typedb|tql|query'
281
+ ```
282
+
283
+ Zero hits across all greps = security score eligible for 1.0.
284
+ Each hit = `→ improve: file:line — what the pattern is`.
285
+
286
+ 11. **Write improvement artifacts** — this is how the system learns.
287
+
288
+ ```bash
289
+ # a) Machine-readable: feeds next cycle's W1 recon
290
+ cat > .w4-improvements.json <<EOF
291
+ {
292
+ "cycle": N,
293
+ "timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
294
+ "composite": COMPOSITE,
295
+ "velocity": COMPOSITE_MINUS_PREV_COMPOSITE,
296
+ "open": [
297
+ { "dim": "security", "score": SEC, "file": "...", "line": N, "action": "..." },
298
+ { "dim": "stability", "score": STA, "file": "...", "line": N, "action": "..." },
299
+ { "dim": "simplicity", "score": SIM, "file": "...", "line": N, "action": "..." },
300
+ { "dim": "speed", "score": SPD, "audit": "...", "component": "...", "action": "..." }
301
+ ]
302
+ }
303
+ EOF
304
+ # Omit any dim with score 1.00 from "open" — those are clean.
305
+
306
+ # b) Human-readable history: feeds pattern detection and learning
307
+ cat >> docs/improvements.md <<EOF
308
+
309
+ ## $(date -u +%Y-%m-%d) · cycle N · composite=COMPOSITE (Δ VELOCITY)
310
+ - security/SEC: IMPROVE_LINE_OR_clean
311
+ - stability/STA: IMPROVE_LINE_OR_clean
312
+ - simplicity/SIM: IMPROVE_LINE_OR_clean
313
+ - speed/SPD: IMPROVE_LINE_OR_clean
314
+ EOF
315
+ ```
316
+
317
+ **Systemic gap detection** — after writing, check for patterns:
318
+
319
+ ```bash
320
+ # If any file:line has appeared in 3+ consecutive entries → systemic gap
321
+ grep -A4 'cycle' docs/improvements.md | grep -oE 'src/[^:]+:[0-9]+' | sort | uniq -c | sort -rn | head -5
322
+ ```
323
+
324
+ If a file:line appears 3+ times consecutively without "clean": emit a systemic-gap signal to
325
+ the substrate — this file is structurally weak and should be prioritized in future W1 recons:
326
+
327
+ ```json
328
+ {
329
+ "receiver": "substrate:systemic-gap",
330
+ "data": {
331
+ "file": "src/pages/api/provision.ts",
332
+ "dim": "security",
333
+ "cycles_unresolved": 3,
334
+ "action": "add Zod parse on slug param"
335
+ }
336
+ }
337
+ ```
338
+
339
+ 12. Emit the completion signal.
340
+
341
+ ## Known-flaky allowlist
342
+
343
+ Tests matching patterns in `scripts/deploy.ts` `KNOWN_FLAKY` are stochastic (timing, network). They do NOT fail the gate — report them as `flaky=N` in the receipt and continue. See memory `feedback_timing_tests.md`.
344
+
345
+ ## TypeScript crash handling
346
+
347
+ `tsc` 5.9 has a known stack-overflow bug — see memory `feedback_typecheck_crash.md`. If `tsc` crashes WITHOUT a real `TS####` error line, treat as pass. Fall through to `scripts/typecheck.sh` if it exists.
348
+
349
+ ## Completion signal
350
+
351
+ Success:
352
+ ```json
353
+ {
354
+ "receiver": "w4:verify:ok",
355
+ "data": {
356
+ "tags": ["w4", "verify"],
357
+ "weight": 1,
358
+ "content": {
359
+ "passed": N, "failed": 0,
360
+ "rubric": {
361
+ "security": { "score": 0.95, "improve": "src/pages/api/provision.ts:31 — missing Zod parse on slug" },
362
+ "stability": { "score": 1.00, "improve": "clean" },
363
+ "simplicity": { "score": 0.85, "improve": "inline formatDate() at src/lib/slug.ts:12, saves 9 lines" },
364
+ "speed": { "score": 0.80, "improve": "EvalCard client:load → client:visible; Lighthouse Perf 97" }
365
+ },
366
+ "composite": 0.91,
367
+ "velocity": +0.06,
368
+ "buildMs": N,
369
+ "lighthouse": { "perf": 97, "a11y": 100, "bp": 100, "seo": 100 },
370
+ "improvements_file": ".w4-improvements.json"
371
+ }
372
+ }
373
+ }
374
+ ```
375
+
376
+ Failure:
377
+ ```json
378
+ {
379
+ "receiver": "w4:verify:fail",
380
+ "data": {
381
+ "tags": ["w4", "verify"],
382
+ "weight": -1,
383
+ "content": {
384
+ "passed": N, "failed": M,
385
+ "failures": ["<test name or tsc error>"],
386
+ "rubric": {
387
+ "security": { "score": 0.50, "improve": "src/pages/api/chat.ts:23 — missing Zod parse on body.slug" },
388
+ "stability": { "score": 0.00, "improve": "vitest: chat renders message FAILED — type mismatch line 14" },
389
+ "simplicity": { "score": 0.60, "improve": "parseMarkdown() 18 lines, one caller — inline and delete" },
390
+ "speed": { "score": 0.50, "improve": "Lighthouse Perf 94 — unused JS from lodash import in slug.ts" }
391
+ },
392
+ "composite": 0.34,
393
+ "velocity": -0.12,
394
+ "improvements_file": ".w4-improvements.json"
395
+ }
396
+ }
397
+ }
398
+ ```
399
+
400
+ `velocity` = this cycle's composite minus the previous cycle's composite (read from `docs/improvements.md`).
401
+ Positive velocity = the system is improving. Negative = something regressed.
402
+ Pheromone compounds the velocity signal: `mark(edge, composite)` every cycle → paths that
403
+ consistently score high get strong; paths that keep failing accumulate resistance.
404
+
405
+ ## Edit tool policy
406
+
407
+ You may `Edit` only to apply micro-fixes during a W3.5 reloop when the parent delegates that explicitly. Default posture: read and verify.
408
+
409
+ ## Out of scope
410
+
411
+ - Writing new features. That was W3.
412
+ - Deciding the plan. That was W2.
413
+ - Mapping the problem. That was W1.
414
+ - Judging by feel. Only by numbers.
415
+
416
+ Verify. Score. Emit. The path remembers.
@@ -0,0 +1,55 @@
1
+ # /browser — Playwright browser diagnostic
2
+
3
+ Runs a headless Chrome check against a URL and reports page health, JS errors, and chat behaviour.
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ /browser [url] [--send "message"] [--screenshot] [--network]
9
+ ```
10
+
11
+ **Arguments (all optional):**
12
+ - `url` — page to check (default: `http://localhost:4321`)
13
+ - `--send "text"` — type and submit a chat message, then compare rail before/after
14
+ - `--screenshot` — save `/tmp/browser-check.png`
15
+ - `--network` — capture API request list
16
+
17
+ ## How to invoke
18
+
19
+ ```bash
20
+ node .claude/scripts/browser-check.mjs http://localhost:4321/studio/boq-empire?agent=boq-empire --send "hello" --screenshot
21
+ ```
22
+
23
+ Or directly in conversation — Claude runs the script via Bash.
24
+
25
+ ## What it checks
26
+
27
+ | Check | How |
28
+ |---|---|
29
+ | HTTP status | `page.goto` response code |
30
+ | Title | `page.title()` |
31
+ | JS errors | `pageerror` events |
32
+ | Console errors | `console.error` events |
33
+ | Chat rail (before send) | `.chat-rail` innerText |
34
+ | Chat POST body | fetch monkey-patch captures `agentId`, `slug`, messages |
35
+ | Stream content | Reads cloned SSE stream; shows first 800 chars |
36
+ | Chat rail (after send) | After 12s wait post-submit |
37
+
38
+ ## Prerequisites
39
+
40
+ Playwright installed once:
41
+ ```bash
42
+ cd /tmp && npm install playwright && npx playwright install chromium
43
+ ```
44
+
45
+ Check with: `node -e "require('/tmp/node_modules/playwright'); console.log('ok')"`
46
+
47
+ ## Output
48
+
49
+ JSON report to stdout. Key fields:
50
+ - `httpStatus` — 200/404/500
51
+ - `jsErrors` — uncaught JS exceptions
52
+ - `consoleErrors` — console.error calls
53
+ - `chatRailBefore` / `chatRailAfter` — visible text
54
+ - `chatCapture[].body` — POST body (check `agentId` present)
55
+ - `chatCapture[].stream` — SSE response (check for error vs real tokens)
@@ -0,0 +1,67 @@
1
+ # /cc-connect — Claude Code ↔ Claude Code messaging
2
+
3
+ Real-time peer chat between Claude Code sessions over the substrate. **SSE push, no client polling.**
4
+
5
+ A background listener (one per group) holds a long-lived connection to claw and writes new signals to a local `.cc-connect/<group>.jsonl` file. Reading is a local file tail — instant, zero network. Sending is one HTTP POST.
6
+
7
+ ## Usage
8
+
9
+ ```
10
+ /cc-connect # read new messages since last read
11
+ /cc-connect send "your text" # send to default group
12
+ /cc-connect send --to founders "text" # send to specific group (--group also works)
13
+ /cc-connect listen # start background SSE listener (idempotent)
14
+ /cc-connect stop # kill listener
15
+ /cc-connect status # show config + listener PID + unread count
16
+ /cc-connect init tony newco # set sender + group (once per project)
17
+ ```
18
+
19
+ ## How to invoke
20
+
21
+ Run the script via Bash:
22
+
23
+ ```bash
24
+ .claude/scripts/cc-connect.sh <subcommand> [args]
25
+ ```
26
+
27
+ Examples:
28
+
29
+ ```bash
30
+ .claude/scripts/cc-connect.sh send "hey donal, did you see the rename plan?"
31
+ .claude/scripts/cc-connect.sh # = read
32
+ .claude/scripts/cc-connect.sh listen # start once per session
33
+ ```
34
+
35
+ ## First-time setup
36
+
37
+ ```bash
38
+ .claude/scripts/cc-connect.sh init <yourname> newco
39
+ .claude/scripts/cc-connect.sh listen
40
+ ```
41
+
42
+ That's it. The listener runs in the background until you `stop` it. Across Claude Code sessions, just re-run `listen` — it's idempotent.
43
+
44
+ ## What's stored
45
+
46
+ | File | Purpose |
47
+ |---|---|
48
+ | `.cc-connect/config.json` | `{sender, group}` |
49
+ | `.cc-connect/<group>.jsonl` | Append-only message log (one JSON per line) |
50
+ | `.cc-connect/<group>.offset` | Last-read line count |
51
+ | `.cc-connect/<group>.pid` | Background listener PID |
52
+
53
+ The `.cc-connect/` dir is gitignored.
54
+
55
+ ## Tech
56
+
57
+ - **claw endpoint:** `GET /stream/:group` — Server-Sent Events, 25s heartbeat, resumable via `Last-Event-ID`
58
+ - **Client:** `curl -N` holding the SSE connection in a background process
59
+ - **Storage:** local JSONL append; reads tail since byte offset
60
+
61
+ No client polling. The CF worker pushes; your terminal stays asleep until a message lands.
62
+
63
+ ## See also
64
+
65
+ - `web/src/pages/peer/[group].astro` — web view of the same group (`app.one.ie/peer/newco`)
66
+ - `claw/src/index.ts` — `GET /stream/:group` SSE source
67
+ - `.claude/scripts/cc-connect.sh` — the worker script
@@ -0,0 +1,135 @@
1
+ # /claw
2
+
3
+ **Skills:** `/sui` (agent wallet derivation via `addressFor(uid)`) · `/cloudflare` (Worker deploy + secrets) · `/signal` (webhook channel routing, `ui:*` + `hook:*`)
4
+
5
+ Add a NanoClaw (edge worker with LLM + substrate tools) to any agent.
6
+
7
+ ## Usage
8
+
9
+ ```
10
+ /claw <agent-id> Deploy claw for an agent from agents/*.md
11
+ /claw <agent-id> --token T Deploy with Telegram bot token
12
+ /claw --list List available agents
13
+ /claw --dry-run <agent-id> Show config without deploying
14
+ ```
15
+
16
+ ## What is a Claw?
17
+
18
+ A **NanoClaw** is a Cloudflare Worker that gives any agent:
19
+ - LLM access (via OpenRouter — any model)
20
+ - Substrate tools (signal, discover, remember, recall, highways, mark, warn)
21
+ - Channel adapters (Telegram, Discord, Web)
22
+ - Queue for async processing
23
+
24
+ ## Steps
25
+
26
+ ### 1. Check if agent exists
27
+
28
+ First, verify the agent exists in `agents/` directory:
29
+
30
+ ```bash
31
+ ls agents/*.md agents/**/*.md
32
+ ```
33
+
34
+ If the agent doesn't exist, create one first:
35
+ ```bash
36
+ cat > agents/<name>.md << 'EOF'
37
+ ---
38
+ name: <name>
39
+ model: anthropic/claude-haiku-4-5
40
+ ---
41
+
42
+ Your system prompt here.
43
+ EOF
44
+ ```
45
+
46
+ ### 2. Generate claw config
47
+
48
+ Use the API to generate the config:
49
+
50
+ ```bash
51
+ curl -X POST http://localhost:4321/api/claw \
52
+ -H "Content-Type: application/json" \
53
+ -d '{"agentId": "<agent-id>"}'
54
+ ```
55
+
56
+ This returns:
57
+ - `persona` — the agent's name, model, system prompt
58
+ - `wranglerConfig` — ready-to-use wrangler.toml
59
+ - `personaEntry` — code to add to personas.ts
60
+ - `deployCommands` — step-by-step deploy instructions
61
+ - `quickDeploy` — one-liner to deploy
62
+
63
+ ### 3. Deploy the claw
64
+
65
+ **Option A: Quick deploy (recommended)**
66
+
67
+ ```bash
68
+ bun run scripts/setup-agents.ts --name <name> --agent <agent-id>
69
+ ```
70
+
71
+ Add `--token <telegram-token>` if you want a Telegram bot.
72
+
73
+ **Option B: Manual deploy**
74
+
75
+ 1. Add persona to `agents/src/personas.ts`
76
+ 2. Create `agents/wrangler.<name>.toml`
77
+ 3. Deploy:
78
+ ```bash
79
+ cd agents
80
+ wrangler deploy --config wrangler.<name>.toml
81
+ wrangler secret put OPENROUTER_API_KEY --config wrangler.<name>.toml
82
+ ```
83
+ 4. Register Telegram webhook (optional):
84
+ ```bash
85
+ curl "https://api.telegram.org/bot<TOKEN>/setWebhook?url=https://<name>-claw.oneie.workers.dev/webhook/telegram"
86
+ ```
87
+
88
+ ### 4. Test the claw
89
+
90
+ ```bash
91
+ # Web message
92
+ curl -X POST https://<name>-claw.oneie.workers.dev/message \
93
+ -H "Content-Type: application/json" \
94
+ -d '{"group": "test", "text": "Hello!"}'
95
+
96
+ # Health check
97
+ curl https://<name>-claw.oneie.workers.dev/health
98
+ ```
99
+
100
+ ## Available Tools
101
+
102
+ Every claw has access to these substrate tools:
103
+
104
+ | Tool | What it does |
105
+ |------|-------------|
106
+ | `signal` | Emit a signal to another agent or skill |
107
+ | `discover` | Find agents by tag or capability |
108
+ | `remember` | Store an insight in TypeDB |
109
+ | `recall` | Retrieve learned patterns |
110
+ | `highways` | Get proven paths (highest pheromone) |
111
+ | `mark` | Strengthen a path (positive feedback) |
112
+ | `warn` | Weaken a path (negative feedback) |
113
+
114
+ ## Examples
115
+
116
+ ```bash
117
+ # Deploy claw for the tutor agent
118
+ /claw tutor
119
+
120
+ # Deploy with Telegram bot
121
+ /claw tutor --token 1234567890:ABC...
122
+
123
+ # Deploy for a marketing agent
124
+ /claw marketing/creative
125
+
126
+ # Just show config
127
+ /claw tutor --dry-run
128
+ ```
129
+
130
+ ## See Also
131
+
132
+ - `scripts/setup-agents.ts` — Full deploy script
133
+ - `agents/src/personas.ts` — Persona definitions
134
+ - `agents/src/lib/tools.ts` — Substrate tool implementations
135
+ - `/api/claw` — Config generation API