sdg-agents 1.1.3 → 1.2.6

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/README.md CHANGED
@@ -69,9 +69,8 @@ your-project/
69
69
  │ │ └── competencies/ ← Layer-specific rules (frontend, backend)
70
70
  │ ├── commands/ ← Context files for feat/fix/docs cycles
71
71
  │ └── dev-guides/ ← Reference files, spec templates, and guides
72
- └── .ai-backlog/ ← Session memory (gitignored)
73
- ├── context.md Project brief, decisions, current state
74
- └── tasks.md ← Task list (TODO / IN_PROGRESS / DONE)
72
+ └── .ai-backlog/ ← Session memory & Expertise (gitignored)
73
+ └── ... (See docs/PROJECT-STRUCTURE.md for details)
75
74
  ```
76
75
 
77
76
  `dev-guides/` is always included. It contains the 5-phase cycle guide, the internal decision-gate flow, SDLC reference, UI prompt guide, and spec templates (`prompt-tracks/`) for authoring the SPEC phase of any task.
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "sdg-agents",
3
- "version": "1.1.3",
3
+ "version": "1.2.6",
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",
7
7
  "bin": {
8
- "sdg-agents": "./src/engine/bin/index.mjs"
8
+ "sdg-agents": "src/engine/bin/index.mjs"
9
9
  },
10
10
  "engines": {
11
11
  "node": ">=24.0.0"
@@ -12,14 +12,20 @@ Write one sentence per completed PLAN task. If no PLAN existed (e.g. `[S]` tasks
12
12
 
13
13
  ## Step 2 — CHANGELOG
14
14
 
15
- Append an entry under `## [Unreleased]` in `CHANGELOG.md`:
15
+ - Append an entry under `## [Unreleased]` in `CHANGELOG.md`:
16
16
 
17
- - `feat:` cycle `### Added`
18
- - `fix:` cycle → `### Fixed`
19
- - `docs:` cycle → skip this step
20
- - `land:` cycle skip this step
17
+ 1. **Identify Version**: Check `package.json` (or equivalent) for the current version.
18
+ 2. **Calculate Next**: Determine the next version (patch/minor) based on the cycle type (`feat` minor/patch, `fix` → patch).
19
+ 3. **Update Header**:
20
+ - If the project uses auto-bump or a release is intended: Create/Update the header to `## [NEXT_VERSION] - YYYY-MM-DD`.
21
+ - Otherwise: Append under `## [Unreleased]`.
22
+ 4. **Append Entry**:
23
+ - `feat:` cycle → `### Added`
24
+ - `fix:` cycle → `### Fixed`
25
+ - `docs:` cycle → skip this step
26
+ - `land:` cycle → skip this step
21
27
 
22
- If `## [Unreleased]` does not exist, create it above the most recent versioned entry.
28
+ If `## [Unreleased]` (or the appropriate version header) does not exist, create it above the most recent entry.
23
29
 
24
30
  ## Step 3 — BACKLOG: tasks.md
25
31
 
@@ -30,9 +36,13 @@ If `## [Unreleased]` does not exist, create it above the most recent versioned e
30
36
 
31
37
  Update `## Now` with the next objective, or set it to `Ready for next instruction.` if nothing is pending.
32
38
 
33
- ## Step 5 — INSIGHTS
39
+ ## Step 5 — KNOWLEDGE (INSIGHTS)
34
40
 
35
- Log any patterns, findings, or rework discovered during this cycle in `context.md ## Engineering Insights`. Curate stale or irrelevant entries.
41
+ Log any patterns, findings, or rework discovered during this cycle. Curate stale or irrelevant entries.
42
+
43
+ - **feat:** cycle → Update `.ai-backlog/learned.md` with success patterns and research findings.
44
+ - **fix:** cycle → Update `.ai-backlog/troubleshoot.md` with the Root Cause Analysis (RCA) and "gotchas" discovered.
45
+ - **Other:** If specific insights exist but don't fit the above, announce them or update `.ai-backlog/learned.md`.
36
46
 
37
47
  ## Step 6 — CURATE
38
48
 
@@ -10,10 +10,11 @@ We are initializing a new feature: $ARGUMENTS. This command prepares the context
10
10
  - **Frontend** (UI/UX) → read `.ai/instructions/competencies/frontend.md`
11
11
  - **Fullstack** → read both
12
12
  3. **Architecture Standards**: If `.ai/instructions/flavor/principles.md` exists, read the established data pipeline (Vertical Slice, MVC, etc.).
13
- 4. **Code Style Load** (mandatory do not skip):
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):
14
15
  - **Engineering Standards** → read `.ai/instructions/core/engineering-standards.md`
15
16
  - **Code Style & NarrativeCascade** → read `.ai/instructions/core/code-style.md`
16
- 5. **Quality & Debugging**:
17
+ 6. **Quality & Debugging**:
17
18
  - **Testing Strategy** → read `.ai/instructions/core/testing-principles.md`
18
19
  - **Observability** → read `.ai/instructions/core/observability.md`
19
20
 
@@ -10,10 +10,11 @@ We are correcting a recorded incident: $ARGUMENTS. This command prepares the con
10
10
  - **Frontend** (UI/UX) → read `.ai/instructions/competencies/frontend.md`
11
11
  - **Fullstack** → read both
12
12
  3. **Architecture Standards**: If `.ai/instructions/flavor/principles.md` exists, read the architectural principles.
13
- 4. **Code Style & Standards** (mandatory):
13
+ 4. **Backlog Knowledge**: Read `.ai-backlog/troubleshoot.md` to load previous RCA logs and critical failure records.
14
+ 5. **Code Style & Standards** (mandatory):
14
15
  - **Engineering Standards** → read `.ai/instructions/core/engineering-standards.md`
15
16
  - **Code Style & Narrative Scansion** → read `.ai/instructions/core/code-style.md`
16
- 5. **Diagnostic Standards**:
17
+ 6. **Diagnostic Standards**:
17
18
  - **Testing Principles** → read `.ai/instructions/core/testing-principles.md`
18
19
  - **Observability** → read `.ai/instructions/core/observability.md`
19
20
 
@@ -226,6 +226,7 @@ function buildOrderSummary(order) {
226
226
  - **Idempotency:** Operations involving money, state changes, or side-effects must use **Idempotency Keys (UUIDs)**.
227
227
  - **Graceful Degradation:** Use **Error Boundaries** and defensive type checking (`data?.user?.name`) to prevent UI collapses.
228
228
  - **Failure Narrative:** Prefer typed error objects (or Result objects when they clarify the happy/failure path) over magic strings or raw exceptions. Do not force the pattern where idiomatic error handling is already clear.
229
+ - **Toolchain Discoverability & Boot Sanity:** Non-interactive processes (hooks, CI, agents) must explicitly verify or discover their dependencies instead of assuming a pre-configured interactive `$PATH`. Any script that relies on a specific binary (Node, Go, Python, etc.) should fail-fast with a clear diagnostic message if the binary is missing, or attempt to locate it in common installation paths.
229
230
  </rule>
230
231
 
231
232
  ## Rule: Result Pattern & HTTP Envelope
@@ -216,7 +216,29 @@ export default UserService;
216
216
  >
217
217
  > </rule>
218
218
 
219
- >
219
+ ---
220
+
221
+ ## Operational Resilience
222
+
223
+ ### Node Discovery (Shell Resilience)
224
+
225
+ > <rule name="NodeDiscovery">
226
+ > When writing shell hooks (Husky, CI, git hooks) for a Node project, attempt to discover `node` and `npm` if they are missing from the current `$PATH`. This prevents failures in restricted environments (AI agents, GUI clients).
227
+
228
+ ```bash
229
+ # Node Discovery — Staff-grade Resilience
230
+ if ! command -v node >/dev/null 2>&1; then
231
+ export PATH="$PATH:/usr/local/bin:/usr/bin:/bin:/opt/homebrew/bin"
232
+ # Source common environment managers
233
+ [ -f "$HOME/.nvm/nvm.sh" ] && . "$HOME/.nvm/nvm.sh" && nvm use --silent >/dev/null 2>&1
234
+ [ -f "$HOME/.asdf/asdf.sh" ] && . "$HOME/.asdf/asdf.sh" >/dev/null 2>&1
235
+ fi
236
+
237
+ if ! command -v node >/dev/null 2>&1; then
238
+ echo "❌ Error: 'node' not found in PATH."
239
+ exit 1
240
+ fi
241
+ ```
220
242
 
221
243
  > </rule>
222
244
 
@@ -301,4 +301,28 @@ return <div className={headerContainerClassName}>...</div>
301
301
  > Fetch and validation in the server block (`---`). Only data is passed to client islands (`client:load`, `client:visible`).
302
302
  > </ rule>
303
303
 
304
+ ## Operational Resilience
305
+
306
+ ### Node Discovery (Shell Resilience)
307
+
308
+ > <rule name="NodeDiscovery">
309
+ > When writing shell hooks (Husky, CI, git hooks) for a Node project, attempt to discover `node` and `npm` if they are missing from the current `$PATH`. This prevents failures in restricted environments (AI agents, GUI clients).
310
+
311
+ ```bash
312
+ # Node Discovery — Staff-grade Resilience
313
+ if ! command -v node >/dev/null 2>&1; then
314
+ export PATH="$PATH:/usr/local/bin:/usr/bin:/bin:/opt/homebrew/bin"
315
+ # Source common environment managers
316
+ [ -f "$HOME/.nvm/nvm.sh" ] && . "$HOME/.nvm/nvm.sh" && nvm use --silent >/dev/null 2>&1
317
+ [ -f "$HOME/.asdf/asdf.sh" ] && . "$HOME/.asdf/asdf.sh" >/dev/null 2>&1
318
+ fi
319
+
320
+ if ! command -v node >/dev/null 2>&1; then
321
+ echo "❌ Error: 'node' not found in PATH."
322
+ exit 1
323
+ fi
324
+ ```
325
+
326
+ > </rule>
327
+
304
328
  </ruleset>
@@ -140,10 +140,10 @@ On every request, classify intent before acting:
140
140
  ### END Checklist (mandatory — execute in order, mark each before proceeding)
141
141
 
142
142
  - [ ] **SUMMARIZE** — one sentence per completed PLAN task written in response
143
- - [ ] **CHANGELOG** — entry appended under `## [Unreleased]` (`### Added` for feat, `### Fixed` for fix; skip for docs)
143
+ - [ ] **CHANGELOG** — Append entry. **Identify next version** (check \`package.json\`) to determine the header (\`## [NEXT_VERSION] - YYYY-MM-DD\` for releases/auto-bump, or \`## [Unreleased]\`). Categories: \`### Added\` (feat), \`### Fixed\` (fix).
144
144
  - [ ] **BACKLOG: tasks.md** — all completed tasks moved to `## Done` with `[DONE]` status
145
145
  - [ ] **BACKLOG: context.md** — \`## Now\` updated with next objective or cleared
146
- - [ ] **INSIGHTS** — log patterns, research findings, or rework in \`context.md\` ## Engineering Insights (curate stale or irrelevant items)
146
+ - [ ] **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.
147
147
  - [ ] **CURATE** — final scan for slop, "AI-isms", and unfinished comments. Run `git status` to ensure only intended changes are staged.
148
148
  - [ ] **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
149
149
  - [ ] **COMMIT** — **PROPOSE** the commit message and **WAIT** for explicit Developer approval
@@ -184,10 +184,6 @@ entry: <main entry point file>
184
184
  ## Now
185
185
 
186
186
  - Ready for next instruction.
187
-
188
- ## Engineering Insights
189
-
190
- - [topic]: [lesson learned or research finding]
191
187
  ```
192
188
 
193
189
  ### Checkpoint (after each atomic task)
@@ -137,7 +137,9 @@ function buildMasterInstructions(selections) {
137
137
  | File | Purpose |
138
138
  | :--- | :------ |
139
139
  | \`.ai-backlog/context.md\` | Project Brief — read before anything else |
140
- | \`.ai-backlog/tasks.md\` | Active tasks and handoff state |`;
140
+ | \`.ai-backlog/tasks.md\` | Active tasks and handoff state |
141
+ | \`.ai-backlog/learned.md\` | Lessons Learned — success patterns and research |
142
+ | \`.ai-backlog/troubleshoot.md\` | Troubleshooting — RCA logs and failure records |`;
141
143
 
142
144
  return routingString;
143
145
  }
@@ -292,6 +294,8 @@ function writeBacklogFiles(targetDir, selections) {
292
294
 
293
295
  writeContextFile(backlogDir, targetDir, selections);
294
296
  writeTasksFile(backlogDir);
297
+ writeLearnedFile(backlogDir);
298
+ writeTroubleshootFile(backlogDir);
295
299
 
296
300
  function writeContextFile(backlogDirPath, projectDir, currentSelections) {
297
301
  const contextPath = path.join(backlogDirPath, 'context.md');
@@ -313,9 +317,6 @@ function writeBacklogFiles(targetDir, selections) {
313
317
 
314
318
  ## Now
315
319
  [what is actively being worked on]
316
-
317
- ## Engineering Insights
318
- - [topic]: [lesson learned or research finding]
319
320
  `;
320
321
 
321
322
  fs.writeFileSync(contextPath, contextContent);
@@ -343,6 +344,46 @@ function writeBacklogFiles(targetDir, selections) {
343
344
 
344
345
  fs.writeFileSync(tasksPath, tasksContent);
345
346
  }
347
+
348
+ function writeLearnedFile(backlogDirPath) {
349
+ const learnedPath = path.join(backlogDirPath, 'learned.md');
350
+ if (fs.existsSync(learnedPath)) return;
351
+
352
+ const learnedContent = dedent`
353
+ # Lessons Learned & Research
354
+
355
+ > Persistent repository for success patterns, technical research, and architecture decisions.
356
+ > Loaded during \`feat:\` cycles.
357
+
358
+ ## Success Patterns
359
+ - [topic]: [pattern or approach that worked well]
360
+
361
+ ## Research Findings
362
+ - [topic]: [discovery or validated hypothesis]
363
+ `;
364
+
365
+ fs.writeFileSync(learnedPath, learnedContent);
366
+ }
367
+
368
+ function writeTroubleshootFile(backlogDirPath) {
369
+ const troubleshootPath = path.join(backlogDirPath, 'troubleshoot.md');
370
+ if (fs.existsSync(troubleshootPath)) return;
371
+
372
+ const troubleshootContent = dedent`
373
+ # Troubleshooting & RCA Logs
374
+
375
+ > Persistent repository for failure records, Root Cause Analysis (RCA), and technical debt.
376
+ > Loaded during \`fix:\` cycles to prevent regression.
377
+
378
+ ## Failure Records (RCA)
379
+ - [date] [topic]: [what failed, why, and the "gotcha" to avoid]
380
+
381
+ ## Technical Debt & Risks
382
+ - [topic]: [known limitation or fragile area]
383
+ `;
384
+
385
+ fs.writeFileSync(troubleshootPath, troubleshootContent);
386
+ }
346
387
  }
347
388
 
348
389
  /**
@@ -368,7 +409,8 @@ function buildClaudeContent() {
368
409
 
369
410
  1. **Check backlog**: Read \`.ai-backlog/context.md\` — understand the project brief. **Priority**: Always check the local directory first to avoid redundant scans.
370
411
  2. **Check tasks**: Read \`.ai-backlog/tasks.md\` — resume any \`[IN_PROGRESS]\` task before accepting new work.
371
- 3. **Bootstrap if missing**: If \`.ai-backlog/context.md\` does not exist, follow the **Context Bootstrap** defined in the Working Protocol (loaded via \`@.ai/skill/AGENTS.md\` above).
412
+ 3. **Terminal Sanity Check**: Run \`node -v\` and \`npm -v\` (or the project's primary toolchain) to "wake up" the terminal and confirm execution capabilities in the current shell.
413
+ 4. **Bootstrap if missing**: If \`.ai-backlog/context.md\` does not exist, follow the **Context Bootstrap** defined in the Working Protocol (loaded via \`@.ai/skill/AGENTS.md\` above).
372
414
 
373
415
  ## Intent Routing (quick reference)
374
416