@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,104 @@
1
+ /**
2
+ * Command Reference Utilities
3
+ *
4
+ * Utilities for transforming command references to tool-specific formats.
5
+ */
6
+ import type { CommandSurfaceCapability } from '../core/command-surface.js';
7
+ import type { CommandInvocation } from '../core/command-generation/invocation.js';
8
+ /**
9
+ * Rewrites the canonical `/freespec:<command>` references that command bodies and
10
+ * skill templates are authored with into the form one tool actually registers
11
+ * — `/freespec-<command>` for tools that name the command by filename,
12
+ * `@freespec-<command>` for Amazon Q's prompt library.
13
+ *
14
+ * Only known command ids are rewritten, matching how
15
+ * `transformToSkillReferences` leaves unrecognized references alone, so a
16
+ * mistyped or invented `/freespec:<something>` is left as written rather than
17
+ * silently reshaped into a command that does not exist either.
18
+ *
19
+ * @param text - The text containing command references
20
+ * @param invocation - The tool's invocation, from resolveCommandInvocation()
21
+ * @returns Text with command references spelled the tool's way
22
+ *
23
+ * @example
24
+ * transformCommandInvocations('/freespec:new', { style: 'flat', prefix: '/' }) // '/freespec-new'
25
+ * transformCommandInvocations('/freespec:new', { style: 'flat', prefix: '@' }) // '@freespec-new'
26
+ */
27
+ export declare function transformCommandInvocations(text: string, invocation: CommandInvocation): string;
28
+ /**
29
+ * Whether a tool references skills by natural language rather than a slash
30
+ * command (see NATURAL_LANGUAGE_SKILL_TOOLS).
31
+ */
32
+ export declare function usesNaturalLanguageSkillReferences(toolId: string): boolean;
33
+ /**
34
+ * Keeps Codex's `$<name>` spelling first while making its canonical shared
35
+ * `.agents` tree usable by agents that invoke the same skills with `/<name>`.
36
+ */
37
+ export declare function transformToCodexCompatibleSkillReferences(text: string): string;
38
+ /**
39
+ * Transforms command references to skill references using the default `/`
40
+ * invocation prefix. Converts `/freespec:<command>` patterns to
41
+ * `/freespec-<skill>` so that generated skills do not reference commands
42
+ * that were never generated. Used for channels that are not tied to one
43
+ * tool (e.g. the skills.sh distribution); tool-targeted generation should
44
+ * go through getSkillReferenceTransformer instead.
45
+ *
46
+ * Unknown command references are left unchanged.
47
+ *
48
+ * @param text - The text containing command references
49
+ * @returns Text with command references transformed to skill references
50
+ *
51
+ * @example
52
+ * transformToSkillReferences('/freespec:apply') // returns '/freespec-apply-change'
53
+ * transformToSkillReferences('Use /freespec:archive next') // returns 'Use /freespec-archive-change next'
54
+ */
55
+ export declare function transformToSkillReferences(text: string): string;
56
+ /**
57
+ * Returns the skill-reference transformer for a specific tool, honoring the
58
+ * tool's documented skill invocation syntax (e.g. Kimi Code's
59
+ * `/skill:freespec-propose`). Tools with no slash surface (e.g. Rovo Dev) get
60
+ * natural-language references ("the freespec-propose skill"); everything else
61
+ * falls back to the default `/freespec-*` form.
62
+ *
63
+ * @param toolId - The AI tool identifier (e.g. 'kimi', 'vibe', 'rovodev')
64
+ * @returns A transformer converting `/freespec:*` references to skill invocations
65
+ */
66
+ export declare function getSkillReferenceTransformer(toolId: string): (text: string) => string;
67
+ /**
68
+ * Selects the command-reference transformer for a skill generation target.
69
+ *
70
+ * Skill references are used whenever the tool ends up without `/freespec:*`
71
+ * commands — because delivery is skills-only, because the tool has no command
72
+ * surface at all (capability 'none', e.g. Kimi Code or Mistral Vibe), or
73
+ * because the tool invokes skills directly and FreeSpec generates no command
74
+ * files for it (capability 'skills-invocable', e.g. Codex or Warp) — so those skills
75
+ * never point at commands that were not generated.
76
+ *
77
+ * When commands are generated, the spelling follows the tool's invocation: a
78
+ * `flat` adapter names the command by filename (`.cursor/commands/freespec-apply.md`
79
+ * → `/freespec-apply`), a `namespaced` adapter puts it in an `freespec/` directory
80
+ * (`.claude/commands/freespec/apply.md` → `/freespec:apply`), and a non-slash prefix
81
+ * wraps it further (`.amazonq/prompts/freespec-apply.md` → `@freespec-apply`). Passing
82
+ * the invocation in keeps this module free of a hand-maintained tool list —
83
+ * the list drifted and left 16 tools advertising commands their palettes never
84
+ * registered (#727, #1307).
85
+ *
86
+ * Devin is the one tool that takes skill references even though its commands
87
+ * are generated: only Devin Desktop reads `.devin/workflows/`, so a workflow
88
+ * reference is dead text for anyone on Devin Local, while the `/freespec-*`
89
+ * skills work on both agents. Under commands-only delivery there are no Devin
90
+ * skills to point at, so it falls through to the invocation rewrite below and
91
+ * gets the `/freespec-<id>` form its workflow filenames register.
92
+ *
93
+ * @param toolId - The AI tool identifier (e.g. 'claude', 'opencode', 'pi')
94
+ * @param delivery - The configured delivery mode
95
+ * @param capability - The tool's command surface capability
96
+ * @param invocation - How the tool's generated commands are invoked, from
97
+ * resolveCommandInvocation(); undefined for tools with no command
98
+ * adapter. Required rather than optional so a caller that forgets it
99
+ * fails to compile instead of silently getting the canonical form.
100
+ * @returns The transformer to pass to generateSkillContent, or undefined when
101
+ * the tool already answers to the canonical `/freespec:<id>`
102
+ */
103
+ export declare function getTransformerForTool(toolId: string, delivery: 'both' | 'skills' | 'commands', capability: CommandSurfaceCapability, invocation: CommandInvocation | undefined): ((text: string) => string) | undefined;
104
+ //# sourceMappingURL=command-references.d.ts.map
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Command Reference Utilities
3
+ *
4
+ * Utilities for transforming command references to tool-specific formats.
5
+ */
6
+ // Value import of a pure, dependency-free helper: invocation.ts imports only
7
+ // `path` and a type, so this does not close the cycle the note above guards.
8
+ import { formatCommandInvocation, needsInvocationRewrite, } from '../core/command-generation/invocation.js';
9
+ /**
10
+ * Rewrites the canonical `/freespec:<command>` references that command bodies and
11
+ * skill templates are authored with into the form one tool actually registers
12
+ * — `/freespec-<command>` for tools that name the command by filename,
13
+ * `@freespec-<command>` for Amazon Q's prompt library.
14
+ *
15
+ * Only known command ids are rewritten, matching how
16
+ * `transformToSkillReferences` leaves unrecognized references alone, so a
17
+ * mistyped or invented `/freespec:<something>` is left as written rather than
18
+ * silently reshaped into a command that does not exist either.
19
+ *
20
+ * @param text - The text containing command references
21
+ * @param invocation - The tool's invocation, from resolveCommandInvocation()
22
+ * @returns Text with command references spelled the tool's way
23
+ *
24
+ * @example
25
+ * transformCommandInvocations('/freespec:new', { style: 'flat', prefix: '/' }) // '/freespec-new'
26
+ * transformCommandInvocations('/freespec:new', { style: 'flat', prefix: '@' }) // '@freespec-new'
27
+ */
28
+ export function transformCommandInvocations(text, invocation) {
29
+ return text.replace(/\/freespec:([a-zA-Z0-9\u4e00-\u9fff-]+)/g, (match, commandId) => commandId in COMMAND_TO_SKILL_NAME
30
+ ? formatCommandInvocation(invocation, commandId)
31
+ : match);
32
+ }
33
+ /**
34
+ * Maps command short names to their skill names.
35
+ * Keep in sync with WORKFLOW_TO_SKILL_DIR, which exists in both
36
+ * src/core/profile-sync-drift.ts (exported) and src/core/init.ts (local copy).
37
+ */
38
+ const COMMAND_TO_SKILL_NAME = {
39
+ '新建': '新建',
40
+ '深思': '深思',
41
+ '需求': '需求',
42
+ '设计': '设计',
43
+ '任务': '任务',
44
+ '审文档': '审文档',
45
+ '用例': '用例',
46
+ '验收': '验收',
47
+ '写Java': '写Java',
48
+ '审Java': '审Java',
49
+ };
50
+ /**
51
+ * Tools whose skill invocation uses a non-default prefix. The default is `/`
52
+ * (e.g. `/freespec-propose`); Kimi Code invokes skills as `/skill:<name>` and
53
+ * Codex CLI as `$<name>` — a `/<name>` form Codex does not recognize
54
+ * (see docs/supported-tools.md).
55
+ */
56
+ const SKILL_INVOCATION_PREFIX = {
57
+ kimi: '/skill:',
58
+ codex: '$',
59
+ };
60
+ /**
61
+ * Tools with no documented slash invocation for skills: use automatic
62
+ * matching or natural-language prompts instead. SourceCraft Code Assistant
63
+ * supports separate command files, but its skills use description matching.
64
+ * Rovo Dev's `/skills` only manages skills (see docs/supported-tools.md).
65
+ * Skill references for these tools are spelled as prose ("the freespec-propose
66
+ * skill") so skills-only delivery does not advertise unregistered commands.
67
+ */
68
+ const NATURAL_LANGUAGE_SKILL_TOOLS = new Set(['gsd', 'rovodev', 'codeassistant']);
69
+ /**
70
+ * Whether a tool references skills by natural language rather than a slash
71
+ * command (see NATURAL_LANGUAGE_SKILL_TOOLS).
72
+ */
73
+ export function usesNaturalLanguageSkillReferences(toolId) {
74
+ return NATURAL_LANGUAGE_SKILL_TOOLS.has(toolId);
75
+ }
76
+ function replaceCommandsWithNaturalLanguageSkillReferences(text) {
77
+ return text.replace(/\/freespec:([a-zA-Z0-9\u4e00-\u9fff-]+)/g, (match, commandId) => {
78
+ const skillName = COMMAND_TO_SKILL_NAME[commandId];
79
+ return skillName === undefined ? match : `the ${skillName} skill`;
80
+ });
81
+ }
82
+ function replaceCommandsWithSkillReferences(text, prefix) {
83
+ return text.replace(/\/freespec:([a-zA-Z0-9\u4e00-\u9fff-]+)/g, (match, commandId) => {
84
+ const skillName = COMMAND_TO_SKILL_NAME[commandId];
85
+ return skillName === undefined ? match : `${prefix}${skillName}`;
86
+ });
87
+ }
88
+ /**
89
+ * Keeps Codex's `$<name>` spelling first while making its canonical shared
90
+ * `.agents` tree usable by agents that invoke the same skills with `/<name>`.
91
+ */
92
+ export function transformToCodexCompatibleSkillReferences(text) {
93
+ return text.replace(/\/freespec:([a-zA-Z0-9\u4e00-\u9fff-]+)/g, (match, commandId) => {
94
+ const skillName = COMMAND_TO_SKILL_NAME[commandId];
95
+ return skillName === undefined
96
+ ? match
97
+ : `$${skillName} (Codex) or /${skillName} (other agents)`;
98
+ });
99
+ }
100
+ /**
101
+ * Transforms command references to skill references using the default `/`
102
+ * invocation prefix. Converts `/freespec:<command>` patterns to
103
+ * `/freespec-<skill>` so that generated skills do not reference commands
104
+ * that were never generated. Used for channels that are not tied to one
105
+ * tool (e.g. the skills.sh distribution); tool-targeted generation should
106
+ * go through getSkillReferenceTransformer instead.
107
+ *
108
+ * Unknown command references are left unchanged.
109
+ *
110
+ * @param text - The text containing command references
111
+ * @returns Text with command references transformed to skill references
112
+ *
113
+ * @example
114
+ * transformToSkillReferences('/freespec:apply') // returns '/freespec-apply-change'
115
+ * transformToSkillReferences('Use /freespec:archive next') // returns 'Use /freespec-archive-change next'
116
+ */
117
+ export function transformToSkillReferences(text) {
118
+ return replaceCommandsWithSkillReferences(text, '/');
119
+ }
120
+ /**
121
+ * Returns the skill-reference transformer for a specific tool, honoring the
122
+ * tool's documented skill invocation syntax (e.g. Kimi Code's
123
+ * `/skill:freespec-propose`). Tools with no slash surface (e.g. Rovo Dev) get
124
+ * natural-language references ("the freespec-propose skill"); everything else
125
+ * falls back to the default `/freespec-*` form.
126
+ *
127
+ * @param toolId - The AI tool identifier (e.g. 'kimi', 'vibe', 'rovodev')
128
+ * @returns A transformer converting `/freespec:*` references to skill invocations
129
+ */
130
+ export function getSkillReferenceTransformer(toolId) {
131
+ if (usesNaturalLanguageSkillReferences(toolId)) {
132
+ return replaceCommandsWithNaturalLanguageSkillReferences;
133
+ }
134
+ const prefix = SKILL_INVOCATION_PREFIX[toolId];
135
+ if (prefix === undefined) {
136
+ return transformToSkillReferences;
137
+ }
138
+ return (text) => replaceCommandsWithSkillReferences(text, prefix);
139
+ }
140
+ /**
141
+ * Selects the command-reference transformer for a skill generation target.
142
+ *
143
+ * Skill references are used whenever the tool ends up without `/freespec:*`
144
+ * commands — because delivery is skills-only, because the tool has no command
145
+ * surface at all (capability 'none', e.g. Kimi Code or Mistral Vibe), or
146
+ * because the tool invokes skills directly and FreeSpec generates no command
147
+ * files for it (capability 'skills-invocable', e.g. Codex or Warp) — so those skills
148
+ * never point at commands that were not generated.
149
+ *
150
+ * When commands are generated, the spelling follows the tool's invocation: a
151
+ * `flat` adapter names the command by filename (`.cursor/commands/freespec-apply.md`
152
+ * → `/freespec-apply`), a `namespaced` adapter puts it in an `freespec/` directory
153
+ * (`.claude/commands/freespec/apply.md` → `/freespec:apply`), and a non-slash prefix
154
+ * wraps it further (`.amazonq/prompts/freespec-apply.md` → `@freespec-apply`). Passing
155
+ * the invocation in keeps this module free of a hand-maintained tool list —
156
+ * the list drifted and left 16 tools advertising commands their palettes never
157
+ * registered (#727, #1307).
158
+ *
159
+ * Devin is the one tool that takes skill references even though its commands
160
+ * are generated: only Devin Desktop reads `.devin/workflows/`, so a workflow
161
+ * reference is dead text for anyone on Devin Local, while the `/freespec-*`
162
+ * skills work on both agents. Under commands-only delivery there are no Devin
163
+ * skills to point at, so it falls through to the invocation rewrite below and
164
+ * gets the `/freespec-<id>` form its workflow filenames register.
165
+ *
166
+ * @param toolId - The AI tool identifier (e.g. 'claude', 'opencode', 'pi')
167
+ * @param delivery - The configured delivery mode
168
+ * @param capability - The tool's command surface capability
169
+ * @param invocation - How the tool's generated commands are invoked, from
170
+ * resolveCommandInvocation(); undefined for tools with no command
171
+ * adapter. Required rather than optional so a caller that forgets it
172
+ * fails to compile instead of silently getting the canonical form.
173
+ * @returns The transformer to pass to generateSkillContent, or undefined when
174
+ * the tool already answers to the canonical `/freespec:<id>`
175
+ */
176
+ export function getTransformerForTool(toolId, delivery, capability, invocation) {
177
+ if (delivery === 'skills' || capability !== 'adapter-backed') {
178
+ return toolId === 'codex'
179
+ ? transformToCodexCompatibleSkillReferences
180
+ : getSkillReferenceTransformer(toolId);
181
+ }
182
+ if (toolId === 'devin' && delivery === 'both') {
183
+ return getSkillReferenceTransformer(toolId);
184
+ }
185
+ if (invocation !== undefined && needsInvocationRewrite(invocation)) {
186
+ return (text) => transformCommandInvocations(text, invocation);
187
+ }
188
+ return undefined;
189
+ }
190
+ //# sourceMappingURL=command-references.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Formats a date using the effective local time zone of the Node.js process.
3
+ *
4
+ * The result is locale-independent and suitable for date-only metadata and
5
+ * path prefixes.
6
+ */
7
+ export declare function formatLocalDate(date?: Date): string;
8
+ //# sourceMappingURL=date.d.ts.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Formats a date using the effective local time zone of the Node.js process.
3
+ *
4
+ * The result is locale-independent and suitable for date-only metadata and
5
+ * path prefixes.
6
+ */
7
+ export function formatLocalDate(date = new Date()) {
8
+ const year = date.getFullYear();
9
+ const month = String(date.getMonth() + 1).padStart(2, '0');
10
+ const day = String(date.getDate()).padStart(2, '0');
11
+ return `${year}-${month}-${day}`;
12
+ }
13
+ //# sourceMappingURL=date.js.map
@@ -0,0 +1,5 @@
1
+ /** Every `freespec` on PATH, in the order a shell would find them. */
2
+ export declare function findCopiesOnPath(pathValue?: string, platform?: NodeJS.Platform): string[];
3
+ /** Whether two paths name the same file once symlinks are resolved. */
4
+ export declare function samePath(a: string, b: string): boolean;
5
+ //# sourceMappingURL=executable-path.d.ts.map
@@ -0,0 +1,44 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ /** Every `freespec` on PATH, in the order a shell would find them. */
4
+ export function findCopiesOnPath(pathValue = process.env.PATH ?? '', platform = process.platform) {
5
+ const names = platform === 'win32' ? ['freespec.exe', 'freespec.cmd'] : ['freespec'];
6
+ const seen = new Set();
7
+ const copies = [];
8
+ for (const dir of pathValue.split(path.delimiter)) {
9
+ if (!dir)
10
+ continue;
11
+ for (const name of names) {
12
+ const candidate = path.join(dir, name);
13
+ try {
14
+ if (!fs.statSync(candidate).isFile())
15
+ continue;
16
+ if (platform !== 'win32')
17
+ fs.accessSync(candidate, fs.constants.X_OK);
18
+ const key = platform === 'win32' ? candidate.toLowerCase() : candidate;
19
+ if (!seen.has(key)) {
20
+ seen.add(key);
21
+ copies.push(candidate);
22
+ }
23
+ }
24
+ catch {
25
+ // Not there, or not runnable: not a copy a shell would run.
26
+ }
27
+ }
28
+ }
29
+ return copies;
30
+ }
31
+ /** Whether two paths name the same file once symlinks are resolved. */
32
+ export function samePath(a, b) {
33
+ const real = (value) => {
34
+ try {
35
+ return fs.realpathSync(value);
36
+ }
37
+ catch {
38
+ return path.resolve(value);
39
+ }
40
+ };
41
+ const [x, y] = [real(a), real(b)];
42
+ return process.platform === 'win32' ? x.toLowerCase() === y.toLowerCase() : x === y;
43
+ }
44
+ //# sourceMappingURL=executable-path.js.map
@@ -0,0 +1,58 @@
1
+ export declare class FileSystemUtils {
2
+ /**
3
+ * Converts a path to use forward slashes (POSIX style).
4
+ * Essential for cross-platform compatibility with glob libraries like tinyglobby.
5
+ */
6
+ static toPosixPath(p: string): string;
7
+ /**
8
+ * Returns a canonical absolute path when the target exists.
9
+ * Falls back to path.resolve() so callers can still produce a stable absolute path.
10
+ */
11
+ static canonicalizeExistingPath(targetPath: string): string;
12
+ /**
13
+ * Refuses a target that leaves an allowed directory, including through an
14
+ * existing symlink in either the target or one of its parent directories.
15
+ * Missing suffixes are resolved from their nearest existing ancestor.
16
+ */
17
+ static assertPathWithin(allowedDirectory: string, targetPath: string): void;
18
+ /**
19
+ * Like assertPathWithin, but a targetPath that is itself a symlink may
20
+ * resolve outside allowedDirectory, so a project can keep a managed
21
+ * directory (for example freespec) in another repository. Its parent
22
+ * must still be confined and the link must resolve to an existing path.
23
+ */
24
+ static assertPathWithinAllowingLinkedLeaf(allowedDirectory: string, targetPath: string): void;
25
+ static resolveProjectArtifactPath(projectPath: string, artifactPath: string): string;
26
+ static assertProjectArtifactPath(projectPath: string, targetPath: string): void;
27
+ private static isPathWithin;
28
+ private static canonicalizePotentialPath;
29
+ private static isWindowsBasePath;
30
+ private static normalizeSegments;
31
+ static joinPath(basePath: string, ...segments: string[]): string;
32
+ static createDirectory(dirPath: string): Promise<void>;
33
+ static fileExists(filePath: string): Promise<boolean>;
34
+ /**
35
+ * Finds the first existing parent directory by walking up the directory tree.
36
+ * @param dirPath Starting directory path
37
+ * @returns The first existing directory path, or null if root is reached without finding one
38
+ */
39
+ private static findFirstExistingDirectory;
40
+ static canWriteFile(filePath: string): Promise<boolean>;
41
+ static directoryExists(dirPath: string): Promise<boolean>;
42
+ static writeFile(filePath: string, content: string): Promise<void>;
43
+ static readFile(filePath: string): Promise<string>;
44
+ static updateFileWithMarkers(filePath: string, content: string, startMarker: string, endMarker: string): Promise<void>;
45
+ static ensureWritePermissions(dirPath: string): Promise<boolean>;
46
+ }
47
+ /**
48
+ * Removes a marker block from file content.
49
+ * Only removes markers that are on their own lines (ignores inline mentions).
50
+ * Cleans up double blank lines that may result from removal.
51
+ *
52
+ * @param content - File content with markers
53
+ * @param startMarker - The start marker string
54
+ * @param endMarker - The end marker string
55
+ * @returns Content with marker block removed, or original content if markers not found/invalid
56
+ */
57
+ export declare function removeMarkerBlock(content: string, startMarker: string, endMarker: string): string;
58
+ //# sourceMappingURL=file-system.d.ts.map