@niujiajie/freespec 0.0.0-stage → 1.15.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 (308) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +58 -2
  3. package/bin/freespec.js +5 -0
  4. package/dist/cli/index.d.ts +25 -0
  5. package/dist/cli/index.js +359 -0
  6. package/dist/commands/shared-output.d.ts +18 -0
  7. package/dist/commands/shared-output.js +61 -0
  8. package/dist/commands/workflow/default-schema.d.ts +2 -0
  9. package/dist/commands/workflow/default-schema.js +4 -0
  10. package/dist/commands/workflow/index.d.ts +13 -0
  11. package/dist/commands/workflow/index.js +10 -0
  12. package/dist/commands/workflow/instructions.d.ts +39 -0
  13. package/dist/commands/workflow/instructions.js +565 -0
  14. package/dist/commands/workflow/new-change.d.ts +19 -0
  15. package/dist/commands/workflow/new-change.js +135 -0
  16. package/dist/commands/workflow/shared.d.ts +94 -0
  17. package/dist/commands/workflow/shared.js +169 -0
  18. package/dist/commands/workflow/status.d.ts +18 -0
  19. package/dist/commands/workflow/status.js +201 -0
  20. package/dist/core/artifact-graph/graph.d.ts +72 -0
  21. package/dist/core/artifact-graph/graph.js +165 -0
  22. package/dist/core/artifact-graph/index.d.ts +9 -0
  23. package/dist/core/artifact-graph/index.js +14 -0
  24. package/dist/core/artifact-graph/instruction-loader.d.ts +208 -0
  25. package/dist/core/artifact-graph/instruction-loader.js +268 -0
  26. package/dist/core/artifact-graph/outputs.d.ts +19 -0
  27. package/dist/core/artifact-graph/outputs.js +351 -0
  28. package/dist/core/artifact-graph/resolver.d.ts +89 -0
  29. package/dist/core/artifact-graph/resolver.js +342 -0
  30. package/dist/core/artifact-graph/schema.d.ts +27 -0
  31. package/dist/core/artifact-graph/schema.js +160 -0
  32. package/dist/core/artifact-graph/state.d.ts +12 -0
  33. package/dist/core/artifact-graph/state.js +31 -0
  34. package/dist/core/artifact-graph/types.d.ts +40 -0
  35. package/dist/core/artifact-graph/types.js +59 -0
  36. package/dist/core/available-tools.d.ts +18 -0
  37. package/dist/core/available-tools.js +49 -0
  38. package/dist/core/change-layout.d.ts +17 -0
  39. package/dist/core/change-layout.js +30 -0
  40. package/dist/core/change-metadata/index.d.ts +2 -0
  41. package/dist/core/change-metadata/index.js +2 -0
  42. package/dist/core/change-metadata/schema.d.ts +23 -0
  43. package/dist/core/change-metadata/schema.js +46 -0
  44. package/dist/core/change-status-policy.d.ts +49 -0
  45. package/dist/core/change-status-policy.js +50 -0
  46. package/dist/core/command-generation/adapters/amazon-q.d.ts +17 -0
  47. package/dist/core/command-generation/adapters/amazon-q.js +32 -0
  48. package/dist/core/command-generation/adapters/antigravity.d.ts +13 -0
  49. package/dist/core/command-generation/adapters/antigravity.js +27 -0
  50. package/dist/core/command-generation/adapters/atomcode.d.ts +24 -0
  51. package/dist/core/command-generation/adapters/atomcode.js +46 -0
  52. package/dist/core/command-generation/adapters/auggie.d.ts +13 -0
  53. package/dist/core/command-generation/adapters/auggie.js +28 -0
  54. package/dist/core/command-generation/adapters/bob.d.ts +18 -0
  55. package/dist/core/command-generation/adapters/bob.js +33 -0
  56. package/dist/core/command-generation/adapters/claude.d.ts +13 -0
  57. package/dist/core/command-generation/adapters/claude.js +32 -0
  58. package/dist/core/command-generation/adapters/cline.d.ts +14 -0
  59. package/dist/core/command-generation/adapters/cline.js +27 -0
  60. package/dist/core/command-generation/adapters/codeassistant.d.ts +15 -0
  61. package/dist/core/command-generation/adapters/codeassistant.js +29 -0
  62. package/dist/core/command-generation/adapters/codebuddy.d.ts +13 -0
  63. package/dist/core/command-generation/adapters/codebuddy.js +29 -0
  64. package/dist/core/command-generation/adapters/codestudio.d.ts +13 -0
  65. package/dist/core/command-generation/adapters/codestudio.js +27 -0
  66. package/dist/core/command-generation/adapters/command-code.d.ts +19 -0
  67. package/dist/core/command-generation/adapters/command-code.js +34 -0
  68. package/dist/core/command-generation/adapters/continue.d.ts +13 -0
  69. package/dist/core/command-generation/adapters/continue.js +33 -0
  70. package/dist/core/command-generation/adapters/costrict.d.ts +13 -0
  71. package/dist/core/command-generation/adapters/costrict.js +28 -0
  72. package/dist/core/command-generation/adapters/crush.d.ts +13 -0
  73. package/dist/core/command-generation/adapters/crush.js +30 -0
  74. package/dist/core/command-generation/adapters/cursor.d.ts +14 -0
  75. package/dist/core/command-generation/adapters/cursor.js +31 -0
  76. package/dist/core/command-generation/adapters/devin.d.ts +19 -0
  77. package/dist/core/command-generation/adapters/devin.js +36 -0
  78. package/dist/core/command-generation/adapters/easycode.d.ts +17 -0
  79. package/dist/core/command-generation/adapters/easycode.js +28 -0
  80. package/dist/core/command-generation/adapters/factory.d.ts +13 -0
  81. package/dist/core/command-generation/adapters/factory.js +28 -0
  82. package/dist/core/command-generation/adapters/gemini.d.ts +13 -0
  83. package/dist/core/command-generation/adapters/gemini.js +27 -0
  84. package/dist/core/command-generation/adapters/gigacode.d.ts +17 -0
  85. package/dist/core/command-generation/adapters/gigacode.js +31 -0
  86. package/dist/core/command-generation/adapters/github-copilot.d.ts +13 -0
  87. package/dist/core/command-generation/adapters/github-copilot.js +27 -0
  88. package/dist/core/command-generation/adapters/iflow.d.ts +13 -0
  89. package/dist/core/command-generation/adapters/iflow.js +30 -0
  90. package/dist/core/command-generation/adapters/index.d.ts +40 -0
  91. package/dist/core/command-generation/adapters/index.js +40 -0
  92. package/dist/core/command-generation/adapters/junie.d.ts +13 -0
  93. package/dist/core/command-generation/adapters/junie.js +27 -0
  94. package/dist/core/command-generation/adapters/kilocode.d.ts +14 -0
  95. package/dist/core/command-generation/adapters/kilocode.js +23 -0
  96. package/dist/core/command-generation/adapters/kiro.d.ts +13 -0
  97. package/dist/core/command-generation/adapters/kiro.js +27 -0
  98. package/dist/core/command-generation/adapters/lingma.d.ts +13 -0
  99. package/dist/core/command-generation/adapters/lingma.js +30 -0
  100. package/dist/core/command-generation/adapters/oh-my-pi.d.ts +21 -0
  101. package/dist/core/command-generation/adapters/oh-my-pi.js +42 -0
  102. package/dist/core/command-generation/adapters/opencode.d.ts +14 -0
  103. package/dist/core/command-generation/adapters/opencode.js +38 -0
  104. package/dist/core/command-generation/adapters/pi.d.ts +18 -0
  105. package/dist/core/command-generation/adapters/pi.js +39 -0
  106. package/dist/core/command-generation/adapters/qoder.d.ts +13 -0
  107. package/dist/core/command-generation/adapters/qoder.js +30 -0
  108. package/dist/core/command-generation/adapters/qwen.d.ts +17 -0
  109. package/dist/core/command-generation/adapters/qwen.js +31 -0
  110. package/dist/core/command-generation/adapters/roocode.d.ts +14 -0
  111. package/dist/core/command-generation/adapters/roocode.js +27 -0
  112. package/dist/core/command-generation/adapters/trae.d.ts +13 -0
  113. package/dist/core/command-generation/adapters/trae.js +28 -0
  114. package/dist/core/command-generation/adapters/zcode.d.ts +16 -0
  115. package/dist/core/command-generation/adapters/zcode.js +33 -0
  116. package/dist/core/command-generation/generator.d.ts +29 -0
  117. package/dist/core/command-generation/generator.js +43 -0
  118. package/dist/core/command-generation/index.d.ts +22 -0
  119. package/dist/core/command-generation/index.js +24 -0
  120. package/dist/core/command-generation/invocation.d.ts +73 -0
  121. package/dist/core/command-generation/invocation.js +77 -0
  122. package/dist/core/command-generation/registry.d.ts +36 -0
  123. package/dist/core/command-generation/registry.js +114 -0
  124. package/dist/core/command-generation/toml.d.ts +19 -0
  125. package/dist/core/command-generation/toml.js +39 -0
  126. package/dist/core/command-generation/types.d.ts +63 -0
  127. package/dist/core/command-generation/types.js +8 -0
  128. package/dist/core/command-generation/yaml.d.ts +36 -0
  129. package/dist/core/command-generation/yaml.js +48 -0
  130. package/dist/core/command-surface.d.ts +15 -0
  131. package/dist/core/command-surface.js +33 -0
  132. package/dist/core/config-prompts.d.ts +9 -0
  133. package/dist/core/config-prompts.js +56 -0
  134. package/dist/core/config-schema.d.ts +98 -0
  135. package/dist/core/config-schema.js +308 -0
  136. package/dist/core/config.d.ts +50 -0
  137. package/dist/core/config.js +122 -0
  138. package/dist/core/file-state.d.ts +36 -0
  139. package/dist/core/file-state.js +144 -0
  140. package/dist/core/file-view.d.ts +13 -0
  141. package/dist/core/file-view.js +14 -0
  142. package/dist/core/global-config.d.ts +101 -0
  143. package/dist/core/global-config.js +182 -0
  144. package/dist/core/id.d.ts +17 -0
  145. package/dist/core/id.js +30 -0
  146. package/dist/core/index.d.ts +6 -0
  147. package/dist/core/index.js +7 -0
  148. package/dist/core/init.d.ts +57 -0
  149. package/dist/core/init.js +836 -0
  150. package/dist/core/list.d.ts +11 -0
  151. package/dist/core/list.js +197 -0
  152. package/dist/core/migration.d.ts +121 -0
  153. package/dist/core/migration.js +540 -0
  154. package/dist/core/onboarding-commands.d.ts +30 -0
  155. package/dist/core/onboarding-commands.js +38 -0
  156. package/dist/core/openspec-root.d.ts +47 -0
  157. package/dist/core/openspec-root.js +196 -0
  158. package/dist/core/planning-home.d.ts +16 -0
  159. package/dist/core/planning-home.js +67 -0
  160. package/dist/core/profile-sync-drift.d.ts +31 -0
  161. package/dist/core/profile-sync-drift.js +201 -0
  162. package/dist/core/profiles.d.ts +19 -0
  163. package/dist/core/profiles.js +33 -0
  164. package/dist/core/project-config.d.ts +132 -0
  165. package/dist/core/project-config.js +519 -0
  166. package/dist/core/references.d.ts +10 -0
  167. package/dist/core/references.js +46 -0
  168. package/dist/core/root-selection.d.ts +59 -0
  169. package/dist/core/root-selection.js +132 -0
  170. package/dist/core/shared/allowed-tools.d.ts +12 -0
  171. package/dist/core/shared/allowed-tools.js +12 -0
  172. package/dist/core/shared/ide-restart.d.ts +26 -0
  173. package/dist/core/shared/ide-restart.js +42 -0
  174. package/dist/core/shared/index.d.ts +11 -0
  175. package/dist/core/shared/index.js +11 -0
  176. package/dist/core/shared/skill-content-equivalence.d.ts +7 -0
  177. package/dist/core/shared/skill-content-equivalence.js +45 -0
  178. package/dist/core/shared/skill-files.d.ts +7 -0
  179. package/dist/core/shared/skill-files.js +43 -0
  180. package/dist/core/shared/skill-generation.d.ts +49 -0
  181. package/dist/core/shared/skill-generation.js +125 -0
  182. package/dist/core/shared/skill-paths.d.ts +13 -0
  183. package/dist/core/shared/skill-paths.js +23 -0
  184. package/dist/core/shared/tool-detection.d.ts +99 -0
  185. package/dist/core/shared/tool-detection.js +318 -0
  186. package/dist/core/shared-skill-target.d.ts +51 -0
  187. package/dist/core/shared-skill-target.js +239 -0
  188. package/dist/core/store/errors.d.ts +20 -0
  189. package/dist/core/store/errors.js +22 -0
  190. package/dist/core/store/index.d.ts +2 -0
  191. package/dist/core/store/index.js +2 -0
  192. package/dist/core/styles/palette.d.ts +7 -0
  193. package/dist/core/styles/palette.js +8 -0
  194. package/dist/core/templates/optional-workflow.d.ts +69 -0
  195. package/dist/core/templates/optional-workflow.js +140 -0
  196. package/dist/core/templates/types.d.ts +19 -0
  197. package/dist/core/templates/types.js +5 -0
  198. package/dist/core/templates/workflows/personal.d.ts +22 -0
  199. package/dist/core/templates/workflows/personal.js +225 -0
  200. package/dist/core/update-plan.d.ts +127 -0
  201. package/dist/core/update-plan.js +390 -0
  202. package/dist/core/update.d.ts +154 -0
  203. package/dist/core/update.js +723 -0
  204. package/dist/core/version-check.d.ts +188 -0
  205. package/dist/core/version-check.js +906 -0
  206. package/dist/core/zod-issues.d.ts +4 -0
  207. package/dist/core/zod-issues.js +10 -0
  208. package/dist/index.d.ts +3 -0
  209. package/dist/index.js +3 -0
  210. package/dist/prompts/searchable-multi-select.d.ts +35 -0
  211. package/dist/prompts/searchable-multi-select.js +188 -0
  212. package/dist/telemetry/config.d.ts +37 -0
  213. package/dist/telemetry/config.js +148 -0
  214. package/dist/telemetry/index.d.ts +39 -0
  215. package/dist/telemetry/index.js +217 -0
  216. package/dist/telemetry/opt-out.d.ts +17 -0
  217. package/dist/telemetry/opt-out.js +27 -0
  218. package/dist/ui/ascii-patterns.d.ts +16 -0
  219. package/dist/ui/ascii-patterns.js +133 -0
  220. package/dist/ui/welcome-screen.d.ts +18 -0
  221. package/dist/ui/welcome-screen.js +199 -0
  222. package/dist/utils/change-metadata.d.ts +116 -0
  223. package/dist/utils/change-metadata.js +324 -0
  224. package/dist/utils/change-utils.d.ts +79 -0
  225. package/dist/utils/change-utils.js +121 -0
  226. package/dist/utils/ci.d.ts +12 -0
  227. package/dist/utils/ci.js +16 -0
  228. package/dist/utils/command-references.d.ts +104 -0
  229. package/dist/utils/command-references.js +190 -0
  230. package/dist/utils/date.d.ts +8 -0
  231. package/dist/utils/date.js +13 -0
  232. package/dist/utils/executable-path.d.ts +5 -0
  233. package/dist/utils/executable-path.js +44 -0
  234. package/dist/utils/file-system.d.ts +58 -0
  235. package/dist/utils/file-system.js +432 -0
  236. package/dist/utils/index.d.ts +6 -0
  237. package/dist/utils/index.js +9 -0
  238. package/dist/utils/interactive.d.ts +85 -0
  239. package/dist/utils/interactive.js +174 -0
  240. package/dist/utils/item-discovery.d.ts +15 -0
  241. package/dist/utils/item-discovery.js +33 -0
  242. package/dist/utils/line-endings.d.ts +34 -0
  243. package/dist/utils/line-endings.js +46 -0
  244. package/dist/utils/match.d.ts +3 -0
  245. package/dist/utils/match.js +22 -0
  246. package/dist/utils/nested-change.d.ts +35 -0
  247. package/dist/utils/nested-change.js +185 -0
  248. package/dist/utils/shell-detection.d.ts +20 -0
  249. package/dist/utils/shell-detection.js +94 -0
  250. package/dist/utils/task-progress.d.ts +67 -0
  251. package/dist/utils/task-progress.js +184 -0
  252. package/package.json +74 -4
  253. package/schemas//351/273/230/350/256/244/schema.yaml +68 -0
  254. package/schemas//351/273/230/350/256/244/templates//344/273/273/345/212/241/346/270/205/345/215/225.md +25 -0
  255. package/schemas//351/273/230/350/256/244/templates//346/265/213/350/257/225/347/224/250/344/276/213.md +34 -0
  256. package/schemas//351/273/230/350/256/244/templates//350/256/276/350/256/241/346/226/207/346/241/243.md +172 -0
  257. package/schemas//351/273/230/350/256/244/templates//351/234/200/346/261/202/346/226/207/346/241/243.md +19 -0
  258. package/skill-files//344/273/273/345/212/241/references//346/212/244/346/240/217.md +43 -0
  259. package/skill-files//344/273/273/345/212/241/references//347/262/222/345/272/246.md +23 -0
  260. package/skill-files//344/273/273/345/212/241/references//347/272/246/346/235/237.md +8 -0
  261. package/skill-files//344/273/273/345/212/241/scripts/check-tasks.mjs +83 -0
  262. package/skill-files//345/206/231Java/references/Java/350/247/204/350/214/203.md +25 -0
  263. package/skill-files//345/206/231Java/references//345/215/261/351/231/251/345/206/231/346/263/225.md +27 -0
  264. package/skill-files//345/206/231Java/references//345/256/214/346/210/220/345/257/271/347/205/247.md +15 -0
  265. package/skill-files//345/206/231Java/references//346/212/244/346/240/217.md +35 -0
  266. package/skill-files//345/206/231Java/references//347/272/246/346/235/237.md +8 -0
  267. package/skill-files//345/206/231Java/references//350/270/251/345/235/221.md +17 -0
  268. package/skill-files//345/256/241Java/references//346/212/244/346/240/217.md +19 -0
  269. package/skill-files//345/256/241Java/references//347/244/272/344/276/213.md +23 -0
  270. package/skill-files//345/256/241Java/references//347/272/246/346/235/237.md +7 -0
  271. package/skill-files//345/256/241Java/references//350/247/204/345/210/231.md +23 -0
  272. package/skill-files//345/256/241Java/references//351/242/206/345/237/237/346/243/200/351/241/271.md +58 -0
  273. package/skill-files//345/256/241/346/226/207/346/241/243/references//346/212/244/346/240/217.md +18 -0
  274. package/skill-files//345/256/241/346/226/207/346/241/243/references//347/272/246/346/235/237.md +8 -0
  275. package/skill-files//345/256/241/346/226/207/346/241/243/references//347/273/264/345/272/246.md +17 -0
  276. package/skill-files//345/256/241/346/226/207/346/241/243/references//350/270/251/345/235/221.md +11 -0
  277. package/skill-files//346/226/260/345/273/272/references//344/272/244/346/216/245.md +11 -0
  278. package/skill-files//346/226/260/345/273/272/references//346/212/244/346/240/217.md +14 -0
  279. package/skill-files//346/226/260/345/273/272/references//347/272/246/346/235/237.md +7 -0
  280. package/skill-files//346/267/261/346/200/235/config/prompts.yaml +114 -0
  281. package/skill-files//346/267/261/346/200/235/references//344/270/211/346/226/271/346/240/270/345/257/271.md +72 -0
  282. package/skill-files//346/267/261/346/200/235/references//344/276/213/345/255/220.md +39 -0
  283. package/skill-files//346/267/261/346/200/235/references//346/200/216/344/271/210/346/203/263.md +61 -0
  284. package/skill-files//346/267/261/346/200/235/references//346/212/244/346/240/217.md +26 -0
  285. package/skill-files//346/267/261/346/200/235/references//347/202/271/351/200/211/346/217/220/351/227/256.md +66 -0
  286. package/skill-files//346/267/261/346/200/235/references//347/231/273/350/256/260.md +45 -0
  287. package/skill-files//346/267/261/346/200/235/references//347/272/246/346/235/237.md +9 -0
  288. package/skill-files//347/224/250/344/276/213/references//346/200/216/344/271/210/345/206/231.md +13 -0
  289. package/skill-files//347/224/250/344/276/213/references//346/212/244/346/240/217.md +42 -0
  290. package/skill-files//347/224/250/344/276/213/references//347/272/246/346/235/237.md +5 -0
  291. package/skill-files//347/224/250/344/276/213/scripts/check-cases.mjs +70 -0
  292. package/skill-files//350/256/276/350/256/241/references//345/207/206/345/244/207.md +25 -0
  293. package/skill-files//350/256/276/350/256/241/references//346/212/244/346/240/217.md +134 -0
  294. package/skill-files//350/256/276/350/256/241/references//346/226/207/351/243/216.md +17 -0
  295. package/skill-files//350/256/276/350/256/241/references//347/225/214/351/235/242.md +18 -0
  296. package/skill-files//350/256/276/350/256/241/references//347/261/273/345/236/213.md +19 -0
  297. package/skill-files//350/256/276/350/256/241/references//347/272/246/346/235/237.md +25 -0
  298. package/skill-files//350/256/276/350/256/241/scripts/_smoke.mjs +72 -0
  299. package/skill-files//350/256/276/350/256/241/scripts/check-design.mjs +331 -0
  300. package/skill-files//351/234/200/346/261/202/references//346/212/244/346/240/217.md +26 -0
  301. package/skill-files//351/234/200/346/261/202/references//346/226/207/351/243/216.md +23 -0
  302. package/skill-files//351/234/200/346/261/202/references//346/267/261/346/200/235/346/221/204/345/205/245.md +21 -0
  303. package/skill-files//351/234/200/346/261/202/references//347/272/246/346/235/237.md +8 -0
  304. package/skill-files//351/234/200/346/261/202/references//351/234/200/346/261/202/345/276/205/345/256/232.md +13 -0
  305. package/skill-files//351/234/200/346/261/202/scripts/check-requirements.mjs +60 -0
  306. package/skill-files//351/252/214/346/224/266/references//346/212/244/346/240/217.md +27 -0
  307. package/skill-files//351/252/214/346/224/266/references//346/240/270/345/257/271.md +17 -0
  308. package/skill-files//351/252/214/346/224/266/references//347/272/246/346/235/237.md +7 -0
@@ -0,0 +1,72 @@
1
+ import type { Artifact, SchemaYaml, CompletedSet, BlockedArtifacts } from './types.js';
2
+ /**
3
+ * Represents an artifact dependency graph.
4
+ * Provides methods for querying build order, ready artifacts, and completion status.
5
+ */
6
+ export declare class ArtifactGraph {
7
+ private artifacts;
8
+ private schema;
9
+ /** Artifact id -> its position in the schema's `artifacts:` list. */
10
+ private declarationOrder;
11
+ private constructor();
12
+ /**
13
+ * Orders artifact ids by where the schema declares them.
14
+ *
15
+ * The dependency graph leaves siblings tied - spec-driven's `specs` and
16
+ * `design` both require only `proposal`, so both become ready at the same
17
+ * time. Ties used to be broken alphabetically, which put `design` ahead of
18
+ * `specs` and made the CLI recommend the artifacts in an order that
19
+ * contradicted the schema's own documented sequence
20
+ * (proposal -> specs -> design -> tasks). Breaking ties by declaration order
21
+ * follows the sequence the schema author wrote, for built-in and custom
22
+ * schemas alike, and stays just as deterministic. Ids not in the schema sort
23
+ * last so the comparator stays total.
24
+ */
25
+ private compareByDeclarationOrder;
26
+ /**
27
+ * Creates an ArtifactGraph from a YAML file path.
28
+ */
29
+ static fromYaml(filePath: string): ArtifactGraph;
30
+ /**
31
+ * Creates an ArtifactGraph from YAML content string.
32
+ */
33
+ static fromYamlContent(yamlContent: string): ArtifactGraph;
34
+ /**
35
+ * Creates an ArtifactGraph from a pre-validated schema object.
36
+ */
37
+ static fromSchema(schema: SchemaYaml): ArtifactGraph;
38
+ /**
39
+ * Gets a single artifact by ID.
40
+ */
41
+ getArtifact(id: string): Artifact | undefined;
42
+ /**
43
+ * Gets all artifacts in the graph.
44
+ */
45
+ getAllArtifacts(): Artifact[];
46
+ /**
47
+ * Gets the schema name.
48
+ */
49
+ getName(): string;
50
+ /**
51
+ * Gets the schema version.
52
+ */
53
+ getVersion(): number;
54
+ /**
55
+ * Computes the topological build order using Kahn's algorithm.
56
+ * Returns artifact IDs in the order they should be built.
57
+ */
58
+ getBuildOrder(): string[];
59
+ /**
60
+ * Gets artifacts that are ready to be created (all dependencies completed).
61
+ */
62
+ getNextArtifacts(completed: CompletedSet): string[];
63
+ /**
64
+ * Checks if all artifacts in the graph are completed.
65
+ */
66
+ isComplete(completed: CompletedSet): boolean;
67
+ /**
68
+ * Gets blocked artifacts and their unmet dependencies.
69
+ */
70
+ getBlocked(completed: CompletedSet): BlockedArtifacts;
71
+ }
72
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1,165 @@
1
+ import { loadSchema, parseSchema } from './schema.js';
2
+ /**
3
+ * Represents an artifact dependency graph.
4
+ * Provides methods for querying build order, ready artifacts, and completion status.
5
+ */
6
+ export class ArtifactGraph {
7
+ artifacts;
8
+ schema;
9
+ /** Artifact id -> its position in the schema's `artifacts:` list. */
10
+ declarationOrder;
11
+ constructor(schema) {
12
+ this.schema = schema;
13
+ this.artifacts = new Map(schema.artifacts.map(a => [a.id, a]));
14
+ this.declarationOrder = new Map(schema.artifacts.map((a, index) => [a.id, index]));
15
+ }
16
+ /**
17
+ * Orders artifact ids by where the schema declares them.
18
+ *
19
+ * The dependency graph leaves siblings tied - spec-driven's `specs` and
20
+ * `design` both require only `proposal`, so both become ready at the same
21
+ * time. Ties used to be broken alphabetically, which put `design` ahead of
22
+ * `specs` and made the CLI recommend the artifacts in an order that
23
+ * contradicted the schema's own documented sequence
24
+ * (proposal -> specs -> design -> tasks). Breaking ties by declaration order
25
+ * follows the sequence the schema author wrote, for built-in and custom
26
+ * schemas alike, and stays just as deterministic. Ids not in the schema sort
27
+ * last so the comparator stays total.
28
+ */
29
+ compareByDeclarationOrder(a, b) {
30
+ return ((this.declarationOrder.get(a) ?? Number.MAX_SAFE_INTEGER) -
31
+ (this.declarationOrder.get(b) ?? Number.MAX_SAFE_INTEGER));
32
+ }
33
+ /**
34
+ * Creates an ArtifactGraph from a YAML file path.
35
+ */
36
+ static fromYaml(filePath) {
37
+ const schema = loadSchema(filePath);
38
+ return new ArtifactGraph(schema);
39
+ }
40
+ /**
41
+ * Creates an ArtifactGraph from YAML content string.
42
+ */
43
+ static fromYamlContent(yamlContent) {
44
+ const schema = parseSchema(yamlContent);
45
+ return new ArtifactGraph(schema);
46
+ }
47
+ /**
48
+ * Creates an ArtifactGraph from a pre-validated schema object.
49
+ */
50
+ static fromSchema(schema) {
51
+ return new ArtifactGraph(schema);
52
+ }
53
+ /**
54
+ * Gets a single artifact by ID.
55
+ */
56
+ getArtifact(id) {
57
+ return this.artifacts.get(id);
58
+ }
59
+ /**
60
+ * Gets all artifacts in the graph.
61
+ */
62
+ getAllArtifacts() {
63
+ return Array.from(this.artifacts.values());
64
+ }
65
+ /**
66
+ * Gets the schema name.
67
+ */
68
+ getName() {
69
+ return this.schema.name;
70
+ }
71
+ /**
72
+ * Gets the schema version.
73
+ */
74
+ getVersion() {
75
+ return this.schema.version;
76
+ }
77
+ /**
78
+ * Computes the topological build order using Kahn's algorithm.
79
+ * Returns artifact IDs in the order they should be built.
80
+ */
81
+ getBuildOrder() {
82
+ const inDegree = new Map();
83
+ const dependents = new Map();
84
+ // Initialize all artifacts
85
+ for (const artifact of this.artifacts.values()) {
86
+ inDegree.set(artifact.id, artifact.requires.length);
87
+ dependents.set(artifact.id, []);
88
+ }
89
+ // Build reverse adjacency (who depends on whom)
90
+ for (const artifact of this.artifacts.values()) {
91
+ for (const req of artifact.requires) {
92
+ dependents.get(req).push(artifact.id);
93
+ }
94
+ }
95
+ // Start with roots (in-degree 0), in declaration order for determinism
96
+ const queue = [...this.artifacts.keys()]
97
+ .filter(id => inDegree.get(id) === 0)
98
+ .sort((a, b) => this.compareByDeclarationOrder(a, b));
99
+ const result = [];
100
+ while (queue.length > 0) {
101
+ const current = queue.shift();
102
+ result.push(current);
103
+ // Collect newly ready artifacts, then sort before adding
104
+ const newlyReady = [];
105
+ for (const dep of dependents.get(current)) {
106
+ const newDegree = inDegree.get(dep) - 1;
107
+ inDegree.set(dep, newDegree);
108
+ if (newDegree === 0) {
109
+ newlyReady.push(dep);
110
+ }
111
+ }
112
+ // Re-sort the whole queue, not just the new arrivals: an artifact that
113
+ // has been waiting can be declared after one that just became ready.
114
+ queue.push(...newlyReady);
115
+ queue.sort((a, b) => this.compareByDeclarationOrder(a, b));
116
+ }
117
+ return result;
118
+ }
119
+ /**
120
+ * Gets artifacts that are ready to be created (all dependencies completed).
121
+ */
122
+ getNextArtifacts(completed) {
123
+ const ready = [];
124
+ for (const artifact of this.artifacts.values()) {
125
+ if (completed.has(artifact.id)) {
126
+ continue; // Already completed
127
+ }
128
+ const allDepsCompleted = artifact.requires.every(req => completed.has(req));
129
+ if (allDepsCompleted) {
130
+ ready.push(artifact.id);
131
+ }
132
+ }
133
+ // Declaration order: deterministic, and the first entry is the artifact the
134
+ // schema wants written next.
135
+ return ready.sort((a, b) => this.compareByDeclarationOrder(a, b));
136
+ }
137
+ /**
138
+ * Checks if all artifacts in the graph are completed.
139
+ */
140
+ isComplete(completed) {
141
+ for (const artifact of this.artifacts.values()) {
142
+ if (!completed.has(artifact.id)) {
143
+ return false;
144
+ }
145
+ }
146
+ return true;
147
+ }
148
+ /**
149
+ * Gets blocked artifacts and their unmet dependencies.
150
+ */
151
+ getBlocked(completed) {
152
+ const blocked = {};
153
+ for (const artifact of this.artifacts.values()) {
154
+ if (completed.has(artifact.id)) {
155
+ continue; // Already completed
156
+ }
157
+ const unmetDeps = artifact.requires.filter(req => !completed.has(req));
158
+ if (unmetDeps.length > 0) {
159
+ blocked[artifact.id] = unmetDeps.sort((a, b) => this.compareByDeclarationOrder(a, b));
160
+ }
161
+ }
162
+ return blocked;
163
+ }
164
+ }
165
+ //# sourceMappingURL=graph.js.map
@@ -0,0 +1,9 @@
1
+ export { ArtifactSchema, SchemaYamlSchema, type Artifact, type SchemaYaml, type CompletedSet, type BlockedArtifacts, } from './types.js';
2
+ export { loadSchema, parseSchema, SchemaValidationError } from './schema.js';
3
+ export { ArtifactGraph } from './graph.js';
4
+ export { detectCompleted } from './state.js';
5
+ export { artifactOutputExists, isGlobPattern, resolveArtifactOutputPath, resolveArtifactOutputs, } from './outputs.js';
6
+ export { resolveSchema, listSchemas, listSchemasWithInfo, getSchemaDir, getPackageSchemasDir, getUserSchemasDir, SchemaLoadError, type SchemaInfo, } from './resolver.js';
7
+ export { loadTemplate, loadChangeContext, generateInstructions, formatChangeStatus, TemplateLoadError, type ChangeContext, type LoadChangeContextOptions, type ArtifactInstructions, type DependencyInfo, type ArtifactStatus, type ChangeStatus, type ArtifactPathSummary, } from './instruction-loader.js';
8
+ export type { PlanningHomeSummary, ActionContext, } from '../change-status-policy.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,14 @@
1
+ // Types
2
+ export { ArtifactSchema, SchemaYamlSchema, } from './types.js';
3
+ // Schema loading and validation
4
+ export { loadSchema, parseSchema, SchemaValidationError } from './schema.js';
5
+ // Graph operations
6
+ export { ArtifactGraph } from './graph.js';
7
+ // State detection
8
+ export { detectCompleted } from './state.js';
9
+ export { artifactOutputExists, isGlobPattern, resolveArtifactOutputPath, resolveArtifactOutputs, } from './outputs.js';
10
+ // Schema resolution
11
+ export { resolveSchema, listSchemas, listSchemasWithInfo, getSchemaDir, getPackageSchemasDir, getUserSchemasDir, SchemaLoadError, } from './resolver.js';
12
+ // Instruction loading
13
+ export { loadTemplate, loadChangeContext, generateInstructions, formatChangeStatus, TemplateLoadError, } from './instruction-loader.js';
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,208 @@
1
+ import { ArtifactGraph } from './graph.js';
2
+ import { type ActionContext, type PlanningHomeSummary } from '../change-status-policy.js';
3
+ import { type ProjectConfig } from '../project-config.js';
4
+ import type { PlanningHome } from '../planning-home.js';
5
+ import type { ChangeMetadata } from '../change-metadata/index.js';
6
+ import type { CompletedSet } from './types.js';
7
+ /**
8
+ * Error thrown when loading a template fails.
9
+ */
10
+ export declare class TemplateLoadError extends Error {
11
+ readonly templatePath: string;
12
+ constructor(message: string, templatePath: string);
13
+ }
14
+ /**
15
+ * Change context containing graph, completion state, and metadata.
16
+ */
17
+ export interface ChangeContext {
18
+ /** The artifact dependency graph */
19
+ graph: ArtifactGraph;
20
+ /** Set of completed artifact IDs */
21
+ completed: CompletedSet;
22
+ /** Schema name being used */
23
+ schemaName: string;
24
+ /** Change name */
25
+ changeName: string;
26
+ /** Path to the change directory */
27
+ changeDir: string;
28
+ /** Project root directory */
29
+ projectRoot: string;
30
+ /** Resolved planning home for this change */
31
+ planningHome?: PlanningHome;
32
+ /** Parsed change metadata, when present */
33
+ metadata?: ChangeMetadata;
34
+ /** Non-fatal metadata diagnostics for text and JSON command surfaces */
35
+ warnings?: string[];
36
+ /**
37
+ * Artifact IDs counted as complete only because the change declares
38
+ * skip_specs, not because their files exist. Kept separate so status can
39
+ * render them as skipped rather than done.
40
+ */
41
+ skippedArtifacts?: Set<string>;
42
+ }
43
+ export interface LoadChangeContextOptions {
44
+ changeDir?: string;
45
+ planningHome?: PlanningHome;
46
+ /** Pre-read project config; suppresses schema resolution's fallback config read. */
47
+ projectConfig?: ProjectConfig | null;
48
+ }
49
+ /**
50
+ * Enriched instructions for creating an artifact.
51
+ */
52
+ export interface ArtifactInstructions {
53
+ /** Change name */
54
+ changeName: string;
55
+ /** Artifact ID */
56
+ artifactId: string;
57
+ /** Schema name */
58
+ schemaName: string;
59
+ /** Full path to change directory */
60
+ changeDir: string;
61
+ /** Resolved planning home for this change */
62
+ planningHome?: PlanningHomeSummary;
63
+ /** Output path pattern (e.g., "proposal.md") */
64
+ outputPath: string;
65
+ /** Absolute output path or glob pattern resolved under the change directory */
66
+ resolvedOutputPath: string;
67
+ /** Existing concrete output files for this artifact */
68
+ existingOutputPaths: string[];
69
+ /** Artifact description */
70
+ description: string;
71
+ /** Guidance on how to create this artifact (from schema instruction field) */
72
+ instruction: string | undefined;
73
+ /** Project context from config (constraints/background for AI, not to be included in output) */
74
+ context: string | undefined;
75
+ /** Artifact-specific rules from config (constraints for AI, not to be included in output) */
76
+ rules: string[] | undefined;
77
+ /** Template content (structure to follow - this IS the output format) */
78
+ template: string;
79
+ /** Dependencies with completion status and paths */
80
+ dependencies: DependencyInfo[];
81
+ /** Artifacts that become available after completing this one */
82
+ unlocks: string[];
83
+ /** True when the change declares skip_specs and this artifact is skipped */
84
+ skipped?: boolean;
85
+ /** Present only when skipped: tells the consumer not to create the artifact */
86
+ warning?: string;
87
+ /** Non-fatal metadata diagnostics */
88
+ warnings?: string[];
89
+ }
90
+ /**
91
+ * Dependency information including path and description.
92
+ */
93
+ export interface DependencyInfo {
94
+ /** Artifact ID */
95
+ id: string;
96
+ /** Whether the dependency is completed */
97
+ done: boolean;
98
+ /** Relative output path of the dependency (e.g., "proposal.md") */
99
+ path: string;
100
+ /** Description of the dependency artifact */
101
+ description: string;
102
+ /** True when the dependency is satisfied via skip_specs - no files exist to read */
103
+ skipped?: boolean;
104
+ }
105
+ /**
106
+ * Status of a single artifact in the workflow.
107
+ */
108
+ export interface ArtifactStatus {
109
+ /** Artifact ID */
110
+ id: string;
111
+ /** Output path pattern */
112
+ outputPath: string;
113
+ /** Status: done, skipped (via skip_specs), ready, or blocked */
114
+ status: 'done' | 'skipped' | 'ready' | 'blocked';
115
+ /** Artifact IDs this artifact directly requires (its `requires` edges).
116
+ * Present for every status so callers can compute the transitive required
117
+ * set even when the artifact is already `done` (file-existence status does
118
+ * not imply its dependencies exist). */
119
+ requires: string[];
120
+ /** Missing dependencies (only for blocked) */
121
+ missingDeps?: string[];
122
+ }
123
+ /**
124
+ * Formatted change status.
125
+ */
126
+ export interface ChangeStatus {
127
+ /** Change name */
128
+ changeName: string;
129
+ /** Schema name */
130
+ schemaName: string;
131
+ /** Planning home facts (generated skills derive the archive dir
132
+ * from planningHome.changesDir - a published agent contract). */
133
+ planningHome?: PlanningHomeSummary;
134
+ /** Full path to the change root */
135
+ changeRoot: string;
136
+ /** Absolute artifact path details keyed by artifact ID */
137
+ artifactPaths: Record<string, ArtifactPathSummary>;
138
+ /** Plain-language next steps for users and agents */
139
+ nextSteps: string[];
140
+ /** Machine-readable action constraints for agents */
141
+ actionContext: ActionContext;
142
+ /** Whether all planning artifacts are complete */
143
+ isPlanningComplete: boolean;
144
+ /** Compatibility alias for isPlanningComplete */
145
+ isComplete: boolean;
146
+ /** Artifact IDs required before apply phase (from schema's apply.requires) */
147
+ applyRequires: string[];
148
+ /** Status of each artifact */
149
+ artifacts: ArtifactStatus[];
150
+ /** Non-fatal metadata diagnostics */
151
+ warnings?: string[];
152
+ }
153
+ export interface ArtifactPathSummary {
154
+ outputPath: string;
155
+ resolvedOutputPath: string;
156
+ existingOutputPaths: string[];
157
+ }
158
+ /**
159
+ * Loads a template from a schema's templates directory.
160
+ *
161
+ * @param schemaName - Schema name (e.g., "spec-driven")
162
+ * @param templatePath - Relative path within the templates directory (e.g., "proposal.md")
163
+ * @param projectRoot - Optional project root for project-local schema resolution
164
+ * @returns The template content
165
+ * @throws TemplateLoadError if the template cannot be loaded
166
+ */
167
+ export declare function loadTemplate(schemaName: string, templatePath: string, projectRoot?: string): string;
168
+ /**
169
+ * Loads change context combining graph and completion state.
170
+ *
171
+ * Schema resolution order:
172
+ * 1. Explicit schemaName parameter (if provided)
173
+ * 2. Schema from .freespec.yaml metadata (if exists in change directory)
174
+ * 3. Default schema (`默认`)
175
+ *
176
+ * @param projectRoot - Project root directory
177
+ * @param changeName - Change name
178
+ * @param schemaName - Optional schema name override. If not provided, auto-detected from metadata.
179
+ * @returns Change context with graph, completed set, and metadata
180
+ */
181
+ export declare function loadChangeContext(projectRoot: string, changeName: string, schemaName?: string, options?: LoadChangeContextOptions): ChangeContext;
182
+ /**
183
+ * Generates enriched instructions for creating an artifact.
184
+ *
185
+ * Instruction injection order:
186
+ * 1. <context> - Project context from config (if present)
187
+ * 2. <rules> - Artifact-specific rules from config (if present)
188
+ * 3. <template> - Schema's template content
189
+ *
190
+ * @param context - Change context
191
+ * @param artifactId - Artifact ID to generate instructions for
192
+ * @param projectRoot - Project root directory (for reading config)
193
+ * @returns Enriched artifact instructions
194
+ * @throws Error if artifact not found
195
+ */
196
+ export interface GenerateInstructionsOptions {
197
+ /** Pre-read project config; suppresses the internal read (no double read). */
198
+ projectConfig?: ProjectConfig | null;
199
+ }
200
+ export declare function generateInstructions(context: ChangeContext, artifactId: string, projectRoot?: string, options?: GenerateInstructionsOptions): ArtifactInstructions;
201
+ /**
202
+ * Formats the status of all artifacts in a change.
203
+ *
204
+ * @param context - Change context
205
+ * @returns Formatted change status
206
+ */
207
+ export declare function formatChangeStatus(context: ChangeContext): ChangeStatus;
208
+ //# sourceMappingURL=instruction-loader.d.ts.map