@quinteroac/agents-coding-toolkit 0.1.0-preview

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 (85) hide show
  1. package/AGENTS.md +7 -0
  2. package/README.md +127 -0
  3. package/package.json +34 -0
  4. package/scaffold/.agents/flow/archived/tmpl_.gitkeep +0 -0
  5. package/scaffold/.agents/flow/tmpl_README.md +7 -0
  6. package/scaffold/.agents/flow/tmpl_iteration_close_checklist.example.md +11 -0
  7. package/scaffold/.agents/skills/automated-fix/tmpl_SKILL.md +67 -0
  8. package/scaffold/.agents/skills/create-issue/tmpl_SKILL.md +68 -0
  9. package/scaffold/.agents/skills/create-pr-document/tmpl_SKILL.md +125 -0
  10. package/scaffold/.agents/skills/create-project-context/tmpl_SKILL.md +168 -0
  11. package/scaffold/.agents/skills/create-test-plan/tmpl_SKILL.md +86 -0
  12. package/scaffold/.agents/skills/debug/tmpl_SKILL.md +19 -0
  13. package/scaffold/.agents/skills/evaluate/tmpl_SKILL.md +19 -0
  14. package/scaffold/.agents/skills/execute-test-batch/tmpl_SKILL.md +49 -0
  15. package/scaffold/.agents/skills/execute-test-case/tmpl_SKILL.md +47 -0
  16. package/scaffold/.agents/skills/implement-user-story/tmpl_SKILL.md +68 -0
  17. package/scaffold/.agents/skills/plan-refactor/tmpl_SKILL.md +19 -0
  18. package/scaffold/.agents/skills/refactor-prd/tmpl_SKILL.md +19 -0
  19. package/scaffold/.agents/skills/refine-pr-document/tmpl_SKILL.md +108 -0
  20. package/scaffold/.agents/skills/refine-project-context/tmpl_SKILL.md +157 -0
  21. package/scaffold/.agents/skills/refine-test-plan/tmpl_SKILL.md +76 -0
  22. package/scaffold/.agents/tmpl_PROJECT_CONTEXT.md +3 -0
  23. package/scaffold/.agents/tmpl_state.example.json +26 -0
  24. package/scaffold/.agents/tmpl_state_rules.md +29 -0
  25. package/scaffold/docs/nvst-flow/templates/tmpl_CHANGELOG.md +18 -0
  26. package/scaffold/docs/nvst-flow/templates/tmpl_TECHNICAL_DEBT.md +11 -0
  27. package/scaffold/docs/nvst-flow/templates/tmpl_it_000001_evaluation-report.md +19 -0
  28. package/scaffold/docs/nvst-flow/templates/tmpl_it_000001_product-requirement-document.md +19 -0
  29. package/scaffold/docs/nvst-flow/templates/tmpl_it_000001_refactor_plan.md +19 -0
  30. package/scaffold/docs/nvst-flow/templates/tmpl_it_000001_test-plan.md +19 -0
  31. package/scaffold/docs/nvst-flow/tmpl_COMMANDS.md +0 -0
  32. package/scaffold/docs/nvst-flow/tmpl_QUICK_USE.md +0 -0
  33. package/scaffold/docs/tmpl_PLACEHOLDER.md +0 -0
  34. package/scaffold/schemas/node-shims.d.ts +15 -0
  35. package/scaffold/schemas/tmpl_issues.ts +19 -0
  36. package/scaffold/schemas/tmpl_prd.ts +26 -0
  37. package/scaffold/schemas/tmpl_progress.ts +39 -0
  38. package/scaffold/schemas/tmpl_state.ts +81 -0
  39. package/scaffold/schemas/tmpl_test-plan.ts +20 -0
  40. package/scaffold/schemas/tmpl_validate-progress.ts +13 -0
  41. package/scaffold/schemas/tmpl_validate-state.ts +13 -0
  42. package/scaffold/tmpl_AGENTS.md +7 -0
  43. package/schemas/prd.ts +26 -0
  44. package/schemas/progress.ts +39 -0
  45. package/schemas/state.ts +81 -0
  46. package/schemas/test-plan.test.ts +53 -0
  47. package/schemas/test-plan.ts +20 -0
  48. package/schemas/validate-progress.ts +13 -0
  49. package/schemas/validate-state.ts +13 -0
  50. package/src/agent.test.ts +37 -0
  51. package/src/agent.ts +225 -0
  52. package/src/cli-path.ts +4 -0
  53. package/src/cli.ts +578 -0
  54. package/src/commands/approve-project-context.ts +37 -0
  55. package/src/commands/approve-requirement.ts +217 -0
  56. package/src/commands/approve-test-plan.test.ts +193 -0
  57. package/src/commands/approve-test-plan.ts +202 -0
  58. package/src/commands/create-issue.test.ts +484 -0
  59. package/src/commands/create-issue.ts +371 -0
  60. package/src/commands/create-project-context.ts +96 -0
  61. package/src/commands/create-prototype.test.ts +153 -0
  62. package/src/commands/create-prototype.ts +425 -0
  63. package/src/commands/create-test-plan.test.ts +381 -0
  64. package/src/commands/create-test-plan.ts +248 -0
  65. package/src/commands/define-requirement.ts +47 -0
  66. package/src/commands/destroy.ts +113 -0
  67. package/src/commands/execute-automated-fix.test.ts +580 -0
  68. package/src/commands/execute-automated-fix.ts +363 -0
  69. package/src/commands/execute-manual-fix.test.ts +343 -0
  70. package/src/commands/execute-manual-fix.ts +203 -0
  71. package/src/commands/execute-test-plan.test.ts +1891 -0
  72. package/src/commands/execute-test-plan.ts +722 -0
  73. package/src/commands/init.ts +85 -0
  74. package/src/commands/refine-project-context.ts +74 -0
  75. package/src/commands/refine-requirement.ts +60 -0
  76. package/src/commands/refine-test-plan.test.ts +200 -0
  77. package/src/commands/refine-test-plan.ts +93 -0
  78. package/src/commands/start-iteration.test.ts +144 -0
  79. package/src/commands/start-iteration.ts +101 -0
  80. package/src/commands/write-json.ts +136 -0
  81. package/src/install.test.ts +124 -0
  82. package/src/pack.test.ts +103 -0
  83. package/src/state.test.ts +66 -0
  84. package/src/state.ts +52 -0
  85. package/tsconfig.json +15 -0
package/AGENTS.md ADDED
@@ -0,0 +1,7 @@
1
+ # Agents entry point
2
+
3
+ - **What this project is:** (Describe the product or project. This file is the single entry point for the agent.)
4
+ - **How to work here:** Use this file as the single entry point. Follow the process phases in order; read and update `.agents/state.json` for the current iteration and phase. Invoke the skills under `.agents/skills/` as indicated by each command. All iteration artifacts live in `.agents/flow/` with the naming `it_` + 6-digit iteration (e.g. `it_000001_product-requirement-document.md`). From the second iteration onward, adhere to `.agents/PROJECT_CONTEXT.md`.
5
+ - **Process:** Define → Prototype → Refactor (see package or usage documentation).
6
+ - **Project context:** `.agents/PROJECT_CONTEXT.md` (conventions and architecture; agent adheres from second iteration onward).
7
+ - **Rule:** All generated resources in this repo must be in English.
package/README.md ADDED
@@ -0,0 +1,127 @@
1
+ # Nerds Vibecoding Survivor Toolkit
2
+
3
+ > 🚧 **Work in Progress**: This toolkit is currently under active development.
4
+
5
+ ## Purpose
6
+
7
+ This repository contains nerds-vst (Nerd's Vibecoding Survivor Toolkit).
8
+
9
+ nerds-vst is a framework and command-line tool built on Bun, designed to help you create and develop projects from scratch using a specification-driven development pattern powered by AI coding—a process informally known as vibecoding. This repository is the toolkit implementation; usage and workflow documentation will be published with the package.
10
+
11
+ The framework is built on the following principles:
12
+
13
+ - Single source of truth — State is centralized, minimizing the risk of AI hallucination and reducing ambiguity.
14
+ - Context is everything — Leveraging diverse project context and specialized skills helps both AI and humans to better understand and reason about the project.
15
+ - Human in the loop — Mandatory review and decision points ensure that humans define and validate key steps in every iteration.
16
+ - Build fast / Fail fast — Developers can grant AI a controlled degree of autonomy to enable rapid prototyping, embodying the agile principle of building quickly and embracing early failure.
17
+ - Iterative development — Strongly encourages building software incrementally, block by block, allowing time to refactor and address technical debt during each iteration instead of all at once.
18
+ - Agnostic agent support — Whether you prefer Claude, Codex, Gemini, or another CLI-based agent, the toolkit is designed to easily integrate with most agent providers and lets you choose or combine the tools that best fit your workflow.
19
+
20
+
21
+ ## Features
22
+
23
+ nerds-vst is a package that provides:
24
+
25
+ - **Scaffold tool** — Running `bun nvst init` copies the template from this repo’s `scaffold/` directory into the target project, creating the following structure:
26
+
27
+ ```
28
+ AGENTS.md
29
+ iteration_close_checklist.md
30
+ ralph_loop.md
31
+ providers.md
32
+ .agents/
33
+ PROJECT_CONTEXT.md
34
+ state.json
35
+ state_rules.md
36
+ scripts/
37
+ ralph.ts
38
+ skills/
39
+ create-pr-document/SKILL.md
40
+ refine-pr-document/SKILL.md
41
+ create-project-context/SKILL.md
42
+ refine-project-context/SKILL.md
43
+ create-test-plan/SKILL.md
44
+ refine-test-plan/SKILL.md
45
+ implement-user-story/SKILL.md
46
+ create-issue/SKILL.md
47
+ execute-test-case/SKILL.md
48
+ execute-test-batch/SKILL.md
49
+ evaluate/SKILL.md
50
+ plan-refactor/SKILL.md
51
+ refactor-prd/SKILL.md
52
+ debug/SKILL.md
53
+ flow/
54
+ README.md
55
+ archived/
56
+ docs/templates/
57
+ CHANGELOG.md
58
+ TECHNICAL_DEBT.md
59
+ schemas/
60
+ state.ts
61
+ progress.ts
62
+ validate-state.ts
63
+ validate-progress.ts
64
+ ```
65
+
66
+ Template files in this repository live under [`scaffold/`](scaffold/) with a `tmpl_` prefix (e.g. `tmpl_AGENTS.md`, `tmpl_ralph_loop.md`); `bun nvst init` copies them into the target project and writes them without the prefix to avoid naming conflicts when the toolkit is integrated elsewhere.
67
+
68
+ - **Command-line tool** — Sends instructions to your chosen agent provider (Claude, Codex, Gemini, etc.) so it follows the framework. Commands drive the Define → Prototype → Refactor flow and keep state in sync, giving you a single way to run the process regardless of which agent you use.
69
+
70
+ **Command summary** (see [process_design.md](process_design.md) for full details):
71
+
72
+ | Phase | Commands |
73
+ |-------|----------|
74
+ | **Iteration** | `bun nvst start iteration` — Start or advance to the next iteration (archives current, resets state). |
75
+ | **Define** | `bun nvst define requirement` → `bun nvst refine requirement` (optional) → `bun nvst approve requirement` → `bun nvst create prd` |
76
+ | **Prototype** | `bun nvst create project-context` → `bun nvst approve project-context` → `bun nvst create prototype` → `bun nvst define test-plan` → `bun nvst approve test-plan` → `bun nvst execute test-plan` → `bun nvst execute automated-fix` / `bun nvst execute manual-fix` → `bun nvst approve prototype` |
77
+ | **Refactor** | `bun nvst define refactor-plan` → `bun nvst approve refactor-plan` → `bun nvst create prd --refactor` → `bun nvst execute refactor` → update PROJECT_CONTEXT, CHANGELOG → then `bun nvst start iteration` for next iteration |
78
+
79
+
80
+ ## Installation
81
+
82
+ **Prerequisites:** [Bun](https://bun.sh/) v1 or later must be installed.
83
+
84
+ You can install the toolkit from the local file system or from a registry (when published).
85
+
86
+ ### From local file system
87
+
88
+ Install from a local directory or a packed tarball:
89
+
90
+ ```bash
91
+ # From project root
92
+ bun add /path/to/nerds-vibecoding-survivor-toolkit
93
+
94
+ # Or from a packed .tgz (run `bun run package` first)
95
+ bun add ./quinteroac-agents-coding-toolkit-0.1.0.tgz
96
+ ```
97
+
98
+ ### From npm
99
+
100
+ When the package is published to npm:
101
+
102
+ ```bash
103
+ bun add @quinteroac/agents-coding-toolkit
104
+ # or
105
+ npm install @quinteroac/agents-coding-toolkit
106
+ ```
107
+
108
+ ### Verify installation
109
+
110
+ After installation, the `nvst` command should be available:
111
+
112
+ ```bash
113
+ # Check that the command works
114
+ nvst --help
115
+
116
+ # Verify installed version matches the package
117
+ nvst --version
118
+ ```
119
+
120
+ ## Acknowledgement
121
+
122
+ Acknowledgements and credits will be added after the initial release.
123
+
124
+ ## References
125
+
126
+ - [process_design.md](process_design.md) — Full process specification.
127
+ - [scaffold/.agents/flow/tmpl_README.md](scaffold/.agents/flow/tmpl_README.md) — Flow directory and naming conventions (scaffold template).
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@quinteroac/agents-coding-toolkit",
3
+ "publishConfig": {
4
+ "registry": "https://registry.npmjs.org",
5
+ "access": "public"
6
+ },
7
+ "version": "0.1.0-preview",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/quinteroac/nerds-vibecoding-survivor-toolkit.git"
11
+ },
12
+ "bin": { "nvst": "src/cli.ts" },
13
+ "files": [
14
+ "src",
15
+ "scaffold",
16
+ "schemas",
17
+ "AGENTS.md",
18
+ "README.md",
19
+ "tsconfig.json"
20
+ ],
21
+ "scripts": {
22
+ "package": "npm pack",
23
+ "validate:state": "bun run scaffold/schemas/tmpl_validate-state.ts",
24
+ "validate:progress": "bun run scaffold/schemas/tmpl_validate-progress.ts"
25
+ },
26
+ "dependencies": {
27
+ "zod": "^3.23.8"
28
+ },
29
+ "devDependencies": {
30
+ "@types/bun": "^1.3.9",
31
+ "@types/node": "^25.3.0",
32
+ "typescript": "^5.6.3"
33
+ }
34
+ }
File without changes
@@ -0,0 +1,7 @@
1
+ # Flow directory (scaffold)
2
+
3
+ <!-- TODO: Complete. All content in English. -->
4
+
5
+ - **What lives here:** TBD — Iteration artifacts `it_<6 digits>_*` (e.g. product-requirement-document.md, PRD.json, progress.json, test-plan.md, evaluation-report.md, refactor_plan.md).
6
+ - **Naming:** Prefix `it_` + 6-digit iteration number (e.g. `it_000001_`, `it_000042_`). No spaces.
7
+ - **What gets archived:** When starting the next iteration, current iteration files move to `.agents/flow/archived/<iteration>/` (e.g. `archived/000001/`).
@@ -0,0 +1,11 @@
1
+ # Iteration close checklist (scaffold)
2
+
3
+ <!-- TODO: Complete. All content in English. Use when closing an iteration (before running start next iteration / archive). -->
4
+
5
+ - [ ] **prototype_approved** — Prototype has been approved (`phases.prototype.prototype_approved === true`).
6
+ - [ ] **Full tests** — Tests for all use cases of the iteration (original + refactor/regression) have been run and pass (or documented exceptions).
7
+ - [ ] **PROJECT_CONTEXT.md** — Updated with newly implemented features; summary mechanism applied so file does not exceed 250 lines.
8
+ - [ ] **CHANGELOG.md** — Iteration summary recorded (requirements, refactorings, fixes).
9
+ - [ ] **Archive** — Ready to run “start iteration” (move `it_<iteration>_*` to `.agents/flow/archived/<iteration>/`, update state.history, reset phase for next iteration).
10
+
11
+ TBD — Add any project-specific items.
@@ -0,0 +1,67 @@
1
+ ---
2
+ name: automated-fix
3
+ description: "Fixes one issue from the iteration issues list by reproducing, diagnosing, and resolving it. Invoked by: bun nvst fix issue."
4
+ user-invocable: false
5
+ ---
6
+
7
+ # Automated Fix
8
+
9
+ Attempt to resolve the provided issue safely and deterministically by following a structured debugging workflow.
10
+
11
+ ---
12
+
13
+ ## Inputs
14
+
15
+ | Source | Used for |
16
+ |--------|----------|
17
+ | `issue` (context variable) | The issue to fix, including id, title, description, and reproduction steps |
18
+ | `project_context` (context variable) | Project conventions, tech stack, code standards, testing strategy, and architecture |
19
+ | `iteration` (context variable) | Current iteration number for file naming and context |
20
+
21
+ ---
22
+
23
+ ## The Job
24
+
25
+ Follow this debugging workflow in order:
26
+
27
+ 1. Understand the issue — read the description and any reproduction steps carefully.
28
+ 2. Reproduce the issue — confirm it is observable before making any changes.
29
+ 3. Form hypotheses — identify possible root causes based on the observed behaviour.
30
+ 4. Identify affected code — locate the files and functions involved.
31
+ 5. Add instrumentation if needed — add temporary logging or assertions to narrow down the cause.
32
+ 6. Collect logs — run the code and capture output if instrumentation was added.
33
+ 7. Confirm or discard hypotheses — use evidence to settle on the root cause.
34
+ 8. Fix the issue — apply the minimal change that resolves the root cause.
35
+ 9. Verify the fix — attempt to reproduce the original issue and confirm it no longer occurs.
36
+ 10. Remove instrumentation — clean up any temporary logging or assertions added in step 5.
37
+
38
+ ---
39
+
40
+ ## Rules
41
+
42
+ - **Minimal scope.** Keep changes scoped to the provided issue — do not refactor unrelated code.
43
+ - **Add or update tests.** Write or update tests to cover the fix when appropriate.
44
+ - **Do not commit.** The calling command handles git commits.
45
+ - **Stop on uncertainty.** If no hypothesis can be confirmed after reasonable effort, stop and report failure rather than guessing.
46
+ - **Follow conventions exactly.** Use the naming, formatting, error handling, and module organisation patterns from the project context.
47
+
48
+ ---
49
+
50
+ ## Output
51
+
52
+ The output is the set of file changes (modified or new files) in the working tree. There is no document to produce — the corrected code and any updated tests are the deliverable.
53
+
54
+ ---
55
+
56
+ ## Checklist
57
+
58
+ Before finishing:
59
+
60
+ - [ ] Issue was reproduced before any changes were made
61
+ - [ ] Root cause was identified and confirmed
62
+ - [ ] Fix is minimal and scoped to the provided issue
63
+ - [ ] Issue can no longer be reproduced after the fix
64
+ - [ ] Instrumentation has been removed
65
+ - [ ] Tests were added or updated where appropriate
66
+ - [ ] Code follows project conventions (naming, style, error handling)
67
+ - [ ] No git commits were made
@@ -0,0 +1,68 @@
1
+ ---
2
+ name: create-issue
3
+ description: "Interactively defines one or more issues with the user. Triggered by: bun nvst create issue --agent <provider>."
4
+ user-invocable: true
5
+ ---
6
+
7
+ # Create Issue
8
+
9
+ Define one or more issues interactively with the user and write them to the output file using `write-json`.
10
+
11
+ **Important:** Do NOT fix the issues. Just gather information and produce the output file.
12
+
13
+ ---
14
+
15
+ ## The Job
16
+
17
+ 1. Ask the user what issue(s) they want to create. Gather a `title` and `description` for each issue.
18
+ 2. Ask clarifying questions one at a time until you have enough detail.
19
+ 3. Run the `write-json` command to write the issues file (see Output section).
20
+
21
+ ---
22
+
23
+ ## Questions Flow
24
+
25
+ **CRITICAL: Ask ONE question at a time. Wait for the user's answer before asking the next question.**
26
+
27
+ 1. Describe the issue — what is the problem or task?
28
+ 2. Is there additional context (error messages, affected files, reproduction steps)?
29
+ 3. Are there more issues to add? If yes, repeat questions 1–2.
30
+
31
+ ---
32
+
33
+ ## Output
34
+
35
+ When you have collected all issues, write the file by running:
36
+
37
+ ```bash
38
+ bun run src/cli.ts write-json --schema issues --out .agents/flow/it_{iteration}_ISSUES.json --data '<json>'
39
+ ```
40
+
41
+ Replace `{iteration}` with the value from Context (e.g. `000009`). The JSON must be a valid array where each element has:
42
+
43
+ - `id`: `ISSUE-{iteration}-001`, `ISSUE-{iteration}-002`, etc. (sequential, zero-padded)
44
+ - `title`: concise summary (one sentence)
45
+ - `description`: detailed explanation including context, reproduction steps, or expected behaviour
46
+ - `status`: always `"open"`
47
+
48
+ Example:
49
+
50
+ ```json
51
+ [
52
+ {"id": "ISSUE-000009-001", "title": "Short issue title", "description": "Detailed description.", "status": "open"},
53
+ {"id": "ISSUE-000009-002", "title": "Another issue", "description": "More details.", "status": "open"}
54
+ ]
55
+ ```
56
+
57
+ **You must run the write-json command.** Do not output JSON to stdout alone. The calling system expects the file to exist.
58
+
59
+ ---
60
+
61
+ ## Checklist
62
+
63
+ Before running write-json:
64
+
65
+ - [ ] Each issue has a clear, specific `title`
66
+ - [ ] Each issue has a detailed `description`
67
+ - [ ] Each issue has correct `id` (ISSUE-{iteration}-NNN) and `status` ("open")
68
+ - [ ] Write the file via `bun run src/cli.ts write-json ...`
@@ -0,0 +1,125 @@
1
+ ---
2
+ name: create-pr-document
3
+ description: "Gathers the requirement from the user and produces it_{iteration}_product-requirement-document.md. Triggered by: bun nvst define requirement."
4
+ user-invocable: true
5
+ ---
6
+
7
+ # Create Product Requirement Document
8
+
9
+ Produce `it_{current_iteration}_product-requirement-document.md` in `.agents/flow/` by interviewing the user about the feature or change they want to build.
10
+
11
+ **Important:** Do NOT start implementing. Just gather the requirement and write the document.
12
+
13
+ ---
14
+
15
+ ## The Job
16
+
17
+ 1. **Understand the project first.** Read `AGENTS.md`, `.agents/PROJECT_CONTEXT.md`, and explore the codebase structure (main entry points, conventions, existing features) before starting the interview. This context will make your questions more relevant and the PRD better aligned with the project.
18
+ 2. Read `state.json` to get `current_iteration` (6-digit string, e.g. `"000001"`).
19
+ 3. Ask 3–5 clarifying questions (see Questions Flow).
20
+ 4. Generate the document following the Output Structure.
21
+ 5. Write to `.agents/flow/it_{current_iteration}_product-requirement-document.md`.
22
+ 6. Update `state.json`: `requirement_definition.status` = `"in_progress"`, `requirement_definition.file` = filename.
23
+
24
+ ---
25
+
26
+ ## Questions Flow
27
+
28
+ **CRITICAL: Ask ONE question at a time. Wait for the user's answer before asking the next question. Do NOT present all questions at once.**
29
+
30
+ Ask only questions where the initial prompt is ambiguous. Present lettered options so the user can reply with short codes (e.g. "1A").
31
+
32
+ Questions to ask (one by one, in order):
33
+
34
+ 1. What problem does this solve or goal does it achieve?
35
+ - A. [inferred option]
36
+ - B. [inferred option]
37
+ - C. Other: [please specify]
38
+
39
+ *(Wait for answer, then ask question 2)*
40
+
41
+ 2. Who is the primary user or actor?
42
+ - A. End user / customer
43
+ - B. Internal operator / admin
44
+ - C. Another system or automated process
45
+ - D. Other: [specify]
46
+
47
+ *(Wait for answer, then ask question 3)*
48
+
49
+ 3. MVP scope — what is the minimum set of use cases needed to validate the idea?
50
+ List only the user stories you consider strictly necessary.
51
+ *(e.g. "UC-1: user can log in, UC-2: user can view dashboard")*
52
+
53
+ *(Wait for answer, then ask question 4)*
54
+
55
+ 4. Are there hard constraints (deadline, platform, dependencies)?
56
+ *(Skip if the user says none)*
57
+
58
+ *(Wait for answer, then ask question 5)*
59
+
60
+ 5. What does "done" look like? How will we know it works?
61
+ *(Describe acceptance criteria or how you'd verify success)*
62
+
63
+ *(Wait for answer, then generate the document)*
64
+
65
+ ---
66
+
67
+ ## Output Structure
68
+
69
+ ```markdown
70
+ # Requirement: [Feature or Change Name]
71
+
72
+ ## Context
73
+ Brief description of the problem or opportunity this addresses.
74
+
75
+ ## Goals
76
+ - [Specific, measurable objective]
77
+ - …
78
+
79
+ ## User Stories
80
+ Each story must be small enough to implement in one focused session.
81
+
82
+ ### US-001: [Title]
83
+ **As a** [actor], **I want** [capability] **so that** [benefit].
84
+
85
+ **Acceptance Criteria:**
86
+ - [ ] [Specific, verifiable criterion — not vague]
87
+ - [ ] [Another criterion]
88
+ - [ ] Typecheck / lint passes
89
+ - [ ] **[UI stories only]** Visually verified in browser
90
+
91
+ ### US-002: …
92
+
93
+ ## Functional Requirements
94
+ - FR-1: …
95
+ - FR-2: …
96
+
97
+ ## Non-Goals (Out of Scope)
98
+ - …
99
+
100
+ ## Open Questions
101
+ - …
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Writing Guidelines
107
+
108
+ - **MVP first:** include only the user stories from the answer to question 3. If the user did not list explicit stories, propose the smallest set possible and confirm before writing. Do not pad scope.
109
+ - Be explicit and unambiguous — the reader may be a junior developer or an AI agent.
110
+ - Acceptance criteria must be verifiable: "button shows confirmation dialog before deleting" ✓ — "works correctly" ✗.
111
+ - Every story with a UI change must include browser verification as an acceptance criterion.
112
+ - Number requirements (`FR-N`) for easy cross-reference with `it_{iteration}_PRD.json`.
113
+
114
+ ---
115
+
116
+ ## Checklist
117
+
118
+ Before saving:
119
+
120
+ - [ ] Clarifying questions asked and answered
121
+ - [ ] Each user story has verifiable acceptance criteria
122
+ - [ ] Functional requirements are numbered and unambiguous
123
+ - [ ] Non-goals define clear scope boundaries
124
+ - [ ] File written to `.agents/flow/it_{current_iteration}_product-requirement-document.md`
125
+ - [ ] `state.json` → `requirement_definition.status` = `"in_progress"`, `requirement_definition.file` set
@@ -0,0 +1,168 @@
1
+ ---
2
+ name: create-project-context
3
+ description: "Creates or updates .agents/PROJECT_CONTEXT.md with project conventions, tech stack, code standards, testing strategy, and product architecture. Triggered by: bun nvst create project-context."
4
+ user-invocable: true
5
+ ---
6
+
7
+ # Create / Update Project Context
8
+
9
+ Create or update `.agents/PROJECT_CONTEXT.md` so the agent has a single, stable reference for conventions and architecture across all iterations.
10
+
11
+ ---
12
+
13
+ ## The Job
14
+
15
+ 1. Check whether `.agents/PROJECT_CONTEXT.md` already exists.
16
+ - **First iteration (file absent or empty):** run the Questions flow below.
17
+ - **Subsequent iterations (file present):** ask the user what to add or change; skip questions for sections already covered. In `--mode yolo` skip all questions and infer from the codebase and the current iteration's PRD.
18
+ 2. Produce or update the document following the Output Structure.
19
+ 3. Enforce the **250-line cap** (see Cap Rule).
20
+ 4. Write the result to `.agents/PROJECT_CONTEXT.md`.
21
+
22
+ ---
23
+
24
+ ## Inputs
25
+
26
+ | Source | Used for |
27
+ |--------|----------|
28
+ | `it_{iteration}_product-requirement-document.md` | Understanding product goals and implied stack/conventions |
29
+ | `it_{iteration}_PRD.json` | Use cases and scope of the current iteration |
30
+ | `.agents/PROJECT_CONTEXT.md` (if present) | Existing content to preserve or update |
31
+ | User answers (interactive mode) | Filling in sections that cannot be inferred |
32
+
33
+ ---
34
+
35
+ ## Questions Flow (first iteration or missing sections)
36
+
37
+ Ask only about sections that cannot be confidently inferred from the PRD and codebase. Present lettered options where applicable so the user can reply with short codes (e.g. "1A, 2B").
38
+
39
+ ```
40
+ 1. Primary language(s) and runtime?
41
+ A. TypeScript / Node.js
42
+ B. Python
43
+ C. Go
44
+ D. Rust
45
+ E. TypeScript (frontend) + Python (backend)
46
+ F. TypeScript (frontend) + Go (backend)
47
+ G. TypeScript (frontend) + Rust (backend)
48
+ H. Other: [specify]
49
+
50
+ 2. Main framework(s)?
51
+ A. Next.js
52
+ B. React + Vite
53
+ C. FastAPI / Flask
54
+ D. Gin / Echo / Fiber (Go)
55
+ E. Actix-web / Axum (Rust)
56
+ F. Other: [specify]
57
+
58
+ 3. Package manager?
59
+ A. bun
60
+ B. npm
61
+ C. pnpm
62
+ D. yarn
63
+
64
+ 4. Test approach?
65
+ A. TDD — tests first, then code
66
+ B. Code first, tests after
67
+ C. Tests only for critical paths
68
+
69
+ 5. Test runner?
70
+ A. Vitest
71
+ B. Jest
72
+ C. Pytest
73
+ D. Go built-in (`go test`)
74
+ E. Rust built-in (`cargo test`)
75
+ F. Other: [specify]
76
+
77
+ 6. Git flow?
78
+ A. Feature branches per iteration (feature/it_XXXXXX)
79
+ B. Trunk-based (commits directly to main)
80
+ C. Other: [specify]
81
+
82
+ 7. Style / formatting conventions?
83
+ A. Prettier + ESLint defaults
84
+ B. Project-specific config (already committed)
85
+ C. `gofmt` / `goimports` (Go — enforced by default)
86
+ D. `rustfmt` (Rust — enforced by default)
87
+ E. No enforced formatting
88
+
89
+ 8. Any hard constraints (monorepo, deployment target, env restrictions)?
90
+ [Open answer — skip if none]
91
+ ```
92
+
93
+ ---
94
+
95
+ ## Output Structure
96
+
97
+ Write `.agents/PROJECT_CONTEXT.md` using only the sections relevant to the project. Include all sections that have content; omit those that are genuinely not applicable.
98
+
99
+ ```markdown
100
+ # Project Context
101
+
102
+ <!-- Created or updated by `bun nvst create project-context`. Cap: 250 lines. -->
103
+
104
+ ## Conventions
105
+ - Naming: [files, variables, components]
106
+ - Formatting: [tool + config]
107
+ - Git flow: [branching strategy, commit convention]
108
+ - Workflow: [any process agreement]
109
+
110
+ ## Tech Stack
111
+ - Language(s): …
112
+ - Runtime: …
113
+ - Frameworks: …
114
+ - Key libraries: …
115
+ - Package manager: …
116
+ - Build / tooling: …
117
+
118
+ ## Code Standards
119
+ - Style patterns: …
120
+ - Error handling: …
121
+ - Module organisation: …
122
+ - Forbidden patterns (if any): …
123
+
124
+ ## Testing Strategy
125
+ - Approach: [TDD | code-first | critical-paths only]
126
+ - Runner: …
127
+ - Coverage targets (if any): …
128
+ - Test location convention: …
129
+
130
+ ## Product Architecture
131
+ - High-level diagram or description: …
132
+ - Main components / layers: …
133
+ - Data flow summary: …
134
+
135
+ ## Modular Structure
136
+ - [package or module]: [responsibility]
137
+ - …
138
+
139
+ ## Implemented Capabilities
140
+ <!-- Updated at the end of each iteration by bun nvst create project-context -->
141
+ - (none yet — populated after first Refactor)
142
+ ```
143
+
144
+ ---
145
+
146
+ ## Cap Rule (250 lines)
147
+
148
+ Before writing the file, count projected line count.
149
+
150
+ - If ≤ 250 lines → write as-is.
151
+ - If > 250 lines → apply the summary mechanism **before** appending new content:
152
+ 1. Condense the **Implemented Capabilities** section: group earlier iterations into a "Summary of previous iterations" block; keep full detail only for the last 1–2 iterations.
153
+ 2. Shorten any section that has grown beyond 10 lines by merging or removing redundant entries.
154
+ 3. If still over 250, move low-priority detail (e.g. full feature lists from old iterations) to `.agents/PROJECT_CONTEXT_archive.md` and replace with a one-line reference.
155
+ - Re-count after summarisation; write only when ≤ 250 lines.
156
+
157
+ ---
158
+
159
+ ## Checklist
160
+
161
+ Before saving the file:
162
+
163
+ - [ ] All sections answered or explicitly marked N/A
164
+ - [ ] Conventions are specific (not "follow best practices")
165
+ - [ ] Tech stack lists exact versions where relevant
166
+ - [ ] Testing strategy matches what the PRD implies
167
+ - [ ] File does not exceed 250 lines
168
+ - [ ] `state.json` → `project_context.status` set to `"pending_approval"` and `project_context.file` set to `".agents/PROJECT_CONTEXT.md"` after writing