cclaw-cli 0.5.7 → 0.5.8

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.
@@ -120,7 +120,18 @@ The original premise (“add notifications”) was reframed to **“ensure users
120
120
  - Accepted scope: durable feed + SSE + explicit degraded UX.
121
121
  - Deferred: WebSocket channel and rich-media/search enhancements.
122
122
  - Explicitly excluded: outbound channels and marketing workflows for v1.`,
123
- design: `### Search Before Building (sample result)
123
+ design: `### Codebase Investigation (blast-radius files)
124
+
125
+ | File | Current responsibility | Patterns discovered |
126
+ | --- | --- | --- |
127
+ | \`src/api/routes/user.ts\` | User CRUD endpoints | Express router, Zod validation, throws \`AppError\` |
128
+ | \`src/services/event-bus.ts\` | In-process pub/sub | EventEmitter wrapper, typed channels, no persistence |
129
+ | \`src/middleware/auth.ts\` | JWT verification | Extracts user from token, attaches to \`req.context\` |
130
+ | \`tests/integration/user.test.ts\` | User route tests | Supertest, factory helpers, \`beforeEach\` DB reset |
131
+
132
+ Discovery: existing EventEmitter-based bus has no durability — notifications must add persistence layer on top, not replace the bus.
133
+
134
+ ### Search Before Building (sample result)
124
135
 
125
136
  | Layer | Label | What to reuse first |
126
137
  | --- | --- | --- |
@@ -128,7 +139,7 @@ The original premise (“add notifications”) was reframed to **“ensure users
128
139
  | Layer 2 | existing codebase | Existing auth middleware, existing API client wrapper, existing feature flags helper |
129
140
  | Layer 3 | npm | A small, well-maintained SSE helper (only if Layer 1–2 cannot cover framing/reconnect ergonomics) |
130
141
 
131
- ### Minimal component diagram (ASCII)
142
+ ### Architecture Diagram (mandatory)
132
143
 
133
144
  \`\`\`
134
145
  ┌─────────────┐ ┌──────────────┐ ┌────────────────┐
@@ -142,18 +153,54 @@ The original premise (“add notifications”) was reframed to **“ensure users
142
153
  └──────────────┘
143
154
  \`\`\`
144
155
 
145
- ### Unresolved Decision (sample entry)
156
+ Data flow: Gateway → Service (validate + enrich) → Publisher (fan-out) → Queue (persist) → Read Model (project).
157
+
158
+ ### What Already Exists
159
+
160
+ | Sub-problem | Existing code/library | Layer | Reuse decision |
161
+ | --- | --- | --- | --- |
162
+ | Auth context extraction | \`src/middleware/auth.ts\` | Layer 1 | Reuse as-is |
163
+ | Event fan-out | \`src/services/event-bus.ts\` | Layer 2 | Wrap with persistence adapter |
164
+ | SSE framing | None | Layer 3 | Evaluate \`better-sse\` npm package |
165
+ | Notification schema | None | — | New: define in \`src/schemas/notification.ts\` |
166
+
167
+ ### Failure Mode Table
168
+
169
+ | Failure | Trigger | Detection | Mitigation | User impact |
170
+ | --- | --- | --- | --- | --- |
171
+ | SSE connection drop | Network interruption | Client heartbeat timeout (30s) | Auto-reconnect with exponential backoff + snapshot fallback | Brief delay (≤10s), no data loss |
172
+ | Duplicate publish | Retry after timeout | Dedupe key check in outbox | Upsert with idempotency key | None (transparent) |
173
+ | Queue backpressure | Spike >1000 events/s | Queue depth metric alarm | Back-pressure signal to publisher, shed non-critical events | Delayed delivery of low-priority notifications |
146
174
 
147
- - **Decision:** Should the feed be modeled as append-only events or as CRUD “notification rows”?
148
- - **Status:** OPEN
149
- - **Options:** (A) append-only event log + projection, (B) mutable rows with status fields, (C) hybrid with compaction job
150
- - **Deadline:** Decide before implementation of persistence migrations (end of week)
175
+ ### NOT in scope
176
+
177
+ - Outbound channels (email, push, SMS) deferred to v2.
178
+ - Admin notification management UI separate workstream.
179
+ - Notification preferences / mute rules — requires user settings redesign.
180
+
181
+ ### Unresolved Decisions
182
+
183
+ | Decision | Status | Options | Missing info | Default if unanswered |
184
+ | --- | --- | --- | --- | --- |
185
+ | Feed storage model | OPEN | (A) append-only event log, (B) mutable rows, (C) hybrid | Load testing results on read patterns | (A) append-only — safest for audit trail |
151
186
 
152
187
  ### Interface sketch (non-binding)
153
188
 
154
189
  - **Client → server:** \`GET /api/me/notifications/snapshot?limit=50\` plus optional cursor parameters (if adopted).
155
190
  - **Server → client:** \`GET /api/me/notifications/stream\` as SSE with periodic heartbeats.
156
191
 
192
+ ### Completion Dashboard
193
+
194
+ | Review Section | Status | Issues |
195
+ | --- | --- | --- |
196
+ | Architecture Review | issues-found-resolved | Decided on outbox pattern over direct pub/sub |
197
+ | Code Quality Review | clear | — |
198
+ | Test Review | issues-found-resolved | Added integration test gap for SSE reconnect |
199
+ | Performance Review | clear | — |
200
+ | Distribution & Delivery Review | clear | — |
201
+
202
+ **Decisions made:** 4 | **Unresolved:** 1 (feed storage model)
203
+
157
204
  ### Quality bar for this stage
158
205
 
159
206
  Design output should be **reviewable by someone who did not attend brainstorming**: they can trace from constraints → components → open decisions without reading code.`,
@@ -385,28 +385,35 @@ const DESIGN = {
385
385
  "Implementation has already started and requires review instead of design lock"
386
386
  ],
387
387
  checklist: [
388
+ "Trivial-Change Escape Hatch — If scope artifact shows ≤3 files, zero new interfaces, and no cross-module data flow, skip full review sections. Produce a mini-design: one paragraph of rationale, list of changed files, one risk to watch. Proceed to spec.",
388
389
  "Design Doc Check — read existing design docs, scope artifact, brainstorm artifact. If a design doc exists that covers this area, check for 'Supersedes:' and use the latest. Use upstream artifacts as source of truth.",
390
+ "Codebase Investigation — Before any design decision, read the actual code in the blast radius. List every file that will be touched, its current responsibilities, and existing patterns (error handling, naming, test style). Design must conform to discovered patterns, not impose new ones without justification.",
389
391
  "Step 0: Scope Challenge — what existing code solves sub-problems? Minimum change set? Complexity check: 8+ files or 2+ new services = complexity smell → flag for possible scope reduction.",
390
392
  "Search Before Building — For each technical choice (library, pattern, architecture), search for existing solutions. Label findings: Layer 1 (exact match), Layer 2 (partial match, needs adaptation), Layer 3 (inspiration only), EUREKA (unexpected perfect solution). Default to existing before custom.",
391
- "Architecture Review — system design, component boundaries, data flow, scaling, security architecture. For each new codepath: one realistic production failure scenario.",
393
+ "Architecture Review — system design, component boundaries, data flow, scaling, security architecture. For each new codepath: one realistic production failure scenario. **Mandatory:** produce at least one architecture diagram (ASCII, Mermaid, or tool-generated) showing component boundaries and data flow direction.",
392
394
  "Code Quality Review — code organization, DRY violations, error handling patterns, over/under-engineering assessment.",
393
395
  "Test Review — diagram every new flow, data path, error path. For each: what test type covers it? Does one exist? What is the gap? Produce test plan artifact.",
394
396
  "Performance Review — N+1 queries, memory concerns, caching opportunities, slow code paths. What breaks at 10x load? At 100x?",
395
397
  "Parallelization Strategy — If multiple independent modules, produce dependency table: which can be built in parallel? Where are conflict risks? Flag shared-state modules.",
396
398
  "Unresolved Decisions — List any design decisions that could not be resolved in this session. For each: what information is missing? Who can provide it? What is the default if no answer comes?",
397
- "Distribution Check — If the plan creates new artifact types (packages, CLI tools, configs), document the build/publish story. How does it reach the user?"
399
+ "Distribution Check — If the plan creates new artifact types (packages, CLI tools, configs), document the build/publish story. How does it reach the user?",
400
+ "Deferred Items Cross-Reference — Collect every item explicitly deferred during design review. Each must appear in the Unresolved Decisions table or in the upstream scope artifact's deferred list. No deferred item may exist only in conversation — it must be written down."
398
401
  ],
399
402
  interactionProtocol: [
400
403
  "Review architecture decisions section-by-section.",
401
404
  "For EACH issue found in a review section, present it ONE AT A TIME. Do NOT batch multiple issues.",
402
- "For each issue: use the Decision Protocol — describe concretely with file/line references, present labeled options (A/B/C) with trade-offs and mark one as (recommended). If AskQuestion/AskUserQuestion is available, send exactly ONE question per call, validate fields against runtime schema, and on schema error immediately fall back to plain-text question instead of retrying guessed payloads.",
405
+ "For each issue: use the Decision Protocol — describe concretely with file/line references, present labeled options (A/B/C) with trade-offs, effort estimate (S/M/L/XL), risk level (Low/Med/High), and mark one as (recommended). If AskQuestion/AskUserQuestion is available, send exactly ONE question per call, validate fields against runtime schema, and on schema error immediately fall back to plain-text question instead of retrying guessed payloads.",
403
406
  "Only proceed to the next review section after ALL issues in the current section are resolved.",
404
407
  "If a section has no issues, say 'No issues found' and move on.",
405
408
  "Do not skip failure-mode mapping.",
406
- "For design baseline approval: present the full baseline. **STOP.** Do NOT proceed until user explicitly approves the design."
409
+ "For design baseline approval: present the full baseline. **STOP.** Do NOT proceed until user explicitly approves the design.",
410
+ "Take a firm position on every recommendation. Do NOT hedge with 'it depends' or 'you could do either'. State your opinion, then justify it.",
411
+ "Use pushback patterns for weak framing: if the user says 'it's just a small change', respond with 'small changes to shared interfaces have outsized blast radius — let's map it'. If 'we'll refactor later', respond with 'later never comes — show me the refactor ticket or do it now'.",
412
+ "When the user's proposed architecture is suboptimal, say so directly. Offer the alternative with concrete trade-offs, do not bury criticism in praise."
407
413
  ],
408
414
  process: [
409
415
  "Read upstream artifacts (brainstorm, scope).",
416
+ "Investigate codebase: read files in blast radius, catalogue current patterns and responsibilities.",
410
417
  "Run Step 0 scope challenge: existing code leverage, minimum change set, complexity check.",
411
418
  "Walk through each review section interactively.",
412
419
  "Define architecture boundaries and ownership.",
@@ -414,9 +421,11 @@ const DESIGN = {
414
421
  "Map failure modes and recovery strategy.",
415
422
  "Define test coverage strategy and performance budget.",
416
423
  "Produce required outputs: NOT-in-scope section, What-already-exists section, diagrams, failure mode table.",
424
+ "Produce completion dashboard: list every review section with status (clear / issues-found-resolved / issues-open), count of decisions made, and list of unresolved items.",
417
425
  "Write design lock artifact for downstream spec/plan."
418
426
  ],
419
427
  requiredGates: [
428
+ { id: "design_codebase_investigated", description: "Blast-radius files read and current patterns catalogued." },
420
429
  { id: "design_scope_challenge_done", description: "Step 0 scope challenge completed with existing-code mapping." },
421
430
  { id: "design_architecture_locked", description: "Architecture boundaries are explicit and approved." },
422
431
  { id: "design_data_flow_mapped", description: "Data/state flow includes edge-case paths." },
@@ -428,7 +437,8 @@ const DESIGN = {
428
437
  "Failure-mode table exists with mitigations.",
429
438
  "Test strategy includes unit/integration/e2e expectations.",
430
439
  "NOT-in-scope section produced.",
431
- "What-already-exists section produced."
440
+ "What-already-exists section produced.",
441
+ "Completion dashboard lists every review section status, decision count, and unresolved items (or 'None')."
432
442
  ],
433
443
  inputs: ["scope contract", "system constraints", "non-functional requirements"],
434
444
  requiredContext: [
@@ -441,7 +451,8 @@ const DESIGN = {
441
451
  "risk and failure map",
442
452
  "test and performance baseline",
443
453
  "NOT-in-scope section",
444
- "What-already-exists section"
454
+ "What-already-exists section",
455
+ "design completion dashboard"
445
456
  ],
446
457
  blockers: [
447
458
  "architecture ambiguity remains",
@@ -452,6 +463,7 @@ const DESIGN = {
452
463
  "design baseline approved",
453
464
  "all review sections completed",
454
465
  "required gates marked satisfied",
466
+ "completion dashboard present with all review-section statuses",
455
467
  "artifact complete for spec handoff"
456
468
  ],
457
469
  antiPatterns: [
@@ -459,20 +471,26 @@ const DESIGN = {
459
471
  "Missing data-flow edge cases",
460
472
  "No performance budget for critical path",
461
473
  "Batching multiple design issues into one question",
462
- "Skipping review sections because plan seems simple"
474
+ "Skipping review sections because plan seems simple",
475
+ "Agreeing with user's architecture choice without evaluating alternatives",
476
+ "Hedging every recommendation with 'it depends' instead of taking a position"
463
477
  ],
464
478
  rationalizations: [
465
479
  { claim: "Architecture can emerge incrementally while coding.", reality: "Unplanned architecture decisions cause incompatible module boundaries." },
466
480
  { claim: "Failure modes are edge cases we can ignore for now.", reality: "Production incidents usually come from unplanned edge paths." },
467
481
  { claim: "Performance can be optimized after launch.", reality: "Missing performance budgets make regressions invisible until late." },
468
- { claim: "This is a strategy doc so implementation sections do not apply.", reality: "Implementation details are where strategy breaks down. Every section must be evaluated." }
482
+ { claim: "This is a strategy doc so implementation sections do not apply.", reality: "Implementation details are where strategy breaks down. Every section must be evaluated." },
483
+ { claim: "The user preferred approach A, so we should go with it.", reality: "User preference is an input, not a conclusion. Evaluate on engineering merit. If approach B is objectively better, recommend B with evidence." },
484
+ { claim: "Both options are roughly equivalent.", reality: "Options are never equivalent once you quantify effort (S/M/L/XL) and risk (Low/Med/High). If you cannot distinguish them, you have not investigated deeply enough." }
469
485
  ],
470
486
  redFlags: [
471
487
  "No explicit architecture boundary section",
472
488
  "No failure recovery strategy",
473
489
  "No defined test/perf baseline",
474
490
  "Review sections skipped or condensed",
475
- "No NOT-in-scope output section"
491
+ "No NOT-in-scope output section",
492
+ "No What-already-exists output section",
493
+ "Design decisions made without reading the actual code first"
476
494
  ],
477
495
  policyNeedles: [
478
496
  "Architecture",
@@ -490,7 +508,10 @@ const DESIGN = {
490
508
  { name: "Essential vs Accidental Complexity", description: "Before adding anything: is this solving a real problem or one we created? Distinguish essential complexity from accidental." },
491
509
  { name: "Blast Radius Instinct", description: "Every decision evaluated through: what is the worst case and how many systems/people does it affect?" },
492
510
  { name: "Completeness Push", description: "AI effort is cheap. Push for completeness in plans: cover all files in blast radius, all edge cases in touched code, all affected tests. Favor doing it now over creating a TODO." },
493
- { name: "Owner Preference Alignment", description: "Every recommendation must align with project conventions (DRY, test style, minimal diff, edge-case rigor). Read existing patterns before recommending new ones." }
511
+ { name: "Owner Preference Alignment", description: "Every recommendation must align with project conventions (DRY, test style, minimal diff, edge-case rigor). Read existing patterns before recommending new ones." },
512
+ { name: "Failure Is Information", description: "A design that fails fast and visibly is better than one that silently degrades. Map every failure mode and make it observable. Undetected failures compound." },
513
+ { name: "Search Breadth Before Depth", description: "Before committing to a design path, survey the full solution space: stdlib, existing code, open-source, prior art. A 30-minute search can save a 30-hour custom build." },
514
+ { name: "Outside Voice", description: "When confidence is high and options seem obvious, that is exactly when to seek contradiction. Ask: what would a skeptical reviewer challenge here? What assumption am I not questioning?" }
494
515
  ],
495
516
  reviewSections: [
496
517
  {
@@ -555,12 +576,15 @@ const DESIGN = {
555
576
  },
556
577
  artifactValidation: [
557
578
  { section: "Architecture Boundaries", required: true, validationRule: "Must list component boundaries with ownership." },
579
+ { section: "Architecture Diagram", required: true, validationRule: "At least one diagram (ASCII, Mermaid, or image) showing component boundaries and data flow direction." },
558
580
  { section: "Data Flow", required: true, validationRule: "Must include happy path, nil input, empty input, upstream error paths." },
559
581
  { section: "Failure Mode Table", required: true, validationRule: "Each failure mode has: trigger, detection, mitigation, user impact." },
560
582
  { section: "Test Strategy", required: true, validationRule: "Must define unit/integration/e2e expectations with coverage targets." },
583
+ { section: "What Already Exists", required: true, validationRule: "For each sub-problem: existing code/library found (Layer 1-3/EUREKA label), reuse decision, and adaptation needed." },
561
584
  { section: "NOT in scope", required: true, validationRule: "Work considered and explicitly deferred with one-line rationale." },
562
585
  { section: "Parallelization Strategy", required: false, validationRule: "If multi-module: dependency table, parallel lanes, conflict flags." },
563
- { section: "Unresolved Decisions", required: false, validationRule: "If any: what info is missing, who provides it, default if unanswered." }
586
+ { section: "Unresolved Decisions", required: false, validationRule: "If any: what info is missing, who provides it, default if unanswered." },
587
+ { section: "Completion Dashboard", required: true, validationRule: "Lists every review section with status (clear / issues-found-resolved / issues-open), decision count, and unresolved items (or 'None')." }
564
588
  ],
565
589
  namedAntiPattern: {
566
590
  title: "Architecture Will Emerge While Coding",
@@ -110,11 +110,34 @@ export const ARTIFACT_TEMPLATES = {
110
110
  `,
111
111
  "03-design.md": `# Design Artifact
112
112
 
113
+ ## Codebase Investigation
114
+ | File | Current responsibility | Patterns discovered |
115
+ |---|---|---|
116
+ | | | |
117
+
118
+ ## Search Before Building
119
+ | Layer | Label | What to reuse first |
120
+ |---|---|---|
121
+ | Layer 1 | | |
122
+ | Layer 2 | | |
123
+ | Layer 3 | | |
124
+
113
125
  ## Architecture Boundaries
114
126
  | Component | Responsibility | Owner |
115
127
  |---|---|---|
116
128
  | | | |
117
129
 
130
+ ## Architecture Diagram
131
+
132
+ \\\`\\\`\\\`
133
+ (ASCII, Mermaid, or tool-generated diagram showing component boundaries and data flow direction)
134
+ \\\`\\\`\\\`
135
+
136
+ ## What Already Exists
137
+ | Sub-problem | Existing code/library | Layer | Reuse decision |
138
+ |---|---|---|---|
139
+ | | | | |
140
+
118
141
  ## Data Flow
119
142
  - Happy path:
120
143
  - Nil/empty input path:
@@ -142,6 +165,17 @@ export const ARTIFACT_TEMPLATES = {
142
165
  | Decision | Missing info | Owner | Default |
143
166
  |---|---|---|---|
144
167
  | | | | |
168
+
169
+ ## Completion Dashboard
170
+ | Review Section | Status | Issues |
171
+ |---|---|---|
172
+ | Architecture Review | | |
173
+ | Code Quality Review | | |
174
+ | Test Review | | |
175
+ | Performance Review | | |
176
+ | Distribution & Delivery Review | | |
177
+
178
+ **Decisions made:** 0 | **Unresolved:** 0
145
179
  `,
146
180
  "04-spec.md": `# Specification Artifact
147
181
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cclaw-cli",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "description": "Installer-first flow toolkit for coding agents",
5
5
  "type": "module",
6
6
  "bin": {