@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,14 @@
1
+ /**
2
+ * Zoo Code Command Adapter
3
+ *
4
+ * Formats commands for Zoo Code following its workflow specification.
5
+ * Zoo Code uses markdown headers instead of YAML frontmatter.
6
+ */
7
+ import type { ToolCommandAdapter } from '../types.js';
8
+ /**
9
+ * Zoo Code adapter for command generation.
10
+ * File path: .roo/commands/freespec-<id>.md
11
+ * Format: Markdown header with description
12
+ */
13
+ export declare const roocodeAdapter: ToolCommandAdapter;
14
+ //# sourceMappingURL=roocode.d.ts.map
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Zoo Code Command Adapter
3
+ *
4
+ * Formats commands for Zoo Code following its workflow specification.
5
+ * Zoo Code uses markdown headers instead of YAML frontmatter.
6
+ */
7
+ import path from 'path';
8
+ /**
9
+ * Zoo Code adapter for command generation.
10
+ * File path: .roo/commands/freespec-<id>.md
11
+ * Format: Markdown header with description
12
+ */
13
+ export const roocodeAdapter = {
14
+ toolId: 'roocode',
15
+ getFilePath(commandId) {
16
+ return path.join('.roo', 'commands', `freespec-${commandId}.md`);
17
+ },
18
+ formatFile(content) {
19
+ return `# ${content.name}
20
+
21
+ ${content.description}
22
+
23
+ ${content.body}
24
+ `;
25
+ },
26
+ };
27
+ //# sourceMappingURL=roocode.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Trae Command Adapter
3
+ *
4
+ * Formats commands for Trae IDE following its command specification.
5
+ */
6
+ import type { ToolCommandAdapter } from '../types.js';
7
+ /**
8
+ * Trae adapter for command generation.
9
+ * File path: .trae/commands/freespec-<id>.md
10
+ * Frontmatter: name, description
11
+ */
12
+ export declare const traeAdapter: ToolCommandAdapter;
13
+ //# sourceMappingURL=trae.d.ts.map
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Trae Command Adapter
3
+ *
4
+ * Formats commands for Trae IDE following its command specification.
5
+ */
6
+ import path from 'path';
7
+ import { escapeYamlValue } from '../yaml.js';
8
+ /**
9
+ * Trae adapter for command generation.
10
+ * File path: .trae/commands/freespec-<id>.md
11
+ * Frontmatter: name, description
12
+ */
13
+ export const traeAdapter = {
14
+ toolId: 'trae',
15
+ getFilePath(commandId) {
16
+ return path.join('.trae', 'commands', `freespec-${commandId}.md`);
17
+ },
18
+ formatFile(content) {
19
+ return `---
20
+ name: ${escapeYamlValue(content.name)}
21
+ description: ${escapeYamlValue(content.description)}
22
+ ---
23
+
24
+ ${content.body}
25
+ `;
26
+ },
27
+ };
28
+ //# sourceMappingURL=trae.js.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * ZCode Command Adapter
3
+ *
4
+ * Formats commands for ZCode following its frontmatter specification.
5
+ * ZCode shares Claude Code's command format conventions.
6
+ * File path: .zcode/commands/freespec/<id>.md
7
+ * Frontmatter: name, description, category, tags
8
+ */
9
+ import type { ToolCommandAdapter } from '../types.js';
10
+ /**
11
+ * ZCode adapter for command generation.
12
+ * File path: .zcode/commands/freespec/<id>.md
13
+ * Frontmatter: name, description, category, tags
14
+ */
15
+ export declare const zcodeAdapter: ToolCommandAdapter;
16
+ //# sourceMappingURL=zcode.d.ts.map
@@ -0,0 +1,33 @@
1
+ /**
2
+ * ZCode Command Adapter
3
+ *
4
+ * Formats commands for ZCode following its frontmatter specification.
5
+ * ZCode shares Claude Code's command format conventions.
6
+ * File path: .zcode/commands/freespec/<id>.md
7
+ * Frontmatter: name, description, category, tags
8
+ */
9
+ import path from 'path';
10
+ import { escapeYamlValue, formatTagsArray } from '../yaml.js';
11
+ /**
12
+ * ZCode adapter for command generation.
13
+ * File path: .zcode/commands/freespec/<id>.md
14
+ * Frontmatter: name, description, category, tags
15
+ */
16
+ export const zcodeAdapter = {
17
+ toolId: 'zcode',
18
+ getFilePath(commandId) {
19
+ return path.join('.zcode', 'commands', 'freespec', `${commandId}.md`);
20
+ },
21
+ formatFile(content) {
22
+ return `---
23
+ name: ${escapeYamlValue(content.name)}
24
+ description: ${escapeYamlValue(content.description)}
25
+ category: ${escapeYamlValue(content.category)}
26
+ tags: ${formatTagsArray(content.tags)}
27
+ ---
28
+
29
+ ${content.body}
30
+ `;
31
+ },
32
+ };
33
+ //# sourceMappingURL=zcode.js.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Command Generator
3
+ *
4
+ * Functions for generating command files using tool adapters.
5
+ */
6
+ import type { CommandContent, ToolCommandAdapter, GeneratedCommand } from './types.js';
7
+ /**
8
+ * Generate a single command file using the provided adapter.
9
+ *
10
+ * Command bodies are authored with `/freespec:<id>` references. Tools whose command
11
+ * files are invoked by filename register `/freespec-<id>` instead, and Amazon Q
12
+ * surfaces them in its prompt library as `@freespec-<id>`, so the body is rewritten
13
+ * to the form that tool answers to before the adapter formats it. Doing it here
14
+ * rather than per adapter keeps every tool in step (#727, #1307); adapters stay
15
+ * pure formatters.
16
+ *
17
+ * @param content - The tool-agnostic command content
18
+ * @param adapter - The tool-specific adapter
19
+ * @returns Generated command with path and file content
20
+ */
21
+ export declare function generateCommand(content: CommandContent, adapter: ToolCommandAdapter): GeneratedCommand;
22
+ /**
23
+ * Generate multiple command files using the provided adapter.
24
+ * @param contents - Array of tool-agnostic command contents
25
+ * @param adapter - The tool-specific adapter
26
+ * @returns Array of generated commands with paths and file contents
27
+ */
28
+ export declare function generateCommands(contents: CommandContent[], adapter: ToolCommandAdapter): GeneratedCommand[];
29
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Command Generator
3
+ *
4
+ * Functions for generating command files using tool adapters.
5
+ */
6
+ import { getInvocationForAdapter, needsInvocationRewrite } from './invocation.js';
7
+ import { transformCommandInvocations } from '../../utils/command-references.js';
8
+ import { assertWorkflowConditionalsResolved } from '../templates/optional-workflow.js';
9
+ /**
10
+ * Generate a single command file using the provided adapter.
11
+ *
12
+ * Command bodies are authored with `/freespec:<id>` references. Tools whose command
13
+ * files are invoked by filename register `/freespec-<id>` instead, and Amazon Q
14
+ * surfaces them in its prompt library as `@freespec-<id>`, so the body is rewritten
15
+ * to the form that tool answers to before the adapter formats it. Doing it here
16
+ * rather than per adapter keeps every tool in step (#727, #1307); adapters stay
17
+ * pure formatters.
18
+ *
19
+ * @param content - The tool-agnostic command content
20
+ * @param adapter - The tool-specific adapter
21
+ * @returns Generated command with path and file content
22
+ */
23
+ export function generateCommand(content, adapter) {
24
+ assertWorkflowConditionalsResolved(content.body, `Command '${content.id}' was generated without resolving its optional-workflow blocks`);
25
+ const invocation = getInvocationForAdapter(adapter);
26
+ const formatted = needsInvocationRewrite(invocation)
27
+ ? { ...content, body: transformCommandInvocations(content.body, invocation) }
28
+ : content;
29
+ return {
30
+ path: adapter.getFilePath(content.id),
31
+ fileContent: adapter.formatFile(formatted),
32
+ };
33
+ }
34
+ /**
35
+ * Generate multiple command files using the provided adapter.
36
+ * @param contents - Array of tool-agnostic command contents
37
+ * @param adapter - The tool-specific adapter
38
+ * @returns Array of generated commands with paths and file contents
39
+ */
40
+ export function generateCommands(contents, adapter) {
41
+ return contents.map((content) => generateCommand(content, adapter));
42
+ }
43
+ //# sourceMappingURL=generator.js.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Command Generation Module
3
+ *
4
+ * Generic command generation system with tool-specific adapters.
5
+ *
6
+ * Usage:
7
+ * ```typescript
8
+ * import { generateCommands, CommandAdapterRegistry, type CommandContent } from './command-generation/index.js';
9
+ *
10
+ * const contents: CommandContent[] = [...];
11
+ * const adapter = CommandAdapterRegistry.get('cursor');
12
+ * if (adapter) {
13
+ * const commands = generateCommands(contents, adapter);
14
+ * // Write commands to disk
15
+ * }
16
+ * ```
17
+ */
18
+ export type { CommandContent, ToolCommandAdapter, GeneratedCommand, } from './types.js';
19
+ export { CommandAdapterRegistry } from './registry.js';
20
+ export { generateCommand, generateCommands } from './generator.js';
21
+ export { claudeAdapter, cursorAdapter, devinAdapter } from './adapters/index.js';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Command Generation Module
3
+ *
4
+ * Generic command generation system with tool-specific adapters.
5
+ *
6
+ * Usage:
7
+ * ```typescript
8
+ * import { generateCommands, CommandAdapterRegistry, type CommandContent } from './command-generation/index.js';
9
+ *
10
+ * const contents: CommandContent[] = [...];
11
+ * const adapter = CommandAdapterRegistry.get('cursor');
12
+ * if (adapter) {
13
+ * const commands = generateCommands(contents, adapter);
14
+ * // Write commands to disk
15
+ * }
16
+ * ```
17
+ */
18
+ // Registry
19
+ export { CommandAdapterRegistry } from './registry.js';
20
+ // Generator functions
21
+ export { generateCommand, generateCommands } from './generator.js';
22
+ // Adapters (for direct access if needed)
23
+ export { claudeAdapter, cursorAdapter, devinAdapter } from './adapters/index.js';
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Command Invocation
3
+ *
4
+ * How a tool spells a FreeSpec command has two parts, and only one of them
5
+ * can be read off the file the adapter writes:
6
+ *
7
+ * - The *name* comes from the file. `.../commands/freespec/<id>.md` is namespaced
8
+ * by its directory, so the tool registers `freespec:<id>` (Claude Code, Gemini,
9
+ * Crush, ...). `.../commands/freespec-<id>.md` names the command with the
10
+ * filename, so the tool registers `freespec-<id>` (Cursor, GitHub Copilot,
11
+ * OpenCode, ...).
12
+ * - The *prefix* is the tool's own and cannot be derived. Almost every tool
13
+ * uses `/`; Amazon Q loads these files into its prompt library, which is
14
+ * invoked with `@` (`@freespec-propose`), so its adapter declares that prefix.
15
+ *
16
+ * Deriving the name from `getFilePath` keeps generated cross-references and
17
+ * onboarding hints in step with the files FreeSpec actually writes. A
18
+ * hand-maintained list drifted before: only OpenCode was rewritten when the
19
+ * hyphen form was introduced (#727), and Cursor still advertised `/freespec:`
20
+ * commands its palette never registered (#1307). Carrying the prefix as
21
+ * adapter metadata rather than inferring it keeps the one tool that does not
22
+ * use a slash from being advertised as if it did.
23
+ */
24
+ import type { ToolCommandAdapter } from './types.js';
25
+ export type CommandInvocationStyle = 'namespaced' | 'flat';
26
+ /**
27
+ * Everything needed to spell one of a tool's FreeSpec commands.
28
+ */
29
+ export interface CommandInvocation {
30
+ /** How the command file names the command. */
31
+ style: CommandInvocationStyle;
32
+ /** What the user types before the name, e.g. `/` or Amazon Q's `@`. */
33
+ prefix: string;
34
+ }
35
+ /** The form these docs, command bodies, and skill templates are authored in. */
36
+ export declare const CANONICAL_INVOCATION: CommandInvocation;
37
+ /**
38
+ * Classifies a generated command file by the name the tool will answer to.
39
+ *
40
+ * The test is the filename, not the directory: an `freespec-` prefix means the
41
+ * filename is the command. Every other shape is treated as namespaced, which
42
+ * is what all seven `freespec/<id>.*` adapters need. An adapter that neither
43
+ * prefixes the filename nor nests under `freespec/` would land here too — none
44
+ * does, and the registry-wide test in invocation.test.ts fails if one appears.
45
+ *
46
+ * @param commandFilePath - Path returned by an adapter's `getFilePath`
47
+ * @returns 'flat' when the filename carries the `freespec-` prefix, otherwise
48
+ * 'namespaced'
49
+ */
50
+ export declare function getInvocationStyleForPath(commandFilePath: string): CommandInvocationStyle;
51
+ /**
52
+ * Resolves how a tool's generated commands are invoked: the name from the
53
+ * files its adapter writes, the prefix from the adapter's own declaration.
54
+ *
55
+ * @param adapter - The tool-specific command adapter
56
+ * @returns The invocation shared by every command that adapter generates
57
+ */
58
+ export declare function getInvocationForAdapter(adapter: ToolCommandAdapter): CommandInvocation;
59
+ /**
60
+ * Spells one command the way the tool registers it.
61
+ *
62
+ * @param invocation - The tool's invocation, from getInvocationForAdapter()
63
+ * @param commandId - The command identifier (e.g. 'apply')
64
+ * @returns What the user types, e.g. `/freespec:apply`, `/freespec-apply`, `@freespec-apply`
65
+ */
66
+ export declare function formatCommandInvocation(invocation: CommandInvocation, commandId: string): string;
67
+ /**
68
+ * Whether a tool's invocation differs from the canonical `/freespec:<id>` that
69
+ * command bodies and skill templates are authored in — that is, whether
70
+ * generated text has to be rewritten for that tool at all.
71
+ */
72
+ export declare function needsInvocationRewrite(invocation: CommandInvocation): boolean;
73
+ //# sourceMappingURL=invocation.d.ts.map
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Command Invocation
3
+ *
4
+ * How a tool spells a FreeSpec command has two parts, and only one of them
5
+ * can be read off the file the adapter writes:
6
+ *
7
+ * - The *name* comes from the file. `.../commands/freespec/<id>.md` is namespaced
8
+ * by its directory, so the tool registers `freespec:<id>` (Claude Code, Gemini,
9
+ * Crush, ...). `.../commands/freespec-<id>.md` names the command with the
10
+ * filename, so the tool registers `freespec-<id>` (Cursor, GitHub Copilot,
11
+ * OpenCode, ...).
12
+ * - The *prefix* is the tool's own and cannot be derived. Almost every tool
13
+ * uses `/`; Amazon Q loads these files into its prompt library, which is
14
+ * invoked with `@` (`@freespec-propose`), so its adapter declares that prefix.
15
+ *
16
+ * Deriving the name from `getFilePath` keeps generated cross-references and
17
+ * onboarding hints in step with the files FreeSpec actually writes. A
18
+ * hand-maintained list drifted before: only OpenCode was rewritten when the
19
+ * hyphen form was introduced (#727), and Cursor still advertised `/freespec:`
20
+ * commands its palette never registered (#1307). Carrying the prefix as
21
+ * adapter metadata rather than inferring it keeps the one tool that does not
22
+ * use a slash from being advertised as if it did.
23
+ */
24
+ import path from 'path';
25
+ /** The form these docs, command bodies, and skill templates are authored in. */
26
+ export const CANONICAL_INVOCATION = { style: 'namespaced', prefix: '/' };
27
+ /**
28
+ * Classifies a generated command file by the name the tool will answer to.
29
+ *
30
+ * The test is the filename, not the directory: an `freespec-` prefix means the
31
+ * filename is the command. Every other shape is treated as namespaced, which
32
+ * is what all seven `freespec/<id>.*` adapters need. An adapter that neither
33
+ * prefixes the filename nor nests under `freespec/` would land here too — none
34
+ * does, and the registry-wide test in invocation.test.ts fails if one appears.
35
+ *
36
+ * @param commandFilePath - Path returned by an adapter's `getFilePath`
37
+ * @returns 'flat' when the filename carries the `freespec-` prefix, otherwise
38
+ * 'namespaced'
39
+ */
40
+ export function getInvocationStyleForPath(commandFilePath) {
41
+ return path.basename(commandFilePath).startsWith('freespec-') ? 'flat' : 'namespaced';
42
+ }
43
+ /**
44
+ * Resolves how a tool's generated commands are invoked: the name from the
45
+ * files its adapter writes, the prefix from the adapter's own declaration.
46
+ *
47
+ * @param adapter - The tool-specific command adapter
48
+ * @returns The invocation shared by every command that adapter generates
49
+ */
50
+ export function getInvocationForAdapter(adapter) {
51
+ return {
52
+ // Any command id works: every adapter applies one naming rule to all of them.
53
+ style: getInvocationStyleForPath(adapter.getFilePath('explore')),
54
+ prefix: adapter.invocationPrefix ?? CANONICAL_INVOCATION.prefix,
55
+ };
56
+ }
57
+ /**
58
+ * Spells one command the way the tool registers it.
59
+ *
60
+ * @param invocation - The tool's invocation, from getInvocationForAdapter()
61
+ * @param commandId - The command identifier (e.g. 'apply')
62
+ * @returns What the user types, e.g. `/freespec:apply`, `/freespec-apply`, `@freespec-apply`
63
+ */
64
+ export function formatCommandInvocation(invocation, commandId) {
65
+ const separator = invocation.style === 'namespaced' ? ':' : '-';
66
+ return `${invocation.prefix}freespec${separator}${commandId}`;
67
+ }
68
+ /**
69
+ * Whether a tool's invocation differs from the canonical `/freespec:<id>` that
70
+ * command bodies and skill templates are authored in — that is, whether
71
+ * generated text has to be rewritten for that tool at all.
72
+ */
73
+ export function needsInvocationRewrite(invocation) {
74
+ return (invocation.style !== CANONICAL_INVOCATION.style ||
75
+ invocation.prefix !== CANONICAL_INVOCATION.prefix);
76
+ }
77
+ //# sourceMappingURL=invocation.js.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Command Adapter Registry
3
+ *
4
+ * Centralized registry for tool command adapters.
5
+ * Similar pattern to existing SlashCommandRegistry in the codebase.
6
+ */
7
+ import type { ToolCommandAdapter } from './types.js';
8
+ /**
9
+ * Registry for looking up tool command adapters.
10
+ */
11
+ export declare class CommandAdapterRegistry {
12
+ private static adapters;
13
+ /**
14
+ * Register a tool command adapter.
15
+ * @param adapter - The adapter to register
16
+ */
17
+ static register(adapter: ToolCommandAdapter): void;
18
+ /**
19
+ * Get an adapter by tool ID.
20
+ * @param toolId - The tool identifier (e.g., 'claude', 'cursor')
21
+ * @returns The adapter or undefined if not registered
22
+ */
23
+ static get(toolId: string): ToolCommandAdapter | undefined;
24
+ /**
25
+ * Get all registered adapters.
26
+ * @returns Array of all registered adapters
27
+ */
28
+ static getAll(): ToolCommandAdapter[];
29
+ /**
30
+ * Check if an adapter is registered for a tool.
31
+ * @param toolId - The tool identifier
32
+ * @returns True if an adapter exists
33
+ */
34
+ static has(toolId: string): boolean;
35
+ }
36
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Command Adapter Registry
3
+ *
4
+ * Centralized registry for tool command adapters.
5
+ * Similar pattern to existing SlashCommandRegistry in the codebase.
6
+ */
7
+ import { amazonQAdapter } from './adapters/amazon-q.js';
8
+ import { antigravityAdapter } from './adapters/antigravity.js';
9
+ import { atomcodeAdapter } from './adapters/atomcode.js';
10
+ import { auggieAdapter } from './adapters/auggie.js';
11
+ import { bobAdapter } from './adapters/bob.js';
12
+ import { claudeAdapter } from './adapters/claude.js';
13
+ import { clineAdapter } from './adapters/cline.js';
14
+ import { commandCodeAdapter } from './adapters/command-code.js';
15
+ import { devinAdapter } from './adapters/devin.js';
16
+ import { codebuddyAdapter } from './adapters/codebuddy.js';
17
+ import { codeStudioAdapter } from './adapters/codestudio.js';
18
+ import { continueAdapter } from './adapters/continue.js';
19
+ import { costrictAdapter } from './adapters/costrict.js';
20
+ import { crushAdapter } from './adapters/crush.js';
21
+ import { cursorAdapter } from './adapters/cursor.js';
22
+ import { easycodeAdapter } from './adapters/easycode.js';
23
+ import { factoryAdapter } from './adapters/factory.js';
24
+ import { geminiAdapter } from './adapters/gemini.js';
25
+ import { githubCopilotAdapter } from './adapters/github-copilot.js';
26
+ import { gigacodeAdapter } from './adapters/gigacode.js';
27
+ import { iflowAdapter } from './adapters/iflow.js';
28
+ import { junieAdapter } from './adapters/junie.js';
29
+ import { kilocodeAdapter } from './adapters/kilocode.js';
30
+ import { kiroAdapter } from './adapters/kiro.js';
31
+ import { ohMyPiAdapter } from './adapters/oh-my-pi.js';
32
+ import { opencodeAdapter } from './adapters/opencode.js';
33
+ import { piAdapter } from './adapters/pi.js';
34
+ import { codeassistantAdapter } from './adapters/codeassistant.js';
35
+ import { qoderAdapter } from './adapters/qoder.js';
36
+ import { lingmaAdapter } from './adapters/lingma.js';
37
+ import { qwenAdapter } from './adapters/qwen.js';
38
+ import { roocodeAdapter } from './adapters/roocode.js';
39
+ import { traeAdapter } from './adapters/trae.js';
40
+ import { zcodeAdapter } from './adapters/zcode.js';
41
+ /**
42
+ * Registry for looking up tool command adapters.
43
+ */
44
+ export class CommandAdapterRegistry {
45
+ static adapters = new Map();
46
+ // Static initializer - register built-in adapters
47
+ static {
48
+ CommandAdapterRegistry.register(amazonQAdapter);
49
+ CommandAdapterRegistry.register(antigravityAdapter);
50
+ CommandAdapterRegistry.register(atomcodeAdapter);
51
+ CommandAdapterRegistry.register(auggieAdapter);
52
+ CommandAdapterRegistry.register(bobAdapter);
53
+ CommandAdapterRegistry.register(claudeAdapter);
54
+ CommandAdapterRegistry.register(clineAdapter);
55
+ CommandAdapterRegistry.register(commandCodeAdapter);
56
+ CommandAdapterRegistry.register(devinAdapter);
57
+ CommandAdapterRegistry.register(codebuddyAdapter);
58
+ CommandAdapterRegistry.register(codeStudioAdapter);
59
+ CommandAdapterRegistry.register(continueAdapter);
60
+ CommandAdapterRegistry.register(costrictAdapter);
61
+ CommandAdapterRegistry.register(crushAdapter);
62
+ CommandAdapterRegistry.register(cursorAdapter);
63
+ CommandAdapterRegistry.register(easycodeAdapter);
64
+ CommandAdapterRegistry.register(factoryAdapter);
65
+ CommandAdapterRegistry.register(geminiAdapter);
66
+ CommandAdapterRegistry.register(githubCopilotAdapter);
67
+ CommandAdapterRegistry.register(gigacodeAdapter);
68
+ CommandAdapterRegistry.register(iflowAdapter);
69
+ CommandAdapterRegistry.register(junieAdapter);
70
+ CommandAdapterRegistry.register(kilocodeAdapter);
71
+ CommandAdapterRegistry.register(kiroAdapter);
72
+ CommandAdapterRegistry.register(ohMyPiAdapter);
73
+ CommandAdapterRegistry.register(opencodeAdapter);
74
+ CommandAdapterRegistry.register(piAdapter);
75
+ CommandAdapterRegistry.register(codeassistantAdapter);
76
+ CommandAdapterRegistry.register(qoderAdapter);
77
+ CommandAdapterRegistry.register(lingmaAdapter);
78
+ CommandAdapterRegistry.register(qwenAdapter);
79
+ CommandAdapterRegistry.register(roocodeAdapter);
80
+ CommandAdapterRegistry.register(traeAdapter);
81
+ CommandAdapterRegistry.register(zcodeAdapter);
82
+ }
83
+ /**
84
+ * Register a tool command adapter.
85
+ * @param adapter - The adapter to register
86
+ */
87
+ static register(adapter) {
88
+ CommandAdapterRegistry.adapters.set(adapter.toolId, adapter);
89
+ }
90
+ /**
91
+ * Get an adapter by tool ID.
92
+ * @param toolId - The tool identifier (e.g., 'claude', 'cursor')
93
+ * @returns The adapter or undefined if not registered
94
+ */
95
+ static get(toolId) {
96
+ return CommandAdapterRegistry.adapters.get(toolId);
97
+ }
98
+ /**
99
+ * Get all registered adapters.
100
+ * @returns Array of all registered adapters
101
+ */
102
+ static getAll() {
103
+ return Array.from(CommandAdapterRegistry.adapters.values());
104
+ }
105
+ /**
106
+ * Check if an adapter is registered for a tool.
107
+ * @param toolId - The tool identifier
108
+ * @returns True if an adapter exists
109
+ */
110
+ static has(toolId) {
111
+ return CommandAdapterRegistry.adapters.has(toolId);
112
+ }
113
+ }
114
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Shared TOML string escaping for command adapters.
3
+ */
4
+ /**
5
+ * TOML basic strings are escape-active: a backslash or double quote in the
6
+ * value breaks the file if written raw. Newlines cannot appear in a
7
+ * single-line basic string at all, so they are escaped too.
8
+ */
9
+ export declare function escapeTomlBasicString(value: string): string;
10
+ /**
11
+ * Multiline basic strings keep raw newlines and tabs, but backslashes are
12
+ * still escape-active, any run of three quotes would end the string, and the
13
+ * same control characters are invalid as in single-line basic strings — a
14
+ * lone carriage return included (only LF and CRLF may appear raw; CRLF is
15
+ * normalized away so the emitted file is single-convention). Escapes are
16
+ * introduced after backslash-doubling so they are not re-doubled.
17
+ */
18
+ export declare function escapeTomlMultilineBasicString(value: string): string;
19
+ //# sourceMappingURL=toml.d.ts.map
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Shared TOML string escaping for command adapters.
3
+ */
4
+ /**
5
+ * Control characters (C0 except tab/newline/carriage return, plus DEL) are
6
+ * invalid inside TOML strings and must be written as escapes.
7
+ */
8
+ const TOML_CONTROL_CHARS = new RegExp('[\\u0000-\\u0008\\u000b\\u000c\\u000e-\\u001f\\u007f]', 'g');
9
+ /**
10
+ * TOML basic strings are escape-active: a backslash or double quote in the
11
+ * value breaks the file if written raw. Newlines cannot appear in a
12
+ * single-line basic string at all, so they are escaped too.
13
+ */
14
+ export function escapeTomlBasicString(value) {
15
+ return value
16
+ .replace(/\\/g, '\\\\')
17
+ .replace(/"/g, '\\"')
18
+ .replace(/\n/g, '\\n')
19
+ .replace(/\r/g, '\\r')
20
+ .replace(/\t/g, '\\t')
21
+ .replace(TOML_CONTROL_CHARS, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, '0')}`);
22
+ }
23
+ /**
24
+ * Multiline basic strings keep raw newlines and tabs, but backslashes are
25
+ * still escape-active, any run of three quotes would end the string, and the
26
+ * same control characters are invalid as in single-line basic strings — a
27
+ * lone carriage return included (only LF and CRLF may appear raw; CRLF is
28
+ * normalized away so the emitted file is single-convention). Escapes are
29
+ * introduced after backslash-doubling so they are not re-doubled.
30
+ */
31
+ export function escapeTomlMultilineBasicString(value) {
32
+ return value
33
+ .replace(/\r\n/g, '\n')
34
+ .replace(/\\/g, '\\\\')
35
+ .replace(/"""/g, '""\\"')
36
+ .replace(/\r/g, '\\r')
37
+ .replace(TOML_CONTROL_CHARS, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, '0')}`);
38
+ }
39
+ //# sourceMappingURL=toml.js.map