gsd-pi 2.5.0 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist/loader.js +21 -3
  2. package/dist/logo.d.ts +3 -3
  3. package/dist/logo.js +2 -2
  4. package/package.json +1 -1
  5. package/src/resources/extensions/get-secrets-from-user.ts +63 -8
  6. package/src/resources/extensions/gsd/auto.ts +45 -11
  7. package/src/resources/extensions/gsd/docs/preferences-reference.md +1 -0
  8. package/src/resources/extensions/gsd/files.ts +70 -0
  9. package/src/resources/extensions/gsd/git-service.ts +27 -106
  10. package/src/resources/extensions/gsd/gitignore.ts +1 -0
  11. package/src/resources/extensions/gsd/guided-flow.ts +6 -3
  12. package/src/resources/extensions/gsd/preferences.ts +8 -0
  13. package/src/resources/extensions/gsd/prompts/complete-slice.md +7 -5
  14. package/src/resources/extensions/gsd/prompts/discuss.md +7 -15
  15. package/src/resources/extensions/gsd/prompts/execute-task.md +2 -6
  16. package/src/resources/extensions/gsd/prompts/guided-plan-milestone.md +4 -0
  17. package/src/resources/extensions/gsd/prompts/plan-milestone.md +33 -1
  18. package/src/resources/extensions/gsd/prompts/plan-slice.md +24 -32
  19. package/src/resources/extensions/gsd/templates/plan.md +8 -10
  20. package/src/resources/extensions/gsd/templates/secrets-manifest.md +22 -0
  21. package/src/resources/extensions/gsd/templates/task-plan.md +6 -6
  22. package/src/resources/extensions/gsd/tests/git-service.test.ts +63 -0
  23. package/src/resources/extensions/gsd/tests/parsers.test.ts +211 -65
  24. package/src/resources/extensions/gsd/tests/secure-env-collect.test.ts +185 -0
  25. package/src/resources/extensions/gsd/types.ts +20 -0
@@ -3,6 +3,7 @@ import { homedir } from "node:os";
3
3
  import { isAbsolute, join } from "node:path";
4
4
  import { getAgentDir } from "@mariozechner/pi-coding-agent";
5
5
  import type { GitPreferences } from "./git-service.ts";
6
+ import { VALID_BRANCH_NAME } from "./git-service.ts";
6
7
 
7
8
  const GLOBAL_PREFERENCES_PATH = join(homedir(), ".gsd", "preferences.md");
8
9
  const LEGACY_GLOBAL_PREFERENCES_PATH = join(homedir(), ".pi", "agent", "gsd-preferences.md");
@@ -639,6 +640,13 @@ function validatePreferences(preferences: GSDPreferences): {
639
640
  errors.push(`git.commit_type must be one of: feat, fix, refactor, docs, test, chore, perf, ci, build, style`);
640
641
  }
641
642
  }
643
+ if (g.main_branch !== undefined) {
644
+ if (typeof g.main_branch === "string" && g.main_branch.trim() !== "" && VALID_BRANCH_NAME.test(g.main_branch)) {
645
+ git.main_branch = g.main_branch;
646
+ } else {
647
+ errors.push("git.main_branch must be a valid branch name (alphanumeric, _, -, /, .)");
648
+ }
649
+ }
642
650
 
643
651
  if (Object.keys(git).length > 0) {
644
652
  validated.git = git as GitPreferences;
@@ -6,17 +6,19 @@ All relevant context has been preloaded below — the slice plan, all task summa
6
6
 
7
7
  {{inlinedContext}}
8
8
 
9
+ **Match effort to complexity.** A simple slice with 1-2 tasks needs a brief summary and lightweight verification. A complex slice with 5 tasks across multiple subsystems needs thorough verification and a detailed summary. Scale the work below accordingly.
10
+
9
11
  Then:
10
12
  1. Read the templates:
11
13
  - `~/.gsd/agent/extensions/gsd/templates/slice-summary.md`
12
14
  - `~/.gsd/agent/extensions/gsd/templates/uat.md`
13
15
  2. If a `GSD Skill Preferences` block is present in system context, use it to decide which skills to load and follow during completion, without relaxing required verification or artifact rules
14
16
  3. Run all slice-level verification checks defined in the slice plan. All must pass before marking the slice done. If any fail, fix them first.
15
- 4. Confirm the slice's observability/diagnostic surfaces are real and useful where relevant: status inspection works, failure state is externally visible, structured errors/logs are actionable, and hidden failures are not being mistaken for success.
16
- 5. If `.gsd/REQUIREMENTS.md` exists, update it based on what this slice actually proved. Move requirements between Active, Validated, Deferred, Blocked, or Out of Scope only when the evidence from execution supports that change. Surface any new candidate requirements discovered during execution instead of silently dropping them.
17
- 6. Write `{{sliceSummaryAbsPath}}` (compress all task summaries). Fill the requirement-related sections explicitly.
18
- 7. Write `{{sliceUatAbsPath}}`. Fill the new `UAT Type`, `Requirements Proved By This UAT`, and `Not Proven By This UAT` sections explicitly.
19
- 8. Review task summaries for `key_decisions`. Ensure any significant architectural, pattern, or observability decisions are in `.gsd/DECISIONS.md`. If any are missing, append them now.
17
+ 4. If the slice plan includes observability/diagnostic surfaces, confirm they work. Skip this for simple slices that don't have observability sections.
18
+ 5. If `.gsd/REQUIREMENTS.md` exists, update it based on what this slice actually proved. Move requirements between Active, Validated, Deferred, Blocked, or Out of Scope only when the evidence from execution supports that change.
19
+ 6. Write `{{sliceSummaryAbsPath}}` (compress all task summaries).
20
+ 7. Write `{{sliceUatAbsPath}}`.
21
+ 8. Review task summaries for `key_decisions`. Append any significant decisions to `.gsd/DECISIONS.md` if missing.
20
22
  9. Mark {{sliceId}} done in `{{roadmapPath}}` (change `[ ]` to `[x]`)
21
23
  10. Do not commit or squash-merge manually — the system auto-commits your changes and handles the merge after this unit succeeds.
22
24
  11. Update `.gsd/PROJECT.md` if it exists — refresh current state if needed.
@@ -9,7 +9,7 @@ Special handling: if the user message is not a project description (for example,
9
9
  After the user describes their idea, **do not ask questions yet**. First, prove you understood by reflecting back:
10
10
 
11
11
  1. Summarize what you understood in your own words — concretely, not abstractly.
12
- 2. Include a complexity/scale read: "This sounds like [task/project/product] scale roughly N milestone(s)."
12
+ 2. Give an honest size read: roughly how many milestones, roughly how many slices in the first one. Base this on the actual work involved, not a classification label. A config change might be 1 milestone with 1 slice. A social network might be 5 milestones with 8+ slices each. Use your judgment.
13
13
  3. Include scope honesty — a bullet list of the major capabilities you're hearing: "Here's what I'm hearing: [bullet list of major capabilities]."
14
14
  4. Ask: "Did I get that right, or did I miss something?" — plain text, not `ask_user_questions`. Let them correct freely.
15
15
 
@@ -17,18 +17,14 @@ This prevents runaway questioning by forcing comprehension proof before anything
17
17
 
18
18
  ## Vision Mapping
19
19
 
20
- After reflection is confirmed, classify the scale:
20
+ After reflection is confirmed, decide the approach based on the actual scope — not a label:
21
21
 
22
- - **Task** a focused piece of work (single milestone, few slices)
23
- - **Project** — a coherent product with multiple major capabilities (multi-milestone likely)
24
- - **Product/Platform** — a large vision with distinct phases, audiences, or systems (definitely multi-milestone)
25
-
26
- **For Project or Product/Platform scale:** Before drilling into details, map the full landscape:
22
+ **If the work spans multiple milestones:** Before drilling into details, map the full landscape:
27
23
  1. Propose a milestone sequence — names, one-line intents, rough dependencies
28
24
  2. Present this to the user for confirmation or adjustment
29
25
  3. Only then begin the deep Q&A — and scope the Q&A to the full vision, not just M001
30
26
 
31
- **For Task scale:** Proceed directly to questioning.
27
+ **If the work fits in a single milestone:** Proceed directly to questioning.
32
28
 
33
29
  **Anti-reduction rule:** If the user describes a big vision, plan the big vision. Do not ask "what's the minimum viable version?" or try to reduce scope unless the user explicitly asks for an MVP or minimal version. When something is complex or risky, phase it into a later milestone — do not cut it. The user's ambition is the target, and your job is to sequence it intelligently, not shrink it.
34
30
 
@@ -77,15 +73,13 @@ Do NOT offer to proceed until ALL of the following are satisfied. Track these in
77
73
  - [ ] **The biggest technical unknowns / risks** — what could fail, what hasn't been proven
78
74
  - [ ] **What external systems/services this touches** — APIs, databases, third-party services, hardware
79
75
 
80
- **Minimum round counts before the wrap-up gate is allowed:**
81
- - **Task scale:** at least 2 full rounds (6+ questions asked and answered)
82
- - **Project/Product scale:** at least 4 full rounds (12+ questions asked and answered)
76
+ **Questioning depth should match scope.** Simple, well-defined work needs fewer rounds — maybe 1-2. Large, ambiguous visions need more — maybe 4+. Don't pad rounds to hit a number. Stop when the depth checklist is satisfied and you genuinely understand the work.
83
77
 
84
78
  Do not count the reflection step as a question round. Rounds start after reflection is confirmed.
85
79
 
86
80
  ## Wrap-up Gate
87
81
 
88
- Only after the depth checklist is fully satisfied AND minimum rounds are hit, offer to proceed.
82
+ Only after the depth checklist is fully satisfied and you genuinely understand the work, offer to proceed.
89
83
 
90
84
  The wrap-up gate must include a scope reflection:
91
85
  "Here's what I'm planning to build: [list of capabilities with rough complexity]. Does this match your vision, or did I miss something?"
@@ -149,9 +143,7 @@ If the project is new or has no `REQUIREMENTS.md`, confirm candidate requirement
149
143
 
150
144
  ## Scope Assessment
151
145
 
152
- Confirm the scale assessment from Vision Mapping still holds after discussion. If the scope grew or shrank significantly during Q&A, adjust the milestone count accordingly.
153
-
154
- If Vision Mapping classified the work as Task but discussion revealed Project-scale complexity, upgrade to multi-milestone and propose the split. If Vision Mapping classified it as Project but the scope narrowed to a single coherent body of work (roughly 2-12 slices), downgrade to single-milestone.
146
+ Before moving to output, confirm the size estimate from your reflection still holds. Discussion often reveals hidden complexity or simplifies things. If the scope grew or shrank significantly during Q&A, adjust the milestone and slice counts accordingly. Be honest — if something you thought was multi-milestone turns out to be 3 slices, plan 3 slices. If something you thought was simple turns out to need multiple milestones, say so.
155
147
 
156
148
  ## Output Phase
157
149
 
@@ -24,11 +24,7 @@ Then:
24
24
  2. Execute the steps in the inlined task plan
25
25
  3. Build the real thing. If the task plan says "create login endpoint", build an endpoint that actually authenticates against a real store, not one that returns a hardcoded success response. If the task plan says "create dashboard page", build a page that renders real data from the API, not a component with hardcoded props. Stubs and mocks are for tests, not for the shipped feature.
26
26
  4. Write or update tests as part of execution — tests are verification, not an afterthought. If the slice plan defines test files in its Verification section and this is the first task, create them (they should initially fail).
27
- 5. When implementing non-trivial runtime behavior, add or preserve agent-usable observability:
28
- - Prefer structured logs/events, stable error codes/types, and explicit status surfaces over ad hoc console text
29
- - Ensure failures are externally inspectable rather than swallowed or hidden
30
- - Persist high-value failure state when it materially improves retries, recovery, or later debugging
31
- - Never log secrets, tokens, or sensitive raw payloads unnecessarily
27
+ 5. When implementing non-trivial runtime behavior (async flows, API boundaries, background processes, error paths), add or preserve agent-usable observability. Skip this for simple changes where it doesn't apply.
32
28
  6. Verify must-haves are met by running concrete checks (tests, commands, observable behaviors)
33
29
  7. Run the slice-level verification checks defined in the slice plan's Verification section. Track which pass. On the final task of the slice, all must pass before marking done. On intermediate tasks, partial passes are expected — note which ones pass in the summary.
34
30
  8. If the task touches UI, browser flows, DOM behavior, or user-visible web state:
@@ -38,7 +34,7 @@ Then:
38
34
  - use `browser_diff` when an action's effect is ambiguous
39
35
  - use console/network/dialog diagnostics when validating async, stateful, or failure-prone UI
40
36
  - record verification in terms of explicit checks passed/failed, not only prose interpretation
41
- 9. If observability or diagnostics were part of this task's scope, verify them directly — e.g. structured errors, status inspection, health endpoints, persisted failure state, browser/network diagnostics, or equivalent.
37
+ 9. If the task plan includes an Observability Impact section, verify those signals directly. Skip this step if the task plan omits the section.
42
38
  10. **If execution is running long or verification fails:**
43
39
 
44
40
  **Context budget:** If you've used most of your context and haven't finished all steps, stop implementing and prioritize writing the task summary with clear notes on what's done and what remains. A partial summary that enables clean resumption is more valuable than one more half-finished step with no documentation. Never sacrifice summary quality for one more implementation step.
@@ -21,3 +21,7 @@ Plan milestone {{milestoneId}} ("{{milestoneTitle}}"). Read `.gsd/DECISIONS.md`
21
21
  - **Don't invent risks.** If the project is straightforward, skip the proof strategy and just ship value in smart order. Not everything has major unknowns.
22
22
  - **Ship features, not proofs.** A completed slice should leave the product in a state where the new capability is actually usable through its real interface. A login flow slice ends with a working login page, not a middleware function. An API slice ends with endpoints that return real data from a real store, not hardcoded fixtures. A dashboard slice ends with a real dashboard rendering real data, not a component that renders mock props. If a slice can't ship the real thing yet because a dependency isn't built, it should ship with realistic stubs that are clearly marked for replacement — but the user-facing surface must be real.
23
23
  - **Ambition matches the milestone.** The number and depth of slices should match the milestone's ambition. A milestone promising "core platform with auth, data model, and primary user loop" should have enough slices to actually deliver all three as working features — not two proof-of-concept slices and a note that "the rest will come in the next milestone." If the milestone's context promises an outcome, the roadmap must deliver it.
24
+
25
+ ## Secret Forecasting
26
+
27
+ After writing the roadmap, analyze the slices and their boundary maps for external service dependencies (third-party APIs, SaaS platforms, cloud providers, databases requiring credentials, OAuth providers, etc.). If this milestone requires any external API keys or secrets, read the template at `~/.gsd/agent/extensions/gsd/templates/secrets-manifest.md` for the expected format and write `{{secretsOutputPath}}` listing every predicted secret as an H3 section with the Service name, a direct Dashboard URL to the console page where the key is created, a Format hint showing what the key looks like, Status set to `pending`, and Destination (`dotenv`, `vercel`, or `convex`). Include numbered step-by-step guidance for obtaining each key. If this milestone does not require any external API keys or secrets, skip this step entirely — do not create an empty manifest.
@@ -12,7 +12,7 @@ Then:
12
12
  1. Read the template at `~/.gsd/agent/extensions/gsd/templates/roadmap.md`
13
13
  2. Read `.gsd/REQUIREMENTS.md` if it exists. Treat **Active** requirements as the capability contract for planning. If it does not exist, continue in legacy compatibility mode but explicitly note that requirement coverage is operating without a contract.
14
14
  3. If a `GSD Skill Preferences` block is present in system context, use it to decide which skills to load and follow during planning, without overriding required roadmap formatting
15
- 4. Create the roadmap: decompose into demoable vertical slices — as many as the work needs, no more
15
+ 4. Create the roadmap: decompose into demoable vertical slices — as many as the work genuinely needs, no more. A simple feature might be 1 slice. Don't decompose for decomposition's sake.
16
16
  5. Order by risk (high-risk first)
17
17
  6. Write `{{outputPath}}` with checkboxes, risk, depends, demo sentences, proof strategy, verification classes, milestone definition of done, **requirement coverage**, and a boundary map. Write success criteria as observable truths, not implementation tasks. If the milestone crosses multiple runtime boundaries, include an explicit final integration slice that proves the assembled system works end-to-end in a real environment
18
18
  7. If planning produced structural decisions (e.g. slice ordering rationale, technology choices, scope exclusions), append them to `.gsd/DECISIONS.md` (read the template at `~/.gsd/agent/extensions/gsd/templates/decisions.md` if the file doesn't exist yet)
@@ -43,6 +43,38 @@ Apply these when decomposing and ordering slices:
43
43
  - **Don't invent risks.** If the project is straightforward, skip the proof strategy and just ship value in smart order. Not everything has major unknowns.
44
44
  - **Ship features, not proofs.** A completed slice should leave the product in a state where the new capability is actually usable through its real interface. A login flow slice ends with a working login page, not a middleware function. An API slice ends with endpoints that return real data from a real store, not hardcoded fixtures. A dashboard slice ends with a real dashboard rendering real data, not a component that renders mock props. If a slice can't ship the real thing yet because a dependency isn't built, it should ship with realistic stubs that are clearly marked for replacement — but the user-facing surface must be real.
45
45
  - **Ambition matches the milestone.** The number and depth of slices should match the milestone's ambition. A milestone promising "core platform with auth, data model, and primary user loop" should have enough slices to actually deliver all three as working features — not two proof-of-concept slices and a note that "the rest will come in the next milestone." If the milestone's context promises an outcome, the roadmap must deliver it.
46
+ - **Right-size the decomposition.** Match slice count to actual complexity. If the work is small enough to build and verify in one pass, it's one slice — don't split it into three just because you can identify sub-steps. Multiple requirements can share a single slice. Conversely, don't cram genuinely independent capabilities into one slice just to keep the count low. Let the work dictate the structure.
47
+
48
+ ## Single-Slice Fast Path
49
+
50
+ If the roadmap has only one slice, also write the slice plan and task plans inline during this unit — don't leave them for a separate planning session.
51
+
52
+ 1. Read the templates:
53
+ - `~/.gsd/agent/extensions/gsd/templates/plan.md`
54
+ - `~/.gsd/agent/extensions/gsd/templates/task-plan.md`
55
+ 2. `mkdir -p {{milestonePath}}/slices/S01/tasks`
56
+ 3. Write the S01 plan file at `{{milestonePath}}/slices/S01/S01-PLAN.md`
57
+ 4. Write individual task plans at `{{milestonePath}}/slices/S01/tasks/T01-PLAN.md`, etc.
58
+ 5. For simple slices, keep the plan lean — omit Proof Level, Integration Closure, and Observability sections if they would all be "none". Executable verification commands are sufficient.
59
+
60
+ This eliminates a separate research-slice + plan-slice cycle when the work is straightforward.
61
+
62
+ ## Secret Forecasting
63
+
64
+ After writing the roadmap, analyze the slices and their boundary maps for external service dependencies (third-party APIs, SaaS platforms, cloud providers, databases requiring credentials, OAuth providers, etc.).
65
+
66
+ If this milestone requires any external API keys or secrets:
67
+
68
+ 1. Read the template at `~/.gsd/agent/extensions/gsd/templates/secrets-manifest.md` for the expected format
69
+ 2. Write `{{secretsOutputPath}}` listing every predicted secret as an H3 section with:
70
+ - **Service** — the external service name
71
+ - **Dashboard** — direct URL to the console/dashboard page where the key is created (not a generic homepage)
72
+ - **Format hint** — what the key looks like (e.g. `sk-...`, `ghp_...`, 40-char hex, UUID)
73
+ - **Status** — always `pending` during planning
74
+ - **Destination** — `dotenv`, `vercel`, or `convex` depending on where the key will be consumed
75
+ - Numbered step-by-step guidance for obtaining the key (navigate to dashboard → create project → generate key → copy)
76
+
77
+ If this milestone does not require any external API keys or secrets, skip this step entirely — do not create an empty manifest.
46
78
 
47
79
  **You MUST write the file `{{outputAbsPath}}` before finishing.**
48
80
 
@@ -12,7 +12,9 @@ Pay particular attention to **Forward Intelligence** sections — they contain h
12
12
 
13
13
  {{dependencySummaries}}
14
14
 
15
- Narrate your decomposition reasoning — why you're grouping work this way, what risks are driving the order, what verification strategy you're choosing and why.
15
+ Narrate your decomposition reasoning — why you're grouping work this way, what risks are driving the order, what verification strategy you're choosing and why. Keep the narration proportional to the work — a simple slice doesn't need a long justification.
16
+
17
+ **Right-size the plan.** If the slice is simple enough to be 1 task, plan 1 task. Don't split into multiple tasks just because you can identify sub-steps. Don't fill in sections with "None" when the section doesn't apply — omit them entirely. The plan's job is to guide execution, not to fill a template.
16
18
 
17
19
  Then:
18
20
  0. If `REQUIREMENTS.md` was preloaded above, identify which Active requirements the roadmap says this slice owns or supports. These are the requirements this plan must deliver — every owned requirement needs at least one task that directly advances it, and verification must prove the requirement is met.
@@ -20,43 +22,33 @@ Then:
20
22
  - `~/.gsd/agent/extensions/gsd/templates/plan.md`
21
23
  - `~/.gsd/agent/extensions/gsd/templates/task-plan.md`
22
24
  2. If a `GSD Skill Preferences` block is present in system context, use it to decide which skills to load and follow during planning, without overriding required plan formatting
23
- 3. Define slice-level verification first — the objective stopping condition for this slice:
24
- - For non-trivial slices: plan actual test files with real assertions. Name the files. The first task creates them (initially failing). Remaining tasks make them pass.
25
+ 3. Define slice-level verification — the objective stopping condition for this slice:
26
+ - For non-trivial slices: plan actual test files with real assertions. Name the files.
25
27
  - For simple slices: executable commands or script assertions are fine.
26
28
  - If the project is non-trivial and has no test framework, the first task should set one up.
27
29
  - If this slice establishes a boundary contract, verification must exercise that contract.
28
- 4. Plan observability and diagnostics explicitly:
29
- - For non-trivial backend, integration, async, stateful, or UI slices, include an `Observability / Diagnostics` section in the slice plan.
30
- - Define how a future agent will inspect state, detect failure, and localize the problem.
31
- - Prefer structured logs/events, stable error codes/types, status surfaces, and persisted failure state over ad hoc debug text.
32
- - Include at least one verification check for a diagnostic or failure-path signal when relevant.
33
- 5. Fill the `Proof Level` and `Integration Closure` sections truthfully:
34
- - State whether the slice proves contract, integration, operational, or final-assembly behavior.
35
- - Say whether real runtime or human/UAT is required.
36
- - Name the wiring introduced in this slice and what still remains before the milestone is truly usable end-to-end.
37
- 6. Decompose the slice into tasks, each fitting one context window
38
- 7. Every task in the slice plan should be written as an executable increment with:
30
+ 4. **For non-trivial slices only** — plan observability, proof level, and integration closure:
31
+ - Include `Observability / Diagnostics` for backend, integration, async, stateful, or UI slices where failure diagnosis matters.
32
+ - Fill `Proof Level` and `Integration Closure` when the slice crosses runtime boundaries or has meaningful integration concerns.
33
+ - **Omit these sections entirely for simple slices** where they would all be "none" or trivially obvious.
34
+ 5. Decompose the slice into tasks, each fitting one context window. Each task needs:
39
35
  - a concrete, action-oriented title
40
36
  - the inline task entry fields defined in the plan.md template (Why / Files / Do / Verify / Done when)
41
- - a matching task plan containing description, steps, must-haves, verification, observability impact, inputs, and expected output
42
- 8. Each task needs: title, description, steps, must-haves, verification, observability impact, inputs, and expected output
43
- 9. If verification includes test files, ensure the first task includes creating them with expected assertions (they should fail initially — that's correct)
44
- 10. Write `{{outputPath}}`
45
- 11. Write individual task plans in `{{sliceAbsPath}}/tasks/`: `T01-PLAN.md`, `T02-PLAN.md`, etc.
46
- 12. **Self-audit the plan before continuing.** Walk through each check — if any fail, fix the plan files before moving on:
47
- - **Completion semantics:** If every task were completed exactly as written, the slice goal/demo should actually be true at the claimed proof level. Do not allow a task plan that only scaffolds toward a future working state.
48
- - **Requirement coverage:** Every must-have in the slice maps to at least one task. No must-have is orphaned.
49
- - **Task completeness:** Every task has steps, must-haves, verification, observability impact, inputs, and expected output — none are blank or vague.
37
+ - a matching task plan file with description, steps, must-haves, verification, inputs, and expected output
38
+ - Observability Impact section **only if the task touches runtime boundaries, async flows, or error paths** omit it otherwise
39
+ 6. Write `{{outputPath}}`
40
+ 7. Write individual task plans in `{{sliceAbsPath}}/tasks/`: `T01-PLAN.md`, `T02-PLAN.md`, etc.
41
+ 8. **Self-audit the plan.** Walk through each check if any fail, fix the plan files before moving on:
42
+ - **Completion semantics:** If every task were completed exactly as written, the slice goal/demo should actually be true.
43
+ - **Requirement coverage:** Every must-have in the slice maps to at least one task. No must-have is orphaned. If `REQUIREMENTS.md` exists, every Active requirement this slice owns maps to at least one task.
44
+ - **Task completeness:** Every task has steps, must-haves, verification, inputs, and expected output none are blank or vague.
50
45
  - **Dependency correctness:** Task ordering is consistent. No task references work from a later task.
51
- - **Key links planned:** For every pair of artifacts that must connect (component → API, API → database, form → handler), there is an explicit step that wires them — not just "create X" and "create Y" in separate tasks with no connection step.
52
- - **Scope sanity:** Target 2–5 steps and 3–8 files per task. 6–8 steps or 8–10 files is a warning — consider splitting. 10+ steps or 12+ files — must split. Each task must be completable in a single fresh context window.
53
- - **Context compliance:** If context/research artifacts or `.gsd/DECISIONS.md` exist, the plan honors locked decisions and doesn't include deferred or out-of-scope items.
54
- - **Requirement coverage:** If `REQUIREMENTS.md` exists, every Active requirement this slice owns (per the roadmap) maps to at least one task with verification that proves the requirement is met. No owned requirement is left without a task. No task claims to satisfy a requirement that is Deferred or Out of Scope.
55
- - **Proof honesty:** The `Proof Level` and `Integration Closure` sections match what this slice will actually prove, and they do not imply live end-to-end completion if only fixture or contract proof is planned.
56
- - **Feature completeness:** Every task produces real, user-facing progress — not just internal scaffolding. If the slice has a UI surface, at least one task builds the real UI (not a placeholder). If the slice has an API, at least one task connects it to a real data source (not hardcoded returns). If every task were completed and you showed the result to a non-technical stakeholder, they should see real product progress, not developer artifacts.
57
- 13. If planning produced structural decisions (e.g. verification strategy, observability strategy, technology choices, patterns to follow), append them to `.gsd/DECISIONS.md`
58
- 14. Commit: `docs({{sliceId}}): add slice plan`
59
- 15. Update `.gsd/STATE.md`
46
+ - **Key links planned:** For every pair of artifacts that must connect, there is an explicit step that wires them.
47
+ - **Scope sanity:** Target 2–5 steps and 3–8 files per task. 10+ steps or 12+ files — must split. Each task must be completable in a single fresh context window.
48
+ - **Feature completeness:** Every task produces real, user-facing progress not just internal scaffolding.
49
+ 9. If planning produced structural decisions, append them to `.gsd/DECISIONS.md`
50
+ 10. Commit: `docs({{sliceId}}): add slice plan`
51
+ 11. Update `.gsd/STATE.md`
60
52
 
61
53
  The slice directory and tasks/ subdirectory already exist. Do NOT mkdir. You are on the slice branch; all work stays here.
62
54
 
@@ -10,6 +10,8 @@
10
10
 
11
11
  ## Proof Level
12
12
 
13
+ <!-- Omit this section entirely for simple slices where the answer is trivially obvious. -->
14
+
13
15
  - This slice proves: {{contract | integration | operational | final-assembly}}
14
16
  - Real runtime required: {{yes/no}}
15
17
  - Human/UAT required: {{yes/no}}
@@ -41,17 +43,11 @@
41
43
 
42
44
  ## Observability / Diagnostics
43
45
 
44
- <!-- Required for non-trivial backend, integration, async, stateful, or UI slices.
45
- Describe how a future agent will inspect current state, detect failure,
46
- and localize the problem with minimal ambiguity.
47
-
48
- Prefer:
49
- - structured logs/events over ad hoc console strings
50
- - stable error codes/types over vague failures
51
- - health/readiness/status surfaces over hidden internal state
52
- - persisted failure state when it materially improves retries or recovery
46
+ <!-- Include this section for non-trivial backend, integration, async, stateful, or UI slices.
47
+ OMIT ENTIRELY for simple slices where all fields would be "none".
53
48
 
54
- Keep this section concise and high-signal. Do not log secrets or sensitive raw payloads. -->
49
+ When included, describe how a future agent will inspect current state, detect failure,
50
+ and localize the problem with minimal ambiguity. Keep it concise and high-signal. -->
55
51
 
56
52
  - Runtime signals: {{structured log/event, state transition, metric, or none}}
57
53
  - Inspection surfaces: {{status endpoint, CLI command, script, UI state, DB table, or none}}
@@ -60,6 +56,8 @@
60
56
 
61
57
  ## Integration Closure
62
58
 
59
+ <!-- Omit this section entirely for simple slices with no meaningful integration concerns. -->
60
+
63
61
  - Upstream surfaces consumed: {{specific files / modules / contracts}}
64
62
  - New wiring introduced in this slice: {{entrypoint / composition / runtime hookup, or none}}
65
63
  - What remains before the milestone is truly usable end-to-end: {{list or "nothing"}}
@@ -0,0 +1,22 @@
1
+ # Secrets Manifest
2
+
3
+ <!-- This file lists predicted API keys and secrets for the milestone.
4
+ Each H3 section defines one secret with setup guidance.
5
+ The parser extracts entries by H3 heading (the env var name).
6
+ Bold fields: Service, Dashboard, Format hint, Status, Destination.
7
+ Guidance is a numbered list under each entry. -->
8
+
9
+ **Milestone:** {{milestone}}
10
+ **Generated:** {{generatedAt}}
11
+
12
+ ### {{ENV_VAR_NAME}}
13
+
14
+ **Service:** {{serviceName}}
15
+ **Dashboard:** {{dashboardUrl}}
16
+ **Format hint:** {{formatHint}}
17
+ **Status:** pending
18
+ **Destination:** dotenv
19
+
20
+ 1. {{Step 1 guidance}}
21
+ 2. {{Step 2 guidance}}
22
+ 3. {{Step 3 guidance}}
@@ -32,13 +32,13 @@ estimated_files: {{estimatedFiles}}
32
32
 
33
33
  ## Observability Impact
34
34
 
35
- <!-- If this task creates or changes a runtime boundary, async flow, API, UI state,
36
- background process, or error path, explain how it improves or depends on
37
- future agent observability. Use "None" when genuinely not applicable. -->
35
+ <!-- OMIT THIS SECTION ENTIRELY for simple tasks that don't touch runtime boundaries,
36
+ async flows, APIs, background processes, or error paths.
37
+ Include it only when the task meaningfully changes how failures are detected or diagnosed. -->
38
38
 
39
- - Signals added/changed: {{structured logs, statuses, errors, metrics, or None}}
40
- - How a future agent inspects this: {{command, endpoint, file, UI state, or None}}
41
- - Failure state exposed: {{what becomes visible on failure, or None}}
39
+ - Signals added/changed: {{structured logs, statuses, errors, metrics}}
40
+ - How a future agent inspects this: {{command, endpoint, file, UI state}}
41
+ - Failure state exposed: {{what becomes visible on failure}}
42
42
 
43
43
  ## Inputs
44
44
 
@@ -7,6 +7,7 @@ import {
7
7
  inferCommitType,
8
8
  GitServiceImpl,
9
9
  RUNTIME_EXCLUSION_PATHS,
10
+ VALID_BRANCH_NAME,
10
11
  runGit,
11
12
  type GitPreferences,
12
13
  type CommitOptions,
@@ -1230,6 +1231,68 @@ async function main(): Promise<void> {
1230
1231
  rmSync(repo, { recursive: true, force: true });
1231
1232
  }
1232
1233
 
1234
+ // ─── VALID_BRANCH_NAME regex ──────────────────────────────────────────
1235
+
1236
+ console.log("\n=== VALID_BRANCH_NAME regex ===");
1237
+
1238
+ {
1239
+ // Valid branch names
1240
+ assert(VALID_BRANCH_NAME.test("main"), "VALID_BRANCH_NAME accepts 'main'");
1241
+ assert(VALID_BRANCH_NAME.test("master"), "VALID_BRANCH_NAME accepts 'master'");
1242
+ assert(VALID_BRANCH_NAME.test("develop"), "VALID_BRANCH_NAME accepts 'develop'");
1243
+ assert(VALID_BRANCH_NAME.test("feature/foo"), "VALID_BRANCH_NAME accepts 'feature/foo'");
1244
+ assert(VALID_BRANCH_NAME.test("release-1.0"), "VALID_BRANCH_NAME accepts 'release-1.0'");
1245
+ assert(VALID_BRANCH_NAME.test("my_branch"), "VALID_BRANCH_NAME accepts 'my_branch'");
1246
+ assert(VALID_BRANCH_NAME.test("v2.0.1"), "VALID_BRANCH_NAME accepts 'v2.0.1'");
1247
+
1248
+ // Invalid / injection attempts
1249
+ assert(!VALID_BRANCH_NAME.test("main; rm -rf /"), "VALID_BRANCH_NAME rejects shell injection");
1250
+ assert(!VALID_BRANCH_NAME.test("main && echo pwned"), "VALID_BRANCH_NAME rejects && injection");
1251
+ assert(!VALID_BRANCH_NAME.test(""), "VALID_BRANCH_NAME rejects empty string");
1252
+ assert(!VALID_BRANCH_NAME.test("branch name"), "VALID_BRANCH_NAME rejects spaces");
1253
+ assert(!VALID_BRANCH_NAME.test("branch`cmd`"), "VALID_BRANCH_NAME rejects backticks");
1254
+ assert(!VALID_BRANCH_NAME.test("branch$(cmd)"), "VALID_BRANCH_NAME rejects $() subshell");
1255
+ }
1256
+
1257
+ // ─── getMainBranch: configured main_branch preference ──────────────────
1258
+
1259
+ console.log("\n=== getMainBranch: configured main_branch ===");
1260
+
1261
+ {
1262
+ const repo = initBranchTestRepo();
1263
+ const svc = new GitServiceImpl(repo, { main_branch: "trunk" });
1264
+
1265
+ assertEq(svc.getMainBranch(), "trunk", "getMainBranch returns configured main_branch preference");
1266
+
1267
+ rmSync(repo, { recursive: true, force: true });
1268
+ }
1269
+
1270
+ // ─── getMainBranch: falls back to auto-detection when not set ──────────
1271
+
1272
+ console.log("\n=== getMainBranch: fallback to auto-detection ===");
1273
+
1274
+ {
1275
+ const repo = initBranchTestRepo();
1276
+ const svc = new GitServiceImpl(repo, {});
1277
+
1278
+ assertEq(svc.getMainBranch(), "main", "getMainBranch falls back to auto-detection when main_branch not set");
1279
+
1280
+ rmSync(repo, { recursive: true, force: true });
1281
+ }
1282
+
1283
+ // ─── getMainBranch: ignores invalid branch names ───────────────────────
1284
+
1285
+ console.log("\n=== getMainBranch: ignores invalid branch name ===");
1286
+
1287
+ {
1288
+ const repo = initBranchTestRepo();
1289
+ const svc = new GitServiceImpl(repo, { main_branch: "main; rm -rf /" });
1290
+
1291
+ assertEq(svc.getMainBranch(), "main", "getMainBranch ignores invalid branch name and falls back to auto-detection");
1292
+
1293
+ rmSync(repo, { recursive: true, force: true });
1294
+ }
1295
+
1233
1296
  // ─── PreMergeCheckResult type export compile check ─────────────────────
1234
1297
 
1235
1298
  console.log("\n=== PreMergeCheckResult type export ===");