bmad-plus 0.23.1 → 0.24.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 (30) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +23 -13
  3. package/package.json +2 -2
  4. package/readme-international/README.de.md +23 -13
  5. package/readme-international/README.es.md +23 -13
  6. package/readme-international/README.fr.md +23 -13
  7. package/src/bmad-plus/agents/agent-architect-dev/SKILL.md +13 -0
  8. package/src/bmad-plus/agents/agent-architect-dev/bmad-skill-manifest.yaml +1 -1
  9. package/src/bmad-plus/agents/agent-maker/SKILL.md +4 -0
  10. package/src/bmad-plus/agents/agent-orchestrator/SKILL.md +13 -0
  11. package/src/bmad-plus/agents/agent-orchestrator/bmad-skill-manifest.yaml +1 -1
  12. package/src/bmad-plus/agents/agent-quality/SKILL.md +13 -0
  13. package/src/bmad-plus/agents/agent-quality/bmad-skill-manifest.yaml +1 -1
  14. package/src/bmad-plus/agents/agent-strategist/SKILL.md +13 -0
  15. package/src/bmad-plus/agents/agent-strategist/bmad-skill-manifest.yaml +1 -1
  16. package/src/bmad-plus/data/role-triggers.yaml +108 -0
  17. package/src/bmad-plus/module-help.csv +1 -0
  18. package/src/bmad-plus/module.yaml +1 -0
  19. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/analyst-agent.md +10 -0
  20. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/architect-agent.md +11 -0
  21. package/src/bmad-plus/packs/pack-dev-studio/categories/planning/pm-agent.md +10 -0
  22. package/src/bmad-plus/packs/pack-memory/templates/session-handoff.md +3 -0
  23. package/src/bmad-plus/packs/pack-seo/seo-chief.md +2 -0
  24. package/src/bmad-plus/packs/pack-shield/shield-orchestrator.md +6 -0
  25. package/src/bmad-plus/skills/bmad-plus-challenge/SKILL.md +149 -0
  26. package/src/bmad-plus/skills/bmad-plus-intake/SKILL.md +4 -2
  27. package/src/bmad-plus/skills/bmad-plus-intake/ref/intake-format.md +9 -0
  28. package/tools/build/intake-contract.js +97 -1
  29. package/tools/cli/commands/intake.js +4 -0
  30. package/tools/cli/lib/packs.js +44 -12
@@ -48,6 +48,28 @@ strategist:
48
48
  reasoning:
49
49
  - "research_complete_needs_specification"
50
50
 
51
+ # `challenge` names the skill bmad-plus-challenge, not a persona: the agent keeps its
52
+ # role and opens the skill. The generic phrases live here, on Atlas; each other agent
53
+ # below carries longer phrases that name its own subject, which are the more specific.
54
+ challenge:
55
+ patterns:
56
+ - "stress-test"
57
+ - "stress test"
58
+ - "challenge my plan"
59
+ - "poke holes"
60
+ - "grill the plan"
61
+ - "challenge the brief"
62
+ - "challenge the PRD"
63
+ - "challenge mon plan"
64
+ - "critique mon plan"
65
+ - "trouve les failles"
66
+ - "challenge mon brief"
67
+ contexts:
68
+ - "brief_about_to_freeze"
69
+ - "plan_with_open_dependencies"
70
+ reasoning:
71
+ - "choices_unmade_behind_the_document"
72
+
51
73
  architect-dev:
52
74
  default_role: dev
53
75
  auto_triggers:
@@ -108,6 +130,19 @@ architect-dev:
108
130
  - "complex_feature_needs_explanation"
109
131
  - "public_api_changed"
110
132
 
133
+ challenge:
134
+ patterns:
135
+ - "challenge the architecture"
136
+ - "stress-test the architecture"
137
+ - "challenge the refactor"
138
+ - "challenge mon architecture"
139
+ - "critique mon architecture"
140
+ contexts:
141
+ - "architecture_with_open_choices"
142
+ - "irreversible_step_planned"
143
+ reasoning:
144
+ - "refactor_target_not_agreed"
145
+
111
146
  quality:
112
147
  default_role: qa
113
148
  auto_triggers:
@@ -169,6 +204,18 @@ quality:
169
204
  - "human_observable_change_delivered"
170
205
  - "delivery_awaiting_human_acceptance"
171
206
 
207
+ challenge:
208
+ patterns:
209
+ - "attack the plan"
210
+ - "unproven assumption"
211
+ - "challenge the assumptions"
212
+ - "attaque le plan"
213
+ - "hypothèse non prouvée"
214
+ contexts:
215
+ - "plan_assumption_unproven"
216
+ reasoning:
217
+ - "acceptance_criteria_assume_unproven_fact"
218
+
172
219
  orchestrator:
173
220
  default_role: scrum-master
174
221
  auto_triggers:
@@ -230,6 +277,18 @@ orchestrator:
230
277
  - "stories_have_no_shared_dependencies"
231
278
  - "workload_can_be_distributed"
232
279
 
280
+ challenge:
281
+ patterns:
282
+ - "challenge the plan before launch"
283
+ - "stress-test the run"
284
+ - "challenge le plan avant lancement"
285
+ - "challenge ce lancement"
286
+ contexts:
287
+ - "launch_inputs_shaky"
288
+ - "parallel_stories_share_open_decision"
289
+ reasoning:
290
+ - "run_inputs_unsettled"
291
+
233
292
  seo:
234
293
  default_role: seo-chief
235
294
  auto_triggers:
@@ -243,11 +302,14 @@ seo:
243
302
  - "SERP"
244
303
  - "on-page"
245
304
  - "meta tags"
305
+ - "challenge the SEO strategy"
306
+ - "challenge la stratégie SEO"
246
307
  # Level 2 — Contextual (situations detected during work)
247
308
  contexts:
248
309
  - "seo_audit_requested"
249
310
  - "website_launch"
250
311
  - "organic_traffic_drop"
312
+ - "strategy_goals_unstated"
251
313
  # Level 3 — Reasoning chain
252
314
  reasoning:
253
315
  - "organic_visibility_concern"
@@ -312,3 +374,49 @@ design:
312
374
  reasoning:
313
375
  - "ui_looks_generic"
314
376
  - "accessibility_unverified"
377
+
378
+ # The packs below declare no other triggers: these entries only name the phrases that open
379
+ # bmad-plus-challenge for the persona that drives it. The persona keeps its role.
380
+ dev-studio:
381
+ default_role: pm-agent
382
+ auto_triggers:
383
+ analyst-agent:
384
+ patterns:
385
+ - "challenge the product brief"
386
+ - "challenge le product brief"
387
+ contexts:
388
+ - "brief_target_user_unchosen"
389
+ pm-agent:
390
+ patterns:
391
+ - "challenge the PRD scope"
392
+ - "stress-test the requirements"
393
+ - "challenge le périmètre du PRD"
394
+ contexts:
395
+ - "prd_about_to_freeze"
396
+ architect-agent:
397
+ patterns:
398
+ - "challenge the ADRs"
399
+ - "stress-test the epics"
400
+ - "challenge les ADR"
401
+ contexts:
402
+ - "architecture_choices_open"
403
+
404
+ shield:
405
+ default_role: shield-orchestrator
406
+ auto_triggers:
407
+ shield-orchestrator:
408
+ patterns:
409
+ - "challenge the compliance scope"
410
+ - "challenge le périmètre de conformité"
411
+ contexts:
412
+ - "compliance_scope_unstated"
413
+
414
+ maker:
415
+ default_role: agent-maker
416
+ auto_triggers:
417
+ agent-maker:
418
+ patterns:
419
+ - "challenge the agent scope"
420
+ - "challenge le périmètre de l'agent"
421
+ contexts:
422
+ - "agent_purpose_unclear"
@@ -11,3 +11,4 @@ bmad-plus-agent-maker,"Talk to Maker — your Agent Creator. Designs, builds, an
11
11
  bmad-plus-uat,"Human acceptance recipes (recette): turn a delivery into a step-by-step page a person plays, read their run, classify every failure, and gate the delivery on it."
12
12
  bmad-plus-intake,"Pack intake: ask the questions a pack needs before it acts, in the user's language and a few at a time, record each answer, default or unknown, and render the brief the pack works from."
13
13
  bmad-plus-swarm,"Run a swarm of sub-agents under a budget: deal simulated buyers or a jury, brief one sub-agent per unit, file and check their answers, tally them with the disclosure first. Use for panels, juries and fanouts."
14
+ bmad-plus-challenge,"Stress-test a plan, a design or a decision before work starts: map the choices it depends on, ask each open round with a recommended answer, log every decision as answered, defaulted or unknown. Also attacks an existing plan file."
@@ -120,6 +120,7 @@ packs:
120
120
  - agent-orchestrator
121
121
  skills:
122
122
  - bmad-plus-autopilot
123
+ - bmad-plus-challenge
123
124
  - bmad-plus-intake
124
125
  - bmad-plus-parallel
125
126
  - bmad-plus-sync
@@ -47,3 +47,13 @@ Record the inspected inputs, important uncertainties, rejected explanations and
47
47
  decision rationale in the selected workflow's report. On return, reread changed
48
48
  inputs and update affected conclusions. Preserve unresolved dissent; an earlier
49
49
  recommendation does not make a new product direction an authorized decision.
50
+
51
+ ## When to challenge
52
+
53
+ Open the Core skill `bmad-plus-challenge` before a product brief or PR/FAQ is
54
+ written when its target user, problem or success measure rests on a choice nobody
55
+ has made, and the supplied material does not settle it. Pass the reason, the open
56
+ decision and what you already established, with sources. Do not open it for
57
+ research requests, or for a brief whose open points the user has answered. At most
58
+ 6 questions per round, a soft cap of 5 rounds, and "stop" ends it at any time.
59
+ Continue only after the user confirms the end; build on its `decisions.md`.
@@ -44,3 +44,14 @@ Use small examples of requests, responses or state transitions to expose ambigui
44
44
  Report uncertain assumptions and missing validation honestly. A complete document
45
45
  does not establish that the proposed system works. Keep authoring decisions
46
46
  separate from implementation status, and preserve human edits when revising plans.
47
+
48
+ ## When to challenge
49
+
50
+ Open the Core skill `bmad-plus-challenge` before an architecture or an epic split
51
+ is written when three or more choices it depends on are open (data ownership,
52
+ interfaces, deployment, security boundary), or when a step cannot be undone and
53
+ an assumption behind it is unproven. Pass the reason, the open decision and what
54
+ the code and the PRD already fix, with paths. Do not open it for a routine
55
+ choice the project already imposes or for a readiness check. At most 6 questions
56
+ per round, a soft cap of 5 rounds, and "stop" ends it at any time. Write the
57
+ architecture only after the user confirms the end; build on its `decisions.md`.
@@ -46,3 +46,13 @@ Deliver the selected workflow's artifact, rationale and unresolved decisions.
46
46
  A PRD is ready only for the uses its evidence supports; a readable document alone
47
47
  does not establish feasibility or approval. On resume, compare inputs, preserve
48
48
  requirement IDs and record the impact of changed decisions on dependent work.
49
+
50
+ ## When to challenge
51
+
52
+ Open the Core skill `bmad-plus-challenge` before a PRD is frozen when two or more
53
+ scope, priority or constraint decisions it depends on are still open, or when
54
+ stakeholders disagree and the text would hide it. Pass the reason, the open
55
+ decision and the requirements already agreed, with their sources. Do not open it
56
+ for an edit to an approved PRD or a validation without changes. At most 6
57
+ questions per round, a soft cap of 5 rounds, and "stop" ends it at any time.
58
+ Freeze the PRD only after the user confirms the end; build on its `decisions.md`.
@@ -9,6 +9,9 @@ project: "{{project_name}}"
9
9
 
10
10
  # Session Handoff — {{date}}
11
11
 
12
+ <!-- Never write a secret (token, key, password) in this file. Name where it lives instead: "the deploy key is in the CI secret store". -->
13
+ <!-- Refer to an artefact by its path. Do not copy its content here. -->
14
+
12
15
  ## What changed
13
16
  <!-- Summary of work done this session -->
14
17
 
@@ -35,6 +35,8 @@ overrides numeric placeholders in report templates.
35
35
  - **Auto-generate code fixes** for common issues (meta tags, schema JSON-LD, robots.txt improvements)
36
36
  - Estimate impact and effort for each recommendation
37
37
 
38
+ **When to challenge**: open the Core skill `bmad-plus-challenge` before a strategy or roadmap is fixed, when the target markets, the business goal or the pages that must rank are unstated and the audit data does not settle them. Pass the reason, the open decision and what the audit established, with its sources. Do not open it to prioritise the findings of an audit or for a quick win. At most 6 questions per round, a soft cap of 5 rounds, and "stop" ends it at any time. Write the roadmap only after the user confirms the end; build on its `decisions.md`.
39
+
38
40
  ### Role: Reporter
39
41
  **Trigger**: Report generation, export, summary
40
42
  - Produce structured Markdown reports
@@ -179,6 +179,12 @@ Produce a unified report using the `shared/audit-report-template.md` format, hig
179
179
 
180
180
  ---
181
181
 
182
+ ## When to Challenge
183
+
184
+ Open the Core skill `bmad-plus-challenge` before a compliance scope is fixed, when the frameworks, the systems in scope, the data categories or the jurisdictions are not stated and the project files do not settle them. Pass the reason, the open decision and what you already know, with sources. Do not open it for a single-framework question, a control lookup or a review of a stated scope. At most 6 questions per round, a soft cap of 5 rounds, and "stop" ends it at any time. An open scope item stays `unknown` with its risk in the report. Start the analysis only after the user confirms the end; build on its `decisions.md`.
185
+
186
+ ---
187
+
182
188
  ## Interactive Menu
183
189
 
184
190
  When the user is unsure which framework to use, present this interactive guide:
@@ -0,0 +1,149 @@
1
+ ---
2
+ name: bmad-plus-challenge
3
+ description: Stress-test a plan, a design or a decision with the user before any work starts, or attack an existing plan file. Map the choices the plan depends on, look in the project before asking, ask the whole open frontier in one numbered round with a recommended answer for each question, and log every decision as answered, defaulted or unknown in decisions.md. Use when someone says "stress-test", "challenge my plan", "poke holes", "grill the plan", "challenge mon plan", "critique mon plan", "trouve les failles", or when an agent is about to act on a plan whose dependencies are not settled.
4
+ ---
5
+
6
+ # Challenge a plan
7
+
8
+ ## Overview
9
+
10
+ A plan fails where a choice it depends on was never made, or was made on a guess. This skill
11
+ finds those choices before work starts, settles them with the user in few rounds, and writes down
12
+ what was decided, on what basis and at what risk. It asks; it never builds, edits or runs
13
+ anything.
14
+
15
+ ```
16
+ plan ─► decision tree ─► look in the project ─► frontier ─► one numbered round ─► user answers
17
+ ▲ │
18
+ └───────────── answers unlock the next questions ◄──────────────────────┘
19
+ user confirms the end ─► decisions.md ─► hand over
20
+ ```
21
+
22
+ ## When to activate
23
+
24
+ - The user asks to stress-test, challenge, critique or poke holes in a plan, a design or a decision.
25
+ - The user names a plan file to attack (see "Adversarial mode").
26
+ - An agent is about to act on a plan with open dependencies (see "Called by another agent").
27
+
28
+ Do not challenge trivial work: a change that one person reverts in minutes, a request that already
29
+ says exactly what to do, a question with one obvious answer (ask it plainly), a decision a
30
+ `decisions.md` of this subject already covers, or a pack that declares its own questions (see
31
+ "What this skill is not").
32
+
33
+ ## Protocol
34
+
35
+ 1. **Frame.** Restate the plan in two or three lines and pick a subject slug (lowercase, hyphens).
36
+ If `_bmad-output/<subject>/decisions.md` exists, read it and resume from it.
37
+ 2. **Build the decision tree.** List the choices the plan rests on. Give each an id (`d1`, `d2`…)
38
+ and the ids that must be settled before it can even be asked: "which database" waits for
39
+ "single tenant or multi-tenant". Show the user a compact indented tree once, in round 1.
40
+ 3. **Look before you ask.** For every open choice, search the repository, the installed project
41
+ files (`AGENTS.md`, `README`, `package.json`, `docs/`, `project-context.md`) and
42
+ `_bmad-output/`. When the answer is there, do not ask: state what you found and where
43
+ ("`d3` is settled by `package.json`: Node 20"), record it, and move on. The user can overrule it
44
+ in the next message.
45
+ 4. **Find the frontier.** The frontier is every open choice whose prerequisites are all settled
46
+ (answered, defaulted or unknown). Ask the whole frontier in one numbered round, at most 6
47
+ questions. With more, take the ones whose wrong answer costs most and carry the rest over.
48
+ Never put a question in a round while a prerequisite of it is still open, even when its answer
49
+ looks obvious.
50
+ 5. **Ask with a recommendation.** Each question carries the answer you recommend, phrased so that a
51
+ bare "yes" accepts it, and one line of why:
52
+
53
+ ```
54
+ 2. Do users sign in with an email link only?
55
+ Recommended: yes, email link only, no passwords to store or reset.
56
+ Why: the audience is occasional and the plan has no support staff.
57
+ ```
58
+
59
+ Ask in the user's language. A question is one decision, never a bundle.
60
+ 6. **Record what you heard**, one status per decision, the same words as the pack intake:
61
+ - `answered`: the user gave the answer, or said "yes" to a recommendation. A fact found in a
62
+ file counts, with the file as its source.
63
+ - `defaulted`: the user delegated ("your call", "use your defaults") and your recommendation
64
+ stands. It is a proposal the user let stand, not a fact the user gave, and every deliverable
65
+ built on it says so.
66
+ - `unknown`: nobody knows yet. Keep the risk: what breaks if the plan goes ahead on the wrong
67
+ guess, and who or what could settle it.
68
+ 7. **Loop.** Each answer can unlock questions, remove some or add new ones: update the tree, find
69
+ the new frontier, ask the next round. Stop when no choice is open.
70
+ 8. **Soft cap of 5 rounds.** After round 5, stop asking. Summarise what is still open, what each
71
+ open item blocks, and let the user say "stop" or "continue". "Continue" buys more rounds, and
72
+ the summary comes back after each further round. The user can say "stop" at any time: every
73
+ open choice is then recorded `unknown` with its risk, and your recommendation is kept in the
74
+ notes, not adopted.
75
+ 9. **Confirm the end.** Show the table of decisions and ask whether to close the session. Until
76
+ the user confirms, nothing is executed and nothing is written: no commands beyond reading,
77
+ no file created, no plan edited.
78
+ 10. **Write and hand over.** Write `_bmad-output/<subject>/decisions.md` (layout below); a file
79
+ that already exists is updated row by row, never replaced. Then offer
80
+ to hand it to the agent the plan needs next: Atlas for a brief or a PRD, Forge for an
81
+ architecture or a refactor, Nexus for a sprint, a swarm or a parallel run.
82
+
83
+ ## decisions.md
84
+
85
+ ```markdown
86
+ # Decisions — <subject>
87
+
88
+ <One line: the plan, the date (YYYY-MM-DD) and the mode (interview or adversarial).>
89
+
90
+ ## Decisions
91
+
92
+ | ID | Decision | Status | Answer | Source | Risk |
93
+ |----|----------|--------|--------|--------|------|
94
+ | d1 | Who signs in | answered | Staff only | user | |
95
+ | d2 | Session length | defaulted | 12 hours | recommendation | Staff are logged out mid-task if shifts run longer |
96
+ | d3 | Data retention | unknown | | | Deletion rules unknown: a legal review may force a rewrite |
97
+
98
+ ## Open items
99
+
100
+ - d3: what is missing, who can settle it, what it blocks.
101
+
102
+ ## Next
103
+
104
+ Hand over to Forge: why this agent, and what it should read first.
105
+ ```
106
+
107
+ One table, one row per decision. `Source` is `user`, a file path, or `recommendation` for a
108
+ `defaulted` row. `Risk` stays empty on an `answered` row and is never empty on `defaulted` or
109
+ `unknown`. `Open items` lists every `unknown` row and anything the user left unanswered; write
110
+ `None.` when there is none.
111
+
112
+ ## Adversarial mode
113
+
114
+ The user names a plan file ("challenge `docs/plan.md`"). Read it. Do not edit it.
115
+
116
+ 1. List the assumptions the plan rests on, written or implied, as `a1`, `a2`… with one line each.
117
+ 2. Rank them by how much breaks if the assumption is false and how little evidence supports it.
118
+ 3. Attack the weakest first: give the failure scenario in one or two sentences, what the project
119
+ already shows for or against (with the path), and the question or the cheapest test that would
120
+ settle it.
121
+ 4. Assumptions that depend on others wait, as in the decision tree. Rounds, recommendations,
122
+ the soft cap, the "stop" exit and the end-of-session confirmation work as in the protocol.
123
+ 5. `decisions.md` keeps the same layout. Each row is an assumption, the answer is the verdict
124
+ (holds, fails, or what must change), and `Open items` carries the changes the plan needs.
125
+
126
+ ## Called by another agent
127
+
128
+ An agent that is about to act on shaky inputs can open this skill. It states, before the first
129
+ round:
130
+
131
+ - **why** it calls (the plan is about to be frozen, an architecture starts, a run launches);
132
+ - **which decision is open**;
133
+ - **what it already knows**, each fact with its source.
134
+
135
+ What the caller knows is settled: record it with the source `caller: <agent>`, do not search for
136
+ it again and do not ask the user to confirm it. If a lookup you made anyway contradicts it, say so
137
+ once and let the user rule. Start with the open decision and its tree. When the caller names no
138
+ open decision, hand that back instead of opening a session.
139
+
140
+ The result is the same `decisions.md`, handed back to the caller. The caller resumes its own work
141
+ only after the user has confirmed the end of the session.
142
+
143
+ ## What this skill is not
144
+
145
+ - Not the pack intake. When a pack declares its questions, `bmad-plus intake` asks them and keeps
146
+ the book; this skill discovers the questions a plan needs when nobody wrote them down.
147
+ - Not a code review or a test: it does not read the implementation to judge it.
148
+ - Not the plan itself. It settles the choices; Atlas, Forge or Nexus write and run the plan.
149
+ - Not a gate. The user decides, and "stop" always works.
@@ -38,10 +38,12 @@ nor marked unknown with its risk. Never invent an answer.
38
38
  `_bmad-output/<pack>/intake.json`; the brief goes where the pack's first step reads it.
39
39
  2. **Plan.** `bmad-plus intake plan --intake FILE --answers FILE --json`. Exit 0 means ready;
40
40
  exit 2 means a must-have is open. `next` lists what to ask now, must-haves first, in the
41
- file's order, never more than `max_per_message`.
41
+ file's order, never more than `max_per_message`. A question that waits for another
42
+ (`after`) is not in `next`; `blocked` names it and what it waits for.
42
43
  3. **Ask in the user's language** (`language: user`) or in the tag the intake names. One
43
44
  message, the questions of `next`, each with its choices or bounds when it has them, and
44
- the default where one exists ("5 unless you say otherwise"). Do not pad, do not rephrase
45
+ the default where one exists ("5 unless you say otherwise") or the question's `suggest` as
46
+ a recommendation, never as a recorded answer. Do not pad, do not rephrase
45
47
  the question's intent, do not ask what is already recorded.
46
48
  4. **Record what you heard.** `bmad-plus intake record --intake FILE --answers FILE --set
47
49
  id=VALUE ... --json`. A value is checked against the question's kind and bounds and
@@ -49,6 +49,15 @@ sections:
49
49
  - `must_have: true` requires `risk_if_unknown` and forbids `default`: the user answers it or
50
50
  marks it unknown. A question that is not must-have may carry a `default`, valid for its kind.
51
51
  - `feeds` names the artifact anchors the answer fills (`file#anchor`); informative.
52
+ - `after: [id, ...]` (optional) makes a question wait for other questions of the file, in any
53
+ section: `plan` keeps it out of `next` while any of them has no entry in the answers, and lists
54
+ it under `blocked` with the ids it waits for. Any entry settles a prerequisite, `unknown`
55
+ included. The list holds distinct ids of other questions and forms no cycle; `check` refuses
56
+ the rest. A file that declares no `after` has no `blocked` in its plan. A blocked must-have
57
+ still counts as missing.
58
+ - `suggest: text` (optional, at most 4000 characters) is a recommendation `plan` shows next to
59
+ the question, on a must-have too. It is not a default: it is never recorded for the user,
60
+ never counted and never written to the brief. The user still answers.
52
61
  - Question ids are `snake_case` and unique across the whole file; section ids are slugs.
53
62
 
54
63
  ## 2. Answers (`.json`, written by `bmad-plus intake record`)
@@ -45,7 +45,10 @@ const QUESTION_KEYS = new Set([
45
45
  'must_have',
46
46
  'feeds',
47
47
  'risk_if_unknown',
48
+ 'after',
49
+ 'suggest',
48
50
  ]);
51
+ const QUESTION_ID_RE = /^[a-z][a-z0-9_]*$/;
49
52
  const ENTRY_KEYS = new Set(['status', 'value', 'risk']);
50
53
 
51
54
  const isPlainObject = (value) =>
@@ -164,6 +167,78 @@ function validateQuestion(question, where, problems) {
164
167
  problems.push(`${where}: "feeds" must list artifact anchors such as brief.md#surface`);
165
168
  }
166
169
  }
170
+ if (question.after !== undefined) {
171
+ if (
172
+ !Array.isArray(question.after) ||
173
+ question.after.length === 0 ||
174
+ !question.after.every((id) => typeof id === 'string' && QUESTION_ID_RE.test(id)) ||
175
+ new Set(question.after).size !== question.after.length
176
+ ) {
177
+ problems.push(`${where}: "after" must list distinct question ids`);
178
+ }
179
+ }
180
+ if (question.suggest !== undefined) {
181
+ if (!isText(question.suggest)) {
182
+ problems.push(`${where}: "suggest" must be a non-empty text`);
183
+ } else if (question.suggest.length > MAX_TEXT) {
184
+ problems.push(`${where}: "suggest" is longer than ${MAX_TEXT} characters`);
185
+ } else if (hasControlCharacter(question.suggest)) {
186
+ problems.push(`${where}: "suggest" holds a control character`);
187
+ }
188
+ }
189
+ }
190
+
191
+ /**
192
+ * The `after` links of a file whose questions are otherwise valid: each id must name
193
+ * another question of the file, and the links must not close a loop.
194
+ */
195
+ function validateOrder(intake, problems) {
196
+ const questions = new Map();
197
+ intake.sections.forEach((section, index) =>
198
+ (isPlainObject(section) && Array.isArray(section.questions) ? section.questions : []).forEach(
199
+ (question, position) => {
200
+ if (
201
+ isPlainObject(question) &&
202
+ typeof question.id === 'string' &&
203
+ !questions.has(question.id)
204
+ )
205
+ questions.set(question.id, {
206
+ question,
207
+ label: `sections[${index}].questions[${position}]`,
208
+ });
209
+ }
210
+ )
211
+ );
212
+ const prerequisites = (id) => {
213
+ const after = questions.get(id).question.after;
214
+ return Array.isArray(after)
215
+ ? after.filter((other) => questions.has(other) && other !== id)
216
+ : [];
217
+ };
218
+ for (const [id, { question, label }] of questions) {
219
+ if (!Array.isArray(question.after)) continue;
220
+ for (const other of question.after) {
221
+ if (typeof other !== 'string' || !QUESTION_ID_RE.test(other)) continue;
222
+ if (other === id) problems.push(`${label}: "after" names the question itself`);
223
+ else if (!questions.has(other))
224
+ problems.push(`${label}: "after" names unknown question "${other}"`);
225
+ }
226
+ }
227
+ // Depth-first walk; a question met again while still on the path closes a cycle.
228
+ const state = new Map();
229
+ const walk = (id, path) => {
230
+ state.set(id, 'open');
231
+ for (const other of prerequisites(id)) {
232
+ if (state.get(other) === 'open') {
233
+ const loop = [...path.slice(path.indexOf(other)), id, other];
234
+ problems.push(
235
+ `${questions.get(id).label}: "after" forms a cycle (each waits for the next): ${loop.join(' -> ')}`
236
+ );
237
+ } else if (!state.has(other)) walk(other, [...path, id]);
238
+ }
239
+ state.set(id, 'done');
240
+ };
241
+ for (const id of questions.keys()) if (!state.has(id)) walk(id, []);
167
242
  }
168
243
 
169
244
  /**
@@ -241,6 +316,7 @@ function validateIntake(intake) {
241
316
  validateQuestion(question, label, problems);
242
317
  });
243
318
  });
319
+ validateOrder(intake, problems);
244
320
  return { ok: problems.length === 0, problems };
245
321
  }
246
322
 
@@ -327,12 +403,16 @@ function publicQuestion(question) {
327
403
  ...(question.max !== undefined ? { max: question.max } : {}),
328
404
  ...(question.default !== undefined ? { default: question.default } : {}),
329
405
  ...(question.risk_if_unknown !== undefined ? { risk: question.risk_if_unknown } : {}),
406
+ ...(question.suggest !== undefined ? { suggest: question.suggest } : {}),
330
407
  };
331
408
  }
332
409
 
333
410
  /**
334
411
  * What to ask next and whether the pack may act. Both inputs must be valid.
335
412
  * `ready` holds once every must-have is answered or marked unknown with its risk.
413
+ * A pending question waits while a question in its `after` has no entry yet (answered,
414
+ * defaulted and unknown all settle it): it stays out of `next` and shows in `blocked`
415
+ * with the ids it waits for. `blocked` is present only when the file declares an `after`.
336
416
  */
337
417
  function planIntake(intake, answers = emptyAnswers(intake)) {
338
418
  const limit = intake.max_per_message ?? MAX_PER_MESSAGE.fallback;
@@ -340,7 +420,14 @@ function planIntake(intake, answers = emptyAnswers(intake)) {
340
420
  const recorded = (question) => entryOf(answers.answers, question.id);
341
421
  const pending = questions.filter((question) => recorded(question) === undefined);
342
422
  const missing = pending.filter((question) => question.must_have === true);
343
- const next = [...missing, ...pending.filter((question) => question.must_have !== true)]
423
+ const waitingFor = (question) =>
424
+ (question.after ?? []).filter((id) => entryOf(answers.answers, id) === undefined);
425
+ const blocked = pending.filter((question) => waitingFor(question).length > 0);
426
+ const askable = (question) => !blocked.includes(question);
427
+ const next = [
428
+ ...missing.filter(askable),
429
+ ...pending.filter((question) => question.must_have !== true && askable(question)),
430
+ ]
344
431
  .slice(0, limit)
345
432
  .map(publicQuestion);
346
433
  const unknowns = questions
@@ -360,6 +447,15 @@ function planIntake(intake, answers = emptyAnswers(intake)) {
360
447
  ready: missing.length === 0,
361
448
  missing: missing.map((question) => question.id),
362
449
  next,
450
+ ...(questions.some((question) => question.after !== undefined)
451
+ ? {
452
+ blocked: blocked.map((question) => ({
453
+ id: question.id,
454
+ mustHave: question.must_have === true,
455
+ waitingFor: waitingFor(question),
456
+ })),
457
+ }
458
+ : {}),
363
459
  unknowns,
364
460
  counts: {
365
461
  questions: questions.length,
@@ -21,11 +21,15 @@ function describePlan(result) {
21
21
  if (question.choices) hints.push(`choices: ${question.choices.join(', ')}`);
22
22
  if (question.default !== undefined)
23
23
  hints.push(`default: ${JSON.stringify(question.default)}`);
24
+ if (question.suggest !== undefined) hints.push(`suggest: ${question.suggest}`);
24
25
  lines.push(
25
26
  ` - ${question.id} [${question.kind}] ${question.ask}${hints.length ? ` (${hints.join('; ')})` : ''}`
26
27
  );
27
28
  }
28
29
  }
30
+ for (const blocked of result.blocked ?? []) {
31
+ lines.push(`Blocked: ${blocked.id} — waits for ${blocked.waitingFor.join(', ')}`);
32
+ }
29
33
  for (const unknown of result.unknowns) {
30
34
  lines.push(`Unknown: ${unknown.id}${unknown.risk ? ` — risk: ${unknown.risk}` : ''}`);
31
35
  }