intent-planner 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (334) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +225 -0
  3. package/README.md +225 -0
  4. package/bin/cli.mjs +289 -0
  5. package/package.json +46 -0
  6. package/src/install.mjs +527 -0
  7. package/templates/en/agents/claude/CLAUDE.md +62 -0
  8. package/templates/en/agents/codex/AGENTS.md +62 -0
  9. package/templates/en/agents/gemini/GEMINI.md +62 -0
  10. package/templates/en/claude/skills/CONTRACT.md +86 -0
  11. package/templates/en/claude/skills/intent-compass/SKILL.md +55 -0
  12. package/templates/en/claude/skills/intent-compass/rules/algo-qoc.md +62 -0
  13. package/templates/en/claude/skills/intent-compass/rules/constraint-surfacing.md +41 -0
  14. package/templates/en/claude/skills/intent-discover/SKILL.md +63 -0
  15. package/templates/en/claude/skills/intent-discover/rules/algo-drift-analysis.md +34 -0
  16. package/templates/en/claude/skills/intent-discover/rules/algo-gore-lite.md +35 -0
  17. package/templates/en/claude/skills/intent-discover/rules/algo-impact-analysis.md +37 -0
  18. package/templates/en/claude/skills/intent-discover/rules/algo-intent-recovery.md +39 -0
  19. package/templates/en/claude/skills/intent-discover/rules/designer-questions.md +78 -0
  20. package/templates/en/claude/skills/intent-discover/rules/drift-terrain.md +105 -0
  21. package/templates/en/claude/skills/intent-discover/rules/mode-selection.md +31 -0
  22. package/templates/en/claude/skills/intent-export-cc-sdd/SKILL.md +88 -0
  23. package/templates/en/claude/skills/intent-export-cc-sdd/rules/drift-export-check.md +75 -0
  24. package/templates/en/claude/skills/intent-export-cc-sdd/rules/export-questions.md +23 -0
  25. package/templates/en/claude/skills/intent-export-cc-sdd/rules/map-cc-sdd.md +62 -0
  26. package/templates/en/claude/skills/intent-export-openspec/SKILL.md +90 -0
  27. package/templates/en/claude/skills/intent-export-openspec/rules/drift-export-check.md +50 -0
  28. package/templates/en/claude/skills/intent-export-openspec/rules/export-questions.md +23 -0
  29. package/templates/en/claude/skills/intent-export-openspec/rules/map-openspec.md +75 -0
  30. package/templates/en/claude/skills/intent-from-spec/SKILL.md +60 -0
  31. package/templates/en/claude/skills/intent-from-spec/rules/extract-intent.md +56 -0
  32. package/templates/en/claude/skills/intent-from-spec/rules/gap-readout.md +54 -0
  33. package/templates/en/claude/skills/intent-from-spec/rules/load-bearing.md +48 -0
  34. package/templates/en/claude/skills/intent-from-spec/rules/omission-recap.md +42 -0
  35. package/templates/en/claude/skills/intent-improve/SKILL.md +70 -0
  36. package/templates/en/claude/skills/intent-improve/rules/improve-axes.md +121 -0
  37. package/templates/en/claude/skills/intent-overview/SKILL.md +63 -0
  38. package/templates/en/claude/skills/intent-overview/rules/aggregate-sources.md +61 -0
  39. package/templates/en/claude/skills/intent-overview/rules/gap-readout.md +54 -0
  40. package/templates/en/claude/skills/intent-overview/rules/mermaid-tree.md +78 -0
  41. package/templates/en/claude/skills/intent-overview/rules/progress-readout.md +119 -0
  42. package/templates/en/claude/skills/intent-packets/SKILL.md +97 -0
  43. package/templates/en/claude/skills/intent-packets/rules/algo-additive-slicing.md +55 -0
  44. package/templates/en/claude/skills/intent-packets/rules/algo-characterization-test.md +40 -0
  45. package/templates/en/claude/skills/intent-packets/rules/algo-example-mapping.md +47 -0
  46. package/templates/en/claude/skills/intent-packets/rules/algo-migration-slicing.md +47 -0
  47. package/templates/en/claude/skills/intent-packets/rules/decision-slots.md +88 -0
  48. package/templates/en/claude/skills/intent-packets/rules/export-route.md +54 -0
  49. package/templates/en/claude/skills/intent-packets/rules/first-packet.md +35 -0
  50. package/templates/en/claude/skills/intent-packets/rules/packet-format.md +207 -0
  51. package/templates/en/claude/skills/intent-packets/rules/walking-skeleton.md +35 -0
  52. package/templates/en/claude/skills/intent-release-note/SKILL.md +58 -0
  53. package/templates/en/claude/skills/intent-release-note/rules/format-changelog.md +40 -0
  54. package/templates/en/claude/skills/intent-release-note/rules/format-github-releases.md +41 -0
  55. package/templates/en/claude/skills/intent-release-note/rules/format-select.md +32 -0
  56. package/templates/en/claude/skills/intent-release-note/rules/source-scope.md +42 -0
  57. package/templates/en/claude/skills/intent-status/SKILL.md +171 -0
  58. package/templates/en/claude/skills/intent-status/rules/decision-table.md +47 -0
  59. package/templates/en/claude/skills/intent-to-spec/SKILL.md +68 -0
  60. package/templates/en/claude/skills/intent-to-spec/rules/fabrication-guard.md +41 -0
  61. package/templates/en/claude/skills/intent-to-spec/rules/format-integrated.md +42 -0
  62. package/templates/en/claude/skills/intent-to-spec/rules/format-nonprogram.md +45 -0
  63. package/templates/en/claude/skills/intent-to-spec/rules/format-upstream.md +41 -0
  64. package/templates/en/claude/skills/intent-to-spec/rules/source-scope.md +50 -0
  65. package/templates/en/claude/skills/intent-validate/SKILL.md +80 -0
  66. package/templates/en/claude/skills/intent-validate/rules/validate-checks.md +121 -0
  67. package/templates/en/claude/skills/intent-writeback/SKILL.md +71 -0
  68. package/templates/en/claude/skills/intent-writeback/rules/writeback-protocol.md +139 -0
  69. package/templates/en/codex/skills/CONTRACT.md +77 -0
  70. package/templates/en/codex/skills/intent-compass/SKILL.md +52 -0
  71. package/templates/en/codex/skills/intent-compass/rules/algo-qoc.md +62 -0
  72. package/templates/en/codex/skills/intent-compass/rules/constraint-surfacing.md +41 -0
  73. package/templates/en/codex/skills/intent-discover/SKILL.md +60 -0
  74. package/templates/en/codex/skills/intent-discover/rules/algo-drift-analysis.md +34 -0
  75. package/templates/en/codex/skills/intent-discover/rules/algo-gore-lite.md +35 -0
  76. package/templates/en/codex/skills/intent-discover/rules/algo-impact-analysis.md +37 -0
  77. package/templates/en/codex/skills/intent-discover/rules/algo-intent-recovery.md +39 -0
  78. package/templates/en/codex/skills/intent-discover/rules/designer-questions.md +78 -0
  79. package/templates/en/codex/skills/intent-discover/rules/drift-terrain.md +105 -0
  80. package/templates/en/codex/skills/intent-discover/rules/mode-selection.md +31 -0
  81. package/templates/en/codex/skills/intent-export-cc-sdd/SKILL.md +85 -0
  82. package/templates/en/codex/skills/intent-export-cc-sdd/rules/drift-export-check.md +75 -0
  83. package/templates/en/codex/skills/intent-export-cc-sdd/rules/export-questions.md +23 -0
  84. package/templates/en/codex/skills/intent-export-cc-sdd/rules/map-cc-sdd.md +62 -0
  85. package/templates/en/codex/skills/intent-export-openspec/SKILL.md +87 -0
  86. package/templates/en/codex/skills/intent-export-openspec/rules/drift-export-check.md +50 -0
  87. package/templates/en/codex/skills/intent-export-openspec/rules/export-questions.md +23 -0
  88. package/templates/en/codex/skills/intent-export-openspec/rules/map-openspec.md +75 -0
  89. package/templates/en/codex/skills/intent-from-spec/SKILL.md +58 -0
  90. package/templates/en/codex/skills/intent-from-spec/rules/extract-intent.md +56 -0
  91. package/templates/en/codex/skills/intent-from-spec/rules/gap-readout.md +54 -0
  92. package/templates/en/codex/skills/intent-from-spec/rules/load-bearing.md +48 -0
  93. package/templates/en/codex/skills/intent-from-spec/rules/omission-recap.md +42 -0
  94. package/templates/en/codex/skills/intent-improve/SKILL.md +67 -0
  95. package/templates/en/codex/skills/intent-improve/rules/improve-axes.md +121 -0
  96. package/templates/en/codex/skills/intent-overview/SKILL.md +61 -0
  97. package/templates/en/codex/skills/intent-overview/rules/aggregate-sources.md +61 -0
  98. package/templates/en/codex/skills/intent-overview/rules/gap-readout.md +54 -0
  99. package/templates/en/codex/skills/intent-overview/rules/mermaid-tree.md +78 -0
  100. package/templates/en/codex/skills/intent-overview/rules/progress-readout.md +119 -0
  101. package/templates/en/codex/skills/intent-packets/SKILL.md +94 -0
  102. package/templates/en/codex/skills/intent-packets/rules/algo-additive-slicing.md +55 -0
  103. package/templates/en/codex/skills/intent-packets/rules/algo-characterization-test.md +40 -0
  104. package/templates/en/codex/skills/intent-packets/rules/algo-example-mapping.md +47 -0
  105. package/templates/en/codex/skills/intent-packets/rules/algo-migration-slicing.md +47 -0
  106. package/templates/en/codex/skills/intent-packets/rules/decision-slots.md +88 -0
  107. package/templates/en/codex/skills/intent-packets/rules/export-route.md +54 -0
  108. package/templates/en/codex/skills/intent-packets/rules/first-packet.md +35 -0
  109. package/templates/en/codex/skills/intent-packets/rules/packet-format.md +207 -0
  110. package/templates/en/codex/skills/intent-packets/rules/walking-skeleton.md +35 -0
  111. package/templates/en/codex/skills/intent-release-note/SKILL.md +56 -0
  112. package/templates/en/codex/skills/intent-release-note/rules/format-changelog.md +40 -0
  113. package/templates/en/codex/skills/intent-release-note/rules/format-github-releases.md +41 -0
  114. package/templates/en/codex/skills/intent-release-note/rules/format-select.md +32 -0
  115. package/templates/en/codex/skills/intent-release-note/rules/source-scope.md +42 -0
  116. package/templates/en/codex/skills/intent-status/SKILL.md +169 -0
  117. package/templates/en/codex/skills/intent-status/rules/decision-table.md +47 -0
  118. package/templates/en/codex/skills/intent-to-spec/SKILL.md +66 -0
  119. package/templates/en/codex/skills/intent-to-spec/rules/fabrication-guard.md +41 -0
  120. package/templates/en/codex/skills/intent-to-spec/rules/format-integrated.md +42 -0
  121. package/templates/en/codex/skills/intent-to-spec/rules/format-nonprogram.md +45 -0
  122. package/templates/en/codex/skills/intent-to-spec/rules/format-upstream.md +41 -0
  123. package/templates/en/codex/skills/intent-to-spec/rules/source-scope.md +50 -0
  124. package/templates/en/codex/skills/intent-validate/SKILL.md +78 -0
  125. package/templates/en/codex/skills/intent-validate/rules/validate-checks.md +121 -0
  126. package/templates/en/codex/skills/intent-writeback/SKILL.md +68 -0
  127. package/templates/en/codex/skills/intent-writeback/rules/writeback-protocol.md +139 -0
  128. package/templates/en/intent/README.md +118 -0
  129. package/templates/en/intent/cc-sdd/README.md +28 -0
  130. package/templates/en/intent/compass-archive/README.md +9 -0
  131. package/templates/en/intent/compass-archive/archive/.gitkeep +0 -0
  132. package/templates/en/intent/compass-archive.md +7 -0
  133. package/templates/en/intent/constraint-library.md +32 -0
  134. package/templates/en/intent/constraint-starters.md +58 -0
  135. package/templates/en/intent/context-cost-cues.md +55 -0
  136. package/templates/en/intent/deltas/README.md +11 -0
  137. package/templates/en/intent/deltas/archive/.gitkeep +0 -0
  138. package/templates/en/intent/deltas.md +34 -0
  139. package/templates/en/intent/drift-log/README.md +11 -0
  140. package/templates/en/intent/drift-log/archive/.gitkeep +0 -0
  141. package/templates/en/intent/drift-log.md +41 -0
  142. package/templates/en/intent/drift-patterns.md +68 -0
  143. package/templates/en/intent/export-log/README.md +12 -0
  144. package/templates/en/intent/export-log/archive/.gitkeep +0 -0
  145. package/templates/en/intent/export-log.md +6 -0
  146. package/templates/en/intent/glossary.md +23 -0
  147. package/templates/en/intent/intent-compass.md +55 -0
  148. package/templates/en/intent/intent-tree.md +59 -0
  149. package/templates/en/intent/milestones/README.md +10 -0
  150. package/templates/en/intent/milestones/archive/.gitkeep +0 -0
  151. package/templates/en/intent/milestones.md +22 -0
  152. package/templates/en/intent/mode.local.md +23 -0
  153. package/templates/en/intent/mode.md +32 -0
  154. package/templates/en/intent/modes/README.md +28 -0
  155. package/templates/en/intent/modes/behavior-unknown.md +57 -0
  156. package/templates/en/intent/modes/feature-growth.md +57 -0
  157. package/templates/en/intent/modes/non-code.md +46 -0
  158. package/templates/en/intent/modes/refactor.md +56 -0
  159. package/templates/en/intent/modes/standard.md +50 -0
  160. package/templates/en/intent/nl-spec/README.md +18 -0
  161. package/templates/en/intent/openspec/proposal.md +15 -0
  162. package/templates/en/intent/openspec/spec-delta.md +25 -0
  163. package/templates/en/intent/overview/README.md +18 -0
  164. package/templates/en/intent/packets/README.md +29 -0
  165. package/templates/en/intent/packets/index.md +6 -0
  166. package/templates/en/intent/packets/plan.md +23 -0
  167. package/templates/en/intent/release-note/README.md +18 -0
  168. package/templates/en/intent/scripts/intent-check.mjs +786 -0
  169. package/templates/en/intent/scripts/pre-push +27 -0
  170. package/templates/en/intent/spec-ingest/README.md +18 -0
  171. package/templates/ja/agents/claude/CLAUDE.md +62 -0
  172. package/templates/ja/agents/codex/AGENTS.md +62 -0
  173. package/templates/ja/agents/gemini/GEMINI.md +62 -0
  174. package/templates/ja/claude/skills/CONTRACT.md +90 -0
  175. package/templates/ja/claude/skills/intent-compass/SKILL.md +55 -0
  176. package/templates/ja/claude/skills/intent-compass/rules/algo-qoc.md +62 -0
  177. package/templates/ja/claude/skills/intent-compass/rules/constraint-surfacing.md +41 -0
  178. package/templates/ja/claude/skills/intent-discover/SKILL.md +63 -0
  179. package/templates/ja/claude/skills/intent-discover/rules/algo-drift-analysis.md +34 -0
  180. package/templates/ja/claude/skills/intent-discover/rules/algo-gore-lite.md +35 -0
  181. package/templates/ja/claude/skills/intent-discover/rules/algo-impact-analysis.md +37 -0
  182. package/templates/ja/claude/skills/intent-discover/rules/algo-intent-recovery.md +39 -0
  183. package/templates/ja/claude/skills/intent-discover/rules/designer-questions.md +78 -0
  184. package/templates/ja/claude/skills/intent-discover/rules/drift-terrain.md +105 -0
  185. package/templates/ja/claude/skills/intent-discover/rules/mode-selection.md +31 -0
  186. package/templates/ja/claude/skills/intent-export-cc-sdd/SKILL.md +88 -0
  187. package/templates/ja/claude/skills/intent-export-cc-sdd/rules/drift-export-check.md +75 -0
  188. package/templates/ja/claude/skills/intent-export-cc-sdd/rules/export-questions.md +23 -0
  189. package/templates/ja/claude/skills/intent-export-cc-sdd/rules/map-cc-sdd.md +62 -0
  190. package/templates/ja/claude/skills/intent-export-openspec/SKILL.md +90 -0
  191. package/templates/ja/claude/skills/intent-export-openspec/rules/drift-export-check.md +50 -0
  192. package/templates/ja/claude/skills/intent-export-openspec/rules/export-questions.md +23 -0
  193. package/templates/ja/claude/skills/intent-export-openspec/rules/map-openspec.md +75 -0
  194. package/templates/ja/claude/skills/intent-from-spec/SKILL.md +60 -0
  195. package/templates/ja/claude/skills/intent-from-spec/rules/extract-intent.md +56 -0
  196. package/templates/ja/claude/skills/intent-from-spec/rules/gap-readout.md +54 -0
  197. package/templates/ja/claude/skills/intent-from-spec/rules/load-bearing.md +48 -0
  198. package/templates/ja/claude/skills/intent-from-spec/rules/omission-recap.md +42 -0
  199. package/templates/ja/claude/skills/intent-improve/SKILL.md +70 -0
  200. package/templates/ja/claude/skills/intent-improve/rules/improve-axes.md +121 -0
  201. package/templates/ja/claude/skills/intent-overview/SKILL.md +63 -0
  202. package/templates/ja/claude/skills/intent-overview/rules/aggregate-sources.md +61 -0
  203. package/templates/ja/claude/skills/intent-overview/rules/gap-readout.md +54 -0
  204. package/templates/ja/claude/skills/intent-overview/rules/mermaid-tree.md +78 -0
  205. package/templates/ja/claude/skills/intent-overview/rules/progress-readout.md +119 -0
  206. package/templates/ja/claude/skills/intent-packets/SKILL.md +97 -0
  207. package/templates/ja/claude/skills/intent-packets/rules/algo-additive-slicing.md +55 -0
  208. package/templates/ja/claude/skills/intent-packets/rules/algo-characterization-test.md +40 -0
  209. package/templates/ja/claude/skills/intent-packets/rules/algo-example-mapping.md +47 -0
  210. package/templates/ja/claude/skills/intent-packets/rules/algo-migration-slicing.md +47 -0
  211. package/templates/ja/claude/skills/intent-packets/rules/decision-slots.md +88 -0
  212. package/templates/ja/claude/skills/intent-packets/rules/export-route.md +54 -0
  213. package/templates/ja/claude/skills/intent-packets/rules/first-packet.md +35 -0
  214. package/templates/ja/claude/skills/intent-packets/rules/packet-format.md +207 -0
  215. package/templates/ja/claude/skills/intent-packets/rules/walking-skeleton.md +35 -0
  216. package/templates/ja/claude/skills/intent-release-note/SKILL.md +58 -0
  217. package/templates/ja/claude/skills/intent-release-note/rules/format-changelog.md +40 -0
  218. package/templates/ja/claude/skills/intent-release-note/rules/format-github-releases.md +41 -0
  219. package/templates/ja/claude/skills/intent-release-note/rules/format-select.md +32 -0
  220. package/templates/ja/claude/skills/intent-release-note/rules/source-scope.md +42 -0
  221. package/templates/ja/claude/skills/intent-status/SKILL.md +171 -0
  222. package/templates/ja/claude/skills/intent-status/rules/decision-table.md +47 -0
  223. package/templates/ja/claude/skills/intent-to-spec/SKILL.md +68 -0
  224. package/templates/ja/claude/skills/intent-to-spec/rules/fabrication-guard.md +41 -0
  225. package/templates/ja/claude/skills/intent-to-spec/rules/format-integrated.md +42 -0
  226. package/templates/ja/claude/skills/intent-to-spec/rules/format-nonprogram.md +45 -0
  227. package/templates/ja/claude/skills/intent-to-spec/rules/format-upstream.md +41 -0
  228. package/templates/ja/claude/skills/intent-to-spec/rules/source-scope.md +50 -0
  229. package/templates/ja/claude/skills/intent-validate/SKILL.md +80 -0
  230. package/templates/ja/claude/skills/intent-validate/rules/validate-checks.md +121 -0
  231. package/templates/ja/claude/skills/intent-writeback/SKILL.md +71 -0
  232. package/templates/ja/claude/skills/intent-writeback/rules/writeback-protocol.md +139 -0
  233. package/templates/ja/codex/skills/CONTRACT.md +81 -0
  234. package/templates/ja/codex/skills/intent-compass/SKILL.md +52 -0
  235. package/templates/ja/codex/skills/intent-compass/rules/algo-qoc.md +62 -0
  236. package/templates/ja/codex/skills/intent-compass/rules/constraint-surfacing.md +41 -0
  237. package/templates/ja/codex/skills/intent-discover/SKILL.md +60 -0
  238. package/templates/ja/codex/skills/intent-discover/rules/algo-drift-analysis.md +34 -0
  239. package/templates/ja/codex/skills/intent-discover/rules/algo-gore-lite.md +35 -0
  240. package/templates/ja/codex/skills/intent-discover/rules/algo-impact-analysis.md +37 -0
  241. package/templates/ja/codex/skills/intent-discover/rules/algo-intent-recovery.md +39 -0
  242. package/templates/ja/codex/skills/intent-discover/rules/designer-questions.md +78 -0
  243. package/templates/ja/codex/skills/intent-discover/rules/drift-terrain.md +105 -0
  244. package/templates/ja/codex/skills/intent-discover/rules/mode-selection.md +31 -0
  245. package/templates/ja/codex/skills/intent-export-cc-sdd/SKILL.md +85 -0
  246. package/templates/ja/codex/skills/intent-export-cc-sdd/rules/drift-export-check.md +75 -0
  247. package/templates/ja/codex/skills/intent-export-cc-sdd/rules/export-questions.md +23 -0
  248. package/templates/ja/codex/skills/intent-export-cc-sdd/rules/map-cc-sdd.md +62 -0
  249. package/templates/ja/codex/skills/intent-export-openspec/SKILL.md +87 -0
  250. package/templates/ja/codex/skills/intent-export-openspec/rules/drift-export-check.md +50 -0
  251. package/templates/ja/codex/skills/intent-export-openspec/rules/export-questions.md +23 -0
  252. package/templates/ja/codex/skills/intent-export-openspec/rules/map-openspec.md +75 -0
  253. package/templates/ja/codex/skills/intent-from-spec/SKILL.md +58 -0
  254. package/templates/ja/codex/skills/intent-from-spec/rules/extract-intent.md +56 -0
  255. package/templates/ja/codex/skills/intent-from-spec/rules/gap-readout.md +54 -0
  256. package/templates/ja/codex/skills/intent-from-spec/rules/load-bearing.md +48 -0
  257. package/templates/ja/codex/skills/intent-from-spec/rules/omission-recap.md +42 -0
  258. package/templates/ja/codex/skills/intent-improve/SKILL.md +67 -0
  259. package/templates/ja/codex/skills/intent-improve/rules/improve-axes.md +121 -0
  260. package/templates/ja/codex/skills/intent-overview/SKILL.md +61 -0
  261. package/templates/ja/codex/skills/intent-overview/rules/aggregate-sources.md +61 -0
  262. package/templates/ja/codex/skills/intent-overview/rules/gap-readout.md +54 -0
  263. package/templates/ja/codex/skills/intent-overview/rules/mermaid-tree.md +78 -0
  264. package/templates/ja/codex/skills/intent-overview/rules/progress-readout.md +119 -0
  265. package/templates/ja/codex/skills/intent-packets/SKILL.md +94 -0
  266. package/templates/ja/codex/skills/intent-packets/rules/algo-additive-slicing.md +55 -0
  267. package/templates/ja/codex/skills/intent-packets/rules/algo-characterization-test.md +40 -0
  268. package/templates/ja/codex/skills/intent-packets/rules/algo-example-mapping.md +47 -0
  269. package/templates/ja/codex/skills/intent-packets/rules/algo-migration-slicing.md +47 -0
  270. package/templates/ja/codex/skills/intent-packets/rules/decision-slots.md +88 -0
  271. package/templates/ja/codex/skills/intent-packets/rules/export-route.md +54 -0
  272. package/templates/ja/codex/skills/intent-packets/rules/first-packet.md +35 -0
  273. package/templates/ja/codex/skills/intent-packets/rules/packet-format.md +207 -0
  274. package/templates/ja/codex/skills/intent-packets/rules/walking-skeleton.md +35 -0
  275. package/templates/ja/codex/skills/intent-release-note/SKILL.md +56 -0
  276. package/templates/ja/codex/skills/intent-release-note/rules/format-changelog.md +40 -0
  277. package/templates/ja/codex/skills/intent-release-note/rules/format-github-releases.md +41 -0
  278. package/templates/ja/codex/skills/intent-release-note/rules/format-select.md +32 -0
  279. package/templates/ja/codex/skills/intent-release-note/rules/source-scope.md +42 -0
  280. package/templates/ja/codex/skills/intent-status/SKILL.md +169 -0
  281. package/templates/ja/codex/skills/intent-status/rules/decision-table.md +47 -0
  282. package/templates/ja/codex/skills/intent-to-spec/SKILL.md +66 -0
  283. package/templates/ja/codex/skills/intent-to-spec/rules/fabrication-guard.md +41 -0
  284. package/templates/ja/codex/skills/intent-to-spec/rules/format-integrated.md +42 -0
  285. package/templates/ja/codex/skills/intent-to-spec/rules/format-nonprogram.md +45 -0
  286. package/templates/ja/codex/skills/intent-to-spec/rules/format-upstream.md +41 -0
  287. package/templates/ja/codex/skills/intent-to-spec/rules/source-scope.md +50 -0
  288. package/templates/ja/codex/skills/intent-validate/SKILL.md +78 -0
  289. package/templates/ja/codex/skills/intent-validate/rules/validate-checks.md +121 -0
  290. package/templates/ja/codex/skills/intent-writeback/SKILL.md +68 -0
  291. package/templates/ja/codex/skills/intent-writeback/rules/writeback-protocol.md +139 -0
  292. package/templates/ja/intent/README.md +118 -0
  293. package/templates/ja/intent/cc-sdd/README.md +28 -0
  294. package/templates/ja/intent/compass-archive/README.md +9 -0
  295. package/templates/ja/intent/compass-archive/archive/.gitkeep +0 -0
  296. package/templates/ja/intent/compass-archive.md +7 -0
  297. package/templates/ja/intent/constraint-library.md +32 -0
  298. package/templates/ja/intent/constraint-starters.md +58 -0
  299. package/templates/ja/intent/context-cost-cues.md +55 -0
  300. package/templates/ja/intent/deltas/README.md +11 -0
  301. package/templates/ja/intent/deltas/archive/.gitkeep +0 -0
  302. package/templates/ja/intent/deltas.md +34 -0
  303. package/templates/ja/intent/drift-log/README.md +11 -0
  304. package/templates/ja/intent/drift-log/archive/.gitkeep +0 -0
  305. package/templates/ja/intent/drift-log.md +41 -0
  306. package/templates/ja/intent/drift-patterns.md +68 -0
  307. package/templates/ja/intent/export-log/README.md +12 -0
  308. package/templates/ja/intent/export-log/archive/.gitkeep +0 -0
  309. package/templates/ja/intent/export-log.md +6 -0
  310. package/templates/ja/intent/glossary.md +23 -0
  311. package/templates/ja/intent/intent-compass.md +55 -0
  312. package/templates/ja/intent/intent-tree.md +59 -0
  313. package/templates/ja/intent/milestones/README.md +10 -0
  314. package/templates/ja/intent/milestones/archive/.gitkeep +0 -0
  315. package/templates/ja/intent/milestones.md +22 -0
  316. package/templates/ja/intent/mode.local.md +23 -0
  317. package/templates/ja/intent/mode.md +32 -0
  318. package/templates/ja/intent/modes/README.md +28 -0
  319. package/templates/ja/intent/modes/behavior-unknown.md +57 -0
  320. package/templates/ja/intent/modes/feature-growth.md +57 -0
  321. package/templates/ja/intent/modes/non-code.md +46 -0
  322. package/templates/ja/intent/modes/refactor.md +56 -0
  323. package/templates/ja/intent/modes/standard.md +50 -0
  324. package/templates/ja/intent/nl-spec/README.md +18 -0
  325. package/templates/ja/intent/openspec/proposal.md +15 -0
  326. package/templates/ja/intent/openspec/spec-delta.md +25 -0
  327. package/templates/ja/intent/overview/README.md +18 -0
  328. package/templates/ja/intent/packets/README.md +29 -0
  329. package/templates/ja/intent/packets/index.md +6 -0
  330. package/templates/ja/intent/packets/plan.md +23 -0
  331. package/templates/ja/intent/release-note/README.md +18 -0
  332. package/templates/ja/intent/scripts/intent-check.mjs +786 -0
  333. package/templates/ja/intent/scripts/pre-push +27 -0
  334. package/templates/ja/intent/spec-ingest/README.md +18 -0
@@ -0,0 +1,527 @@
1
+ // intent-planner installer
2
+ //
3
+ // 知能は core 側 (skill) にあり、このモジュールはファイル配置に徹する。
4
+ // 非破壊性は computeCopyPlan の純粋関数で構造的に保証する:
5
+ // 計画に現れるパスは templates/ 由来のものだけなので、.kiro/ や kiro-* は触れられない。
6
+ // fs.cpSync は使わない (ファイル単位のスキップ判定と両立しないため)。
7
+
8
+ import fs from "node:fs";
9
+ import path from "node:path";
10
+ import { fileURLToPath } from "node:url";
11
+ import { spawnSync } from "node:child_process";
12
+
13
+ // agent → 配置の対応を保持する縫い目(AGENT_REGISTRY)。
14
+ // 新 agent は1エントリ追加 + templates/<lang>/<agent>/ テンプレ追加で拡張できる。
15
+ // - agentName : このエントリの agent 名。rootDoc ソースパス解決に使う。
16
+ // - skillSubdir: skill ツリーの言語ルート相対サブディレクトリ(templates/<lang>/<skillSubdir>/skills/)。
17
+ // - skillDest : skill の配置先(配置先ルート相対)。
18
+ // - rootDoc : ルート memory doc のファイル名(null なら配置しない)。
19
+ // ソースは templates/<lang>/agents/<agentName>/<rootDoc>。
20
+ // claude エントリは現行挙動(skill→.claude/skills、rootDoc なし)を表現し、回帰を保証する。
21
+ export const AGENT_REGISTRY = {
22
+ claude: { agentName: "claude", skillSubdir: "claude", skillDest: ".claude/skills", rootDoc: "CLAUDE.md" },
23
+ codex: { agentName: "codex", skillSubdir: "codex", skillDest: ".agents/skills", rootDoc: "AGENTS.md" },
24
+ // gemini は3つ目の agent。Gemini CLI は .agents/skills を cross-tool alias として読むため
25
+ // skillDest を codex と共有する(DR35・第一候補)。skillSubdir は暫定で codex 共有とし、
26
+ // 実機 smoke の結果で最終確定する(task 3.2・共有なら codex のまま/専用なら "gemini" へ)。
27
+ // rootDoc は Gemini CLI 既定の GEMINI.md。配置経路は computeCopyPlan の汎用分岐をそのまま使う
28
+ // (agent 名で分岐するロジックを足さない=INV26/DR34)。
29
+ gemini: { agentName: "gemini", skillSubdir: "codex", skillDest: ".agents/skills", rootDoc: "GEMINI.md" },
30
+ };
31
+
32
+ // 共有 intent scaffold の対応(agent 不問・常に同じ)。
33
+ // templates/<lang>/intent/... -> <target>/.intent/...
34
+ const INTENT_SUBDIR = "intent";
35
+ const INTENT_DEST = ".intent";
36
+
37
+ // ---- code / user-data 分類 (安全なバージョンアップの核心) ----
38
+ //
39
+ // 配置物は3種類に分かれる:
40
+ // - code : intent-planner 専有ディレクトリ (.claude/skills/ ・ .agents/skills/ ・
41
+ // .intent/ 配下) にある skill ロジック・スクリプト・参照ドキュメント。
42
+ // バージョンアップで上書きしてよい(むしろ上書きしたい)。<file>.bak に退避してから書く。
43
+ // - user-data : ユーザー / ワークフローが書き込む成果物・ログ・状態。
44
+ // バージョンアップで決して上書きしてはいけない(ユーザーの作業が消える)。
45
+ // - shared : ユーザー領域とテリトリを共有するファイル(リポジトリ直下の AGENTS.md・
46
+ // .git/hooks/pre-push)。ユーザーが自分の内容を追記・統合している可能性があるため、
47
+ // update では上書きせず既存を尊重して SKIP する(明示的な --force のときだけ上書き)。
48
+ //
49
+ // 分類は配置先の relative パスのみで決まる純粋関数 classifyFile で行う。判定基準は
50
+ // 各テンプレートファイル冒頭の「誰が書くか」注記に対応する(intent-tree は /intent-discover が、
51
+ // drift-log はフックが書く…等)。USER_DATA_RELATIVES / SHARED_RELATIVES に列挙されたものだけが
52
+ // それぞれ user-data / shared で、残り(intent-planner 専有ツリー内)は全て code。
53
+ const USER_DATA_RELATIVES = new Set([
54
+ ".intent/intent-tree.md", // /intent-discover が書く意図ツリー
55
+ ".intent/intent-compass.md", // /intent-compass が書く判断基準
56
+ ".intent/compass-archive.md", // 覆された Decision Rules の退避先
57
+ ".intent/deltas.md", // /intent-writeback が記録する書き戻し delta
58
+ ".intent/drift-log.md", // drift-watch フックが追記するログ
59
+ ".intent/drift-patterns.md", // ユーザーが現場で育てる逸脱の型カタログ
60
+ ".intent/context-cost-cues.md", // ユーザーが現場で育てるコンテキストコストの気づきカタログ
61
+ ".intent/glossary.md", // ユーザーが現場で育てる正規語彙の台帳
62
+ ".intent/constraint-library.md", // ユーザーが現場で育てる制約の台帳(叩き台ライブラリの蓄積側)
63
+ ".intent/export-log.md", // /intent-export-cc-sdd が追記する export 履歴
64
+ ".intent/mode.md", // Enforcement / Drift-watch(共有ポリシー)
65
+ ".intent/mode.local.md", // /intent-discover が書く mode 状態(ローカル専用・upgrade で上書きしない)
66
+ ".intent/milestones.md", // 節目イベント(Decision 確定等)の記録(ユーザー成果物)
67
+ ".intent/packets/index.md", // packet の再生成インデックス(ユーザーの packet を反映)
68
+ ".intent/packets/plan.md", // /intent-packets が書く plan レベルの記録
69
+ ]);
70
+
71
+ // ユーザー領域とテリトリを共有するファイル(update では上書きしない・--force でのみ上書き)。
72
+ // AGENTS.md / CLAUDE.md はリポジトリ直下のプロジェクト指示でユーザーが追記しうる。pre-push は
73
+ // 他ツールと統合されている可能性がある既存フック。どちらも黙って上書きすると高リスクなので尊重する。
74
+ const SHARED_RELATIVES = new Set([
75
+ "AGENTS.md",
76
+ "CLAUDE.md",
77
+ "GEMINI.md",
78
+ ".git/hooks/pre-push",
79
+ ]);
80
+
81
+ // 配置先 relative を "code" | "user-data" | "shared" に分類する純粋関数。
82
+ // relative はプラットフォーム差を吸収するため POSIX 区切りへ正規化してから照合する。
83
+ export function classifyFile(relative) {
84
+ const posix = relative.split(path.sep).join("/");
85
+ if (USER_DATA_RELATIVES.has(posix)) return "user-data";
86
+ if (SHARED_RELATIVES.has(posix)) return "shared";
87
+ return "code";
88
+ }
89
+
90
+ // templates/ の絶対パス。npx 実行時の cwd に依存せず、このファイルからの相対で解決する。
91
+ export function defaultTemplatesDir() {
92
+ const here = path.dirname(fileURLToPath(import.meta.url));
93
+ return path.join(here, "..", "templates");
94
+ }
95
+
96
+ // 対応言語の集合。言語追加はここと templates/<lang>/ の追加のみ(拡張点)。
97
+ const SUPPORTED_LANGS = ["ja", "en"];
98
+ const DEFAULT_LANG = "ja";
99
+
100
+ // 言語コードから配置元の言語別ルートを解決する純粋関数。
101
+ // 対応集合に含まれれば templates/<lang> を、含まれなければ既定 templates/ja を返す。
102
+ // 対応集合外でも例外を投げず langFallback を立てて続行する(非停止・2.3)。
103
+ // 返り値: { langRoot, langFallback, resolvedLang }
104
+ export function resolveLangRoot(templatesDir, lang = DEFAULT_LANG) {
105
+ const supported = SUPPORTED_LANGS.includes(lang);
106
+ const resolvedLang = supported ? lang : DEFAULT_LANG;
107
+ return {
108
+ langRoot: path.join(templatesDir, resolvedLang),
109
+ langFallback: !supported,
110
+ resolvedLang,
111
+ };
112
+ }
113
+
114
+ // あるディレクトリ配下の全ファイルを相対パスで列挙する (任意のネスト深さ、隠しファイル含む)。
115
+ // ディレクトリ自体は返さない (COPY 時に親を作る)。存在しなければ空配列。
116
+ function listFilesRecursive(dir) {
117
+ if (!fs.existsSync(dir)) return [];
118
+ return fs
119
+ .readdirSync(dir, { recursive: true, withFileTypes: true })
120
+ .filter((entry) => entry.isFile())
121
+ .map((entry) => {
122
+ // Node 18/20 の Dirent.path と 22 の parentPath の差を吸収する。
123
+ const parent = entry.parentPath ?? entry.path;
124
+ return path.relative(dir, path.join(parent, entry.name));
125
+ });
126
+ }
127
+
128
+ // 配置先パスに「何らかのエントリ」が存在するかを symlink を辿らず判定する (INV1 の核心)。
129
+ // fs.existsSync はリンクを辿るため、リンク先が消えた dangling symlink を「存在しない」と
130
+ // 誤判定し、COPY → リンク越しに配置先ツリー外へ書き込んでしまう。
131
+ // lstat はリンク自体を見るので、file / dir / symlink (dangling 含む) すべて「既存」になる。
132
+ function entryExists(p) {
133
+ try {
134
+ fs.lstatSync(p);
135
+ return true;
136
+ } catch {
137
+ return false;
138
+ }
139
+ }
140
+
141
+ // 配置先の現物がソースと byte 完全一致かを返す(純粋・読み取りのみ)。
142
+ // 配置先が無い・読めない・symlink 等で比較不能なら false(= 一致とみなさない=従来判定に委ねる)。
143
+ // 大きいファイルは無いので単純な全読み比較で十分。
144
+ function filesIdentical(from, to) {
145
+ try {
146
+ if (!fs.statSync(to).isFile()) return false; // symlink/dir は比較対象外
147
+ return fs.readFileSync(from).equals(fs.readFileSync(to));
148
+ } catch {
149
+ return false;
150
+ }
151
+ }
152
+
153
+ // 配置先既存有無・分類・force/update から COPY/SKIP を決める純粋関数。
154
+ // 全ての計画エントリの action はここに集約する(判定ロジックの単一の真実)。
155
+ // - 配置先が存在しない → 常に COPY(新規ファイルは分類に関わらず配置する)
156
+ // - force → 常に COPY(既存原則どおり全上書き。従来の --force と同じ)
157
+ // - update かつ kind === code:
158
+ // 既存がソースと byte 一致 → SKIP(更新不要。冪等: 同じ版で再実行しても何も書かない)
159
+ // 一致しない → COPY(バージョンアップ: code を上書きする)
160
+ // - それ以外(既存) → SKIP(user-data / shared は update でも保護。従来の既定と同じ)
161
+ //
162
+ // バックアップ(.bak 退避)は「既存の code を実際に上書きするとき」だけ必要なので、その事実を
163
+ // backup フラグで返す(applyPlan が COPY 前に退避する)。新規 COPY・force・一致 SKIP では立てない。
164
+ function decideAction(exists, kind, { force, update, identical = false }) {
165
+ if (!exists) return { action: "COPY", backup: false };
166
+ if (force) return { action: "COPY", backup: false };
167
+ if (update && kind === "code") {
168
+ if (identical) return { action: "SKIP", backup: false };
169
+ return { action: "COPY", backup: true };
170
+ }
171
+ return { action: "SKIP", backup: false };
172
+ }
173
+
174
+ // 既存 code を update で上書きする候補のときだけ byte 一致を調べる(無駄読みを避ける)。
175
+ // 一致なら decideAction が SKIP に倒し、冪等な再実行で何も書かない。
176
+ function isIdenticalIfRelevant(exists, kind, from, to, { force, update }) {
177
+ if (!exists || force || !update || kind !== "code") return false;
178
+ return filesIdentical(from, to);
179
+ }
180
+
181
+ // 1 つの単一ファイルを計画エントリ化する純粋ヘルパ。ソースが無ければ null。
182
+ // 分類 (code/user-data/shared) を付与し、decideAction で action/backup を決める。
183
+ function planFile(from, to, relative, { force, update }) {
184
+ if (!fs.existsSync(from)) return null;
185
+ const kind = classifyFile(relative);
186
+ const exists = entryExists(to);
187
+ const identical = isIdenticalIfRelevant(exists, kind, from, to, { force, update });
188
+ const { action, backup } = decideAction(exists, kind, { force, update, identical });
189
+ return { from, to, relative, action, kind, backup };
190
+ }
191
+
192
+ // srcRoot 配下を再帰走査し destRoot へ相対パス保持でマップした計画エントリ群を返す(純粋)。
193
+ function planTree(srcRoot, targetDir, destRoot, { force, update }) {
194
+ const entries = [];
195
+ for (const rel of listFilesRecursive(srcRoot)) {
196
+ const from = path.join(srcRoot, rel);
197
+ const to = path.join(targetDir, destRoot, rel);
198
+ const relative = path.join(destRoot, rel);
199
+ const kind = classifyFile(relative);
200
+ const exists = entryExists(to);
201
+ const identical = isIdenticalIfRelevant(exists, kind, from, to, { force, update });
202
+ const { action, backup } = decideAction(exists, kind, { force, update, identical });
203
+ entries.push({ from, to, relative, action, kind, backup });
204
+ }
205
+ return entries;
206
+ }
207
+
208
+ // agent を考慮した COPY/SKIP 計画を合成する純粋関数。ファイルシステムを変更しない。
209
+ // agentEntry は options に入れる(位置引数を増やさない)。省略時は claude 既定 =
210
+ // 既存3引数呼び出し computeCopyPlan(langRoot, targetDir, {force}) と完全後方互換。
211
+ // enforce も options(既定 false)。false なら plan は従来と完全同一(mode キーも現れない)。
212
+ // 構成順序は固定: skill 計画 → intent 計画 → rootDoc 計画 →(enforce 時のみ)フック計画。
213
+ // - skill 計画 : <langRoot>/<skillSubdir>/skills/ を <skillDest>/ へ相対保持でマップ。
214
+ // (claude は <langRoot>/claude/skills/ → .claude/skills/ で現行と一致)
215
+ // - intent 計画: 共有 <langRoot>/intent/ を .intent/ へマップ(agent 不問・常に同じ)。
216
+ // - rootDoc 計画: rootDoc が非 null なら <langRoot>/agents/<agentName>/<rootDoc> を
217
+ // 配置先ルートの <rootDoc> へマップ。
218
+ // - フック計画 : enforce かつ <targetDir>/.git が存在するときのみ、plan 末尾に
219
+ // <langRoot>/intent/scripts/pre-push → .git/hooks/pre-push を1エントリ追加
220
+ // (mode: 0o755 付き。実行ビットは applyPlan が chmod で付与する)。
221
+ // 既存フックは SKIP(force 時は既存原則どおり COPY)。.git 不在なら足さない(6.1–6.2, 6.7)。
222
+ // 返り値: [{ from, to, relative, action: "COPY" | "SKIP", mode? }]
223
+ // update(既定 false)はバージョンアップ挙動: code 種別の既存ファイルを上書きし、user-data は
224
+ // 保護する(classifyFile 参照)。各エントリは kind ("code"|"user-data") と backup (bool) を持つ。
225
+ // update も force も false なら従来どおり全既存を SKIP し、kind/backup は付くが action は不変
226
+ // (後方互換: action 集合は従来と同一)。force は update に優先し全既存を COPY する。
227
+ export function computeCopyPlan(
228
+ langRoot,
229
+ targetDir,
230
+ { force = false, update = false, agentEntry = AGENT_REGISTRY.claude, enforce = false } = {},
231
+ ) {
232
+ const plan = [];
233
+ const opts = { force, update };
234
+
235
+ // (a) skill 計画: agent 別 skill ツリー → skillDest。
236
+ const skillSrc = path.join(langRoot, agentEntry.skillSubdir, "skills");
237
+ plan.push(...planTree(skillSrc, targetDir, agentEntry.skillDest, opts));
238
+
239
+ // (b) intent 計画: 共有 → .intent(agent 不問)。
240
+ const intentSrc = path.join(langRoot, INTENT_SUBDIR);
241
+ plan.push(...planTree(intentSrc, targetDir, INTENT_DEST, opts));
242
+
243
+ // (c) rootDoc 計画: rootDoc があるときのみ。ソースは agents/<agentName>/<rootDoc>。
244
+ if (agentEntry.rootDoc) {
245
+ const docFrom = path.join(langRoot, "agents", agentEntry.agentName, agentEntry.rootDoc);
246
+ const docTo = path.join(targetDir, agentEntry.rootDoc);
247
+ const entry = planFile(docFrom, docTo, agentEntry.rootDoc, opts);
248
+ if (entry) plan.push(entry);
249
+ }
250
+
251
+ // (d) フック計画: --enforce かつ配置先が git リポジトリのときだけ pre-push を計画する。
252
+ // .git/hooks 配下は非破壊許可リストの唯一の例外(enforce 明示時のみ・1ファイル固定)。
253
+ if (enforce && fs.existsSync(path.join(targetDir, ".git"))) {
254
+ const hookFrom = path.join(langRoot, INTENT_SUBDIR, "scripts", "pre-push");
255
+ const hookTo = path.join(targetDir, ".git", "hooks", "pre-push");
256
+ const entry = planFile(hookFrom, hookTo, path.join(".git", "hooks", "pre-push"), opts);
257
+ if (entry) plan.push({ ...entry, mode: 0o755 });
258
+ }
259
+
260
+ return plan;
261
+ }
262
+
263
+ // 計画を適用する (副作用)。COPY のみ 1 ファイルずつ書き、SKIP は触れない。
264
+ // fs.cpSync は使わず、mkdirSync(recursive) + copyFileSync で書く。
265
+ // 配置先に既存エントリ (force 時の上書き対象・symlink 含む) があれば copy 前に rm して
266
+ // 「リンク自体の置換」にする。copyFileSync はリンクを辿って書くため、rm しないと
267
+ // リンク先 (配置先ツリー外かもしれない) を上書きしてしまう (INV1 破り)。
268
+ // backup フラグ付きエントリ (update での code 上書き) は、配置先の現物を <to>.bak へ
269
+ // 退避してから上書きする。退避は copyFileSync ベース(リンクは辿らず実体をコピーして残す)。
270
+ // 既存の .bak は前回退避なので上書きしてよい(最新の「上書き前」を1世代だけ保持)。
271
+ // mode 付きエントリ(pre-push フック)は copy 後に chmod で権限を確定する。
272
+ // 途中失敗 (EACCES/ENOSPC 等) は copiedSoFar (配置済み relative の配列) を付与した
273
+ // エラーで報告する。メッセージは配置済み件数と再実行の安全性 (冪等) を自己完結で伝える。
274
+ // 返り値: { copied, skipped, backedUp } (いずれも relative パスの配列)
275
+ export function applyPlan(plan) {
276
+ const copied = [];
277
+ const skipped = [];
278
+ const backedUp = [];
279
+ for (const entry of plan) {
280
+ if (entry.action === "COPY") {
281
+ try {
282
+ fs.mkdirSync(path.dirname(entry.to), { recursive: true });
283
+ // 上書き前のバックアップ(update での code 上書き時のみ)。配置先が実在するときだけ退避する。
284
+ if (entry.backup && entryExists(entry.to)) {
285
+ fs.copyFileSync(entry.to, `${entry.to}.bak`);
286
+ backedUp.push(entry.relative);
287
+ }
288
+ if (entryExists(entry.to)) fs.rmSync(entry.to, { force: true });
289
+ fs.copyFileSync(entry.from, entry.to);
290
+ if (entry.mode !== undefined) fs.chmodSync(entry.to, entry.mode);
291
+ } catch (cause) {
292
+ const err = new Error(
293
+ `配置中にエラーが発生しました (${copied.length} 件配置済み、${entry.relative} で失敗): ${cause.message}\n` +
294
+ (entry.backup ? ` 上書き前の現物は ${entry.to}.bak に退避済みです(必要なら手動で復元できます)。\n` : "") +
295
+ "このインストーラは冪等です。原因を解消して再実行すれば、配置済みファイルはスキップされ、続きから安全に配置されます。",
296
+ );
297
+ err.copiedSoFar = [...copied];
298
+ err.cause = cause;
299
+ throw err;
300
+ }
301
+ copied.push(entry.relative);
302
+ } else {
303
+ skipped.push(entry.relative);
304
+ }
305
+ }
306
+ return { copied, skipped, backedUp };
307
+ }
308
+
309
+ // 配置先に cc-sdd (.kiro/) が存在するかを返す。改変しない (読み取りのみ)。
310
+ export function detectCcSdd(targetDir) {
311
+ return fs.existsSync(path.join(targetDir, ".kiro"));
312
+ }
313
+
314
+ // ---- gitignore 整備 (export 下書きの Git 非追跡化・4.1-4.6) ----
315
+ //
316
+ // 非破壊原則の明示的例外: .gitignore への「既存内容を変更しない末尾追記」のみを許す
317
+ // (--enforce のフック配置と同族)。計画 (planGitignore) と適用 (applyGitignore) を
318
+ // 分離し、dry-run では計画のみ返して書き込まない。
319
+
320
+ // 追記ブロック (コメント1 + パターン群)。新規作成時はコメント込み、欠落補完時はパターンのみ。
321
+ // `!.intent/cc-sdd/README.md` の再包含は親ディレクトリ自体を除外していないため有効。
322
+ const GITIGNORE_COMMENT = "# intent-planner: local-only files (export drafts / mode state)";
323
+ // `*.bak` はバージョンアップ時に code を上書きする前の退避ファイル(applyPlan が作る安全網)。
324
+ // ローカル専用なので Git 非追跡にする(git status を汚さない)。intent-planner が書き込む
325
+ // ディレクトリ配下に限定する(リポジトリ全体の *.bak を巻き込むと、ユーザーの src/foo.bak 等を
326
+ // 黙って除外してしまうため。退避先は code = .claude/skills/ ・ .agents/skills/ ・ .intent/ のみ)。
327
+ const GITIGNORE_PATTERNS = [
328
+ ".intent/cc-sdd/*",
329
+ "!.intent/cc-sdd/README.md",
330
+ ".intent/overview/*",
331
+ "!.intent/overview/README.md",
332
+ ".intent/spec-ingest/*",
333
+ "!.intent/spec-ingest/README.md",
334
+ ".intent/nl-spec/*",
335
+ "!.intent/nl-spec/README.md",
336
+ ".intent/release-note/*",
337
+ "!.intent/release-note/README.md",
338
+ ".intent/mode.local.md",
339
+ ".intent/**/*.bak",
340
+ ".claude/**/*.bak",
341
+ ".agents/**/*.bak",
342
+ ];
343
+
344
+ /**
345
+ * @typedef {Object} GitignorePlan
346
+ * @property {"create"|"append"|"none"|"skipped-not-git"} action
347
+ * @property {string} path .gitignore の絶対パス
348
+ * @property {string[]} blockLines 追記する行 (新規=コメント + 全パターン / 補完=欠落パターンのみ)
349
+ */
350
+
351
+ // .gitignore 整備の計画を返す純粋関数。書き込みは行わない。
352
+ // - <targetDir>/.git が無い → skipped-not-git (非 git リポジトリでは何もしない・4.6)
353
+ // - .gitignore 不在 → create (コメント + 全パターンのブロック全体)
354
+ // - 既存あり → パターン2行を trim 後完全一致で独立に判定し、欠落行のみ append。
355
+ // コメント行は両パターン欠落 (= fresh block) のときだけ付ける。
356
+ // 除外行だけが先に存在する不完全な状態でも、欠けた再包含行を補える (4.2-4.3)。
357
+ // - 両方あり → none (再実行で重複しない・冪等)
358
+ /** @returns {GitignorePlan} 書き込みは行わない(純粋な計画) */
359
+ export function planGitignore(targetDir) {
360
+ const gitignorePath = path.join(targetDir, ".gitignore");
361
+ if (!fs.existsSync(path.join(targetDir, ".git"))) {
362
+ return { action: "skipped-not-git", path: gitignorePath, blockLines: [] };
363
+ }
364
+ if (!entryExists(gitignorePath)) {
365
+ return { action: "create", path: gitignorePath, blockLines: [GITIGNORE_COMMENT, ...GITIGNORE_PATTERNS] };
366
+ }
367
+ const existingLines = fs
368
+ .readFileSync(gitignorePath, "utf8")
369
+ .split("\n")
370
+ .map((line) => line.trim());
371
+ const missing = GITIGNORE_PATTERNS.filter((p) => !existingLines.includes(p));
372
+ if (missing.length === 0) {
373
+ return { action: "none", path: gitignorePath, blockLines: [] };
374
+ }
375
+ // コメント行は両パターン欠落 (新規ブロック) のときのみ。片方だけの補完では付けない。
376
+ const blockLines =
377
+ missing.length === GITIGNORE_PATTERNS.length ? [GITIGNORE_COMMENT, ...missing] : missing;
378
+ return { action: "append", path: gitignorePath, blockLines };
379
+ }
380
+
381
+ // 計画を適用する (副作用)。create / append のときだけ書き込む。
382
+ // append は既存内容のバイト列を一切変更せず末尾に追記するのみ。
383
+ // 既存末尾に改行が無ければ改行を補ってからブロックを足す (既存行と結合させない・4.2)。
384
+ /** @param {GitignorePlan} plan @returns {void} action が create/append のときのみ書き込む */
385
+ export function applyGitignore(plan) {
386
+ if (plan.action === "create") {
387
+ fs.writeFileSync(plan.path, plan.blockLines.join("\n") + "\n");
388
+ } else if (plan.action === "append") {
389
+ const existing = fs.readFileSync(plan.path, "utf8");
390
+ const separator = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
391
+ fs.appendFileSync(plan.path, separator + plan.blockLines.join("\n") + "\n");
392
+ }
393
+ // none / skipped-not-git: 何もしない。
394
+ }
395
+
396
+ /**
397
+ * Git 追跡中の .intent/cc-sdd/ 配下ファイル (README.md を除く) を返す。
398
+ * 読み取り専用の `git ls-files` のみを使い、追跡解除は行わない (案内は cli 側・4.4)。
399
+ * git 実行不可・非リポジトリ・非ゼロ終了では [] を返す (フェイルオープン)。
400
+ * cwd 指定必須 (intent-check.mjs の先例に従う)。
401
+ * @returns {string[]}
402
+ */
403
+ export function detectTrackedCcSdd(targetDir) {
404
+ try {
405
+ const r = spawnSync("git", ["ls-files", "--", ".intent/cc-sdd"], {
406
+ cwd: targetDir,
407
+ encoding: "utf8",
408
+ });
409
+ if (r.error || r.status !== 0 || typeof r.stdout !== "string") return [];
410
+ return r.stdout
411
+ .split("\n")
412
+ .map((line) => line.trim())
413
+ .filter((line) => line.length > 0 && line !== ".intent/cc-sdd/README.md");
414
+ } catch {
415
+ return [];
416
+ }
417
+ }
418
+
419
+ /**
420
+ * Git 追跡中の .intent/mode.local.md を検出する。
421
+ * mode 状態はローカル専用 (DD1) であり、古い scaffold では git 追跡済みになっている場合がある。
422
+ * 読み取り専用の `git ls-files` のみを使い、追跡解除は行わない (案内は cli 側・DR12・INV3)。
423
+ * git 実行不可・非リポジトリ・非ゼロ終了では false を返す (フェイルオープン)。
424
+ * @returns {boolean}
425
+ */
426
+ export function detectTrackedModeLocal(targetDir) {
427
+ try {
428
+ const r = spawnSync("git", ["ls-files", "--", ".intent/mode.local.md"], {
429
+ cwd: targetDir,
430
+ encoding: "utf8",
431
+ });
432
+ if (r.error || r.status !== 0 || typeof r.stdout !== "string") return false;
433
+ return r.stdout.split("\n").some((line) => line.trim() === ".intent/mode.local.md");
434
+ } catch {
435
+ return false;
436
+ }
437
+ }
438
+
439
+ // インストールのオーケストレーション。
440
+ // update(既定 false)はバージョンアップ挙動: code 種別の既存ファイル(skill・scripts・参照
441
+ // ドキュメント)を上書きし、user-data 種別(intent-tree.md / 各ログ等・classifyFile 参照)は
442
+ // 保護する。上書きする code は <file>.bak へ退避してから書く(backedUp に列挙)。force は update に
443
+ // 優先し全既存を上書きする(バックアップは取らない・明示的全上書き)。
444
+ // dryRun 時は計画のみで書き込まない。lang から言語別ルートを解決し、
445
+ // 対応言語(ja, en)以外は ja にフォールバックする(langFallback=true・非停止)。
446
+ // agent は AGENT_REGISTRY に無ければエラーを投げる(不正 agent はエラー停止・lang の
447
+ // ja フォールバックと非対称: agent 違いは想定と異なる形式の配置という破壊的誤りになりうる)。
448
+ // enforce(既定 false)は computeCopyPlan へ素通しする。enforce 指定でも .git 不在なら
449
+ // フックは計画されず、その事実を enforceHookSkippedNoGit で返す(cli サマリ用・additive)。
450
+ // gitignore 整備は配置とは独立に計画し、dry-run では計画 (action) のみ返して書き込まない。
451
+ // 返り値: { copied, skipped, plan, ccSddDetected, langFallback, resolvedLang, agent,
452
+ // enforceHookSkippedNoGit, gitignore, trackedCcSdd }
453
+ export function install(
454
+ targetDir,
455
+ {
456
+ force = false,
457
+ update = false,
458
+ dryRun = false,
459
+ lang = "ja",
460
+ agent = "claude",
461
+ templatesDir,
462
+ enforce = false,
463
+ } = {},
464
+ ) {
465
+ const tmpl = templatesDir ?? defaultTemplatesDir();
466
+ if (!fs.existsSync(tmpl)) {
467
+ throw new Error(
468
+ `templates が見つかりません: ${tmpl}\nパッケージが壊れている可能性があります。再インストールしてください。`,
469
+ );
470
+ }
471
+
472
+ // agent を検証する。未登録 agent はエラー停止(配置しない)。
473
+ const agentEntry = AGENT_REGISTRY[agent];
474
+ if (!agentEntry) {
475
+ const supported = Object.keys(AGENT_REGISTRY).join(", ");
476
+ throw new Error(
477
+ `対応していないエージェントです: ${agent}\n対応エージェント: ${supported}`,
478
+ );
479
+ }
480
+
481
+ // 言語別ルートを解決し、解決済みルートと agent エントリをコピー計画算出に渡す。
482
+ // langFallback は resolveLangRoot 由来(対応集合外なら true。旧 lang !== "ja" を置換)。
483
+ const { langRoot, langFallback, resolvedLang } = resolveLangRoot(tmpl, lang);
484
+ const plan = computeCopyPlan(langRoot, targetDir, { force, update, agentEntry, enforce });
485
+
486
+ let copied = [];
487
+ let skipped = [];
488
+ let backedUp = [];
489
+ if (!dryRun) {
490
+ const applied = applyPlan(plan);
491
+ copied = applied.copied;
492
+ skipped = applied.skipped;
493
+ backedUp = applied.backedUp;
494
+ } else {
495
+ // dry-run: 適用はしないが、実行時と同じ COPY/SKIP/backup 判定を提示する。
496
+ copied = plan.filter((e) => e.action === "COPY").map((e) => e.relative);
497
+ skipped = plan.filter((e) => e.action === "SKIP").map((e) => e.relative);
498
+ // backup は「既存の code を上書きする」エントリのみ。dry-run では entryExists 判定済みの
499
+ // backup フラグ(計画段階で配置先存在を加味済み)をそのまま提示する。
500
+ backedUp = plan.filter((e) => e.action === "COPY" && e.backup).map((e) => e.relative);
501
+ }
502
+
503
+ // gitignore 整備: 計画は常に算出し (dry-run でも action を提示・4.5)、適用は非 dry-run のみ。
504
+ const gitignorePlan = planGitignore(targetDir);
505
+ if (!dryRun) applyGitignore(gitignorePlan);
506
+
507
+ return {
508
+ copied,
509
+ skipped,
510
+ backedUp,
511
+ update,
512
+ plan,
513
+ ccSddDetected: detectCcSdd(targetDir),
514
+ langFallback,
515
+ resolvedLang,
516
+ agent: agentEntry.agentName,
517
+ // --enforce なのに .git が無くフックを計画できなかったか(cli の案内表示用・6.1 系)。
518
+ enforceHookSkippedNoGit: enforce && !fs.existsSync(path.join(targetDir, ".git")),
519
+ // gitignore 整備の結果 (dry-run では計画のみ): "create" | "append" | "none" | "skipped-not-git"。
520
+ gitignore: gitignorePlan.action,
521
+ // Git 追跡済みの cc-sdd 下書き (README.md 除く)。cli が追跡解除手順を案内のみ表示する (4.4)。
522
+ trackedCcSdd: detectTrackedCcSdd(targetDir),
523
+ // Git 追跡済みの .intent/mode.local.md。mode 状態はローカル専用 (DD1) だが古い scaffold
524
+ // では追跡済みになっている場合がある。cli が移行手順を案内のみ表示する (DR12・INV3)。
525
+ trackedModeLocal: detectTrackedModeLocal(targetDir),
526
+ };
527
+ }
@@ -0,0 +1,62 @@
1
+ # intent-planner (quickstart for Claude)
2
+
3
+ intent-planner is a lightweight **Intent Planning layer** where the human and the agent align on "the overall intent" and "a unified design policy" **before** starting implementation. It prevents architectural drift — where each file looks fine on its own but the overall design intent slowly erodes — by stopping the agent from escaping into local optimization without a cross-cutting intent.
4
+
5
+ This is not a full IDD framework; it is a pre-spec stage that sits **before** the spec-driven flow (cc-sdd). The intent worked out here is bridged into cc-sdd's requirements → design → tasks flow non-destructively and at low token cost.
6
+
7
+ ## Workflow
8
+
9
+ Start from `/intent-discover` and run the following in order. Review each step's deliverable (Markdown under `.intent/`) before proceeding.
10
+
11
+ 1. `/intent-discover` — Build the Intent Tree (L0–L4), recommend/confirm the mode for working out the Intent, and confirm/record whether to delegate the designer-role questions (designer-questions)
12
+ 2. `/intent-compass` — Create decision criteria such as North Star / Anti-direction / Invariants
13
+ 3. `/intent-packets` — Decompose into work units (packets) before handing off to cc-sdd
14
+ 4. `/intent-export-cc-sdd` — Convert the chosen packets into cc-sdd drafts
15
+
16
+ The four above are the "planning" phase. After export, the intent is not disposable; keep growing it as a cycle with the four maintain/anytime skills.
17
+
18
+ - `/intent-status` — Anytime (when unsure). Recommend a summary of where you are plus exactly one "next move" (read-only)
19
+ - `/intent-validate` — Before export (recommended). Report contradictions, coverage gaps, and boundary inconsistencies with severity (read-only)
20
+ - `/intent-writeback` — After a packet's implementation is done. Record learnings into `.intent/deltas.md` as deltas; promote only approved items into the canonical deliverables
21
+ - `/intent-improve` — At milestones. Re-align `.intent/` with implementation reality on completeness / correctness / coherence
22
+
23
+ These `intent-*` skills live at `.claude/skills/intent-*/SKILL.md`.
24
+
25
+ ## Active prompts (imperative, short)
26
+
27
+ - Before implementing anything, run `/intent-discover` first.
28
+ - When unsure where you are, run `/intent-status`.
29
+ - While implementing, read only the relevant **packet** plus the related **Invariant** / Decision Rule — not the whole Compass or Tree.
30
+
31
+ ## Pull discipline (don't full-load)
32
+
33
+ Before implementing, read only the relevant **packet** and the **Invariant** / Decision Rule that touch it. Do not constantly load the full Compass or full Tree. Do not transcribe Spec/Invariant bodies here; point to the source instead (`.intent/intent-compass.md`, `.intent/intent-tree.md`, the relevant packet under `.intent/packets/`).
34
+
35
+ ## Steering is not recommended
36
+
37
+ Do not generate cross-cutting `steering` (especially steering custom) every time a responsibility is added. The constraints you need are supplied per-spec by intent through `export` (just-in-time, JIT), so prefer pulling the exact constraint over standing up new steering.
38
+
39
+ ## .intent/ scaffold
40
+
41
+ The Intent intelligence and the planning deliverables live in `.intent/` and are agent-independent.
42
+
43
+ - `intent-tree.md` — Intent Tree (L0–L4)
44
+ - `intent-compass.md` — North Star / Anti-direction / Invariants
45
+ - `packets/` — the Packet Plan and packet files (1 packet = 1 file)
46
+ - `mode.md` / `modes/` — the Intent-working mode and its records
47
+ - `cc-sdd/` — drafts of cc-sdd requirements / design / tasks to hand off
48
+
49
+ See `.intent/README.md` for details.
50
+
51
+ ## cc-sdd integration
52
+
53
+ Hand the target packet's `.intent/cc-sdd/<slug>/requirements.md` produced by `/intent-export-cc-sdd` to cc-sdd's `/kiro-spec-init`, and the Intent Planning results carry into cc-sdd's spec-driven flow. intent-planner only goes as far as drafts; cc-sdd generates the body, and a human reviews each phase.
54
+
55
+ ## Rules
56
+
57
+ - Do not change application code during the Intent Planning phase.
58
+ - Do not propose local refactors that do not support a parent intent.
59
+ - Each packet must reference a parent intent, and each task must preserve the invariants.
60
+ - When intent is unclear, do not edit code; write it into Open Questions.
61
+ - Treat inferred intent as provisional until a human reviews it.
62
+ - If an implementation request exceeds the exported packet's Scope, do not keep implementing — go back to intent: open a new packet for the new area with `/intent-packets` (or widen the packet's scope and supersede it), then re-export. This prevents missing the new area's decisions (authorization, consistency, idempotency, error semantics) and packet-specific invariants.
@@ -0,0 +1,62 @@
1
+ # intent-planner (quickstart for Codex)
2
+
3
+ intent-planner is a lightweight **Intent Planning layer** where the human and the agent align on "the overall intent" and "a unified design policy" **before** starting implementation. It prevents architectural drift — where each file looks fine on its own but the overall design intent slowly erodes — by stopping the agent from escaping into local optimization without a cross-cutting intent.
4
+
5
+ This is not a full IDD framework; it is a pre-spec stage that sits **before** the spec-driven flow (cc-sdd). The intent worked out here is bridged into cc-sdd's requirements → design → tasks flow non-destructively and at low token cost.
6
+
7
+ ## Workflow
8
+
9
+ Start from `/intent-discover` and run the following in order. Review each step's deliverable (Markdown under `.intent/`) before proceeding.
10
+
11
+ 1. `/intent-discover` — Build the Intent Tree (L0–L4), recommend/confirm the mode for working out the Intent, and confirm/record whether to delegate the designer-role questions (designer-questions)
12
+ 2. `/intent-compass` — Create decision criteria such as North Star / Anti-direction / Invariants
13
+ 3. `/intent-packets` — Decompose into work units (packets) before handing off to cc-sdd
14
+ 4. `/intent-export-cc-sdd` — Convert the chosen packets into cc-sdd drafts
15
+
16
+ The four above are the "planning" phase. After export, the intent is not disposable; keep growing it as a cycle with the four maintain/anytime skills.
17
+
18
+ - `/intent-status` — Anytime (when unsure). Recommend a summary of where you are plus exactly one "next move" (read-only)
19
+ - `/intent-validate` — Before export (recommended). Report contradictions, coverage gaps, and boundary inconsistencies across deliverables with severity (read-only)
20
+ - `/intent-writeback` — After a packet's implementation is done. Record the learnings gained from the implementation into `.intent/deltas.md` as deltas, and promote only the approved items into the canonical deliverables
21
+ - `/intent-improve` — At milestones (e.g. after implementing several packets). Re-align `.intent/` with the implementation reality on the three axes of completeness / correctness / coherence
22
+
23
+ These `intent-*` skills live at `.agents/skills/intent-*/SKILL.md`.
24
+
25
+ ## Active prompts (imperative, short)
26
+
27
+ - Before implementing anything, run `/intent-discover` first.
28
+ - When unsure where you are, run `/intent-status`.
29
+ - While implementing, read only the relevant **packet** plus the related **Invariant** / Decision Rule — not the whole Compass or Tree.
30
+
31
+ ## Pull discipline (don't full-load)
32
+
33
+ Before implementing, read only the relevant **packet** and the **Invariant** / Decision Rule that touch it. Do not constantly load the full Compass or full Tree. Do not transcribe Spec/Invariant bodies here; point to the source instead (`.intent/intent-compass.md`, `.intent/intent-tree.md`, the relevant packet under `.intent/packets/`).
34
+
35
+ ## Steering is not recommended
36
+
37
+ Do not generate cross-cutting `steering` (especially steering custom) every time a responsibility is added. The constraints you need are supplied per-spec by intent through `export` (just-in-time, JIT), so prefer pulling the exact constraint over standing up new steering.
38
+
39
+ ## .intent/ scaffold
40
+
41
+ The Intent intelligence (mode definitions, algorithm rules, cc-sdd bridge) and the planning deliverables live in `.intent/` and are agent-independent.
42
+
43
+ - `intent-tree.md` — Intent Tree (L0–L4)
44
+ - `intent-compass.md` — North Star / Anti-direction / Invariants
45
+ - `packets/` — the Packet Plan (`plan.md`) and the packet files (1 packet = 1 file under `active/`; `index.md` lists the active packets, and completed packets move to `archive/`)
46
+ - `mode.md` / `modes/` — the Intent-working mode (the selected mode, the `designer-questions` / `purpose` records, and the mode definitions)
47
+ - `cc-sdd/` — drafts of cc-sdd requirements / design / tasks to hand off (kept per packet in `<slug>/` directories)
48
+
49
+ See `.intent/README.md` for details.
50
+
51
+ ## cc-sdd integration
52
+
53
+ Hand the target packet's `.intent/cc-sdd/<slug>/requirements.md` (a condensed Project Description) produced by `/intent-export-cc-sdd` to cc-sdd's `/kiro-spec-init`, and the Intent Planning results carry smoothly into cc-sdd's spec-driven flow. intent-planner only goes as far as drafts; cc-sdd generates the body, and a human reviews each phase.
54
+
55
+ ## Rules
56
+
57
+ - Do not change application code during the Intent Planning phase.
58
+ - Do not propose local refactors that do not support a parent intent.
59
+ - Each packet must always reference a parent intent, and each task must preserve the invariants.
60
+ - When intent is unclear, do not edit code; write it into Open Questions.
61
+ - Treat inferred intent as provisional until a human reviews it.
62
+ - If an implementation request exceeds the exported packet's Scope, do not keep implementing — go back to intent: open a new packet for the new area with `/intent-packets` (or widen the packet's scope and supersede it), then re-export. This prevents missing the new area's decisions (authorization, consistency, idempotency, error semantics) and packet-specific invariants.