sdg-agents 1.14.2 → 1.16.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdg-agents",
3
- "version": "1.14.2",
3
+ "version": "1.16.0",
4
4
  "description": "Structured working protocol and engineering rules for AI agents. Works with Claude Code, Antigravity, Codex, and others.",
5
5
  "type": "module",
6
6
  "main": "./src/engine/bin/index.mjs",
@@ -2,18 +2,9 @@
2
2
 
3
3
  Executing documentation for: $ARGUMENTS. This command prepares the context for the **Docs Cycle**.
4
4
 
5
- ## Step 0 — Document Classification
6
-
7
- 1. **Context Check**: Identify the document type needed based on the goal:
8
- - **CHANGELOG**: Release entry or version synchronization → `CHANGELOG.md` at project root.
9
- - **FEAT (Especificação da Funcionalidade)**: Document _what_ was built and _how_ it fits the pipeline → `docs/specs/FEAT-NNN-slug.md`.
10
- - **ADR (Architecture Decision Record)**: Document _why_ a technical path was chosen (trade-offs) → `docs/decisions/ADR-NNN-slug.md`.
11
- 2. **Numbering**: Use sequential zero-padded numbers (`ADR-001`, `FEAT-042`). Check existing files to find the next available number.
12
- 3. **Current Alignment**: Read existing files in the target directory to maintain style and numbering consistency.
13
-
14
5
  ---
15
6
 
16
- ## Phase: SPEC (Draft Specialization)
7
+ ## Phase: SPEC (The Contract) — MODE: PLANNING
17
8
 
18
9
  Follow the **Phase: SPEC** from the **Working Protocol**, using these templates for the "Drafting" logic:
19
10
 
@@ -27,7 +18,7 @@ Follow the **Phase: SPEC** from the **Working Protocol**, using these templates
27
18
  - [Brief entries from Unreleased]
28
19
  ```
29
20
 
30
- ### Template B: FEAT (Especificação da Funcionalidade)
21
+ ### Template B: FEAT (Feature Specification)
31
22
 
32
23
  ```md
33
24
  # FEAT-[NNN]: [Feature Name]
@@ -47,11 +38,9 @@ Follow the **Phase: SPEC** from the **Working Protocol**, using these templates
47
38
 
48
39
  ---
49
40
 
50
- ---
51
-
52
- ## Phase: END (Hardened)
41
+ ## Phase: END (The Delivery) — MODE: PLANNING
53
42
 
54
- Follow the **Phase: END** from the **Working Protocol**. Documentation must be accurate and mirror the code state perfectly. Sync the backlog and **WAIT** for authorization before `commit`/`push`.
43
+ Follow the **Phase: END** from the **Working Protocol**. Documentation must be accurate and mirror the code state perfectly. Sync the backlog and **WAIT** for authorization before any `commit`/`push` proposal.
55
44
 
56
45
  ---
57
46
 
@@ -1,80 +1,70 @@
1
- # Cycle TerminatorEND Phase
1
+ # Phase: END (The Delivery) MODE: PLANNING
2
2
 
3
- This command has no arguments. Type `end:` to close the active cycle.
4
-
5
- Executing the **Phase: END** checklist from the **Working Protocol** in strict order. Each item must be completed before advancing to the next.
3
+ This command closes the current development cycle and is the **Ultimate Guarantor of Zero Context Leak**. Follow all 7 steps with total rigor.
6
4
 
7
5
  ---
8
6
 
9
- ## Step 1 — SUMMARIZE
10
-
11
- Write one sentence per completed PLAN task. If no PLAN existed (e.g. `[S]` tasks), write a one-line summary of what changed.
12
-
13
- ## Step 2 — CHANGELOG
7
+ ## Step 1 — Task Summary
14
8
 
15
- Prepare your technical narrative in the `CHANGELOG.md`.
9
+ Write a concise summary of the work performed.
16
10
 
17
- 1. **Identify Strategy**:
18
- - **Automated**: If `auto-bump.mjs` exists, you **MUST** first manually populate the `## [Unreleased]` section with your technical narrative. The automated pipeline will promote this content to the new version header during the commit. **DO NOT commit with an empty [Unreleased] section.**
19
- - **Manual**: If no automation is present, you must promote the header manually (e.g., `## [1.2.0] - 2026-04-11`) or run the designated `bump` script.
11
+ - One sentence per completed task from `.ai-backlog/tasks.md`.
12
+ - Focus on technical outcomes.
20
13
 
21
- 2. **Append Entry**:
22
- - `feat:` cycle → Add under `### Added`
23
- - `fix:` cycle → Add under `### Fixed`
24
- - `docs:` cycle → Optional (for major architectural docs)
25
- - `land:` cycle → Skip
14
+ ## Step 2 Changelog Narrative
26
15
 
27
- 3. **Verify Header**: Ensure `## [Unreleased]` exists at the top. If missing, create it above the most recent version entry.
16
+ Update `CHANGELOG.md` to maintain the project's technical history.
28
17
 
29
- ## Step 3 BACKLOG: tasks.md
18
+ - **Action**: Add entries under `## [Unreleased]`.
19
+ - **Categorization**: Use `### Added` for `feat:` or `### Fixed` for `fix:`.
20
+ - **Integrity**: Ensure the narrative allows for a professional semantic release.
30
21
 
31
- - Move all `[DONE]` tasks to `## Done`.
32
- - If no active `tasks.md` existed (`[S]` cycle), skip.
22
+ ## Step 3 Backlog Sync & Catch-all Staging
33
23
 
34
- ## Step 4 BACKLOG: context.md
24
+ Synchronize state and ensure ALL side-effects are captured.
35
25
 
36
- Update `## Now` with the next objective, or set it to `Ready for next instruction.` if nothing is pending.
26
+ - **Backlog**: Move all `Active` tasks to `Done` in `.ai-backlog/tasks.md`.
27
+ - **Catch-all Stage**: Run `git add .` to capture metadata updates (package-lock.json, manifests) and any uncommitted side-effects.
28
+ - **Audit**: Perform a **Zero Context Leak** check: no `TODO` remnants or internal-only files.
37
29
 
38
- ## Step 5KNOWLEDGE (INSIGHTS)
30
+ ## Step 4Context Resilience (Bootstrap & Update)
39
31
 
40
- Log any patterns, findings, or rework discovered during this cycle. Curate stale or irrelevant entries.
32
+ Update the project context. If the project state is lost, this is the healing moment.
41
33
 
42
- - [ ] **KNOWLEDGE** Log findings in `.ai-backlog/learned.md` or `troubleshoot.md`. Curate stale items.
43
- - [ ] **CURATE** Final scan for slop/AI-isms. Run `git status`.
44
- - [ ] **PURGE SESSION (GSD)** — Mandatório se chat longo (>10 mensagens). Sugira fechar chat e abrir novo após commit. Limpa "context rot".
45
- - [ ] **LINT** — Run `lint`, `lint:fix`, or equivalent. Block commit if errors remain.
34
+ - **Self-Healing**: If `.ai-backlog/context.md` is missing, analyze the project and **Bootstrap** it using the template from `workflow.md`.
35
+ - **Update**: Set `## Now` to `Ready for next instruction.`.
46
36
 
47
- ## Step 6CURATE (Zero Context Leak)
37
+ ## Step 5Technical Quality (Self-Healing Lint)
48
38
 
49
- Scan all changed files for technical slop. Run `git status` **You MUST ensure the workspace is 100% clean.**
39
+ Perform a final quality sweep. No delivery with broken quality.
50
40
 
51
- - No uncommitted files (like `package-lock.json` or modified instructions).
52
- - No unfinished comments (`TODO`, `FIXME`, `...`).
53
- - No "AI-isms" or promotional language.
54
- - Run `git status` — confirm only intended files are staged/committed.
41
+ - **Lint**: Run the project's linting script.
42
+ - **Self-Healing**: If lint fails, you **MUST** run a one-time repair attempt (e.g., `npm run lint -- --fix`) before reporting a failure.
43
+ - **Blocker**: If non-auto-fixable errors remain, you **MUST** report them and stop.
55
44
 
56
- ## Step 7LINT
45
+ ## Step 6Semantic Release (Audit & Commit)
57
46
 
58
- If a lint script exists (`lint`, `lint:fix`, `lint:all`, or a config file is detected):
47
+ Execute the delivery using the automated semantic pipeline.
59
48
 
60
- - Run it and auto-fix what's possible.
61
- - If non-auto-fixable violations remain, surface them explicitly.
62
- - Block commit if errors remain.
49
+ 1. **Identify**: Determine if the cycle was a `feat` or `fix`.
50
+ 2. **Execute**: Run `npm run bump <feat|fix>`.
51
+ 3. **Workspace Audit**: Run `git status` to ensure the staging area is 100% clean and nothing was left behind after the bump. Stage any remaining metadata changes with `git add .`.
52
+ 4. **Semantic Commit**: Propose exactly: `git commit -m "<feat|fix>: release v<version>"`.
53
+ 5. **Approval**: **PROPOSE** and **WAIT** for explicit Developer authorization.
63
54
 
64
- ## Step 8COMMIT & RELEASE
55
+ ## Step 7Final Stroke (Push & Purge)
65
56
 
66
- Propose the commit message and **WAIT** for explicit Developer approval before committing.
57
+ Complete the delivery cycle.
67
58
 
68
- - **Option A (Manual)**: If you just want to save progress without a version bump, commit with `feat:` or `fix:`. Remember you **MUST** have content in `[Unreleased]`.
69
- - **Option B (End Cycle)**: If the cycle is complete, run `npm run bump <fix|feat|major>` to consolidate the narrative and bump the version.
59
+ - **Push**: Propose `git push` to synchronize remote.
60
+ - **GSD**: Suggest starting a brand new chat session to purge the current context and prevent token rot.
70
61
 
71
- ## Step 9 — PUSH
62
+ ---
72
63
 
73
- **ASK** for explicit permission before pushing to remote.
74
- The `pre-push` hook will **BLOCK** the push if any `[Unreleased]` narrative remains (preventing unversioned leaks to main).
64
+ > [!WARNING]
65
+ > The cycle is **INCOMPLETE** until all 7 steps are checked.
66
+ > You are **FORBIDDEN** from accepting new work until this phase is finalized and the workspace is clean.
75
67
 
76
68
  ---
77
69
 
78
- > [!WARNING]
79
- > The cycle is **INCOMPLETE** until all applicable steps above are checked.
80
- > Do not accept new work until END is fully executed.
70
+ > Read `.ai/instructions/core/agent-roles.md` for the multi-agent handoff protocol (Planning + Fast roles).
@@ -2,44 +2,22 @@
2
2
 
3
3
  We are initializing a new feature: $ARGUMENTS. This command prepares the context for the development lifecycle following the **Working Protocol**.
4
4
 
5
- ## Step 0 — Context Preparation
6
-
7
- 1. **Roadmap Check**: If `ROADMAP.md` exists, read it to identify where this feature fits in the project's long-term vision.
8
- 2. **Domain Scope**:
9
- - **Backend** (API/Domain/DB) → read `.ai/instructions/competencies/backend.md`
10
- - **Frontend** (UI/UX) → read `.ai/instructions/competencies/frontend.md`
11
- - **Fullstack** → read both
12
- 3. **Architecture Standards**: If `.ai/instructions/flavor/principles.md` exists, read the established data pipeline (Vertical Slice, MVC, etc.).
13
- 4. **Backlog Knowledge**: Read `.ai-backlog/learned.md` to load successful patterns and past research findings.
14
- 5. **Code Style Load** (mandatory — do not skip):
15
- - **Engineering Standards** → read `.ai/instructions/core/engineering-standards.md`
16
- - **Code Style & NarrativeCascade** → read `.ai/instructions/core/code-style.md`
17
- 6. **Quality & Debugging**:
18
- - **Testing Strategy** → read `.ai/instructions/core/testing-principles.md`
19
- - **Observability** → read `.ai/instructions/core/observability.md`
20
-
21
5
  ---
22
6
 
23
- ## Phase: SPEC (Especificação da Funcionalidade)
7
+ ## Phase: SPEC (The Contract) — MODE: PLANNING
24
8
 
25
- Follow the **Phase: SPEC** from the **Working Protocol**, with these mandatory additions:
9
+ Follow the **Phase: SPEC** from the **Working Protocol**, ensuring all 5 steps are executed and announced. Mandatory technical density:
26
10
 
27
- - **Domain Modeling**: Explicitly define the primary entities and aggregate roots involved.
28
- - **Configuration Contract**: Define the environment variables required for this feature (keys must be **abstract**; pro-tip: `AUTH_SECRET` over `CLERK_SECRET`).
29
- - **Contract-First**: Define the Public Interface (API endpoints, public methods, or Component Props) before listing implementation steps.
30
- - **Storytelling**: The SPEC must describe the "User Journey" or the "Data Life Cycle".
31
- - **Backend SPEC (mandatory addition)**: If the domain includes API work, define the response contract before listing implementation steps:
32
- - Use the Contract template from `backend.md`'s ContractFirst rule
33
- - Define: endpoint method + path, input fields with types, output shape (envelope fields), and all error codes with conditions
34
- - This contract must appear in the SPEC and be approved before PLAN begins
35
- - **Frontend SPEC (mandatory addition)**: If the domain includes UI work, define the section structure before any code:
36
- - List each section by type (`section.hero`, `section.cards`, `section.form`, etc.)
37
- - Define the layout skeleton: grid columns, main content blocks, and their data sources
38
- - Identify which states must be handled: Loading / Empty / Error
39
- - This wireframe contract must appear in the SPEC and be approved before PLAN begins
40
- - **Testing SPEC (mandatory addition)**: Explicitly define at least three scenarios: One Happy Path, one Edge Case, and one Expected Failure.
41
- - Format as: `Scenario [Name] (Input: { ... }) -> Expected: [Result/State]`
42
- - This testing contract must appear in the SPEC and be approved before PLAN begins
11
+ - **1. Intent Classification**: Confirmed as `feat:`.
12
+ - **2. Goal Definition**: Writes one sentence describing what will be built and why.
13
+ - **3. Domain & Contracts**:
14
+ - **Domain Modeling**: Defines the domain (Backend / Frontend / Fullstack) and primary entities.
15
+ - **Configuration Contract**: Define environment variables (abstract keys).
16
+ - **Contract-First**: Defines the inputs and outputs (API or Props) before implementation.
17
+ - **Backend SPEC**: Define response contract template (method, path, input/output types, error codes). Load `competencies/backend.md`.
18
+ - **Frontend SPEC**: Define section structure, layout skeleton (grid/columns), and states (Loading/Empty/Error). Load `competencies/frontend.md`.
19
+ - **4. Verification Checklist**: Creates up to 5 yes/no checkpoints to confirm the work is done right (min 3: Happy Path, Edge Case, Expected Failure).
20
+ - **5. Approval Gate**: Stops and waits for your approval before writing any code.
43
21
 
44
22
  ---
45
23
 
@@ -2,40 +2,28 @@
2
2
 
3
3
  We are correcting a recorded incident: $ARGUMENTS. This command prepares the context for the **Fix Cycle** defined in the **Working Protocol**.
4
4
 
5
- ## Step 0 — Incident Analysis
6
-
7
- 1. **Reproduction Scenario**: Read existing logs or provided data to define the exact steps to reproduce the issue.
8
- 2. **Domain Scope**:
9
- - **Backend** (Logic/Data) → read `.ai/instructions/competencies/backend.md`
10
- - **Frontend** (UI/UX) → read `.ai/instructions/competencies/frontend.md`
11
- - **Fullstack** → read both
12
- 3. **Architecture Standards**: If `.ai/instructions/flavor/principles.md` exists, read the architectural principles.
13
- 4. **Backlog Knowledge**: Read `.ai-backlog/troubleshoot.md` to load previous RCA logs and critical failure records.
14
- 5. **Code Style & Standards** (mandatory):
15
- - **Engineering Standards** → read `.ai/instructions/core/engineering-standards.md`
16
- - **Code Style & Narrative Scansion** → read `.ai/instructions/core/code-style.md`
17
- 6. **Diagnostic Standards**:
18
- - **Testing Principles** → read `.ai/instructions/core/testing-principles.md`
19
- - **Observability** → read `.ai/instructions/core/observability.md`
20
-
21
5
  ---
22
6
 
23
- ## Phase: SPEC (Fix Specialization)
7
+ ## Phase: SPEC (The Contract) — MODE: PLANNING
24
8
 
25
- Follow the **Phase: SPEC** from the **Working Protocol**, with these mandatory additions:
9
+ Follow the **Phase: SPEC** from the **Working Protocol**, ensuring all 5 steps are executed and announced. Fix specialization:
26
10
 
27
- - **Root Cause Analysis (RCA)**: Explicitly identify the layer, file, and line where the contract or logic breaks.
28
- - **Observed vs Expected**: Contrast the current broken behavior with the desired outcome.
29
- - **Minimal Surface**: Ensure the proposed fix targets ONLY the bug. No refactors allowed in this cycle.
30
- - **Configuration Contract**: If this fix introduces or changes any environment variable, list it here with its abstract key and purpose. Keys must hide vendor/infrastructure details (e.g., `AUTH_PROVIDER_SECRET` over `CLERK_SECRET`). No committed templates.
11
+ - **1. Intent Classification**: Confirmed as `fix:`.
12
+ - **2. Goal Definition**: Writes one sentence describing the incident and the reason for the fix.
13
+ - **3. Domain & Contracts**:
14
+ - **Root Cause Analysis (RCA)**: Explicitly identify the layer, file, and line where the contract or logic breaks.
15
+ - **Observed vs Expected**: Contrast the current broken behavior with the desired outcome.
16
+ - **Minimal Surface**: Ensure the proposed fix targets ONLY the bug. No refactors allowed.
17
+ - **4. Verification Checklist**: Creates up to 5 yes/no checkpoints, including the **Reproduction Case** as the primary validator.
18
+ - **5. Approval Gate**: Stops and waits for your approval before writing any code.
31
19
 
32
20
  ---
33
21
 
34
- ## Phase: PLAN (Regression Focus)
22
+ ## Phase: PLAN (The Strategy) — MODE: PLANNING
35
23
 
36
24
  Follow the **Phase: PLAN** from the **Working Protocol**, with this mandatory addition:
37
25
 
38
- - **Regression Test**: Include a task specifically for a test that reproduces the bug (Characterization Test). Use the patterns from `testing-principles.md`. This task must appear in the PLAN before approval.
26
+ - **Regression Test**: Include a task specifically for a test that reproduces the bug (Characterization Test). Use the patterns from `testing-principles.md`.
39
27
 
40
28
  ---
41
29
 
@@ -14,7 +14,7 @@ We are landing on a project: $ARGUMENTS. This command runs once, at the very beg
14
14
 
15
15
  ---
16
16
 
17
- ## Phase: VISION
17
+ ## Phase: VISION — MODE: PLANNING
18
18
 
19
19
  Parse the input prompt. Extract only what was explicitly stated — no assumptions, no embellishments.
20
20
 
@@ -29,7 +29,7 @@ If the prompt is too vague to extract these three points, ask one clarifying que
29
29
 
30
30
  ---
31
31
 
32
- ## Phase: SURVEY (legacy only — skip if greenfield)
32
+ ## Phase: SURVEY — MODE: PLANNING (legacy only — skip if greenfield)
33
33
 
34
34
  Read the project silently. Do not announce findings yet.
35
35
 
@@ -41,7 +41,7 @@ If the project has no code at all, treat it as greenfield.
41
41
 
42
42
  ---
43
43
 
44
- ## Phase: SCOPE
44
+ ## Phase: SCOPE — MODE: PLANNING
45
45
 
46
46
  Define the MVP boundary. This is the most important step.
47
47
 
@@ -56,7 +56,7 @@ Present the scope boundary before generating the backlog. If the vision is clear
56
56
 
57
57
  ---
58
58
 
59
- ## Phase: BACKLOG
59
+ ## Phase: BACKLOG — MODE: PLANNING
60
60
 
61
61
  Generate two outputs:
62
62
 
@@ -104,6 +104,7 @@ Structure the backlog as ordered epics, each decomposed into concrete `feat:` ta
104
104
 
105
105
  ### Epic 2 — [Name]
106
106
 
107
+ - [TODO] feat: [atomic task]
107
108
  - [TODO] feat: [atomic task]
108
109
  ```
109
110
 
@@ -111,7 +112,7 @@ Move the first task of Epic 1 to `## Active` as `[IN_PROGRESS]` only after the d
111
112
 
112
113
  ---
113
114
 
114
- ## Phase: STOP
115
+ ## Phase: STOP — MODE: PLANNING
115
116
 
116
117
  Present a summary of what was produced:
117
118
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  ## Roles
8
8
 
9
- | Role | Phases | Model default | Mindset |
9
+ | Role | Phases (Cycles) | Model default | Mindset |
10
10
  | :----------- | :---------------------- | :------------------------- | :------------------------------- |
11
11
  | **Planning** | SPEC, PLAN, Review, END | claude-sonnet-4-6 thinking | Analytical — strategy and design |
12
12
  | **Fast** | CODE, TEST | claude-sonnet-4-6 | Operational — execute and verify |
@@ -18,7 +18,7 @@ Dev → Planning: SPEC + PLAN → [Dev approval]
18
18
 
19
19
  Planning spawns Fast via Agent tool
20
20
 
21
- Fast: CODE + TEST
21
+ Fast: CODE + TEST
22
22
 
23
23
  Fast returns output to Planning
24
24
 
@@ -33,7 +33,7 @@ Dev → Planning: SPEC + PLAN → [Dev approval]
33
33
  ## Planning Role — Responsibilities
34
34
 
35
35
  - Load full governance context before SPEC: backlog, flavor, competencies.
36
- - Produce SPEC and PLAN. Stop and wait for Dev approval at each.
36
+ - Produce SPEC and PLAN (MODE: PLANNING). Stop and wait for Dev approval at each.
37
37
  - When PLAN is approved, invoke the Agent tool to delegate CODE + TEST to Fast.
38
38
  - **Handoff prompt must include** (never omit):
39
39
  - The approved SPEC (goal, inputs/outputs, verification checklist)
@@ -45,7 +45,7 @@ Dev → Planning: SPEC + PLAN → [Dev approval]
45
45
  ## Fast Role — Responsibilities
46
46
 
47
47
  - Load only what is required for CODE: engineering standards, code style, idiom patterns.
48
- - Do not re-derive strategy. The SPEC and PLAN are the contract — follow them exactly.
48
+ - Do not re-derive strategy. The SPEC and PLAN are the contract — follow them exactly (MODE: FAST).
49
49
  - Apply Narrative Gate before every function body.
50
50
  - Run tests and lint. Return a structured report: tasks completed, gate results, test status.
51
51
  - Do not proceed to END. Return control to Planning.
@@ -58,7 +58,7 @@ Planning invokes Fast using the Agent tool with `model: "sonnet"`:
58
58
  Agent({
59
59
  model: "sonnet",
60
60
  prompt: `
61
- ## Role: Fast — CODE + TEST
61
+ ## Role: Fast — CODE + TEST — MODE: FAST
62
62
 
63
63
  You are the Fast agent. Execute only CODE and TEST phases.
64
64
  Do not plan, do not strategize. Follow the contract below exactly.
@@ -98,7 +98,7 @@ Any ❌ → Planning fixes inline or sends back to Fast for a targeted correctio
98
98
  **If the Agent tool is not available** (Gemini, Cursor, Windsurf, Cline, or any non-Claude Code environment):
99
99
 
100
100
  - Execute all phases as a single agent.
101
- - Apply Planning mindset during SPEC and PLAN (analytical, stop for approval).
102
- - Apply Fast mindset during CODE and TEST (operational, no strategic detours).
103
- - The role annotations in the workflow (`> **Role: Planning**`, `> **Role: Fast**`) serve as mindset cues — treat them as discipline markers, not execution boundaries.
101
+ - Apply Planning mindset during SPEC and PLAN (MODE: PLANNING, stop for approval).
102
+ - Apply Fast mindset during CODE and TEST (MODE: FAST, no strategic detours).
103
+ - The mode annotations in the workflow (`MODE: PLANNING`, `MODE: FAST`) serve as mindset cues — treat them as discipline markers, not execution boundaries.
104
104
  - Proceed through END normally.
@@ -8,8 +8,8 @@
8
8
 
9
9
  ## The Rules of the Caveman
10
10
 
11
- 1. **Articles Die**: Remove "a", "an", "the" (EN) and "o", "a", "os", "as", "um", "uma" (PT).
12
- 2. **Filler Die**: No "I'd be happy to", "Certamente", "Com certeza", "Claro". Start with the result.
11
+ 1. **Articles Die**: Remove "a", "an", "the".
12
+ 2. **Filler Die**: No "I'd be happy to", "Certainly", "Sure". Start with the result.
13
13
  3. **Hedging Die**: No "I think", "It seems", "Perhaps". State facts or code.
14
14
  4. **Fragments Allowed**: Use bullet points or short fragments. "Fix bug. Task done." > "I have fixed the bug and the task is now done."
15
15
  5. **Technical Integrity**: NEVER compress paths, code blocks, or identifiers. Code must remain elegant (Narrative Cascade).
@@ -17,7 +17,7 @@
17
17
 
18
18
  ## Example (Caveman Full)
19
19
 
20
- **Prompt**: "Como está o projeto?"
21
- **Response**: "Status: v1.10.4. Backlog: 2 itens. Contexto ok. Pronto comando."
20
+ **Prompt**: "How is the project status?"
21
+ **Response**: "Status: v1.10.4. Backlog: 2 items. Context ok. Ready for command."
22
22
 
23
23
  </ruleset>
@@ -20,139 +20,95 @@ On every request, classify intent before acting:
20
20
 
21
21
  ---
22
22
 
23
- ## Phase: SPEC (The Contract)
24
-
25
- > **Role: Planning**
23
+ ## Phase: SPEC (The Contract) — MODE: PLANNING
26
24
 
27
25
  > <rule name="PhaseSPEC">
28
26
  > [!IMPORTANT]
29
27
  > Structure the intent before any implementation. **Stop and wait for approval.**
30
-
31
- ### Instructions
32
-
33
- - **Goal:** One sentence summary.
34
- - **Domain:** Backend | Frontend | Fullstack.
35
- - **Inputs / Outputs:** Clearly defined contracts.
36
- - **Configuration Contract**: List all required environment variables with their purpose (keys must be **abstract**; no committed templates like `.env.example`).
37
- - **Specialization**:
38
- - **Feat**: Focus on **Domain Modeling** and **Public Interfaces**.
39
- - **Fix**: Focus on **Root Cause Analysis (RCA)** and **Reproduction Case**.
40
- - **Docs**: Focus on **Structure and Accuracy** select the appropriate template (CHANGELOG / FEAT / ADR) before drafting.
41
- - **Verification Checklist:** Binary pass/fail criteria (max 5 items).
42
- - **Hard Rule**: You **MUST STOP** and wait for explicit Developer approval before proceeding.
43
- > </rule>
44
-
45
- ## Phase: PLAN (The Strategy)
46
-
47
- > **Role: Planning**
28
+ >
29
+ > **Steps:**
30
+ >
31
+ > 1. **Intent Classification**: Reads the request and identifies the intent: `land:`, `feat:`, `fix:`, `docs:` or `end:`.
32
+ > 2. **Goal Definition**: Writes one sentence describing what will be built and why.
33
+ > 3. **Domain & Contracts**: Defines the domain (Backend / Frontend / Fullstack) and the inputs and outputs.
34
+ > 4. **Verification Checklist**: Creates up to 5 yes/no checkpoints to confirm the work is done right.
35
+ > 5. **Approval Gate**: Stops and waits for your approval before writing any code.
36
+ > </rule>
37
+
38
+ ## Phase: PLAN (The Strategy)MODE: PLANNING
48
39
 
49
40
  > <rule name="PhasePLAN">
50
41
  > [!NOTE]
51
42
  > After spec is approved, produce a numbered task list ordered by logical execution sequence. **Stop and wait for approval.**
52
-
53
- ### Instructions
54
-
55
- - **Action Verb + Object**: Each task must be atomic (e.g., "1. Create User repository").
56
- - **Logical Order**: Tasks must be sequenced so each step unblocks the next — foundation before consumers, contracts before implementations, data layer before orchestration.
57
- - **Effort Estimate**: Tag each task with a relative size structural criteria are primary, time is a secondary reference:
58
- - `[S]` 1–2 files, isolated scope, no cross-layer tracing (≤ 5 min)
59
- - `[M]` 3–5 files, cross-layer impact, completes in one session (5–15 min)
60
- - `[L]` — 6+ files or cross-session risk **must** be split into sub-tasks (> 15 min)
61
- - **Task Decomposition**: Any task tagged `[L]` or that spans multiple layers **MUST** be split into numbered sub-tasks (e.g., `1.1`, `1.2`) to prevent context/token exhaustion.
62
- - **Backlog Sync**:
63
- - `[M]` / `[L]`: write all tasks to `.ai-backlog/tasks.md` under `## Backlog` with `[TODO]`; move first to `## Active` as `[IN_PROGRESS]`.
64
- - `[S]`: skip `tasks.md` — update only `context.md ## Now` at END.
65
- - **Hard Rule**: You **MUST STOP** and wait for explicit Developer approval before proceeding.
66
- > </rule>
67
-
68
- ## Phase: CODE (The Execution)
69
-
70
- > **Role: Fast**
43
+ >
44
+ > **Steps:**
45
+ >
46
+ > 1. **Task Breakdown**: Breaks the spec into concrete tasks. Each one starts with an action verb.
47
+ > 2. **Logical Sequencing**: Orders tasks by dependency: what needs to exist first, goes first.
48
+ > 3. **Effort Tagging**: Tags each task by size: `[S]` small · `[M]` medium · `[L]` large (must be split).
49
+ > 4. **Sub-task Split**: Breaks every `[L]` task into numbered steps: 1.1, 1.2...
50
+ > 5. **Backlog Sync**: Saves all tasks to `.ai-backlog/tasks.md` and marks the first one as in progress.
51
+ > 6. **Approval Gate**: Stops and waits for your approval before writing any code.
52
+ > </rule>
53
+
54
+ ## Phase: CODE (The Execution) MODE: FAST
71
55
 
72
56
  > <rule name="PhaseCODE">
73
57
  > [!IMPORTANT]
74
58
  > Follow the approved plan strictly.
75
-
76
- ### Instructions
77
-
78
- - **Context Load**: Before writing any code, load based on domain scope:
79
- - `engineering-standards.md` and `code-style.md` always required
80
- - `competencies/backend.md` — if domain includes backend
81
- - `competencies/frontend.md` if domain includes frontend
82
- - `flavor/principles.md` — if architectural pattern is relevant to the task
83
-
84
- - **Narrative Gate (hard gate output before writing each function)**:
85
- Output this checklist with ✅/❌ before writing any function body.
86
- Any = redesign first. This gate cannot be skipped or internalized.
87
-
88
- _Structure_
89
- - [ ] **Stepdown Rule** — entry point is topmost; callers above callees in the file
90
- - [ ] **SLA** — this function orchestrates OR implements, never both in the same body
91
- - [ ] **Guard Clauses** all nested conditionals replaced with early returns
92
- - [ ] **Lexical Scoping** one-off helpers defined inside their only caller, not at module level
93
-
94
- _Expression_
95
- - [ ] **Explaining Returns**return value assigned to a named `const`; no bare `return ok(...)` or anonymous inline objects
96
- - [ ] **Shallow Boundaries** — no property chain deeper than 3 levels; extract a named `const` slice first
97
- - [ ] **Vertical Density** — related variables grouped together; single blank line between logical blocks
98
-
99
- _Naming_
100
- - [ ] **Expressive Names** — every name reveals its role without needing a comment
101
- - [ ] **Boolean Prefix** — `isLoading`, `hasError`, `isActive`; never bare `loading`, `error`, `active`
102
- - [ ] **No Abbreviations** — `request`/`response`; never `req`/`res`; no framework exception
103
-
104
- _Documentation_
105
- - [ ] **Code as Documentation** — no "what" comments; only `// why:` for non-obvious constraints or deliberate trade-offs
106
-
107
- _Module (per file)_
108
- - [ ] **Revealing Module Pattern** — named object + named export at file footer; no `export default`
109
- - [ ] **No God Modules** — no `helpers.js`, `utils.js`, `common.js`; name files by domain + operation
110
-
111
- - **Result Pattern**: Prefer `Result<T>` when it meaningfully clarifies the happy/failure split — do not force it where idiomatic error handling is already clear.
112
- - **YAGNI**: No features or refactors outside the approved SPEC.
113
- - **Blockers**: Surface issues immediately; do not work around them silently.
114
- > </rule>
115
-
116
- ## Phase: TEST (The Verification)
117
-
118
- > **Role: Fast**
59
+ >
60
+ > **Steps:**
61
+ >
62
+ > 1. **Context Load**: Reads the project's standards and style guide before writing anything (read `engineering-standards.md`, `code-style.md`, and competencies).
63
+ > 2. **Quality Gate**: Reviews every function against the guide's readability rules before moving on.
64
+ >
65
+ > _Narrative Gate Checklist:_
66
+ >
67
+ > - [ ] **Stepdown Rule** — entry point is topmost; callers above callees in the file
68
+ > - [ ] **SLA** this function orchestrates OR implements, never both in same body
69
+ > - [ ] **Guard Clauses** all nested conditionals replaced with early returns
70
+ > - [ ] **Lexical Scoping** one-off helpers defined inside their only caller
71
+ > - [ ] **Explaining Returns** — return value assigned to a named `const`; no bare returns
72
+ > - [ ] **Boolean Prefix** — `isLoading`, `hasError`, `isActive`; never bare `loading`, `error`
73
+ > - [ ] **Code as Documentation** — no "what" comments; only `// why:` for non-obvious constraints
74
+ >
75
+ > 3. **Plan Adherence**: Follows the agreed plan. No extra features or refactors outside what was approved.
76
+ > 4. **Blocker Surface**: Raises blockers immediately. Never quietly works around them.
77
+ > </rule>
78
+
79
+ ## Phase: TEST (The Verification)MODE: FAST
119
80
 
120
81
  > <rule name="PhaseTEST">
121
82
  > [!IMPORTANT]
122
83
  > Verify against the Verification Checklist.
123
-
124
- ### Instructions
125
-
126
- - **Regression Focus**: For `fix:` cycles, the test MUST prove the bug no longer reproduces and no regressions exist.
127
- - **Fix Loop (max 3x)**: If any test FAILs, fix and re-run.
128
- - **Lint Fix**: After tests pass, run `lint --fix` (or equivalent) if a lint script is available in the project. Resolve all auto-fixable violations before leaving this phase. If non-auto-fixable violations remain, surface them explicitly.
129
- - **Reporting**: Report PASS/FAIL for every checklist item plus lint status. If still failing after 3 loops, STOP and report.
130
- > </rule>
131
-
132
- ## Phase: END (The Delivery)
133
-
134
- > **Role: Planning**
84
+ >
85
+ > **Steps:**
86
+ >
87
+ > 1. **Checklist Verification**: Goes through every item on the Spec's Verification Checklist.
88
+ > 2. **Regression Check**: For `fix:` cycles: confirms the bug is gone and nothing else broke.
89
+ > 3. **Fix Loop**: If something fails: fix and re-run. Up to 3 attempts before escalating.
90
+ > 4. **Lint Fix**: Runs the linter and fixes what it can before wrapping up.
91
+ > 5. **Report**: Reports the result of each checklist item and lint status before moving on.
92
+ > </rule>
93
+
94
+ ## Phase: END (The Delivery) — MODE: PLANNING
135
95
 
136
96
  > <rule name="PhaseEND">
137
97
  > [!NOTE]
138
98
  > Close the cycle and sync documentation. **No delivery without explicit curation and authorization.**
139
-
140
- ### END Checklist (mandatory — execute in order, mark each before proceeding)
141
-
142
- - [ ] **SUMMARIZE** one sentence per completed PLAN task written in response
143
- - [ ] **CHANGELOG** Prepare your technical narrative in the `CHANGELOG.md` under `## [Unreleased]`. This MUST be done before bumping.
144
- - [ ] **BUMP** run \`npm run bump <feat|fix>\` to promote CHANGELOG and package.json version. Skip if not applicable.
145
- - [ ] **BACKLOG: tasks.md** all completed tasks moved to `## Done` with `[DONE]` status
146
- - [ ] **BACKLOG: context.md** \`## Now\` updated with next objective or cleared
147
- - [ ] **KNOWLEDGE** Log any patterns, findings, or rework discovered during this cycle. Update \`.ai-backlog/learned.md\` (for successful feats) or \`.ai-backlog/troubleshoot.md\` (for fixed incidents). Curate stale or irrelevant items.
148
- - [ ] **CURATE** final scan for slop, "AI-isms", and unfinished comments. Run `git status` to ensure only intended changes are staged.
149
- - [ ] **LINT** — if lint script exists (`lint`, `lint:fix`, `lint:all`, or config file detected), run it; auto-fix what's possible; block commit if errors remain
150
- - [ ] **COMMIT** — **PROPOSE** the commit message and **WAIT** for explicit Developer approval
151
- - [ ] **PUSH** — **ASK** for explicit permission before pushing to remote
152
-
99
+ >
100
+ > **Steps:**
101
+ >
102
+ > 1. **Task Summary**: Writes one sentence per completed task.
103
+ > 2. **Changelog**: Adds a narrative entry under `## [Unreleased]`.
104
+ > 3. **Zero-Leak Staging**: Runs `git add .` to capture all side-effects and metadata.
105
+ > 4. **Context Resilience**: Updates `context.md` (or bootstraps it if missing).
106
+ > 5. **Self-Healing Quality**: Runs linting and attempts auto-repair (`lint --fix`) if needed.
107
+ > 6. **Release (Audit & Commit)**: Runs `npm run bump <feat|fix>`, performs a final workspace audit, and proposes a semantic release commit.
108
+ > 7. **Final Delivery**: Proposes `git push` and a fresh session.
109
+ >
153
110
  > [!WARNING]
154
- > Do NOT consider the cycle closed until every applicable item above is checked.
155
- > If any item is skipped, the cycle is **INCOMPLETE** — return and complete it before accepting new work.
111
+ > Do NOT perform `git commit` or `git push` autonomously. Always **PROPOSE** and **WAIT**.
156
112
  > </rule>
157
113
 
158
114
  ## Rule: Task Handoff (Cross-Session & Cross-Agent Continuity)
@@ -219,6 +175,9 @@ When a message arrives during an active cycle, classify it before acting:
219
175
  | **Pivot** | "change the approach entirely" | Return to SPEC, revise, wait for re-approval |
220
176
  | **Unrelated request** | "fix this other thing while you're at it" | Flag it as out-of-scope. Finish the current cycle first, then start a new one |
221
177
 
178
+ **State Recovery**: After any conversational interruption, explicitly state your current position before continuing.
179
+ _Example: "Resuming Cycle Feat — Phase: SPEC — Step 3 (Domain & Contracts)."_
180
+
222
181
  **Hard Rule**: Never interpret a conversational message as a new `land:`, `feat:`, or `fix:` while a cycle is active. The cycle closes only at END.
223
182
 
224
183
  > </rule>
@@ -7,7 +7,6 @@
7
7
 
8
8
  import fs from 'node:fs';
9
9
  import path from 'node:path';
10
-
11
10
  import { execSync } from 'node:child_process';
12
11
 
13
12
  const PROJECT_ROOT = process.cwd();
@@ -17,6 +16,22 @@ async function run() {
17
16
  const isPrePush = process.argv.includes('--pre-push');
18
17
  const commitMsgFile = isPrePush ? null : process.argv[2];
19
18
 
19
+ let changelog = '';
20
+ try {
21
+ // Read STAGED version of CHANGELOG.md (if possible)
22
+ changelog = execSync('git show :CHANGELOG.md', {
23
+ stdio: ['pipe', 'pipe', 'ignore'],
24
+ }).toString();
25
+ } catch {
26
+ if (fs.existsSync(CHANGELOG_PATH)) {
27
+ changelog = fs.readFileSync(CHANGELOG_PATH, 'utf8');
28
+ }
29
+ }
30
+
31
+ if (!changelog) {
32
+ process.exit(0);
33
+ }
34
+
20
35
  if (!isPrePush) {
21
36
  if (!commitMsgFile) {
22
37
  console.error(' ❌ Error: No commit message file provided.');
@@ -30,29 +45,49 @@ async function run() {
30
45
  const commitMsg = fs.readFileSync(commitMsgFile, 'utf8').trim();
31
46
  const firstLine = commitMsg.split('\n')[0].trim();
32
47
 
33
- // ONLY target feat: and fix: (SDG Cycle Triggers) as per maintainer instruction
48
+ // ONLY target feat: and fix: (SDG Cycle Triggers)
34
49
  const isSdgTrigger = /^feat:/.test(firstLine) || /^fix:/.test(firstLine);
35
50
  if (!isSdgTrigger) {
36
51
  process.exit(0);
37
52
  }
38
- }
39
53
 
40
- let changelog = '';
41
- try {
42
- // Read STAGED version of CHANGELOG.md (if possible)
43
- changelog = execSync('git show :CHANGELOG.md', {
44
- stdio: ['pipe', 'pipe', 'ignore'],
45
- }).toString();
46
- } catch {
47
- if (fs.existsSync(CHANGELOG_PATH)) {
48
- changelog = fs.readFileSync(CHANGELOG_PATH, 'utf8');
49
- }
50
- }
54
+ // RELEASE CONTEXT DETECTION
55
+ const isReleaseCommit = firstLine.toLowerCase().includes('release');
56
+ const releaseVersionMatch = firstLine.match(/v?(\d+\.\d+\.\d+)/);
57
+ const releaseVersion = releaseVersionMatch ? releaseVersionMatch[1] : null;
51
58
 
52
- if (!changelog) {
53
- process.exit(0);
59
+ if (isReleaseCommit && releaseVersion) {
60
+ const versionHeaderRegex = new RegExp(
61
+ `##\\s*\\[${releaseVersion}\\].*?\\n([\\s\\S]*?)(?=\\n##\\s|(?:\\n){0,1}$)`,
62
+ 'i'
63
+ );
64
+ const versionMatch = changelog.match(versionHeaderRegex);
65
+
66
+ if (!versionMatch) {
67
+ console.error(
68
+ `\n ❌ NARRATIVE VIOLATION: Version header "## [${releaseVersion}]" not found in CHANGELOG.md.`
69
+ );
70
+ process.exit(1);
71
+ }
72
+
73
+ const versionNarrative = versionMatch[1]
74
+ .replace(/###\s*(Added|Fixed|Changed|Removed|Security|Deprecated)/gi, '')
75
+ .replace(/<!--[\s\S]*?-->/g, '')
76
+ .trim();
77
+
78
+ if (versionNarrative.length < 3) {
79
+ console.error(
80
+ `\n ❌ NARRATIVE VIOLATION: Version header "## [${releaseVersion}]" has no narrative.`
81
+ );
82
+ process.exit(1);
83
+ }
84
+
85
+ console.log(` ✅ Narrative Guard: Release v${releaseVersion} validated.`);
86
+ process.exit(0);
87
+ }
54
88
  }
55
89
 
90
+ // STANDARD NARRATIVE CHECK (Unreleased)
56
91
  const unreleasedMatch = changelog.match(
57
92
  /##\s*\[Unreleased\].*?\n([\s\S]*?)(?=\n##\s|(?:\n){0,1}$)/i
58
93
  );
@@ -96,4 +131,3 @@ run().catch((err) => {
96
131
  console.error(' ❌ Narrative Guard Exception:', err.message);
97
132
  process.exit(1);
98
133
  });
99
- // test