volt-framework 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +1 -0
  2. package/dist/bin/cli.d.ts +3 -0
  3. package/dist/bin/cli.d.ts.map +1 -0
  4. package/dist/bin/cli.js +27 -0
  5. package/dist/bin/cli.js.map +1 -0
  6. package/dist/src/installer/copy.d.ts +4 -0
  7. package/dist/src/installer/copy.d.ts.map +1 -0
  8. package/dist/src/installer/copy.js +78 -0
  9. package/dist/src/installer/copy.js.map +1 -0
  10. package/dist/src/installer/index.d.ts +8 -0
  11. package/dist/src/installer/index.d.ts.map +1 -0
  12. package/dist/src/installer/index.js +150 -0
  13. package/dist/src/installer/index.js.map +1 -0
  14. package/dist/src/installer/prompts.d.ts +36 -0
  15. package/dist/src/installer/prompts.d.ts.map +1 -0
  16. package/dist/src/installer/prompts.js +171 -0
  17. package/dist/src/installer/prompts.js.map +1 -0
  18. package/package.json +48 -0
  19. package/src/templates/CLAUDE.md +94 -0
  20. package/src/templates/agent-manifest.csv +8 -0
  21. package/src/templates/commands/architect.md +256 -0
  22. package/src/templates/commands/ask.md +51 -0
  23. package/src/templates/commands/correct-course.md +428 -0
  24. package/src/templates/commands/debug.md +195 -0
  25. package/src/templates/commands/dev/spec-template.md +76 -0
  26. package/src/templates/commands/dev/steps/step-01-clarify-and-route.md +45 -0
  27. package/src/templates/commands/dev/steps/step-02-plan.md +43 -0
  28. package/src/templates/commands/dev/steps/step-03-implement.md +40 -0
  29. package/src/templates/commands/dev/steps/step-04-review.md +45 -0
  30. package/src/templates/commands/dev/steps/step-05-present.md +45 -0
  31. package/src/templates/commands/dev/steps/step-oneshot.md +41 -0
  32. package/src/templates/commands/dev/workflow.md +114 -0
  33. package/src/templates/commands/dev.md +169 -0
  34. package/src/templates/commands/devops.md +253 -0
  35. package/src/templates/commands/help.md +174 -0
  36. package/src/templates/commands/init-context.md +227 -0
  37. package/src/templates/commands/map-brownfield/checklist.md +66 -0
  38. package/src/templates/commands/map-brownfield/steps/step-00-state-check.md +69 -0
  39. package/src/templates/commands/map-brownfield/steps/step-01-classify.md +51 -0
  40. package/src/templates/commands/map-brownfield/steps/step-02-scan.md +126 -0
  41. package/src/templates/commands/map-brownfield/steps/step-03-validate.md +44 -0
  42. package/src/templates/commands/map-brownfield/steps/step-04-generate.md +89 -0
  43. package/src/templates/commands/map-brownfield/steps/step-05-scope.md +50 -0
  44. package/src/templates/commands/map-brownfield/workflow.md +77 -0
  45. package/src/templates/commands/map-brownfield.md +101 -0
  46. package/src/templates/commands/new-task/elicitation.md +216 -0
  47. package/src/templates/commands/new-task/personas/architect.md +50 -0
  48. package/src/templates/commands/new-task/personas/dev.md +48 -0
  49. package/src/templates/commands/new-task/personas/devops.md +42 -0
  50. package/src/templates/commands/new-task/personas/pm.md +41 -0
  51. package/src/templates/commands/new-task/personas/qa.md +47 -0
  52. package/src/templates/commands/new-task/personas/tech-writer.md +39 -0
  53. package/src/templates/commands/new-task/personas/ux.md +41 -0
  54. package/src/templates/commands/new-task/steps/step-01-context.md +88 -0
  55. package/src/templates/commands/new-task/steps/step-02-scope.md +71 -0
  56. package/src/templates/commands/new-task/steps/step-03-roster.md +72 -0
  57. package/src/templates/commands/new-task/steps/step-04-discussion.md +111 -0
  58. package/src/templates/commands/new-task/steps/step-05-elicitation.md +91 -0
  59. package/src/templates/commands/new-task/steps/step-06-questions.md +82 -0
  60. package/src/templates/commands/new-task/steps/step-07-decision.md +93 -0
  61. package/src/templates/commands/new-task/steps/step-08-generate.md +106 -0
  62. package/src/templates/commands/new-task/steps/step-09-azure.md +88 -0
  63. package/src/templates/commands/new-task/workflow.md +185 -0
  64. package/src/templates/commands/new-task.md +84 -0
  65. package/src/templates/commands/pm.md +328 -0
  66. package/src/templates/commands/qa.md +215 -0
  67. package/src/templates/commands/quick-dev.md +118 -0
  68. package/src/templates/commands/quick-spec.md +113 -0
  69. package/src/templates/commands/review/steps/step-01-gather-context.md +66 -0
  70. package/src/templates/commands/review/steps/step-02-adversarial-review.md +74 -0
  71. package/src/templates/commands/review/steps/step-03-triage.md +54 -0
  72. package/src/templates/commands/review/steps/step-04-present.md +75 -0
  73. package/src/templates/commands/review/workflow.md +43 -0
  74. package/src/templates/commands/review.md +82 -0
  75. package/src/templates/commands/standup.md +276 -0
  76. package/src/templates/commands/tech-writer.md +270 -0
  77. package/src/templates/commands/ux.md +241 -0
  78. package/src/templates/docs/architecture.md +149 -0
  79. package/src/templates/docs/brownfield.md +151 -0
  80. package/src/templates/docs/coding-standards.md +124 -0
  81. package/src/templates/docs/source-tree.md +163 -0
  82. package/src/templates/docs/tech-stack.md +123 -0
  83. package/src/templates/registry.csv +19 -0
  84. package/src/templates/templates/EPIC-template.md +65 -0
  85. package/src/templates/templates/TASK-template.md +120 -0
  86. package/src/templates/templates/deferred-work.md +7 -0
@@ -0,0 +1,66 @@
1
+ # Map Brownfield -- Validation Checklist
2
+
3
+ Before marking the workflow as complete, verify every item below.
4
+
5
+ ---
6
+
7
+ ## Scan and Resumability
8
+
9
+ - [ ] State file created at workflow start and updated after each sub-phase
10
+ - [ ] State file contains all required fields per schema
11
+ - [ ] Resumability prompt shown if state file exists and is < 24 hours old
12
+ - [ ] Old state files (> 24 hours) automatically archived
13
+ - [ ] Resume functionality loads previous state correctly and jumps to correct phase
14
+
15
+ ## Write-as-you-go Architecture
16
+
17
+ - [ ] Each document written to disk IMMEDIATELY after generation
18
+ - [ ] Document validation performed right after writing (section-level)
19
+ - [ ] Detailed findings purged from context after writing (only summaries kept)
20
+ - [ ] No accumulation of full project analysis in memory
21
+
22
+ ## Project Detection and Classification
23
+
24
+ - [ ] Project type correctly identified and matches actual technology stack
25
+ - [ ] Multi-part vs single-part structure accurately detected
26
+ - [ ] Conditional documents correctly flagged (API contracts, data models)
27
+
28
+ ## Pattern Validation
29
+
30
+ - [ ] All conflicts presented to user with evidence and percentages
31
+ - [ ] User decisions recorded for every conflict
32
+ - [ ] Non-conflicting patterns confirmed by user
33
+ - [ ] No patterns remain as "uncertain" after Phase 3
34
+
35
+ ## Document Quality
36
+
37
+ - [ ] All documents saved to `.kc1t/docs/`
38
+ - [ ] Each document has generation header with date and version
39
+ - [ ] No generic placeholders or TODO items remain
40
+ - [ ] Mermaid diagrams included where applicable
41
+ - [ ] File paths and references are correct
42
+ - [ ] Terminology consistent across all documents
43
+
44
+ ## Brownfield Context Specific
45
+
46
+ - [ ] "What NOT to change" section is comprehensive and user-validated
47
+ - [ ] User was explicitly asked about untouchable areas
48
+ - [ ] Tech debt prioritized by severity
49
+ - [ ] Scope classification included
50
+
51
+ ## File Completeness
52
+
53
+ - [ ] Architecture generated
54
+ - [ ] Source Tree generated
55
+ - [ ] Coding Standards generated
56
+ - [ ] Brownfield Context generated and user-validated
57
+ - [ ] `api-contracts.md` generated (if APIs detected)
58
+ - [ ] `data-models.md` generated (if database detected)
59
+ - [ ] `deep-dive-{area}.md` generated (if deep-dive mode used)
60
+
61
+ ## Brownfield PRD Readiness
62
+
63
+ - [ ] Documentation provides enough context for AI to understand existing system
64
+ - [ ] Reusable components identified for leveraging in new work
65
+ - [ ] Architecture constraints clear for informed decision-making
66
+ - [ ] Code conventions captured for consistency in future tasks
@@ -0,0 +1,69 @@
1
+ # Step 00: State Check & Mode Router
2
+
3
+ ## RULES
4
+
5
+ - You are a state machine router -- determine workflow mode and delegate to the correct phase.
6
+ - HALT at every user prompt and wait for their response before proceeding.
7
+ - Never auto-proceed without user confirmation when no CLI argument is provided.
8
+ - Never overwrite an existing state file without archiving it first.
9
+ - Every state file mutation must record: phase id, sub-phase id, human-readable summary, timestamp, and outputs written.
10
+
11
+ ## INSTRUCTIONS
12
+
13
+ 1. **Check for existing state.** Look for `.kc1t/scan-state.json` in the project root.
14
+ - If it does not exist, set `resume_mode = false` and go to step 3.
15
+
16
+ 2. **Route based on state.** Read the file and extract `lastUpdatedAt`, `mode`, `currentPhase`, `currentSubPhase`, `completedPhases`, `classification`, `status`.
17
+
18
+ **If age >= 24 hours:** Archive to `.kc1t/.archive/scan-state-{timestamp}.json`. Inform the user the old state was archived. Set `resume_mode = false`, go to step 3.
19
+
20
+ **If status == "completed":** Present options:
21
+ - `[1]` Incremental rescan -- update only what changed
22
+ - `[2]` Deep-dive -- exhaustive analysis of a specific area
23
+ - `[3]` Start over from scratch (archives old state)
24
+ - `[4]` Cancel -- keep existing documentation
25
+
26
+ HALT. On 1: set `mode = "rescan"`, continue to step 01. On 2: set `mode = "deep-dive"`, jump to step 02 deep-dive section. On 3: archive and go to step 3. On 4: exit.
27
+
28
+ **If status == "in-progress":** Present options:
29
+ - `[1]` Resume from Phase {currentPhase}, sub-phase {currentSubPhase}
30
+ - `[2]` Start over from scratch (archives old state)
31
+ - `[3]` Cancel
32
+
33
+ HALT. On 1: load findings summaries and cached classification, jump to recorded phase/sub-phase. On 2: archive and go to step 3. On 3: exit.
34
+
35
+ 3. **Mode selection (fresh starts).** If mode was passed as CLI argument (`initial`, `rescan`, `deep-dive`), use it directly. Otherwise present:
36
+ - `[1]` Initial scan -- full scan from scratch (recommended for first time)
37
+ - `[2]` Deep-dive -- exhaustive analysis of a specific module/area
38
+
39
+ HALT. On 1: set `mode = "initial"`. On 2: set `mode = "deep-dive"`, jump to step 02 deep-dive section.
40
+
41
+ 4. **Initialize state file.** Create `.kc1t/` if missing. Write `.kc1t/scan-state.json`:
42
+ ```json
43
+ {
44
+ "version": "1.0",
45
+ "projectName": "",
46
+ "startedAt": "{timestamp}",
47
+ "lastUpdatedAt": "{timestamp}",
48
+ "currentPhase": 1,
49
+ "currentSubPhase": "1.0",
50
+ "completedPhases": [],
51
+ "mode": "{mode}",
52
+ "status": "in-progress",
53
+ "classification": {},
54
+ "conditionalDocs": { "apiContracts": false, "dataModels": false },
55
+ "modulesScanned": [],
56
+ "modulesRemaining": [],
57
+ "conflicts": [],
58
+ "userDecisions": [],
59
+ "scopeClassification": "",
60
+ "documentsGenerated": [],
61
+ "scanMetrics": { "totalFiles": 0, "totalModules": 0, "estimatedLines": 0, "externalDependencies": 0 }
62
+ }
63
+ ```
64
+
65
+ If the user wants to discuss or go deeper on any point, shift to interactive mode. Otherwise, proceed.
66
+
67
+ ## NEXT
68
+
69
+ Read fully and follow `./step-01-classify.md`.
@@ -0,0 +1,51 @@
1
+ # Step 01: Project Classification
2
+
3
+ ## RULES
4
+
5
+ - Detect every manifest, config, and infrastructure file to build an accurate classification.
6
+ - Present classification to the user for confirmation before proceeding -- never assume correctness.
7
+ - If evidence is insufficient for a dimension, mark it as "unknown" and ask the user. Never guess.
8
+ - Always check for multi-part structures, even for seemingly simple projects.
9
+ - Save classification to state only after user confirmation.
10
+
11
+ ## INSTRUCTIONS
12
+
13
+ 1. **Detect project manifests.** Search root and up to 2 levels deep for:
14
+ - Package manifests: `package.json`, `composer.json`, `pyproject.toml`, `Cargo.toml`, `go.mod`, `pom.xml`, `build.gradle`, `Gemfile`, `*.csproj`, `setup.py`
15
+ - Language configs: `tsconfig.json`, `jsconfig.json`, `.python-version`, `rust-toolchain.toml`, `.nvmrc`
16
+ - Infrastructure: `Dockerfile`, `docker-compose.yml`, `.env.example`, `terraform/`, `serverless.yml`
17
+ - Framework configs: `next.config.*`, `nuxt.config.*`, `angular.json`, `vite.config.*`, `nest-cli.json`, `remix.config.*`, `astro.config.*`, `svelte.config.*`
18
+ - CI/CD: `.github/workflows/`, `.gitlab-ci.yml`, `Jenkinsfile`, `.circleci/`, `azure-pipelines.yml`
19
+ - Linter/formatter: `.eslintrc*`, `.prettierrc*`, `biome.json`, `.editorconfig`, `ruff.toml`, `.golangci.yml`
20
+
21
+ For each detected file, extract key fields (dependencies, scripts, compiler options).
22
+
23
+ 2. **Classify across 8 dimensions.** For each dimension, record the evidence source (which file and field):
24
+
25
+ | Dimension | Examples |
26
+ |---|---|
27
+ | Type | frontend, backend, fullstack, monorepo, library, CLI, worker, mobile |
28
+ | Language | TypeScript, JavaScript, Python, Go, Rust, Java, C#, PHP, Ruby |
29
+ | Framework | Next.js, NestJS, Express, FastAPI, Django, Rails, Spring, Laravel |
30
+ | Package Manager | npm, yarn, pnpm, bun, pip, poetry, cargo, go modules, maven |
31
+ | Database | PostgreSQL, MySQL, MongoDB, Redis, SQLite, DynamoDB |
32
+ | ORM | Prisma, TypeORM, Drizzle, SQLAlchemy, GORM, ActiveRecord |
33
+ | Tests | Jest, Vitest, Pytest, Go test, JUnit, RSpec, Cypress, Playwright |
34
+ | Infrastructure | Docker, Kubernetes, Serverless, Vercel, AWS, GCP, Azure |
35
+
36
+ 3. **Detect multi-part structure.** Determine if the project is monolith, monorepo, or multi-part (e.g. `client/` + `server/`). If multiple parts are detected, list them with paths and ask the user to confirm. HALT. If single project, set `repository_type = "monolith"`.
37
+
38
+ 4. **Set conditional document flags.**
39
+ - HTTP endpoints detected (routes, controllers, API handlers) -> `conditionalDocs.apiContracts = true`
40
+ - Database detected (ORM config, migrations, schema files) -> `conditionalDocs.dataModels = true`
41
+
42
+ 5. **Present and confirm.** Show classification in a compact table with evidence. Ask: `Is this classification correct? [y/n/edit]`. HALT.
43
+ - y: proceed. n: ask what is wrong, correct, re-present. edit: ask which dimension to change.
44
+
45
+ 6. **Save state.** Update `scan-state.json` with classification, conditionalDocs, completedPhases entry, set `currentPhase = 2`, `currentSubPhase = "2.1"`. Purge detailed scan data from memory -- keep only the summary string.
46
+
47
+ If the user wants to discuss or go deeper on any point, shift to interactive mode. Otherwise, proceed.
48
+
49
+ ## NEXT
50
+
51
+ Read fully and follow `./step-02-scan.md`.
@@ -0,0 +1,126 @@
1
+ # Step 02: Scan Execution
2
+
3
+ ## RULES
4
+
5
+ - Complete every sub-scan (2.1 through 2.7) unless its precondition is not met.
6
+ - Update state after every sub-scan with `currentSubPhase`, timestamp, and a precise summary.
7
+ - After each sub-scan: write findings, then purge detailed data from context -- keep only 1-2 sentence summaries.
8
+ - Respect mode depth: initial reads excerpts, rescan reads diffs only, deep-dive reads everything (no sampling).
9
+ - In deep-dive mode, halt after each module batch for user review before continuing.
10
+ - Exclude from all scans: `node_modules/`, `.git/`, `dist/`, `build/`, `coverage/`, `*.min.js`, `*.map`.
11
+
12
+ ## INSTRUCTIONS
13
+
14
+ **Mode behavior:**
15
+ - **Initial**: Read relevant excerpts (imports, exports, signatures). Do not read entire files.
16
+ - **Rescan**: Execute only for modified modules (via `git diff` or timestamps). Skip unchanged.
17
+ - **Deep-dive**: Every file read in full. No sampling, no guessing. Organize batches by subfolder: read files, extract info, write output, validate, purge context, move on.
18
+
19
+ ### 2.1 -- Structure Scan
20
+
21
+ 1. Generate directory tree (3 levels in initial/rescan, unlimited in deep-dive).
22
+ 2. Classify organizational pattern: feature-based, layer-based, domain-driven, mixed.
23
+ 3. Identify ambiguous directories (empty, single-file, overlapping purpose).
24
+ 4. Map special directories: config, scripts, migrations, seeds, assets, public, tests.
25
+
26
+ Inform user: "Sub-scan 2.1 (Structure) complete." Update state.
27
+
28
+ ### 2.2 -- Module & Responsibility Scan
29
+
30
+ 1. List each module/feature with its inferred purpose (1 sentence).
31
+ 2. Map inter-module dependencies (who imports whom).
32
+ 3. Detect circular dependencies.
33
+ 4. Calculate fan-in / fan-out for each module.
34
+ 5. In deep-dive: list all public exports and their consumers.
35
+
36
+ Inform user: "Sub-scan 2.2 (Modules) complete." Update state.
37
+
38
+ ### 2.3 -- Code Pattern Scan
39
+
40
+ 1. **Naming**: Convention by context (files, variables, functions, classes, constants). Adherence % and exceptions.
41
+ 2. **File structure**: Internal organization pattern (import order, types, constants, functions, export).
42
+ 3. **Functions**: Average size in lines. Functions exceeding 50 lines (list file + name).
43
+ 4. **Error handling**: Categorize (try/catch, error boundaries, Result pattern, custom errors). Percentage of each.
44
+ 5. **Logging**: console.log vs custom logger vs external service. Structured vs unstructured.
45
+ 6. **Validation**: Zod, Joi, class-validator, manual. Where in the call chain.
46
+ 7. **Imports**: Absolute vs relative. Barrel exports. Path aliases.
47
+
48
+ In deep-dive: 3+ concrete examples with file path and snippet for each pattern. Flag conflicts for step 03.
49
+
50
+ Inform user: "Sub-scan 2.3 (Patterns) complete." Update state.
51
+
52
+ ### 2.4 -- API & Contract Scan (Conditional)
53
+
54
+ Skip if `conditionalDocs.apiContracts == false`. Inform user and move on.
55
+
56
+ 1. List endpoints: HTTP method, path, handler location.
57
+ 2. Classify route organization (by resource, feature, version).
58
+ 3. Identify middleware chain (auth, validation, logging, rate limiting, CORS).
59
+ 4. Detect response pattern (envelope, status codes, error format).
60
+ 5. Check for existing docs (Swagger/OpenAPI, GraphQL schema).
61
+ 6. In deep-dive: document request/response body for each main endpoint.
62
+
63
+ Inform user: "Sub-scan 2.4 (APIs) complete." Update state.
64
+
65
+ ### 2.5 -- Data Model Scan (Conditional)
66
+
67
+ Skip if `conditionalDocs.dataModels == false`. Inform user and move on.
68
+
69
+ 1. List entities/models with fields and types.
70
+ 2. Map relationships (1:1, 1:N, N:N).
71
+ 3. Identify migration and seed patterns.
72
+ 4. Classify data access pattern (repository, active record, service layer, raw queries).
73
+ 5. In deep-dive: document indexes, constraints, triggers, defaults.
74
+
75
+ Inform user: "Sub-scan 2.5 (Data Models) complete." Update state.
76
+
77
+ ### 2.6 -- Tech Debt Scan
78
+
79
+ 1. Search for `TODO`, `FIXME`, `HACK`, `XXX`, `WORKAROUND` comments with locations.
80
+ 2. Identify commented-out code blocks (>5 lines).
81
+ 3. List functions >50 lines and files >300 lines.
82
+ 4. Check for outdated or deprecated dependencies.
83
+ 5. Identify areas without test coverage.
84
+ 6. Detect code smells: god objects, feature envy, shotgun surgery, long parameter lists.
85
+ 7. Classify each finding by severity: high (operational risk), medium (maintainability), low (cosmetic).
86
+
87
+ Inform user: "Sub-scan 2.6 (Tech Debt) complete." Update state.
88
+
89
+ ### 2.7 -- Dependency Analysis
90
+
91
+ 1. Separate production vs development dependencies.
92
+ 2. Identify known vulnerabilities (via audit if possible).
93
+ 3. Detect abandoned dependencies (>2 years without update).
94
+ 4. Identify functional duplications (libraries doing the same thing).
95
+ 5. Estimate bundle weight for frontend projects.
96
+ 6. List critical dependencies (used in >50% of modules).
97
+
98
+ Inform user: "Sub-scan 2.7 (Dependencies) complete. Phase 2 complete." Update state.
99
+
100
+ ### Deep-Dive Module Pause
101
+
102
+ In deep-dive mode, after each module/subfolder batch present:
103
+ - `[1]` View details before continuing
104
+ - `[2]` Continue to next module
105
+ - `[3]` Mark as sensitive area (goes to "What NOT to change" in brownfield.md)
106
+
107
+ HALT and wait before proceeding.
108
+
109
+ ### Deep-Dive Area Analysis
110
+
111
+ When `mode = "deep-dive"`, this replaces standard sub-scans:
112
+
113
+ 1. **Select target area.** Present detected modules with file counts. Accept folder path, file path, or feature name. HALT for confirmation.
114
+ 2. **Exhaustive scan.** Read every line. Document: purpose, exports, imports, dependents, side effects, error handling, test coverage, TODOs, per-file risks.
115
+ 3. **Relationship analysis.** Build dependency graph, trace data flow, identify integration points.
116
+ 4. **Related code discovery.** Search outside scanned area for similar patterns and reusable utilities.
117
+ 5. **Generate document.** Write to `.kc1t/docs/deep-dive-{target_name}.md`.
118
+ 6. **Continue or complete.** `[1]` Deep-dive another area, `[2]` Continue to step 03. HALT.
119
+
120
+ Mark Phase 2 complete. Update `completedPhases`, set `currentPhase = 3`.
121
+
122
+ If the user wants to discuss or go deeper on any point, shift to interactive mode. Otherwise, proceed.
123
+
124
+ ## NEXT
125
+
126
+ Read fully and follow `./step-03-validate.md`.
@@ -0,0 +1,44 @@
1
+ # Step 03: Pattern Conflict Validation
2
+
3
+ ## RULES
4
+
5
+ - No pattern may remain as "uncertain" or "conflicting" after this step completes.
6
+ - Never resolve a conflict on the user's behalf -- every conflict requires an explicit user decision.
7
+ - Present at least 2 concrete code examples (file path + snippet) per competing pattern in a conflict.
8
+ - Record every user decision with category, question, decision, rationale, and timestamp.
9
+ - Do not proceed to step 04 until all conflicts are resolved and all patterns are confirmed.
10
+
11
+ ## INSTRUCTIONS
12
+
13
+ 1. **Present structured pattern summary.** Group all detected patterns by category (naming, error handling, file organization, validation, logging, imports) with adherence percentages and evidence. Mark conflicts clearly.
14
+
15
+ Present options:
16
+ - `[1]` Confirm all non-conflicting patterns (proceed to conflict resolution only)
17
+ - `[2]` Review one by one
18
+ - `[3]` Add a pattern manually
19
+
20
+ HALT and wait.
21
+
22
+ 2. **Resolve conflicts.** For each conflict, present it in isolation with full evidence:
23
+ - Show Pattern A and Pattern B with percentages and 2-3 concrete code examples each (file path + snippet).
24
+ - Ask which is the official pattern:
25
+ - `[A]` Pattern A is the standard
26
+ - `[B]` Pattern B is the standard
27
+ - `[C]` Both are accepted (document when to use each)
28
+ - `[D]` Neither -- specify a different approach
29
+
30
+ HALT after each conflict. Record the decision:
31
+ ```json
32
+ { "category": "...", "question": "...", "decision": "...", "rationale": "...", "decidedAt": "..." }
33
+ ```
34
+
35
+ 3. **Confirm final pattern list.** Present the complete confirmed pattern list. Ask: `Is this correct, or does anything need adjustment? [y/n/edit]`. HALT.
36
+ - y: proceed. n/edit: ask which pattern to adjust, record correction.
37
+
38
+ 4. **Save state.** Update `scan-state.json`: store `conflicts` array, `userDecisions` array, add completedPhases entry with summary, set `currentPhase = 4`, `currentSubPhase = "4.1"`.
39
+
40
+ If the user wants to discuss or go deeper on any point, shift to interactive mode. Otherwise, proceed.
41
+
42
+ ## NEXT
43
+
44
+ Read fully and follow `./step-04-generate.md`.
@@ -0,0 +1,89 @@
1
+ # Step 04: Document Generation
2
+
3
+ ## RULES
4
+
5
+ - Write each document to disk immediately after generation. Do not accumulate all documents in memory.
6
+ - After writing each document: validate structure, update state, purge detailed findings from context.
7
+ - Include the header `<!-- Generated by map-brownfield | Date: {date} | Version: {version} -->` in every document.
8
+ - The brownfield.md user review is mandatory -- never skip it.
9
+ - Conditional documents (api-contracts, data-models) are only generated when their flag is true.
10
+
11
+ ## INSTRUCTIONS
12
+
13
+ Generate up to 6 documents (4 mandatory + 2 conditional) into `.kc1t/docs/`. After each, ask: `Review now or continue? [review/continue]`. HALT.
14
+
15
+ ### 4.1 -- `architecture.md`
16
+
17
+ Generate:
18
+ - High-level architecture pattern (MVC, Clean, Hexagonal, Layered, Event-Driven, etc.)
19
+ - Module relationship diagram (Mermaid `graph TD` or `flowchart LR`) -- at least one diagram required
20
+ - Main data flow (request lifecycle)
21
+ - Detected architectural decisions (implicit ADRs)
22
+ - Entry points (HTTP server, CLI, workers, cron)
23
+ - External service integrations (APIs, databases, queues, caches)
24
+ - Deployment architecture from config files
25
+
26
+ Write to `.kc1t/docs/architecture.md`. Validate. Update state. Purge.
27
+
28
+ ### 4.2 -- `source-tree.md`
29
+
30
+ Generate:
31
+ - Complete directory tree with purpose annotation per directory
32
+ - Key files highlighted and described (entry points, config, main modules)
33
+ - Organization convention explained
34
+ - Entry points marked, integration paths noted for multi-part projects
35
+
36
+ Write to `.kc1t/docs/source-tree.md`. Validate. Update state. Purge.
37
+
38
+ ### 4.3 -- `coding-standards.md`
39
+
40
+ Generate with concrete codebase examples for every pattern:
41
+ - Naming conventions with file paths and snippets
42
+ - File structure patterns (import order, types, export style)
43
+ - Error handling approach (including Phase 3 conflict resolutions)
44
+ - Logging, validation, testing patterns
45
+ - Import/export conventions
46
+ - All user decisions from Phase 3 with rationale
47
+
48
+ Write to `.kc1t/docs/coding-standards.md`. Validate. Update state. Purge.
49
+
50
+ ### 4.4 -- `brownfield.md` (Main Document)
51
+
52
+ This is the most important document -- primary reference for all future development.
53
+
54
+ Structure:
55
+ - **Executive summary** (3-5 lines): what the project is, its state, its health
56
+ - **Classification and Scope**: Phase 1 table + Phase 5 scope metrics
57
+ - **Current state**: overall health (good / acceptable / concerning) with justification
58
+ - **"What NOT to change"**: established patterns, explicit user decisions, sensitive areas, protected dependencies
59
+ - **"What to improve"**: tech debt by severity (high/medium/low) with estimated effort
60
+ - **"Known risks"**: problematic dependencies, fragile areas, security concerns, missing tests
61
+ - **"Suggested next steps"**: prioritized by impact vs effort
62
+
63
+ Write to `.kc1t/docs/brownfield.md`. Validate. Update state. Purge.
64
+
65
+ Present the full draft. Ask: **"Please review brownfield.md carefully. Is there anything in this project you consider untouchable? Anything that should NOT be refactored, even if it looks like tech debt?"** HALT. Incorporate the answer into "What NOT to change" and rewrite.
66
+
67
+ ### 4.5 -- `api-contracts.md` (Conditional)
68
+
69
+ Skip if `conditionalDocs.apiContracts == false`. Log skip reason in state.
70
+
71
+ Generate: endpoints (method, path, handler, description), request/response patterns, auth requirements, middleware chain, versioning, error format.
72
+
73
+ Write to `.kc1t/docs/api-contracts.md`. Validate. Update state. Purge.
74
+
75
+ ### 4.6 -- `data-models.md` (Conditional)
76
+
77
+ Skip if `conditionalDocs.dataModels == false`. Log skip reason in state.
78
+
79
+ Generate: entities with fields/types/constraints, relationships (list + Mermaid ER diagram), migration patterns, indexes, data access pattern.
80
+
81
+ Write to `.kc1t/docs/data-models.md`. Validate. Update state. Purge.
82
+
83
+ Mark Phase 4 complete. Update `documentsGenerated` in state.
84
+
85
+ If the user wants to discuss or go deeper on any point, shift to interactive mode. Otherwise, proceed.
86
+
87
+ ## NEXT
88
+
89
+ Read fully and follow `./step-05-scope.md`.
@@ -0,0 +1,50 @@
1
+ # Step 05: Scope Classification and Completion
2
+
3
+ ## RULES
4
+
5
+ - Classify project size from actual metrics in the state file -- never estimate from memory.
6
+ - Do not declare the workflow complete without running the validation checklist.
7
+ - The final "untouchable areas" prompt is a safety net -- never skip it.
8
+ - Save scope classification to both state file and brownfield.md.
9
+
10
+ ## INSTRUCTIONS
11
+
12
+ 1. **Classify project size.** Read metrics from `scan-state.json`:
13
+
14
+ | Classification | Files | Modules | Typical Team |
15
+ |---|---|---|---|
16
+ | Small | < 50 | < 5 | 1 developer |
17
+ | Medium | 50-200 | 5-15 | 2-5 developers |
18
+ | Large | 200-1000 | 15-50 | 5-15 developers |
19
+ | Very Large | > 1000 | > 50 | Multiple teams |
20
+
21
+ Record: total code files, total modules, estimated LOC, external dependency count (production).
22
+
23
+ 2. **Save scope.** Update `scan-state.json` with `scopeClassification` and `scanMetrics`. Update `brownfield.md` "Classification and Scope" section with metrics table.
24
+
25
+ 3. **Present future workflow guidance** tailored to scope:
26
+ - **Small**: Bug fix -> /quick-dev. New feature -> /new-task (lean mode).
27
+ - **Medium**: Bug fix -> /quick-dev. Small feature (1-3 tasks) -> /new-task lean. Larger -> /new-task full + QA.
28
+ - **Large / Very Large**: Bug fix -> /quick-dev with brownfield context. Any feature -> /new-task full + QA. Cross-module -> mandatory architecture review.
29
+
30
+ Recommend running `/map-brownfield rescan` after significant changes.
31
+
32
+ 4. **Final untouchable areas prompt.** Ask: **"Is there anything in this project you consider untouchable? Anything that should NOT be refactored, even if it looks like tech debt?"** HALT.
33
+ - If items provided: incorporate into brownfield.md "What NOT to change" and rewrite.
34
+ - If nothing to add: acknowledge and proceed.
35
+
36
+ 5. **Mark scan complete.** Update state: `status = "completed"`, `lastUpdatedAt`, add completedPhases entry.
37
+
38
+ 6. **Run validation checklist.** Read and execute `../checklist.md`. Verify every item. If any fail, report which and offer to fix. Do not declare complete until all pass.
39
+
40
+ Present final summary: list all generated documents with paths, scan status, and classification.
41
+
42
+ If the user wants to discuss or go deeper on any point, shift to interactive mode. Otherwise, proceed.
43
+
44
+ ## NEXT
45
+
46
+ This is the final step. The documentation in `.kc1t/docs/` is now available for all future workflow commands.
47
+
48
+ ## Handoff Protocol
49
+
50
+ Recommend: `/new-task` (greenfield) or `/init-context` (if docs incomplete) in fresh chat. Fresh context avoids anchoring bias from this session.
@@ -0,0 +1,77 @@
1
+ # Map Brownfield -- Workflow
2
+
3
+ ## Execution Modes
4
+
5
+ | Invocation | Behavior |
6
+ |---|---|
7
+ | `/map-brownfield` | Ask the user which mode to run |
8
+ | `/map-brownfield initial` | Full scan from scratch |
9
+ | `/map-brownfield rescan` | Update only what changed since last scan |
10
+ | `/map-brownfield deep-dive` | Exhaustive module-by-module analysis (full file reads, no sampling) |
11
+
12
+ ## Step Processing Rules
13
+
14
+ - Read the entire step before acting.
15
+ - Execute sections in order. No skipping.
16
+ - Halt at checkpoints and wait for the user.
17
+ - Only load the next step when directed.
18
+
19
+ ## Initialization
20
+
21
+ 1. Check for `.kc1t/` directory. Create if missing.
22
+ 2. Check for `.kc1t/docs/` directory. Create if missing.
23
+ 3. Load `.kc1t/config.yaml` if it exists. Extract: `project_name`, `language`, `user_name`.
24
+ 4. Set `date` as current datetime.
25
+ 5. Proceed to Step 00.
26
+
27
+ ## Step Sequence
28
+
29
+ | Step | File | Description |
30
+ |------|------|-------------|
31
+ | 00 | `./steps/step-00-state-check.md` | State check and mode router |
32
+ | 01 | `./steps/step-01-classify.md` | Project classification |
33
+ | 02 | `./steps/step-02-scan.md` | Scan execution (initial, rescan, deep-dive) |
34
+ | 03 | `./steps/step-03-validate.md` | Pattern conflict validation |
35
+ | 04 | `./steps/step-04-generate.md` | Document generation |
36
+ | 05 | `./steps/step-05-scope.md` | Scope classification and completion |
37
+
38
+ ## Interaction Flow
39
+
40
+ 1. Greet the user. Briefly explain the command's purpose.
41
+ 2. **Step 00**: Check state, offer resume if applicable, select mode.
42
+ 3. **Step 01**: Classify project, request confirmation.
43
+ 4. **Step 02**: Execute sub-scans, inform progress at each. (Or deep-dive: exhaustive area analysis.)
44
+ 5. **Step 03**: Present patterns, resolve conflicts one by one.
45
+ 6. **Step 04**: Generate documents, offer review. Present brownfield.md for validation.
46
+ 7. **Step 05**: Classify scope, present metrics, final untouchable-areas prompt.
47
+ 8. Mark scan complete.
48
+
49
+ ## Special Project Handling
50
+
51
+ **Monorepos**: Map each package individually. Map inter-package dependencies. Generate per-package docs + consolidated overview.
52
+
53
+ **No framework**: Focus on custom structure. Identify homegrown patterns that act as an internal framework. Document conventions with extra care.
54
+
55
+ **Multi-language**: Map each language separately. Identify integration points (FFI, API calls, shared schemas, protobuf). Document which language owns which responsibility.
56
+
57
+ ## State Management
58
+
59
+ File: `.kc1t/scan-state.json`. After each sub-phase, update `lastUpdatedAt`, `currentPhase`, `currentSubPhase`, and relevant arrays. This guarantees granular resume. See step-00 for the full schema.
60
+
61
+ ## Document Output Format
62
+
63
+ - Valid Markdown with hierarchical headings.
64
+ - Code blocks with language specified. Mermaid diagrams when applicable.
65
+ - Header: `<!-- Generated by map-brownfield | Date: {date} | Version: {version} -->`
66
+ - No generic placeholders or TODO items in final output.
67
+ - Terminology consistent across all documents. File paths verified.
68
+
69
+ ## Implementation Notes
70
+
71
+ - Read priority: configs > entrypoints > services/controllers > models > utils > tests.
72
+ - Initial/rescan: read relevant excerpts. Deep-dive: read every file in full.
73
+ - Write-as-you-go: write each document immediately, validate, purge detailed findings.
74
+ - Large projects: process in module batches, save progress frequently.
75
+ - Weight patterns by frequency. A single isolated file does not define a pattern.
76
+
77
+ After completing all steps, run the validation checklist: `./checklist.md`