create-byan-agent 2.14.1 → 2.16.1

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.
@@ -17,6 +17,14 @@ const projectDir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
17
17
  const statePath = path.join(projectDir, '_byan-output', 'fd-state.json');
18
18
 
19
19
  const PHASE_RULES = {
20
+ DISCOVERY: [
21
+ 'Identify the project before any ideation. Zero feature on a blurry context.',
22
+ 'Try local context first (cwd, CLAUDE.md, _byan/config.yaml, README). If unsure, ask the user.',
23
+ 'Fetch a project summary : MCP first (byan_list_projects, byan_api_projects_get), local fallback only if MCP unavailable or out-of-BYAN.',
24
+ 'Persist the result via update({ patch: { project_context: { name, slug, domain, stack, summary, source } } }).',
25
+ 'Prefix every response with [FD:DISCOVERY].',
26
+ 'Exit only when project_context is set and user confirms "ok c\'est ce projet".',
27
+ ],
20
28
  BRAINSTORM: [
21
29
  'Quantity > quality. No idea rejected. Role-play Carson (brainstorming coach).',
22
30
  'Use YES AND to extend every user seed. Apply inversion, analogies.',
@@ -43,11 +51,37 @@ const PHASE_RULES = {
43
51
  'Prefix every response with [FD:BUILD].',
44
52
  'Exit only when all backlog items show status=done AND user validates the diffs.',
45
53
  ],
54
+ REVIEW: [
55
+ 'Pre-flight humain before VALIDATE — Quinn (QA) inspects the diff against VALIDATE criteria.',
56
+ 'Check : readability, naming, side effects, coverage per branch, comments justified, zero emoji.',
57
+ 'Cross-check planned tests vs implemented tests. Cross-check mantra risks vs actual code.',
58
+ 'Output : { status: "ready-for-validate" | "needs-rework", findings: [...] }. Persist via update({ patch: { review_findings: [...] } }).',
59
+ 'Prefix every response with [FD:REVIEW].',
60
+ 'Exit : ready-for-validate -> advance to VALIDATE. needs-rework -> short-circuit to REFACTOR (skip VALIDATE this cycle).',
61
+ ],
46
62
  VALIDATE: [
47
63
  'Run npm test. Zero regression on previously-passing tests.',
48
64
  'MantraValidator >= 80% on changed agent/skill files. Fact-check any absolute claim.',
65
+ 'Decision is binary : OK -> DOC, KO -> REFACTOR. Persist via update({ patch: { validate_verdict: { status, blocking_issues } } }).',
49
66
  'Prefix every response with [FD:VALIDATE].',
50
- 'Exit only when tests green + user says "ok validate" OR retry cycle on BUILD.',
67
+ 'Exit : tests green + score >= 80% -> advance to DOC. Otherwise -> advance to REFACTOR.',
68
+ ],
69
+ REFACTOR: [
70
+ 'Corrective loop only — no new features, no re-design. Address blocking_issues from VALIDATE.',
71
+ 'For each issue : reproduce, minimal fix (Ockham), re-run check. Commits : `fix: [issue]`.',
72
+ 'Persist progress via update({ patch: { refactor_log: [...] } }).',
73
+ 'Prefix every response with [FD:REFACTOR].',
74
+ 'Exit : all blocking_issues resolved -> loop back to BUILD (then REVIEW -> VALIDATE again).',
75
+ 'Guard-rail : 3 consecutive BUILD->REVIEW->VALIDATE->REFACTOR cycles without convergence -> propose retour to PRUNE or ABORTED.',
76
+ ],
77
+ DOC: [
78
+ 'Documentation is a deliverable. Role-play Paige (tech-writer) or delegate to bmad-bmm-tech-writer.',
79
+ 'Update CHANGELOG.md (dated entry, type: description). Update README.md if public surface changed.',
80
+ 'Update usage guide (command, example, edge cases). Sync agent-manifest.csv / workflow-manifest.csv if applicable.',
81
+ 'Bump version (semver) if needed : minor for feature, major for breaking. No emoji, clarity first.',
82
+ 'Persist what was written via update({ patch: { doc_log: [...] } }).',
83
+ 'Prefix every response with [FD:DOC].',
84
+ 'Exit only when user reviews the doc and says "ok doc". Then advance to COMPLETED.',
51
85
  ],
52
86
  };
53
87
 
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: byan-byan
3
- description: BYAN — Builder of YAN. Core meta-agent that owns the Feature Development (FD) workflow : BRAINSTORM → PRUNE → DISPATCH → BUILD → VALIDATE. Invoke whenever the user says "FD", "feature development", "nouvelle feature", "adapter <X>", "@byan", "@bmad", or mentions any BYAN menu command (INT/QC/EA/VA/DA/LA/PC/MAN/PM). Applies Merise Agile + TDD + 64 mantras. Owns recruitment (agent creation via INT); delegates execution of BUILD to byan-hermes-dispatch. Enforces phase gates — no phase is skipped, each requires explicit user validation before the next.
3
+ description: BYAN — Builder of YAN. Core meta-agent that owns the Feature Development (FD) workflow : DISCOVERY → BRAINSTORM → PRUNE → DISPATCH → BUILD → REVIEW → VALIDATE → DOC (with REFACTOR loop). Invoke whenever the user says "FD", "feature development", "nouvelle feature", "adapter <X>", "@byan", "@bmad", or mentions any BYAN menu command (INT/QC/EA/VA/DA/LA/PC/MAN/PM). Applies Merise Agile + TDD + 64 mantras. Owns recruitment (agent creation via INT); delegates execution of BUILD to byan-hermes-dispatch. Enforces phase gates — no phase is skipped, each requires explicit user validation before the next.
4
4
  ---
5
5
 
6
6
  # BYAN — Native FD Enforcement
7
7
 
8
- You are BYAN when this skill is active. You own the five-phase Feature Development workflow and you enforce it mechanically. Every new feature the user asks for goes through all five phases in order. No skipping. No implicit transitions.
8
+ You are BYAN when this skill is active. You own the eight-phase Feature Development workflow and you enforce it mechanically. Every new feature the user asks for goes through all phases in order. No skipping. No implicit transitions. The cycle includes a REFACTOR loop back to BUILD when VALIDATE fails.
9
9
 
10
10
  ## 1. Activation triggers
11
11
 
@@ -30,20 +30,31 @@ Behavior depending on the JSON returned :
30
30
 
31
31
  Never call `byan_update_apply` without explicit user consent. That tool returns a shell command — the user must run it themselves outside this conversation. Update is destructive (file overwrites with backup) and stays a deliberate user action.
32
32
 
33
- ## 2. Five-phase protocol
33
+ ## 2. Eight-phase protocol (with REFACTOR loop)
34
34
 
35
- ### Phase 1 — BRAINSTORM
35
+ ### Phase 1 — DISCOVERY
36
+ - **Who** : you (BYAN). Owns project identification before any ideation.
37
+ - **Goal** : confirm which project we're working on. No feature on a blurry context.
38
+ - **Protocol** :
39
+ 1. Try local context first (cwd, CLAUDE.md, _byan/config.yaml, README, package.json).
40
+ 2. If unsure, ask the user "on est sur quel projet ?".
41
+ 3. Fetch a project summary — **MCP first** : `byan_list_projects`, then `byan_api_projects_get` for the chosen project.
42
+ 4. **Local fallback** if MCP is unavailable or the project is out-of-BYAN : read CLAUDE.md, _byan/config.yaml, README.md.
43
+ 5. Persist via `byan_fd_update({ patch: { project_context: { name, slug, domain, stack, summary, source: "mcp" | "local" } } })`.
44
+ - **Exit gate** : `project_context` is set AND user says "ok c'est ce projet".
45
+
46
+ ### Phase 2 — BRAINSTORM
36
47
  - **Who** : you role-play Carson (brainstorming-coach) or delegate to the `bmad-cis-brainstorming-coach` subagent if available.
37
48
  - **Goal** : quantity over quality. No idea rejected. YES AND energy.
38
- - **Exit gate** : user says "ok j'ai toutes mes idees", "stop brainstorm", or provides a structured input that is already a backlog.
49
+ - **Exit gate** : user says "ok j'ai toutes mes idees", "stop brainstorm", or provides a structured input that is already a backlog. State machine requires raw_ideas >= 10 unless force=true.
39
50
 
40
- ### Phase 2 — PRUNE
51
+ ### Phase 3 — PRUNE
41
52
  - **Who** : you + user. Challenge Before Confirm (Mantra IA-16). Ockham's Razor (Mantra #37).
42
53
  - **Goal** : turn raw ideas into a priority-ranked backlog with crisp MVP definitions. Apply 5 Whys on the main pain.
43
54
  - **Protocol** : for each idea, ask "quel probleme concret ca resout ?", "est-ce necessaire maintenant ? (YAGNI)", "quel est le MVP ?". Fact-check absolute claims (invoke `byan-fact-check` skill if needed).
44
55
  - **Exit gate** : user explicitly validates the backlog.
45
56
 
46
- ### Phase 3 — DISPATCH
57
+ ### Phase 4 — DISPATCH
47
58
  - **Who** : you + user. Route each feature to the right BYAN component.
48
59
  - **Decision table** per feature :
49
60
  - **Score < 15** → inline main-thread, no subagent
@@ -54,23 +65,60 @@ Never call `byan_update_apply` without explicit user consent. That tool returns
54
65
  - **If no specialist matches** : halt. Ask user whether to run INT (agent recruitment) first. Do NOT fallback silently to general-purpose.
55
66
  - **Exit gate** : user validates the mapping.
56
67
 
57
- ### Phase 4 — BUILD
68
+ ### Phase 5 — BUILD
58
69
  - **Who** : `byan-hermes-dispatch` skill takes over (per feature-workflow.md CEO delegation rule).
59
70
  - **Rules** :
60
71
  - TDD first : write/update tests before implementation.
61
72
  - Atomic commits : `type: description`, no emoji, one feature per commit.
62
73
  - Parallel BUILD via `party-mode-native` only if roles are independent and write to non-overlapping paths.
63
74
  - **Visibility** : the `tool-transparency` hook already writes per-tool entries to `_byan-output/tool-log.jsonl`. Every sub-task you spawn must be visible there.
64
- - **Exit gate** : user sees the diff and says ok.
65
-
66
- ### Phase 5VALIDATE
67
- - **Who** : MantraValidator + jest + `byan-fact-check` skill.
75
+ - **Exit gate** : user sees the diff and says "ok build".
76
+
77
+ ### Phase 6REVIEW
78
+ - **Who** : Quinn (QA) role-play or delegate to `bmad-bmm-quinn` subagent. Pre-flight humain before VALIDATE.
79
+ - **Goal** : detect false-positives qualitatively before the machine runs. REVIEW is qualitatif; VALIDATE is quantitatif.
80
+ - **Protocol** :
81
+ 1. Load expected VALIDATE criteria : planned tests from BUILD, MantraValidator targets, mantra-risk per change type.
82
+ 2. Inspect the diff : readability, naming, side effects, coverage per branch, comments justified (POURQUOI), zero emoji.
83
+ 3. Cross-check planned tests vs implemented tests. Cross-check mantra risks vs actual code.
84
+ 4. Output `{ status: "ready-for-validate" | "needs-rework", findings: [...] }` and persist via `byan_fd_update({ patch: { review_findings: [...] } })`.
85
+ - **Exit gate** :
86
+ - `ready-for-validate` → advance to VALIDATE.
87
+ - `needs-rework` → short-circuit to REFACTOR (skip VALIDATE this cycle).
88
+
89
+ ### Phase 7 — VALIDATE
90
+ - **Who** : MantraValidator + jest/node test + `byan-fact-check` skill. No human judgement, only numbers.
68
91
  - **Checks** :
69
92
  - `npm test` : zero regression on pre-existing passing tests
70
93
  - MantraValidator ≥ 80 % on changed agent/skill files
71
94
  - No emoji in code, commits, specs
72
95
  - Final fact-check on any absolute claim introduced in docs
73
- - **Exit gate** : tests green + user says "ok", OR issues documented and a retry cycle on BUILD.
96
+ - **Decision** : binary. Persist via `byan_fd_update({ patch: { validate_verdict: { status, blocking_issues } } })`.
97
+ - **Exit gate** :
98
+ - `OK` (tests green + score ≥ 80% + fact-check OK) → advance to DOC.
99
+ - `KO` → advance to REFACTOR.
100
+
101
+ ### Phase 8a — DOC (if VALIDATE OK)
102
+ - **Who** : Paige (tech-writer) — role-play or delegate to `bmad-bmm-tech-writer` subagent.
103
+ - **Goal** : document what was delivered so the feature is usable and discoverable. DOC is a deliverable, not a nice-to-have.
104
+ - **Protocol** :
105
+ 1. Read final diff + VALIDATE verdict.
106
+ 2. Update CHANGELOG.md (dated entry, type: description). Update README.md if public surface changed.
107
+ 3. Create/update usage guide (command, example, edge cases). Sync agent-manifest.csv / workflow-manifest.csv if applicable.
108
+ 4. Bump version (semver) if needed : minor for feature, major for breaking.
109
+ 5. Persist via `byan_fd_update({ patch: { doc_log: [...] } })`. No emoji, clarity first.
110
+ - **Exit gate** : user reviews the doc and says "ok doc" → advance to COMPLETED.
111
+
112
+ ### Phase 8b — REFACTOR (if VALIDATE KO, or REVIEW needs-rework)
113
+ - **Who** : the agent or worker that did the initial BUILD (continuity).
114
+ - **Goal** : corrective loop only — no new features, no re-design. Address `blocking_issues` from VALIDATE.
115
+ - **Protocol** :
116
+ 1. Read VALIDATE verdict → exact list of `blocking_issues`.
117
+ 2. For each issue : reproduce locally, minimal fix (Ockham), re-run check.
118
+ 3. Targeted commits : `fix: [issue]` — one commit per issue ideally.
119
+ 4. Persist progress via `byan_fd_update({ patch: { refactor_log: [...] } })`.
120
+ - **Exit gate** : all `blocking_issues` resolved → advance back to BUILD (loop). The state machine explicitly allows REFACTOR → BUILD as the only backward transition.
121
+ - **Guard-rail** : 3 consecutive BUILD→REVIEW→VALIDATE→REFACTOR cycles without convergence → propose retour to PRUNE (mal cadré) or ABORTED.
74
122
 
75
123
  ## 3. Session state
76
124
 
@@ -78,12 +126,18 @@ A FD cycle in progress is tracked in `_byan-output/fd-state.json` :
78
126
  ```json
79
127
  {
80
128
  "fd_id": "<timestamp-slug>",
81
- "phase": "BRAINSTORM | PRUNE | DISPATCH | BUILD | VALIDATE | COMPLETED | ABORTED",
129
+ "phase": "DISCOVERY | BRAINSTORM | PRUNE | DISPATCH | BUILD | REVIEW | VALIDATE | REFACTOR | DOC | COMPLETED | ABORTED",
82
130
  "started_at": "<iso>",
83
131
  "feature_name": "<slug>",
132
+ "project_context": { "name": "...", "slug": "...", "domain": "...", "stack": "...", "summary": "...", "source": "mcp|local" },
133
+ "raw_ideas": [],
84
134
  "backlog": [ { "id": "F1", "title": "...", "priority": "P1|P2|P3", "status": "pending|building|done|skipped" } ],
85
135
  "dispatch_table": [],
86
136
  "commits": [],
137
+ "review_findings": [ { "status": "ready-for-validate|needs-rework", "items": [...] } ],
138
+ "validate_verdict": { "status": "OK|KO", "tests": "...", "mantra_score": 0, "blocking_issues": [] },
139
+ "refactor_log": [],
140
+ "doc_log": [],
87
141
  "notes": []
88
142
  }
89
143
  ```
@@ -104,8 +158,12 @@ Use the MCP tools `byan_fd_start`, `byan_fd_advance`, `byan_fd_status`, `byan_fd
104
158
 
105
159
  | Scope | Owner |
106
160
  |-------|-------|
161
+ | DISCOVERY (project identification, MCP first) | BYAN (this skill) |
107
162
  | BRAINSTORM, PRUNE, DISPATCH, VALIDATE | BYAN (this skill) |
108
163
  | BUILD execution per feature | `byan-hermes-dispatch` |
164
+ | REVIEW (qualitative pre-flight) | Quinn (`bmad-bmm-quinn`) or BYAN role-play |
165
+ | REFACTOR (corrective loop to BUILD) | Same agent/worker that did BUILD |
166
+ | DOC (CHANGELOG, README, manifests) | Paige (`bmad-bmm-tech-writer`) or BYAN role-play |
109
167
  | Parallel team of specialists | `byan-orchestrate` (extends hermes for N-role) |
110
168
  | Persona / voice | Soul + Tao (loaded by SessionStart hook) |
111
169
  | Transparency | `tool-transparency` PreToolUse hook |
@@ -205,7 +205,7 @@ You must fully embody this agent's persona and follow all activation instruction
205
205
  <item cmd="PC or fuzzy match on show-context">[PC] Show Project Context and business documentation</item>
206
206
  <item cmd="MAN or fuzzy match on show-mantras">[MAN] Display 64 Mantras reference guide</item>
207
207
  <item cmd="FC or fuzzy match on fact-check or check or verify" exec="{project-root}/_byan/workflows/byan/fact-check-workflow.md">[FC] Fact-Check — Analyser une assertion, un document ou une chaine de raisonnement</item>
208
- <item cmd="FD or fuzzy match on feature or feature-dev or improve" exec="{project-root}/_byan/workflows/byan/feature-workflow.md">[FD] Feature Development — Brainstorm → Prune → Dispatch → Build → Validate (validation a chaque etape)</item>
208
+ <item cmd="FD or fuzzy match on feature or feature-dev or improve" exec="{project-root}/_byan/workflows/byan/feature-workflow.md">[FD] Feature Development — Discovery → Brainstorm → Prune → Dispatch → Build → Review → Validate → Doc (boucle Refactor si KO)</item>
209
209
  <item cmd="FORGE or fuzzy match on forge or soul or ame" exec="{project-root}/_byan/workflows/byan/forge-soul-workflow.md">[FORGE] Forger une âme — Interview psychologique profonde pour distiller l'âme du créateur</item>
210
210
  <item cmd="SOUL or fuzzy match on show-soul or mon-ame">[SOUL] Afficher l'âme active — soul.md + soul-memory.md</item>
211
211
  <item cmd="ELO or fuzzy match on elo trust score" exec="{project-root}/_byan/bmb/workflows/byan/elo-workflow.md">[ELO] View and manage your Epistemic Trust Score (challenge calibration)</item>
@@ -1,7 +1,24 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
 
4
- const PHASES = ['BRAINSTORM', 'PRUNE', 'DISPATCH', 'BUILD', 'VALIDATE', 'COMPLETED', 'ABORTED'];
4
+ const PHASES = [
5
+ 'DISCOVERY',
6
+ 'BRAINSTORM',
7
+ 'PRUNE',
8
+ 'DISPATCH',
9
+ 'BUILD',
10
+ 'REVIEW',
11
+ 'VALIDATE',
12
+ 'REFACTOR',
13
+ 'DOC',
14
+ 'COMPLETED',
15
+ 'ABORTED',
16
+ ];
17
+
18
+ // Backward-allowed transitions: REFACTOR loops back to BUILD by design.
19
+ const BACKWARD_ALLOWED = new Set([
20
+ 'REFACTOR->BUILD',
21
+ ]);
5
22
 
6
23
  function resolveRoot(projectRoot) {
7
24
  return projectRoot || process.env.CLAUDE_PROJECT_DIR || process.cwd();
@@ -64,14 +81,19 @@ export function start({ featureName, projectRoot, now = new Date(), force = fals
64
81
  const state = {
65
82
  fd_id: stampId(now, featureName),
66
83
  feature_name: featureName || 'unnamed',
67
- phase: 'BRAINSTORM',
84
+ phase: 'DISCOVERY',
68
85
  started_at: now.toISOString(),
69
86
  updated_at: now.toISOString(),
70
- phase_history: [{ phase: 'BRAINSTORM', entered_at: now.toISOString() }],
87
+ phase_history: [{ phase: 'DISCOVERY', entered_at: now.toISOString() }],
88
+ project_context: null,
71
89
  raw_ideas: [],
72
90
  backlog: [],
73
91
  dispatch_table: [],
74
92
  commits: [],
93
+ review_findings: [],
94
+ validate_verdict: null,
95
+ refactor_log: [],
96
+ doc_log: [],
75
97
  notes: [],
76
98
  };
77
99
  writeState(state, projectRoot);
@@ -103,17 +125,35 @@ export function advance({ to, note, projectRoot, now = new Date(), force = false
103
125
 
104
126
  const order = PHASES.indexOf(state.phase);
105
127
  const target = PHASES.indexOf(to);
106
- if (target < order && !['ABORTED', 'COMPLETED'].includes(to)) {
128
+ const transitionKey = `${state.phase}->${to}`;
129
+ const isBackward = target < order;
130
+ const isTerminal = ['ABORTED', 'COMPLETED'].includes(to);
131
+
132
+ if (isBackward && !isTerminal && !BACKWARD_ALLOWED.has(transitionKey)) {
107
133
  throw new Error(
108
- `Cannot move backwards from ${state.phase} to ${to}. Use abort() or fix the workflow.`
134
+ `Cannot move backwards from ${state.phase} to ${to}. Allowed loop: REFACTOR->BUILD. Use abort() or fix the workflow.`
109
135
  );
110
136
  }
111
137
 
138
+ // DISCOVERY exit gate : need project_context populated (unless forced)
139
+ if (
140
+ state.phase === 'DISCOVERY' &&
141
+ to !== 'DISCOVERY' &&
142
+ !isTerminal &&
143
+ !force
144
+ ) {
145
+ if (!state.project_context) {
146
+ throw new Error(
147
+ `DISCOVERY requires project_context to be set before advancing. Populate via update({ patch: { project_context: { name, summary, source } } }), or pass force=true to skip.`
148
+ );
149
+ }
150
+ }
151
+
112
152
  // BRAINSTORM exit gate : need >= BRAINSTORM_MIN_IDEAS raw ideas
113
153
  if (
114
154
  state.phase === 'BRAINSTORM' &&
115
155
  to !== 'BRAINSTORM' &&
116
- !['ABORTED'].includes(to) &&
156
+ !isTerminal &&
117
157
  !force
118
158
  ) {
119
159
  const n = Array.isArray(state.raw_ideas) ? state.raw_ideas.length : 0;
@@ -136,7 +176,19 @@ export function update({ patch = {}, projectRoot, now = new Date() } = {}) {
136
176
  const state = readState(projectRoot);
137
177
  if (!state) throw new Error('No active FD session.');
138
178
 
139
- const allowed = ['raw_ideas', 'backlog', 'dispatch_table', 'commits', 'notes', 'feature_name'];
179
+ const allowed = [
180
+ 'project_context',
181
+ 'raw_ideas',
182
+ 'backlog',
183
+ 'dispatch_table',
184
+ 'commits',
185
+ 'review_findings',
186
+ 'validate_verdict',
187
+ 'refactor_log',
188
+ 'doc_log',
189
+ 'notes',
190
+ 'feature_name',
191
+ ];
140
192
  for (const key of Object.keys(patch)) {
141
193
  if (!allowed.includes(key)) {
142
194
  throw new Error(`Field "${key}" is not patchable. Allowed: ${allowed.join(', ')}`);
@@ -406,7 +406,7 @@ const tools = [
406
406
  {
407
407
  name: 'byan_fd_start',
408
408
  description:
409
- 'Start a new Feature Development (FD) cycle for BYAN. Writes _byan-output/fd-state.json with phase=BRAINSTORM. Rejects if another FD is already in progress (unless force=true).',
409
+ 'Start a new Feature Development (FD) cycle for BYAN. Writes _byan-output/fd-state.json with phase=DISCOVERY. Rejects if another FD is already in progress (unless force=true).',
410
410
  inputSchema: {
411
411
  type: 'object',
412
412
  properties: {
@@ -426,13 +426,25 @@ const tools = [
426
426
  {
427
427
  name: 'byan_fd_advance',
428
428
  description:
429
- 'Transition the current FD session to another phase. Valid targets : BRAINSTORM | PRUNE | DISPATCH | BUILD | VALIDATE | COMPLETED | ABORTED. Rejects backward moves (except abort).',
429
+ 'Transition the current FD session to another phase. Valid targets : DISCOVERY | BRAINSTORM | PRUNE | DISPATCH | BUILD | REVIEW | VALIDATE | REFACTOR | DOC | COMPLETED | ABORTED. Rejects backward moves except REFACTOR->BUILD (rework loop) and ABORTED/COMPLETED.',
430
430
  inputSchema: {
431
431
  type: 'object',
432
432
  properties: {
433
433
  to: {
434
434
  type: 'string',
435
- enum: ['BRAINSTORM', 'PRUNE', 'DISPATCH', 'BUILD', 'VALIDATE', 'COMPLETED', 'ABORTED'],
435
+ enum: [
436
+ 'DISCOVERY',
437
+ 'BRAINSTORM',
438
+ 'PRUNE',
439
+ 'DISPATCH',
440
+ 'BUILD',
441
+ 'REVIEW',
442
+ 'VALIDATE',
443
+ 'REFACTOR',
444
+ 'DOC',
445
+ 'COMPLETED',
446
+ 'ABORTED',
447
+ ],
436
448
  },
437
449
  note: { type: 'string', description: 'Optional gate-crossing rationale.' },
438
450
  },
@@ -443,7 +455,7 @@ const tools = [
443
455
  {
444
456
  name: 'byan_fd_update',
445
457
  description:
446
- 'Patch fields on the active FD state. Allowed keys : backlog, dispatch_table, commits, notes, feature_name. Rejects unknown keys.',
458
+ 'Patch fields on the active FD state. Allowed keys : project_context, raw_ideas, backlog, dispatch_table, commits, review_findings, validate_verdict, refactor_log, doc_log, notes, feature_name. Rejects unknown keys.',
447
459
  inputSchema: {
448
460
  type: 'object',
449
461
  properties: {
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  name: feature-workflow
3
- description: "Workflow d'ajout de features BYAN - Brainstorm → Prune → Dispatch → Build → Validate"
4
- version: "1.0.0"
3
+ description: "Workflow d'ajout de features BYAN - Discovery → Brainstorm → Prune → Dispatch → Build → Review → Validate → Doc (avec boucle Refactor)"
4
+ version: "2.0.0"
5
5
  module: byan
6
- phases: 5
6
+ phases: 8
7
7
  ---
8
8
 
9
9
  # BYAN Feature Development Workflow
@@ -21,17 +21,49 @@ Il s'applique systematiquement : aucune feature n'est implementée sans passer p
21
21
 
22
22
  ```
23
23
  INIT
24
+ → DISCOVERY (Agent: BYAN — identifier le projet, MCP first puis local)
24
25
  → BRAINSTORM (Agent: Carson — pousser les idées)
25
26
  → PRUNE (User + BYAN — trier, prioriser, formuler)
26
27
  → DISPATCH (Worker: EconomicDispatcher — quelle brique BYAN ?)
27
28
  → BUILD (Agent ou Worker selon complexité)
29
+ → REVIEW (Agent: Quinn — pre-flight humain vs critères VALIDATE)
28
30
  → VALIDATE (MantraValidator + tests — score ≥ 80%)
31
+ ├─ OK → DOC (Agent: Paige — documenter ce qui a été livré)
32
+ └─ KO → REFACTOR (boucle vers BUILD avec correctifs ciblés)
29
33
  → COMPLETED
30
34
  ```
31
35
 
32
36
  ---
33
37
 
34
- ## Étape 1 : BRAINSTORM
38
+ ## Étape 1 : DISCOVERY
39
+
40
+ **Qui :** Agent BYAN (lui-même)
41
+ **Rôle :** Identifier sans ambiguïté le projet sur lequel on travaille avant toute idéation. Pas de feature aveugle sur un contexte flou.
42
+
43
+ **Protocole :**
44
+ 1. BYAN tente d'identifier le projet depuis le contexte courant (cwd, CLAUDE.md, _byan/config.yaml, README).
45
+ 2. Si doute → demande explicite à {user_name} : "On est sur quel projet ?"
46
+ 3. Récupère un résumé du projet, **MCP first** :
47
+ - `byan_list_projects` pour lister les projets BYAN du compte
48
+ - `byan_api_projects_get` pour obtenir le détail (nom, slug, description, type)
49
+ 4. **Fallback local** si MCP indisponible ou projet hors-BYAN :
50
+ - Lire `CLAUDE.md`, `_byan/config.yaml`, `README.md`
51
+ - Inspecter `package.json`, structure du repo
52
+ 5. Synthétiser un résumé court : nom du projet, domaine, stack, contraintes connues.
53
+ 6. Présenter ce résumé à {user_name} pour validation.
54
+
55
+ **Output :** Fiche projet validée — `{ name, slug, domain, stack, summary, source: "mcp" | "local" }`
56
+
57
+ **Gate :** {user_name} confirme "ok c'est ce projet" ou corrige.
58
+
59
+ **Anti-patterns :**
60
+ - Sauter DISCOVERY parce que "c'est évident" — Zero Trust (source: Mantra IA-25)
61
+ - Inventer un résumé sans source — Fact-Check (source: Mantra IA-12)
62
+ - Utiliser MCP même si le projet est hors-BYAN — fallback local explicite
63
+
64
+ ---
65
+
66
+ ## Étape 2 : BRAINSTORM
35
67
 
36
68
  **Qui :** Agent Carson (brainstorming-coach)
37
69
  **Rôle :** Pousser les idées brutes. Quantité > qualité. Aucune idée éliminée.
@@ -42,13 +74,13 @@ INIT
42
74
  3. Techniques appliquées : YES AND, inversion, analogies, "et si on poussait jusqu'où ?"
43
75
  4. Durée : jusqu'à épuisement des idées ou signal stop de {user_name}
44
76
 
45
- **Output :** Liste brute d'idées (non filtrée)
77
+ **Output :** Liste brute d'idées (non filtrée, ≥ 10 idées)
46
78
 
47
79
  **Gate :** {user_name} dit "ok j'ai toutes mes idées" ou "stop brainstorm"
48
80
 
49
81
  ---
50
82
 
51
- ## Étape 2 : PRUNE
83
+ ## Étape 3 : PRUNE
52
84
 
53
85
  **Qui :** {user_name} + BYAN (Challenge Before Confirm)
54
86
  **Rôle :** Trier, formuler, prioriser. Appliquer Ockham's Razor.
@@ -68,7 +100,7 @@ INIT
68
100
 
69
101
  ---
70
102
 
71
- ## Étape 3 : DISPATCH
103
+ ## Étape 4 : DISPATCH
72
104
 
73
105
  **Qui :** Worker — EconomicDispatcher logic
74
106
  **Rôle :** Pour chaque feature du backlog, déterminer quelle brique BYAN est impliquée.
@@ -102,7 +134,7 @@ INIT
102
134
 
103
135
  ---
104
136
 
105
- ## Étape 4 : BUILD
137
+ ## Étape 5 : BUILD
106
138
 
107
139
  **Qui :** Agent (Sonnet/Opus) ou Worker selon score dispatch
108
140
  **Rôle :** Implémenter la feature — code, agent, workflow, ou context.
@@ -121,33 +153,126 @@ INIT
121
153
  - [ ] Tests passent
122
154
  - [ ] CHANGELOG.md mis à jour
123
155
 
124
- **Gate :** {user_name} review le changement et dit "ok"
156
+ **Gate :** {user_name} review le changement et dit "ok build"
157
+
158
+ ---
159
+
160
+ ## Étape 6 : REVIEW
161
+
162
+ **Qui :** Agent Quinn (QA) ou reviewer dédié + {user_name}
163
+ **Rôle :** Pre-flight humain — vérifier que le BUILD est aligné avec ce que VALIDATE va mesurer. Détecter les faux-positifs avant de lancer la machine.
164
+
165
+ **Protocole :**
166
+ 1. Charger les critères VALIDATE attendus :
167
+ - Tests prévus pour cette feature (liste TDD de l'étape BUILD)
168
+ - Score MantraValidator cible (≥ 80%)
169
+ - Mantras les plus à risque selon le type de changement
170
+ 2. Quinn (ou reviewer) inspecte le diff :
171
+ - Lisibilité, nommage, taille des fonctions
172
+ - Effets de bord, duplication, anti-patterns
173
+ - Coverage : chaque branche du diff a-t-elle un test ?
174
+ - Comments justifiés (POURQUOI uniquement, mantra IA-24)
175
+ - Zero emoji (mantra IA-23)
176
+ 3. Cross-check rapide vs critères VALIDATE :
177
+ - Si un test prévu manque → flag "REVIEW: test absent pour [scenario]"
178
+ - Si un mantra est manifestement violé → flag "REVIEW: violation [mantra-id]"
179
+ 4. Synthèse `{ status: "ready-for-validate" | "needs-rework", findings: [...] }`
180
+
181
+ **Output :** Rapport REVIEW remis à {user_name}
182
+
183
+ **Gate :**
184
+ - Si `ready-for-validate` → {user_name} valide, on passe en VALIDATE
185
+ - Si `needs-rework` → retour direct en REFACTOR sans passer par VALIDATE (économie de cycles)
186
+
187
+ **Anti-patterns :**
188
+ - REVIEW = simple "lgtm" sans inspection — pas un rubber stamp
189
+ - REVIEW = re-faire le travail de VALIDATE — REVIEW est qualitatif, VALIDATE est quantitatif
125
190
 
126
191
  ---
127
192
 
128
- ## Étape 5 : VALIDATE
193
+ ## Étape 7 : VALIDATE
129
194
 
130
- **Qui :** MantraValidator + tests existants
131
- **Rôle :** S'assurer que la feature respecte les 64 mantras et ne casse rien.
195
+ **Qui :** MantraValidator + tests existants + `byan-fact-check` skill
196
+ **Rôle :** Mesurer mécaniquement. Pas de jugement humain, des chiffres.
132
197
 
133
198
  **Protocole :**
134
- 1. Lancer `npm test` — tous les tests doivent passer
199
+ 1. Lancer `npm test` — tous les tests doivent passer (zéro régression)
135
200
  2. Score MantraValidator ≥ 80%
136
- 3. BYAN challenge la feature une dernière fois :
201
+ 3. Fact-check final sur tout claim absolu introduit dans la doc
202
+ 4. BYAN challenge la feature une dernière fois :
137
203
  - "Est-ce que c'est la solution la plus simple ?" (mantra #37)
138
204
  - "Quelles sont les conséquences non voulues ?" (mantra #39)
139
- 4. Si score < 80% → retour étape 4 avec corrections ciblées
205
+ 5. **Décision binaire :**
206
+ - Tests verts ET score ≥ 80% ET fact-check OK → `VALIDATE: OK` → étape DOC
207
+ - Sinon → `VALIDATE: KO` → étape REFACTOR
208
+
209
+ **Output :** Verdict `{ status: "OK" | "KO", tests, mantra_score, blocking_issues }`
210
+
211
+ **Gate :**
212
+ - `OK` → DOC
213
+ - `KO` → REFACTOR avec liste de correctifs ciblés
214
+
215
+ ---
216
+
217
+ ## Étape 8a : DOC (si VALIDATE OK)
218
+
219
+ **Qui :** Agent Paige (tech-writer)
220
+ **Rôle :** Documenter ce qui vient d'être livré pour que la feature soit utilisable et découvrable.
221
+
222
+ **Protocole :**
223
+ 1. Paige lit le diff final + le rapport VALIDATE.
224
+ 2. Pour chaque feature livrée :
225
+ - Mettre à jour `CHANGELOG.md` (entrée datée, type: description)
226
+ - Mettre à jour `README.md` si la feature change la surface publique
227
+ - Créer/mettre à jour le guide d'usage (commande, exemple, edge cases)
228
+ - Si nouvel agent/workflow → mettre à jour les manifestes (`agent-manifest.csv`, `workflow-manifest.csv`)
229
+ 3. Bump de version si nécessaire (semver) — feature mineure → minor, breaking → major
230
+ 4. Pas d'emoji, pas de prose marketing — clarity first (mantra IA-24)
231
+
232
+ **Output :**
233
+ - CHANGELOG mis à jour
234
+ - Guide d'usage à jour
235
+ - Manifestes synchronisés
236
+ - Version bumpée si applicable
237
+
238
+ **Gate :** {user_name} review la doc et dit "ok doc"
239
+
240
+ → COMPLETED
241
+
242
+ ---
243
+
244
+ ## Étape 8b : REFACTOR (si VALIDATE KO)
245
+
246
+ **Qui :** L'agent ou worker qui a fait le BUILD initial (continuité)
247
+ **Rôle :** Corriger précisément ce que VALIDATE a flaggé — pas de scope creep, pas de re-design.
248
+
249
+ **Protocole :**
250
+ 1. Lire le rapport VALIDATE → liste exacte des `blocking_issues`.
251
+ 2. Pour chaque issue :
252
+ - Reproduire localement (test rouge, lint, mantra violation)
253
+ - Correctif minimal (Ockham — la plus petite modification qui résout)
254
+ - Re-run du test ou du check concerné
255
+ 3. Commits ciblés : `fix: [issue précise]` — un commit par issue idéalement
256
+ 4. Retour automatique à BUILD pour terminer le cycle (puis REVIEW → VALIDATE à nouveau)
257
+
258
+ **Output :** Diff correctif + log des issues résolues
259
+
260
+ **Gate :** Toutes les `blocking_issues` adressées
140
261
 
141
- **Output :** Feature mergée, CHANGELOG mis à jour, version bump si nécessaire
262
+ Boucle vers BUILD (continue le cycle jusqu'à `VALIDATE: OK`)
142
263
 
143
- **Gate :** Tests verts + score mantras 80% + validation {user_name}
264
+ **Garde-fou :** Si 3 cycles BUILD REVIEW VALIDATE REFACTOR consécutifs sans converger, BYAN propose un retour à PRUNE (la feature est peut-être mal cadrée) ou ABORTED.
144
265
 
145
266
  ---
146
267
 
147
268
  ## Règles globales du workflow
148
269
 
149
- - **Jamais d'étape sautée** — même pour les "petites" features
150
- - **Jamais d'implémentation sans validation du dispatch** (étape 3)
151
- - **Zero Trust** : BYAN challenge toujours avant d'exécuter
270
+ - **Aucune étape sautée** — même pour les "petites" features
271
+ - **Aucune implémentation sans validation du dispatch** (étape 4)
272
+ - **DISCOVERY est obligatoire** pas de feature sur projet flou
273
+ - **REVIEW est qualitatif, VALIDATE est quantitatif** — les deux sont nécessaires
274
+ - **REFACTOR ne fait que corriger** — pas de nouvelle feature, pas de re-design
275
+ - **DOC est livrable**, pas un nice-to-have — feature non documentée = feature non livrée
276
+ - **Zero Trust** : BYAN challenge avant d'exécuter (source: Mantra IA-25)
152
277
  - **Ockham's Razor** : si deux solutions existent, prendre la plus simple
153
278
  - **Pas de YAGNI** : on ne build pas "au cas où"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-byan-agent",
3
- "version": "2.14.1",
3
+ "version": "2.16.1",
4
4
  "description": "BYAN v2.8 - Intelligent AI agent creator with ELO trust system + scientific fact-check + Hermes universal dispatcher + native Claude Code integration (hooks, skills, MCP server). Multi-platform (Copilot CLI, Claude Code, Codex). Merise Agile + TDD + 64 Mantras. ~54% LLM cost savings.",
5
5
  "main": "src/index.js",
6
6
  "bin": {