@aigne/afs-cli 1.11.0-beta.6 → 1.11.0-beta.8

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 (346) hide show
  1. package/dist/_virtual/rolldown_runtime.mjs +7 -0
  2. package/dist/cli.cjs +27 -353
  3. package/dist/cli.d.cts +2 -1
  4. package/dist/cli.d.mts +2 -1
  5. package/dist/cli.mjs +28 -353
  6. package/dist/cli.mjs.map +1 -1
  7. package/dist/config/afs-loader.cjs +567 -0
  8. package/dist/config/afs-loader.d.cts +19 -0
  9. package/dist/config/afs-loader.d.cts.map +1 -0
  10. package/dist/config/afs-loader.d.mts +19 -0
  11. package/dist/config/afs-loader.d.mts.map +1 -0
  12. package/dist/config/afs-loader.mjs +565 -0
  13. package/dist/config/afs-loader.mjs.map +1 -0
  14. package/dist/config/loader.cjs +28 -11
  15. package/dist/config/loader.mjs +28 -11
  16. package/dist/config/loader.mjs.map +1 -1
  17. package/dist/config/mount-commands.cjs +208 -0
  18. package/dist/config/mount-commands.d.cts +14 -0
  19. package/dist/config/mount-commands.d.cts.map +1 -0
  20. package/dist/config/mount-commands.d.mts +14 -0
  21. package/dist/config/mount-commands.d.mts.map +1 -0
  22. package/dist/config/mount-commands.mjs +203 -0
  23. package/dist/config/mount-commands.mjs.map +1 -0
  24. package/dist/config/schema.cjs +10 -2
  25. package/dist/config/schema.mjs +10 -2
  26. package/dist/config/schema.mjs.map +1 -1
  27. package/dist/core/commands/delete.cjs +41 -0
  28. package/dist/core/commands/delete.d.cts +18 -0
  29. package/dist/core/commands/delete.d.cts.map +1 -0
  30. package/dist/core/commands/delete.d.mts +18 -0
  31. package/dist/core/commands/delete.d.mts.map +1 -0
  32. package/dist/core/commands/delete.mjs +42 -0
  33. package/dist/core/commands/delete.mjs.map +1 -0
  34. package/dist/core/commands/exec.cjs +98 -0
  35. package/dist/core/commands/exec.d.cts +26 -0
  36. package/dist/core/commands/exec.d.cts.map +1 -0
  37. package/dist/core/commands/exec.d.mts +26 -0
  38. package/dist/core/commands/exec.d.mts.map +1 -0
  39. package/dist/core/commands/exec.mjs +99 -0
  40. package/dist/core/commands/exec.mjs.map +1 -0
  41. package/dist/core/commands/explain.cjs +254 -0
  42. package/dist/core/commands/explain.d.cts +25 -0
  43. package/dist/core/commands/explain.d.cts.map +1 -0
  44. package/dist/core/commands/explain.d.mts +25 -0
  45. package/dist/core/commands/explain.d.mts.map +1 -0
  46. package/dist/core/commands/explain.mjs +255 -0
  47. package/dist/core/commands/explain.mjs.map +1 -0
  48. package/dist/core/commands/explore.cjs +30 -0
  49. package/dist/core/commands/explore.d.mts +2 -0
  50. package/dist/core/commands/explore.mjs +31 -0
  51. package/dist/core/commands/explore.mjs.map +1 -0
  52. package/dist/core/commands/index.cjs +36 -0
  53. package/dist/core/commands/index.d.cts +21 -0
  54. package/dist/core/commands/index.d.cts.map +1 -0
  55. package/dist/core/commands/index.d.mts +24 -0
  56. package/dist/core/commands/index.d.mts.map +1 -0
  57. package/dist/core/commands/index.mjs +37 -0
  58. package/dist/core/commands/index.mjs.map +1 -0
  59. package/dist/core/commands/ls.cjs +57 -0
  60. package/dist/core/commands/ls.d.cts +21 -0
  61. package/dist/core/commands/ls.d.cts.map +1 -0
  62. package/dist/core/commands/ls.d.mts +21 -0
  63. package/dist/core/commands/ls.d.mts.map +1 -0
  64. package/dist/core/commands/ls.mjs +58 -0
  65. package/dist/core/commands/ls.mjs.map +1 -0
  66. package/dist/core/commands/mount.cjs +222 -0
  67. package/dist/core/commands/mount.d.cts +35 -0
  68. package/dist/core/commands/mount.d.cts.map +1 -0
  69. package/dist/core/commands/mount.d.mts +35 -0
  70. package/dist/core/commands/mount.d.mts.map +1 -0
  71. package/dist/core/commands/mount.mjs +223 -0
  72. package/dist/core/commands/mount.mjs.map +1 -0
  73. package/dist/core/commands/read.cjs +48 -0
  74. package/dist/core/commands/read.d.cts +17 -0
  75. package/dist/core/commands/read.d.cts.map +1 -0
  76. package/dist/core/commands/read.d.mts +17 -0
  77. package/dist/core/commands/read.d.mts.map +1 -0
  78. package/dist/core/commands/read.mjs +49 -0
  79. package/dist/core/commands/read.mjs.map +1 -0
  80. package/dist/core/commands/search.cjs +40 -0
  81. package/dist/core/commands/search.d.mts +2 -0
  82. package/dist/core/commands/search.mjs +41 -0
  83. package/dist/core/commands/search.mjs.map +1 -0
  84. package/dist/core/commands/serve.cjs +267 -0
  85. package/dist/core/commands/serve.d.mts +2 -0
  86. package/dist/core/commands/serve.mjs +267 -0
  87. package/dist/core/commands/serve.mjs.map +1 -0
  88. package/dist/core/commands/stat.cjs +53 -0
  89. package/dist/core/commands/stat.d.cts +17 -0
  90. package/dist/core/commands/stat.d.cts.map +1 -0
  91. package/dist/core/commands/stat.d.mts +17 -0
  92. package/dist/core/commands/stat.d.mts.map +1 -0
  93. package/dist/core/commands/stat.mjs +54 -0
  94. package/dist/core/commands/stat.mjs.map +1 -0
  95. package/dist/core/commands/types.cjs +18 -0
  96. package/dist/core/commands/types.d.cts +54 -0
  97. package/dist/core/commands/types.d.cts.map +1 -0
  98. package/dist/core/commands/types.d.mts +54 -0
  99. package/dist/core/commands/types.d.mts.map +1 -0
  100. package/dist/core/commands/types.mjs +19 -0
  101. package/dist/core/commands/types.mjs.map +1 -0
  102. package/dist/core/commands/write.cjs +70 -0
  103. package/dist/core/commands/write.d.cts +20 -0
  104. package/dist/core/commands/write.d.cts.map +1 -0
  105. package/dist/core/commands/write.d.mts +20 -0
  106. package/dist/core/commands/write.d.mts.map +1 -0
  107. package/dist/core/commands/write.mjs +71 -0
  108. package/dist/core/commands/write.mjs.map +1 -0
  109. package/dist/core/executor/index.cjs +196 -0
  110. package/dist/core/executor/index.d.cts +77 -0
  111. package/dist/core/executor/index.d.cts.map +1 -0
  112. package/dist/core/executor/index.d.mts +77 -0
  113. package/dist/core/executor/index.d.mts.map +1 -0
  114. package/dist/core/executor/index.mjs +195 -0
  115. package/dist/core/executor/index.mjs.map +1 -0
  116. package/dist/core/formatters/delete.cjs +37 -0
  117. package/dist/core/formatters/delete.d.cts +18 -0
  118. package/dist/core/formatters/delete.d.cts.map +1 -0
  119. package/dist/core/formatters/delete.d.mts +18 -0
  120. package/dist/core/formatters/delete.d.mts.map +1 -0
  121. package/dist/core/formatters/delete.mjs +37 -0
  122. package/dist/core/formatters/delete.mjs.map +1 -0
  123. package/dist/core/formatters/exec.cjs +60 -0
  124. package/dist/core/formatters/exec.d.cts +18 -0
  125. package/dist/core/formatters/exec.d.cts.map +1 -0
  126. package/dist/core/formatters/exec.d.mts +18 -0
  127. package/dist/core/formatters/exec.d.mts.map +1 -0
  128. package/dist/core/formatters/exec.mjs +60 -0
  129. package/dist/core/formatters/exec.mjs.map +1 -0
  130. package/dist/core/formatters/explain.cjs +97 -0
  131. package/dist/core/formatters/explain.d.cts +11 -0
  132. package/dist/core/formatters/explain.d.cts.map +1 -0
  133. package/dist/core/formatters/explain.d.mts +11 -0
  134. package/dist/core/formatters/explain.d.mts.map +1 -0
  135. package/dist/core/formatters/explain.mjs +96 -0
  136. package/dist/core/formatters/explain.mjs.map +1 -0
  137. package/dist/core/formatters/index.d.mts +9 -0
  138. package/dist/core/formatters/ls.cjs +179 -0
  139. package/dist/core/formatters/ls.d.cts +20 -0
  140. package/dist/core/formatters/ls.d.cts.map +1 -0
  141. package/dist/core/formatters/ls.d.mts +20 -0
  142. package/dist/core/formatters/ls.d.mts.map +1 -0
  143. package/dist/core/formatters/ls.mjs +179 -0
  144. package/dist/core/formatters/ls.mjs.map +1 -0
  145. package/dist/core/formatters/mount.cjs +55 -0
  146. package/dist/core/formatters/mount.d.cts +15 -0
  147. package/dist/core/formatters/mount.d.cts.map +1 -0
  148. package/dist/core/formatters/mount.d.mts +15 -0
  149. package/dist/core/formatters/mount.d.mts.map +1 -0
  150. package/dist/core/formatters/mount.mjs +55 -0
  151. package/dist/core/formatters/mount.mjs.map +1 -0
  152. package/dist/core/formatters/read.cjs +100 -0
  153. package/dist/core/formatters/read.d.cts +22 -0
  154. package/dist/core/formatters/read.d.cts.map +1 -0
  155. package/dist/core/formatters/read.d.mts +22 -0
  156. package/dist/core/formatters/read.d.mts.map +1 -0
  157. package/dist/core/formatters/read.mjs +100 -0
  158. package/dist/core/formatters/read.mjs.map +1 -0
  159. package/dist/core/formatters/search.cjs +44 -0
  160. package/dist/core/formatters/search.d.mts +1 -0
  161. package/dist/core/formatters/search.mjs +44 -0
  162. package/dist/core/formatters/search.mjs.map +1 -0
  163. package/dist/core/formatters/stat.cjs +155 -0
  164. package/dist/core/formatters/stat.d.cts +15 -0
  165. package/dist/core/formatters/stat.d.cts.map +1 -0
  166. package/dist/core/formatters/stat.d.mts +15 -0
  167. package/dist/core/formatters/stat.d.mts.map +1 -0
  168. package/dist/core/formatters/stat.mjs +155 -0
  169. package/dist/core/formatters/stat.mjs.map +1 -0
  170. package/dist/core/formatters/write.cjs +51 -0
  171. package/dist/core/formatters/write.d.cts +22 -0
  172. package/dist/core/formatters/write.d.cts.map +1 -0
  173. package/dist/core/formatters/write.d.mts +22 -0
  174. package/dist/core/formatters/write.d.mts.map +1 -0
  175. package/dist/core/formatters/write.mjs +51 -0
  176. package/dist/core/formatters/write.mjs.map +1 -0
  177. package/dist/core/helpers/exec-args.cjs +142 -0
  178. package/dist/core/helpers/exec-args.d.cts +46 -0
  179. package/dist/core/helpers/exec-args.d.cts.map +1 -0
  180. package/dist/core/helpers/exec-args.d.mts +46 -0
  181. package/dist/core/helpers/exec-args.d.mts.map +1 -0
  182. package/dist/core/helpers/exec-args.mjs +139 -0
  183. package/dist/core/helpers/exec-args.mjs.map +1 -0
  184. package/dist/core/helpers/stdin.cjs +41 -0
  185. package/dist/core/helpers/stdin.d.cts +15 -0
  186. package/dist/core/helpers/stdin.d.cts.map +1 -0
  187. package/dist/core/helpers/stdin.d.mts +15 -0
  188. package/dist/core/helpers/stdin.d.mts.map +1 -0
  189. package/dist/core/helpers/stdin.mjs +41 -0
  190. package/dist/core/helpers/stdin.mjs.map +1 -0
  191. package/dist/core/index.cjs +49 -0
  192. package/dist/core/index.d.cts +24 -0
  193. package/dist/core/index.d.mts +25 -0
  194. package/dist/core/index.mjs +24 -0
  195. package/dist/core/path-utils.cjs +1 -0
  196. package/dist/core/path-utils.mjs +3 -0
  197. package/dist/core/types.d.cts +24 -0
  198. package/dist/core/types.d.cts.map +1 -0
  199. package/dist/core/types.d.mts +24 -0
  200. package/dist/core/types.d.mts.map +1 -0
  201. package/dist/credential/auth-server.cjs +247 -0
  202. package/dist/credential/auth-server.mjs +247 -0
  203. package/dist/credential/auth-server.mjs.map +1 -0
  204. package/dist/credential/cli-auth-context.cjs +86 -0
  205. package/dist/credential/cli-auth-context.d.mts +1 -0
  206. package/dist/credential/cli-auth-context.mjs +86 -0
  207. package/dist/credential/cli-auth-context.mjs.map +1 -0
  208. package/dist/credential/index.cjs +5 -0
  209. package/dist/credential/index.d.mts +4 -0
  210. package/dist/credential/index.mjs +7 -0
  211. package/dist/credential/mcp-auth-context.cjs +186 -0
  212. package/dist/credential/mcp-auth-context.d.mts +1 -0
  213. package/dist/credential/mcp-auth-context.mjs +186 -0
  214. package/dist/credential/mcp-auth-context.mjs.map +1 -0
  215. package/dist/credential/resolver.cjs +125 -0
  216. package/dist/credential/resolver.d.mts +1 -0
  217. package/dist/credential/resolver.mjs +125 -0
  218. package/dist/credential/resolver.mjs.map +1 -0
  219. package/dist/credential/store.cjs +106 -0
  220. package/dist/credential/store.d.cts +30 -0
  221. package/dist/credential/store.d.cts.map +1 -0
  222. package/dist/credential/store.d.mts +30 -0
  223. package/dist/credential/store.d.mts.map +1 -0
  224. package/dist/credential/store.mjs +106 -0
  225. package/dist/credential/store.mjs.map +1 -0
  226. package/dist/errors.cjs +0 -11
  227. package/dist/errors.mjs +1 -11
  228. package/dist/errors.mjs.map +1 -1
  229. package/dist/explorer/actions.cjs +67 -32
  230. package/dist/explorer/actions.mjs +66 -32
  231. package/dist/explorer/actions.mjs.map +1 -1
  232. package/dist/explorer/components/dialog.cjs +170 -46
  233. package/dist/explorer/components/dialog.mjs +170 -46
  234. package/dist/explorer/components/dialog.mjs.map +1 -1
  235. package/dist/explorer/components/metadata-panel.cjs +86 -3
  236. package/dist/explorer/components/metadata-panel.mjs +86 -3
  237. package/dist/explorer/components/metadata-panel.mjs.map +1 -1
  238. package/dist/explorer/screen.cjs +63 -27
  239. package/dist/explorer/screen.d.cts +23 -0
  240. package/dist/explorer/screen.d.cts.map +1 -0
  241. package/dist/explorer/screen.d.mts +23 -0
  242. package/dist/explorer/screen.d.mts.map +1 -0
  243. package/dist/explorer/screen.mjs +63 -27
  244. package/dist/explorer/screen.mjs.map +1 -1
  245. package/dist/explorer/theme.cjs +1 -1
  246. package/dist/explorer/theme.mjs +1 -1
  247. package/dist/explorer/theme.mjs.map +1 -1
  248. package/dist/index.cjs +10 -1
  249. package/dist/index.d.cts +5 -1
  250. package/dist/index.d.mts +6 -1
  251. package/dist/index.mjs +6 -1
  252. package/dist/mcp/http-transport.cjs +87 -0
  253. package/dist/mcp/http-transport.mjs +87 -0
  254. package/dist/mcp/http-transport.mjs.map +1 -0
  255. package/dist/mcp/prompts.cjs +48 -0
  256. package/dist/mcp/prompts.mjs +48 -0
  257. package/dist/mcp/prompts.mjs.map +1 -0
  258. package/dist/mcp/resources.cjs +25 -0
  259. package/dist/mcp/resources.mjs +25 -0
  260. package/dist/mcp/resources.mjs.map +1 -0
  261. package/dist/mcp/server.cjs +40 -0
  262. package/dist/mcp/server.mjs +39 -0
  263. package/dist/mcp/server.mjs.map +1 -0
  264. package/dist/mcp/tools.cjs +152 -0
  265. package/dist/mcp/tools.mjs +152 -0
  266. package/dist/mcp/tools.mjs.map +1 -0
  267. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/index.d.cts +10 -0
  268. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/index.d.cts.map +1 -0
  269. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/index.d.mts +10 -0
  270. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/index.d.mts.map +1 -0
  271. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/types.d.cts +46 -0
  272. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/types.d.cts.map +1 -0
  273. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/types.d.mts +46 -0
  274. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/types.d.mts.map +1 -0
  275. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/urlpattern.cjs +902 -0
  276. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/urlpattern.mjs +902 -0
  277. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/urlpattern.mjs.map +1 -0
  278. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/index.cjs +6 -0
  279. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/index.mjs +8 -0
  280. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/index.mjs.map +1 -0
  281. package/dist/path-utils.d.cts +50 -0
  282. package/dist/path-utils.d.cts.map +1 -0
  283. package/dist/path-utils.d.mts +50 -0
  284. package/dist/path-utils.d.mts.map +1 -0
  285. package/dist/repl.cjs +491 -0
  286. package/dist/repl.d.cts +15 -0
  287. package/dist/repl.d.cts.map +1 -0
  288. package/dist/repl.d.mts +16 -0
  289. package/dist/repl.d.mts.map +1 -0
  290. package/dist/repl.mjs +491 -0
  291. package/dist/repl.mjs.map +1 -0
  292. package/dist/serve.cjs +146 -0
  293. package/dist/serve.d.cts +41 -0
  294. package/dist/serve.d.cts.map +1 -0
  295. package/dist/serve.d.mts +41 -0
  296. package/dist/serve.d.mts.map +1 -0
  297. package/dist/serve.mjs +146 -0
  298. package/dist/serve.mjs.map +1 -0
  299. package/dist/ui/header.cjs +1 -40
  300. package/dist/ui/header.mjs +1 -39
  301. package/dist/ui/header.mjs.map +1 -1
  302. package/dist/ui/index.cjs +2 -9
  303. package/dist/ui/index.mjs +2 -7
  304. package/dist/ui/index.mjs.map +1 -1
  305. package/dist/ui/terminal.cjs +1 -10
  306. package/dist/ui/terminal.mjs +1 -8
  307. package/dist/ui/terminal.mjs.map +1 -1
  308. package/package.json +30 -17
  309. package/dist/commands/exec.cjs +0 -164
  310. package/dist/commands/exec.mjs +0 -160
  311. package/dist/commands/exec.mjs.map +0 -1
  312. package/dist/commands/explain.cjs +0 -244
  313. package/dist/commands/explain.mjs +0 -242
  314. package/dist/commands/explain.mjs.map +0 -1
  315. package/dist/commands/index.cjs +0 -8
  316. package/dist/commands/index.mjs +0 -10
  317. package/dist/commands/ls.cjs +0 -242
  318. package/dist/commands/ls.mjs +0 -242
  319. package/dist/commands/ls.mjs.map +0 -1
  320. package/dist/commands/mount.cjs +0 -194
  321. package/dist/commands/mount.mjs +0 -190
  322. package/dist/commands/mount.mjs.map +0 -1
  323. package/dist/commands/read.cjs +0 -264
  324. package/dist/commands/read.mjs +0 -263
  325. package/dist/commands/read.mjs.map +0 -1
  326. package/dist/commands/serve.cjs +0 -144
  327. package/dist/commands/serve.mjs +0 -143
  328. package/dist/commands/serve.mjs.map +0 -1
  329. package/dist/commands/stat.cjs +0 -195
  330. package/dist/commands/stat.mjs +0 -195
  331. package/dist/commands/stat.mjs.map +0 -1
  332. package/dist/commands/write.cjs +0 -85
  333. package/dist/commands/write.mjs +0 -85
  334. package/dist/commands/write.mjs.map +0 -1
  335. package/dist/config/provider-factory.cjs +0 -400
  336. package/dist/config/provider-factory.mjs +0 -401
  337. package/dist/config/provider-factory.mjs.map +0 -1
  338. package/dist/config/uri-parser.cjs +0 -285
  339. package/dist/config/uri-parser.mjs +0 -285
  340. package/dist/config/uri-parser.mjs.map +0 -1
  341. package/dist/runtime.cjs +0 -120
  342. package/dist/runtime.mjs +0 -120
  343. package/dist/runtime.mjs.map +0 -1
  344. package/dist/utils/meta.cjs +0 -51
  345. package/dist/utils/meta.mjs +0 -49
  346. package/dist/utils/meta.mjs.map +0 -1
@@ -0,0 +1,77 @@
1
+ import { AFS } from "@aigne/afs";
2
+
3
+ //#region src/core/executor/index.d.ts
4
+ /**
5
+ * Result from executing a command
6
+ */
7
+ interface ExecuteResult {
8
+ /** Whether the command executed successfully */
9
+ success: boolean;
10
+ /** The command that was executed (ls, read, write, etc.) */
11
+ command: string;
12
+ /** The raw result data from AFS */
13
+ result?: unknown;
14
+ /** Formatted output string */
15
+ formatted: string;
16
+ /** Error info if the command failed */
17
+ error?: {
18
+ /** Exit code (from ExitCode enum) */code?: number; /** Error message */
19
+ message: string;
20
+ };
21
+ }
22
+ /**
23
+ * Options for the executor
24
+ */
25
+ interface ExecutorOptions {
26
+ /** Whether the output is for a TTY (enables colors) */
27
+ tty?: boolean;
28
+ /** Current working directory (for explore command) */
29
+ cwd?: string;
30
+ /** Version of the AFS CLI */
31
+ version?: string;
32
+ }
33
+ /**
34
+ * AFS Command Executor
35
+ *
36
+ * Provides a unified interface for executing AFS commands using yargs.
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const executor = new AFSCommandExecutor(afs, { tty: false });
41
+ * const result = await executor.execute("afs ls /path --depth=2");
42
+ * console.log(result.formatted);
43
+ * ```
44
+ */
45
+ declare class AFSCommandExecutor {
46
+ private afs?;
47
+ private options;
48
+ constructor(afs?: AFS, options?: ExecutorOptions);
49
+ /**
50
+ * Execute an AFS command
51
+ *
52
+ * @param argv - Command string or array of arguments
53
+ * - String: "afs ls /path --depth=2" or "ls /path --depth=2"
54
+ * - Array: ["ls", "/path", "--depth=2"]
55
+ * @returns Execution result with formatted output
56
+ */
57
+ execute(argv: string | string[]): Promise<ExecuteResult>;
58
+ /**
59
+ * Normalize argv to an array of strings
60
+ */
61
+ private normalizeArgv;
62
+ /**
63
+ * Tokenize a command string, respecting quotes
64
+ */
65
+ private tokenize;
66
+ /**
67
+ * Extract output options from args
68
+ */
69
+ private extractOutputOptions;
70
+ /**
71
+ * Extract path from args (first non-option argument after command)
72
+ */
73
+ private extractPath;
74
+ }
75
+ //#endregion
76
+ export { AFSCommandExecutor, ExecuteResult, ExecutorOptions };
77
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/core/executor/index.ts"],"mappings":";;;;;;UAkBiB,aAAA;EAQf;EANA,OAAA;EAUE;EARF,OAAA;EAUS;EART,MAAA;EAee;EAbf,SAAA;;EAEA,KAAA;IAaA,qCAXE,IAAA,WAeF;IAbE,OAAA;EAAA;AAAA;;;;UAOa,eAAA;EAsCiC;EApChD,GAAA;EAoC+C;EAlC/C,GAAA;EAkBQ;EAhBR,OAAA;AAAA;;;;;;;;;;;;;cAeW,kBAAA;EAAA,QACH,GAAA;EAAA,QACA,OAAA;cAEI,GAAA,GAAM,GAAA,EAAK,OAAA,GAAU,eAAA;;;;;;;;;EAa3B,OAAA,CAAQ,IAAA,sBAA0B,OAAA,CAAQ,aAAA;;;;UA6IxC,aAAA;;;;UAoCA,QAAA;;;;UA2CA,oBAAA;;;;UA+BA,WAAA;AAAA"}
@@ -0,0 +1,77 @@
1
+ import { AFS } from "@aigne/afs";
2
+
3
+ //#region src/core/executor/index.d.ts
4
+ /**
5
+ * Result from executing a command
6
+ */
7
+ interface ExecuteResult {
8
+ /** Whether the command executed successfully */
9
+ success: boolean;
10
+ /** The command that was executed (ls, read, write, etc.) */
11
+ command: string;
12
+ /** The raw result data from AFS */
13
+ result?: unknown;
14
+ /** Formatted output string */
15
+ formatted: string;
16
+ /** Error info if the command failed */
17
+ error?: {
18
+ /** Exit code (from ExitCode enum) */code?: number; /** Error message */
19
+ message: string;
20
+ };
21
+ }
22
+ /**
23
+ * Options for the executor
24
+ */
25
+ interface ExecutorOptions {
26
+ /** Whether the output is for a TTY (enables colors) */
27
+ tty?: boolean;
28
+ /** Current working directory (for explore command) */
29
+ cwd?: string;
30
+ /** Version of the AFS CLI */
31
+ version?: string;
32
+ }
33
+ /**
34
+ * AFS Command Executor
35
+ *
36
+ * Provides a unified interface for executing AFS commands using yargs.
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const executor = new AFSCommandExecutor(afs, { tty: false });
41
+ * const result = await executor.execute("afs ls /path --depth=2");
42
+ * console.log(result.formatted);
43
+ * ```
44
+ */
45
+ declare class AFSCommandExecutor {
46
+ private afs?;
47
+ private options;
48
+ constructor(afs?: AFS, options?: ExecutorOptions);
49
+ /**
50
+ * Execute an AFS command
51
+ *
52
+ * @param argv - Command string or array of arguments
53
+ * - String: "afs ls /path --depth=2" or "ls /path --depth=2"
54
+ * - Array: ["ls", "/path", "--depth=2"]
55
+ * @returns Execution result with formatted output
56
+ */
57
+ execute(argv: string | string[]): Promise<ExecuteResult>;
58
+ /**
59
+ * Normalize argv to an array of strings
60
+ */
61
+ private normalizeArgv;
62
+ /**
63
+ * Tokenize a command string, respecting quotes
64
+ */
65
+ private tokenize;
66
+ /**
67
+ * Extract output options from args
68
+ */
69
+ private extractOutputOptions;
70
+ /**
71
+ * Extract path from args (first non-option argument after command)
72
+ */
73
+ private extractPath;
74
+ }
75
+ //#endregion
76
+ export { AFSCommandExecutor, ExecuteResult, ExecutorOptions };
77
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/core/executor/index.ts"],"mappings":";;;;;;UAkBiB,aAAA;EAQf;EANA,OAAA;EAUE;EARF,OAAA;EAUS;EART,MAAA;EAee;EAbf,SAAA;;EAEA,KAAA;IAaA,qCAXE,IAAA,WAeF;IAbE,OAAA;EAAA;AAAA;;;;UAOa,eAAA;EAsCiC;EApChD,GAAA;EAoC+C;EAlC/C,GAAA;EAkBQ;EAhBR,OAAA;AAAA;;;;;;;;;;;;;cAeW,kBAAA;EAAA,QACH,GAAA;EAAA,QACA,OAAA;cAEI,GAAA,GAAM,GAAA,EAAK,OAAA,GAAU,eAAA;;;;;;;;;EAa3B,OAAA,CAAQ,IAAA,sBAA0B,OAAA,CAAQ,aAAA;;;;UA6IxC,aAAA;;;;UAoCA,QAAA;;;;UA2CA,oBAAA;;;;UA+BA,WAAA;AAAA"}
@@ -0,0 +1,195 @@
1
+ import { commandFactories } from "../commands/index.mjs";
2
+ import yargs from "yargs";
3
+
4
+ //#region src/core/executor/index.ts
5
+ /**
6
+ * AFS Command Executor
7
+ *
8
+ * Provides a unified interface for executing AFS commands using yargs.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const executor = new AFSCommandExecutor(afs, { tty: false });
13
+ * const result = await executor.execute("afs ls /path --depth=2");
14
+ * console.log(result.formatted);
15
+ * ```
16
+ */
17
+ var AFSCommandExecutor = class {
18
+ afs;
19
+ options;
20
+ constructor(afs, options) {
21
+ this.afs = afs;
22
+ this.options = options ?? {};
23
+ }
24
+ /**
25
+ * Execute an AFS command
26
+ *
27
+ * @param argv - Command string or array of arguments
28
+ * - String: "afs ls /path --depth=2" or "ls /path --depth=2"
29
+ * - Array: ["ls", "/path", "--depth=2"]
30
+ * @returns Execution result with formatted output
31
+ */
32
+ async execute(argv) {
33
+ const normalizedArgs = this.normalizeArgv(argv);
34
+ let commandResult;
35
+ const outputOptions = this.extractOutputOptions(normalizedArgs);
36
+ const factoryOptions = {
37
+ afs: this.afs,
38
+ argv: normalizedArgs,
39
+ cwd: this.options.cwd,
40
+ onResult: (result) => {
41
+ commandResult = result;
42
+ }
43
+ };
44
+ let parser = yargs(normalizedArgs).scriptName("afs").usage("$0 <command> [options]").option("json", {
45
+ type: "boolean",
46
+ description: "Output in JSON format",
47
+ global: true
48
+ }).option("yaml", {
49
+ type: "boolean",
50
+ description: "Output in YAML format",
51
+ global: true
52
+ }).option("view", {
53
+ type: "string",
54
+ choices: [
55
+ "default",
56
+ "llm",
57
+ "human"
58
+ ],
59
+ default: "default",
60
+ description: "Output view format",
61
+ global: true
62
+ }).option("interactive", {
63
+ alias: "i",
64
+ type: "boolean",
65
+ description: "Start interactive REPL mode",
66
+ global: false
67
+ }).help(true).alias("h", "help").version(this.options.version || "unknown").alias("v", "version").demandCommand().showHelpOnFail(true).exitProcess(false);
68
+ for (const factory of commandFactories) parser = parser.command(factory(factoryOptions));
69
+ try {
70
+ let output;
71
+ let error;
72
+ const parsed = await parser.parseAsync(normalizedArgs, {}, (e, _, o) => {
73
+ if (e) error = e;
74
+ output = o;
75
+ });
76
+ if (error) return {
77
+ success: false,
78
+ command: normalizedArgs[0] || "unknown",
79
+ result: void 0,
80
+ formatted: output,
81
+ error: { message: error.message }
82
+ };
83
+ if (parsed.help) return {
84
+ success: true,
85
+ command: "help",
86
+ formatted: output
87
+ };
88
+ if (parsed.version) return {
89
+ success: true,
90
+ command: "version",
91
+ formatted: output
92
+ };
93
+ if (!commandResult) throw new Error("Command not found");
94
+ const view = outputOptions.json ? "json" : outputOptions.yaml ? "yaml" : outputOptions.view;
95
+ const formatted = commandResult.format(commandResult.result, view, { path: this.extractPath(normalizedArgs) });
96
+ if (commandResult.error) return {
97
+ success: false,
98
+ command: commandResult.command,
99
+ result: commandResult.result,
100
+ formatted,
101
+ error: commandResult.error
102
+ };
103
+ return {
104
+ success: true,
105
+ command: commandResult.command,
106
+ result: commandResult.result,
107
+ formatted
108
+ };
109
+ } catch (error) {
110
+ const errorMessage = error instanceof Error ? error.message : String(error);
111
+ return {
112
+ success: false,
113
+ command: normalizedArgs[0] || "unknown",
114
+ result: void 0,
115
+ formatted: `ERROR: ${errorMessage}`,
116
+ error: { message: errorMessage }
117
+ };
118
+ }
119
+ }
120
+ /**
121
+ * Normalize argv to an array of strings
122
+ */
123
+ normalizeArgv(argv) {
124
+ if (typeof argv === "string") return this.tokenize(argv);
125
+ const filtered = [];
126
+ let foundCommand = false;
127
+ for (const arg of argv) {
128
+ if (!foundCommand && (arg.includes("node") || arg.includes("bun") || arg.endsWith(".js") || arg.endsWith(".ts"))) continue;
129
+ if (!foundCommand && arg === "afs") continue;
130
+ filtered.push(arg);
131
+ if (!arg.startsWith("-")) foundCommand = true;
132
+ }
133
+ return filtered;
134
+ }
135
+ /**
136
+ * Tokenize a command string, respecting quotes
137
+ */
138
+ tokenize(input) {
139
+ const tokens = [];
140
+ let current = "";
141
+ let inQuote = false;
142
+ let quoteChar = "";
143
+ for (let i = 0; i < input.length; i++) {
144
+ const char = input[i];
145
+ if (inQuote) if (char === quoteChar) inQuote = false;
146
+ else current += char;
147
+ else if (char === "\"" || char === "'") {
148
+ inQuote = true;
149
+ quoteChar = char;
150
+ } else if (char === " " || char === " ") {
151
+ if (current) {
152
+ tokens.push(current);
153
+ current = "";
154
+ }
155
+ } else current += char;
156
+ }
157
+ if (current) tokens.push(current);
158
+ if (tokens[0] === "afs") tokens.shift();
159
+ return tokens;
160
+ }
161
+ /**
162
+ * Extract output options from args
163
+ */
164
+ extractOutputOptions(args) {
165
+ let json = false;
166
+ let yaml = false;
167
+ let view;
168
+ for (let i = 0; i < args.length; i++) {
169
+ const arg = args[i];
170
+ if (arg === "--json") json = true;
171
+ if (arg === "--yaml") yaml = true;
172
+ if (arg.startsWith("--view=")) view = arg.slice(7);
173
+ else if (arg === "--view" && args[i + 1] && !args[i + 1].startsWith("-")) view = args[i + 1];
174
+ }
175
+ if (!view) view = this.options.tty ? "human" : "default";
176
+ return {
177
+ json,
178
+ yaml,
179
+ view
180
+ };
181
+ }
182
+ /**
183
+ * Extract path from args (first non-option argument after command)
184
+ */
185
+ extractPath(args) {
186
+ for (let i = 1; i < args.length; i++) {
187
+ const arg = args[i];
188
+ if (!arg.startsWith("-")) return arg;
189
+ }
190
+ }
191
+ };
192
+
193
+ //#endregion
194
+ export { AFSCommandExecutor };
195
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/core/executor/index.ts"],"sourcesContent":["/**\n * AFS Command Executor\n *\n * Unified command execution interface using yargs and CommandFactory pattern.\n */\n\nimport type { AFS } from \"@aigne/afs\";\nimport yargs from \"yargs\";\nimport {\n type CommandFactoryOptions,\n type CommandOutput,\n commandFactories,\n} from \"../commands/index.js\";\nimport type { ViewType } from \"../types.js\";\n\n/**\n * Result from executing a command\n */\nexport interface ExecuteResult {\n /** Whether the command executed successfully */\n success: boolean;\n /** The command that was executed (ls, read, write, etc.) */\n command: string;\n /** The raw result data from AFS */\n result?: unknown;\n /** Formatted output string */\n formatted: string;\n /** Error info if the command failed */\n error?: {\n /** Exit code (from ExitCode enum) */\n code?: number;\n /** Error message */\n message: string;\n };\n}\n\n/**\n * Options for the executor\n */\nexport interface ExecutorOptions {\n /** Whether the output is for a TTY (enables colors) */\n tty?: boolean;\n /** Current working directory (for explore command) */\n cwd?: string;\n /** Version of the AFS CLI */\n version?: string;\n}\n\n/**\n * AFS Command Executor\n *\n * Provides a unified interface for executing AFS commands using yargs.\n *\n * @example\n * ```typescript\n * const executor = new AFSCommandExecutor(afs, { tty: false });\n * const result = await executor.execute(\"afs ls /path --depth=2\");\n * console.log(result.formatted);\n * ```\n */\nexport class AFSCommandExecutor {\n private afs?: AFS;\n private options: ExecutorOptions;\n\n constructor(afs?: AFS, options?: ExecutorOptions) {\n this.afs = afs;\n this.options = options ?? {};\n }\n\n /**\n * Execute an AFS command\n *\n * @param argv - Command string or array of arguments\n * - String: \"afs ls /path --depth=2\" or \"ls /path --depth=2\"\n * - Array: [\"ls\", \"/path\", \"--depth=2\"]\n * @returns Execution result with formatted output\n */\n async execute(argv: string | string[]): Promise<ExecuteResult> {\n const normalizedArgs = this.normalizeArgv(argv);\n\n // Capture command result\n let commandResult: CommandOutput | undefined;\n\n // Determine output format from args\n const outputOptions = this.extractOutputOptions(normalizedArgs);\n\n // Create factory options\n const factoryOptions: CommandFactoryOptions = {\n afs: this.afs,\n argv: normalizedArgs,\n cwd: this.options.cwd,\n onResult: (result) => {\n commandResult = result;\n },\n };\n\n // Build yargs parser with all commands\n let parser = yargs(normalizedArgs)\n .scriptName(\"afs\")\n .usage(\"$0 <command> [options]\")\n .option(\"json\", {\n type: \"boolean\",\n description: \"Output in JSON format\",\n global: true,\n })\n .option(\"yaml\", {\n type: \"boolean\",\n description: \"Output in YAML format\",\n global: true,\n })\n .option(\"view\", {\n type: \"string\",\n choices: [\"default\", \"llm\", \"human\"],\n default: \"default\",\n description: \"Output view format\",\n global: true,\n })\n .option(\"interactive\", {\n alias: \"i\",\n type: \"boolean\",\n description: \"Start interactive REPL mode\",\n global: false,\n })\n .help(true)\n .alias(\"h\", \"help\")\n .version(this.options.version || \"unknown\")\n .alias(\"v\", \"version\")\n .demandCommand()\n .showHelpOnFail(true)\n .exitProcess(false);\n\n // Register all commands from factories\n for (const factory of commandFactories) {\n parser = parser.command(factory(factoryOptions));\n }\n\n // Parse and execute\n try {\n let output: string | undefined;\n let error: Error | undefined;\n\n const parsed = await parser.parseAsync(normalizedArgs, {}, (e, _, o) => {\n if (e) error = e;\n output = o;\n });\n\n if (error) {\n return {\n success: false,\n command: normalizedArgs[0] || \"unknown\",\n result: undefined,\n formatted: output!,\n error: { message: error.message },\n };\n }\n\n if (parsed.help) {\n return {\n success: true,\n command: \"help\",\n formatted: output!,\n };\n }\n if (parsed.version) {\n return {\n success: true,\n command: \"version\",\n formatted: output!,\n };\n }\n\n if (!commandResult) {\n throw new Error(\"Command not found\");\n }\n\n // Always use the formatter - it handles json/llm/human views\n const view: ViewType = outputOptions.json\n ? \"json\"\n : outputOptions.yaml\n ? \"yaml\"\n : outputOptions.view;\n const formatted = commandResult.format(commandResult.result, view, {\n path: this.extractPath(normalizedArgs),\n });\n\n // Check if command indicated failure\n if (commandResult.error) {\n return {\n success: false,\n command: commandResult.command,\n result: commandResult.result,\n formatted,\n error: commandResult.error,\n };\n }\n\n return {\n success: true,\n command: commandResult.command,\n result: commandResult.result,\n formatted,\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n\n return {\n success: false,\n command: normalizedArgs[0] || \"unknown\",\n result: undefined,\n formatted: `ERROR: ${errorMessage}`,\n error: { message: errorMessage },\n };\n }\n }\n\n /**\n * Normalize argv to an array of strings\n */\n private normalizeArgv(argv: string | string[]): string[] {\n if (typeof argv === \"string\") {\n // Parse quoted strings properly\n return this.tokenize(argv);\n }\n\n // Filter array input\n const filtered: string[] = [];\n let foundCommand = false;\n\n for (const arg of argv) {\n // Skip node and script paths (for process.argv format)\n if (\n !foundCommand &&\n (arg.includes(\"node\") || arg.includes(\"bun\") || arg.endsWith(\".js\") || arg.endsWith(\".ts\"))\n ) {\n continue;\n }\n\n // Skip \"afs\" prefix\n if (!foundCommand && arg === \"afs\") {\n continue;\n }\n\n filtered.push(arg);\n if (!arg.startsWith(\"-\")) {\n foundCommand = true;\n }\n }\n\n return filtered;\n }\n\n /**\n * Tokenize a command string, respecting quotes\n */\n private tokenize(input: string): string[] {\n const tokens: string[] = [];\n let current = \"\";\n let inQuote = false;\n let quoteChar = \"\";\n\n for (let i = 0; i < input.length; i++) {\n const char = input[i]!;\n\n if (inQuote) {\n if (char === quoteChar) {\n inQuote = false;\n } else {\n current += char;\n }\n } else if (char === '\"' || char === \"'\") {\n inQuote = true;\n quoteChar = char;\n } else if (char === \" \" || char === \"\\t\") {\n if (current) {\n tokens.push(current);\n current = \"\";\n }\n } else {\n current += char;\n }\n }\n\n if (current) {\n tokens.push(current);\n }\n\n // Filter out \"afs\" prefix if present\n if (tokens[0] === \"afs\") {\n tokens.shift();\n }\n\n return tokens;\n }\n\n /**\n * Extract output options from args\n */\n private extractOutputOptions(args: string[]): {\n json: boolean;\n yaml: boolean;\n view: ViewType;\n } {\n let json = false;\n let yaml = false;\n let view: ViewType | undefined;\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i]!;\n if (arg === \"--json\") json = true;\n if (arg === \"--yaml\") yaml = true;\n if (arg.startsWith(\"--view=\")) {\n view = arg.slice(7) as ViewType;\n } else if (arg === \"--view\" && args[i + 1] && !args[i + 1]!.startsWith(\"-\")) {\n view = args[i + 1] as ViewType;\n }\n }\n\n // Default to human view in TTY, default otherwise\n if (!view) {\n view = this.options.tty ? \"human\" : \"default\";\n }\n\n return { json, yaml, view };\n }\n\n /**\n * Extract path from args (first non-option argument after command)\n */\n private extractPath(args: string[]): string | undefined {\n for (let i = 1; i < args.length; i++) {\n const arg = args[i]!;\n if (!arg.startsWith(\"-\")) {\n return arg;\n }\n }\n return undefined;\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1,37 @@
1
+
2
+ //#region src/core/formatters/delete.ts
3
+ /**
4
+ * Format delete output for different views
5
+ *
6
+ * @param result - AFS delete result (native type)
7
+ * @param view - View type (default, json, llm, human)
8
+ * @param options - Format options (path for display)
9
+ * @returns Formatted string (no ANSI colors)
10
+ */
11
+ function formatDeleteOutput(result, view, options) {
12
+ const path = options?.path;
13
+ switch (view) {
14
+ case "json": return JSON.stringify(result, null, 2);
15
+ case "llm": return formatLlm(result, path);
16
+ case "human": return formatHuman(result, path);
17
+ default: return formatDefault(result, path);
18
+ }
19
+ }
20
+ function formatDefault(result, path) {
21
+ if (path) return path;
22
+ return result.message || "Deleted";
23
+ }
24
+ function formatLlm(result, path) {
25
+ const lines = [];
26
+ lines.push(`DELETE ${path || "path"}`);
27
+ lines.push("STATUS SUCCESS");
28
+ if (result.message) lines.push(`MESSAGE ${result.message}`);
29
+ return lines.join("\n");
30
+ }
31
+ function formatHuman(result, path) {
32
+ if (path) return `Deleted: ${path}`;
33
+ return result.message || "Deleted successfully";
34
+ }
35
+
36
+ //#endregion
37
+ exports.formatDeleteOutput = formatDeleteOutput;
@@ -0,0 +1,18 @@
1
+ import { ViewType } from "../types.cjs";
2
+ import { AFSDeleteResult } from "@aigne/afs";
3
+
4
+ //#region src/core/formatters/delete.d.ts
5
+ /**
6
+ * Format delete output for different views
7
+ *
8
+ * @param result - AFS delete result (native type)
9
+ * @param view - View type (default, json, llm, human)
10
+ * @param options - Format options (path for display)
11
+ * @returns Formatted string (no ANSI colors)
12
+ */
13
+ declare function formatDeleteOutput(result: AFSDeleteResult, view: ViewType, options?: {
14
+ path?: string;
15
+ }): string;
16
+ //#endregion
17
+ export { formatDeleteOutput };
18
+ //# sourceMappingURL=delete.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.d.cts","names":[],"sources":["../../../src/core/formatters/delete.ts"],"mappings":";;;;;;;;;;;;iBAkBgB,kBAAA,CACd,MAAA,EAAQ,eAAA,EACR,IAAA,EAAM,QAAA,EACN,OAAA;EAAY,IAAA;AAAA"}
@@ -0,0 +1,18 @@
1
+ import { ViewType } from "../types.mjs";
2
+ import { AFSDeleteResult } from "@aigne/afs";
3
+
4
+ //#region src/core/formatters/delete.d.ts
5
+ /**
6
+ * Format delete output for different views
7
+ *
8
+ * @param result - AFS delete result (native type)
9
+ * @param view - View type (default, json, llm, human)
10
+ * @param options - Format options (path for display)
11
+ * @returns Formatted string (no ANSI colors)
12
+ */
13
+ declare function formatDeleteOutput(result: AFSDeleteResult, view: ViewType, options?: {
14
+ path?: string;
15
+ }): string;
16
+ //#endregion
17
+ export { formatDeleteOutput };
18
+ //# sourceMappingURL=delete.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.d.mts","names":[],"sources":["../../../src/core/formatters/delete.ts"],"mappings":";;;;;;;;;;;;iBAkBgB,kBAAA,CACd,MAAA,EAAQ,eAAA,EACR,IAAA,EAAM,QAAA,EACN,OAAA;EAAY,IAAA;AAAA"}
@@ -0,0 +1,37 @@
1
+ //#region src/core/formatters/delete.ts
2
+ /**
3
+ * Format delete output for different views
4
+ *
5
+ * @param result - AFS delete result (native type)
6
+ * @param view - View type (default, json, llm, human)
7
+ * @param options - Format options (path for display)
8
+ * @returns Formatted string (no ANSI colors)
9
+ */
10
+ function formatDeleteOutput(result, view, options) {
11
+ const path = options?.path;
12
+ switch (view) {
13
+ case "json": return JSON.stringify(result, null, 2);
14
+ case "llm": return formatLlm(result, path);
15
+ case "human": return formatHuman(result, path);
16
+ default: return formatDefault(result, path);
17
+ }
18
+ }
19
+ function formatDefault(result, path) {
20
+ if (path) return path;
21
+ return result.message || "Deleted";
22
+ }
23
+ function formatLlm(result, path) {
24
+ const lines = [];
25
+ lines.push(`DELETE ${path || "path"}`);
26
+ lines.push("STATUS SUCCESS");
27
+ if (result.message) lines.push(`MESSAGE ${result.message}`);
28
+ return lines.join("\n");
29
+ }
30
+ function formatHuman(result, path) {
31
+ if (path) return `Deleted: ${path}`;
32
+ return result.message || "Deleted successfully";
33
+ }
34
+
35
+ //#endregion
36
+ export { formatDeleteOutput };
37
+ //# sourceMappingURL=delete.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.mjs","names":[],"sources":["../../../src/core/formatters/delete.ts"],"sourcesContent":["/**\n * delete Formatter - Core Implementation\n *\n * Formats delete output without colors.\n * Accepts AFS native AFSDeleteResult directly.\n */\n\nimport type { AFSDeleteResult } from \"@aigne/afs\";\nimport type { ViewType } from \"../types.js\";\n\n/**\n * Format delete output for different views\n *\n * @param result - AFS delete result (native type)\n * @param view - View type (default, json, llm, human)\n * @param options - Format options (path for display)\n * @returns Formatted string (no ANSI colors)\n */\nexport function formatDeleteOutput(\n result: AFSDeleteResult,\n view: ViewType,\n options?: { path?: string },\n): string {\n const path = options?.path;\n switch (view) {\n case \"json\":\n return JSON.stringify(result, null, 2);\n case \"llm\":\n return formatLlm(result, path);\n case \"human\":\n return formatHuman(result, path);\n default:\n return formatDefault(result, path);\n }\n}\n\nfunction formatDefault(result: AFSDeleteResult, path?: string): string {\n if (path) {\n return path;\n }\n return result.message || \"Deleted\";\n}\n\nfunction formatLlm(result: AFSDeleteResult, path?: string): string {\n const lines: string[] = [];\n\n lines.push(`DELETE ${path || \"path\"}`);\n lines.push(\"STATUS SUCCESS\");\n\n if (result.message) {\n lines.push(`MESSAGE ${result.message}`);\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction formatHuman(result: AFSDeleteResult, path?: string): string {\n if (path) {\n return `Deleted: ${path}`;\n }\n return result.message || \"Deleted successfully\";\n}\n"],"mappings":";;;;;;;;;AAkBA,SAAgB,mBACd,QACA,MACA,SACQ;CACR,MAAM,OAAO,SAAS;AACtB,SAAQ,MAAR;EACE,KAAK,OACH,QAAO,KAAK,UAAU,QAAQ,MAAM,EAAE;EACxC,KAAK,MACH,QAAO,UAAU,QAAQ,KAAK;EAChC,KAAK,QACH,QAAO,YAAY,QAAQ,KAAK;EAClC,QACE,QAAO,cAAc,QAAQ,KAAK;;;AAIxC,SAAS,cAAc,QAAyB,MAAuB;AACrE,KAAI,KACF,QAAO;AAET,QAAO,OAAO,WAAW;;AAG3B,SAAS,UAAU,QAAyB,MAAuB;CACjE,MAAM,QAAkB,EAAE;AAE1B,OAAM,KAAK,UAAU,QAAQ,SAAS;AACtC,OAAM,KAAK,iBAAiB;AAE5B,KAAI,OAAO,QACT,OAAM,KAAK,WAAW,OAAO,UAAU;AAGzC,QAAO,MAAM,KAAK,KAAK;;AAGzB,SAAS,YAAY,QAAyB,MAAuB;AACnE,KAAI,KACF,QAAO,YAAY;AAErB,QAAO,OAAO,WAAW"}
@@ -0,0 +1,60 @@
1
+
2
+ //#region src/core/formatters/exec.ts
3
+ /**
4
+ * Format exec output for different views
5
+ *
6
+ * @param result - AFS exec result (native type)
7
+ * @param view - View type (default, json, llm, human)
8
+ * @param options - Format options (path for display)
9
+ * @returns Formatted string (no ANSI colors)
10
+ */
11
+ function formatExecOutput(result, view, options) {
12
+ const path = options?.path;
13
+ switch (view) {
14
+ case "json": return JSON.stringify(result, null, 2);
15
+ case "llm": return formatLlm(result, path);
16
+ case "human": return formatHuman(result, path);
17
+ default: return formatDefault(result, path);
18
+ }
19
+ }
20
+ function formatDefault(result, path) {
21
+ if (result.success) {
22
+ if (result.data) return JSON.stringify(result.data);
23
+ return path ? `OK ${path}` : "OK";
24
+ }
25
+ return `${result.error?.code || "ERROR"} ${path || ""} ${result.error?.message || ""}`.trim();
26
+ }
27
+ function formatLlm(result, path) {
28
+ const lines = [];
29
+ if (path) lines.push(`EXEC ${path}`);
30
+ lines.push(`STATUS ${result.success ? "SUCCESS" : "FAILED"}`);
31
+ if (result.data) lines.push(`DATA ${JSON.stringify(result.data)}`);
32
+ if (!result.success && result.error) {
33
+ if (result.error.code) lines.push(`ERROR ${result.error.code}`);
34
+ if (result.error.message) lines.push(`MESSAGE ${result.error.message}`);
35
+ if (result.error.details) lines.push(`DETAILS ${JSON.stringify(result.error.details)}`);
36
+ }
37
+ return lines.join("\n");
38
+ }
39
+ function formatHuman(result, path) {
40
+ if (result.success) {
41
+ const lines$1 = path ? [`Executed: ${path}`] : ["Executed successfully"];
42
+ if (result.data) {
43
+ lines$1.push("");
44
+ lines$1.push(JSON.stringify(result.data, null, 2));
45
+ }
46
+ return lines$1.join("\n");
47
+ }
48
+ const lines = path ? [`Failed: ${path}`] : ["Execution failed"];
49
+ lines.push("");
50
+ if (result.error?.code) lines.push(`Error: ${result.error.code}`);
51
+ if (result.error?.message) lines.push(`Message: ${result.error.message}`);
52
+ if (result.error?.details) {
53
+ lines.push("Details:");
54
+ for (const [key, value] of Object.entries(result.error.details)) lines.push(` ${key}: ${JSON.stringify(value)}`);
55
+ }
56
+ return lines.join("\n");
57
+ }
58
+
59
+ //#endregion
60
+ exports.formatExecOutput = formatExecOutput;
@@ -0,0 +1,18 @@
1
+ import { ViewType } from "../types.cjs";
2
+ import { AFSExecResult } from "@aigne/afs";
3
+
4
+ //#region src/core/formatters/exec.d.ts
5
+ /**
6
+ * Format exec output for different views
7
+ *
8
+ * @param result - AFS exec result (native type)
9
+ * @param view - View type (default, json, llm, human)
10
+ * @param options - Format options (path for display)
11
+ * @returns Formatted string (no ANSI colors)
12
+ */
13
+ declare function formatExecOutput(result: AFSExecResult, view: ViewType, options?: {
14
+ path?: string;
15
+ }): string;
16
+ //#endregion
17
+ export { formatExecOutput };
18
+ //# sourceMappingURL=exec.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec.d.cts","names":[],"sources":["../../../src/core/formatters/exec.ts"],"mappings":";;;;;;;;;;;;iBAkBgB,gBAAA,CACd,MAAA,EAAQ,aAAA,EACR,IAAA,EAAM,QAAA,EACN,OAAA;EAAY,IAAA;AAAA"}
@@ -0,0 +1,18 @@
1
+ import { ViewType } from "../types.mjs";
2
+ import { AFSExecResult } from "@aigne/afs";
3
+
4
+ //#region src/core/formatters/exec.d.ts
5
+ /**
6
+ * Format exec output for different views
7
+ *
8
+ * @param result - AFS exec result (native type)
9
+ * @param view - View type (default, json, llm, human)
10
+ * @param options - Format options (path for display)
11
+ * @returns Formatted string (no ANSI colors)
12
+ */
13
+ declare function formatExecOutput(result: AFSExecResult, view: ViewType, options?: {
14
+ path?: string;
15
+ }): string;
16
+ //#endregion
17
+ export { formatExecOutput };
18
+ //# sourceMappingURL=exec.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec.d.mts","names":[],"sources":["../../../src/core/formatters/exec.ts"],"mappings":";;;;;;;;;;;;iBAkBgB,gBAAA,CACd,MAAA,EAAQ,aAAA,EACR,IAAA,EAAM,QAAA,EACN,OAAA;EAAY,IAAA;AAAA"}