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,264 @@
1
+ #!/usr/bin/env bash
2
+ # jdi-uninstall: remove JDI do projeto.
3
+ #
4
+ # - Default: NAO remove .jdi/ (state files - decisoes locked, roadmap)
5
+ # - --purge: remove TUDO incluindo .jdi/
6
+ # - --runtime <name>: especifico
7
+ # - --scope user|project|both: especifico (default: both)
8
+ # - --yes: pula confirmacoes
9
+ # - --dry-run: mostra sem aplicar
10
+ #
11
+ # SEMPRE pede confirmacao por padrao - acao destrutiva.
12
+
13
+ set -euo pipefail
14
+
15
+ PROJECT_DIR="$(pwd)"
16
+ USER_HOME="${HOME:-$HOME}"
17
+
18
+ RUNTIME="all"
19
+ SCOPE="both"
20
+ PURGE=0
21
+ YES=0
22
+ DRY_RUN=0
23
+
24
+ while [[ $# -gt 0 ]]; do
25
+ case "$1" in
26
+ --runtime) RUNTIME="$2"; shift 2 ;;
27
+ --scope) SCOPE="$2"; shift 2 ;;
28
+ --purge) PURGE=1; shift ;;
29
+ --yes|-y) YES=1; shift ;;
30
+ --dry-run) DRY_RUN=1; shift ;;
31
+ *) shift ;;
32
+ esac
33
+ done
34
+
35
+ confirm_action() {
36
+ local msg="$1"
37
+ if [[ $YES -eq 1 || $DRY_RUN -eq 1 ]]; then return 0; fi
38
+ read -r -p "$msg (y/N) " resp
39
+ [[ "$resp" =~ ^[YySs] ]]
40
+ }
41
+
42
+ remove_safe() {
43
+ local path="$1"
44
+ local label="$2"
45
+ [[ ! -e "$path" ]] && return 0
46
+
47
+ if [[ $DRY_RUN -eq 1 ]]; then
48
+ echo " [dry-run] removeria: $path"
49
+ return 0
50
+ fi
51
+
52
+ rm -rf "$path"
53
+ echo " removido: $label"
54
+ }
55
+
56
+ uninstall_claude() {
57
+ local scope="$1"
58
+ local targets=()
59
+ [[ "$scope" == "project" || "$scope" == "both" ]] && targets+=("$PROJECT_DIR/.claude:project")
60
+ [[ "$scope" == "user" || "$scope" == "both" ]] && targets+=("$USER_HOME/.claude:user")
61
+
62
+ for t in "${targets[@]}"; do
63
+ local dir="${t%:*}"
64
+ local sc="${t#*:}"
65
+ [[ ! -d "$dir" ]] && continue
66
+
67
+ echo
68
+ echo "Claude ($sc scope) em: $dir"
69
+
70
+ if [[ -d "$dir/agents" ]]; then
71
+ for f in "$dir/agents"/jdi-*.md; do
72
+ [[ -f "$f" ]] && remove_safe "$f" "agents/$(basename "$f")"
73
+ done
74
+ fi
75
+
76
+ if [[ -d "$dir/commands" ]]; then
77
+ for f in "$dir/commands"/jdi-*.md; do
78
+ [[ -f "$f" ]] && remove_safe "$f" "commands/$(basename "$f")"
79
+ done
80
+ fi
81
+
82
+ if [[ -d "$dir/skills" ]]; then
83
+ for skill in frontend-rules frontend-validator dry kiss yagni solid clean-code; do
84
+ remove_safe "$dir/skills/$skill" "skills/$skill/"
85
+ done
86
+ fi
87
+
88
+ if [[ "$sc" == "project" ]]; then
89
+ if [[ -f "$PROJECT_DIR/CLAUDE.md" ]]; then
90
+ if confirm_action "Remover CLAUDE.md? (pode ter sido editado)"; then
91
+ remove_safe "$PROJECT_DIR/CLAUDE.md" "CLAUDE.md"
92
+ fi
93
+ fi
94
+ fi
95
+ done
96
+ }
97
+
98
+ uninstall_copilot() {
99
+ local dest="$PROJECT_DIR/.github"
100
+ [[ ! -d "$dest" ]] && return 0
101
+
102
+ echo
103
+ echo "Copilot (project scope) em: $dest"
104
+
105
+ if [[ -d "$dest/agents" ]]; then
106
+ for f in "$dest/agents"/jdi-*.agent.md; do
107
+ [[ -f "$f" ]] && remove_safe "$f" "agents/$(basename "$f")"
108
+ done
109
+ fi
110
+
111
+ if [[ -d "$dest/prompts" ]]; then
112
+ for f in "$dest/prompts"/jdi-*.prompt.md; do
113
+ [[ -f "$f" ]] && remove_safe "$f" "prompts/$(basename "$f")"
114
+ done
115
+ fi
116
+
117
+ if [[ -f "$dest/copilot-instructions.md" ]]; then
118
+ if confirm_action "Remover .github/copilot-instructions.md? (pode ter sido editado)"; then
119
+ remove_safe "$dest/copilot-instructions.md" ".github/copilot-instructions.md"
120
+ fi
121
+ fi
122
+ }
123
+
124
+ uninstall_antigravity() {
125
+ local scope="$1"
126
+ local targets=()
127
+ [[ "$scope" == "project" || "$scope" == "both" ]] && targets+=("$PROJECT_DIR/.gemini/antigravity:project")
128
+ [[ "$scope" == "user" || "$scope" == "both" ]] && targets+=("$USER_HOME/.gemini/antigravity:user")
129
+
130
+ for t in "${targets[@]}"; do
131
+ local dir="${t%:*}"
132
+ local sc="${t#*:}"
133
+ [[ ! -d "$dir" ]] && continue
134
+
135
+ echo
136
+ echo "Antigravity ($sc scope) em: $dir"
137
+
138
+ if [[ -d "$dir/skills" ]]; then
139
+ # jdi-* skills (cada uma eh dir)
140
+ for sd in "$dir/skills"/jdi-*; do
141
+ [[ -d "$sd" ]] && remove_safe "$sd" "skills/$(basename "$sd")/"
142
+ done
143
+ # universais
144
+ for skill in frontend-rules frontend-validator dry kiss yagni solid clean-code; do
145
+ remove_safe "$dir/skills/$skill" "skills/$skill/"
146
+ done
147
+ fi
148
+
149
+ if [[ "$sc" == "project" && -f "$PROJECT_DIR/agents.md" ]]; then
150
+ if confirm_action "Remover agents.md (Antigravity)? (pode ter sido editado)"; then
151
+ remove_safe "$PROJECT_DIR/agents.md" "agents.md"
152
+ fi
153
+ fi
154
+ done
155
+ }
156
+
157
+ uninstall_opencode() {
158
+ local scope="$1"
159
+ local targets=()
160
+ [[ "$scope" == "project" || "$scope" == "both" ]] && targets+=("$PROJECT_DIR/.opencode:project")
161
+ [[ "$scope" == "user" || "$scope" == "both" ]] && targets+=("$USER_HOME/.config/opencode:user")
162
+
163
+ for t in "${targets[@]}"; do
164
+ local dir="${t%:*}"
165
+ local sc="${t#*:}"
166
+ [[ ! -d "$dir" ]] && continue
167
+
168
+ echo
169
+ echo "OpenCode ($sc scope) em: $dir"
170
+
171
+ if [[ -d "$dir/agents" ]]; then
172
+ for f in "$dir/agents"/jdi-*.md; do
173
+ [[ -f "$f" ]] && remove_safe "$f" "agents/$(basename "$f")"
174
+ done
175
+ fi
176
+
177
+ if [[ -d "$dir/commands" ]]; then
178
+ for f in "$dir/commands"/jdi-*.md; do
179
+ [[ -f "$f" ]] && remove_safe "$f" "commands/$(basename "$f")"
180
+ done
181
+ fi
182
+
183
+ if [[ -d "$dir/skills" ]]; then
184
+ for skill in frontend-rules frontend-validator dry kiss yagni solid clean-code; do
185
+ remove_safe "$dir/skills/$skill" "skills/$skill/"
186
+ done
187
+ fi
188
+
189
+ if [[ "$sc" == "project" ]]; then
190
+ if [[ -f "$PROJECT_DIR/AGENTS.md" ]]; then
191
+ if confirm_action "Remover AGENTS.md (OpenCode)? (pode ter sido editado)"; then
192
+ remove_safe "$PROJECT_DIR/AGENTS.md" "AGENTS.md"
193
+ fi
194
+ fi
195
+ if [[ -f "$dir/opencode.jsonc" ]]; then
196
+ if confirm_action "Remover .opencode/opencode.jsonc? (pode ter config customizada)"; then
197
+ remove_safe "$dir/opencode.jsonc" ".opencode/opencode.jsonc"
198
+ fi
199
+ fi
200
+ fi
201
+ done
202
+ }
203
+
204
+ # =========================================================
205
+ # Main
206
+ # =========================================================
207
+
208
+ echo
209
+ echo "JDI Uninstall"
210
+ echo " Dir: $PROJECT_DIR"
211
+ echo " Runtime: $RUNTIME"
212
+ echo " Scope: $SCOPE"
213
+ [[ $PURGE -eq 1 ]] && echo " Purge: YES (vai remover .jdi/ tambem)"
214
+ [[ $DRY_RUN -eq 1 ]] && echo " Mode: DRY-RUN (sem mudancas)"
215
+ echo
216
+
217
+ if [[ $YES -eq 0 && $DRY_RUN -eq 0 ]]; then
218
+ if ! confirm_action "Continuar com uninstall? (acao destrutiva)"; then
219
+ echo "Cancelado."
220
+ exit 0
221
+ fi
222
+ fi
223
+
224
+ if [[ "$RUNTIME" == "all" ]]; then
225
+ runtimes=("claude" "copilot" "antigravity" "opencode")
226
+ else
227
+ runtimes=("$RUNTIME")
228
+ fi
229
+
230
+ for r in "${runtimes[@]}"; do
231
+ case "$r" in
232
+ claude) uninstall_claude "$SCOPE" ;;
233
+ copilot) uninstall_copilot ;;
234
+ antigravity) uninstall_antigravity "$SCOPE" ;;
235
+ opencode) uninstall_opencode "$SCOPE" ;;
236
+ esac
237
+ done
238
+
239
+ # Purge
240
+ if [[ $PURGE -eq 1 ]]; then
241
+ echo
242
+ if [[ -d "$PROJECT_DIR/.jdi" ]]; then
243
+ echo "PURGE: removendo .jdi/ (state files - DECISIONS, ROADMAP, phases, etc)"
244
+ if confirm_action "TEM CERTEZA? Isso apaga decisoes locked permanentemente"; then
245
+ remove_safe "$PROJECT_DIR/.jdi" ".jdi/"
246
+ else
247
+ echo " .jdi/ preservado."
248
+ fi
249
+ fi
250
+
251
+ if [[ -d "$PROJECT_DIR/.githooks" ]]; then
252
+ if confirm_action "Remover .githooks/?"; then
253
+ remove_safe "$PROJECT_DIR/.githooks" ".githooks/"
254
+ fi
255
+ fi
256
+ fi
257
+
258
+ echo
259
+ echo "Uninstall completo."
260
+ [[ $DRY_RUN -eq 1 ]] && echo "(dry-run - nada foi mudado)"
261
+ if [[ $PURGE -eq 0 ]]; then
262
+ echo
263
+ echo "Nota: .jdi/ preservado (state files). Use --purge pra remover tambem."
264
+ fi
@@ -0,0 +1,215 @@
1
+ <#
2
+ .SYNOPSIS
3
+ jdi-update (Windows): atualiza JDI em projeto que ja tem JDI instalado.
4
+
5
+ .DESCRIPTION
6
+ Diferente do install, o update:
7
+ - Detecta automaticamente quais runtimes estao instalados no projeto
8
+ - Sobrescreve runtime files (agents, commands, skills) - shipped pelo JDI
9
+ - NUNCA toca state files (PROJECT.md, DECISIONS.md, ROADMAP.md, STATE.md, phases/, registry.md)
10
+ - Detecta specialists em .jdi/agents/ e pergunta se regenera (template pode ter mudado)
11
+ - Atualiza .jdi/VERSION com versao nova
12
+
13
+ .PARAMETER ForceSpecialists
14
+ Regenera specialists sem perguntar (assume Yes pra regen).
15
+
16
+ .PARAMETER SkipSpecialists
17
+ Nao mexe em specialists mesmo se template mudou.
18
+
19
+ .PARAMETER DryRun
20
+ Mostra o que seria atualizado, sem aplicar mudanca.
21
+
22
+ .EXAMPLE
23
+ .\bin\jdi-update.ps1
24
+ .\bin\jdi-update.ps1 -DryRun
25
+ .\bin\jdi-update.ps1 -ForceSpecialists
26
+ #>
27
+ [CmdletBinding()]
28
+ param(
29
+ [switch]$ForceSpecialists,
30
+ [switch]$SkipSpecialists,
31
+ [switch]$DryRun
32
+ )
33
+
34
+ $ErrorActionPreference = 'Stop'
35
+
36
+ $Root = Split-Path -Parent $PSScriptRoot
37
+ $ProjectDir = (Get-Location).Path
38
+ $UserHome = if ($env:HOME) { $env:HOME } else { $env:USERPROFILE }
39
+
40
+ # Le versao nova do package.json shipado
41
+ $pkgJson = Get-Content (Join-Path $Root 'package.json') -Raw | ConvertFrom-Json
42
+ $NewVersion = $pkgJson.version
43
+
44
+ # Pre-flight
45
+ if (-not (Test-Path (Join-Path $ProjectDir '.jdi'))) {
46
+ Write-Host "Esse diretorio nao tem .jdi/. Use 'npx jdi-cli install <runtime>' pra primeira instalacao." -ForegroundColor Yellow
47
+ exit 1
48
+ }
49
+
50
+ # Le versao instalada
51
+ $VersionFile = Join-Path $ProjectDir '.jdi/VERSION'
52
+ $OldVersion = if (Test-Path $VersionFile) { (Get-Content $VersionFile -Raw).Trim() } else { 'unknown (pre-1.2.1)' }
53
+
54
+ Write-Host ""
55
+ Write-Host "JDI Update" -ForegroundColor Cyan
56
+ Write-Host " De: $OldVersion"
57
+ Write-Host " Para: $NewVersion"
58
+ Write-Host " Dir: $ProjectDir"
59
+ if ($DryRun) { Write-Host " Mode: DRY-RUN (sem mudancas)" -ForegroundColor Yellow }
60
+ Write-Host ""
61
+
62
+ if ($OldVersion -eq $NewVersion -and -not $DryRun) {
63
+ Write-Host "Ja na versao mais recente ($NewVersion). Use --force pra reinstalar mesmo assim." -ForegroundColor Green
64
+ exit 0
65
+ }
66
+
67
+ # =========================================================
68
+ # Detecta runtimes instalados
69
+ # =========================================================
70
+
71
+ $detected = @()
72
+
73
+ if ((Test-Path (Join-Path $ProjectDir '.claude')) -or (Test-Path (Join-Path $UserHome '.claude/agents/jdi-architect.md'))) {
74
+ $detected += 'claude'
75
+ }
76
+ if (Test-Path (Join-Path $ProjectDir '.github/agents')) {
77
+ # Verifica se tem agents JDI especificamente
78
+ if (Get-ChildItem (Join-Path $ProjectDir '.github/agents') -Filter 'jdi-*.agent.md' -ErrorAction SilentlyContinue | Select-Object -First 1) {
79
+ $detected += 'copilot'
80
+ }
81
+ }
82
+ if ((Test-Path (Join-Path $ProjectDir '.gemini/antigravity')) -or (Test-Path (Join-Path $UserHome '.gemini/antigravity/skills/jdi-architect'))) {
83
+ $detected += 'antigravity'
84
+ }
85
+ if ((Test-Path (Join-Path $ProjectDir '.opencode')) -or (Test-Path (Join-Path $UserHome '.config/opencode/agents/jdi-architect.md'))) {
86
+ $detected += 'opencode'
87
+ }
88
+
89
+ if ($detected.Count -eq 0) {
90
+ Write-Host "Nenhum runtime JDI detectado. Tem .jdi/ mas nao .claude/, .github/, .gemini/, .opencode/." -ForegroundColor Yellow
91
+ Write-Host "Use 'npx jdi-cli install <runtime>' pra instalar." -ForegroundColor Yellow
92
+ exit 1
93
+ }
94
+
95
+ Write-Host "Runtimes detectados: $($detected -join ', ')" -ForegroundColor Cyan
96
+ Write-Host ""
97
+
98
+ # =========================================================
99
+ # Atualiza runtime files (sobrescreve)
100
+ # =========================================================
101
+
102
+ $installScript = Join-Path $Root 'bin/jdi-install.ps1'
103
+
104
+ foreach ($runtime in $detected) {
105
+ # Detecta scope - se tem em user dir tbm, atualiza user; se so projeto, project
106
+ $userScopeMarker = switch ($runtime) {
107
+ 'claude' { Join-Path $UserHome '.claude/agents/jdi-architect.md' }
108
+ 'antigravity' { Join-Path $UserHome '.gemini/antigravity/skills/jdi-architect' }
109
+ 'opencode' { Join-Path $UserHome '.config/opencode/agents/jdi-architect.md' }
110
+ default { $null }
111
+ }
112
+
113
+ $hasUserScope = $userScopeMarker -and (Test-Path $userScopeMarker)
114
+ $projectMarker = switch ($runtime) {
115
+ 'claude' { Join-Path $ProjectDir '.claude/agents/jdi-architect.md' }
116
+ 'copilot' { Join-Path $ProjectDir '.github/agents/jdi-architect.agent.md' }
117
+ 'antigravity' { Join-Path $ProjectDir '.gemini/antigravity/skills/jdi-architect' }
118
+ 'opencode' { Join-Path $ProjectDir '.opencode/agents/jdi-architect.md' }
119
+ }
120
+ $hasProjectScope = Test-Path $projectMarker
121
+
122
+ if ($hasProjectScope) {
123
+ Write-Host "Atualizando $runtime (project scope)..." -ForegroundColor Cyan
124
+ if (-not $DryRun) {
125
+ & pwsh -NoProfile -ExecutionPolicy Bypass -File $installScript -Runtime $runtime -Scope project | Out-Null
126
+ } else {
127
+ Write-Host " [dry-run] copia runtimes/$runtime/* pra escopo project"
128
+ }
129
+ }
130
+
131
+ if ($hasUserScope) {
132
+ Write-Host "Atualizando $runtime (user scope)..." -ForegroundColor Cyan
133
+ if (-not $DryRun) {
134
+ & pwsh -NoProfile -ExecutionPolicy Bypass -File $installScript -Runtime $runtime -Scope user | Out-Null
135
+ } else {
136
+ Write-Host " [dry-run] copia runtimes/$runtime/* pra escopo user"
137
+ }
138
+ }
139
+ }
140
+
141
+ Write-Host ""
142
+
143
+ # =========================================================
144
+ # Detecta specialists e pergunta sobre regen
145
+ # =========================================================
146
+
147
+ $specialistDir = Join-Path $ProjectDir '.jdi/agents'
148
+ $specialists = @()
149
+
150
+ if (Test-Path $specialistDir) {
151
+ $doers = Get-ChildItem $specialistDir -Filter 'jdi-doer-*.md' -ErrorAction SilentlyContinue
152
+ $reviewers = Get-ChildItem $specialistDir -Filter 'jdi-reviewer-*.md' -ErrorAction SilentlyContinue
153
+ $specialists = @($doers) + @($reviewers)
154
+ }
155
+
156
+ if ($specialists.Count -gt 0) {
157
+ Write-Host "Specialists detectados em .jdi/agents/:" -ForegroundColor Cyan
158
+ foreach ($s in $specialists) { Write-Host " - $($s.Name)" }
159
+ Write-Host ""
160
+
161
+ # Detecta se template/skills mudaram - heuristica: skills_to_load presente?
162
+ $needsRegen = $false
163
+ foreach ($s in $specialists) {
164
+ $content = Get-Content $s.FullName -Raw
165
+ if ($content -notmatch '<skills_to_load>') {
166
+ $needsRegen = $true
167
+ break
168
+ }
169
+ }
170
+
171
+ if ($needsRegen) {
172
+ Write-Host "Specialists existentes NAO tem <skills_to_load> - foram gerados antes da 1.2.1." -ForegroundColor Yellow
173
+ Write-Host "Pra ativar skills universais (DRY/KISS/YAGNI/SOLID/Clean Code) via eager loading," -ForegroundColor Yellow
174
+ Write-Host "specialists precisam ser regenerados." -ForegroundColor Yellow
175
+ Write-Host ""
176
+
177
+ $shouldRegen = $false
178
+ if ($ForceSpecialists) {
179
+ $shouldRegen = $true
180
+ } elseif ($SkipSpecialists) {
181
+ $shouldRegen = $false
182
+ } else {
183
+ $resp = Read-Host "Regenerar specialists? Vai rodar /jdi-bootstrap (Y/n)"
184
+ $shouldRegen = ($resp -eq '' -or $resp -match '^[YySs]')
185
+ }
186
+
187
+ if ($shouldRegen) {
188
+ Write-Host ""
189
+ Write-Host "ACAO MANUAL NECESSARIA:" -ForegroundColor Yellow
190
+ Write-Host " Abra teu runtime e rode: /jdi-bootstrap" -ForegroundColor Cyan
191
+ Write-Host " Architect vai detectar specialists existentes e oferecer 'Recriar'." -ForegroundColor Cyan
192
+ Write-Host " Os specialists novos terao <skills_to_load> com as 5 universais wired." -ForegroundColor Cyan
193
+ } else {
194
+ Write-Host " Specialists mantidos como estao - skills universais ficam em modo discoverable only." -ForegroundColor DarkGray
195
+ }
196
+ } else {
197
+ Write-Host "Specialists ja tem <skills_to_load> - up to date." -ForegroundColor Green
198
+ }
199
+ }
200
+
201
+ # =========================================================
202
+ # Atualiza .jdi/VERSION
203
+ # =========================================================
204
+
205
+ if (-not $DryRun) {
206
+ Set-Content -Path $VersionFile -Value $NewVersion -Encoding UTF8 -NoNewline
207
+ }
208
+
209
+ Write-Host ""
210
+ Write-Host "JDI atualizado: $OldVersion -> $NewVersion" -ForegroundColor Green
211
+ if ($DryRun) {
212
+ Write-Host "(dry-run - nada foi mudado)" -ForegroundColor Yellow
213
+ }
214
+ Write-Host ""
215
+ Write-Host "Changelog: https://github.com/slipalison/jdi-cli/releases" -ForegroundColor DarkGray
@@ -0,0 +1,209 @@
1
+ #!/usr/bin/env bash
2
+ # jdi-update: atualiza JDI em projeto que ja tem JDI instalado.
3
+ #
4
+ # - Detecta runtimes instalados no projeto
5
+ # - Sobrescreve runtime files (agents, commands, skills) - shipped pelo JDI
6
+ # - NUNCA toca state files (.jdi/PROJECT.md, DECISIONS.md, etc)
7
+ # - Detecta specialists e pergunta se regenera
8
+ # - Atualiza .jdi/VERSION
9
+ #
10
+ # Flags:
11
+ # --force-specialists Regenera specialists sem perguntar
12
+ # --skip-specialists Nao mexe em specialists
13
+ # --dry-run Mostra o que faria
14
+
15
+ set -euo pipefail
16
+
17
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
18
+ PROJECT_DIR="$(pwd)"
19
+ USER_HOME="${HOME:-$HOME}"
20
+
21
+ FORCE_SPECIALISTS=0
22
+ SKIP_SPECIALISTS=0
23
+ DRY_RUN=0
24
+
25
+ for arg in "$@"; do
26
+ case "$arg" in
27
+ --force-specialists) FORCE_SPECIALISTS=1 ;;
28
+ --skip-specialists) SKIP_SPECIALISTS=1 ;;
29
+ --dry-run) DRY_RUN=1 ;;
30
+ esac
31
+ done
32
+
33
+ # Le versao nova do package.json shipado
34
+ NEW_VERSION=$(grep -oE '"version":\s*"[^"]+"' "$ROOT/package.json" | head -1 | sed 's/.*"\([^"]*\)"/\1/')
35
+
36
+ # Pre-flight
37
+ if [[ ! -d "$PROJECT_DIR/.jdi" ]]; then
38
+ echo "Esse diretorio nao tem .jdi/. Use 'npx jdi-cli install <runtime>' pra primeira instalacao."
39
+ exit 1
40
+ fi
41
+
42
+ # Le versao instalada
43
+ VERSION_FILE="$PROJECT_DIR/.jdi/VERSION"
44
+ if [[ -f "$VERSION_FILE" ]]; then
45
+ OLD_VERSION=$(cat "$VERSION_FILE" | tr -d '[:space:]')
46
+ else
47
+ OLD_VERSION="unknown (pre-1.2.1)"
48
+ fi
49
+
50
+ echo
51
+ echo "JDI Update"
52
+ echo " De: $OLD_VERSION"
53
+ echo " Para: $NEW_VERSION"
54
+ echo " Dir: $PROJECT_DIR"
55
+ [[ $DRY_RUN -eq 1 ]] && echo " Mode: DRY-RUN (sem mudancas)"
56
+ echo
57
+
58
+ if [[ "$OLD_VERSION" == "$NEW_VERSION" && $DRY_RUN -eq 0 ]]; then
59
+ echo "Ja na versao mais recente ($NEW_VERSION)."
60
+ exit 0
61
+ fi
62
+
63
+ # =========================================================
64
+ # Detecta runtimes instalados
65
+ # =========================================================
66
+
67
+ detected=()
68
+
69
+ if [[ -d "$PROJECT_DIR/.claude" ]] || [[ -f "$USER_HOME/.claude/agents/jdi-architect.md" ]]; then
70
+ detected+=("claude")
71
+ fi
72
+
73
+ if [[ -d "$PROJECT_DIR/.github/agents" ]] && ls "$PROJECT_DIR/.github/agents/jdi-"*.agent.md >/dev/null 2>&1; then
74
+ detected+=("copilot")
75
+ fi
76
+
77
+ if [[ -d "$PROJECT_DIR/.gemini/antigravity" ]] || [[ -d "$USER_HOME/.gemini/antigravity/skills/jdi-architect" ]]; then
78
+ detected+=("antigravity")
79
+ fi
80
+
81
+ if [[ -d "$PROJECT_DIR/.opencode" ]] || [[ -f "$USER_HOME/.config/opencode/agents/jdi-architect.md" ]]; then
82
+ detected+=("opencode")
83
+ fi
84
+
85
+ if [[ ${#detected[@]} -eq 0 ]]; then
86
+ echo "Nenhum runtime JDI detectado. Tem .jdi/ mas nao .claude/, .github/, .gemini/, .opencode/."
87
+ echo "Use 'npx jdi-cli install <runtime>' pra instalar."
88
+ exit 1
89
+ fi
90
+
91
+ echo "Runtimes detectados: ${detected[*]}"
92
+ echo
93
+
94
+ # =========================================================
95
+ # Atualiza runtime files (sobrescreve via install)
96
+ # =========================================================
97
+
98
+ INSTALL_SCRIPT="$ROOT/bin/jdi-install.sh"
99
+
100
+ for runtime in "${detected[@]}"; do
101
+ # Detecta scope - se tem em user dir, atualiza user; se tem em project, atualiza project
102
+ case "$runtime" in
103
+ claude)
104
+ USER_MARKER="$USER_HOME/.claude/agents/jdi-architect.md"
105
+ PROJ_MARKER="$PROJECT_DIR/.claude/agents/jdi-architect.md"
106
+ ;;
107
+ copilot)
108
+ USER_MARKER=""
109
+ PROJ_MARKER="$PROJECT_DIR/.github/agents/jdi-architect.agent.md"
110
+ ;;
111
+ antigravity)
112
+ USER_MARKER="$USER_HOME/.gemini/antigravity/skills/jdi-architect"
113
+ PROJ_MARKER="$PROJECT_DIR/.gemini/antigravity/skills/jdi-architect"
114
+ ;;
115
+ opencode)
116
+ USER_MARKER="$USER_HOME/.config/opencode/agents/jdi-architect.md"
117
+ PROJ_MARKER="$PROJECT_DIR/.opencode/agents/jdi-architect.md"
118
+ ;;
119
+ esac
120
+
121
+ if [[ -e "$PROJ_MARKER" ]]; then
122
+ echo "Atualizando $runtime (project scope)..."
123
+ if [[ $DRY_RUN -eq 0 ]]; then
124
+ bash "$INSTALL_SCRIPT" "$runtime" --scope project >/dev/null
125
+ else
126
+ echo " [dry-run] copia runtimes/$runtime/* pra escopo project"
127
+ fi
128
+ fi
129
+
130
+ if [[ -n "$USER_MARKER" && -e "$USER_MARKER" ]]; then
131
+ echo "Atualizando $runtime (user scope)..."
132
+ if [[ $DRY_RUN -eq 0 ]]; then
133
+ bash "$INSTALL_SCRIPT" "$runtime" --scope user >/dev/null
134
+ else
135
+ echo " [dry-run] copia runtimes/$runtime/* pra escopo user"
136
+ fi
137
+ fi
138
+ done
139
+
140
+ echo
141
+
142
+ # =========================================================
143
+ # Detecta specialists e oferece regen
144
+ # =========================================================
145
+
146
+ specialist_dir="$PROJECT_DIR/.jdi/agents"
147
+ specialists=()
148
+
149
+ if [[ -d "$specialist_dir" ]]; then
150
+ while IFS= read -r f; do specialists+=("$f"); done < <(ls "$specialist_dir"/jdi-doer-*.md "$specialist_dir"/jdi-reviewer-*.md 2>/dev/null || true)
151
+ fi
152
+
153
+ if [[ ${#specialists[@]} -gt 0 ]]; then
154
+ echo "Specialists detectados em .jdi/agents/:"
155
+ for s in "${specialists[@]}"; do echo " - $(basename "$s")"; done
156
+ echo
157
+
158
+ # Heuristica: specialists novos tem <skills_to_load>
159
+ needs_regen=0
160
+ for s in "${specialists[@]}"; do
161
+ if ! grep -q '<skills_to_load>' "$s"; then
162
+ needs_regen=1
163
+ break
164
+ fi
165
+ done
166
+
167
+ if [[ $needs_regen -eq 1 ]]; then
168
+ echo "Specialists existentes NAO tem <skills_to_load> - foram gerados antes da 1.2.1."
169
+ echo "Pra ativar skills universais (DRY/KISS/YAGNI/SOLID/Clean Code) via eager loading,"
170
+ echo "specialists precisam ser regenerados."
171
+ echo
172
+
173
+ should_regen=0
174
+ if [[ $FORCE_SPECIALISTS -eq 1 ]]; then
175
+ should_regen=1
176
+ elif [[ $SKIP_SPECIALISTS -eq 1 ]]; then
177
+ should_regen=0
178
+ else
179
+ read -r -p "Regenerar specialists? Vai rodar /jdi-bootstrap (Y/n) " resp
180
+ if [[ -z "$resp" || "$resp" =~ ^[YySs] ]]; then should_regen=1; fi
181
+ fi
182
+
183
+ if [[ $should_regen -eq 1 ]]; then
184
+ echo
185
+ echo "ACAO MANUAL NECESSARIA:"
186
+ echo " Abra teu runtime e rode: /jdi-bootstrap"
187
+ echo " Architect vai detectar specialists existentes e oferecer 'Recriar'."
188
+ echo " Os specialists novos terao <skills_to_load> com as 5 universais wired."
189
+ else
190
+ echo " Specialists mantidos - skills universais ficam em modo discoverable only."
191
+ fi
192
+ else
193
+ echo "Specialists ja tem <skills_to_load> - up to date."
194
+ fi
195
+ fi
196
+
197
+ # =========================================================
198
+ # Atualiza .jdi/VERSION
199
+ # =========================================================
200
+
201
+ if [[ $DRY_RUN -eq 0 ]]; then
202
+ printf '%s' "$NEW_VERSION" > "$VERSION_FILE"
203
+ fi
204
+
205
+ echo
206
+ echo "JDI atualizado: $OLD_VERSION -> $NEW_VERSION"
207
+ [[ $DRY_RUN -eq 1 ]] && echo "(dry-run - nada foi mudado)"
208
+ echo
209
+ echo "Changelog: https://github.com/slipalison/jdi-cli/releases"