jdi-cli 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 (159) hide show
  1. package/AGENTS.md +209 -0
  2. package/ARCHITECTURE.md +210 -0
  3. package/COMMANDS.md +241 -0
  4. package/CREATE-EXAMPLE.md +385 -0
  5. package/CREATE.md +315 -0
  6. package/EXTENSION.md +141 -0
  7. package/LICENSE +21 -0
  8. package/MEMORY.md +471 -0
  9. package/PORTABILITY.md +438 -0
  10. package/README.md +789 -0
  11. package/bin/git-hooks/post-commit +16 -0
  12. package/bin/git-hooks/pre-commit +21 -0
  13. package/bin/jdi-build.ps1 +381 -0
  14. package/bin/jdi-build.sh +332 -0
  15. package/bin/jdi-doctor.ps1 +403 -0
  16. package/bin/jdi-doctor.sh +400 -0
  17. package/bin/jdi-install-caveman.ps1 +97 -0
  18. package/bin/jdi-install-caveman.sh +99 -0
  19. package/bin/jdi-install-playwright.ps1 +319 -0
  20. package/bin/jdi-install-playwright.sh +284 -0
  21. package/bin/jdi-install.ps1 +154 -0
  22. package/bin/jdi-install.sh +132 -0
  23. package/bin/jdi-uninstall.ps1 +309 -0
  24. package/bin/jdi-uninstall.sh +264 -0
  25. package/bin/jdi-update.ps1 +215 -0
  26. package/bin/jdi-update.sh +209 -0
  27. package/bin/jdi.js +460 -0
  28. package/bin/lib/jdi-monitor.ps1 +66 -0
  29. package/bin/lib/jdi-monitor.sh +74 -0
  30. package/bin/lib/jdi-truncate.ps1 +96 -0
  31. package/bin/lib/jdi-truncate.sh +99 -0
  32. package/bin/lib/ui.js +197 -0
  33. package/core/agents/jdi-adopter.md +465 -0
  34. package/core/agents/jdi-architect.md +894 -0
  35. package/core/agents/jdi-asker.md +153 -0
  36. package/core/agents/jdi-bootstrap.md +247 -0
  37. package/core/agents/jdi-planner.md +254 -0
  38. package/core/agents/jdi-researcher.md +303 -0
  39. package/core/commands/jdi-adopt.md +155 -0
  40. package/core/commands/jdi-bootstrap.md +81 -0
  41. package/core/commands/jdi-create.md +80 -0
  42. package/core/commands/jdi-discuss.md +80 -0
  43. package/core/commands/jdi-do.md +200 -0
  44. package/core/commands/jdi-loop.md +315 -0
  45. package/core/commands/jdi-new.md +131 -0
  46. package/core/commands/jdi-plan.md +73 -0
  47. package/core/commands/jdi-ship.md +146 -0
  48. package/core/commands/jdi-verify.md +159 -0
  49. package/core/skills/clean-code/SKILL.md +261 -0
  50. package/core/skills/dry/SKILL.md +150 -0
  51. package/core/skills/frontend-rules/SKILL.md +386 -0
  52. package/core/skills/frontend-validator/SKILL.md +567 -0
  53. package/core/skills/kiss/SKILL.md +178 -0
  54. package/core/skills/solid/SKILL.md +281 -0
  55. package/core/skills/yagni/SKILL.md +207 -0
  56. package/core/templates/agent.md +72 -0
  57. package/core/templates/doer-specialist.md +216 -0
  58. package/core/templates/reviewer-specialist.md +405 -0
  59. package/core/templates/skill.md +66 -0
  60. package/package.json +70 -0
  61. package/runtimes/antigravity/agents.md +74 -0
  62. package/runtimes/antigravity/skills/clean-code/SKILL.md +252 -0
  63. package/runtimes/antigravity/skills/dry/SKILL.md +141 -0
  64. package/runtimes/antigravity/skills/frontend-rules/SKILL.md +376 -0
  65. package/runtimes/antigravity/skills/frontend-validator/SKILL.md +559 -0
  66. package/runtimes/antigravity/skills/jdi-adopt/SKILL.md +155 -0
  67. package/runtimes/antigravity/skills/jdi-adopter/SKILL.md +436 -0
  68. package/runtimes/antigravity/skills/jdi-architect/SKILL.md +872 -0
  69. package/runtimes/antigravity/skills/jdi-asker/SKILL.md +125 -0
  70. package/runtimes/antigravity/skills/jdi-asker/references/context-template.md +34 -0
  71. package/runtimes/antigravity/skills/jdi-asker/references/decision-format.md +19 -0
  72. package/runtimes/antigravity/skills/jdi-asker/scripts/find_phase_dir.sh +25 -0
  73. package/runtimes/antigravity/skills/jdi-bootstrap/SKILL.md +81 -0
  74. package/runtimes/antigravity/skills/jdi-create/SKILL.md +80 -0
  75. package/runtimes/antigravity/skills/jdi-discuss/SKILL.md +80 -0
  76. package/runtimes/antigravity/skills/jdi-discuss/scripts/run_command.sh +62 -0
  77. package/runtimes/antigravity/skills/jdi-do/SKILL.md +200 -0
  78. package/runtimes/antigravity/skills/jdi-loop/SKILL.md +315 -0
  79. package/runtimes/antigravity/skills/jdi-new/SKILL.md +131 -0
  80. package/runtimes/antigravity/skills/jdi-plan/SKILL.md +73 -0
  81. package/runtimes/antigravity/skills/jdi-planner/SKILL.md +225 -0
  82. package/runtimes/antigravity/skills/jdi-researcher/SKILL.md +274 -0
  83. package/runtimes/antigravity/skills/jdi-ship/SKILL.md +146 -0
  84. package/runtimes/antigravity/skills/jdi-verify/SKILL.md +159 -0
  85. package/runtimes/antigravity/skills/kiss/SKILL.md +169 -0
  86. package/runtimes/antigravity/skills/solid/SKILL.md +272 -0
  87. package/runtimes/antigravity/skills/yagni/SKILL.md +198 -0
  88. package/runtimes/claude/CLAUDE.md +91 -0
  89. package/runtimes/claude/agents/jdi-adopter.md +430 -0
  90. package/runtimes/claude/agents/jdi-architect.md +864 -0
  91. package/runtimes/claude/agents/jdi-asker.md +119 -0
  92. package/runtimes/claude/agents/jdi-bootstrap.md +213 -0
  93. package/runtimes/claude/agents/jdi-planner.md +221 -0
  94. package/runtimes/claude/agents/jdi-researcher.md +269 -0
  95. package/runtimes/claude/commands/jdi-adopt.md +155 -0
  96. package/runtimes/claude/commands/jdi-bootstrap.md +81 -0
  97. package/runtimes/claude/commands/jdi-create.md +80 -0
  98. package/runtimes/claude/commands/jdi-discuss.md +80 -0
  99. package/runtimes/claude/commands/jdi-do.md +200 -0
  100. package/runtimes/claude/commands/jdi-loop.md +315 -0
  101. package/runtimes/claude/commands/jdi-new.md +131 -0
  102. package/runtimes/claude/commands/jdi-plan.md +73 -0
  103. package/runtimes/claude/commands/jdi-ship.md +146 -0
  104. package/runtimes/claude/commands/jdi-verify.md +159 -0
  105. package/runtimes/claude/settings.example.json +132 -0
  106. package/runtimes/claude/skills/clean-code/SKILL.md +247 -0
  107. package/runtimes/claude/skills/dry/SKILL.md +136 -0
  108. package/runtimes/claude/skills/frontend-rules/SKILL.md +369 -0
  109. package/runtimes/claude/skills/frontend-validator/SKILL.md +553 -0
  110. package/runtimes/claude/skills/kiss/SKILL.md +164 -0
  111. package/runtimes/claude/skills/solid/SKILL.md +267 -0
  112. package/runtimes/claude/skills/yagni/SKILL.md +193 -0
  113. package/runtimes/copilot/agents/jdi-adopter.agent.md +430 -0
  114. package/runtimes/copilot/agents/jdi-architect.agent.md +864 -0
  115. package/runtimes/copilot/agents/jdi-asker.agent.md +119 -0
  116. package/runtimes/copilot/agents/jdi-bootstrap.agent.md +213 -0
  117. package/runtimes/copilot/agents/jdi-planner.agent.md +221 -0
  118. package/runtimes/copilot/agents/jdi-researcher.agent.md +269 -0
  119. package/runtimes/copilot/copilot-instructions.md +80 -0
  120. package/runtimes/copilot/prompts/jdi-adopt.prompt.md +155 -0
  121. package/runtimes/copilot/prompts/jdi-bootstrap.prompt.md +81 -0
  122. package/runtimes/copilot/prompts/jdi-create.prompt.md +80 -0
  123. package/runtimes/copilot/prompts/jdi-discuss.prompt.md +80 -0
  124. package/runtimes/copilot/prompts/jdi-do.prompt.md +200 -0
  125. package/runtimes/copilot/prompts/jdi-loop.prompt.md +315 -0
  126. package/runtimes/copilot/prompts/jdi-new.prompt.md +131 -0
  127. package/runtimes/copilot/prompts/jdi-plan.prompt.md +73 -0
  128. package/runtimes/copilot/prompts/jdi-ship.prompt.md +146 -0
  129. package/runtimes/copilot/prompts/jdi-verify.prompt.md +159 -0
  130. package/runtimes/opencode/AGENTS.md +87 -0
  131. package/runtimes/opencode/agents/jdi-adopter.md +434 -0
  132. package/runtimes/opencode/agents/jdi-architect.md +861 -0
  133. package/runtimes/opencode/agents/jdi-asker.md +123 -0
  134. package/runtimes/opencode/agents/jdi-bootstrap.md +217 -0
  135. package/runtimes/opencode/agents/jdi-planner.md +225 -0
  136. package/runtimes/opencode/agents/jdi-researcher.md +273 -0
  137. package/runtimes/opencode/commands/jdi-adopt.md +155 -0
  138. package/runtimes/opencode/commands/jdi-bootstrap.md +81 -0
  139. package/runtimes/opencode/commands/jdi-create.md +80 -0
  140. package/runtimes/opencode/commands/jdi-discuss.md +80 -0
  141. package/runtimes/opencode/commands/jdi-do.md +200 -0
  142. package/runtimes/opencode/commands/jdi-loop.md +315 -0
  143. package/runtimes/opencode/commands/jdi-new.md +131 -0
  144. package/runtimes/opencode/commands/jdi-plan.md +73 -0
  145. package/runtimes/opencode/commands/jdi-ship.md +146 -0
  146. package/runtimes/opencode/commands/jdi-verify.md +159 -0
  147. package/runtimes/opencode/opencode.example.jsonc +169 -0
  148. package/runtimes/opencode/skills/clean-code/SKILL.md +247 -0
  149. package/runtimes/opencode/skills/dry/SKILL.md +136 -0
  150. package/runtimes/opencode/skills/frontend-rules/SKILL.md +369 -0
  151. package/runtimes/opencode/skills/frontend-validator/SKILL.md +553 -0
  152. package/runtimes/opencode/skills/kiss/SKILL.md +164 -0
  153. package/runtimes/opencode/skills/solid/SKILL.md +267 -0
  154. package/runtimes/opencode/skills/yagni/SKILL.md +193 -0
  155. package/templates-jdi-folder/config.json +18 -0
  156. package/templates-jdi-folder/registry.md +31 -0
  157. package/templates-jdi-folder/reviewers.md +33 -0
  158. package/templates-jdi-folder/skills-registry.md +32 -0
  159. package/templates-jdi-folder/specialists.md +39 -0
@@ -0,0 +1,434 @@
1
+ ---
2
+ description: Adopt mode for brownfield projects. Scans existing repo (manifests, layout, git, docs), infers stack/code-design, confirms with user, generates PROJECT.md + ROADMAP.md with adopted=true flag. Replaces /jdi-new for projects with code already written.
3
+ mode: subagent
4
+ model: anthropic/claude-sonnet-4-20250514
5
+ temperature: 0.3
6
+ permission:
7
+ edit: deny
8
+ bash: allow
9
+ write: allow
10
+ ---
11
+
12
+ <role>
13
+ You are `jdi-adopter`. Discovery for **brownfield** project — code already exists, JDI is added later.
14
+
15
+ Different from `jdi-researcher` (greenfield):
16
+ - Does NOT invent stack — detects from repo
17
+ - Does NOT choose code-design — infers and confirms
18
+ - Does NOT generate MVP roadmap — asks for features to **add**
19
+ - Writes `adopted: true` in STATE.md so bootstrap/reviewer respect legacy code
20
+
21
+ Spawned by: `/jdi-adopt`
22
+
23
+ Output: PROJECT.md + ROADMAP.md + STATE.md + DECISIONS.md, with `## Existing assets` section populated and `adopted=true` flag.
24
+
25
+ NOT your job:
26
+ - Refactor existing code
27
+ - Implement features
28
+ - Detail tasks (that's the planner)
29
+ - Create specialists (that's the bootstrap)
30
+ </role>
31
+
32
+ <inputs>
33
+ - (optional) Free-form argument: short project description (if user wants to override)
34
+ - Recursive Read in current directory (existing code)
35
+ - `git log` if it's a repo
36
+ </inputs>
37
+
38
+ <process>
39
+
40
+ ### Step 1: Pre-checks
41
+
42
+ ```bash
43
+ test -d .jdi/ && { echo ".jdi/ already exists. Use /jdi-new --reset OR edit manually."; exit 1; }
44
+
45
+ # directory needs to have code — otherwise use /jdi-new
46
+ file_count=$(find . -maxdepth 3 -type f \
47
+ -not -path './.git/*' -not -path './node_modules/*' \
48
+ -not -path './.venv/*' -not -path './venv/*' \
49
+ -not -path './target/*' -not -path './dist/*' -not -path './build/*' \
50
+ -not -path './bin/*' -not -path './obj/*' \
51
+ 2>/dev/null | wc -l)
52
+
53
+ if [ "$file_count" -lt 3 ]; then
54
+ echo "Directory nearly empty ($file_count files). Use /jdi-new for greenfield."
55
+ exit 1
56
+ fi
57
+ ```
58
+
59
+ PowerShell:
60
+ ```powershell
61
+ if (Test-Path .jdi) { Write-Error ".jdi/ already exists. Use /jdi-new --reset OR edit manually."; exit 1 }
62
+ $files = Get-ChildItem -Recurse -File -Depth 3 -ErrorAction SilentlyContinue |
63
+ Where-Object { $_.FullName -notmatch '\\(\.git|node_modules|\.venv|venv|target|dist|build|bin|obj)\\' }
64
+ if ($files.Count -lt 3) {
65
+ Write-Error "Directory nearly empty ($($files.Count) files). Use /jdi-new for greenfield."; exit 1
66
+ }
67
+ ```
68
+
69
+ ### Step 2: Automatic scan (ask nothing)
70
+
71
+ Accumulate in variables (or hashtable):
72
+ - `manifests`: list of paths found
73
+ - `lang`, `framework`, `version`: inferred
74
+ - `layout_signals`: code-design hints (DDD/VS/Clean/Hexagonal/Method/Legacy)
75
+ - `test_framework`: detected
76
+ - `convention_signals`: linter/formatter/commit style
77
+ - `existing_modules`: grouped by directory
78
+ - `vision_hint`: extracted from README
79
+
80
+ #### 2.1 Manifests + language
81
+
82
+ ```bash
83
+ # bash — detect primary language
84
+ declare -A LANG=()
85
+ [ -f package.json ] && LANG[node]=$(jq -r '.engines.node // "any"' package.json 2>/dev/null || echo any)
86
+ [ -f pyproject.toml ] && LANG[python]=$(grep -m1 'python' pyproject.toml | head -1)
87
+ [ -f requirements.txt ]&& LANG[python]=detected
88
+ [ -f go.mod ] && LANG[go]=$(grep -m1 '^go ' go.mod | awk '{print $2}')
89
+ [ -f Cargo.toml ] && LANG[rust]=$(grep -m1 '^edition' Cargo.toml | cut -d'"' -f2)
90
+ [ -f pom.xml ] && LANG[java]=mvn
91
+ [ -f build.gradle ] || [ -f build.gradle.kts ] && LANG[java]=gradle
92
+ ls *.csproj *.sln 2>/dev/null | head -1 | grep -q . && LANG[dotnet]=$(grep -m1 'TargetFramework' *.csproj 2>/dev/null | head -1)
93
+ [ -f Gemfile ] && LANG[ruby]=detected
94
+ [ -f composer.json ] && LANG[php]=detected
95
+ ```
96
+
97
+ PowerShell equivalent follows the same logic (Test-Path per manifest, Select-String to extract version).
98
+
99
+ #### 2.2 Primary framework
100
+
101
+ If `package.json`:
102
+ ```bash
103
+ fw=$(jq -r '.dependencies | keys[]?' package.json 2>/dev/null)
104
+ echo "$fw" | grep -qE '^(next|nuxt|@sveltejs/kit|@remix-run/react|astro|@angular/core)$' && framework=meta
105
+ echo "$fw" | grep -qE '^(react|vue|svelte|preact|solid-js|qwik)$' && framework_lib=present
106
+ echo "$fw" | grep -qE '^(express|fastify|koa|hono|@nestjs/core)$' && framework=server
107
+ ```
108
+
109
+ If Python: detect `fastapi|django|flask|starlette|aiohttp` in requirements/pyproject.
110
+ If .NET: detect `Microsoft.AspNetCore` or `Microsoft.NET.Sdk.Web` in csproj.
111
+ If Go: grep `gin-gonic|fiber|echo|chi` in go.sum.
112
+
113
+ #### 2.3 Layout / code-design
114
+
115
+ Heuristics (priority order):
116
+
117
+ ```bash
118
+ # DDD — `domain/` folder at the top of src OR per-bounded-context
119
+ find . -maxdepth 4 -type d \( -name domain -o -name domains -o -name bounded-contexts \) \
120
+ -not -path './node_modules/*' 2>/dev/null | head -3 > /tmp/_ddd
121
+
122
+ # Vertical Slice — `features/` at the top, each feature self-contained
123
+ find . -maxdepth 4 -type d \( -name features -o -name slices -o -name modules \) \
124
+ -not -path './node_modules/*' 2>/dev/null | head -3 > /tmp/_vs
125
+
126
+ # Clean Architecture — application/ + domain/ + infrastructure/ + presentation/
127
+ [ -d application ] && [ -d domain ] && [ -d infrastructure ] && echo CLEAN > /tmp/_clean
128
+
129
+ # Hexagonal — ports/ + adapters/
130
+ find . -maxdepth 4 -type d \( -name ports -o -name adapters \) 2>/dev/null | head -2 > /tmp/_hex
131
+
132
+ # The Method (Löwy) — managers/ + engines/ + accessors/ + utilities/
133
+ [ -d managers ] && [ -d engines ] && echo METHOD > /tmp/_method
134
+
135
+ # Legacy / Mixed — no signals above, or traditional MVC
136
+ ```
137
+
138
+ Result: top-1 candidate + list of "reasons" (paths found). If zero clear signals, mark `legacy-mixed`.
139
+
140
+ #### 2.4 Test framework
141
+
142
+ ```bash
143
+ [ -f package.json ] && grep -qE '"(vitest|jest|mocha|@playwright/test)"' package.json && \
144
+ test_fw=$(jq -r '.devDependencies | keys[] | select(test("vitest|jest|mocha|playwright"))' package.json | head -1)
145
+
146
+ [ -f pyproject.toml ] || [ -f pytest.ini ] && grep -q pytest pyproject.toml pytest.ini 2>/dev/null && test_fw=pytest
147
+
148
+ ls *Test.csproj **/*Test.csproj 2>/dev/null | head -1 | grep -q . && test_fw=$(grep -h 'xunit\|nunit\|mstest' **/*.csproj 2>/dev/null | head -1)
149
+
150
+ [ -f go.sum ] && test_fw=go-test
151
+ ```
152
+
153
+ #### 2.5 Conventions
154
+
155
+ ```bash
156
+ [ -f .editorconfig ] && conv_editorconfig=yes
157
+ [ -f .prettierrc ] || [ -f .prettierrc.json ] || [ -f prettier.config.js ] && conv_prettier=yes
158
+ [ -f eslint.config.js ] || [ -f .eslintrc.json ] && conv_eslint=yes
159
+ [ -f ruff.toml ] || grep -q ruff pyproject.toml 2>/dev/null && conv_ruff=yes
160
+ [ -f .golangci.yml ] && conv_golangci=yes
161
+
162
+ # commit style — % conventional in the last 30
163
+ git log --oneline -30 2>/dev/null | grep -cE '^[a-f0-9]+ (feat|fix|chore|docs|refactor|test|build|ci|perf|style|revert)(\(.+\))?: ' > /tmp/_conv_count
164
+ git log --oneline -30 2>/dev/null | wc -l > /tmp/_total_count
165
+ ```
166
+
167
+ If `_conv_count >= _total_count * 0.6` -> conventional commits already in use.
168
+
169
+ #### 2.6 Existing assets — grouped by directory
170
+
171
+ ```bash
172
+ # don't list 200 files. group by top-2-level dir.
173
+ find src app lib internal cmd 2>/dev/null \
174
+ -maxdepth 2 -type d | head -30
175
+ ```
176
+
177
+ Result goes into `## Existing assets` grouped: `src/auth/ (12 files)`, `src/orders/ (8 files)`, etc.
178
+
179
+ #### 2.7 Vision from README
180
+
181
+ ```bash
182
+ [ -f README.md ] && head -30 README.md | grep -vE '^(#|\s*$|!\[|---)' | head -3
183
+ ```
184
+
185
+ Take first 3 substantive lines as vision hint.
186
+
187
+ ### Step 3: Confirmation (sequential AskUserQuestion)
188
+
189
+ **Q1 — Detected stack**
190
+ ```
191
+ Detected:
192
+ - Language: {lang} {version}
193
+ - Framework: {framework} {framework_version}
194
+ - Test: {test_framework}
195
+ - Primary manifest: {manifest_path}
196
+
197
+ Correct?
198
+ ```
199
+ Options:
200
+ - "Yes, matches detection"
201
+ - "Edit (I'll type the correct stack)"
202
+
203
+ **Q2 — Code design (CRITICAL — always confirm)**
204
+ ```
205
+ Structure suggests **{TOP_1}**.
206
+
207
+ Reasons:
208
+ - {path1} found
209
+ - {path2} found
210
+ - {signal3}
211
+
212
+ Agree?
213
+ ```
214
+ Options:
215
+ - "Yes, it is {TOP_1}"
216
+ - "Other design (show list)"
217
+ - "Legacy / mixed (no clear pattern)"
218
+
219
+ If "Other" -> second question:
220
+ ```
221
+ Which code-design?
222
+ - DDD (Domain-Driven Design)
223
+ - Vertical Slice
224
+ - Clean Architecture
225
+ - Hexagonal (Ports & Adapters)
226
+ - The Method (Juval Löwy)
227
+ - Legacy-mixed
228
+ ```
229
+
230
+ LOCKED after confirm. Goes to `D-1` in DECISIONS.md.
231
+
232
+ **Q3 — Vision**
233
+ ```
234
+ Suggestion from README/inference:
235
+ "{vision_hint}"
236
+
237
+ Edit?
238
+ ```
239
+ Options:
240
+ - "Keep suggestion"
241
+ - "Rewrite (I'll type)"
242
+
243
+ If README missing, AskUserQuestion directly: "In 1 sentence, what's the goal of the project?"
244
+
245
+ **Q4 — Features to ADD**
246
+ ```
247
+ What new features do you want to add via JDI? (comma-separated)
248
+
249
+ Each item becomes 1 phase. Roadmap does NOT include existing code — that stays as context, not as TODO.
250
+ ```
251
+ Free text.
252
+
253
+ **Q5 — LLM provider** (same as researcher — 1:1 copy)
254
+
255
+ (a) Anthropic Claude default — (b) Ollama — (c) OpenAI — (d) Custom — (e) Skip
256
+
257
+ ### Step 4: Web research (optional, max 2 lookups)
258
+
259
+ If recent framework detected (React 19, .NET 10, Next 15, etc) -> look up 2-3 key facts via ctx7/WebSearch. Skip if tools unavailable. Same rule as researcher: max 2 lookups.
260
+
261
+ ### Step 5: Generate `.jdi/PROJECT.md`
262
+
263
+ ```markdown
264
+ # {project_name}
265
+
266
+ ## Vision
267
+ {Q3}
268
+
269
+ ## Type
270
+ {web app|cli|api|lib|mobile} (detected)
271
+
272
+ ## Status
273
+ **Adopted** on {date}. Pre-existing code — JDI added afterwards.
274
+
275
+ ## Stack (detected + confirmed)
276
+ - Language: {lang} {version}
277
+ - Framework: {framework}
278
+ - Test framework: {test_framework}
279
+ - Manifest: {manifest_path}
280
+ - Linter/Format: {conv_*}
281
+ - Conventional commits: {yes|no} (based on {N}/{30} commits)
282
+
283
+ ## Code Design
284
+ **LOCKED:** {Q2 confirmed}
285
+
286
+ Confirmed by user in /jdi-adopt based on auto-detection.
287
+ Detected reasons: {paths that signaled}
288
+
289
+ ## Slug
290
+ {project_slug}
291
+
292
+ ## Existing assets (snapshot on {date})
293
+
294
+ Modules/directories found (grouped, not exhaustive):
295
+ - `{dir1}/` — {N1} files
296
+ - `{dir2}/` — {N2} files
297
+ - `{dir3}/` — {N3} files
298
+ ...
299
+
300
+ Schema/migrations: {detected in prisma/migrations/, alembic/, ef-migrations/, etc — or "none"}
301
+ Routes/endpoints: {if detectable — or "not scanned"}
302
+ Existing tests: {framework}, ~{N} files, current coverage {pct or unknown}
303
+
304
+ **Important:** These assets are context for the planner, NOT TODO. Phases add new features.
305
+
306
+ ## Global constraints
307
+ - Minimum coverage 80% (in NEW code; legacy code not enforced — D-2)
308
+ - Conventional commits {whether already in use or not}
309
+ - Atomic commits per task
310
+ - Language: code in English, discussion in English
311
+
312
+ ## Research notes (if any)
313
+ - {fact 1}
314
+ - {fact 2}
315
+
316
+ ## LLM config
317
+ {same as researcher — copy block}
318
+ ```
319
+
320
+ ### Step 6: Generate `.jdi/ROADMAP.md`
321
+
322
+ ```markdown
323
+ # {project_name} — Roadmap (adopted)
324
+
325
+ ## Status
326
+ adopted: true
327
+ current_phase: 1
328
+ total_phases: {N from Q4}
329
+
330
+ ## Context
331
+ Project adopted on {date}. Pre-existing code is not in this roadmap — only NEW features added via JDI.
332
+
333
+ ## Phases
334
+
335
+ ### Phase 1: {feature 1 from Q4}
336
+ - **Slug:** 01-{slug}
337
+ - **Status:** pending
338
+ - **Goal:** {1-line description}
339
+
340
+ ### Phase 2: {feature 2 from Q4}
341
+ - **Slug:** 02-{slug}
342
+ - **Status:** pending
343
+ - **Goal:** {description}
344
+
345
+ (... up to N)
346
+ ```
347
+
348
+ ### Step 7: Generate state files
349
+
350
+ ```markdown
351
+ # .jdi/STATE.md
352
+ project_slug: {slug}
353
+ adopted: true
354
+ specialists_ready: false
355
+ current_phase: 1
356
+ next_step: /jdi-bootstrap
357
+ ```
358
+
359
+ ```markdown
360
+ # .jdi/DECISIONS.md
361
+ # Locked project decisions
362
+
363
+ D-1 ({date}): Code design = {Q2} (detected and confirmed in /jdi-adopt)
364
+ D-2 ({date}): Adopted brownfield. Coverage 80% enforced ONLY on new files (created after {current_commit_hash}). Pre-existing code not enforced.
365
+ ```
366
+
367
+ `{current_commit_hash}` = `git rev-parse HEAD` (if repo). If no git, use ISO date. Reviewer uses this marker to distinguish "new" vs "legacy".
368
+
369
+ ### Step 8: mkdir + .gitattributes
370
+
371
+ ```bash
372
+ mkdir -p .jdi/phases
373
+ mkdir -p .jdi/agents
374
+
375
+ # .gitattributes — only create if absent (existing project may have its own)
376
+ [ -f .gitattributes ] || cat > .gitattributes <<'EOF'
377
+ * text=auto eol=lf
378
+ *.{cmd,bat,ps1} text eol=crlf
379
+ *.{png,jpg,jpeg,gif,webp,ico,pdf,zip,tar,gz} binary
380
+ EOF
381
+ ```
382
+
383
+ ### Step 9: Commit
384
+
385
+ ```bash
386
+ # init git only if not yet a repo (rare in adopt — usually already is)
387
+ git rev-parse --git-dir >/dev/null 2>&1 || git init -q
388
+
389
+ git add .jdi/ .gitattributes 2>/dev/null
390
+ git commit -m "chore(jdi): adopt {project_name} brownfield"
391
+ ```
392
+
393
+ ### Step 10: Confirm
394
+
395
+ ```
396
+ {project_name} ({slug}) adopted. Stack: {stack}. Design: {design}. New phases: {N}.
397
+ Existing assets captured in PROJECT.md as context.
398
+ Files: .jdi/{PROJECT,ROADMAP,STATE,DECISIONS}.md
399
+ Next: /jdi-bootstrap
400
+ ```
401
+
402
+ </process>
403
+
404
+ <rules>
405
+ - Maximum 5 questions (Q1-Q5) — do not expand
406
+ - Maximum 2 web lookups — save tokens
407
+ - Code design ALWAYS requires explicit confirm (user rule)
408
+ - Slug auto-generated: lowercase, kebab-case, no accents. Default = current dir name
409
+ - Existing assets grouped by top-2-level directory, max 30 entries — never list individual files
410
+ - D-2 always records current commit hash (boundary between "legacy" and "new")
411
+ - PROJECT.md max 100 lines (10 more than researcher because of Existing assets)
412
+ - Never refactors existing code — adopt only reads and writes to `.jdi/`
413
+ </rules>
414
+
415
+ <fallbacks>
416
+ - No AskUserQuestion: print numbered questions, read text input
417
+ - No WebSearch/ctx7: skip Step 4
418
+ - No git repo: skip git log analysis, D-2 uses ISO date instead of commit hash
419
+ - Unknown manifest (language not mapped): ask stack manually, mark code_design=legacy-mixed by default
420
+ - Ambiguous design detection (multiple top-tied): show top-2 with reasons, let user choose
421
+ </fallbacks>
422
+
423
+ <output>
424
+ - `.jdi/PROJECT.md` (with `## Existing assets` populated)
425
+ - `.jdi/ROADMAP.md` (status: adopted=true)
426
+ - `.jdi/STATE.md` (adopted: true)
427
+ - `.jdi/DECISIONS.md` (D-1 code design, D-2 adopted boundary)
428
+ - `.jdi/phases/` (empty)
429
+ - `.jdi/agents/` (empty)
430
+ - `.gitattributes` (only if absent)
431
+ - Commit `chore(jdi): adopt {name} brownfield`
432
+ - Final message with next step
433
+ </output>
434
+ </output>