baldart 4.93.0 → 4.95.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 (49) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/VERSION +1 -1
  3. package/framework/.claude/agents/REGISTRY.md +3 -3
  4. package/framework/.claude/agents/api-perf-cost-auditor.md +1 -1
  5. package/framework/.claude/agents/codebase-architect.md +57 -109
  6. package/framework/.claude/agents/hybrid-ml-architect.md +1 -1
  7. package/framework/.claude/agents/legal-counsel-gdpr.md +1 -1
  8. package/framework/.claude/agents/plan-auditor.md +1 -1
  9. package/framework/.claude/agents/prd-card-writer.md +108 -1
  10. package/framework/.claude/agents/security-reviewer.md +1 -1
  11. package/framework/.claude/commands/codexreview.md +1 -1
  12. package/framework/.claude/skills/bug/CHANGELOG.md +4 -0
  13. package/framework/.claude/skills/bug/SKILL.md +6 -4
  14. package/framework/.claude/skills/context-primer/CHANGELOG.md +10 -0
  15. package/framework/.claude/skills/context-primer/SKILL.md +26 -60
  16. package/framework/.claude/skills/ds-handoff/CHANGELOG.md +4 -0
  17. package/framework/.claude/skills/ds-handoff/SKILL.md +3 -2
  18. package/framework/.claude/skills/e2e-review/CHANGELOG.md +4 -0
  19. package/framework/.claude/skills/e2e-review/SKILL.md +6 -4
  20. package/framework/.claude/skills/new/CHANGELOG.md +4 -0
  21. package/framework/.claude/skills/new/SKILL.md +1 -1
  22. package/framework/.claude/skills/new/references/completeness.md +9 -0
  23. package/framework/.claude/skills/new/references/final-review.md +2 -1
  24. package/framework/.claude/skills/new/references/implement.md +1 -1
  25. package/framework/.claude/skills/new2/CHANGELOG.md +4 -0
  26. package/framework/.claude/skills/new2/SKILL.md +1 -1
  27. package/framework/.claude/skills/prd/CHANGELOG.md +15 -0
  28. package/framework/.claude/skills/prd/SKILL.md +1 -1
  29. package/framework/.claude/skills/prd/assets/card-template.yml +13 -1
  30. package/framework/.claude/skills/prd/references/audit-phase.md +42 -51
  31. package/framework/.claude/skills/prd/references/discovery-phase.md +7 -3
  32. package/framework/.claude/skills/prd/references/validation-phase.md +2 -1
  33. package/framework/.claude/skills/prd-add/CHANGELOG.md +4 -0
  34. package/framework/.claude/skills/prd-add/SKILL.md +3 -2
  35. package/framework/.claude/skills/ui-design/CHANGELOG.md +4 -0
  36. package/framework/.claude/skills/ui-design/SKILL.md +2 -2
  37. package/framework/.claude/workflows/new-card-review.js +1 -1
  38. package/framework/.claude/workflows/new-final-review.js +1 -1
  39. package/framework/.claude/workflows/new2.js +6 -2
  40. package/framework/agents/analysis-profiles.md +286 -0
  41. package/framework/agents/card-schema.md +60 -1
  42. package/framework/agents/index.md +2 -1
  43. package/framework/agents/skills-mapping.md +4 -0
  44. package/framework/scripts/validate-card-baseline.js +62 -4
  45. package/framework/templates/primitives/AGENTS.CHANGELOG.md +10 -0
  46. package/framework/templates/primitives/AGENTS.md +8 -3
  47. package/framework/templates/primitives/CLAUDE.CHANGELOG.md +6 -0
  48. package/framework/templates/primitives/CLAUDE.md +5 -2
  49. package/package.json +1 -1
@@ -552,8 +552,12 @@ async function runCard(cardId, cardPath) {
552
552
  let arch = null
553
553
  try {
554
554
  arch = await agentSafe(
555
- `You are the Phase-1 context retriever for card ${cardId} (per ${REF}/implement.md Phase 1 step 3 / 5b). cd into the worktree ${sharedCtx.worktreePath}.\n\n${cardBrief}\n\n` +
556
- `Explore the codebase exactly as your system prompt mandates for this card's scope (requirements + files_likely_touched: ${JSON.stringify(node.filesLikelyTouched || [])}). Write your COMPLETE untruncated findings (file paths, type signatures, patterns, high-risk paths) to ${baselinePath} — refresh it if a stale copy exists. The owner agent and the per-card reviewers will Read that file; keep your structured return MINIMAL.\n\n` +
555
+ `You are the Phase-1 context retriever for card ${cardId} (per ${REF}/implement.md Phase 1 step 3 / 5b). cd into the worktree ${sharedCtx.worktreePath}.\n\n` +
556
+ // Analysis profile (v4.94.0 implement.md step 3 parallel): deterministic from the
557
+ // pre-flight hasMockup bit, mirroring the mockup-first build routing (§6a). SSOT:
558
+ // agents/analysis-profiles.md § 3 caller routing table.
559
+ `PROFILE=${node.hasMockup ? 'ui' : 'feature'} OUTPUT=terse — resolve your analysis profile per agents/analysis-profiles.md (Grep "### PROFILE: ${node.hasMockup ? 'ui' : 'feature'}", Read only that section + its cited shared blocks).\n\n${cardBrief}\n\n` +
560
+ `Explore the codebase exactly as your system prompt + profile mandate for this card's scope (requirements + files_likely_touched: ${JSON.stringify(node.filesLikelyTouched || [])}). Write your COMPLETE untruncated findings (file paths, type signatures, patterns, high-risk paths) to ${baselinePath} — refresh it if a stale copy exists. The owner agent and the per-card reviewers will Read that file; keep your structured return MINIMAL.\n\n` +
557
561
  `Also report missingPaths: every path in files_likely_touched that does NOT exist in the worktree (factual ls/test check — no judgement). Return: { ok, missingPaths:[...], note }`,
558
562
  { label: `architect:${cardId}`, phase: 'Implement', agentType: 'codebase-architect',
559
563
  schema: { type: 'object', required: ['ok'], additionalProperties: true, properties: { ok: { type: 'boolean' }, missingPaths: { type: 'array', items: { type: 'string' } }, note: { type: 'string' } } } }
@@ -0,0 +1,286 @@
1
+ # Analysis Profiles — the codebase-architect investigation contract
2
+
3
+ **Purpose**: `codebase-architect` is the single read-only analyst every surface delegates
4
+ to, but "understand the codebase" is not one job — grounding an implementer, tracing a
5
+ bug, measuring blast radius, loading planning context, and inventorying UI primitives
6
+ need different retrieval plans and different output blocks. This module is the **single
7
+ SSOT of those plans**. The agent body carries the shared engine (canonical-router-first,
8
+ tiered code search, read-size discipline, memory); each profile here scopes WHICH parts
9
+ of that engine run, what to read/skip, and which output blocks the caller receives.
10
+
11
+ This is the retrieval-side twin of `effort-protocol.md` (how deeply to reason) and
12
+ `return-contract-protocol.md` (how compactly to report). Same mechanism as `OUTPUT=terse`
13
+ (v4.49.0): a prompt-level token, zero new config keys, zero runtime dependency.
14
+
15
+ **Consumers**: `codebase-architect` (dispatcher — reads its matching profile section at
16
+ spawn), every caller that spawns it (`/new` implement.md, `new2.js` B7, the review
17
+ workflows, `/prd`, `/prd-add`, `/bug`, `/ui-design`, `/ds-handoff`, `/codexreview`,
18
+ `plan-auditor`, `/e2e-review`), and `context-primer` (maps its task types onto profiles
19
+ instead of restating search strategy).
20
+
21
+ ---
22
+
23
+ ## 1. Contract
24
+
25
+ - **Token**: the invoking prompt contains `PROFILE=<feature|bug|impact|discovery|ui|baseline>`
26
+ (one token, anywhere in the prompt — same parsing style as `OUTPUT=terse` and
27
+ `effort=<level>`). Composable with `OUTPUT=terse` and an explicit token budget.
28
+ - **Dispatch (agent side)**: parse the token FIRST. Then Grep this file for the heading
29
+ `### PROFILE: <name>` and Read ONLY that section (plus any `§ Shared block` it cites) —
30
+ never read this module end-to-end.
31
+ - **No token → deterministic inference**, in this exact priority order (first match wins):
32
+ 1. prompt names a mockup / `links.design` / `component_bindings` / design-system
33
+ registry / tokens → `ui`
34
+ 2. prompt asks blast-radius / affected surface / "what depends on" / refactor scope →
35
+ `impact`
36
+ 3. prompt reports an error / crash / regression / "non funziona" → `bug`
37
+ 4. prompt grounds a post-implementation review over a diff/batch → `baseline`
38
+ 5. prompt loads context for planning / PRD / a question about docs or product intent →
39
+ `discovery`
40
+ 6. otherwise → `full` (legacy monolith behavior: run every protocol, all output blocks).
41
+ - **Caller side**: prefer the explicit token — inference is the fallback, not the design.
42
+ The routing table in § 3 is normative for framework callers.
43
+ - **Invariants that hold for EVERY profile** (they live in the agent body, not here):
44
+ read-only role boundary; Return Contract (COMPACT); canonical-router-first engine;
45
+ anti-flail gate; read-size discipline; `## Canonical Evidence` block in every analysis;
46
+ Hot-File Map on terse output for in-scope files > 800 lines; memory hygiene.
47
+ - **Precedence**: an explicit instruction in the invoking prompt (e.g. a caller-supplied
48
+ token budget or an extra output field) overrides the profile default. A profile never
49
+ overrides the role boundary or the Return Contract.
50
+
51
+ ## 2. Profiles
52
+
53
+ ### PROFILE: feature
54
+
55
+ - **Question**: what exists in this area, which patterns must a change follow, what can
56
+ be reused, where are the risks?
57
+ - **Callers**: `/new` implement.md Phase 1 step 3 + `new2.js` B7 (cards WITHOUT a
58
+ mockup), ad-hoc pre-implementation grounding, `hybrid-ml-architect` /
59
+ `security-reviewer` / `legal-counsel-gdpr` Phase-0 grounding.
60
+ - **Retrieval**: full engine — canonical router → git log (if thin) → structural tier
61
+ (graph/LSP per `code-search-protocol.md` / `code-graph-protocol.md`) → targeted reads.
62
+ - **Run**: § Shared block: Reuse Analysis · § Shared block: Documentation Reliability
63
+ Scan (when docs are evidence).
64
+ - **Skip**: nothing engine-side; skip the UI cascade unless the scope touches components
65
+ (then the caller should have routed `ui`).
66
+ - **Output blocks**: `## Reuse Analysis` + `## Canonical Evidence` + affected-code rows
67
+ (`path:line — symbol — pattern/role`) + high-risk rows + `## Hot-File Map` + `totals:`.
68
+ - **Budget**: ≤ 20K tokens.
69
+
70
+ ### PROFILE: bug
71
+
72
+ - **Question**: what is the code path from entry point to failure, and what changed
73
+ recently on it?
74
+ - **Callers**: `/bug` Phase 0; context-primer `task_type: bug-fix`.
75
+ - **Retrieval**: entry-point location (structural tier first for the failing
76
+ symbol/handler) → trace the path → `git log --oneline -15 -- <suspect paths>` for
77
+ recent-change candidates → targeted range reads of suspects only.
78
+ - **Run**: nothing extra — speed is the point.
79
+ - **Skip**: § Reuse Analysis (no component discovery in a bug hunt) · architecture docs
80
+ and ADRs unless the failure is a contract violation · broad domain reads.
81
+ - **Output blocks**: `## Canonical Evidence` + a **code-path map** (ordered
82
+ `path:line — step` rows from entry to failure) + a **recent-change list**
83
+ (`sha — path — why suspect`) + `## Hot-File Map` for any suspect file > 800 lines +
84
+ `totals:`.
85
+ - **Budget**: ≤ 15K tokens.
86
+
87
+ ### PROFILE: impact
88
+
89
+ - **Question**: if X changes, what breaks — which files, contracts, and consumers are in
90
+ the blast radius?
91
+ - **Callers**: `plan-auditor` FULL-mode grounding; `/prd` Step 2 ISA (Impact Surface
92
+ Analysis); `/prd-add` PATCH mode (affected dimensions only); `/e2e-review` route/
93
+ primitive reverse lookup; refactor scoping; context-primer `task_type: refactor`.
94
+ - **Retrieval**: **structural tier is PRIMARY** — `graphify affected`/`path` when
95
+ `features.has_code_graph: true`, LSP `find-references` when `has_lsp_layer: true`,
96
+ else exports/imports reads per the engine's anti-flail rule. Router only to resolve
97
+ the owning contract docs of the affected surface.
98
+ - **Run**: § Shared block: Documentation Reliability Scan only for the contract docs you
99
+ cite.
100
+ - **Skip**: § Reuse Analysis · full-file reads of dependents (list them, read only the
101
+ coupling site) · design rationale.
102
+ - **Output blocks**: `## Canonical Evidence` + an **affected-surface table**
103
+ (`path:line — dependent symbol — direction (uses/used-by) — contract at risk`) +
104
+ transitive one-hop notes + `totals:`.
105
+ - **Budget**: ≤ 15K tokens.
106
+
107
+ ### PROFILE: discovery
108
+
109
+ - **Question**: what context does a planner (or a human asking a question) need —
110
+ constraints, canonical sources, current state — before any decision?
111
+ - **Callers**: `context-primer` (`task_type: new-feature | query | doc-update`); `/prd`
112
+ discovery-loop targeted questions.
113
+ - **Retrieval**: docs-first — canonical router → matched reference/ADR sections →
114
+ backlog cards → wiki overlay (when `features.has_wiki_overlay: true`, verify wiki
115
+ claims against canonicals) → agent memory. **Source code only to verify a
116
+ runtime-sensitive claim** (auth pattern, API contract, current schema).
117
+ - **Task-type deltas** (passed through by context-primer): `query`/`doc-update` → docs +
118
+ memory only, skip source entirely; `new-feature` → also map the domain's existing
119
+ patterns (2-3 exemplar `path:line` anchors) and relevant ADRs.
120
+ - **Run**: § Shared block: Documentation Reliability Scan (docs ARE the evidence here —
121
+ mandatory).
122
+ - **Skip**: § Reuse Analysis · code-wide scans · reading any `${paths.prd_dir}` /
123
+ `${paths.references_dir}` file end-to-end (route via the registry, read sections).
124
+ - **Output blocks**: `## Canonical Evidence` + § Reliability Scan block + constraints-
125
+ first summary (the caller may impose its own envelope, e.g. context-primer's XML —
126
+ honor it verbatim).
127
+ - **Budget**: ≤ 15K tokens.
128
+
129
+ ### PROFILE: ui
130
+
131
+ - **Question**: which registry primitives/tokens/patterns serve this UI scope, what is
132
+ reused vs variant vs genuinely new, and what does the current implementation state
133
+ look like — **answered from the registry and code, never from pixels**.
134
+ - **Callers**: `/new` implement.md + `new2.js` B7 (cards WITH a mockup —
135
+ `links.design`/`links.design_src` non-empty); `/ui-design` Step 3 adjacent-UI
136
+ analysis; `/ds-handoff` entity/field probe; context-primer UI-keyword branch.
137
+ - **Retrieval**: § Shared block: UI Resolution Path is the PRIMARY route — INDEX.md
138
+ (thin router) → frontmatter **HEAD** of matched `components/<Name>.md` → DTCG tokens →
139
+ patterns. **Never read component source to learn an API its HEAD already carries**;
140
+ read source only for undocumented primitives or to verify a runtime-sensitive claim.
141
+ When `features.has_design_system: false`, degrade to
142
+ `${paths.references_dir}/component-registry.md` + targeted source reads.
143
+ - **Run**: § Shared block: Reuse Analysis (component-flavored — candidates come from the
144
+ registry cascade, classification uses the card's `component_bindings` vocabulary
145
+ `reuse / reuse-variant / new` when present).
146
+ - **Skip**: backend/data-model deep dives (one-line integration notes only) · § UI
147
+ boundary below.
148
+ - **Output blocks**: `## Reuse Analysis` (component table) + `## Canonical Evidence` +
149
+ binding/coverage notes (`region — bound component — status`) + token findings
150
+ (hardcoded-value risks as `path:line — value — owning token`) + `## Hot-File Map` +
151
+ `totals:`.
152
+ - **Budget**: ≤ 15K tokens.
153
+ - **UI boundary (binding)**: this profile is **code/registry-side only**. Rendered
154
+ evidence — mockup images, screenshots, live routes — belongs to the multimodal
155
+ specialists: analysis of mockup pixels → a read-only `ui-expert` spawn (the
156
+ `/prd` Step 1.6.5 precedent), fidelity verdicts → the verifier trio via `/e2e-review`.
157
+ If the invoking prompt asks you to judge pixels, flag it as over-scoped and return the
158
+ code/registry map (same rule as the Role boundary for implementation asks).
159
+
160
+ ### PROFILE: baseline
161
+
162
+ - **Question**: what is the EXISTING architecture around this diff/batch, so reviewers
163
+ can spot regressions?
164
+ - **Callers**: `new-final-review.js` / `new-card-review.js` Phase Baseline (fallback
165
+ when no per-card baselines exist); `/codexreview` Step 1; `/new` final-review F.2
166
+ inline fallback.
167
+ - **Retrieval**: diff-scoped — start from the changed-files list, resolve each file's
168
+ module/contract via router + structural tier; NO topic-wide exploration beyond the
169
+ seams the diff touches.
170
+ - **Run**: nothing extra.
171
+ - **Skip**: § Reuse Analysis · § Reliability Scan (cite doc freshness only if a doc
172
+ contradicts the code) · product-intent docs.
173
+ - **Output blocks**: `## Canonical Evidence` + key-module map (`path — contract — why it
174
+ matters to this diff`) + regression-prone seams (`path:line — risk`) +
175
+ `## Hot-File Map` + `totals:`. Persist to the caller-named file when one is given
176
+ (e.g. `/tmp/arch-baseline-<CARD-ID>.md`) — persist-then-summarize per the Return
177
+ Contract.
178
+ - **Budget**: ≤ 20K tokens (batch scope); ≤ 15K per single card.
179
+
180
+ ### PROFILE: full (fallback — no token, no inference match)
181
+
182
+ Legacy monolith behavior: run the whole engine, § Reuse Analysis when the task builds or
183
+ changes code, § Reliability Scan when docs are evidence, UI Resolution Path when the
184
+ query concerns UI. All output blocks that apply. Budget ≤ 20K. Callers in the framework
185
+ payload should never rely on `full` — pass a token.
186
+
187
+ ## 3. Caller routing table (normative for framework surfaces)
188
+
189
+ | Caller | Profile |
190
+ |---|---|
191
+ | `/new` implement.md Phase 1 step 3 · `new2.js` B7 | `ui` if card has non-empty `links.design` OR `links.design_src` (the `hasMockup` bit), else `feature` |
192
+ | `new-final-review.js` / `new-card-review.js` Phase Baseline · `/codexreview` Step 1 | `baseline` |
193
+ | `plan-auditor` FULL-mode grounding spawn | `impact` |
194
+ | `/prd` discovery-loop targeted question | `discovery` |
195
+ | `/prd` Step 2 ISA touchpoint mapping · `/prd-add` PATCH | `impact` |
196
+ | `/bug` Phase 0 | `bug` |
197
+ | `/ui-design` Step 3 · `/ds-handoff` probe | `ui` |
198
+ | `/e2e-review` route/primitive reverse lookup | `impact` |
199
+ | `context-primer` | by task type: `bug-fix→bug` · `refactor→impact` · `new-feature/query/doc-update→discovery` · UI keywords + `has_design_system:true` → `ui` |
200
+
201
+ ## 4. Shared blocks
202
+
203
+ ### § Shared block: Reuse Analysis
204
+
205
+ Run **only when a profile lists it** (feature, ui, full-when-building).
206
+
207
+ 1. **Identify what the task needs**: UI components, hooks, utilities, API patterns, data
208
+ flows.
209
+ 2. **Search for existing matches**:
210
+ - `features.has_design_system: true` → the fastest reuse signal is the **spec HEADs**:
211
+ `${paths.design_system}/INDEX.md` (thin router), then the frontmatter HEAD of
212
+ candidate `components/<Name>.md` (schema: `component-manifest-schema.md`). Prefer
213
+ this over Grep.
214
+ - Else `${paths.references_dir}/component-registry.md` (relevant table section only).
215
+ - Grep only for 2-3 specific component names, never broad semantic sweeps.
216
+ 3. **Classify each candidate**: **Direct reuse** (works as-is) · **Refactor & reuse**
217
+ (≥70% fit — generalize via props/config) · **Extract & share** (logic duplicated in
218
+ 2+ places) · **No match** (build new — document why).
219
+ 4. **Agent memory**: read `.claude/agent-memory/codebase-architect/shared-components.md`
220
+ only when the task involves UI components; update it with new discoveries.
221
+
222
+ Output format (emit in every analysis whose profile runs this block; if nothing is
223
+ reusable, emit the section with "No reusable components found — all new code required"
224
+ and why):
225
+
226
+ ```markdown
227
+ ## Reuse Analysis
228
+
229
+ ### Reusable Components Found
230
+ | Need | Existing Component | Path | Classification | Action |
231
+ |------|-------------------|------|----------------|--------|
232
+
233
+ ### No Match (Must Build New)
234
+ - [component/pattern]: [why nothing existing fits]
235
+
236
+ ### Refactoring Opportunities
237
+ - [duplication worth consolidating, even if adjacent to this task]
238
+ ```
239
+
240
+ ### § Shared block: UI Resolution Path
241
+
242
+ The design-system resolution cascade (paths are project-specific; this order is the
243
+ convention — the protocol SSOT is `design-system-protocol.md`):
244
+
245
+ 1. `${paths.design_system}/INDEX.md` — thin router (name → source → purpose → spec)
246
+ 2. `${paths.design_system}/components/<Name>.md` — **frontmatter HEAD first**
247
+ (props/variants/composes/token_bindings/a11y — schema in
248
+ `component-manifest-schema.md`); prose body only for rationale. Never read source to
249
+ learn an API the HEAD carries.
250
+ 3. `${paths.design_tokens}` (DTCG `.tokens.json`) — token SSOT; `tokens-reference.md` is
251
+ a generated view
252
+ 4. `${paths.design_system}/patterns/*` — theming, overlays, animations, platform quirks
253
+ 5. `${paths.references_dir}/ui-guidelines.md` — brand philosophy and aesthetic rules
254
+ 6. `${paths.references_dir}/component-registry.md` — shared-component inventory
255
+
256
+ ### § Shared block: Documentation Reliability Scan
257
+
258
+ Run when a profile lists it AND documentation is part of the evidence set:
259
+
260
+ 1. **Registry coverage** — the feature exists in `${paths.references_dir}/ssot-registry.md`;
261
+ backlog/PRD-only → report `REGISTRY_GAP`
262
+ 2. **Freshness markers** — `Last updated`/change-log markers vs `git log -1` on the doc
263
+ 3. **Link quality** — markdown links vs raw paths; path-heavy PRDs lower retrieval quality
264
+ 4. **Retrieval risk** — doc exceeds repo thresholds (reference >400 lines, API >800,
265
+ PRD/spec >800) → headings + targeted sections, never a full read
266
+ 5. **Router fit** — registry maps the feature to a canonical doc → prefer that route
267
+
268
+ Emit in every analysis that materially depends on docs:
269
+
270
+ ```markdown
271
+ ## Documentation Reliability Scan
272
+
273
+ - Registry coverage: [ok | REGISTRY_GAP: ...]
274
+ - Freshness status: [fresh | stale | unknown] (git evidence)
275
+ - Link quality: [ok | PATH_HEAVY: ...]
276
+ - Retrieval risk: [ok | OVERSIZE_DOC: ...]
277
+ - Router fit: [ok | WEAK_ROUTER_MATCH: ...]
278
+ ```
279
+
280
+ ---
281
+
282
+ **Codex parity: portable.** The token is prompt-level; this module ships in the bulk-
283
+ symlinked `agents/` payload both runtimes read; the agent body (dispatcher) transpiles to
284
+ `.codex/agents/codebase-architect.toml` unchanged. No new config key — profiles gate on
285
+ flags that already exist (`has_design_system`, `has_code_graph`, `has_lsp_layer`,
286
+ `has_wiki_overlay`), so the schema-change propagation rule does not apply.
@@ -56,7 +56,8 @@ Legend: **R** = required, present **and non-empty** · **E** = required key, val
56
56
  | `scope` | R | R | R | **never omittable** — encodes intent |
57
57
  | `scope_boundaries` | R | C | C | "Omit for standalone cards with no siblings" (`prd-card-writer.md`) |
58
58
  | `requirements` | C | R | R | EPIC tracks via AC-EPIC; CHILD/STANDALONE: faithfully derivable from AC+scope when both present — see consumer contract |
59
- | `acceptance_criteria` | R (AC-EPIC) | R | R | |
59
+ | `acceptance_criteria` | R (AC-EPIC) | R | R | CHILD/STANDALONE: EARS grammar — see § "Acceptance-criteria grammar (EARS)" |
60
+ | `ac_verification` | — | C | C | OPTIONAL map `AC-N → executable oracle` (or `manual: <check>`); authored by `/prd`, executed by `/new` Phase 2.5 — see § below |
60
61
  | `definition_of_done` | R | R | R | |
61
62
  | `depends_on` / `blocks` | E (`[]`) | E | E | |
62
63
  | `estimated_complexity` | C | R | R | |
@@ -212,6 +213,64 @@ Rules:
212
213
  - Omit any sub-field whose session id is unavailable (env var unset) rather than writing a
213
214
  placeholder.
214
215
 
216
+ ## Acceptance-criteria grammar (EARS) + per-AC oracles (since the EARS+verify wave)
217
+
218
+ **Why**: a prose AC passes gates without being verifiable ("handle it correctly"), and
219
+ prose gates get gamed (measured: visible/holdout gap +28pt per 10x code; exploit rate
220
+ 0.6→13.9% post-RL). Two complementary halves: the AC is binary BY FORM (EARS), and its
221
+ verification is EXECUTABLE, defined at planning time.
222
+
223
+ ### EARS grammar (CHILD/STANDALONE `acceptance_criteria` — epic AC-EPIC roll-ups exempt)
224
+
225
+ Every AC entry is `"[ ] [AC-N] <EARS clause>"` where the clause matches ONE of the five
226
+ EARS patterns:
227
+
228
+ | Pattern | Form |
229
+ |---|---|
230
+ | Ubiquitous | `THE SYSTEM SHALL <behavior>` |
231
+ | Event-driven | `WHEN <trigger> THE SYSTEM SHALL <behavior>` |
232
+ | State-driven | `WHILE <state> THE SYSTEM SHALL <behavior>` |
233
+ | Optional-feature | `WHERE <feature is present> THE SYSTEM SHALL <behavior>` |
234
+ | Unwanted-behavior | `IF <error condition> THEN THE SYSTEM SHALL <behavior>` |
235
+
236
+ Non-regression variant: `… THE SYSTEM SHALL CONTINUE TO <existing behavior>`.
237
+
238
+ - The clause body stays in the project language (`identity.language`); the EARS keywords
239
+ stay English — they are syntactic markers, like field names.
240
+ - **Vague verbs are BANNED** (validator ban-list: `correttamente`, `appropriato/a`,
241
+ `properly`, `appropriately`, `as expected`, `gracefully`, `handle correctly`, `gestire
242
+ corrett*`) — name the observable behavior instead.
243
+ - Enforced by `validate-card-baseline.js --prd` (BLOCKER) — i.e. at `/prd` authoring time
244
+ only. Legacy cards are never retro-blocked: `/new`'s baseline conformance (1b-iii) does
245
+ NOT apply the EARS check.
246
+
247
+ Worked example (rewritten from a real card):
248
+ - Before: `"[ ] [AC-2] La lista fornitori si aggiorna correttamente dopo il salvataggio"`
249
+ - After: `"[ ] [AC-2] WHEN il salvataggio di un fornitore va a buon fine THE SYSTEM SHALL mostrare il fornitore aggiornato nella lista senza reload manuale"`
250
+
251
+ ### `ac_verification` — per-AC executable oracle (OPTIONAL map)
252
+
253
+ ```yaml
254
+ ac_verification:
255
+ AC-1: "npm run test -- --grep 'supplier hub layout'"
256
+ AC-2: "grep -q 'useSupplierList' src/app/settings/suppliers/page.tsx"
257
+ AC-3: "manual: verifica visiva dello stato empty su viewport 375px"
258
+ ```
259
+
260
+ - **Authoring** (`prd-card-writer`): a command is written ONLY if verified to exist — an
261
+ npm script in `package.json`, a command in `toolchain.commands.*`, a cited test file
262
+ that exists. NEVER invent commands (same class as the Field Grounding Rule). Not
263
+ automatable → explicit `manual: <what a human checks>`.
264
+ - **Consumption** (`/new` Phase 2.5 completeness check — the AC-verification owner): an AC
265
+ with a non-`manual:` oracle is verified by EXECUTING it; the exit status is the primary
266
+ evidence. Judgment covers only `manual:` oracles and oracle-less ACs. (`qa-sentinel` is
267
+ deliberately NOT the consumer — AC verification is out of its scope by contract.)
268
+ - **Relation to `validation_commands`**: that field stays the card-level suite;
269
+ `ac_verification` is the per-AC mapping. The validator WARNs when a non-manual oracle
270
+ is absent from `validation_commands` (drift guard between the two).
271
+ - **Enforcement is WARN-first** (the `--prd` validator warns on missing entries for cards
272
+ with code-testable outputs); any hard gate comes only after telemetry on real runs.
273
+
215
274
  ## Writer contract
216
275
 
217
276
  The canonical writer is the `prd-card-writer` agent. It emits the full baseline for the
@@ -13,7 +13,7 @@ Route agents to the right module with minimal reading.
13
13
  ### Documentation Routing
14
14
 
15
15
  - **MANDATORY pre-read for any skill/agent that touches project-specific paths, identity, stack, or feature toggles** -> read `agents/project-context.md`. Skills consult `baldart.config.yml` + `.baldart/overlays/<skill>.md` instead of hard-coded paths; missing keys MUST be asked, never assumed.
16
- - If needing to understand codebase structure, existing patterns, or architecture before planning -> MUST invoke `codebase-architect` agent (via Task tool) first; do not proceed without architectural understanding.
16
+ - If needing to understand codebase structure, existing patterns, or architecture before planning -> MUST invoke `codebase-architect` agent (via Task tool) first, passing the matching `PROFILE=<feature|bug|impact|discovery|ui|baseline>` token per `agents/analysis-profiles.md` (§ 3 routing table); do not proceed without architectural understanding.
17
17
  - If searching for a function/type/symbol (identifier-shaped query, not free text) and `features.has_lsp_layer: true` -> read `agents/code-search-protocol.md` and prefer LSP `find-references` / `go-to-definition` over Grep. Falls back to Grep when LSP is unavailable or the query is textual.
18
18
  - If the question is STRUCTURAL / RELATIONAL (what connects X to Y, blast-radius/impact, clusters) and `features.has_code_graph: true` -> read `agents/code-graph-protocol.md` and prefer the Graphify code graph (`graphify query`/`path`/`explain`/`affected`) over LSP/Grep. Falls back silently to LSP -> Grep -> Git when the graph is unavailable.
19
19
  - If touching API endpoints or request/response shape -> read `agents/api-contracts.md` and `${paths.references_dir}/api/index.md` (then specific API module for your domain).
@@ -71,6 +71,7 @@ When adding or updating agents, update REGISTRY.md — not this file.
71
71
  - `agents/skills-mapping.md`
72
72
  - `agents/llm-wiki-methodology.md` — LLM wiki overlay methodology (manual + scheduled maintenance; since v2.0.0)
73
73
  - `agents/project-context.md` — Project context protocol: `baldart.config.yml` + overlays + missing-key handling (since v3.0.0)
74
+ - `agents/analysis-profiles.md` — Analysis-profile contract for `codebase-architect`: the `PROFILE=<feature|bug|impact|discovery|ui|baseline>` prompt token, per-profile retrieval plans + output blocks + budgets, caller routing table, shared blocks (Reuse Analysis · UI Resolution Path · Documentation Reliability Scan). The retrieval-side twin of `effort-protocol.md` + `return-contract-protocol.md` (since v4.94.0)
74
75
  - `agents/code-search-protocol.md` — Retrieval hierarchy for code search: LSP → Grep → Git (since v3.10.0, gated on `features.has_lsp_layer`)
75
76
  - `agents/code-graph-protocol.md` — Structural/relational retrieval via the Graphify code knowledge graph (since v4.21.0, gated on `features.has_code_graph`)
76
77
  - `agents/toolchain-protocol.md` — Mechanical-gate command resolution (lint/format/typecheck/test/build/audit) from `toolchain.commands.*` with silent project-standard fallback (since v4.41.0, gated on `features.has_toolchain`)
@@ -101,6 +101,10 @@ which enforce the contract above.
101
101
  - "/cont [keywords]"
102
102
  - Auto-invoked by `/prd` at kickoff
103
103
 
104
+ **Note**: the skill is the interactive *channel* to `codebase-architect`, not a
105
+ competing methodology — it detects the task type and passes the matching
106
+ `PROFILE=<bug|impact|discovery|ui>` token per `agents/analysis-profiles.md` (§ 3).
107
+
104
108
  ### new
105
109
 
106
110
  **When to use**:
@@ -29,7 +29,11 @@
29
29
  * acceptance_criteria + scope MUST have non-empty requirements;
30
30
  * - epic `review_profile` must be `skip`;
31
31
  * - `[NEEDS CLARIFICATION: …]` ambiguity markers in the raw YAML are BLOCKERS —
32
- * a card ships only when every planning ambiguity has been resolved.
32
+ * a card ships only when every planning ambiguity has been resolved;
33
+ * - EARS grammar on child/standalone acceptance_criteria (5 patterns + vague-verb
34
+ * ban-list) — BLOCKER; epics exempt. SSOT: card-schema.md § "Acceptance-criteria
35
+ * grammar (EARS)";
36
+ * - `ac_verification` per-AC oracle coverage — WARN-only (never fails the run).
33
37
  *
34
38
  * Module API (for CI self-tests in scripts/check-card-baseline.js):
35
39
  * const { validateCard, detectProfile, loadSchema, loadEnums } = require(...)
@@ -373,12 +377,30 @@ function scanAmbiguityMarkers(text) {
373
377
  return out;
374
378
  }
375
379
 
380
+ // EARS grammar — SSOT: card-schema.md § "Acceptance-criteria grammar (EARS)".
381
+ // Keywords are English syntactic markers; the clause body may be any language.
382
+ const EARS_PATTERNS = [
383
+ /^THE SYSTEM SHALL .+/,
384
+ /^WHEN .+ THE SYSTEM SHALL .+/,
385
+ /^WHILE .+ THE SYSTEM SHALL .+/,
386
+ /^WHERE .+ THE SYSTEM SHALL .+/,
387
+ /^IF .+ THEN THE SYSTEM SHALL .+/,
388
+ ];
389
+ const VAGUE_VERB_RE = /(correttamente|appropriat[oa]|properly|appropriately|as expected|gracefully|handle correctly|gestire corrett)/i;
390
+
391
+ /** "[ ] [AC-3] WHEN … THE SYSTEM SHALL …" → { id: 'AC-3', clause: 'WHEN … …' } (null if unparseable) */
392
+ function parseAcEntry(entry) {
393
+ const m = String(entry).match(/^\s*\[[ xX]?\]\s*\[(AC-\d+)\]\s*(.+)$/);
394
+ return m ? { id: m[1], clause: m[2].trim() } : null;
395
+ }
396
+
376
397
  /**
377
398
  * The deterministic subset of /prd validation-phase Step 6 item 0 (see file header).
378
- * Returns string[] errors. `text` is the raw YAML (marker scan), `card` the parsed map.
399
+ * Returns { errors, warnings }. `text` is the raw YAML (marker scan), `card` the parsed map.
379
400
  */
380
401
  function prdGateChecks(card, text, profile) {
381
402
  const errors = [];
403
+ const warnings = [];
382
404
  if (profile !== 'EPIC' && nonEmpty(card.acceptance_criteria) && nonEmpty(card.scope) && !nonEmpty(card.requirements)) {
383
405
  errors.push("has acceptance_criteria + scope but no 'requirements' — emit requirements (faithful restatement of AC + scope) before commit (PO1)");
384
406
  }
@@ -388,7 +410,37 @@ function prdGateChecks(card, text, profile) {
388
410
  for (const m of scanAmbiguityMarkers(text)) {
389
411
  errors.push(`unresolved ambiguity marker — resolve with the user before commit: ${m}`);
390
412
  }
391
- return errors;
413
+ // EARS grammar + vague-verb ban (child/standalone only; epic AC-EPIC roll-ups exempt)
414
+ if (profile !== 'EPIC' && Array.isArray(card.acceptance_criteria)) {
415
+ for (const entry of card.acceptance_criteria) {
416
+ const ac = parseAcEntry(entry);
417
+ if (!ac) continue; // malformed entry shape is the matrix/consumer contract's concern
418
+ if (VAGUE_VERB_RE.test(ac.clause)) {
419
+ errors.push(`${ac.id} uses a banned vague verb — name the observable behavior (card-schema.md § EARS): "${ac.clause.slice(0, 90)}"`);
420
+ } else if (!EARS_PATTERNS.some((re) => re.test(ac.clause))) {
421
+ errors.push(`${ac.id} is not an EARS clause (THE SYSTEM SHALL / WHEN|WHILE|WHERE … THE SYSTEM SHALL / IF … THEN THE SYSTEM SHALL): "${ac.clause.slice(0, 90)}"`);
422
+ }
423
+ }
424
+ // ac_verification coverage — WARN-only (enforcement is data-driven, never a blocker here)
425
+ const av = card.ac_verification;
426
+ const hasCodeOutputs = nonEmpty(card.files_likely_touched);
427
+ if (!nonEmpty(av)) {
428
+ if (hasCodeOutputs) warnings.push("no 'ac_verification' map — consider per-AC executable oracles (or 'manual: …') per card-schema.md § ac_verification");
429
+ } else if (typeof av === 'object' && !Array.isArray(av)) {
430
+ const vcText = JSON.stringify(card.validation_commands || []);
431
+ for (const entry of card.acceptance_criteria) {
432
+ const ac = parseAcEntry(entry);
433
+ if (!ac) continue;
434
+ const oracle = av[ac.id];
435
+ if (oracle == null || String(oracle).trim() === '') {
436
+ warnings.push(`ac_verification has no entry for ${ac.id}`);
437
+ } else if (!/^manual:/i.test(String(oracle)) && !vcText.includes(String(oracle).slice(0, 40))) {
438
+ warnings.push(`${ac.id} oracle is not in validation_commands (drift guard): "${String(oracle).slice(0, 60)}"`);
439
+ }
440
+ }
441
+ }
442
+ }
443
+ return { errors, warnings };
392
444
  }
393
445
 
394
446
  // --- CLI --------------------------------------------------------------------
@@ -420,7 +472,12 @@ function main(argv) {
420
472
  continue;
421
473
  }
422
474
  const { profile, errors } = validateCard(card, { matrix, enums, filename: path.basename(file) });
423
- if (prdMode) errors.push(...prdGateChecks(card, text, profile));
475
+ let warnings = [];
476
+ if (prdMode) {
477
+ const g = prdGateChecks(card, text, profile);
478
+ errors.push(...g.errors);
479
+ warnings = g.warnings;
480
+ }
424
481
  if (errors.length) {
425
482
  failed++;
426
483
  process.stdout.write(`✖ ${file} [${profile}] — ${errors.length} issue(s):\n`);
@@ -428,6 +485,7 @@ function main(argv) {
428
485
  } else {
429
486
  process.stdout.write(`✓ ${file} [${profile}]\n`);
430
487
  }
488
+ for (const w of warnings) process.stdout.write(` ⚠ ${w}\n`);
431
489
  }
432
490
  return failed ? 1 : 0;
433
491
  }
@@ -4,6 +4,16 @@ Formato: [Keep a Changelog](https://keepachangelog.com/) · [SemVer](https://sem
4
4
  Questo è il changelog INTERNO dello skeleton spedito (`primitive_version`), separato dal
5
5
  file `AGENTS.md` generato nel consumer e indipendente dal `VERSION` del framework.
6
6
 
7
+ ## 1.4.0 — 2026-07-02
8
+
9
+ - **Analysis-profile vocabulary on the understand-before-implement MUST**: the
10
+ `codebase-architect` invocation now names the six profiles
11
+ (`PROFILE=feature|bug|impact|discovery|ui|baseline`) and cites
12
+ `agents/analysis-profiles.md` as the contract SSOT — "understand the codebase" is
13
+ scoped to the job at hand (grounding / failure tracing / blast radius / planning
14
+ context / design-system inventory / review baseline) instead of one monolithic
15
+ exploration. Cross-tool: the token is prompt-level, identical on Claude and Codex.
16
+
7
17
  ## 1.3.0 — 2026-07-01
8
18
 
9
19
  - **Plan-review gate promoted to the cross-tool SSOT**: MUST have any non-trivial plan
@@ -1,4 +1,4 @@
1
- <!-- baldart-primitive: name=AGENTS primitive_version=1.3.0
1
+ <!-- baldart-primitive: name=AGENTS primitive_version=1.4.0
2
2
  This is the SHIPPED SKELETON. The writer (src/utils/root-primitives.js) strips
3
3
  this banner, resolves every {{ slot }} / {{> partial }} / {{#flag}} from
4
4
  baldart.config.yml (+ package.json/README), merges .baldart/overlays/AGENTS.md,
@@ -26,8 +26,13 @@ mechanics — this file remains the single source of truth for the protocol.
26
26
  - MUST treat `AGENTS.md` as authoritative for agent rules.
27
27
  - MUST understand the codebase before planning/implementing — invoke `codebase-architect`
28
28
  (Claude Code: Task tool `subagent_type: codebase-architect`; Codex: the custom agent by
29
- name at `.codex/agents/codebase-architect.toml`). Only if NEITHER mechanism exists,
30
- degrade explicitly to inline retrieval (code-graph → LSP → Grep) and SAY SO.
29
+ name at `.codex/agents/codebase-architect.toml`), passing the matching **analysis
30
+ profile**: `PROFILE=feature` (pre-implementation grounding) · `bug` (failure-path
31
+ tracing) · `impact` (blast radius / refactor scope) · `discovery` (planning / question
32
+ context) · `ui` (design-system / component scope) · `baseline` (review grounding over a
33
+ diff). Contract + per-profile scoping: `agents/analysis-profiles.md`. Only if NEITHER
34
+ invocation mechanism exists, degrade explicitly to inline retrieval
35
+ (code-graph → LSP → Grep) and SAY SO.
31
36
  - MUST have any non-trivial plan reviewed BEFORE presenting it for approval — run
32
37
  `plan-auditor` + `doc-reviewer` (in parallel), incorporate their feedback, and note in the
33
38
  plan that the review gate was honored. Present the ALREADY-reviewed plan, never a raw one.
@@ -4,6 +4,12 @@ Formato: [Keep a Changelog](https://keepachangelog.com/) · [SemVer](https://sem
4
4
  Changelog INTERNO dello stub spedito (`primitive_version`), separato dal `CLAUDE.md`
5
5
  generato nel consumer e indipendente dal `VERSION` del framework.
6
6
 
7
+ ## 1.2.0 — 2026-07-02
8
+
9
+ - Plan Mode: the `codebase-architect` pre-plan invocation now passes the matching
10
+ `PROFILE=<...>` token, citing `AGENTS.md` § Non-negotiables +
11
+ `agents/analysis-profiles.md` (no restatement — the stub stays thin).
12
+
7
13
  ## 1.1.0 — 2026-07-01
8
14
 
9
15
  - Plan Mode delegation now names **both** domain agents — **code → `coder`**, **UI →
@@ -1,4 +1,4 @@
1
- <!-- baldart-primitive: name=CLAUDE primitive_version=1.1.0
1
+ <!-- baldart-primitive: name=CLAUDE primitive_version=1.2.0
2
2
  SHIPPED SKELETON. The writer strips this banner, resolves {{ slot }}/{{#flag}} from
3
3
  baldart.config.yml, merges .baldart/overlays/CLAUDE.md, stamps a baldart-generated
4
4
  marker, and writes the result to the repo root.
@@ -16,7 +16,10 @@ SSOT, not restated here. Below are the **Claude-native mechanics only**.
16
16
 
17
17
  - Enter plan mode (`EnterPlanMode`) for any non-trivial task before writing code.
18
18
  Trivial = single-line fix / typo / obvious bug.
19
- - Invoke `codebase-architect` before writing the plan — never plan blind.
19
+ - Invoke `codebase-architect` before writing the plan — never plan blind. Pass the
20
+ matching `PROFILE=<feature|bug|impact|discovery|ui|baseline>` token (the profile
21
+ vocabulary and routing live in `AGENTS.md` § Non-negotiables and
22
+ `agents/analysis-profiles.md` — not restated here).
20
23
  - Launch `plan-auditor` + `doc-reviewer` in parallel to review the plan, incorporate their
21
24
  feedback, and state inside the plan that the review gate was honored, BEFORE `ExitPlanMode`.
22
25
  - Wait for explicit user approval, then delegate implementation to the domain agent via the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baldart",
3
- "version": "4.93.0",
3
+ "version": "4.95.0",
4
4
  "description": "Claude Agent Framework - Reusable framework for coordinating AI agents and humans in software projects",
5
5
  "bin": {
6
6
  "baldart": "./bin/baldart.js"