@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,179 @@
1
+ //#region src/core/formatters/ls.ts
2
+ /**
3
+ * Check if a path is an actions path
4
+ */
5
+ function isActionsPath(path) {
6
+ return path.endsWith("/.actions") || path.includes("/.actions/");
7
+ }
8
+ /**
9
+ * Format ls output for different views
10
+ *
11
+ * @param result - AFS list result (native type)
12
+ * @param view - View type (default, json, llm, human)
13
+ * @param options - Format options
14
+ * @returns Formatted string (no ANSI colors)
15
+ */
16
+ function formatLsOutput(result, view, options) {
17
+ const isActions = options?.path && isActionsPath(options.path);
18
+ switch (view) {
19
+ case "json": return isActions ? formatActionsJson(result, options.path) : formatJson(result);
20
+ case "llm": return isActions ? formatActionsLlm(result, options.path) : formatLlm(result);
21
+ case "human": return isActions ? formatActionsHuman(result, options.path) : formatHuman(result);
22
+ default: return isActions ? formatActionsDefault(result) : formatDefault(result);
23
+ }
24
+ }
25
+ /**
26
+ * Default format: Machine truth, one path per line
27
+ */
28
+ function formatDefault(result) {
29
+ if (result.data.length === 0 && result.message) return `# ${result.message}`;
30
+ const lines = result.data.map((entry) => entry.path);
31
+ if (result.total !== void 0 && result.total > result.data.length) lines.push(`# Results truncated (${result.data.length} of ${result.total} shown)`);
32
+ return lines.join("\n");
33
+ }
34
+ /**
35
+ * JSON format: Structured output with meta field preserved
36
+ */
37
+ function formatJson(result) {
38
+ const entries = result.data.map((entry) => {
39
+ const output = { path: entry.path };
40
+ if (entry.meta && Object.keys(entry.meta).length > 0) output.meta = entry.meta;
41
+ return output;
42
+ });
43
+ return JSON.stringify({
44
+ entries,
45
+ total: result.total ?? entries.length
46
+ }, null, 2);
47
+ }
48
+ /**
49
+ * LLM format: Token-efficient, semantic facts
50
+ */
51
+ function formatLlm(result) {
52
+ const lines = [];
53
+ if (result.data.length === 0 && result.message) {
54
+ lines.push(`ERROR ${result.message}`);
55
+ return lines.join("\n");
56
+ }
57
+ for (const entry of result.data) {
58
+ const parts = [`ENTRY ${entry.path}`];
59
+ if (entry.meta?.kind) parts.push(`KIND=${entry.meta.kind}`);
60
+ if (entry.meta?.size !== void 0) parts.push(`SIZE=${entry.meta.size}`);
61
+ if (entry.meta?.childrenCount !== void 0) parts.push(`CHILDREN=${entry.meta.childrenCount}`);
62
+ lines.push(parts.join(" "));
63
+ }
64
+ lines.push(`TOTAL ${result.data.length}`);
65
+ if (result.total !== void 0 && result.total > result.data.length) lines.push("TRUNCATED true");
66
+ return lines.join("\n");
67
+ }
68
+ /**
69
+ * Human format: Tree structure (without colors)
70
+ */
71
+ function formatHuman(result) {
72
+ if (result.data.length === 0 && result.message) return result.message;
73
+ const root = {
74
+ name: "",
75
+ children: /* @__PURE__ */ new Map()
76
+ };
77
+ for (const entry of result.data) {
78
+ const parts = entry.path.split("/").filter(Boolean);
79
+ let current = root;
80
+ for (let i = 0; i < parts.length; i++) {
81
+ const part = parts[i];
82
+ if (!current.children.has(part)) current.children.set(part, {
83
+ name: part,
84
+ children: /* @__PURE__ */ new Map()
85
+ });
86
+ current = current.children.get(part);
87
+ if (i === parts.length - 1) current.entry = entry;
88
+ }
89
+ }
90
+ const lines = [];
91
+ renderTree(root, "", lines);
92
+ if (result.total !== void 0 && result.total > result.data.length) {
93
+ lines.push("");
94
+ lines.push(`(Results truncated - ${result.data.length} of ${result.total} entries shown)`);
95
+ }
96
+ return lines.join("\n");
97
+ }
98
+ function renderTree(node, prefix, lines) {
99
+ const children = Array.from(node.children.values());
100
+ for (let i = 0; i < children.length; i++) {
101
+ const child = children[i];
102
+ const isLast = i === children.length - 1;
103
+ const connector = isLast ? "└── " : "├── ";
104
+ const icon = typeof child.entry?.meta?.childrenCount === "number" || child.children.size > 0 ? "📁" : "📄";
105
+ const sizeStr = child.entry?.meta?.size !== void 0 ? ` ${formatSize(child.entry.meta.size)}` : "";
106
+ const kindStr = child.entry?.meta?.kind ? ` (${child.entry.meta.kind})` : "";
107
+ lines.push(`${prefix}${connector}${icon} ${child.name}${kindStr}${sizeStr}`);
108
+ renderTree(child, prefix + (isLast ? " " : "│ "), lines);
109
+ }
110
+ }
111
+ function formatSize(bytes) {
112
+ if (bytes < 1024) return `${bytes}B`;
113
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)}KB`;
114
+ return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
115
+ }
116
+ function getActionName(entry) {
117
+ const parts = entry.path.split("/");
118
+ return parts[parts.length - 1] || entry.path;
119
+ }
120
+ function getActionDescription(entry) {
121
+ return entry.meta?.description;
122
+ }
123
+ function getNodePathFromActions(actionsPath) {
124
+ const idx = actionsPath.lastIndexOf("/.actions");
125
+ return idx > 0 ? actionsPath.substring(0, idx) : "/";
126
+ }
127
+ function formatActionsHuman(result, path) {
128
+ const lines = [];
129
+ const nodePath = getNodePathFromActions(path);
130
+ if (result.data.length === 0) {
131
+ lines.push(`No actions available for ${nodePath}`);
132
+ return lines.join("\n");
133
+ }
134
+ lines.push(`Available actions for ${nodePath}:`);
135
+ lines.push("");
136
+ const maxNameLen = Math.max(...result.data.map((e) => getActionName(e).length));
137
+ for (const entry of result.data) {
138
+ const name = getActionName(entry);
139
+ const desc = getActionDescription(entry) || "";
140
+ lines.push(` ${name.padEnd(maxNameLen + 2)}${desc}`);
141
+ }
142
+ return lines.join("\n");
143
+ }
144
+ function formatActionsLlm(result, path) {
145
+ const lines = [];
146
+ lines.push(`ACTIONS ${path}`);
147
+ if (result.data.length === 0) {
148
+ lines.push("ACTIONS_COUNT 0");
149
+ return lines.join("\n");
150
+ }
151
+ for (const entry of result.data) {
152
+ const name = getActionName(entry);
153
+ const desc = getActionDescription(entry);
154
+ const schema = entry.meta?.inputSchema;
155
+ const descPart = desc ? ` DESCRIPTION "${desc}"` : "";
156
+ const schemaPart = schema !== void 0 ? ` SCHEMA ${JSON.stringify(schema)}` : "";
157
+ lines.push(`ACTION ${name}${descPart}${schemaPart}`);
158
+ }
159
+ return lines.join("\n");
160
+ }
161
+ function formatActionsJson(result, path) {
162
+ const actions = result.data.map((entry) => ({
163
+ name: getActionName(entry),
164
+ description: getActionDescription(entry),
165
+ inputSchema: entry.meta?.inputSchema
166
+ }));
167
+ return JSON.stringify({
168
+ path,
169
+ data: actions
170
+ }, null, 2);
171
+ }
172
+ function formatActionsDefault(result) {
173
+ if (result.data.length === 0) return "";
174
+ return result.data.map((entry) => getActionName(entry)).join("\n");
175
+ }
176
+
177
+ //#endregion
178
+ export { formatLsOutput };
179
+ //# sourceMappingURL=ls.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ls.mjs","names":[],"sources":["../../../src/core/formatters/ls.ts"],"sourcesContent":["/**\n * ls Formatter - Core Implementation\n *\n * Formats ls output without colors.\n * Accepts AFS native AFSListResult directly.\n */\n\nimport type { AFSEntry, AFSListResult } from \"@aigne/afs\";\nimport type { ViewType } from \"../types.js\";\n\nexport interface FormatLsOptions {\n /** The path being listed (used for special formatting of .actions paths) */\n path?: string;\n}\n\n/**\n * Check if a path is an actions path\n */\nfunction isActionsPath(path: string): boolean {\n return path.endsWith(\"/.actions\") || path.includes(\"/.actions/\");\n}\n\n/**\n * Format ls output for different views\n *\n * @param result - AFS list result (native type)\n * @param view - View type (default, json, llm, human)\n * @param options - Format options\n * @returns Formatted string (no ANSI colors)\n */\nexport function formatLsOutput(\n result: AFSListResult,\n view: ViewType,\n options?: FormatLsOptions,\n): string {\n // Check if we're listing an actions path for special formatting\n const isActions = options?.path && isActionsPath(options.path);\n\n switch (view) {\n case \"json\":\n return isActions ? formatActionsJson(result, options.path!) : formatJson(result);\n case \"llm\":\n return isActions ? formatActionsLlm(result, options.path!) : formatLlm(result);\n case \"human\":\n return isActions ? formatActionsHuman(result, options.path!) : formatHuman(result);\n default:\n return isActions ? formatActionsDefault(result) : formatDefault(result);\n }\n}\n\n/**\n * Default format: Machine truth, one path per line\n */\nfunction formatDefault(result: AFSListResult): string {\n if (result.data.length === 0 && result.message) {\n return `# ${result.message}`;\n }\n\n const lines = result.data.map((entry) => entry.path);\n if (result.total !== undefined && result.total > result.data.length) {\n lines.push(`# Results truncated (${result.data.length} of ${result.total} shown)`);\n }\n return lines.join(\"\\n\");\n}\n\n/**\n * JSON format: Structured output with meta field preserved\n */\nfunction formatJson(result: AFSListResult): string {\n const entries = result.data.map((entry) => {\n const output: Record<string, unknown> = {\n path: entry.path,\n };\n\n if (entry.meta && Object.keys(entry.meta).length > 0) {\n output.meta = entry.meta;\n }\n\n return output;\n });\n\n return JSON.stringify({ entries, total: result.total ?? entries.length }, null, 2);\n}\n\n/**\n * LLM format: Token-efficient, semantic facts\n */\nfunction formatLlm(result: AFSListResult): string {\n const lines: string[] = [];\n\n if (result.data.length === 0 && result.message) {\n lines.push(`ERROR ${result.message}`);\n return lines.join(\"\\n\");\n }\n\n for (const entry of result.data) {\n const parts = [`ENTRY ${entry.path}`];\n\n if (entry.meta?.kind) {\n parts.push(`KIND=${entry.meta.kind}`);\n }\n\n if (entry.meta?.size !== undefined) {\n parts.push(`SIZE=${entry.meta.size}`);\n }\n\n if (entry.meta?.childrenCount !== undefined) {\n parts.push(`CHILDREN=${entry.meta.childrenCount}`);\n }\n\n lines.push(parts.join(\" \"));\n }\n\n lines.push(`TOTAL ${result.data.length}`);\n if (result.total !== undefined && result.total > result.data.length) {\n lines.push(\"TRUNCATED true\");\n }\n return lines.join(\"\\n\");\n}\n\ninterface TreeNode {\n name: string;\n entry?: AFSEntry;\n children: Map<string, TreeNode>;\n}\n\n/**\n * Human format: Tree structure (without colors)\n */\nfunction formatHuman(result: AFSListResult): string {\n if (result.data.length === 0 && result.message) {\n return result.message;\n }\n\n // Build tree structure from flat paths\n const root: TreeNode = { name: \"\", children: new Map() };\n\n for (const entry of result.data) {\n const parts = entry.path.split(\"/\").filter(Boolean);\n let current = root;\n\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i]!;\n if (!current.children.has(part)) {\n current.children.set(part, { name: part, children: new Map() });\n }\n current = current.children.get(part)!;\n\n if (i === parts.length - 1) {\n current.entry = entry;\n }\n }\n }\n\n // Render tree\n const lines: string[] = [];\n renderTree(root, \"\", lines);\n\n if (result.total !== undefined && result.total > result.data.length) {\n lines.push(\"\");\n lines.push(`(Results truncated - ${result.data.length} of ${result.total} entries shown)`);\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction renderTree(node: TreeNode, prefix: string, lines: string[]): void {\n const children = Array.from(node.children.values());\n\n for (let i = 0; i < children.length; i++) {\n const child = children[i]!;\n const isLast = i === children.length - 1;\n const connector = isLast ? \"└── \" : \"├── \";\n const isDirectory =\n typeof child.entry?.meta?.childrenCount === \"number\" || child.children.size > 0;\n const icon = isDirectory ? \"📁\" : \"📄\";\n const sizeStr =\n child.entry?.meta?.size !== undefined ? ` ${formatSize(child.entry.meta.size)}` : \"\";\n const kindStr = child.entry?.meta?.kind ? ` (${child.entry.meta.kind})` : \"\";\n\n lines.push(`${prefix}${connector}${icon} ${child.name}${kindStr}${sizeStr}`);\n\n const childPrefix = prefix + (isLast ? \" \" : \"│ \");\n renderTree(child, childPrefix, lines);\n }\n}\n\nfunction formatSize(bytes: number): string {\n if (bytes < 1024) return `${bytes}B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)}KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;\n}\n\n// Actions-specific formatters\n\nfunction getActionName(entry: AFSEntry): string {\n const parts = entry.path.split(\"/\");\n return parts[parts.length - 1] || entry.path;\n}\n\nfunction getActionDescription(entry: AFSEntry): string | undefined {\n return entry.meta?.description;\n}\n\nfunction getNodePathFromActions(actionsPath: string): string {\n const idx = actionsPath.lastIndexOf(\"/.actions\");\n return idx > 0 ? actionsPath.substring(0, idx) : \"/\";\n}\n\nfunction formatActionsHuman(result: AFSListResult, path: string): string {\n const lines: string[] = [];\n const nodePath = getNodePathFromActions(path);\n\n if (result.data.length === 0) {\n lines.push(`No actions available for ${nodePath}`);\n return lines.join(\"\\n\");\n }\n\n lines.push(`Available actions for ${nodePath}:`);\n lines.push(\"\");\n\n const maxNameLen = Math.max(...result.data.map((e) => getActionName(e).length));\n\n for (const entry of result.data) {\n const name = getActionName(entry);\n const desc = getActionDescription(entry) || \"\";\n lines.push(` ${name.padEnd(maxNameLen + 2)}${desc}`);\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction formatActionsLlm(result: AFSListResult, path: string): string {\n const lines: string[] = [];\n\n lines.push(`ACTIONS ${path}`);\n\n if (result.data.length === 0) {\n lines.push(\"ACTIONS_COUNT 0\");\n return lines.join(\"\\n\");\n }\n\n for (const entry of result.data) {\n const name = getActionName(entry);\n const desc = getActionDescription(entry);\n const schema = entry.meta?.inputSchema;\n const descPart = desc ? ` DESCRIPTION \"${desc}\"` : \"\";\n const schemaPart = schema !== undefined ? ` SCHEMA ${JSON.stringify(schema)}` : \"\";\n lines.push(`ACTION ${name}${descPart}${schemaPart}`);\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction formatActionsJson(result: AFSListResult, path: string): string {\n const actions = result.data.map((entry) => ({\n name: getActionName(entry),\n description: getActionDescription(entry),\n inputSchema: entry.meta?.inputSchema,\n }));\n\n return JSON.stringify(\n {\n path,\n data: actions,\n },\n null,\n 2,\n );\n}\n\nfunction formatActionsDefault(result: AFSListResult): string {\n if (result.data.length === 0) {\n return \"\";\n }\n return result.data.map((entry) => getActionName(entry)).join(\"\\n\");\n}\n"],"mappings":";;;;AAkBA,SAAS,cAAc,MAAuB;AAC5C,QAAO,KAAK,SAAS,YAAY,IAAI,KAAK,SAAS,aAAa;;;;;;;;;;AAWlE,SAAgB,eACd,QACA,MACA,SACQ;CAER,MAAM,YAAY,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O,OAAO,KAAK,KAAK,UAAU,cAAc,MAAM,CAAC,CAAC,KAAK,KAAK"}
@@ -0,0 +1,55 @@
1
+
2
+ //#region src/core/formatters/mount.ts
3
+ /**
4
+ * Format mount list output for different views
5
+ *
6
+ * @param mounts - ConfigMountEntry array
7
+ * @param view - View type (default, json, llm, human)
8
+ * @returns Formatted string (no ANSI colors)
9
+ */
10
+ function formatMountListOutput(mounts, view) {
11
+ switch (view) {
12
+ case "json": return JSON.stringify(mounts.map((m) => ({
13
+ path: m.path,
14
+ namespace: m.namespace,
15
+ uri: m.uri,
16
+ description: m.description
17
+ })), null, 2);
18
+ case "llm": return formatLlm(mounts);
19
+ case "human": return formatHuman(mounts);
20
+ default: return formatDefault(mounts);
21
+ }
22
+ }
23
+ function formatDefault(mounts) {
24
+ if (mounts.length === 0) return "No mounts configured";
25
+ return mounts.map((m) => {
26
+ const ns = m.namespace ? `@${m.namespace}` : "";
27
+ const descPart = m.description ? ` (${m.description})` : "";
28
+ return `${ns}${m.path} -> ${m.uri}${descPart}`;
29
+ }).join("\n");
30
+ }
31
+ function formatLlm(mounts) {
32
+ if (mounts.length === 0) return "NO_MOUNTS";
33
+ return mounts.map((m) => {
34
+ const lines = [`MOUNT ${m.path}`];
35
+ if (m.namespace) lines.push(`NAMESPACE=${m.namespace}`);
36
+ lines.push(`URI=${m.uri}`);
37
+ if (m.description) lines.push(`DESC=${m.description}`);
38
+ return lines.join("\n");
39
+ }).join("\n\n");
40
+ }
41
+ function formatHuman(mounts) {
42
+ if (mounts.length === 0) return "No mounts configured.";
43
+ const lines = ["Configured Mounts:", ""];
44
+ for (const m of mounts) {
45
+ const ns = m.namespace ? ` (namespace: ${m.namespace})` : "";
46
+ lines.push(` ${m.path}${ns}`);
47
+ lines.push(` URI: ${m.uri}`);
48
+ if (m.description) lines.push(` Description: ${m.description}`);
49
+ lines.push("");
50
+ }
51
+ return lines.join("\n").trimEnd();
52
+ }
53
+
54
+ //#endregion
55
+ exports.formatMountListOutput = formatMountListOutput;
@@ -0,0 +1,15 @@
1
+ import { ViewType } from "../types.cjs";
2
+ import { ConfigMountEntry } from "../../config/mount-commands.cjs";
3
+
4
+ //#region src/core/formatters/mount.d.ts
5
+ /**
6
+ * Format mount list output for different views
7
+ *
8
+ * @param mounts - ConfigMountEntry array
9
+ * @param view - View type (default, json, llm, human)
10
+ * @returns Formatted string (no ANSI colors)
11
+ */
12
+ declare function formatMountListOutput(mounts: ConfigMountEntry[], view: ViewType): string;
13
+ //#endregion
14
+ export { formatMountListOutput };
15
+ //# sourceMappingURL=mount.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mount.d.cts","names":[],"sources":["../../../src/core/formatters/mount.ts"],"mappings":";;;;;;;;;;;iBAiBgB,qBAAA,CAAsB,MAAA,EAAQ,gBAAA,IAAoB,IAAA,EAAM,QAAA"}
@@ -0,0 +1,15 @@
1
+ import { ViewType } from "../types.mjs";
2
+ import { ConfigMountEntry } from "../../config/mount-commands.mjs";
3
+
4
+ //#region src/core/formatters/mount.d.ts
5
+ /**
6
+ * Format mount list output for different views
7
+ *
8
+ * @param mounts - ConfigMountEntry array
9
+ * @param view - View type (default, json, llm, human)
10
+ * @returns Formatted string (no ANSI colors)
11
+ */
12
+ declare function formatMountListOutput(mounts: ConfigMountEntry[], view: ViewType): string;
13
+ //#endregion
14
+ export { formatMountListOutput };
15
+ //# sourceMappingURL=mount.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mount.d.mts","names":[],"sources":["../../../src/core/formatters/mount.ts"],"mappings":";;;;;;;;;;;iBAiBgB,qBAAA,CAAsB,MAAA,EAAQ,gBAAA,IAAoB,IAAA,EAAM,QAAA"}
@@ -0,0 +1,55 @@
1
+ //#region src/core/formatters/mount.ts
2
+ /**
3
+ * Format mount list output for different views
4
+ *
5
+ * @param mounts - ConfigMountEntry array
6
+ * @param view - View type (default, json, llm, human)
7
+ * @returns Formatted string (no ANSI colors)
8
+ */
9
+ function formatMountListOutput(mounts, view) {
10
+ switch (view) {
11
+ case "json": return JSON.stringify(mounts.map((m) => ({
12
+ path: m.path,
13
+ namespace: m.namespace,
14
+ uri: m.uri,
15
+ description: m.description
16
+ })), null, 2);
17
+ case "llm": return formatLlm(mounts);
18
+ case "human": return formatHuman(mounts);
19
+ default: return formatDefault(mounts);
20
+ }
21
+ }
22
+ function formatDefault(mounts) {
23
+ if (mounts.length === 0) return "No mounts configured";
24
+ return mounts.map((m) => {
25
+ const ns = m.namespace ? `@${m.namespace}` : "";
26
+ const descPart = m.description ? ` (${m.description})` : "";
27
+ return `${ns}${m.path} -> ${m.uri}${descPart}`;
28
+ }).join("\n");
29
+ }
30
+ function formatLlm(mounts) {
31
+ if (mounts.length === 0) return "NO_MOUNTS";
32
+ return mounts.map((m) => {
33
+ const lines = [`MOUNT ${m.path}`];
34
+ if (m.namespace) lines.push(`NAMESPACE=${m.namespace}`);
35
+ lines.push(`URI=${m.uri}`);
36
+ if (m.description) lines.push(`DESC=${m.description}`);
37
+ return lines.join("\n");
38
+ }).join("\n\n");
39
+ }
40
+ function formatHuman(mounts) {
41
+ if (mounts.length === 0) return "No mounts configured.";
42
+ const lines = ["Configured Mounts:", ""];
43
+ for (const m of mounts) {
44
+ const ns = m.namespace ? ` (namespace: ${m.namespace})` : "";
45
+ lines.push(` ${m.path}${ns}`);
46
+ lines.push(` URI: ${m.uri}`);
47
+ if (m.description) lines.push(` Description: ${m.description}`);
48
+ lines.push("");
49
+ }
50
+ return lines.join("\n").trimEnd();
51
+ }
52
+
53
+ //#endregion
54
+ export { formatMountListOutput };
55
+ //# sourceMappingURL=mount.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mount.mjs","names":[],"sources":["../../../src/core/formatters/mount.ts"],"sourcesContent":["/**\n * mount Formatter - Core Implementation\n *\n * Formats mount output without colors.\n * Accepts ConfigMountEntry[] from the config layer.\n */\n\nimport type { ConfigMountEntry } from \"../../config/mount-commands.js\";\nimport type { ViewType } from \"../types.js\";\n\n/**\n * Format mount list output for different views\n *\n * @param mounts - ConfigMountEntry array\n * @param view - View type (default, json, llm, human)\n * @returns Formatted string (no ANSI colors)\n */\nexport function formatMountListOutput(mounts: ConfigMountEntry[], view: ViewType): string {\n switch (view) {\n case \"json\":\n return JSON.stringify(\n mounts.map((m) => ({\n path: m.path,\n namespace: m.namespace,\n uri: m.uri,\n description: m.description,\n })),\n null,\n 2,\n );\n case \"llm\":\n return formatLlm(mounts);\n case \"human\":\n return formatHuman(mounts);\n default:\n return formatDefault(mounts);\n }\n}\n\nfunction formatDefault(mounts: ConfigMountEntry[]): string {\n if (mounts.length === 0) {\n return \"No mounts configured\";\n }\n\n return mounts\n .map((m) => {\n const ns = m.namespace ? `@${m.namespace}` : \"\";\n const descPart = m.description ? ` (${m.description})` : \"\";\n return `${ns}${m.path} -> ${m.uri}${descPart}`;\n })\n .join(\"\\n\");\n}\n\nfunction formatLlm(mounts: ConfigMountEntry[]): string {\n if (mounts.length === 0) {\n return \"NO_MOUNTS\";\n }\n\n return mounts\n .map((m) => {\n const lines = [`MOUNT ${m.path}`];\n if (m.namespace) {\n lines.push(`NAMESPACE=${m.namespace}`);\n }\n lines.push(`URI=${m.uri}`);\n if (m.description) {\n lines.push(`DESC=${m.description}`);\n }\n return lines.join(\"\\n\");\n })\n .join(\"\\n\\n\");\n}\n\nfunction formatHuman(mounts: ConfigMountEntry[]): string {\n if (mounts.length === 0) {\n return \"No mounts configured.\";\n }\n\n const lines = [\"Configured Mounts:\", \"\"];\n for (const m of mounts) {\n const ns = m.namespace ? ` (namespace: ${m.namespace})` : \"\";\n lines.push(` ${m.path}${ns}`);\n lines.push(` URI: ${m.uri}`);\n if (m.description) {\n lines.push(` Description: ${m.description}`);\n }\n lines.push(\"\");\n }\n\n return lines.join(\"\\n\").trimEnd();\n}\n"],"mappings":";;;;;;;;AAiBA,SAAgB,sBAAsB,QAA4B,MAAwB;AACxF,SAAQ,MAAR;EACE,KAAK,OACH,QAAO,KAAK,UACV,OAAO,KAAK,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
+
2
+ //#region src/core/formatters/read.ts
3
+ /**
4
+ * Format read output for different views
5
+ *
6
+ * @param result - AFS read result (native type)
7
+ * @param view - View type (default, json, llm, human)
8
+ * @param options - Format options (e.g., original path)
9
+ * @returns Formatted string (no ANSI colors)
10
+ */
11
+ function formatReadOutput(result, view, options) {
12
+ switch (view) {
13
+ case "json": return formatJson(result);
14
+ case "llm": return formatLlm(result);
15
+ case "human": return formatHuman(result, options);
16
+ default: return formatDefault(result, options);
17
+ }
18
+ }
19
+ /**
20
+ * Default format: Raw content
21
+ */
22
+ function formatDefault(result, options) {
23
+ if (!result.data) return options?.path || result.message || "No data";
24
+ const entry = result.data;
25
+ const content = entry.content;
26
+ if (content !== void 0 && content !== null && content !== "") return typeof content === "string" ? content : JSON.stringify(content, null, 2);
27
+ const parts = [entry.path];
28
+ if (entry.meta?.kind) parts.push(entry.meta.kind);
29
+ if (entry.meta?.childrenCount !== void 0) parts.push(`children=${entry.meta.childrenCount}`);
30
+ if (entry.actions && entry.actions.length > 0) parts.push(`actions=${entry.actions.map((a) => a.name).join(",")}`);
31
+ return parts.join(" ");
32
+ }
33
+ /**
34
+ * JSON format
35
+ */
36
+ function formatJson(result) {
37
+ return JSON.stringify(result, null, 2);
38
+ }
39
+ /**
40
+ * LLM format: Structured text for AI parsing
41
+ */
42
+ function formatLlm(result) {
43
+ if (!result.data) return result.message || "NO_DATA";
44
+ const entry = result.data;
45
+ const lines = [];
46
+ lines.push(`NODE ${entry.path}`);
47
+ if (entry.meta?.kind) lines.push(`KIND ${entry.meta.kind}`);
48
+ if (entry.meta?.kinds && Array.isArray(entry.meta.kinds)) lines.push(`KINDS ${entry.meta.kinds.join(" ")}`);
49
+ if (entry.meta?.childrenCount !== void 0) lines.push(`CHILDREN ${entry.meta.childrenCount}`);
50
+ if (entry.meta?.size !== void 0) lines.push(`SIZE ${entry.meta.size}`);
51
+ if (entry.actions && entry.actions.length > 0) {
52
+ lines.push(`ACTIONS_COUNT ${entry.actions.length}`);
53
+ for (const action of entry.actions) {
54
+ const desc = action.description ? ` "${action.description}"` : "";
55
+ const schema = action.inputSchema;
56
+ const schemaPart = schema !== void 0 ? ` SCHEMA ${JSON.stringify(schema)}` : "";
57
+ lines.push(`ACTION ${action.name}${desc}${schemaPart}`);
58
+ }
59
+ }
60
+ const content = entry.content;
61
+ if (content !== void 0 && content !== null && content !== "") lines.push(`CONTENT ${JSON.stringify(content)}`);
62
+ return lines.join("\n");
63
+ }
64
+ /**
65
+ * Human format: Formatted display (without colors)
66
+ */
67
+ function formatHuman(result, options) {
68
+ if (!result.data) return options?.path || result.message || "No data available";
69
+ const entry = result.data;
70
+ const lines = [];
71
+ lines.push(`Path: ${entry.path}`);
72
+ if (entry.meta && Object.keys(entry.meta).length > 0) {
73
+ lines.push("Metadata:");
74
+ for (const [key, value] of Object.entries(entry.meta)) {
75
+ if (value === null || value === void 0) continue;
76
+ const valueStr = typeof value === "object" ? JSON.stringify(value) : String(value);
77
+ lines.push(` ${key}: ${valueStr}`);
78
+ }
79
+ }
80
+ if (entry.actions && entry.actions.length > 0) lines.push(`Actions: ${entry.actions.map((a) => a.name).join(", ")}`);
81
+ const content = entry.content;
82
+ const meta = entry.meta;
83
+ if (content !== void 0 && content !== null && content !== "") {
84
+ lines.push("");
85
+ lines.push("Content:");
86
+ lines.push(formatContent(content));
87
+ } else if (meta?.childrenCount !== void 0 && meta.childrenCount > 0) {
88
+ lines.push("");
89
+ lines.push("Content:");
90
+ lines.push(" (directory - use 'afs ls' to list children)");
91
+ }
92
+ return lines.join("\n");
93
+ }
94
+ function formatContent(content) {
95
+ if (typeof content === "string") return content.split("\n").map((line) => ` ${line}`).join("\n");
96
+ return ` ${JSON.stringify(content, null, 2).split("\n").join("\n ")}`;
97
+ }
98
+
99
+ //#endregion
100
+ exports.formatReadOutput = formatReadOutput;
@@ -0,0 +1,22 @@
1
+ import { ViewType } from "../types.cjs";
2
+ import { AFSReadResult } from "@aigne/afs";
3
+
4
+ //#region src/core/formatters/read.d.ts
5
+ /**
6
+ * Options for formatting read output
7
+ */
8
+ interface ReadFormatOptions {
9
+ path?: string;
10
+ }
11
+ /**
12
+ * Format read output for different views
13
+ *
14
+ * @param result - AFS read result (native type)
15
+ * @param view - View type (default, json, llm, human)
16
+ * @param options - Format options (e.g., original path)
17
+ * @returns Formatted string (no ANSI colors)
18
+ */
19
+ declare function formatReadOutput(result: AFSReadResult, view: ViewType, options?: ReadFormatOptions): string;
20
+ //#endregion
21
+ export { formatReadOutput };
22
+ //# sourceMappingURL=read.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d.cts","names":[],"sources":["../../../src/core/formatters/read.ts"],"mappings":";;;;;AAyBA;;UAZiB,iBAAA;EACf,IAAA;AAAA;;;;;;;;;iBAWc,gBAAA,CACd,MAAA,EAAQ,aAAA,EACR,IAAA,EAAM,QAAA,EACN,OAAA,GAAU,iBAAA"}
@@ -0,0 +1,22 @@
1
+ import { ViewType } from "../types.mjs";
2
+ import { AFSReadResult } from "@aigne/afs";
3
+
4
+ //#region src/core/formatters/read.d.ts
5
+ /**
6
+ * Options for formatting read output
7
+ */
8
+ interface ReadFormatOptions {
9
+ path?: string;
10
+ }
11
+ /**
12
+ * Format read output for different views
13
+ *
14
+ * @param result - AFS read result (native type)
15
+ * @param view - View type (default, json, llm, human)
16
+ * @param options - Format options (e.g., original path)
17
+ * @returns Formatted string (no ANSI colors)
18
+ */
19
+ declare function formatReadOutput(result: AFSReadResult, view: ViewType, options?: ReadFormatOptions): string;
20
+ //#endregion
21
+ export { formatReadOutput };
22
+ //# sourceMappingURL=read.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d.mts","names":[],"sources":["../../../src/core/formatters/read.ts"],"mappings":";;;;;AAyBA;;UAZiB,iBAAA;EACf,IAAA;AAAA;;;;;;;;;iBAWc,gBAAA,CACd,MAAA,EAAQ,aAAA,EACR,IAAA,EAAM,QAAA,EACN,OAAA,GAAU,iBAAA"}
@@ -0,0 +1,100 @@
1
+ //#region src/core/formatters/read.ts
2
+ /**
3
+ * Format read output for different views
4
+ *
5
+ * @param result - AFS read result (native type)
6
+ * @param view - View type (default, json, llm, human)
7
+ * @param options - Format options (e.g., original path)
8
+ * @returns Formatted string (no ANSI colors)
9
+ */
10
+ function formatReadOutput(result, view, options) {
11
+ switch (view) {
12
+ case "json": return formatJson(result);
13
+ case "llm": return formatLlm(result);
14
+ case "human": return formatHuman(result, options);
15
+ default: return formatDefault(result, options);
16
+ }
17
+ }
18
+ /**
19
+ * Default format: Raw content
20
+ */
21
+ function formatDefault(result, options) {
22
+ if (!result.data) return options?.path || result.message || "No data";
23
+ const entry = result.data;
24
+ const content = entry.content;
25
+ if (content !== void 0 && content !== null && content !== "") return typeof content === "string" ? content : JSON.stringify(content, null, 2);
26
+ const parts = [entry.path];
27
+ if (entry.meta?.kind) parts.push(entry.meta.kind);
28
+ if (entry.meta?.childrenCount !== void 0) parts.push(`children=${entry.meta.childrenCount}`);
29
+ if (entry.actions && entry.actions.length > 0) parts.push(`actions=${entry.actions.map((a) => a.name).join(",")}`);
30
+ return parts.join(" ");
31
+ }
32
+ /**
33
+ * JSON format
34
+ */
35
+ function formatJson(result) {
36
+ return JSON.stringify(result, null, 2);
37
+ }
38
+ /**
39
+ * LLM format: Structured text for AI parsing
40
+ */
41
+ function formatLlm(result) {
42
+ if (!result.data) return result.message || "NO_DATA";
43
+ const entry = result.data;
44
+ const lines = [];
45
+ lines.push(`NODE ${entry.path}`);
46
+ if (entry.meta?.kind) lines.push(`KIND ${entry.meta.kind}`);
47
+ if (entry.meta?.kinds && Array.isArray(entry.meta.kinds)) lines.push(`KINDS ${entry.meta.kinds.join(" ")}`);
48
+ if (entry.meta?.childrenCount !== void 0) lines.push(`CHILDREN ${entry.meta.childrenCount}`);
49
+ if (entry.meta?.size !== void 0) lines.push(`SIZE ${entry.meta.size}`);
50
+ if (entry.actions && entry.actions.length > 0) {
51
+ lines.push(`ACTIONS_COUNT ${entry.actions.length}`);
52
+ for (const action of entry.actions) {
53
+ const desc = action.description ? ` "${action.description}"` : "";
54
+ const schema = action.inputSchema;
55
+ const schemaPart = schema !== void 0 ? ` SCHEMA ${JSON.stringify(schema)}` : "";
56
+ lines.push(`ACTION ${action.name}${desc}${schemaPart}`);
57
+ }
58
+ }
59
+ const content = entry.content;
60
+ if (content !== void 0 && content !== null && content !== "") lines.push(`CONTENT ${JSON.stringify(content)}`);
61
+ return lines.join("\n");
62
+ }
63
+ /**
64
+ * Human format: Formatted display (without colors)
65
+ */
66
+ function formatHuman(result, options) {
67
+ if (!result.data) return options?.path || result.message || "No data available";
68
+ const entry = result.data;
69
+ const lines = [];
70
+ lines.push(`Path: ${entry.path}`);
71
+ if (entry.meta && Object.keys(entry.meta).length > 0) {
72
+ lines.push("Metadata:");
73
+ for (const [key, value] of Object.entries(entry.meta)) {
74
+ if (value === null || value === void 0) continue;
75
+ const valueStr = typeof value === "object" ? JSON.stringify(value) : String(value);
76
+ lines.push(` ${key}: ${valueStr}`);
77
+ }
78
+ }
79
+ if (entry.actions && entry.actions.length > 0) lines.push(`Actions: ${entry.actions.map((a) => a.name).join(", ")}`);
80
+ const content = entry.content;
81
+ const meta = entry.meta;
82
+ if (content !== void 0 && content !== null && content !== "") {
83
+ lines.push("");
84
+ lines.push("Content:");
85
+ lines.push(formatContent(content));
86
+ } else if (meta?.childrenCount !== void 0 && meta.childrenCount > 0) {
87
+ lines.push("");
88
+ lines.push("Content:");
89
+ lines.push(" (directory - use 'afs ls' to list children)");
90
+ }
91
+ return lines.join("\n");
92
+ }
93
+ function formatContent(content) {
94
+ if (typeof content === "string") return content.split("\n").map((line) => ` ${line}`).join("\n");
95
+ return ` ${JSON.stringify(content, null, 2).split("\n").join("\n ")}`;
96
+ }
97
+
98
+ //#endregion
99
+ export { formatReadOutput };
100
+ //# sourceMappingURL=read.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.mjs","names":[],"sources":["../../../src/core/formatters/read.ts"],"sourcesContent":["/**\n * read Formatter - Core Implementation\n *\n * Formats read output without colors.\n * Accepts AFS native AFSReadResult directly.\n */\n\nimport type { AFSReadResult } from \"@aigne/afs\";\nimport type { ViewType } from \"../types.js\";\n\n/**\n * Options for formatting read output\n */\nexport interface ReadFormatOptions {\n path?: string;\n}\n\n/**\n * Format read output for different views\n *\n * @param result - AFS read result (native type)\n * @param view - View type (default, json, llm, human)\n * @param options - Format options (e.g., original path)\n * @returns Formatted string (no ANSI colors)\n */\nexport function formatReadOutput(\n result: AFSReadResult,\n view: ViewType,\n options?: ReadFormatOptions,\n): string {\n switch (view) {\n case \"json\":\n return formatJson(result);\n case \"llm\":\n return formatLlm(result);\n case \"human\":\n return formatHuman(result, options);\n default:\n return formatDefault(result, options);\n }\n}\n\n/**\n * Default format: Raw content\n */\nfunction formatDefault(result: AFSReadResult, options?: ReadFormatOptions): string {\n if (!result.data) {\n // For root or virtual nodes without data, show the path\n return options?.path || result.message || \"No data\";\n }\n\n const entry = result.data;\n const content = entry.content;\n\n // If there's content, show it\n if (content !== undefined && content !== null && content !== \"\") {\n return typeof content === \"string\" ? content : JSON.stringify(content, null, 2);\n }\n\n // For directories (no content), show one-liner summary\n const parts = [entry.path];\n\n if (entry.meta?.kind) {\n parts.push(entry.meta.kind);\n }\n\n if (entry.meta?.childrenCount !== undefined) {\n parts.push(`children=${entry.meta.childrenCount}`);\n }\n\n if (entry.actions && entry.actions.length > 0) {\n parts.push(`actions=${entry.actions.map((a) => a.name).join(\",\")}`);\n }\n\n return parts.join(\" \");\n}\n\n/**\n * JSON format\n */\nfunction formatJson(result: AFSReadResult): string {\n return JSON.stringify(result, null, 2);\n}\n\n/**\n * LLM format: Structured text for AI parsing\n */\nfunction formatLlm(result: AFSReadResult): string {\n if (!result.data) {\n return result.message || \"NO_DATA\";\n }\n\n const entry = result.data;\n const lines: string[] = [];\n\n lines.push(`NODE ${entry.path}`);\n\n if (entry.meta?.kind) {\n lines.push(`KIND ${entry.meta.kind}`);\n }\n\n if (entry.meta?.kinds && Array.isArray(entry.meta.kinds)) {\n lines.push(`KINDS ${entry.meta.kinds.join(\" \")}`);\n }\n\n if (entry.meta?.childrenCount !== undefined) {\n lines.push(`CHILDREN ${entry.meta.childrenCount}`);\n }\n\n if (entry.meta?.size !== undefined) {\n lines.push(`SIZE ${entry.meta.size}`);\n }\n\n if (entry.actions && entry.actions.length > 0) {\n lines.push(`ACTIONS_COUNT ${entry.actions.length}`);\n for (const action of entry.actions) {\n const desc = action.description ? ` \"${action.description}\"` : \"\";\n const schema = action.inputSchema;\n const schemaPart = schema !== undefined ? ` SCHEMA ${JSON.stringify(schema)}` : \"\";\n lines.push(`ACTION ${action.name}${desc}${schemaPart}`);\n }\n }\n\n const content = entry.content;\n if (content !== undefined && content !== null && content !== \"\") {\n lines.push(`CONTENT ${JSON.stringify(content)}`);\n }\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Human format: Formatted display (without colors)\n */\nfunction formatHuman(result: AFSReadResult, options?: ReadFormatOptions): string {\n if (!result.data) {\n // For root or virtual nodes without data, show the path\n return options?.path || result.message || \"No data available\";\n }\n\n const entry = result.data;\n const lines: string[] = [];\n\n lines.push(`Path: ${entry.path}`);\n\n if (entry.meta && Object.keys(entry.meta).length > 0) {\n lines.push(\"Metadata:\");\n for (const [key, value] of Object.entries(entry.meta)) {\n if (value === null || value === undefined) continue;\n const valueStr = typeof value === \"object\" ? JSON.stringify(value) : String(value);\n lines.push(` ${key}: ${valueStr}`);\n }\n }\n\n if (entry.actions && entry.actions.length > 0) {\n lines.push(`Actions: ${entry.actions.map((a) => a.name).join(\", \")}`);\n }\n\n const content = entry.content;\n const meta = entry.meta as Record<string, unknown> | undefined;\n if (content !== undefined && content !== null && content !== \"\") {\n lines.push(\"\");\n lines.push(\"Content:\");\n lines.push(formatContent(content));\n } else if (meta?.childrenCount !== undefined && (meta.childrenCount as number) > 0) {\n lines.push(\"\");\n lines.push(\"Content:\");\n lines.push(\" (directory - use 'afs ls' to list children)\");\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction formatContent(content: unknown): string {\n if (typeof content === \"string\") {\n return content\n .split(\"\\n\")\n .map((line) => ` ${line}`)\n .join(\"\\n\");\n }\n return ` ${JSON.stringify(content, null, 2).split(\"\\n\").join(\"\\n \")}`;\n}\n"],"mappings":";;;;;;;;;AAyBA,SAAgB,iBACd,QACA,MACA,SACQ;AACR,SAAQ,MAAR;EACE,KAAK,OACH,QAAO,WAAW,OAAO;EAC3B,KAAK,MACH,QAAO,UAAU,OAAO;EAC1B,KAAK,QACH,QAAO,YAAY,QAAQ,QAAQ;EACrC,QACE,QAAO,cAAc,QAAQ,QAAQ;;;;;;AAO3C,SAAS,cAAc,QAAuB,SAAqC;AACjF,KAAI,CAAC,OAAO,KAEV,QAAO,SAAS,QAAQ,OAAO,WAAW;CAG5C,MAAM,QAAQ,OAAO;CACrB,MAAM,UAAU,MAAM;AAGtB,KAAI,YAAY,UAAa,YAAY,QAAQ,YAAY,GAC3D,QAAO,OAAO,YAAY,WAAW,UAAU,KAAK,UAAU,SAAS,MAAM,EAAE;CAIjF,MAAM,QAAQ,CAAC,MAAM,KAAK;AAE1B,KAAI,MAAM,MAAM,KACd,OAAM,KAAK,MAAM,KAAK,KAAK;AAG7B,KAAI,MAAM,MAAM,kBAAkB,OAChC,OAAM,KAAK,YAAY,MAAM,KAAK,gBAAgB;AAGpD,KAAI,MAAM,WAAW,MAAM,QAAQ,SAAS,EAC1C,OAAM,KAAK,WAAW,MAAM,QAAQ,KAAK,MAAM,EAAE,KAAK,CAAC,KAAK,IAAI,GAAG;AAGrE,QAAO,MAAM,KAAK,IAAI;;;;;AAMxB,SAAS,WAAW,QAA+B;AACjD,QAAO,KAAK,UAAU,QAAQ,MAAM,EAAE;;;;;AAMxC,SAAS,UAAU,QAA+B;AAChD,KAAI,CAAC,OAAO,KACV,QAAO,OAAO,WAAW;CAG3B,MAAM,QAAQ,OAAO;CACrB,MAAM,QAAkB,EAAE;AAE1B,OAAM,KAAK,QAAQ,MAA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