agentic-toolbox 0.6.0 → 0.7.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 (481) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +14 -6
  3. package/dist/cjs/agents/index.cjs +9 -0
  4. package/dist/cjs/agents/index.cjs.map +1 -0
  5. package/dist/cjs/cli/args/flags.d.cts +3 -0
  6. package/dist/cjs/cli/args/flags.d.cts.map +1 -0
  7. package/dist/cjs/cli/args/index.d.cts +5 -0
  8. package/dist/cjs/cli/args/index.d.cts.map +1 -0
  9. package/dist/{cli/args/parser.d.ts → cjs/cli/args/parser.d.cts} +2 -2
  10. package/dist/cjs/cli/args/parser.d.cts.map +1 -0
  11. package/dist/{cli/args/strategies.d.ts → cjs/cli/args/strategies.d.cts} +2 -2
  12. package/dist/cjs/cli/args/strategies.d.cts.map +1 -0
  13. package/dist/cjs/cli/args/subcommands.d.cts +3 -0
  14. package/dist/cjs/cli/args/subcommands.d.cts.map +1 -0
  15. package/dist/cjs/cli/commands/diff.d.cts +3 -0
  16. package/dist/cjs/cli/commands/diff.d.cts.map +1 -0
  17. package/dist/{cli/commands/doctor.d.ts → cjs/cli/commands/doctor.d.cts} +2 -2
  18. package/dist/cjs/cli/commands/doctor.d.cts.map +1 -0
  19. package/dist/cjs/cli/commands/index.d.cts +6 -0
  20. package/dist/cjs/cli/commands/index.d.cts.map +1 -0
  21. package/dist/cjs/cli/commands/init.d.cts +3 -0
  22. package/dist/cjs/cli/commands/init.d.cts.map +1 -0
  23. package/dist/cjs/cli/commands/sync.d.cts +3 -0
  24. package/dist/cjs/cli/commands/sync.d.cts.map +1 -0
  25. package/dist/cjs/cli/commands/validate.d.cts +3 -0
  26. package/dist/cjs/cli/commands/validate.d.cts.map +1 -0
  27. package/dist/cjs/cli/help/index.d.cts +3 -0
  28. package/dist/cjs/cli/help/index.d.cts.map +1 -0
  29. package/dist/{cli/help/print-help.d.ts → cjs/cli/help/print-help.d.cts} +1 -1
  30. package/dist/cjs/cli/help/print-help.d.cts.map +1 -0
  31. package/dist/{cli/help/templates.d.ts → cjs/cli/help/templates.d.cts} +1 -1
  32. package/dist/cjs/cli/help/templates.d.cts.map +1 -0
  33. package/dist/cjs/cli/index.d.cts +5 -0
  34. package/dist/cjs/cli/index.d.cts.map +1 -0
  35. package/dist/cjs/cli/run-cli.d.cts +3 -0
  36. package/dist/cjs/cli/run-cli.d.cts.map +1 -0
  37. package/dist/{core/config/discovery.d.ts → cjs/core/config/discovery.d.cts} +2 -2
  38. package/dist/cjs/core/config/discovery.d.cts.map +1 -0
  39. package/dist/cjs/core/config/index.d.cts +4 -0
  40. package/dist/cjs/core/config/index.d.cts.map +1 -0
  41. package/dist/cjs/core/config/loader.d.cts +3 -0
  42. package/dist/cjs/core/config/loader.d.cts.map +1 -0
  43. package/dist/{core/config/schema.d.ts → cjs/core/config/schema.d.cts} +2 -2
  44. package/dist/cjs/core/config/schema.d.cts.map +1 -0
  45. package/dist/cjs/core/index.d.cts +4 -0
  46. package/dist/cjs/core/index.d.cts.map +1 -0
  47. package/dist/{core/sync/engine-internal.d.ts → cjs/core/sync/engine-internal.d.cts} +2 -2
  48. package/dist/cjs/core/sync/engine-internal.d.cts.map +1 -0
  49. package/dist/{core/sync/engine.d.ts → cjs/core/sync/engine.d.cts} +2 -2
  50. package/dist/cjs/core/sync/engine.d.cts.map +1 -0
  51. package/dist/cjs/core/sync/index.d.cts +5 -0
  52. package/dist/cjs/core/sync/index.d.cts.map +1 -0
  53. package/dist/{core/sync/manifest.d.ts → cjs/core/sync/manifest.d.cts} +2 -2
  54. package/dist/cjs/core/sync/manifest.d.cts.map +1 -0
  55. package/dist/{core/sync/merger.d.ts → cjs/core/sync/merger.d.cts} +2 -2
  56. package/dist/cjs/core/sync/merger.d.cts.map +1 -0
  57. package/dist/cjs/core/sync/targets/index.d.cts +2 -0
  58. package/dist/cjs/core/sync/targets/index.d.cts.map +1 -0
  59. package/dist/{core/sync/targets/target-configs.d.ts → cjs/core/sync/targets/target-configs.d.cts} +2 -2
  60. package/dist/cjs/core/sync/targets/target-configs.d.cts.map +1 -0
  61. package/dist/cjs/core/transform/index.d.cts +7 -0
  62. package/dist/cjs/core/transform/index.d.cts.map +1 -0
  63. package/dist/{core/transform/parser.d.ts → cjs/core/transform/parser.d.cts} +3 -3
  64. package/dist/cjs/core/transform/parser.d.cts.map +1 -0
  65. package/dist/cjs/core/transform/pipeline.d.cts +3 -0
  66. package/dist/cjs/core/transform/pipeline.d.cts.map +1 -0
  67. package/dist/{core/transform/reassembler.d.ts → cjs/core/transform/reassembler.d.cts} +2 -2
  68. package/dist/cjs/core/transform/reassembler.d.cts.map +1 -0
  69. package/dist/{core/transform/stripper.d.ts → cjs/core/transform/stripper.d.cts} +2 -2
  70. package/dist/cjs/core/transform/stripper.d.cts.map +1 -0
  71. package/dist/{core/transform/transform-agent.d.ts → cjs/core/transform/transform-agent.d.cts} +2 -2
  72. package/dist/cjs/core/transform/transform-agent.d.cts.map +1 -0
  73. package/dist/cjs/index.cjs +1749 -0
  74. package/dist/cjs/index.cjs.map +1 -0
  75. package/dist/cjs/index.d.cts +3 -0
  76. package/dist/cjs/index.d.cts.map +1 -0
  77. package/dist/cjs/skills/index.cjs +14 -0
  78. package/dist/cjs/skills/index.cjs.map +1 -0
  79. package/dist/{types/cli.d.ts → cjs/types/cli.d.cts} +1 -1
  80. package/dist/cjs/types/cli.d.cts.map +1 -0
  81. package/dist/{types/config.d.ts → cjs/types/config.d.cts} +1 -1
  82. package/dist/cjs/types/config.d.cts.map +1 -0
  83. package/dist/{types/constants.d.ts → cjs/types/constants.d.cts} +1 -1
  84. package/dist/cjs/types/constants.d.cts.map +1 -0
  85. package/dist/cjs/types/errors.d.cts +40 -0
  86. package/dist/cjs/types/errors.d.cts.map +1 -0
  87. package/dist/cjs/types/index.d.cts +8 -0
  88. package/dist/cjs/types/index.d.cts.map +1 -0
  89. package/dist/{types/sync.d.ts → cjs/types/sync.d.cts} +3 -3
  90. package/dist/cjs/types/sync.d.cts.map +1 -0
  91. package/dist/{types/targets.d.ts → cjs/types/targets.d.cts} +2 -2
  92. package/dist/cjs/types/targets.d.cts.map +1 -0
  93. package/dist/{types/transform.d.ts → cjs/types/transform.d.cts} +2 -2
  94. package/dist/cjs/types/transform.d.cts.map +1 -0
  95. package/dist/{utils/errors/classes.d.ts → cjs/utils/errors/classes.d.cts} +2 -2
  96. package/dist/cjs/utils/errors/classes.d.cts.map +1 -0
  97. package/dist/cjs/utils/errors/codes.d.cts +2 -0
  98. package/dist/cjs/utils/errors/codes.d.cts.map +1 -0
  99. package/dist/cjs/utils/errors/index.d.cts +4 -0
  100. package/dist/cjs/utils/errors/index.d.cts.map +1 -0
  101. package/dist/{utils/errors/messages.d.ts → cjs/utils/errors/messages.d.cts} +2 -2
  102. package/dist/cjs/utils/errors/messages.d.cts.map +1 -0
  103. package/dist/{utils/fs/atomic.d.ts → cjs/utils/fs/atomic.d.cts} +1 -1
  104. package/dist/cjs/utils/fs/atomic.d.cts.map +1 -0
  105. package/dist/cjs/utils/fs/index.d.cts +5 -0
  106. package/dist/cjs/utils/fs/index.d.cts.map +1 -0
  107. package/dist/{utils/fs/operations.d.ts → cjs/utils/fs/operations.d.cts} +1 -1
  108. package/dist/cjs/utils/fs/operations.d.cts.map +1 -0
  109. package/dist/{utils/fs/paths.d.ts → cjs/utils/fs/paths.d.cts} +1 -1
  110. package/dist/cjs/utils/fs/paths.d.cts.map +1 -0
  111. package/dist/{utils/fs/sanitization.d.ts → cjs/utils/fs/sanitization.d.cts} +1 -1
  112. package/dist/cjs/utils/fs/sanitization.d.cts.map +1 -0
  113. package/dist/cjs/utils/index.d.cts +4 -0
  114. package/dist/cjs/utils/index.d.cts.map +1 -0
  115. package/dist/{utils/logging/console.d.ts → cjs/utils/logging/console.d.cts} +2 -2
  116. package/dist/cjs/utils/logging/console.d.cts.map +1 -0
  117. package/dist/cjs/utils/logging/index.d.cts +3 -0
  118. package/dist/cjs/utils/logging/index.d.cts.map +1 -0
  119. package/dist/{utils/logging/levels.d.ts → cjs/utils/logging/levels.d.cts} +1 -1
  120. package/dist/cjs/utils/logging/levels.d.cts.map +1 -0
  121. package/dist/esm/agents/Agent.md.sample +384 -0
  122. package/dist/esm/agents/agentic-tools-creator.md +143 -0
  123. package/dist/esm/agents/index.js +9 -0
  124. package/dist/esm/agents/index.js.map +1 -0
  125. package/dist/esm/cli/args/flags.d.mts +3 -0
  126. package/dist/esm/cli/args/flags.d.mts.map +1 -0
  127. package/dist/esm/cli/args/index.d.mts +5 -0
  128. package/dist/esm/cli/args/index.d.mts.map +1 -0
  129. package/dist/esm/cli/args/parser.d.mts +5 -0
  130. package/dist/esm/cli/args/parser.d.mts.map +1 -0
  131. package/dist/esm/cli/args/strategies.d.mts +7 -0
  132. package/dist/esm/cli/args/strategies.d.mts.map +1 -0
  133. package/dist/esm/cli/args/subcommands.d.mts +3 -0
  134. package/dist/esm/cli/args/subcommands.d.mts.map +1 -0
  135. package/dist/esm/cli/commands/diff.d.mts +3 -0
  136. package/dist/esm/cli/commands/diff.d.mts.map +1 -0
  137. package/dist/esm/cli/commands/doctor.d.mts +8 -0
  138. package/dist/esm/cli/commands/doctor.d.mts.map +1 -0
  139. package/dist/esm/cli/commands/index.d.mts +6 -0
  140. package/dist/esm/cli/commands/index.d.mts.map +1 -0
  141. package/dist/esm/cli/commands/init.d.mts +3 -0
  142. package/dist/esm/cli/commands/init.d.mts.map +1 -0
  143. package/dist/esm/cli/commands/sync.d.mts +3 -0
  144. package/dist/esm/cli/commands/sync.d.mts.map +1 -0
  145. package/dist/esm/cli/commands/validate.d.mts +3 -0
  146. package/dist/esm/cli/commands/validate.d.mts.map +1 -0
  147. package/dist/esm/cli/help/index.d.mts +3 -0
  148. package/dist/esm/cli/help/index.d.mts.map +1 -0
  149. package/dist/esm/cli/help/print-help.d.mts +2 -0
  150. package/dist/esm/cli/help/print-help.d.mts.map +1 -0
  151. package/dist/esm/cli/help/templates.d.mts +3 -0
  152. package/dist/esm/cli/help/templates.d.mts.map +1 -0
  153. package/dist/esm/cli/index.d.mts +5 -0
  154. package/dist/esm/cli/index.d.mts.map +1 -0
  155. package/dist/esm/cli/run-cli.d.mts +3 -0
  156. package/dist/esm/cli/run-cli.d.mts.map +1 -0
  157. package/dist/esm/core/config/discovery.d.mts +4 -0
  158. package/dist/esm/core/config/discovery.d.mts.map +1 -0
  159. package/dist/esm/core/config/index.d.mts +4 -0
  160. package/dist/esm/core/config/index.d.mts.map +1 -0
  161. package/dist/esm/core/config/loader.d.mts +3 -0
  162. package/dist/esm/core/config/loader.d.mts.map +1 -0
  163. package/dist/esm/core/config/schema.d.mts +8 -0
  164. package/dist/esm/core/config/schema.d.mts.map +1 -0
  165. package/dist/esm/core/index.d.mts +4 -0
  166. package/dist/esm/core/index.d.mts.map +1 -0
  167. package/dist/esm/core/sync/engine-internal.d.mts +3 -0
  168. package/dist/esm/core/sync/engine-internal.d.mts.map +1 -0
  169. package/dist/esm/core/sync/engine.d.mts +4 -0
  170. package/dist/esm/core/sync/engine.d.mts.map +1 -0
  171. package/dist/esm/core/sync/index.d.mts +5 -0
  172. package/dist/esm/core/sync/index.d.mts.map +1 -0
  173. package/dist/esm/core/sync/manifest.d.mts +10 -0
  174. package/dist/esm/core/sync/manifest.d.mts.map +1 -0
  175. package/dist/esm/core/sync/merger.d.mts +9 -0
  176. package/dist/esm/core/sync/merger.d.mts.map +1 -0
  177. package/dist/esm/core/sync/targets/index.d.mts +2 -0
  178. package/dist/esm/core/sync/targets/index.d.mts.map +1 -0
  179. package/dist/esm/core/sync/targets/target-configs.d.mts +5 -0
  180. package/dist/esm/core/sync/targets/target-configs.d.mts.map +1 -0
  181. package/dist/esm/core/transform/index.d.mts +7 -0
  182. package/dist/esm/core/transform/index.d.mts.map +1 -0
  183. package/dist/esm/core/transform/parser.d.mts +16 -0
  184. package/dist/esm/core/transform/parser.d.mts.map +1 -0
  185. package/dist/esm/core/transform/pipeline.d.mts +3 -0
  186. package/dist/esm/core/transform/pipeline.d.mts.map +1 -0
  187. package/dist/esm/core/transform/reassembler.d.mts +3 -0
  188. package/dist/esm/core/transform/reassembler.d.mts.map +1 -0
  189. package/dist/esm/core/transform/stripper.d.mts +3 -0
  190. package/dist/esm/core/transform/stripper.d.mts.map +1 -0
  191. package/dist/esm/core/transform/transform-agent.d.mts +3 -0
  192. package/dist/esm/core/transform/transform-agent.d.mts.map +1 -0
  193. package/dist/esm/index.d.mts +3 -0
  194. package/dist/esm/index.d.mts.map +1 -0
  195. package/dist/esm/index.js +1815 -0
  196. package/dist/esm/index.js.map +1 -0
  197. package/dist/esm/skills/SKILL.md.sample +322 -0
  198. package/dist/esm/skills/agent-creator/SKILL.md +110 -0
  199. package/dist/esm/skills/agent-creator/assets/examples/code-reviewer.md +68 -0
  200. package/dist/esm/skills/agent-creator/assets/examples/docs-writer.md +67 -0
  201. package/dist/esm/skills/agent-creator/assets/examples/read-only-researcher.md +64 -0
  202. package/dist/esm/skills/agent-creator/references/AGENT_TEMPLATE.md +391 -0
  203. package/dist/esm/skills/agent-creator/references/frontmatter.md +544 -0
  204. package/dist/esm/skills/agent-creator/references/prompt.md +449 -0
  205. package/dist/esm/skills/agent-creator/references/validation.md +309 -0
  206. package/dist/esm/skills/agentic-resource-gatherer/SKILL.md +249 -0
  207. package/dist/esm/skills/agentic-resource-gatherer/assets/examples/frontend-developer-agent.md +52 -0
  208. package/dist/esm/skills/agentic-resource-gatherer/assets/examples/git-formatter-skill.md +52 -0
  209. package/dist/esm/skills/agentic-resource-gatherer/references/agent-repos.md +190 -0
  210. package/dist/esm/skills/agentic-resource-gatherer/references/skill-repos.md +225 -0
  211. package/dist/esm/skills/index.js +14 -0
  212. package/dist/esm/skills/index.js.map +1 -0
  213. package/dist/esm/skills/skill-creator/SKILL.md +178 -0
  214. package/dist/esm/skills/skill-creator/assets/examples/background-knowledge-skill.md +25 -0
  215. package/dist/esm/skills/skill-creator/assets/examples/code-generation-skill.md +51 -0
  216. package/dist/esm/skills/skill-creator/assets/examples/simple-git-skill.md +36 -0
  217. package/dist/esm/skills/skill-creator/references/SKILL_TEMPLATE.md +322 -0
  218. package/dist/esm/skills/skill-creator/references/frontmatter.md +441 -0
  219. package/dist/esm/skills/skill-creator/references/prompt.md +384 -0
  220. package/dist/esm/skills/skill-creator/references/validation.md +282 -0
  221. package/dist/esm/types/cli.d.mts +68 -0
  222. package/dist/esm/types/cli.d.mts.map +1 -0
  223. package/dist/esm/types/config.d.mts +22 -0
  224. package/dist/esm/types/config.d.mts.map +1 -0
  225. package/dist/esm/types/constants.d.mts +2 -0
  226. package/dist/esm/types/constants.d.mts.map +1 -0
  227. package/dist/esm/types/errors.d.mts +40 -0
  228. package/dist/esm/types/errors.d.mts.map +1 -0
  229. package/dist/esm/types/index.d.mts +8 -0
  230. package/dist/esm/types/index.d.mts.map +1 -0
  231. package/dist/esm/types/sync.d.mts +26 -0
  232. package/dist/esm/types/sync.d.mts.map +1 -0
  233. package/dist/esm/types/targets.d.mts +25 -0
  234. package/dist/esm/types/targets.d.mts.map +1 -0
  235. package/dist/esm/types/transform.d.mts +24 -0
  236. package/dist/esm/types/transform.d.mts.map +1 -0
  237. package/dist/esm/utils/errors/classes.d.mts +76 -0
  238. package/dist/esm/utils/errors/classes.d.mts.map +1 -0
  239. package/dist/esm/utils/errors/codes.d.mts +2 -0
  240. package/dist/esm/utils/errors/codes.d.mts.map +1 -0
  241. package/dist/esm/utils/errors/index.d.mts +4 -0
  242. package/dist/esm/utils/errors/index.d.mts.map +1 -0
  243. package/dist/esm/utils/errors/messages.d.mts +11 -0
  244. package/dist/esm/utils/errors/messages.d.mts.map +1 -0
  245. package/dist/esm/utils/fs/atomic.d.mts +2 -0
  246. package/dist/esm/utils/fs/atomic.d.mts.map +1 -0
  247. package/dist/esm/utils/fs/index.d.mts +5 -0
  248. package/dist/esm/utils/fs/index.d.mts.map +1 -0
  249. package/dist/esm/utils/fs/operations.d.mts +12 -0
  250. package/dist/esm/utils/fs/operations.d.mts.map +1 -0
  251. package/dist/esm/utils/fs/paths.d.mts +9 -0
  252. package/dist/esm/utils/fs/paths.d.mts.map +1 -0
  253. package/dist/esm/utils/fs/sanitization.d.mts +11 -0
  254. package/dist/esm/utils/fs/sanitization.d.mts.map +1 -0
  255. package/dist/esm/utils/index.d.mts +4 -0
  256. package/dist/esm/utils/index.d.mts.map +1 -0
  257. package/dist/esm/utils/logging/console.d.mts +34 -0
  258. package/dist/esm/utils/logging/console.d.mts.map +1 -0
  259. package/dist/esm/utils/logging/index.d.mts +3 -0
  260. package/dist/esm/utils/logging/index.d.mts.map +1 -0
  261. package/dist/esm/utils/logging/levels.d.mts +23 -0
  262. package/dist/esm/utils/logging/levels.d.mts.map +1 -0
  263. package/package.json +22 -13
  264. package/dist/cli/args/flags.d.ts +0 -3
  265. package/dist/cli/args/flags.d.ts.map +0 -1
  266. package/dist/cli/args/flags.js +0 -50
  267. package/dist/cli/args/flags.js.map +0 -1
  268. package/dist/cli/args/index.d.ts +0 -5
  269. package/dist/cli/args/index.d.ts.map +0 -1
  270. package/dist/cli/args/index.js +0 -6
  271. package/dist/cli/args/index.js.map +0 -1
  272. package/dist/cli/args/parser.d.ts.map +0 -1
  273. package/dist/cli/args/parser.js +0 -88
  274. package/dist/cli/args/parser.js.map +0 -1
  275. package/dist/cli/args/strategies.d.ts.map +0 -1
  276. package/dist/cli/args/strategies.js +0 -49
  277. package/dist/cli/args/strategies.js.map +0 -1
  278. package/dist/cli/args/subcommands.d.ts +0 -3
  279. package/dist/cli/args/subcommands.d.ts.map +0 -1
  280. package/dist/cli/args/subcommands.js +0 -55
  281. package/dist/cli/args/subcommands.js.map +0 -1
  282. package/dist/cli/commands/diff.d.ts +0 -3
  283. package/dist/cli/commands/diff.d.ts.map +0 -1
  284. package/dist/cli/commands/diff.js +0 -142
  285. package/dist/cli/commands/diff.js.map +0 -1
  286. package/dist/cli/commands/doctor.d.ts.map +0 -1
  287. package/dist/cli/commands/doctor.js +0 -104
  288. package/dist/cli/commands/doctor.js.map +0 -1
  289. package/dist/cli/commands/index.d.ts +0 -6
  290. package/dist/cli/commands/index.d.ts.map +0 -1
  291. package/dist/cli/commands/index.js +0 -7
  292. package/dist/cli/commands/index.js.map +0 -1
  293. package/dist/cli/commands/init.d.ts +0 -3
  294. package/dist/cli/commands/init.d.ts.map +0 -1
  295. package/dist/cli/commands/init.js +0 -66
  296. package/dist/cli/commands/init.js.map +0 -1
  297. package/dist/cli/commands/sync.d.ts +0 -3
  298. package/dist/cli/commands/sync.d.ts.map +0 -1
  299. package/dist/cli/commands/sync.js +0 -56
  300. package/dist/cli/commands/sync.js.map +0 -1
  301. package/dist/cli/commands/validate.d.ts +0 -3
  302. package/dist/cli/commands/validate.d.ts.map +0 -1
  303. package/dist/cli/commands/validate.js +0 -71
  304. package/dist/cli/commands/validate.js.map +0 -1
  305. package/dist/cli/help/index.d.ts +0 -3
  306. package/dist/cli/help/index.d.ts.map +0 -1
  307. package/dist/cli/help/index.js +0 -4
  308. package/dist/cli/help/index.js.map +0 -1
  309. package/dist/cli/help/print-help.d.ts.map +0 -1
  310. package/dist/cli/help/print-help.js +0 -13
  311. package/dist/cli/help/print-help.js.map +0 -1
  312. package/dist/cli/help/templates.d.ts.map +0 -1
  313. package/dist/cli/help/templates.js +0 -83
  314. package/dist/cli/help/templates.js.map +0 -1
  315. package/dist/cli/index.d.ts +0 -5
  316. package/dist/cli/index.d.ts.map +0 -1
  317. package/dist/cli/index.js +0 -6
  318. package/dist/cli/index.js.map +0 -1
  319. package/dist/cli/run-cli.d.ts +0 -3
  320. package/dist/cli/run-cli.d.ts.map +0 -1
  321. package/dist/cli/run-cli.js +0 -58
  322. package/dist/cli/run-cli.js.map +0 -1
  323. package/dist/core/config/discovery.d.ts.map +0 -1
  324. package/dist/core/config/discovery.js +0 -21
  325. package/dist/core/config/discovery.js.map +0 -1
  326. package/dist/core/config/index.d.ts +0 -4
  327. package/dist/core/config/index.d.ts.map +0 -1
  328. package/dist/core/config/index.js +0 -5
  329. package/dist/core/config/index.js.map +0 -1
  330. package/dist/core/config/loader.d.ts +0 -3
  331. package/dist/core/config/loader.d.ts.map +0 -1
  332. package/dist/core/config/loader.js +0 -70
  333. package/dist/core/config/loader.js.map +0 -1
  334. package/dist/core/config/schema.d.ts.map +0 -1
  335. package/dist/core/config/schema.js +0 -129
  336. package/dist/core/config/schema.js.map +0 -1
  337. package/dist/core/index.d.ts +0 -4
  338. package/dist/core/index.d.ts.map +0 -1
  339. package/dist/core/index.js +0 -5
  340. package/dist/core/index.js.map +0 -1
  341. package/dist/core/sync/engine-internal.d.ts.map +0 -1
  342. package/dist/core/sync/engine-internal.js +0 -244
  343. package/dist/core/sync/engine-internal.js.map +0 -1
  344. package/dist/core/sync/engine.d.ts.map +0 -1
  345. package/dist/core/sync/engine.js +0 -17
  346. package/dist/core/sync/engine.js.map +0 -1
  347. package/dist/core/sync/index.d.ts +0 -5
  348. package/dist/core/sync/index.d.ts.map +0 -1
  349. package/dist/core/sync/index.js +0 -6
  350. package/dist/core/sync/index.js.map +0 -1
  351. package/dist/core/sync/manifest.d.ts.map +0 -1
  352. package/dist/core/sync/manifest.js +0 -68
  353. package/dist/core/sync/manifest.js.map +0 -1
  354. package/dist/core/sync/merger.d.ts.map +0 -1
  355. package/dist/core/sync/merger.js +0 -65
  356. package/dist/core/sync/merger.js.map +0 -1
  357. package/dist/core/sync/targets/index.d.ts +0 -2
  358. package/dist/core/sync/targets/index.d.ts.map +0 -1
  359. package/dist/core/sync/targets/index.js +0 -3
  360. package/dist/core/sync/targets/index.js.map +0 -1
  361. package/dist/core/sync/targets/target-configs.d.ts.map +0 -1
  362. package/dist/core/sync/targets/target-configs.js +0 -8
  363. package/dist/core/sync/targets/target-configs.js.map +0 -1
  364. package/dist/core/transform/index.d.ts +0 -7
  365. package/dist/core/transform/index.d.ts.map +0 -1
  366. package/dist/core/transform/index.js +0 -7
  367. package/dist/core/transform/index.js.map +0 -1
  368. package/dist/core/transform/parser.d.ts.map +0 -1
  369. package/dist/core/transform/parser.js +0 -152
  370. package/dist/core/transform/parser.js.map +0 -1
  371. package/dist/core/transform/pipeline.d.ts +0 -3
  372. package/dist/core/transform/pipeline.d.ts.map +0 -1
  373. package/dist/core/transform/pipeline.js +0 -10
  374. package/dist/core/transform/pipeline.js.map +0 -1
  375. package/dist/core/transform/reassembler.d.ts.map +0 -1
  376. package/dist/core/transform/reassembler.js +0 -13
  377. package/dist/core/transform/reassembler.js.map +0 -1
  378. package/dist/core/transform/stripper.d.ts.map +0 -1
  379. package/dist/core/transform/stripper.js +0 -10
  380. package/dist/core/transform/stripper.js.map +0 -1
  381. package/dist/core/transform/transform-agent.d.ts.map +0 -1
  382. package/dist/core/transform/transform-agent.js +0 -42
  383. package/dist/core/transform/transform-agent.js.map +0 -1
  384. package/dist/index.d.ts +0 -3
  385. package/dist/index.d.ts.map +0 -1
  386. package/dist/index.js +0 -7
  387. package/dist/index.js.map +0 -1
  388. package/dist/types/cli.d.ts.map +0 -1
  389. package/dist/types/cli.js +0 -3
  390. package/dist/types/cli.js.map +0 -1
  391. package/dist/types/config.d.ts.map +0 -1
  392. package/dist/types/config.js +0 -2
  393. package/dist/types/config.js.map +0 -1
  394. package/dist/types/constants.d.ts.map +0 -1
  395. package/dist/types/constants.js +0 -3
  396. package/dist/types/constants.js.map +0 -1
  397. package/dist/types/errors.d.ts +0 -40
  398. package/dist/types/errors.d.ts.map +0 -1
  399. package/dist/types/errors.js +0 -36
  400. package/dist/types/errors.js.map +0 -1
  401. package/dist/types/index.d.ts +0 -8
  402. package/dist/types/index.d.ts.map +0 -1
  403. package/dist/types/index.js +0 -9
  404. package/dist/types/index.js.map +0 -1
  405. package/dist/types/sync.d.ts.map +0 -1
  406. package/dist/types/sync.js +0 -2
  407. package/dist/types/sync.js.map +0 -1
  408. package/dist/types/targets.d.ts.map +0 -1
  409. package/dist/types/targets.js +0 -92
  410. package/dist/types/targets.js.map +0 -1
  411. package/dist/types/transform.d.ts.map +0 -1
  412. package/dist/types/transform.js +0 -2
  413. package/dist/types/transform.js.map +0 -1
  414. package/dist/utils/errors/classes.d.ts.map +0 -1
  415. package/dist/utils/errors/classes.js +0 -113
  416. package/dist/utils/errors/classes.js.map +0 -1
  417. package/dist/utils/errors/codes.d.ts +0 -2
  418. package/dist/utils/errors/codes.d.ts.map +0 -1
  419. package/dist/utils/errors/codes.js +0 -3
  420. package/dist/utils/errors/codes.js.map +0 -1
  421. package/dist/utils/errors/index.d.ts +0 -4
  422. package/dist/utils/errors/index.d.ts.map +0 -1
  423. package/dist/utils/errors/index.js +0 -5
  424. package/dist/utils/errors/index.js.map +0 -1
  425. package/dist/utils/errors/messages.d.ts.map +0 -1
  426. package/dist/utils/errors/messages.js +0 -13
  427. package/dist/utils/errors/messages.js.map +0 -1
  428. package/dist/utils/fs/atomic.d.ts.map +0 -1
  429. package/dist/utils/fs/atomic.js +0 -24
  430. package/dist/utils/fs/atomic.js.map +0 -1
  431. package/dist/utils/fs/index.d.ts +0 -5
  432. package/dist/utils/fs/index.d.ts.map +0 -1
  433. package/dist/utils/fs/index.js +0 -6
  434. package/dist/utils/fs/index.js.map +0 -1
  435. package/dist/utils/fs/operations.d.ts.map +0 -1
  436. package/dist/utils/fs/operations.js +0 -60
  437. package/dist/utils/fs/operations.js.map +0 -1
  438. package/dist/utils/fs/paths.d.ts.map +0 -1
  439. package/dist/utils/fs/paths.js +0 -58
  440. package/dist/utils/fs/paths.js.map +0 -1
  441. package/dist/utils/fs/sanitization.d.ts.map +0 -1
  442. package/dist/utils/fs/sanitization.js +0 -57
  443. package/dist/utils/fs/sanitization.js.map +0 -1
  444. package/dist/utils/index.d.ts +0 -4
  445. package/dist/utils/index.d.ts.map +0 -1
  446. package/dist/utils/index.js +0 -5
  447. package/dist/utils/index.js.map +0 -1
  448. package/dist/utils/logging/console.d.ts.map +0 -1
  449. package/dist/utils/logging/console.js +0 -133
  450. package/dist/utils/logging/console.js.map +0 -1
  451. package/dist/utils/logging/index.d.ts +0 -3
  452. package/dist/utils/logging/index.d.ts.map +0 -1
  453. package/dist/utils/logging/index.js +0 -4
  454. package/dist/utils/logging/index.js.map +0 -1
  455. package/dist/utils/logging/levels.d.ts.map +0 -1
  456. package/dist/utils/logging/levels.js +0 -2
  457. package/dist/utils/logging/levels.js.map +0 -1
  458. /package/dist/{agents → cjs/agents}/Agent.md.sample +0 -0
  459. /package/dist/{agents → cjs/agents}/agentic-tools-creator.md +0 -0
  460. /package/dist/{skills → cjs/skills}/SKILL.md.sample +0 -0
  461. /package/dist/{skills → cjs/skills}/agent-creator/SKILL.md +0 -0
  462. /package/dist/{skills → cjs/skills}/agent-creator/assets/examples/code-reviewer.md +0 -0
  463. /package/dist/{skills → cjs/skills}/agent-creator/assets/examples/docs-writer.md +0 -0
  464. /package/dist/{skills → cjs/skills}/agent-creator/assets/examples/read-only-researcher.md +0 -0
  465. /package/dist/{skills → cjs/skills}/agent-creator/references/AGENT_TEMPLATE.md +0 -0
  466. /package/dist/{skills → cjs/skills}/agent-creator/references/frontmatter.md +0 -0
  467. /package/dist/{skills → cjs/skills}/agent-creator/references/prompt.md +0 -0
  468. /package/dist/{skills → cjs/skills}/agent-creator/references/validation.md +0 -0
  469. /package/dist/{skills → cjs/skills}/agentic-resource-gatherer/SKILL.md +0 -0
  470. /package/dist/{skills → cjs/skills}/agentic-resource-gatherer/assets/examples/frontend-developer-agent.md +0 -0
  471. /package/dist/{skills → cjs/skills}/agentic-resource-gatherer/assets/examples/git-formatter-skill.md +0 -0
  472. /package/dist/{skills → cjs/skills}/agentic-resource-gatherer/references/agent-repos.md +0 -0
  473. /package/dist/{skills → cjs/skills}/agentic-resource-gatherer/references/skill-repos.md +0 -0
  474. /package/dist/{skills → cjs/skills}/skill-creator/SKILL.md +0 -0
  475. /package/dist/{skills → cjs/skills}/skill-creator/assets/examples/background-knowledge-skill.md +0 -0
  476. /package/dist/{skills → cjs/skills}/skill-creator/assets/examples/code-generation-skill.md +0 -0
  477. /package/dist/{skills → cjs/skills}/skill-creator/assets/examples/simple-git-skill.md +0 -0
  478. /package/dist/{skills → cjs/skills}/skill-creator/references/SKILL_TEMPLATE.md +0 -0
  479. /package/dist/{skills → cjs/skills}/skill-creator/references/frontmatter.md +0 -0
  480. /package/dist/{skills → cjs/skills}/skill-creator/references/prompt.md +0 -0
  481. /package/dist/{skills → cjs/skills}/skill-creator/references/validation.md +0 -0
@@ -0,0 +1,1815 @@
1
+ #!/usr/bin/env node
2
+ import fs$1, * as fs from "fs";
3
+ import path$1, * as path from "path";
4
+ import { fileURLToPath } from "url";
5
+ import { parse, parseDocument, stringify } from "yaml";
6
+ import { createHash, randomBytes } from "crypto";
7
+ // src/cli/args/flags.ts
8
+ var flags = [
9
+ {
10
+ name: "config",
11
+ alias: "c",
12
+ description: "Use a custom config file",
13
+ type: "string"
14
+ },
15
+ {
16
+ name: "dryRun",
17
+ alias: "d",
18
+ description: "Preview what would be synced without making changes",
19
+ type: "boolean"
20
+ },
21
+ {
22
+ name: "verbose",
23
+ alias: "v",
24
+ description: "Enable verbose output",
25
+ type: "boolean"
26
+ },
27
+ {
28
+ name: "help",
29
+ alias: "h",
30
+ description: "Show help message",
31
+ type: "boolean"
32
+ },
33
+ {
34
+ name: "version",
35
+ alias: "V",
36
+ description: "Show version",
37
+ type: "boolean"
38
+ },
39
+ {
40
+ name: "targets",
41
+ alias: "t",
42
+ description: "Comma-separated list of targets to sync",
43
+ type: "string[]"
44
+ },
45
+ {
46
+ name: "quiet",
47
+ alias: "q",
48
+ description: "Suppress non-error output",
49
+ type: "boolean"
50
+ },
51
+ {
52
+ name: "json",
53
+ description: "Emit machine-readable JSON (JSONL) output",
54
+ type: "boolean"
55
+ }
56
+ ];
57
+ // src/types/errors.ts
58
+ var ERROR_CODES = {
59
+ CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND",
60
+ CONFIG_INVALID_JSON: "CONFIG_INVALID_JSON",
61
+ CONFIG_VALIDATION_FAILED: "CONFIG_VALIDATION_FAILED",
62
+ CONFIG_UNKNOWN_TARGET: "CONFIG_UNKNOWN_TARGET",
63
+ CONFIG_UNKNOWN_FIELD: "CONFIG_UNKNOWN_FIELD",
64
+ SYNC_TARGET_FAILED: "SYNC_TARGET_FAILED",
65
+ SYNC_DIRECTORY_CLEANUP_FAILED: "SYNC_DIRECTORY_CLEANUP_FAILED",
66
+ SYNC_FILE_READ_FAILED: "SYNC_FILE_READ_FAILED",
67
+ SYNC_FILE_WRITE_FAILED: "SYNC_FILE_WRITE_FAILED",
68
+ SYNC_FILE_COPY_FAILED: "SYNC_FILE_COPY_FAILED",
69
+ SYNC_MERGE_FAILED: "SYNC_MERGE_FAILED",
70
+ TRANSFORM_PARSE_FAILED: "TRANSFORM_PARSE_FAILED",
71
+ TRANSFORM_STRIP_FAILED: "TRANSFORM_STRIP_FAILED",
72
+ TRANSFORM_REASSEMBLE_FAILED: "TRANSFORM_REASSEMBLE_FAILED",
73
+ YAML_PARSE_FAILED: "YAML_PARSE_FAILED",
74
+ YAML_STRINGIFY_FAILED: "YAML_STRINGIFY_FAILED",
75
+ FS_READ_FAILED: "FS_READ_FAILED",
76
+ FS_WRITE_FAILED: "FS_WRITE_FAILED",
77
+ FS_COPY_FAILED: "FS_COPY_FAILED",
78
+ FS_REMOVE_FAILED: "FS_REMOVE_FAILED",
79
+ FS_PATH_RESOLUTION_FAILED: "FS_PATH_RESOLUTION_FAILED",
80
+ CLI_INVALID_ARGS: "CLI_INVALID_ARGS",
81
+ CLI_UNKNOWN_COMMAND: "CLI_UNKNOWN_COMMAND",
82
+ VALIDATION_FAILED: "VALIDATION_FAILED"
83
+ };
84
+ // src/types/targets.ts
85
+ var TARGET_DEFINITIONS = {
86
+ opencode: {
87
+ name: "opencode",
88
+ value: "opencode",
89
+ description: "Sync to .opencode/ directory",
90
+ directory: ".opencode",
91
+ stripFields: [
92
+ "tools",
93
+ "disallowedTools",
94
+ "permissionMode",
95
+ "maxTurns",
96
+ "skills",
97
+ "mcpServers",
98
+ "hooks",
99
+ "memory",
100
+ "background",
101
+ "effort",
102
+ "isolation",
103
+ "initialPrompt"
104
+ ],
105
+ transformAgents: true,
106
+ transformSkills: false
107
+ },
108
+ claude: {
109
+ name: "claude",
110
+ value: "claude",
111
+ description: "Sync to .claude/ directory",
112
+ directory: ".claude",
113
+ stripFields: [
114
+ "permission",
115
+ "mode",
116
+ "temperature",
117
+ "steps",
118
+ "disable",
119
+ "prompt",
120
+ "hidden",
121
+ "top_p",
122
+ "reasoningEffort",
123
+ "textVerbosity"
124
+ ],
125
+ transformAgents: true,
126
+ transformSkills: false
127
+ },
128
+ agents: {
129
+ name: "agents",
130
+ value: "agents",
131
+ description: "Sync to .agents/ directory (standard)",
132
+ directory: ".agents",
133
+ stripFields: [],
134
+ transformAgents: false,
135
+ transformSkills: false
136
+ }
137
+ };
138
+ var TARGET_OPTIONS = Object.values(TARGET_DEFINITIONS).map((t) => ({
139
+ name: t.name,
140
+ value: t.value,
141
+ description: t.description
142
+ }));
143
+ function getTargetDefinition(target) {
144
+ const def = TARGET_DEFINITIONS[target];
145
+ if (!def) throw new Error(`Unknown target: ${target}`);
146
+ return def;
147
+ }
148
+ function getTargetNames() {
149
+ return Object.keys(TARGET_DEFINITIONS);
150
+ }
151
+ function getStripFields(target) {
152
+ return TARGET_DEFINITIONS[target]?.stripFields ?? [];
153
+ }
154
+ function isValidTarget(target) {
155
+ return typeof target === "string" && Object.prototype.hasOwnProperty.call(TARGET_DEFINITIONS, target.trim());
156
+ }
157
+ function validateTarget(target) {
158
+ const trimmed = typeof target === "string" ? target.trim() : "";
159
+ if (!isValidTarget(trimmed)) {
160
+ const validTargets = getTargetNames().join(", ");
161
+ throw new Error(`Invalid target: "${target}". Expected one of: ${validTargets}`);
162
+ }
163
+ return trimmed;
164
+ }
165
+ function validateTargets(targets) {
166
+ if (!Array.isArray(targets)) throw new Error("Targets must be an array of strings");
167
+ return targets.map((t) => validateTarget(t));
168
+ }
169
+ // src/utils/fs/paths.ts
170
+ var baseDir = typeof __dirname !== "undefined" ? typeof __dirname === "string" ? __dirname : "" : path.dirname(fileURLToPath(import.meta.url));
171
+ var DEFAULT_CONFIG_NAME = "agentic-toolbox.json";
172
+ var cachedVersion = "0.0.0";
173
+ function getPackageVersion() {
174
+ if (cachedVersion !== "0.0.0") return cachedVersion;
175
+ const possiblePaths = [];
176
+ for (let depth = 1; depth <= 4; depth++) {
177
+ const parts = [];
178
+ for (let i = 0; i < depth; i++) parts.push("..");
179
+ parts.push("package.json");
180
+ possiblePaths.push(path.join(baseDir, ...parts));
181
+ }
182
+ for (const packageJsonPath of possiblePaths) try {
183
+ const content = fs.readFileSync(packageJsonPath, "utf8");
184
+ const pkg = JSON.parse(content);
185
+ if (pkg.version) {
186
+ cachedVersion = pkg.version;
187
+ return cachedVersion;
188
+ }
189
+ } catch {}
190
+ cachedVersion = "0.0.0";
191
+ return cachedVersion;
192
+ }
193
+ function getParentProjectRoot() {
194
+ return process.cwd();
195
+ }
196
+ function getToolkitDir() {
197
+ const base = path.basename(baseDir);
198
+ if (base === "esm" || base === "cjs" || base === "dist") return baseDir;
199
+ return path.join(baseDir, "..", "..");
200
+ }
201
+ // src/utils/errors/classes.ts
202
+ var AgenticToolboxError = class extends Error {
203
+ code;
204
+ context;
205
+ path;
206
+ target;
207
+ constructor(context) {
208
+ super(context.message);
209
+ this.name = this.constructor.name;
210
+ this.code = context.code;
211
+ this.context = context.details || {};
212
+ this.path = context.path;
213
+ this.target = context.target;
214
+ if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
215
+ }
216
+ toJSON() {
217
+ return {
218
+ name: this.name,
219
+ message: this.message,
220
+ code: this.code,
221
+ context: this.context,
222
+ path: this.path,
223
+ target: this.target,
224
+ stack: this.stack
225
+ };
226
+ }
227
+ };
228
+ var ConfigError = class extends AgenticToolboxError {
229
+ constructor(context) {
230
+ super(context);
231
+ this.name = "ConfigError";
232
+ }
233
+ };
234
+ var ParseError = class extends AgenticToolboxError {
235
+ constructor(context) {
236
+ super(context);
237
+ this.name = "ParseError";
238
+ }
239
+ };
240
+ var CliError = class extends AgenticToolboxError {
241
+ constructor(context) {
242
+ super(context);
243
+ this.name = "CliError";
244
+ }
245
+ };
246
+ var ValidationError = class extends AgenticToolboxError {
247
+ constructor(context) {
248
+ super(context);
249
+ this.name = "ValidationError";
250
+ }
251
+ };
252
+ var ConfigErrorCode = {
253
+ CONFIG_NOT_FOUND: ERROR_CODES.CONFIG_NOT_FOUND,
254
+ CONFIG_INVALID_JSON: ERROR_CODES.CONFIG_INVALID_JSON,
255
+ CONFIG_VALIDATION_FAILED: ERROR_CODES.CONFIG_VALIDATION_FAILED,
256
+ CONFIG_UNKNOWN_TARGET: ERROR_CODES.CONFIG_UNKNOWN_TARGET,
257
+ CONFIG_UNKNOWN_FIELD: ERROR_CODES.CONFIG_UNKNOWN_FIELD
258
+ };
259
+ ERROR_CODES.SYNC_TARGET_FAILED, ERROR_CODES.SYNC_DIRECTORY_CLEANUP_FAILED, ERROR_CODES.SYNC_FILE_READ_FAILED, ERROR_CODES.SYNC_FILE_WRITE_FAILED, ERROR_CODES.SYNC_FILE_COPY_FAILED, ERROR_CODES.SYNC_MERGE_FAILED;
260
+ ERROR_CODES.TRANSFORM_PARSE_FAILED, ERROR_CODES.TRANSFORM_STRIP_FAILED, ERROR_CODES.TRANSFORM_REASSEMBLE_FAILED;
261
+ var ParseErrorCode = {
262
+ YAML_PARSE_FAILED: ERROR_CODES.YAML_PARSE_FAILED,
263
+ YAML_STRINGIFY_FAILED: ERROR_CODES.YAML_STRINGIFY_FAILED
264
+ };
265
+ ERROR_CODES.FS_READ_FAILED, ERROR_CODES.FS_WRITE_FAILED, ERROR_CODES.FS_COPY_FAILED, ERROR_CODES.FS_REMOVE_FAILED, ERROR_CODES.FS_PATH_RESOLUTION_FAILED;
266
+ var CliErrorCode = {
267
+ CLI_INVALID_ARGS: ERROR_CODES.CLI_INVALID_ARGS,
268
+ CLI_UNKNOWN_COMMAND: ERROR_CODES.CLI_UNKNOWN_COMMAND
269
+ };
270
+ var ValidationErrorCode = { VALIDATION_FAILED: ERROR_CODES.VALIDATION_FAILED };
271
+ // src/utils/errors/messages.ts
272
+ var MESSAGES = {
273
+ invalidArgs: (detail) => `Invalid arguments: ${detail}`,
274
+ unknownFlag: (flag) => `Unknown flag: ${flag}`,
275
+ flagRequiresValue: (flag) => `Flag ${flag} requires a value`,
276
+ unsupportedFlagType: (type) => `Unsupported flag type: ${type}`,
277
+ configInvalidJson: (path) => `Failed to parse config file: ${path}`,
278
+ configValidationFailed: "Config validation failed",
279
+ pathTraversal: (p, root) => `Path traversal detected: "${p}" resolves outside project root "${root}"`,
280
+ configMustBeJson: (p) => `Config file must be a JSON file (.json), got: "${p}"`
281
+ };
282
+ // src/utils/fs/sanitization.ts
283
+ /**
284
+ * Sanitizes a file path, ensuring it is a valid string, free of null bytes,
285
+ * and contained within the expected root directory (preventing directory traversal).
286
+ */
287
+ function sanitizePath(filePath, rootDir = getParentProjectRoot()) {
288
+ if (!filePath || typeof filePath !== "string") throw new ValidationError({
289
+ code: ValidationErrorCode.VALIDATION_FAILED,
290
+ message: "Path must be a non-empty string",
291
+ details: { path: filePath }
292
+ });
293
+ if (filePath.includes("\0")) throw new ValidationError({
294
+ code: ValidationErrorCode.VALIDATION_FAILED,
295
+ message: `Invalid path containing null bytes: "${filePath}"`,
296
+ details: { path: filePath }
297
+ });
298
+ const normalizedRoot = path.resolve(rootDir);
299
+ const resolved = path.resolve(normalizedRoot, filePath);
300
+ const relative = path.relative(normalizedRoot, resolved);
301
+ if (relative.startsWith("..") || path.isAbsolute(relative)) throw new ValidationError({
302
+ code: ValidationErrorCode.VALIDATION_FAILED,
303
+ message: `Path traversal detected: "${filePath}" resolves outside project root "${normalizedRoot}"`,
304
+ details: {
305
+ path: filePath,
306
+ resolved,
307
+ rootDir: normalizedRoot
308
+ }
309
+ });
310
+ return resolved;
311
+ }
312
+ /**
313
+ * Sanitizes a config file path. Defaults to `agentic-toolbox.json` in the project root if omitted.
314
+ * Verifies that the path ends with `.json` and does not traverse outside the project root.
315
+ */
316
+ function sanitizeConfigPath(customPath, rootDir = getParentProjectRoot()) {
317
+ if (!customPath) return path.join(rootDir, DEFAULT_CONFIG_NAME);
318
+ const sanitized = sanitizePath(customPath, rootDir);
319
+ if (!sanitized.endsWith(".json")) throw new ValidationError({
320
+ code: ValidationErrorCode.VALIDATION_FAILED,
321
+ message: `Config file must be a JSON file (.json), got: "${customPath}"`,
322
+ details: {
323
+ path: customPath,
324
+ sanitized
325
+ }
326
+ });
327
+ return sanitized;
328
+ }
329
+ // src/core/config/discovery.ts
330
+ function discoverConfig(projectRoot) {
331
+ if (fs.existsSync(path.join(projectRoot, "opencode.json"))) return { targets: ["opencode"] };
332
+ if (fs.existsSync(path.join(projectRoot, "claude.json")) || fs.existsSync(path.join(projectRoot, ".clauderc"))) return { targets: ["claude"] };
333
+ return { targets: ["agents"] };
334
+ }
335
+ // src/core/sync/targets/target-configs.ts
336
+ function getTargetConfig(target) {
337
+ return getTargetDefinition(target);
338
+ }
339
+ // src/core/config/schema.ts
340
+ function validateConfig(config) {
341
+ const errors = [];
342
+ if (config.targets !== void 0) {
343
+ if (!Array.isArray(config.targets)) errors.push({
344
+ field: "targets",
345
+ message: "targets must be an array",
346
+ value: config.targets
347
+ });
348
+ else {
349
+ const validTargets = getTargetNames();
350
+ for (const target of config.targets) if (!validTargets.includes(target)) errors.push({
351
+ field: "targets",
352
+ message: `Unknown target: ${target}. Valid targets: ${validTargets.join(", ")}`,
353
+ value: target
354
+ });
355
+ }
356
+ }
357
+ if (config.sync !== void 0) {
358
+ if (typeof config.sync !== "object" || config.sync === null) errors.push({
359
+ field: "sync",
360
+ message: "sync must be an object",
361
+ value: config.sync
362
+ });
363
+ else {
364
+ if (config.sync.incremental !== void 0 && typeof config.sync.incremental !== "boolean") errors.push({
365
+ field: "sync.incremental",
366
+ message: "sync.incremental must be a boolean",
367
+ value: config.sync.incremental
368
+ });
369
+ if (config.sync.backup !== void 0 && typeof config.sync.backup !== "boolean") errors.push({
370
+ field: "sync.backup",
371
+ message: "sync.backup must be a boolean",
372
+ value: config.sync.backup
373
+ });
374
+ }
375
+ }
376
+ if (config.transform !== void 0) {
377
+ if (typeof config.transform !== "object" || config.transform === null) errors.push({
378
+ field: "transform",
379
+ message: "transform must be an object",
380
+ value: config.transform
381
+ });
382
+ else if (config.transform.preserveComments !== void 0 && typeof config.transform.preserveComments !== "boolean") errors.push({
383
+ field: "transform.preserveComments",
384
+ message: "transform.preserveComments must be a boolean",
385
+ value: config.transform.preserveComments
386
+ });
387
+ }
388
+ if (config.paths !== void 0) {
389
+ if (typeof config.paths !== "object" || config.paths === null) errors.push({
390
+ field: "paths",
391
+ message: "paths must be an object",
392
+ value: config.paths
393
+ });
394
+ else {
395
+ if (config.paths.agents !== void 0 && typeof config.paths.agents !== "string") errors.push({
396
+ field: "paths.agents",
397
+ message: "paths.agents must be a string",
398
+ value: config.paths.agents
399
+ });
400
+ if (config.paths.skills !== void 0 && typeof config.paths.skills !== "string") errors.push({
401
+ field: "paths.skills",
402
+ message: "paths.skills must be a string",
403
+ value: config.paths.skills
404
+ });
405
+ }
406
+ }
407
+ const knownFields = [
408
+ "targets",
409
+ "sync",
410
+ "transform",
411
+ "paths"
412
+ ];
413
+ for (const key of Object.keys(config)) if (!knownFields.includes(key)) errors.push({
414
+ field: key,
415
+ message: `Unknown config field: ${key}`,
416
+ value: config[key]
417
+ });
418
+ return {
419
+ valid: errors.length === 0,
420
+ errors
421
+ };
422
+ }
423
+ function createDefaultConfig() {
424
+ return {
425
+ targets: ["agents"],
426
+ sync: {
427
+ incremental: false,
428
+ backup: true
429
+ },
430
+ transform: { preserveComments: false },
431
+ paths: {
432
+ agents: "agents",
433
+ skills: "skills"
434
+ }
435
+ };
436
+ }
437
+ // src/core/config/loader.ts
438
+ function loadConfig(customConfigPath) {
439
+ const parentProjectRoot = getParentProjectRoot();
440
+ const configPath = sanitizeConfigPath(customConfigPath, parentProjectRoot);
441
+ let config;
442
+ if (fs.existsSync(configPath)) try {
443
+ const fileContent = fs.readFileSync(configPath, "utf8");
444
+ config = JSON.parse(fileContent);
445
+ } catch (error) {
446
+ throw new ConfigError({
447
+ code: ConfigErrorCode.CONFIG_INVALID_JSON,
448
+ message: `Failed to parse config file: ${configPath}`,
449
+ details: {
450
+ path: configPath,
451
+ originalError: error instanceof Error ? error.message : String(error)
452
+ },
453
+ path: configPath
454
+ });
455
+ }
456
+ else config = discoverConfig(parentProjectRoot);
457
+ const validation = validateConfig(config);
458
+ if (!validation.valid) throw new ConfigError({
459
+ code: ConfigErrorCode.CONFIG_VALIDATION_FAILED,
460
+ message: "Config validation failed",
461
+ details: { errors: validation.errors }
462
+ });
463
+ const resolvedTargets = resolveTargets(config.targets);
464
+ try {
465
+ validateTargets(resolvedTargets);
466
+ } catch (error) {
467
+ throw new ConfigError({
468
+ code: ConfigErrorCode.CONFIG_UNKNOWN_TARGET,
469
+ message: error instanceof Error ? error.message : `Invalid target in config`,
470
+ details: {
471
+ targets: resolvedTargets,
472
+ originalError: error instanceof Error ? error.message : String(error)
473
+ },
474
+ path: configPath
475
+ });
476
+ }
477
+ return {
478
+ ...config,
479
+ resolvedTargets
480
+ };
481
+ }
482
+ function resolveTargets(targets) {
483
+ if (!targets || targets.length === 0) return ["agents"];
484
+ return targets;
485
+ }
486
+ // src/core/transform/parser.ts
487
+ var FRONTMATTER_REGEX = /^(---\n)([\s\S]*?)(\n---)/;
488
+ function getYamlPosition(error) {
489
+ if (typeof error !== "object" || error === null || !("linePos" in error)) return;
490
+ const linePos = error.linePos;
491
+ if (!Array.isArray(linePos) || linePos.length === 0) return;
492
+ const first = linePos[0];
493
+ if (typeof first === "object" && first !== null && "line" in first && "col" in first && typeof first.line === "number" && typeof first.col === "number") return {
494
+ line: first.line,
495
+ col: first.col
496
+ };
497
+ }
498
+ function parseFrontmatter(content) {
499
+ const match = content.match(FRONTMATTER_REGEX);
500
+ if (!match) return {
501
+ frontmatter: {},
502
+ body: content,
503
+ hasFrontmatter: false
504
+ };
505
+ const [, opening, frontmatter, closing] = match;
506
+ let parsed;
507
+ try {
508
+ parsed = parse(frontmatter);
509
+ } catch (error) {
510
+ const position = getYamlPosition(error);
511
+ const message = position ? `Failed to parse YAML frontmatter at line ${position.line}, column ${position.col}` : "Failed to parse YAML frontmatter";
512
+ throw new ParseError({
513
+ code: ParseErrorCode.YAML_PARSE_FAILED,
514
+ message,
515
+ details: { originalError: error instanceof Error ? error.message : String(error) }
516
+ });
517
+ }
518
+ const bodyStart = match.index + match[0].length;
519
+ const body = content.slice(bodyStart).trimStart();
520
+ return {
521
+ frontmatter: parsed || {},
522
+ body,
523
+ hasFrontmatter: true
524
+ };
525
+ }
526
+ function stringifyFrontmatter(frontmatter) {
527
+ try {
528
+ return stringify(frontmatter);
529
+ } catch (error) {
530
+ const position = getYamlPosition(error);
531
+ const message = position ? `Failed to stringify YAML frontmatter at line ${position.line}, column ${position.col}` : "Failed to stringify YAML frontmatter";
532
+ throw new ParseError({
533
+ code: ParseErrorCode.YAML_STRINGIFY_FAILED,
534
+ message,
535
+ details: { originalError: error instanceof Error ? error.message : String(error) }
536
+ });
537
+ }
538
+ }
539
+ function extractFrontmatterDelimiters(content) {
540
+ const match = content.match(FRONTMATTER_REGEX);
541
+ if (!match) return null;
542
+ return {
543
+ opening: match[1],
544
+ closing: match[3]
545
+ };
546
+ }
547
+ function parseFrontmatterDocument(content) {
548
+ const match = content.match(FRONTMATTER_REGEX);
549
+ if (!match) return {
550
+ doc: parseDocument(""),
551
+ body: content,
552
+ hasFrontmatter: false
553
+ };
554
+ const [, , frontmatter] = match;
555
+ let doc;
556
+ try {
557
+ doc = parseDocument(frontmatter);
558
+ } catch (error) {
559
+ const position = getYamlPosition(error);
560
+ const message = position ? `Failed to parse YAML frontmatter at line ${position.line}, column ${position.col}` : "Failed to parse YAML frontmatter";
561
+ throw new ParseError({
562
+ code: ParseErrorCode.YAML_PARSE_FAILED,
563
+ message,
564
+ details: { originalError: error instanceof Error ? error.message : String(error) }
565
+ });
566
+ }
567
+ if (doc.errors.length > 0) {
568
+ const position = getYamlPosition(doc.errors[0]);
569
+ const message = position ? `Failed to parse YAML frontmatter at line ${position.line}, column ${position.col}` : "Failed to parse YAML frontmatter";
570
+ throw new ParseError({
571
+ code: ParseErrorCode.YAML_PARSE_FAILED,
572
+ message,
573
+ details: { originalError: doc.errors[0] instanceof Error ? doc.errors[0].message : String(doc.errors[0]) }
574
+ });
575
+ }
576
+ const bodyStart = match.index + match[0].length;
577
+ const body = content.slice(bodyStart).trimStart();
578
+ return {
579
+ doc,
580
+ body,
581
+ hasFrontmatter: true
582
+ };
583
+ }
584
+ function stringifyDocument(doc) {
585
+ try {
586
+ return doc.toString();
587
+ } catch (error) {
588
+ const position = getYamlPosition(error);
589
+ const message = position ? `Failed to stringify YAML frontmatter at line ${position.line}, column ${position.col}` : "Failed to stringify YAML frontmatter";
590
+ throw new ParseError({
591
+ code: ParseErrorCode.YAML_STRINGIFY_FAILED,
592
+ message,
593
+ details: { originalError: error instanceof Error ? error.message : String(error) }
594
+ });
595
+ }
596
+ }
597
+ // src/core/transform/stripper.ts
598
+ function stripFields(frontmatter, fieldsToStrip) {
599
+ const result = { ...frontmatter };
600
+ for (const field of fieldsToStrip) if (field in result) delete result[field];
601
+ return result;
602
+ }
603
+ // src/core/transform/reassembler.ts
604
+ function reassembleContent(parsed, originalContent) {
605
+ if (!parsed.hasFrontmatter) return originalContent;
606
+ const delimiters = extractFrontmatterDelimiters(originalContent);
607
+ if (!delimiters) return originalContent;
608
+ const frontmatterYaml = stringifyFrontmatter(parsed.frontmatter);
609
+ return `${delimiters.opening}${frontmatterYaml}${delimiters.closing}${parsed.body}`;
610
+ }
611
+ // src/core/transform/pipeline.ts
612
+ var defaultTransformPipeline = {
613
+ parse: parseFrontmatter,
614
+ strip: stripFields,
615
+ reassemble: reassembleContent
616
+ };
617
+ // src/core/transform/transform-agent.ts
618
+ function transformAgentContent(content, target, pipeline = defaultTransformPipeline, preserveComments = false) {
619
+ const options = {
620
+ target,
621
+ stripFields: getStripFields(target),
622
+ preserveComments
623
+ };
624
+ if (preserveComments) return transformWithComments(content, options.stripFields);
625
+ const parsed = pipeline.parse(content);
626
+ if (!parsed.hasFrontmatter || options.stripFields.length === 0) return content;
627
+ const strippedFrontmatter = pipeline.strip(parsed.frontmatter, options.stripFields);
628
+ const transformed = {
629
+ ...parsed,
630
+ frontmatter: strippedFrontmatter
631
+ };
632
+ return pipeline.reassemble(transformed, content);
633
+ }
634
+ function transformWithComments(content, stripFields) {
635
+ const parsed = parseFrontmatterDocument(content);
636
+ if (!parsed.hasFrontmatter || stripFields.length === 0) return content;
637
+ const delimiters = extractFrontmatterDelimiters(content);
638
+ if (!delimiters) return content;
639
+ for (const field of stripFields) parsed.doc.delete(field);
640
+ const frontmatterYaml = stringifyDocument(parsed.doc);
641
+ return `${delimiters.opening}${frontmatterYaml}${delimiters.closing}${parsed.body}`;
642
+ }
643
+ // src/core/sync/merger.ts
644
+ async function mergeAgents(targetDir, toolkitDir, projectDir, config) {
645
+ const result = {
646
+ overwritten: [],
647
+ added: [],
648
+ skipped: []
649
+ };
650
+ const toolkitAgentsDir = path.join(toolkitDir, "agents");
651
+ const projectAgentsDir = projectDir;
652
+ if (!fs.existsSync(toolkitAgentsDir) && !fs.existsSync(projectAgentsDir)) return result;
653
+ const toolkitFiles = new Set(fs.existsSync(toolkitAgentsDir) ? fs.readdirSync(toolkitAgentsDir).filter((f) => f.endsWith(".md")) : []);
654
+ const projectFiles = new Set(fs.existsSync(projectAgentsDir) ? fs.readdirSync(projectAgentsDir).filter((f) => f.endsWith(".md")) : []);
655
+ const allFiles = /* @__PURE__ */ new Set([...toolkitFiles, ...projectFiles]);
656
+ for (const file of allFiles) {
657
+ const destPath = path.join(targetDir, "agents", file);
658
+ const isInToolkit = toolkitFiles.has(file);
659
+ if (projectFiles.has(file)) {
660
+ const srcPath = path.join(projectAgentsDir, file);
661
+ fs.copyFileSync(srcPath, destPath);
662
+ if (isInToolkit) result.overwritten.push(file);
663
+ else result.added.push(file);
664
+ } else if (isInToolkit) {
665
+ const srcPath = path.join(toolkitAgentsDir, file);
666
+ fs.copyFileSync(srcPath, destPath);
667
+ result.added.push(file);
668
+ }
669
+ }
670
+ return result;
671
+ }
672
+ async function mergeSkills(targetDir, toolkitDir, projectDir) {
673
+ const result = {
674
+ overwritten: [],
675
+ added: [],
676
+ skipped: []
677
+ };
678
+ const toolkitSkillsDir = path.join(toolkitDir, "skills");
679
+ const projectSkillsDir = projectDir;
680
+ if (!fs.existsSync(toolkitSkillsDir) && !fs.existsSync(projectSkillsDir)) return result;
681
+ if (fs.existsSync(toolkitSkillsDir)) {
682
+ copyDirectoryRecursive(toolkitSkillsDir, path.join(targetDir, "skills"));
683
+ result.added.push("skills/ (toolkit)");
684
+ }
685
+ if (fs.existsSync(projectSkillsDir)) {
686
+ copyDirectoryRecursive(projectSkillsDir, path.join(targetDir, "skills"));
687
+ result.overwritten.push("skills/ (project)");
688
+ }
689
+ return result;
690
+ }
691
+ function copyDirectoryRecursive(src, dest) {
692
+ fs.cpSync(src, dest, { recursive: true });
693
+ }
694
+ // src/core/sync/manifest.ts
695
+ var MANIFEST_FILENAME = ".agentic-toolbox-manifest.json";
696
+ function getManifestPath(targetDir) {
697
+ return path.join(targetDir, MANIFEST_FILENAME);
698
+ }
699
+ function loadManifest(targetDir) {
700
+ const manifestPath = getManifestPath(targetDir);
701
+ if (!fs.existsSync(manifestPath)) return null;
702
+ try {
703
+ const content = fs.readFileSync(manifestPath, "utf8");
704
+ return JSON.parse(content);
705
+ } catch {
706
+ return null;
707
+ }
708
+ }
709
+ function saveManifest(targetDir, manifest) {
710
+ const manifestPath = getManifestPath(targetDir);
711
+ fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
712
+ }
713
+ function createManifest() {
714
+ return {
715
+ version: 1,
716
+ files: {}
717
+ };
718
+ }
719
+ function computeFileHash(filePath) {
720
+ const content = fs.readFileSync(filePath);
721
+ return createHash("sha256").update(content).digest("hex").substring(0, 16);
722
+ }
723
+ function createFileEntry(filePath, targetDir, target) {
724
+ const stats = fs.statSync(filePath);
725
+ path.relative(targetDir, filePath);
726
+ return {
727
+ hash: computeFileHash(filePath),
728
+ size: stats.size,
729
+ mtime: stats.mtimeMs,
730
+ target
731
+ };
732
+ }
733
+ function updateManifestForSync(manifest, targetDir, target, syncedFiles) {
734
+ const newManifest = {
735
+ ...manifest,
736
+ files: { ...manifest.files }
737
+ };
738
+ for (const file of syncedFiles) {
739
+ const filePath = path.join(targetDir, file);
740
+ if (fs.existsSync(filePath)) newManifest.files[file] = createFileEntry(filePath, targetDir, target);
741
+ else delete newManifest.files[file];
742
+ }
743
+ return newManifest;
744
+ }
745
+ // src/utils/logging/console.ts
746
+ var ConsoleLogger = class {
747
+ level;
748
+ useColor;
749
+ stream;
750
+ errorStream;
751
+ json = false;
752
+ runId = "";
753
+ constructor(options = {}) {
754
+ this.level = options.level ?? "info";
755
+ this.stream = options.stream ?? process.stdout;
756
+ this.errorStream = options.errorStream ?? process.stderr;
757
+ const isTTY = Boolean(this.stream.isTTY);
758
+ this.useColor = (options.useColor ?? true) && isTTY;
759
+ }
760
+ setLevel(level) {
761
+ this.level = level;
762
+ }
763
+ setColor(enabled) {
764
+ const isTTY = Boolean(this.stream.isTTY);
765
+ this.useColor = enabled && isTTY;
766
+ }
767
+ setJson(enabled) {
768
+ this.json = enabled;
769
+ }
770
+ setRunId(runId) {
771
+ this.runId = runId;
772
+ }
773
+ setStream(stream) {
774
+ this.stream = stream;
775
+ const isTTY = Boolean(this.stream.isTTY);
776
+ this.useColor = this.useColor && isTTY;
777
+ }
778
+ setErrorStream(errorStream) {
779
+ this.errorStream = errorStream;
780
+ }
781
+ getStream() {
782
+ return this.stream;
783
+ }
784
+ getErrorStream() {
785
+ return this.errorStream;
786
+ }
787
+ debug(message, ...args) {
788
+ this.log("debug", message, args);
789
+ }
790
+ info(message, ...args) {
791
+ this.log("info", message, args);
792
+ }
793
+ warn(message, ...args) {
794
+ this.log("warn", message, args);
795
+ }
796
+ error(message, ...args) {
797
+ this.log("error", message, args);
798
+ }
799
+ success(message, ...args) {
800
+ this.log("success", message, args);
801
+ }
802
+ raw(message) {
803
+ this.stream.write(`${message}\n`);
804
+ }
805
+ log(level, message, args) {
806
+ if (!this.shouldLog(level)) return;
807
+ const target = level === "warn" || level === "error" ? this.errorStream : this.stream;
808
+ if (this.json) {
809
+ const entry = {
810
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
811
+ level,
812
+ runId: this.runId,
813
+ message
814
+ };
815
+ if (args.length > 0) entry.args = args.map(String);
816
+ target.write(`${JSON.stringify(entry)}\n`);
817
+ return;
818
+ }
819
+ const output = `${this.getPrefix(level)} ${message}${args.length > 0 ? " " + args.map(String).join(" ") : ""}\n`;
820
+ target.write(output);
821
+ }
822
+ shouldLog(level) {
823
+ const levels = {
824
+ debug: 0,
825
+ info: 1,
826
+ warn: 2,
827
+ error: 3,
828
+ success: 1
829
+ };
830
+ return levels[level] >= levels[this.level];
831
+ }
832
+ getPrefix(level) {
833
+ return {
834
+ debug: this.colorize("DEBUG", "gray"),
835
+ info: this.colorize("INFO", "blue"),
836
+ warn: this.colorize("WARN", "yellow"),
837
+ error: this.colorize("ERROR", "red"),
838
+ success: this.colorize("OK", "green")
839
+ }[level];
840
+ }
841
+ colorize(text, color) {
842
+ if (!this.useColor) return `[${text}]`;
843
+ const colors = {
844
+ gray: "\x1B[90m",
845
+ blue: "\x1B[34m",
846
+ yellow: "\x1B[33m",
847
+ red: "\x1B[31m",
848
+ green: "\x1B[32m",
849
+ reset: "\x1B[0m"
850
+ };
851
+ return `${colors[color]}[${text}]${colors.reset}`;
852
+ }
853
+ };
854
+ var logger = new ConsoleLogger();
855
+ /** Generate a short random run/correlation id (e.g. "a1b2c3"). */
856
+ function generateRunId() {
857
+ return randomBytes(3).toString("hex");
858
+ }
859
+ function log(message, verbose = false) {
860
+ if (verbose) logger.debug(message);
861
+ }
862
+ // src/core/sync/engine-internal.ts
863
+ async function syncToTargetImpl(targetName, targetConfig, options) {
864
+ const parentProjectRoot = getParentProjectRoot();
865
+ const toolkitDir = getToolkitDir();
866
+ const targetDir = sanitizePath(targetConfig.directory, parentProjectRoot);
867
+ const incremental = options.config.sync?.incremental === true;
868
+ log(` Syncing to ${targetConfig.directory}...`, options.verbose);
869
+ try {
870
+ if (!options.dryRun) {
871
+ if (options.config.sync?.backup && fs$1.existsSync(targetDir)) {
872
+ const backupDir = `${targetDir}.bak-${formatTimestamp(/* @__PURE__ */ new Date())}`;
873
+ fs$1.cpSync(targetDir, backupDir, { recursive: true });
874
+ log(`[OK] Backup created at ${backupDir}`, true);
875
+ }
876
+ if (!incremental) await cleanupTargetDirectory(targetDir);
877
+ await createTargetDirectories(targetDir);
878
+ }
879
+ const toolkitAgentsDir = path$1.join(toolkitDir, "agents");
880
+ const toolkitSkillsDir = path$1.join(toolkitDir, "skills");
881
+ const projectAgentsDir = sanitizePath(options.config.paths?.agents || "agents", parentProjectRoot);
882
+ const projectSkillsDir = sanitizePath(options.config.paths?.skills || "skills", parentProjectRoot);
883
+ const filesSynced = [];
884
+ const manifest = incremental && !options.dryRun ? loadManifest(targetDir) ?? createManifest() : null;
885
+ const manifestFiles = [];
886
+ if (options.dryRun) {
887
+ logger.info(`Dry run: would sync to ${targetConfig.directory}`);
888
+ if (fs$1.existsSync(toolkitAgentsDir)) {
889
+ const agentFiles = fs$1.readdirSync(toolkitAgentsDir).filter((f) => f.endsWith(".md"));
890
+ for (const file of agentFiles) filesSynced.push(`agents/${file}`);
891
+ }
892
+ if (fs$1.existsSync(projectAgentsDir)) {
893
+ const agentFiles = fs$1.readdirSync(projectAgentsDir).filter((f) => f.endsWith(".md"));
894
+ for (const file of agentFiles) filesSynced.push(`agents/${file}`);
895
+ }
896
+ if (fs$1.existsSync(toolkitSkillsDir)) {
897
+ const skillDirs = fs$1.readdirSync(toolkitSkillsDir).filter((f) => fs$1.statSync(path$1.join(toolkitSkillsDir, f)).isDirectory());
898
+ for (const skillDir of skillDirs) filesSynced.push(`skills/${skillDir}/`);
899
+ }
900
+ if (fs$1.existsSync(projectSkillsDir)) {
901
+ const skillDirs = fs$1.readdirSync(projectSkillsDir).filter((f) => fs$1.statSync(path$1.join(projectSkillsDir, f)).isDirectory());
902
+ for (const skillDir of skillDirs) filesSynced.push(`skills/${skillDir}/`);
903
+ }
904
+ for (const entry of filesSynced) logger.info(` ${entry}`);
905
+ return {
906
+ success: true,
907
+ message: `Dry run complete for ${targetConfig.directory}`,
908
+ target: targetName,
909
+ filesSynced
910
+ };
911
+ }
912
+ if (!options.dryRun) {
913
+ if (targetConfig.transformAgents) {
914
+ const toolkitAgentNames = /* @__PURE__ */ new Set();
915
+ if (fs$1.existsSync(toolkitAgentsDir)) {
916
+ const agentFiles = fs$1.readdirSync(toolkitAgentsDir).filter((f) => f.endsWith(".md"));
917
+ for (const file of agentFiles) {
918
+ const srcPath = path$1.join(toolkitAgentsDir, file);
919
+ const destPath = path$1.join(targetDir, "agents", file);
920
+ const transformed = transformAgentContent(fs$1.readFileSync(srcPath, "utf8"), targetName, void 0, options.config.transform?.preserveComments ?? false);
921
+ const agentName = file.replace(/\.md$/, "");
922
+ if (incremental && fs$1.existsSync(destPath) && fs$1.readFileSync(destPath, "utf8") === transformed) log(` '${agentName}' unchanged (skipped)`, options.verbose);
923
+ else fs$1.writeFileSync(destPath, transformed);
924
+ toolkitAgentNames.add(file);
925
+ filesSynced.push(`agents/${file}`);
926
+ manifestFiles.push(`agents/${file}`);
927
+ log(`[OK] '${agentName}' Agent Synced to ${targetConfig.directory}`, true);
928
+ }
929
+ } else log(` Toolkit agents directory not found: ${toolkitAgentsDir}`, options.verbose);
930
+ if (fs$1.existsSync(projectAgentsDir)) {
931
+ const agentFiles = fs$1.readdirSync(projectAgentsDir).filter((f) => f.endsWith(".md"));
932
+ for (const file of agentFiles) {
933
+ if (toolkitAgentNames.has(file)) logger.warn(`Conflict: project agent '${file}' overrides toolkit template`);
934
+ const srcPath = path$1.join(projectAgentsDir, file);
935
+ const destPath = path$1.join(targetDir, "agents", file);
936
+ const transformed = transformAgentContent(fs$1.readFileSync(srcPath, "utf8"), targetName, void 0, options.config.transform?.preserveComments ?? false);
937
+ const agentName = file.replace(/\.md$/, "");
938
+ if (incremental && fs$1.existsSync(destPath) && fs$1.readFileSync(destPath, "utf8") === transformed) log(` '${agentName}' unchanged (skipped)`, options.verbose);
939
+ else fs$1.writeFileSync(destPath, transformed);
940
+ filesSynced.push(`agents/${file}`);
941
+ manifestFiles.push(`agents/${file}`);
942
+ log(`[OK] '${agentName}' Agent Synced to ${targetConfig.directory}`, true);
943
+ }
944
+ } else log(` Project agents directory not found: ${projectAgentsDir}`, options.verbose);
945
+ } else {
946
+ const toolkitAgentFiles = fs$1.existsSync(toolkitAgentsDir) ? fs$1.readdirSync(toolkitAgentsDir).filter((f) => f.endsWith(".md")) : [];
947
+ const projectAgentFiles = fs$1.existsSync(projectAgentsDir) ? fs$1.readdirSync(projectAgentsDir).filter((f) => f.endsWith(".md")) : [];
948
+ await mergeAgents(targetDir, toolkitDir, projectAgentsDir, options.config);
949
+ if (!fs$1.existsSync(toolkitAgentsDir)) log(` Toolkit agents directory not found: ${toolkitAgentsDir}`, options.verbose);
950
+ for (const file of toolkitAgentFiles) {
951
+ const agentName = file.replace(/\.md$/, "");
952
+ filesSynced.push(`agents/${file}`);
953
+ log(`[OK] '${agentName}' Agent Synced to ${targetConfig.directory}`, true);
954
+ }
955
+ if (!fs$1.existsSync(projectAgentsDir)) log(` Project agents directory not found: ${projectAgentsDir}`, options.verbose);
956
+ const toolkitAgentSet = new Set(toolkitAgentFiles);
957
+ for (const file of projectAgentFiles) {
958
+ if (toolkitAgentSet.has(file)) logger.warn(`Conflict: project agent '${file}' overrides toolkit template`);
959
+ const agentName = file.replace(/\.md$/, "");
960
+ filesSynced.push(`agents/${file}`);
961
+ log(`[OK] '${agentName}' Agent Synced to ${targetConfig.directory}`, true);
962
+ }
963
+ }
964
+ }
965
+ if (!options.dryRun) {
966
+ const toolkitSkillDirs = fs$1.existsSync(toolkitSkillsDir) ? fs$1.readdirSync(toolkitSkillsDir).filter((f) => fs$1.statSync(path$1.join(toolkitSkillsDir, f)).isDirectory()) : [];
967
+ const projectSkillDirs = fs$1.existsSync(projectSkillsDir) ? fs$1.readdirSync(projectSkillsDir).filter((f) => fs$1.statSync(path$1.join(projectSkillsDir, f)).isDirectory()) : [];
968
+ await mergeSkills(targetDir, toolkitDir, projectSkillsDir);
969
+ if (!fs$1.existsSync(toolkitSkillsDir)) log(` Toolkit skills directory not found: ${toolkitSkillsDir}`, options.verbose);
970
+ for (const skillDir of toolkitSkillDirs) {
971
+ filesSynced.push(`skills/${skillDir}/`);
972
+ log(`[OK] '${skillDir}' Skill Synced to ${targetConfig.directory}`, true);
973
+ }
974
+ if (!fs$1.existsSync(projectSkillsDir)) log(` Project skills directory not found: ${projectSkillsDir}`, options.verbose);
975
+ const toolkitSkillSet = new Set(toolkitSkillDirs);
976
+ for (const skillDir of projectSkillDirs) {
977
+ if (toolkitSkillSet.has(skillDir)) logger.warn(`Conflict: project skill '${skillDir}' overrides toolkit template`);
978
+ filesSynced.push(`skills/${skillDir}/`);
979
+ log(`[OK] '${skillDir}' Skill Synced to ${targetConfig.directory}`, true);
980
+ }
981
+ }
982
+ if (incremental && manifest) {
983
+ saveManifest(targetDir, updateManifestForSync(manifest, targetDir, targetName, manifestFiles));
984
+ log(` Manifest updated (${manifestFiles.length} file(s) tracked)`, options.verbose);
985
+ }
986
+ return {
987
+ success: true,
988
+ message: `Synced to ${targetConfig.directory}`,
989
+ target: targetName,
990
+ filesSynced
991
+ };
992
+ } catch (error) {
993
+ return {
994
+ success: false,
995
+ target: targetName,
996
+ message: `Failed to sync to ${targetConfig.directory}`,
997
+ error
998
+ };
999
+ }
1000
+ }
1001
+ async function cleanupTargetDirectory(targetDir) {
1002
+ if (fs$1.existsSync(targetDir)) fs$1.rmSync(targetDir, {
1003
+ recursive: true,
1004
+ force: true
1005
+ });
1006
+ }
1007
+ async function createTargetDirectories(targetDir) {
1008
+ fs$1.mkdirSync(path$1.join(targetDir, "agents"), { recursive: true });
1009
+ fs$1.mkdirSync(path$1.join(targetDir, "skills"), { recursive: true });
1010
+ }
1011
+ function formatTimestamp(date) {
1012
+ const pad = (n) => String(n).padStart(2, "0");
1013
+ return `${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(date.getDate())}-${pad(date.getHours())}${pad(date.getMinutes())}${pad(date.getSeconds())}`;
1014
+ }
1015
+ // src/core/sync/engine.ts
1016
+ async function syncToTargets(options) {
1017
+ const targets = options.targets || options.config.resolvedTargets;
1018
+ const results = [];
1019
+ for (const target of targets) {
1020
+ const result = await syncToTargetImpl(target, getTargetConfig(target), options);
1021
+ results.push(result);
1022
+ }
1023
+ return results;
1024
+ }
1025
+ // src/cli/commands/sync.ts
1026
+ async function syncCommand(args) {
1027
+ if (args.quiet) logger.setLevel("error");
1028
+ else if (args.verbose) logger.setLevel("debug");
1029
+ try {
1030
+ logger.info(`Agentic Toolbox v${getPackageVersion()} - Syncing agents and skills`);
1031
+ const config = loadConfig(args.configPath);
1032
+ if (args.incremental) config.sync = {
1033
+ ...config.sync,
1034
+ incremental: true
1035
+ };
1036
+ const targets = args.targets ? validateTargets(args.targets) : void 0;
1037
+ const results = await syncToTargets({
1038
+ config,
1039
+ dryRun: args.dryRun,
1040
+ verbose: args.verbose,
1041
+ targets
1042
+ });
1043
+ let allSuccess = true;
1044
+ for (const result of results) if (result.success) {
1045
+ logger.success(` ${result.message}`);
1046
+ if (args.verbose && result.filesSynced) for (const file of result.filesSynced) logger.debug(` ${file}`);
1047
+ } else {
1048
+ logger.error(` ${result.message}`);
1049
+ if (result.error) logger.error(` ${result.error.message}`);
1050
+ allSuccess = false;
1051
+ }
1052
+ if (args.dryRun) logger.info("\nDry run complete - no changes made");
1053
+ else if (allSuccess) logger.info("\nSync complete");
1054
+ return {
1055
+ success: allSuccess,
1056
+ exitCode: allSuccess ? 0 : 1
1057
+ };
1058
+ } catch (error) {
1059
+ logger.error(`Sync failed: ${error instanceof Error ? error.message : String(error)}`);
1060
+ return {
1061
+ success: false,
1062
+ exitCode: 1,
1063
+ error
1064
+ };
1065
+ }
1066
+ }
1067
+ // src/cli/commands/validate.ts
1068
+ async function validateCommand(args) {
1069
+ if (args.verbose) logger.setLevel("debug");
1070
+ try {
1071
+ logger.info(`Agentic Toolbox v${getPackageVersion()} - Validating configuration`);
1072
+ const config = loadConfig(args.configPath);
1073
+ logger.success("Config file: valid");
1074
+ const toolkitDir = getToolkitDir();
1075
+ const toolkitAgentsDir = path.join(toolkitDir, "agents");
1076
+ if (fs.existsSync(toolkitAgentsDir)) {
1077
+ const agentFiles = fs.readdirSync(toolkitAgentsDir).filter((f) => f.endsWith(".md"));
1078
+ logger.info(`Toolkit agents: ${agentFiles.length} file(s)`);
1079
+ for (const file of agentFiles) logger.debug(` ${file}`);
1080
+ }
1081
+ const toolkitSkillsDir = path.join(toolkitDir, "skills");
1082
+ if (fs.existsSync(toolkitSkillsDir)) {
1083
+ const skillDirs = fs.readdirSync(toolkitSkillsDir).filter((f) => {
1084
+ const fullPath = path.join(toolkitSkillsDir, f);
1085
+ return fs.statSync(fullPath).isDirectory();
1086
+ });
1087
+ logger.info(`Toolkit skills: ${skillDirs.length} directory(ies)`);
1088
+ for (const dir of skillDirs) logger.debug(` ${dir}/`);
1089
+ }
1090
+ const projectAgentsDir = path.join(getParentProjectRoot(), config.paths?.agents || "agents");
1091
+ if (fs.existsSync(projectAgentsDir)) {
1092
+ const agentFiles = fs.readdirSync(projectAgentsDir).filter((f) => f.endsWith(".md"));
1093
+ logger.info(`Project agents: ${agentFiles.length} file(s)`);
1094
+ }
1095
+ const projectSkillsDir = path.join(getParentProjectRoot(), config.paths?.skills || "skills");
1096
+ if (fs.existsSync(projectSkillsDir)) {
1097
+ const skillDirs = fs.readdirSync(projectSkillsDir).filter((f) => {
1098
+ const fullPath = path.join(projectSkillsDir, f);
1099
+ return fs.statSync(fullPath).isDirectory();
1100
+ });
1101
+ logger.info(`Project skills: ${skillDirs.length} directory(ies)`);
1102
+ }
1103
+ const validTargets = config.resolvedTargets;
1104
+ logger.info(`Targets to sync: ${validTargets.join(", ")}`);
1105
+ logger.success("\nValidation complete - all checks passed");
1106
+ return {
1107
+ success: true,
1108
+ exitCode: 0
1109
+ };
1110
+ } catch (error) {
1111
+ const err = error;
1112
+ logger.error(`Validation failed: ${err.message}`);
1113
+ if (err.context?.errors) for (const e of err.context.errors) logger.error(` ${e.field}: ${e.message}${e.value !== void 0 ? ` (got: ${JSON.stringify(e.value)})` : ""}`);
1114
+ return {
1115
+ success: false,
1116
+ exitCode: 1,
1117
+ error
1118
+ };
1119
+ }
1120
+ }
1121
+ // src/cli/commands/diff.ts
1122
+ async function diffCommand(args) {
1123
+ if (args.verbose) logger.setLevel("debug");
1124
+ try {
1125
+ logger.info(`Agentic Toolbox v${getPackageVersion()} - Diff preview`);
1126
+ const config = loadConfig(args.configPath);
1127
+ const targets = args.targets ? validateTargets(args.targets) : config.resolvedTargets;
1128
+ let hasChanges = false;
1129
+ for (const targetName of targets) {
1130
+ const targetConfig = getTargetConfig(targetName);
1131
+ const targetDir = path.join(getParentProjectRoot(), targetConfig.directory);
1132
+ const toolkitDir = getToolkitDir();
1133
+ logger.info(`\n--- Diff for ${targetConfig.directory} ---`);
1134
+ const toolkitAgentsDir = path.join(toolkitDir, "agents");
1135
+ const projectAgentsDir = path.join(getParentProjectRoot(), config.paths?.agents || "agents");
1136
+ if (fs.existsSync(toolkitAgentsDir)) {
1137
+ const agentFiles = fs.readdirSync(toolkitAgentsDir).filter((f) => f.endsWith(".md"));
1138
+ for (const file of agentFiles) {
1139
+ const toolkitPath = path.join(toolkitAgentsDir, file);
1140
+ const targetPath = path.join(targetDir, "agents", file);
1141
+ const toolkitContent = fs.readFileSync(toolkitPath, "utf8");
1142
+ const transformedContent = targetConfig.transformAgents ? transformAgentContent(toolkitContent, targetName) : toolkitContent;
1143
+ if (fs.existsSync(targetPath)) {
1144
+ const currentContent = fs.readFileSync(targetPath, "utf8");
1145
+ if (currentContent !== transformedContent) {
1146
+ hasChanges = true;
1147
+ logger.warn(` M agents/${file} (modified)`);
1148
+ if (args.verbose) printDiff(currentContent, transformedContent, file);
1149
+ } else logger.debug(` = agents/${file} (unchanged)`);
1150
+ } else {
1151
+ hasChanges = true;
1152
+ logger.success(` + agents/${file} (new)`);
1153
+ }
1154
+ }
1155
+ }
1156
+ if (fs.existsSync(projectAgentsDir)) {
1157
+ const agentFiles = fs.readdirSync(projectAgentsDir).filter((f) => f.endsWith(".md"));
1158
+ for (const file of agentFiles) {
1159
+ const projectPath = path.join(projectAgentsDir, file);
1160
+ const targetPath = path.join(targetDir, "agents", file);
1161
+ const projectContent = fs.readFileSync(projectPath, "utf8");
1162
+ const transformedContent = targetConfig.transformAgents ? transformAgentContent(projectContent, targetName) : projectContent;
1163
+ if (fs.existsSync(targetPath)) {
1164
+ const currentContent = fs.readFileSync(targetPath, "utf8");
1165
+ if (currentContent !== transformedContent) {
1166
+ hasChanges = true;
1167
+ logger.warn(` M agents/${file} (project override)`);
1168
+ if (args.verbose) printDiff(currentContent, transformedContent, file);
1169
+ }
1170
+ } else {
1171
+ hasChanges = true;
1172
+ logger.success(` + agents/${file} (project override, new)`);
1173
+ }
1174
+ }
1175
+ }
1176
+ const toolkitSkillsDir = path.join(toolkitDir, "skills");
1177
+ const projectSkillsDir = path.join(getParentProjectRoot(), config.paths?.skills || "skills");
1178
+ if (fs.existsSync(toolkitSkillsDir)) {
1179
+ const skillDirs = fs.readdirSync(toolkitSkillsDir).filter((f) => fs.statSync(path.join(toolkitSkillsDir, f)).isDirectory());
1180
+ for (const skillDir of skillDirs) {
1181
+ const targetSkillDir = path.join(targetDir, "skills", skillDir);
1182
+ if (!fs.existsSync(targetSkillDir)) {
1183
+ hasChanges = true;
1184
+ logger.success(` + skills/${skillDir}/ (new)`);
1185
+ } else logger.debug(` = skills/${skillDir}/ (exists)`);
1186
+ }
1187
+ }
1188
+ if (fs.existsSync(projectSkillsDir)) {
1189
+ const skillDirs = fs.readdirSync(projectSkillsDir).filter((f) => fs.statSync(path.join(projectSkillsDir, f)).isDirectory());
1190
+ for (const skillDir of skillDirs) {
1191
+ const targetSkillDir = path.join(targetDir, "skills", skillDir);
1192
+ if (!fs.existsSync(targetSkillDir)) {
1193
+ hasChanges = true;
1194
+ logger.success(` + skills/${skillDir}/ (project override, new)`);
1195
+ } else logger.warn(` M skills/${skillDir}/ (project override)`);
1196
+ }
1197
+ }
1198
+ }
1199
+ if (!hasChanges) logger.info("\nNo changes detected");
1200
+ return {
1201
+ success: true,
1202
+ exitCode: 0
1203
+ };
1204
+ } catch (error) {
1205
+ logger.error(`Diff failed: ${error instanceof Error ? error.message : String(error)}`);
1206
+ return {
1207
+ success: false,
1208
+ exitCode: 1,
1209
+ error
1210
+ };
1211
+ }
1212
+ }
1213
+ function printDiff(oldContent, newContent, filename) {
1214
+ const oldLines = oldContent.split("\n");
1215
+ const newLines = newContent.split("\n");
1216
+ logger.info(`\n --- ${filename}`);
1217
+ logger.info(` +++ ${filename}`);
1218
+ const maxLines = Math.max(oldLines.length, newLines.length);
1219
+ for (let i = 0; i < maxLines; i++) {
1220
+ const oldLine = oldLines[i];
1221
+ const newLine = newLines[i];
1222
+ if (oldLine !== newLine) {
1223
+ if (oldLine !== void 0) logger.error(` -${oldLine}`);
1224
+ if (newLine !== void 0) logger.success(` +${newLine}`);
1225
+ }
1226
+ }
1227
+ }
1228
+ // \0vite/preload-helper.js
1229
+ var scriptRel = "modulepreload";
1230
+ var assetsURL = function(dep) {
1231
+ return "/" + dep;
1232
+ };
1233
+ var seen = {};
1234
+ var failedCssLinks = {};
1235
+ var isCssPreloadUrl = function isCssPreloadUrl(url) {
1236
+ return url.pathname.endsWith(".css");
1237
+ };
1238
+ var preloadOnce = function preloadOnce(seen, href, preload) {
1239
+ if (href in seen) return seen[href];
1240
+ const promise = preload();
1241
+ if (!promise) {
1242
+ seen[href] = void 0;
1243
+ return;
1244
+ }
1245
+ const preloadPromise = promise.then(() => {
1246
+ seen[href] = void 0;
1247
+ }, (err) => {
1248
+ delete seen[href];
1249
+ throw err;
1250
+ });
1251
+ seen[href] = preloadPromise;
1252
+ return preloadPromise;
1253
+ };
1254
+ var __vitePreload = function preload(baseModule, deps, importerUrl) {
1255
+ let promise = Promise.resolve();
1256
+ if (deps && deps.length > 0) {
1257
+ let preloadedHrefs;
1258
+ const cspNonceMeta = document.querySelector("meta[property=csp-nonce]");
1259
+ const cspNonce = cspNonceMeta?.nonce || cspNonceMeta?.getAttribute("nonce");
1260
+ function allSettled(promises) {
1261
+ return Promise.all(promises.map((p) => Promise.resolve(p).then((value) => ({
1262
+ status: "fulfilled",
1263
+ value
1264
+ }), (reason) => ({
1265
+ status: "rejected",
1266
+ reason
1267
+ }))));
1268
+ }
1269
+ function importMetaResolve(specifier) {
1270
+ if (import.meta.resolve) return new URL(import.meta.resolve(specifier));
1271
+ return new URL(
1272
+ specifier,
1273
+ /** #__KEEP__ */
1274
+ import.meta.url
1275
+ );
1276
+ }
1277
+ promise = allSettled(deps.map((depString) => {
1278
+ depString = assetsURL(depString, importerUrl);
1279
+ const dep = importMetaResolve(depString);
1280
+ const isCss = isCssPreloadUrl(dep);
1281
+ return preloadOnce(seen, dep.href, () => {
1282
+ if (preloadedHrefs === void 0) {
1283
+ preloadedHrefs = {
1284
+ all: /* @__PURE__ */ new Set(),
1285
+ styles: /* @__PURE__ */ new Set()
1286
+ };
1287
+ const links = document.getElementsByTagName("link");
1288
+ for (let i = links.length - 1; i >= 0; i--) {
1289
+ const link = links[i];
1290
+ preloadedHrefs.all.add(link.href);
1291
+ if (link.rel === "stylesheet") preloadedHrefs.styles.add(link.href);
1292
+ }
1293
+ }
1294
+ const preloadedHrefSet = isCss ? preloadedHrefs.styles : preloadedHrefs.all;
1295
+ const failedCssLink = isCss ? failedCssLinks[dep.href] : void 0;
1296
+ if (!failedCssLink && preloadedHrefSet.has(dep.href)) return;
1297
+ const link = document.createElement("link");
1298
+ link.rel = isCss ? "stylesheet" : scriptRel;
1299
+ if (!isCss) link.as = "script";
1300
+ link.crossOrigin = "";
1301
+ link.href = dep.href;
1302
+ if (cspNonce) link.setAttribute("nonce", cspNonce);
1303
+ if (failedCssLink) delete failedCssLinks[dep.href];
1304
+ if (failedCssLink?.isConnected) failedCssLink.replaceWith(link);
1305
+ else document.head.appendChild(link);
1306
+ if (isCss) return new Promise((res, rej) => {
1307
+ const handleSettle = (e) => {
1308
+ link.removeEventListener("load", handleSettle);
1309
+ link.removeEventListener("error", handleSettle);
1310
+ if (e.type === "error") {
1311
+ failedCssLinks[dep.href] = link;
1312
+ rej(/* @__PURE__ */ new Error(`Unable to preload CSS for ${dep}`));
1313
+ } else res(e);
1314
+ };
1315
+ link.addEventListener("load", handleSettle);
1316
+ link.addEventListener("error", handleSettle);
1317
+ });
1318
+ });
1319
+ }).filter((p) => p !== void 0));
1320
+ }
1321
+ function handlePreloadError(err) {
1322
+ const e = new Event("vite:preloadError", { cancelable: true });
1323
+ e.payload = err;
1324
+ window.dispatchEvent(e);
1325
+ if (!e.defaultPrevented) throw err;
1326
+ }
1327
+ return promise.then((res) => {
1328
+ for (const item of res || []) {
1329
+ if (item.status !== "rejected") continue;
1330
+ handlePreloadError(item.reason);
1331
+ }
1332
+ return baseModule().catch(handlePreloadError);
1333
+ });
1334
+ };
1335
+ // src/cli/commands/init.ts
1336
+ async function promptForTargets() {
1337
+ const { checkbox } = await __vitePreload(async () => {
1338
+ const { checkbox } = await import("@inquirer/prompts");
1339
+ return { checkbox };
1340
+ }, []);
1341
+ return await checkbox({
1342
+ message: "Select target platforms to sync to:",
1343
+ choices: TARGET_OPTIONS,
1344
+ required: true,
1345
+ validate: (choices) => {
1346
+ return choices.filter((c) => c.checked).map((c) => c.value).length > 0 || "Select at least one target";
1347
+ }
1348
+ });
1349
+ }
1350
+ async function initCommand(args) {
1351
+ if (args.verbose) logger.setLevel("debug");
1352
+ if (args.noColor) logger.setColor(false);
1353
+ try {
1354
+ logger.info(`Agentic Toolbox v${getPackageVersion()} - Initializing config`);
1355
+ const configPath = path.join(getParentProjectRoot(), DEFAULT_CONFIG_NAME);
1356
+ if (fs.existsSync(configPath) && !args.force) {
1357
+ logger.error(`Config file already exists at ${configPath}`);
1358
+ logger.info("Use --force to overwrite");
1359
+ return {
1360
+ success: false,
1361
+ exitCode: 1
1362
+ };
1363
+ }
1364
+ let targets = [];
1365
+ if (args.targets) targets = args.targets;
1366
+ else targets = await promptForTargets();
1367
+ const config = createDefaultConfig();
1368
+ config.targets = targets.length > 0 ? targets : ["agents"];
1369
+ const configContent = JSON.stringify(config, null, 2);
1370
+ fs.writeFileSync(configPath, configContent, "utf8");
1371
+ const relativePath = path.relative(process.cwd(), configPath);
1372
+ const displayPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
1373
+ logger.success(`Created ${DEFAULT_CONFIG_NAME}`);
1374
+ logger.info(`Config written to: ${displayPath}`);
1375
+ logger.info("Edit this file to customize sync options and paths.");
1376
+ return {
1377
+ success: true,
1378
+ exitCode: 0
1379
+ };
1380
+ } catch (error) {
1381
+ if (error instanceof Error && error.name === "ExitPromptError") {
1382
+ logger.info("Init cancelled");
1383
+ return {
1384
+ success: false,
1385
+ exitCode: 0
1386
+ };
1387
+ }
1388
+ logger.error(`Init failed: ${error instanceof Error ? error.message : String(error)}`);
1389
+ return {
1390
+ success: false,
1391
+ exitCode: 1,
1392
+ error
1393
+ };
1394
+ }
1395
+ }
1396
+ // src/cli/commands/doctor.ts
1397
+ /**
1398
+ * Read-only diagnostic that compares what a target directory currently contains
1399
+ * against the set of files the tool WOULD manage on the next sync. No writes,
1400
+ * no deletes. Foreign entries are flagged as at risk of being wiped.
1401
+ */
1402
+ async function doctorCommand(args) {
1403
+ if (args.verbose) logger.setLevel("debug");
1404
+ try {
1405
+ logger.info(`Agentic Toolbox v${getPackageVersion()} - Doctor (read-only)`);
1406
+ const config = loadConfig(args.configPath);
1407
+ const targets = args.targets ? validateTargets(args.targets) : config.resolvedTargets;
1408
+ const projectRoot = getParentProjectRoot();
1409
+ const toolkitDir = getToolkitDir();
1410
+ const managedAgents = collectManagedAgents(toolkitDir, projectRoot, config.paths?.agents);
1411
+ const managedSkills = collectManagedSkills(toolkitDir, projectRoot, config.paths?.skills);
1412
+ for (const targetName of targets) {
1413
+ const targetConfig = getTargetConfig(targetName);
1414
+ const targetDir = path.join(projectRoot, targetConfig.directory);
1415
+ logger.info(`\n--- Doctor for ${targetConfig.directory} ---`);
1416
+ if (!fs.existsSync(targetDir)) {
1417
+ logger.info(`${targetConfig.directory}: not present (nothing to back up)`);
1418
+ continue;
1419
+ }
1420
+ reportManagedDir("agents", path.join(targetDir, "agents"), managedAgents, targetConfig.directory);
1421
+ reportManagedDir("skills", path.join(targetDir, "skills"), managedSkills, targetConfig.directory);
1422
+ }
1423
+ logger.success("\nDoctor complete - no changes made");
1424
+ return {
1425
+ success: true,
1426
+ exitCode: 0
1427
+ };
1428
+ } catch (error) {
1429
+ logger.error(`Doctor failed: ${error instanceof Error ? error.message : String(error)}`);
1430
+ return {
1431
+ success: false,
1432
+ exitCode: 1,
1433
+ error
1434
+ };
1435
+ }
1436
+ }
1437
+ /**
1438
+ * Compare the on-disk entries of a managed sub-directory (agents or skills)
1439
+ * against the set of names the tool manages. Reports counts and warns on
1440
+ * foreign entries that would be at risk on the next sync wipe.
1441
+ */
1442
+ function reportManagedDir(label, managedDir, managedNames, targetDirLabel) {
1443
+ if (!fs.existsSync(managedDir)) {
1444
+ logger.info(`${targetDirLabel}/${label}: not present`);
1445
+ return;
1446
+ }
1447
+ const entries = fs.readdirSync(managedDir).filter((entry) => {
1448
+ if (label === "agents") return entry.endsWith(".md");
1449
+ return fs.statSync(path.join(managedDir, entry)).isDirectory();
1450
+ });
1451
+ const managedPresent = entries.filter((entry) => managedNames.has(entry));
1452
+ const foreign = entries.filter((entry) => !managedNames.has(entry));
1453
+ logger.info(`${targetDirLabel}/${label}: ${managedPresent.length} managed file(s)/dir(s) present, ${entries.length} total`);
1454
+ for (const entry of managedPresent) logger.debug(` = ${label}/${entry}`);
1455
+ for (const entry of foreign) logger.warn(` ! ${targetDirLabel}/${label}/${entry} (not managed by toolkit+project — at risk on next sync wipe)`);
1456
+ }
1457
+ /** Names (filenames) of `.md` agents the tool would manage. */
1458
+ function collectManagedAgents(toolkitDir, projectRoot, projectAgentsPath) {
1459
+ const names = /* @__PURE__ */ new Set();
1460
+ const dirs = [path.join(toolkitDir, "agents"), path.join(projectRoot, projectAgentsPath || "agents")];
1461
+ for (const dir of dirs) {
1462
+ if (!fs.existsSync(dir)) continue;
1463
+ for (const file of fs.readdirSync(dir)) if (file.endsWith(".md")) names.add(file);
1464
+ }
1465
+ return names;
1466
+ }
1467
+ /** Names (directory names) of skills the tool would manage. */
1468
+ function collectManagedSkills(toolkitDir, projectRoot, projectSkillsPath) {
1469
+ const names = /* @__PURE__ */ new Set();
1470
+ const dirs = [path.join(toolkitDir, "skills"), path.join(projectRoot, projectSkillsPath || "skills")];
1471
+ for (const dir of dirs) {
1472
+ if (!fs.existsSync(dir)) continue;
1473
+ for (const entry of fs.readdirSync(dir)) if (fs.statSync(path.join(dir, entry)).isDirectory()) names.add(entry);
1474
+ }
1475
+ return names;
1476
+ }
1477
+ // src/cli/args/subcommands.ts
1478
+ var subcommands = [
1479
+ {
1480
+ name: "sync",
1481
+ description: "Sync agents and skills to target directories",
1482
+ flags: [
1483
+ {
1484
+ name: "dryRun",
1485
+ alias: "d",
1486
+ description: "Preview changes without applying",
1487
+ type: "boolean"
1488
+ },
1489
+ {
1490
+ name: "verbose",
1491
+ alias: "v",
1492
+ description: "Enable verbose output",
1493
+ type: "boolean"
1494
+ },
1495
+ {
1496
+ name: "targets",
1497
+ alias: "t",
1498
+ description: "Comma-separated targets",
1499
+ type: "string[]"
1500
+ },
1501
+ {
1502
+ name: "config",
1503
+ alias: "c",
1504
+ description: "Custom config file",
1505
+ type: "string"
1506
+ },
1507
+ {
1508
+ name: "incremental",
1509
+ description: "Use incremental sync with manifest",
1510
+ type: "boolean"
1511
+ }
1512
+ ],
1513
+ handler: syncCommand
1514
+ },
1515
+ {
1516
+ name: "validate",
1517
+ description: "Validate config file and agent/skill definitions",
1518
+ flags: [{
1519
+ name: "config",
1520
+ alias: "c",
1521
+ description: "Custom config file",
1522
+ type: "string"
1523
+ }, {
1524
+ name: "verbose",
1525
+ alias: "v",
1526
+ description: "Enable verbose output",
1527
+ type: "boolean"
1528
+ }],
1529
+ handler: validateCommand
1530
+ },
1531
+ {
1532
+ name: "diff",
1533
+ description: "Show unified diff of what would change",
1534
+ flags: [{
1535
+ name: "config",
1536
+ alias: "c",
1537
+ description: "Custom config file",
1538
+ type: "string"
1539
+ }, {
1540
+ name: "targets",
1541
+ alias: "t",
1542
+ description: "Comma-separated targets",
1543
+ type: "string[]"
1544
+ }],
1545
+ handler: diffCommand
1546
+ },
1547
+ {
1548
+ name: "init",
1549
+ description: "Create a new agentic-toolbox.json config file",
1550
+ flags: [{
1551
+ name: "force",
1552
+ alias: "f",
1553
+ description: "Overwrite existing config",
1554
+ type: "boolean"
1555
+ }],
1556
+ handler: initCommand
1557
+ },
1558
+ {
1559
+ name: "doctor",
1560
+ description: "Report target directory contents vs tool-managed files (read-only)",
1561
+ flags: [{
1562
+ name: "config",
1563
+ alias: "c",
1564
+ description: "Custom config file",
1565
+ type: "string"
1566
+ }, {
1567
+ name: "verbose",
1568
+ alias: "v",
1569
+ description: "Enable verbose output",
1570
+ type: "boolean"
1571
+ }],
1572
+ handler: doctorCommand
1573
+ }
1574
+ ];
1575
+ var FLAG_STRATEGIES = {
1576
+ boolean: { parse(_flagDef, _rawFlag, _argv, currentIndex) {
1577
+ return {
1578
+ value: true,
1579
+ nextIndex: currentIndex
1580
+ };
1581
+ } },
1582
+ string: { parse(_flagDef, rawFlag, argv, currentIndex) {
1583
+ const nextIndex = currentIndex + 1;
1584
+ if (nextIndex >= argv.length) throw new CliError({
1585
+ code: CliErrorCode.CLI_INVALID_ARGS,
1586
+ message: MESSAGES.flagRequiresValue(rawFlag)
1587
+ });
1588
+ return {
1589
+ value: argv[nextIndex],
1590
+ nextIndex
1591
+ };
1592
+ } },
1593
+ "string[]": { parse(_flagDef, rawFlag, argv, currentIndex, currentValue) {
1594
+ const nextIndex = currentIndex + 1;
1595
+ if (nextIndex >= argv.length) throw new CliError({
1596
+ code: CliErrorCode.CLI_INVALID_ARGS,
1597
+ message: MESSAGES.flagRequiresValue(rawFlag)
1598
+ });
1599
+ const values = argv[nextIndex].split(",").map((v) => v.trim());
1600
+ const existing = Array.isArray(currentValue) ? currentValue : [];
1601
+ return {
1602
+ value: existing.length > 0 ? [...existing, ...values] : values,
1603
+ nextIndex
1604
+ };
1605
+ } }
1606
+ };
1607
+ function getFlagStrategy(type) {
1608
+ const strategy = FLAG_STRATEGIES[type];
1609
+ if (!strategy) throw new CliError({
1610
+ code: CliErrorCode.CLI_INVALID_ARGS,
1611
+ message: MESSAGES.unsupportedFlagType(type)
1612
+ });
1613
+ return strategy;
1614
+ }
1615
+ // src/cli/args/parser.ts
1616
+ function kebabToCamel(str) {
1617
+ return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
1618
+ }
1619
+ function findFlagDef(allFlags, flagName) {
1620
+ const camelFlagName = kebabToCamel(flagName);
1621
+ return allFlags.find((f) => f.name === camelFlagName || f.alias === flagName);
1622
+ }
1623
+ function parseFlags(argv, startIndex, allFlags) {
1624
+ const args = {};
1625
+ let i = startIndex;
1626
+ while (i < argv.length) {
1627
+ const arg = argv[i];
1628
+ if (arg.startsWith("--")) {
1629
+ const flagName = arg.slice(2);
1630
+ const flagDef = findFlagDef(allFlags, flagName);
1631
+ if (!flagDef) throw new CliError({
1632
+ code: CliErrorCode.CLI_INVALID_ARGS,
1633
+ message: MESSAGES.unknownFlag(`--${flagName}`)
1634
+ });
1635
+ const targetName = flagDef.name === "config" ? "configPath" : flagDef.name;
1636
+ const result = getFlagStrategy(flagDef.type).parse(flagDef, `--${flagName}`, argv, i, args[targetName]);
1637
+ args[targetName] = result.value;
1638
+ i = result.nextIndex;
1639
+ } else if (arg.startsWith("-") && arg.length === 2) {
1640
+ const shortFlag = arg[1];
1641
+ const flagDef = allFlags.find((f) => f.alias === shortFlag);
1642
+ if (!flagDef) throw new CliError({
1643
+ code: CliErrorCode.CLI_INVALID_ARGS,
1644
+ message: MESSAGES.unknownFlag(`-${shortFlag}`)
1645
+ });
1646
+ const targetName = flagDef.name === "config" ? "configPath" : flagDef.name;
1647
+ const result = getFlagStrategy(flagDef.type).parse(flagDef, `-${shortFlag}`, argv, i, args[targetName]);
1648
+ args[targetName] = result.value;
1649
+ i = result.nextIndex;
1650
+ } else if (!args.command) args.command = arg;
1651
+ i++;
1652
+ }
1653
+ return {
1654
+ args,
1655
+ nextIndex: i
1656
+ };
1657
+ }
1658
+ function parseArgs(argv) {
1659
+ let command;
1660
+ let firstNonFlagIndex = -1;
1661
+ for (let i = 0; i < argv.length; i++) {
1662
+ const arg = argv[i];
1663
+ if (!arg.startsWith("-")) {
1664
+ command = arg;
1665
+ firstNonFlagIndex = i;
1666
+ break;
1667
+ }
1668
+ }
1669
+ const subcommand = command ? subcommands.find((c) => c.name === command) : void 0;
1670
+ const allFlags = subcommand ? [...flags, ...subcommand.flags] : flags;
1671
+ const { args: beforeArgs } = parseFlags(argv, 0, allFlags);
1672
+ const { args: afterArgs } = parseFlags(argv, firstNonFlagIndex + 1, allFlags);
1673
+ return {
1674
+ ...beforeArgs,
1675
+ ...afterArgs,
1676
+ command: beforeArgs.command || afterArgs.command || command
1677
+ };
1678
+ }
1679
+ // src/cli/help/templates.ts
1680
+ function renderFlagLine(flag) {
1681
+ const alias = flag.alias ? `, -${flag.alias}` : "";
1682
+ return ` --${flag.name}${alias.padEnd(20)} ${flag.description}\n`;
1683
+ }
1684
+ function generateGlobalHelp() {
1685
+ let help = `
1686
+ Agentic Toolbox - Cross-platform AI agent & skill sync engine
1687
+
1688
+ Usage:
1689
+ agentic-toolbox [options] [command] [command-options]
1690
+
1691
+ Global Options:
1692
+ `;
1693
+ for (const flag of flags) help += renderFlagLine(flag);
1694
+ help += `\nCommands:\n`;
1695
+ for (const cmd of subcommands) help += ` ${cmd.name.padEnd(12)} ${cmd.description}\n`;
1696
+ help += `
1697
+ Examples:
1698
+ agentic-toolbox # No command: show help + available commands
1699
+ agentic-toolbox sync # Sync to all configured targets
1700
+ agentic-toolbox sync --dry-run --verbose
1701
+ agentic-toolbox validate # Validate config and definitions
1702
+ agentic-toolbox diff # Show what would change
1703
+ agentic-toolbox init # Create default config file
1704
+ agentic-toolbox --help # Show this help
1705
+ agentic-toolbox --version # Show version
1706
+
1707
+ Configuration (agentic-toolbox.json):
1708
+ {
1709
+ "targets": ["opencode", "claude", "agents"],
1710
+ "sync": { "incremental": false, "backup": true },
1711
+ "transform": { "preserveComments": false },
1712
+ "paths": { "agents": "agents", "skills": "skills" }
1713
+ }
1714
+
1715
+ Targets:
1716
+ opencode - Sync to .opencode/ directory
1717
+ claude - Sync to .claude/ directory
1718
+ agents - Sync to .agents/ directory
1719
+
1720
+ Auto-discovery (when config file is missing):
1721
+ opencode.json -> targets .opencode/
1722
+ claude.json -> targets .claude/
1723
+ .clauderc -> targets .claude/
1724
+ (default) -> targets .agents/
1725
+ `;
1726
+ return help;
1727
+ }
1728
+ function generateCommandHelp(commandName) {
1729
+ const cmd = subcommands.find((c) => c.name === commandName);
1730
+ if (!cmd) return `Unknown command: ${commandName}`;
1731
+ let help = `
1732
+ agentic-toolbox ${cmd.name} - ${cmd.description}
1733
+
1734
+ Usage:
1735
+ agentic-toolbox ${cmd.name} [options]
1736
+
1737
+ Options:
1738
+ `;
1739
+ for (const flag of cmd.flags) help += renderFlagLine(flag);
1740
+ const commandFlagNames = new Set(cmd.flags.map((f) => f.name));
1741
+ const globalFlagsToShow = [
1742
+ "config",
1743
+ "verbose",
1744
+ "help"
1745
+ ].filter((name) => !commandFlagNames.has(name));
1746
+ for (const flagName of globalFlagsToShow) {
1747
+ const flag = flags.find((f) => f.name === flagName);
1748
+ if (flag) help += renderFlagLine(flag);
1749
+ }
1750
+ return help;
1751
+ }
1752
+ // src/cli/help/print-help.ts
1753
+ function printHelp(commandName) {
1754
+ if (commandName && subcommands.some((c) => c.name === commandName)) logger.raw(generateCommandHelp(commandName));
1755
+ else logger.raw(generateGlobalHelp());
1756
+ }
1757
+ // src/cli/run-cli.ts
1758
+ async function runCli(argv) {
1759
+ logger.setRunId?.(generateRunId());
1760
+ if (argv.includes("--version") || argv.includes("-V")) {
1761
+ logger.raw(getPackageVersion());
1762
+ return {
1763
+ success: true,
1764
+ exitCode: 0
1765
+ };
1766
+ }
1767
+ try {
1768
+ const args = parseArgs(argv);
1769
+ if (args.json) logger.setJson?.(true);
1770
+ if (args.help) {
1771
+ if (args.command && subcommands.some((c) => c.name === args.command)) printHelp(args.command);
1772
+ else printHelp();
1773
+ return {
1774
+ success: true,
1775
+ exitCode: 0
1776
+ };
1777
+ }
1778
+ if (!args.command) {
1779
+ logger.error("No command provided.");
1780
+ logger.info("Available commands:");
1781
+ for (const c of subcommands) logger.info(` ${c.name.padEnd(10)} ${c.description}`);
1782
+ logger.info("");
1783
+ printHelp();
1784
+ return {
1785
+ success: false,
1786
+ exitCode: 1
1787
+ };
1788
+ }
1789
+ if (!subcommands.some((c) => c.name === args.command)) {
1790
+ logger.error(`Unknown command: ${args.command}`);
1791
+ printHelp();
1792
+ return {
1793
+ success: false,
1794
+ exitCode: 1
1795
+ };
1796
+ }
1797
+ return subcommands.find((c) => c.name === args.command).handler(args);
1798
+ } catch (error) {
1799
+ const message = error instanceof Error ? error.message : String(error);
1800
+ logger.error(`Error: ${message}`);
1801
+ return {
1802
+ success: false,
1803
+ exitCode: 1,
1804
+ error
1805
+ };
1806
+ }
1807
+ }
1808
+ // src/index.ts
1809
+ async function main() {
1810
+ const result = await runCli(process.argv.slice(2));
1811
+ process.exit(result.exitCode);
1812
+ }
1813
+ main();
1814
+
1815
+ //# sourceMappingURL=index.js.map