@tacuchi/agent-workflow-cli 15.1.0 → 16.0.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 (42) hide show
  1. package/package.json +1 -1
  2. package/skills/w/README.md +14 -14
  3. package/skills/w/SKILL.md +96 -75
  4. package/skills/w/artifacts/README.md +6 -6
  5. package/skills/w/artifacts/artifacts-core/SESSION.md +1 -7
  6. package/skills/w/artifacts/artifacts-core/TASKS.md +1 -1
  7. package/skills/w/artifacts/artifacts-exec/TECHNICAL-NOTE.md +9 -54
  8. package/skills/w/artifacts/artifacts-research/CONCLUSIONS.md +1 -1
  9. package/skills/w/commands/README.md +22 -22
  10. package/skills/w/commands/export-diagrams.md +9 -9
  11. package/skills/w/commands/export-manuals.md +9 -9
  12. package/skills/w/commands/export-reports.md +9 -9
  13. package/skills/w/commands/export-scripts.md +9 -9
  14. package/skills/w/commands/fix-git.md +12 -12
  15. package/skills/w/commands/plan-exec.md +19 -19
  16. package/skills/w/commands/plan-new.md +18 -18
  17. package/skills/w/commands/plan-refine.md +22 -22
  18. package/skills/w/commands/quick.md +16 -16
  19. package/skills/w/commands/spec-new.md +35 -34
  20. package/skills/w/commands/spec-refine.md +16 -16
  21. package/skills/w/commands/status.md +18 -16
  22. package/skills/w/commands/workspace-init.md +14 -14
  23. package/skills/w/exports/README.md +5 -5
  24. package/skills/w/exports/export-diagrams/SKILL.md +58 -58
  25. package/skills/w/exports/export-manuals/SKILL.md +61 -61
  26. package/skills/w/exports/export-reports/SKILL.md +51 -51
  27. package/skills/w/exports/export-scripts/SKILL.md +60 -60
  28. package/skills/w/harness/SKILL.md +48 -47
  29. package/skills/w/loops/CHASSIS.md +104 -97
  30. package/skills/w/loops/CODE-POLICIES.md +21 -21
  31. package/skills/w/loops/README.md +30 -29
  32. package/skills/w/loops/plan-exec-loop/SKILL.md +77 -80
  33. package/skills/w/loops/plan-new-loop/SKILL.md +88 -58
  34. package/skills/w/loops/plan-refine-loop/SKILL.md +69 -45
  35. package/skills/w/loops/quick-loop/SKILL.md +79 -79
  36. package/skills/w/loops/spec-refine-loop/SKILL.md +93 -97
  37. package/skills/w/roles/README.md +2 -2
  38. package/skills/w/roles/diagrams/SKILL.md +50 -47
  39. package/skills/w/roles/git/SKILL.md +58 -58
  40. package/skills/w/roles/research/SKILL.md +65 -62
  41. package/skills/w/roles/sql/SKILL.md +59 -55
  42. package/skills/w/roles/ui-spec/SKILL.md +60 -74
@@ -1,108 +1,138 @@
1
1
  ---
2
2
  name: plan-new-loop
3
3
  description: >-
4
- Genera un plan de implementación rico (docs/plans/PPP-plan-<slug>.md) a
5
- partir de un spec (docs/specs/NNN-spec-<slug>.md). Heir del chasis común de
6
- los loops (loops/CHASSIS.md motor gap-driven convergente, session única
7
- con research inline, structured-choice, artefactos como log vivo); sus
8
- deltas viven en el cuerpo:
9
- el plan absorbe el nivel TECHNICAL-NOTE + Phases/Tasks con estado vivo,
10
- research de mapeo código/impacto, gap taxonomy de planificación, y si el
11
- plan incluye UI compone ui-design para autorar design SPECs por pantalla
12
- (NNN-SPEC-<SLUG>.md). Si el spec no está refinado sugiere spec-refine antes.
13
- Lo arranca /w:plan-new y es reanudable. Invocar cuando un spec deba
14
- convertirse en un plan ejecutable antes de implementar.
4
+ Generates a rich implementation plan (docs/plans/PPP-plan-<slug>.md) from a
5
+ spec. Heir of the chassis (loops/CHASSIS.md). Deltas: the plan absorbs the
6
+ TECHNICAL-NOTE level + Phases/Tasks with live state, code/impact-mapping
7
+ research, planning gap taxonomy, and per-screen design SPECs via ui-design
8
+ when the plan includes UI. If the spec is not refined it suggests
9
+ spec-refine first. Started by /w:plan-new; resumable. Invoke when a spec
10
+ must become an executable plan.
15
11
  ---
16
12
 
17
13
  # plan-new-loop
18
14
 
19
- > **Heir** del chasis comúnaquí **solo** los deltas de PLAN-new. El motor no se repite.
15
+ > **Heir** of the common chassis — **only** the PLAN-new deltas live here. The engine is never repeated.
20
16
 
21
17
  ## Flow
22
18
  PLAN
23
19
 
24
20
  ## Layer
25
- 2 — la IA lo corre entero.
21
+ 2 — the AI runs it end to end.
26
22
 
27
23
  ## Started by
28
- `/w:plan-new` — **reanudable** (mismo mecanismo del chasis, keyado off CHECKPOINT).
24
+ `/w:plan-new` — **resumable** (same chassis mechanism, keyed off CHECKPOINT).
29
25
 
30
26
  ## Reads
31
- `docs/specs/NNN-spec-*.md` (glob — localiza el spec por número; o la ruta exacta del argumento del comando). **Refinado vs borrador** se distingue por la **presencia** de `## Refinement decisions` / `## Q&A traceability` en el spec: si faltan → **soft-suggest** correr `/w:spec-refine` primero (planificar sobre un spec sólido produce mejores planes), pero el usuario puede proceder.
27
+ `docs/specs/NNN-spec-*.md` (glob — locates the spec by number; or the exact path from the command argument). **Refined vs draft** is distinguished by the **presence** of `## Refinement decisions` / `## Q&A traceability` in the spec: if missing → **soft-suggest** running `/w:spec-refine` first (planning over a solid spec produces better plans), but the user may proceed.
32
28
 
33
29
  ## Writes
34
- `docs/plans/PPP-plan-<slug>.md` (`generate`; **sobrescribe con confirmación** si existe). Solo escribe `docs/plans` — nunca otras carpetas `docs/` ni auto-export. Si el plan **incluye UI**, además produce **design SPECs** (`NNN-SPEC-<SLUG>.md`) como artefactos **de su sesión** (ver *Delta 4* — no son `docs/`, no hay auto-export).
30
+ `docs/plans/PPP-plan-<slug>.md` (`generate`; **overwrites with confirmation** if it exists). It writes only `docs/plans` — never other `docs/` folders, no auto-export. If the plan **includes UI**, it also produces **design SPECs** (`NNN-SPEC-<SLUG>.md`) as artifacts **of its session** (see *Delta 4* — they are not `docs/`, no auto-export).
35
31
 
36
- > **slug**: kebab-case corto derivado del Requirement del spec solo `[a-z0-9-]`, ≤ ~5 palabras / ≤ 40 chars. El CLI solo devuelve el número `PPP`; el loop arma el nombre completo. Para localizar planes, glob `docs/plans/PPP-plan-*.md`.
32
+ > **slug**: short kebab-case derived from the spec's Requirement — only `[a-z0-9-]`, ≤ ~5 words / ≤ 40 chars. `aw next-number docs/plans` returns JSON (field `next` = `PPP`); the loop builds the full name. To locate plans, glob `docs/plans/PPP-plan-*.md`.
37
33
 
38
34
  ## Inherits
39
35
 
40
- Leé **[`../CHASSIS.md`](../CHASSIS.md)** (instalación normal) **o** `CHASSIS.md` junto a este archivo (instalación aplanada) el motor completo del loop (objetivo persistente + verification-first, gap-driven, session única + research inline, structured-choice + control `flow`, compact/resume, artefactos como log vivo, numeración, convergence gate), **siempre antes** de estos deltas.
36
+ Read **[`../CHASSIS.md`](../CHASSIS.md)** the loop's **full engine** — **always before** these deltas. *(If `../` does not resolve: `CHASSIS.md` next to this file global layout rule, chassis § Reference resolution.)*
41
37
 
42
- ## Internal sessions — instancia PLAN-new
38
+ ## Internal sessions — PLAN-new instance
43
39
 
44
- Doctrina completa en el chasis (§ *Internal sessions* + *Numeración*). La instancia de este loop:
40
+ Full doctrine in the chassis (§ *Internal sessions* + *Numbering*). This loop's instance:
45
41
 
46
42
  | Session | When | Artifacts | Role |
47
43
  |---|---|---|---|
48
- | **plan session** `NNN-<slug>-plan-new/` | al arrancar el loop (o se reanuda) | `SESSION.md` · `CHECKPOINT.md` (· `BACKLOG.md` solo si difiere) | Dueña del run. Type = `refine`; descriptor `<slug>-plan-new` (el `<slug>` sale del spec de entrada). |
44
+ | **plan session** `NNN-<slug>-plan-new/` | when the loop starts (or resumes) | `SESSION.md` · `CHECKPOINT.md` (· `BACKLOG.md` only if something is deferred) | Owns the run. Type = `refine`; descriptor `<slug>-plan-new` (the `<slug>` comes from the input spec). |
49
45
 
50
- ## Delta 1 — Deliverable: PLAN RICO (`PPP-plan-<slug>.md`)
46
+ ## Delta 1 — Deliverable: the RICH PLAN (`PPP-plan-<slug>.md`)
51
47
 
52
- El plan absorbe el nivel `TECHNICAL-NOTE` **inline** (decisión del usuario) + roadmap:
48
+ The plan absorbs the `TECHNICAL-NOTE` level **inline** (user decision) + the roadmap:
53
49
 
54
50
  ```markdown
55
51
  # Plan PPP — <slug>
56
52
 
57
- > Derivado de docs/specs/NNN-spec-<slug>.md · generado por plan-new-loop
58
-
59
- ## Origin spec fuente (o prompt, si se bootstrapeó vía spec-new)
60
- ## Summary el cómo, en 1–2 frases (core)
61
- ## Solution explicación técnica/funcional de cómo se implementará (core)
62
- ## Impacted FE · BE · BD (esquemas/tablas/funciones) · APIs · integr. (core)
63
- ## Dependencies docs / fuentes / bases / sesiones (opt.)
64
- ## Current state (AS-IS) wiring actual (interfaces y métodos), resumido (opt.)
65
- ## Target state (TO-BE) wiring objetivo (opt.)
66
- ## Final behavior cómo se comporta el flujo al final (alineado con criterios del spec) (core)
67
- ## Phases fases agrupadoras (complejidad XS–S) (core)
68
- ## Tasks tareas por fase (≤XS), con deps y estado vivo (- [ ]) (core)
69
- ## Validations validaciones / restricciones / lógica de negocio (core)
70
- ## Risks / impact riesgos e impactos técnicos (opt.)
71
- ## Assumptions supuestos (opt.)
72
- ## Estimated time sizing XS–XL (desarrollo + pruebas internas) (opt.)
73
- ## Open questions pendientes (core)
53
+ > Derived from docs/specs/NNN-spec-<slug>.md · generated by plan-new-loop
54
+
55
+ ## Origin source spec (or prompt, if bootstrapped via spec-new)
56
+ ## Summary the how, in 1–2 sentences (core)
57
+ ## Solution technical/functional explanation of the implementation (core)
58
+ ## Impacted FE · BE · DB (schemas/tables/functions) · APIs · integr. (core)
59
+ ## Dependencies docs / sources / databases / sessions (opt.)
60
+ ## Current state (AS-IS) current wiring (interfaces and methods), brief (opt.)
61
+ ## Target state (TO-BE) target wiring (opt.)
62
+ ## Final behavior how the flow behaves at the end (aligned with the spec criteria) (core)
63
+ ## Phases grouping phases (complexity XS–S) (core)
64
+ ## Tasks tasks per phase (≤XS), with deps and live state (- [ ]) (core)
65
+ ## Validations validations / constraints / business logic (core)
66
+ ## Risks / impact technical risks and impacts (opt.)
67
+ ## Assumptions assumptions (opt.)
68
+ ## Estimated time XS–XL sizing (development + internal testing) (opt.)
69
+ ## Open questions pending (core)
74
70
  ```
75
71
 
76
- > **Escala con complejidad:** las `(core)` van **siempre**; las `(opt.)` solo si el plan lo ameritaun plan chico puede omitir `Dependencies`, AS-IS/TO-BE, `Risks`, `Assumptions`, `Estimated time`. Conciso > exhaustivo.
72
+ > **Scales with complexity:** the `(core)` sections go **always**; the `(opt.)` ones only when the plan warrants thema small plan may omit `Dependencies`, AS-IS/TO-BE, `Risks`, `Assumptions`, `Estimated time`. Concise > exhaustive.
77
73
 
78
- > **Implicación de catálogo:** `TECHNICAL-NOTE` deja de ser artefacto de session y se vuelve **secciones del plan-doc**. Reconciliado en [`plan-exec-loop`](../plan-exec-loop/SKILL.md): la única plan-exec session **no** lleva `TECHNICAL-NOTE` ni `TASKS` propios; el detalle técnico y el progreso viven inline en el plan-doc (living).
74
+ > **Catalog implication:** `TECHNICAL-NOTE` stops being a session artifact and becomes **sections of the plan-doc**. Reconciled in [`plan-exec-loop`](../plan-exec-loop/SKILL.md): the single plan-exec session carries **no** `TECHNICAL-NOTE` nor its own `TASKS`; the technical detail and the progress live inline in the plan-doc (living).
79
75
 
80
- ## Delta 2 — Gap taxonomy (de "plan")
76
+ ## Delta 2 — Gap taxonomy (of "plan")
81
77
 
82
- Reemplaza la gap taxonomy de spec por una orientada a planificación:
78
+ Replaces the spec gap taxonomy with a planning-oriented one:
83
79
 
84
80
  | Gap | Signal | Resolved by |
85
81
  |---|---|---|
86
- | Approach/Solution sin definir | el cómo es vago | research / humano |
87
- | Componentes sin identificar | impacto FE/BE/BD desconocido | **research** (mapea el código) |
88
- | Wiring AS-IS desconocido | no se sabe el estado actual | **research** |
89
- | Fase muy grande | complejidad > S | humano (re-partir) |
90
- | Tarea no atómica | complejidad > XS | la IA re-parte |
91
- | Deps faltantes | orden no claro | research / humano |
92
- | Criterios del spec sin cubrir | tareas no trazan a acceptance criteria | la IA deriva + humano confirma |
93
- | Riesgos sin atender | riesgos técnicos sin mitigar/declarar | humano |
94
- | UI sin design SPEC *(si aplica)* | el plan incluye UI (FE/pantallas en `Impacted`, `## UI spec` en el spec, o tareas UI) sin `NNN-SPEC-*.md` en la sesión | **capacidad `ui-design`** |
82
+ | Approach/Solution undefined | the how is vague | research / human |
83
+ | Components unidentified | FE/BE/DB impact unknown | **research** (maps the code) |
84
+ | AS-IS wiring unknown | current state unknown | **research** |
85
+ | Phase too large | complexity > S | human (re-split) |
86
+ | Task not atomic | complexity > XS | the AI re-splits |
87
+ | Missing deps | order unclear | research / human |
88
+ | Spec criteria uncovered | tasks don't trace to acceptance criteria | the AI derives + human confirms |
89
+ | Unaddressed risks | technical risks unmitigated/undeclared | human |
90
+ | UI without design SPEC *(if it applies)* | the plan includes UI (FE/screens in `Impacted`, `## UI spec` in the spec, or UI tasks) without `NNN-SPEC-*.md` in the session | **`ui-design` capability** |
95
91
 
96
92
  ## Delta 3 — What research investigates here
97
93
 
98
- El research **inline** del chasis se especializa: mapear **código/impacto** — componentes FE/BE/BD afectados, wiring AS-IS, dependencias. Alimenta las secciones `Solution`, `Impacted`, `Current state (AS-IS)`. La regla BD del chasis aplica igual (queries read-only a `SCRIPTS.sql`, MCP elegido vía pregunta de contenido si >1 sin default).
94
+ The chassis' **inline** research specializes: mapping **code/impact** — affected FE/BE/DB components, AS-IS wiring, dependencies. It feeds the `Solution`, `Impacted`, `Current state (AS-IS)` sections. The chassis DB rule applies unchanged (read-only queries into `SCRIPTS.sql`, MCP chosen via a content question when >1 without default).
99
95
 
100
- ## Delta 4 — Design SPECs (si el plan incluye UI)
96
+ ## Delta 4 — Design SPECs (when the plan includes UI)
101
97
 
102
- El gap **UI sin design SPEC** se resuelve **componiendo** la capacidad **`ui-design`** (default built-in [`ui-spec`](../../roles/ui-spec/SKILL.md); rebindeable vía `.workflow/skills.toml`; `off` → degrada a humano / `Open questions`): autora **un design SPEC por pantalla** como artefacto de la sesión — `NNN-SPEC-<SLUG>.md` (`001-SPEC-MODAL-EXPORT.md`, `002-SPEC-ADMIN-DASHBOARD.md`; numeración local a la sesión, ver [`SPEC.md`](../../artifacts/artifacts-design/SPEC.md)). **Deriva** de la sección `## UI spec` del spec si existe (la parte por pantalla y la eleva a detalle ejecutable); si no, autora desde el `Requirement` (design-system/tema/ambigüedades vía *structured-choice*, cuenta en el batch). Las **Tasks UI del plan referencian** la ruta de su SPEC — esa referencia es la fuente de verdad — y `plan-exec-loop` los lee como referencia de diseño. Es el mismo tercer modo de resolución de gap del chasis (junto a *research* y *humano*).
98
+ The **UI without design SPEC** gap is resolved by **composing** the **`ui-design`** capability (built-in default [`ui-spec`](../../roles/ui-spec/SKILL.md); rebindable via `.workflow/skills.toml`; `off` → degrades to human / `Open questions`):
99
+
100
+ - It authors **one design SPEC per screen** as a session artifact: `NNN-SPEC-<SLUG>.md` (numbering local to the session — see [`SPEC.md`](../../artifacts/artifacts-design/SPEC.md)).
101
+ - It **derives** from the spec's `## UI spec` section when present (splits it per screen and raises it to executable detail); otherwise it authors from the `Requirement` (design system/theme/ambiguities via *structured-choice*, counts in the batch).
102
+ - The plan's **UI Tasks reference** their SPEC's path — that reference is the **source of truth** — and `plan-exec-loop` reads them as the design reference.
103
+ - It is the same third gap-resolution mode of the chassis (next to *research* and *human*).
104
+
105
+ ## Sequence
106
+
107
+ ```
108
+ plan-new-loop(spec):
109
+ input = glob(docs/specs/NNN-spec-*.md) | argument path
110
+ if the spec does NOT have ## Refinement decisions + ## Q&A traceability:
111
+ soft-suggest /w:spec-refine (the user may proceed anyway)
112
+ session = create_or_resume("<slug>-plan-new") # CLI prepends global NNN
113
+ seed SESSION.Success criteria = coherence-gate checklist # verification-first, BEFORE
114
+ work = plan skeleton (Delta 1) derived from the spec (+ checkpoint progress if resuming)
115
+ repeat: # chassis engine
116
+ gaps = detect_gaps(work) (Delta 2 taxonomy) minus the exhausted ones
117
+ if gaps == ∅: break
118
+ batch ≤3 → seed CHECKPOINT.Pending/Next → resolve each gap:
119
+ research (maps code/impact — Delta 3) · human (structured-choice) · ui-design (Delta 4)
120
+ integrate + update CHECKPOINT # artifact-first cycle
121
+ coherence gate (read-only) = Success criteria green:
122
+ - every spec acceptance criterion traces to a phase/task
123
+ - Final behavior covers the criteria
124
+ - phases XS–S · tasks XS · deps without cycles · Impacted consistent with Solution
125
+ - (UI) every screen/UI task traces to its design SPEC and does not contradict ## UI spec
126
+ whatever fails → comes back as a gap
127
+ structured_choice(content: [Guardar plan, Preguntar algo más], flow: [Compactar, Cerrar])
128
+ Guardar → write docs/plans/PPP-plan-<slug>.md (confirmation if it exists)
129
+ finalize: CHECKPOINT persisted (+ BACKLOG only if something is deferred) + close session + report
130
+ ```
103
131
 
104
132
  ## Convergence / exit
105
133
 
106
- Sin gaps materiales → **coherence gate** (read-only) = **`Success criteria` en verde** (*verification-first*; es el "convergence gate" del chasis para PLAN-new): cada `acceptance criterion` del spec **traza** a una fase/tarea, `Final behavior` los cubre, fases XS–S / tareas XS, `deps` sin ciclos, `Impacted` consistente con `Solution`; y si el plan incluye UI: cada pantalla/tarea UI **traza a su design SPEC** (`NNN-SPEC-*.md`) y los SPECs no contradicen el `## UI spec` del spec (si existe). Lo que falle **vuelve como gap** — la trazabilidad criterio→tarea es una **invariante chequeada**, no una sección aparte. Si pasa → *structured-choice* (contenido: `Guardar plan` / `Preguntar algo más`; flow: `Compactar`/`Cerrar`) → al `Guardar`, escribe `docs/plans/PPP-plan-<slug>.md` (con confirmación si existe) → `finalize` (persiste `CHECKPOINT`, y `BACKLOG` solo si difiere; cierra la session, reporta). `Cerrar` en cualquier momento → `finalize` igual.
134
+ - **No material gaps** → **coherence gate** (the *Sequence* checklist; the PLAN-new instance of the chassis convergence gate). Criterion→task traceability is a **checked invariant**, never a separate section.
135
+ - Passes → `Guardar plan` (writes with confirmation if it exists) → `finalize`.
136
+ - `Cerrar` at any time → `finalize` (persists `CHECKPOINT`; `BACKLOG` only if something is deferred; closes the session, reports).
107
137
 
108
- > **Después de generar:** el plan puede ir directo a `plan-exec`, osi surgen cambios antes de ejecutar (nuevos requerimientos, ajustes de alcance)pasar por [`plan-refine-loop`](../plan-refine-loop/SKILL.md) (`/w:plan-refine`, auxiliar y **no obligatorio**), que lo refina in place.
138
+ > **After generating:** the plan can go straight to `plan-exec`, orif changes arise before executing (new requirements, scope adjustments)pass through [`plan-refine-loop`](../plan-refine-loop/SKILL.md) (`/w:plan-refine`, auxiliary and **not mandatory**), which refines it in place.
@@ -1,99 +1,123 @@
1
1
  ---
2
2
  name: plan-refine-loop
3
3
  description: >-
4
- Refina un plan existente (docs/plans/PPP-plan-<slug>.md) editándolo IN
5
- PLACE, como paso auxiliar y NO obligatorio del flujo PLAN antes de plan-
6
- exec. Es a plan-new lo que spec-refine es a spec-new. Heir del chasis común
7
- de los loops (loops/CHASSIS.md motor gap-driven, session única con
8
- research inline, structured-choice, artefactos como log vivo); reusa la gap
9
- taxonomy y el coherence gate de plan-new-loop, agrega Refinement
10
- decisions/Q&A traceability al plan
11
- (traza, sin gating), y si el refine toca UI compone ui-design y
12
- produce/actualiza design SPECs por pantalla. Lo arranca /w:plan-refine;
13
- reanudable y re-corrible a demanda. Invocar cuando un plan ya generado deba
14
- ajustarse antes de ejecutarlo.
4
+ Refines an existing plan (docs/plans/PPP-plan-<slug>.md) by editing it IN
5
+ PLACE an auxiliary, NOT mandatory step before plan-exec. Heir of the
6
+ chassis (loops/CHASSIS.md). Deltas: reuses plan-new-loop's gap taxonomy and
7
+ coherence gate, adds Refinement decisions / Q&A traceability (trace, no
8
+ gating), and produces/updates design SPECs via ui-design when the refine
9
+ touches UI. Started by /w:plan-refine; resumable and re-runnable on demand.
10
+ Invoke when an already generated plan must be adjusted before executing it.
15
11
  ---
16
12
 
17
13
  # plan-refine-loop
18
14
 
19
- > **Heir** del chasis comúnaquí **solo** los deltas de PLAN-refine. El motor no se repite.
15
+ > **Heir** of the common chassis — **only** the PLAN-refine deltas live here. The engine is never repeated.
20
16
 
21
- > **Relación con los otros loops de PLAN:** `plan-new-loop` **genera** el plan desde el spec; `plan-refine-loop` **lo refina in place** (opcional); `plan-exec-loop` **lo ejecuta**. plan-refine es a plan-new lo que spec-refine es a spec-new.
17
+ > **Relation to the other PLAN loops:** `plan-new-loop` **generates** the plan from the spec; `plan-refine-loop` **refines it in place** (optional); `plan-exec-loop` **executes it**. plan-refine is to plan-new what spec-refine is to spec-new.
22
18
 
23
19
  ## Flow
24
20
  PLAN
25
21
 
26
22
  ## Layer
27
- 2 — la IA lo corre entero.
23
+ 2 — the AI runs it end to end.
28
24
 
29
- ## Auxiliar / NO obligatorio
30
- `plan-exec` corre **cualquier** plan, refinado o no — **no** hay gate que exija plan-refine. Este loop existe para incorporar cambios (nuevos requerimientos, ajustes de alcance, deps/riesgos detectados al releer) **antes** de ejecutar, sin re-generar el plan desde cero.
25
+ ## Auxiliary / NOT mandatory
26
+ `plan-exec` runs **any** plan, refined or notthere is **no** gate requiring plan-refine. This loop exists to incorporate changes (new requirements, scope adjustments, deps/risks spotted on re-read) **before** executing, without regenerating the plan from scratch.
31
27
 
32
28
  ## Started by
33
- `/w:plan-refine` — **reanudable** (mismo mecanismo del chasis, keyado off CHECKPOINT) y **re-corrible a demanda** (ver *Compact / resume*).
29
+ `/w:plan-refine` — **resumable** (same chassis mechanism, keyed off CHECKPOINT) and **re-runnable on demand** (see *Compact / resume*).
34
30
 
35
31
  ## Reads
36
- `docs/plans/PPP-plan-*.md` (glob — localiza el plan por número; o la ruta exacta del argumento del comando). **Siempre el plan mismo**: este loop lo edita in place, no hay un archivo "refined" aparte.
32
+ `docs/plans/PPP-plan-*.md` (glob — locates the plan by number; or the exact path from the command argument). **Always the plan itself**: this loop edits it in place; there is no separate "refined" file.
37
33
 
38
34
  ## Writes
39
- Actualiza `docs/plans/PPP-plan-<slug>.md` **in place** (cuando el usuario elige `Guardar plan refinado`): completa/ajusta secciones y **agrega** `## Refinement decisions` + `## Q&A traceability`. Como sobrescribe un doc existente, **con confirmación** del usuario. Solo escribe `docs/plans` — nunca otras carpetas `docs/` ni auto-export. Si el refine **toca UI**, además produce/actualiza **design SPECs** (`NNN-SPEC-<SLUG>.md`) como artefactos **de su propia sesión** (ver *Delta 4* — no son `docs/`, no hay auto-export).
35
+ Updates `docs/plans/PPP-plan-<slug>.md` **in place** (when the user picks `Guardar plan refinado`): completes/adjusts sections and **adds** `## Refinement decisions` + `## Q&A traceability`. Since it overwrites an existing doc, it asks the user's **confirmation**. It writes only `docs/plans` — never other `docs/` folders, no auto-export. If the refine **touches UI**, it also produces/updates **design SPECs** (`NNN-SPEC-<SLUG>.md`) as artifacts **of its own session** (see *Delta 4* — they are not `docs/`, no auto-export).
40
36
 
41
37
  ## Inherits
42
38
 
43
- Leé **[`../CHASSIS.md`](../CHASSIS.md)** (instalación normal) **o** `CHASSIS.md` junto a este archivo (instalación aplanada) el motor completo del loop (objetivo persistente + verification-first, gap-driven, session única + research inline, structured-choice + control `flow`, compact/resume, artefactos como log vivo, numeración, convergence gate), **siempre antes** de estos deltas.
39
+ Read **[`../CHASSIS.md`](../CHASSIS.md)** the loop's **full engine** — **always before** these deltas. *(If `../` does not resolve: `CHASSIS.md` next to this file global layout rule, chassis § Reference resolution.)*
44
40
 
45
- ## Internal sessions — instancia PLAN-refine
41
+ ## Internal sessions — PLAN-refine instance
46
42
 
47
- Doctrina completa en el chasis (§ *Internal sessions* + *Numeración*). La instancia de este loop:
43
+ Full doctrine in the chassis (§ *Internal sessions* + *Numbering*). This loop's instance:
48
44
 
49
45
  | Session | When | Artifacts | Role |
50
46
  |---|---|---|---|
51
- | **refine session** `NNN-<slug>-plan-refine/` | al arrancar el loop (o se reanuda/reabre) | `SESSION.md` · `CHECKPOINT.md` (· `BACKLOG.md` solo si difiere) | Dueña del run. Type = `refine`; descriptor `<slug>-plan-refine` (el `<slug>` sale del plan de entrada). |
47
+ | **refine session** `NNN-<slug>-plan-refine/` | when the loop starts (or resumes/reopens) | `SESSION.md` · `CHECKPOINT.md` (· `BACKLOG.md` only if something is deferred) | Owns the run. Type = `refine`; descriptor `<slug>-plan-refine` (the `<slug>` comes from the input plan). |
52
48
 
53
- ## Delta 1 — Deliverable: el PLAN, editado in place
49
+ ## Delta 1 — Deliverable: the PLAN, edited in place
54
50
 
55
- El plan usa el **mismo esqueleto** que produce [`plan-new-loop`](../plan-new-loop/SKILL.md) (en instalaciones aplanadas: la copia hermana `w-plan-new-loop/SKILL.md`) (§ *Delta 1 — PLAN RICO*: `Summary`/`Solution`/`Impacted`/`Phases`/`Tasks`/`Validations`/`Final behavior`/… con secciones `(core)` siempre y `(opt.)` según complejidad). plan-refine **no** cambia el esquema: **completa/ajusta** las secciones existentes **in place** y **agrega** dos de traza:
51
+ The plan uses the **same skeleton** [`plan-new-loop`](../plan-new-loop/SKILL.md) produces (§ *Delta 1 — RICH PLAN*: `Summary`/`Solution`/`Impacted`/`Phases`/`Tasks`/`Validations`/`Final behavior`/… with `(core)` sections always and `(opt.)` by complexity). plan-refine does **not** change the schema: it **completes/adjusts** the existing sections **in place** and **adds** two trace sections:
56
52
 
57
53
  ```markdown
58
- ## Refinement decisions ← NEW (se AGREGA)
59
- Qué se ajustó al refinar y por qué (nuevos requerimientos, cambios de scope,
60
- deps/riesgos). Incluye lo resuelto vía research inline (ref a las CONCLUSIONS
61
- de la session).
54
+ ## Refinement decisions ← NEW (ADDED)
55
+ What was adjusted while refining and why (new requirements, scope changes,
56
+ deps/risks). Includes what inline research resolved (ref to the session's
57
+ CONCLUSIONS).
62
58
 
63
- ## Q&A traceability ← NEW (se AGREGA)
64
- Cada duda preguntada al humano + la respuesta elegida.
59
+ ## Q&A traceability ← NEW (ADDED)
60
+ Every doubt asked to the human + the chosen answer.
65
61
  ```
66
62
 
67
- > **Sin contrato de gating** (a diferencia de spec↔plan): la presencia de `## Refinement decisions`/`## Q&A traceability` en el plan es solo **traza de auditoría** — `plan-exec` **no** la exige ni la chequea (corre cualquier plan). Sirve para (a) distinguir un plan re-refinado de uno recién generado en el resume, y (b) dejar registro de qué cambió y por qué.
63
+ > **No gating contract** (unlike spec↔plan): the presence of `## Refinement decisions`/`## Q&A traceability` in the plan is **audit trace only** — `plan-exec` neither requires nor checks it (it runs any plan). It serves to (a) distinguish a re-refined plan from a freshly generated one on resume, and (b) record what changed and why.
68
64
 
69
- > El plan **no muta por ejecución** (eso lo trackea plan-exec en las Tasks del plan-doc) — solo por un (re-)refine.
65
+ > The plan **never mutates by execution** (plan-exec tracks that in the plan-doc's Tasks) — only by a (re-)refine.
70
66
 
71
- ## Delta 2 — Gap taxonomy (de "plan")
67
+ ## Delta 2 — Gap taxonomy (of "plan")
72
68
 
73
- Reusa **íntegra** la gap taxonomy de [`plan-new-loop`](../plan-new-loop/SKILL.md) (§ *Delta 2*): Approach/Solution vago, componentes sin identificar, wiring AS-IS desconocido, fase muy grande, tarea no atómica, deps faltantes, criterios del spec sin cubrir, riesgos sin atender, UI sin design SPEC. **Diferencia de foco:** plan-new **construye** el plan desde cero; plan-refine **detecta qué cambió** respecto del plan ya escrito (o respecto del spec, si el spec se re-refinó) y cierra **esos** gaps — típicamente menos y más localizados. Un gap extra propio del re-refine:
69
+ Reuses plan-new-loop's gap taxonomy **in full** ([`plan-new-loop`](../plan-new-loop/SKILL.md) § *Delta 2*): vague Approach/Solution, components unidentified, AS-IS wiring unknown, phase too large, task not atomic, missing deps, spec criteria uncovered, unaddressed risks, UI without design SPEC. **Focus difference:** plan-new **builds** the plan from scratch; plan-refine **detects what changed** against the written plan (or against the spec, if the spec was re-refined) and closes **those** gaps — typically fewer and more localized. One extra re-refine gap:
74
70
 
75
71
  | Gap | Signal | Resolved by |
76
72
  |---|---|---|
77
- | Deriva plan↔spec | el spec se re-refinó y el plan quedó desalineado | **research** (re-lee el spec) / **humano** |
73
+ | Plan↔spec drift | the spec was re-refined and the plan fell out of line | **research** (re-reads the spec) / **human** |
78
74
 
79
75
  ## Delta 3 — What research investigates here
80
76
 
81
- Igual que plan-new (mapea código/impacto: componentes FE/BE/BD, wiring AS-IS, deps), pero **acotado al delta**: re-verifica solo lo que el cambio toca (no re-mapea todo el plan). Regla BD del chasis igual (read-only a `SCRIPTS.sql`, MCP vía pregunta si >1 sin default).
77
+ Same as plan-new (maps code/impact: FE/BE/DB components, AS-IS wiring, deps), but **scoped to the delta**: it re-verifies only what the change touches (never re-maps the whole plan). Chassis DB rule unchanged (read-only into `SCRIPTS.sql`, MCP via a question when >1 without default).
82
78
 
83
- ## Delta 4 — Design SPECs (si el refine toca UI)
79
+ ## Delta 4 — Design SPECs (when the refine touches UI)
84
80
 
85
- Mismo mecanismo que [`plan-new-loop`](../plan-new-loop/SKILL.md) (§ *Delta 4*: capacidad **`ui-design`** → `NNN-SPEC-<SLUG>.md` por pantalla, ver [`SPEC.md`](../../artifacts/artifacts-design/SPEC.md)), **acotado al delta**: solo las pantallas **nuevas o cambiadas** por el refine reciben design SPEC. El SPEC actualizado se escribe en **la sesión propia** del plan-refine (cada loop maneja los artefactos de SU sesión no edita los de la sesión de plan-new) y el plan **re-apunta** la referencia de la Task UI al SPEC vigente. Pantallas no tocadas conservan su SPEC original.
81
+ Same mechanism as [`plan-new-loop`](../plan-new-loop/SKILL.md) (§ *Delta 4*: the **`ui-design`** capability per-screen `NNN-SPEC-<SLUG>.md`, see [`SPEC.md`](../../artifacts/artifacts-design/SPEC.md)), **scoped to the delta**: only the screens **new or changed** by the refine get a design SPEC. The updated SPEC is written in **plan-refine's own session** (each loop manages ITS session's artifactsit never edits plan-new's) and the plan **re-points** the UI Task reference to the current SPEC. Untouched screens keep their original SPEC.
86
82
 
87
83
  ## Compact / resume
88
84
 
89
- El resume **keya off el `CHECKPOINT`** de la refine session, no de un archivo "refined". Tres casos al ejecutar `/w:plan-refine` sobre un plan:
85
+ Resume **keys off the `CHECKPOINT`** of the refine session, never a "refined" file. Three cases when `/w:plan-refine` runs over a plan:
90
86
 
91
- 1. **En curso** (existe `CHECKPOINT.md` en la refine session) → reanuda desde el avance (gaps resueltos, Q&A, `attempts`, research inline en curso).
92
- 2. **Sin avance** (no hay CHECKPOINT y el plan **no** tiene `Refinement decisions`/`Q&A traceability`) → arranca desde cero leyendo el plan (`PPP-plan-*.md`).
93
- 3. **Ya refinado / re-refine on demand** (no hay CHECKPOINT abierto pero el plan **ya tiene** `Refinement decisions`/`Q&A traceability`) → **operación de primera clase**: mientras el flujo siga en PLAN, re-correr `/w:plan-refine` sobre el mismo plan **cuantas veces haga falta** está soportado. `create_or_resume` detecta la refine session existente —típicamente **cerrada** tras converger— por descriptor + `## Origin` y la **reabre** (ver chasis § *Internal sessions*: detección con `aw sessions --state all` / `aw resume-summary --include-recent-closed`, reapertura con `aw session-resume --code <NNN> --reopen`); re-refinamiento incremental leyendo el **plan mismo**; al `Guardar`, edita in place con confirmación.
87
+ 1. **In progress** (a `CHECKPOINT.md` exists in the refine session) → resume from the recorded progress (resolved gaps, Q&A, `attempts`, in-flight inline research).
88
+ 2. **No progress** (no CHECKPOINT and the plan does **not** have `Refinement decisions`/`Q&A traceability`) → start from zero reading the plan (`PPP-plan-*.md`).
89
+ 3. **Already refined / re-refine on demand** (no open CHECKPOINT, but the plan **already has** the 2 sections) → **first-class operation**, as many times as needed while the flow stays in PLAN:
90
+ - `create_or_resume` finds the existing refine session (typically **closed** after convergence) by descriptor + `## Origin` and **reopens** it: `aw session-resume --code <NNN> --reopen` (detection: `aw sessions --state all`).
91
+ - Incremental re-refinement reading the **plan itself**; on `Guardar`, edits in place with confirmation.
94
92
 
95
- > **Continuidad inter-turno** (chasis, fila 2): un **comando de flujo** abre "nueva línea de trabajo" (sesión nueva) — **salvo re-correr el mismo flujo sobre la misma entrada** (mismo plan), que hace `create_or_resume` (reanuda/reabre en vez de duplicar).
93
+ > **Inter-turn continuity** (chassis, row 2): a flow command opens a "new work line" (new session) — **except re-running the same flow over the same input** (same plan), which does `create_or_resume` (resumes/reopens instead of duplicating).
94
+
95
+ ## Sequence
96
+
97
+ ```
98
+ plan-refine-loop(plan):
99
+ input = glob(docs/plans/PPP-plan-*.md) | argument path # always the plan itself (in place)
100
+ session = create_or_resume("<slug>-plan-refine") # reopens if it exists (see Compact / resume)
101
+ seed SESSION.Success criteria = coherence-gate checklist # verification-first, BEFORE
102
+ work = read(plan) (+ the spec if realignment is needed; + checkpoint progress if resuming)
103
+ repeat: # chassis engine
104
+ gaps = detect_gaps(work) (plan-new taxonomy + plan↔spec drift) minus the exhausted ones
105
+ if gaps == ∅: break
106
+ batch ≤3 → seed CHECKPOINT.Pending/Next → resolve each gap:
107
+ research (scoped to the delta — Delta 3) · human (structured-choice) ·
108
+ ui-design (Delta 4, only new/changed screens)
109
+ integrate + update CHECKPOINT # artifact-first cycle
110
+ coherence gate (read-only) = Success criteria green:
111
+ - plan-new checklist (criterion→task · Final behavior · XS–S/XS · deps · Impacted↔Solution · UI→current SPEC)
112
+ - re-refine's own check: the plan is REALIGNED with what changed
113
+ whatever fails → comes back as a gap
114
+ structured_choice(content: [Guardar plan refinado, Preguntar algo más], flow: [Compactar, Cerrar])
115
+ Guardar → edit in place (with confirmation) + insert/update Refinement decisions + Q&A traceability
116
+ finalize: CHECKPOINT persisted (+ BACKLOG only if something is deferred) + close session + report
117
+ ```
96
118
 
97
119
  ## Convergence / exit
98
120
 
99
- Sin gaps materiales → **coherence gate** (read-only) = **`Success criteria` en verde** (*verification-first*; el "convergence gate" del chasis para PLAN, mismo que plan-new): cada `acceptance criterion` del spec **traza** a una fase/tarea, `Final behavior` los cubre, fases XS–S / tareas XS, `deps` sin ciclos, `Impacted` consistente con `Solution`, si hay UI cada pantalla/tarea UI **traza a su design SPEC vigente**, y —propio del re-refine **el plan quedó realineado** con lo que cambió. Lo que falle **vuelve como gap**. Si pasa → *structured-choice* (contenido: `Guardar plan refinado` / `Preguntar algo más`; flow: `Compactar`/`Cerrar`) → al `Guardar`, edita `docs/plans/PPP-plan-<slug>.md` in place (con confirmación) + inserta `Refinement decisions`/`Q&A traceability` → `finalize` (persiste `CHECKPOINT`; `BACKLOG` solo si difiere; cierra la session, reporta). `Cerrar` en cualquier momento → `finalize` igual.
121
+ - **No material gaps** → **coherence gate** (the *Sequence* checklist; plan-new's gate + the re-refine's own realignment check).
122
+ - Passes → `Guardar plan refinado` (edits in place with confirmation) → `finalize`.
123
+ - `Cerrar` at any time → `finalize` (persists `CHECKPOINT`; `BACKLOG` only if something is deferred; closes the session, reports).