@aigne/afs-cli 1.11.0-beta.5 → 1.11.0-beta.7

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 (318) hide show
  1. package/dist/cli.cjs +25 -328
  2. package/dist/cli.d.cts +2 -1
  3. package/dist/cli.d.mts +2 -1
  4. package/dist/cli.mjs +26 -328
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/config/afs-loader.cjs +123 -0
  7. package/dist/config/afs-loader.d.cts +14 -0
  8. package/dist/config/afs-loader.d.cts.map +1 -0
  9. package/dist/config/afs-loader.d.mts +14 -0
  10. package/dist/config/afs-loader.d.mts.map +1 -0
  11. package/dist/config/afs-loader.mjs +122 -0
  12. package/dist/config/afs-loader.mjs.map +1 -0
  13. package/dist/config/loader.cjs +14 -3
  14. package/dist/config/loader.mjs +14 -3
  15. package/dist/config/loader.mjs.map +1 -1
  16. package/dist/{commands/mount.cjs → config/mount-commands.cjs} +13 -49
  17. package/dist/config/mount-commands.d.cts +20 -0
  18. package/dist/config/mount-commands.d.cts.map +1 -0
  19. package/dist/config/mount-commands.d.mts +20 -0
  20. package/dist/config/mount-commands.d.mts.map +1 -0
  21. package/dist/{commands/mount.mjs → config/mount-commands.mjs} +14 -49
  22. package/dist/config/mount-commands.mjs.map +1 -0
  23. package/dist/config/schema.cjs +9 -1
  24. package/dist/config/schema.mjs +9 -1
  25. package/dist/config/schema.mjs.map +1 -1
  26. package/dist/core/commands/delete.cjs +41 -0
  27. package/dist/core/commands/delete.d.cts +18 -0
  28. package/dist/core/commands/delete.d.cts.map +1 -0
  29. package/dist/core/commands/delete.d.mts +18 -0
  30. package/dist/core/commands/delete.d.mts.map +1 -0
  31. package/dist/core/commands/delete.mjs +42 -0
  32. package/dist/core/commands/delete.mjs.map +1 -0
  33. package/dist/core/commands/exec.cjs +95 -0
  34. package/dist/core/commands/exec.d.cts +26 -0
  35. package/dist/core/commands/exec.d.cts.map +1 -0
  36. package/dist/core/commands/exec.d.mts +26 -0
  37. package/dist/core/commands/exec.d.mts.map +1 -0
  38. package/dist/core/commands/exec.mjs +96 -0
  39. package/dist/core/commands/exec.mjs.map +1 -0
  40. package/dist/core/commands/explain.cjs +254 -0
  41. package/dist/core/commands/explain.d.cts +25 -0
  42. package/dist/core/commands/explain.d.cts.map +1 -0
  43. package/dist/core/commands/explain.d.mts +25 -0
  44. package/dist/core/commands/explain.d.mts.map +1 -0
  45. package/dist/core/commands/explain.mjs +255 -0
  46. package/dist/core/commands/explain.mjs.map +1 -0
  47. package/dist/core/commands/explore.cjs +30 -0
  48. package/dist/core/commands/explore.d.mts +2 -0
  49. package/dist/core/commands/explore.mjs +31 -0
  50. package/dist/core/commands/explore.mjs.map +1 -0
  51. package/dist/core/commands/index.cjs +36 -0
  52. package/dist/core/commands/index.d.cts +21 -0
  53. package/dist/core/commands/index.d.cts.map +1 -0
  54. package/dist/core/commands/index.d.mts +24 -0
  55. package/dist/core/commands/index.d.mts.map +1 -0
  56. package/dist/core/commands/index.mjs +37 -0
  57. package/dist/core/commands/index.mjs.map +1 -0
  58. package/dist/core/commands/ls.cjs +57 -0
  59. package/dist/core/commands/ls.d.cts +21 -0
  60. package/dist/core/commands/ls.d.cts.map +1 -0
  61. package/dist/core/commands/ls.d.mts +21 -0
  62. package/dist/core/commands/ls.d.mts.map +1 -0
  63. package/dist/core/commands/ls.mjs +58 -0
  64. package/dist/core/commands/ls.mjs.map +1 -0
  65. package/dist/core/commands/mount.cjs +139 -0
  66. package/dist/core/commands/mount.d.cts +33 -0
  67. package/dist/core/commands/mount.d.cts.map +1 -0
  68. package/dist/core/commands/mount.d.mts +33 -0
  69. package/dist/core/commands/mount.d.mts.map +1 -0
  70. package/dist/core/commands/mount.mjs +140 -0
  71. package/dist/core/commands/mount.mjs.map +1 -0
  72. package/dist/core/commands/read.cjs +48 -0
  73. package/dist/core/commands/read.d.cts +17 -0
  74. package/dist/core/commands/read.d.cts.map +1 -0
  75. package/dist/core/commands/read.d.mts +17 -0
  76. package/dist/core/commands/read.d.mts.map +1 -0
  77. package/dist/core/commands/read.mjs +49 -0
  78. package/dist/core/commands/read.mjs.map +1 -0
  79. package/dist/core/commands/search.cjs +40 -0
  80. package/dist/core/commands/search.d.mts +2 -0
  81. package/dist/core/commands/search.mjs +41 -0
  82. package/dist/core/commands/search.mjs.map +1 -0
  83. package/dist/core/commands/serve.cjs +242 -0
  84. package/dist/core/commands/serve.d.mts +2 -0
  85. package/dist/core/commands/serve.mjs +242 -0
  86. package/dist/core/commands/serve.mjs.map +1 -0
  87. package/dist/core/commands/stat.cjs +53 -0
  88. package/dist/core/commands/stat.d.cts +17 -0
  89. package/dist/core/commands/stat.d.cts.map +1 -0
  90. package/dist/core/commands/stat.d.mts +17 -0
  91. package/dist/core/commands/stat.d.mts.map +1 -0
  92. package/dist/core/commands/stat.mjs +54 -0
  93. package/dist/core/commands/stat.mjs.map +1 -0
  94. package/dist/core/commands/types.cjs +13 -0
  95. package/dist/core/commands/types.d.cts +54 -0
  96. package/dist/core/commands/types.d.cts.map +1 -0
  97. package/dist/core/commands/types.d.mts +54 -0
  98. package/dist/core/commands/types.d.mts.map +1 -0
  99. package/dist/core/commands/types.mjs +14 -0
  100. package/dist/core/commands/types.mjs.map +1 -0
  101. package/dist/core/commands/write.cjs +70 -0
  102. package/dist/core/commands/write.d.cts +20 -0
  103. package/dist/core/commands/write.d.cts.map +1 -0
  104. package/dist/core/commands/write.d.mts +20 -0
  105. package/dist/core/commands/write.d.mts.map +1 -0
  106. package/dist/core/commands/write.mjs +71 -0
  107. package/dist/core/commands/write.mjs.map +1 -0
  108. package/dist/core/executor/index.cjs +196 -0
  109. package/dist/core/executor/index.d.cts +77 -0
  110. package/dist/core/executor/index.d.cts.map +1 -0
  111. package/dist/core/executor/index.d.mts +77 -0
  112. package/dist/core/executor/index.d.mts.map +1 -0
  113. package/dist/core/executor/index.mjs +195 -0
  114. package/dist/core/executor/index.mjs.map +1 -0
  115. package/dist/core/formatters/delete.cjs +37 -0
  116. package/dist/core/formatters/delete.d.cts +18 -0
  117. package/dist/core/formatters/delete.d.cts.map +1 -0
  118. package/dist/core/formatters/delete.d.mts +18 -0
  119. package/dist/core/formatters/delete.d.mts.map +1 -0
  120. package/dist/core/formatters/delete.mjs +37 -0
  121. package/dist/core/formatters/delete.mjs.map +1 -0
  122. package/dist/core/formatters/exec.cjs +60 -0
  123. package/dist/core/formatters/exec.d.cts +18 -0
  124. package/dist/core/formatters/exec.d.cts.map +1 -0
  125. package/dist/core/formatters/exec.d.mts +18 -0
  126. package/dist/core/formatters/exec.d.mts.map +1 -0
  127. package/dist/core/formatters/exec.mjs +60 -0
  128. package/dist/core/formatters/exec.mjs.map +1 -0
  129. package/dist/core/formatters/explain.cjs +97 -0
  130. package/dist/core/formatters/explain.d.cts +11 -0
  131. package/dist/core/formatters/explain.d.cts.map +1 -0
  132. package/dist/core/formatters/explain.d.mts +11 -0
  133. package/dist/core/formatters/explain.d.mts.map +1 -0
  134. package/dist/core/formatters/explain.mjs +96 -0
  135. package/dist/core/formatters/explain.mjs.map +1 -0
  136. package/dist/core/formatters/index.d.mts +9 -0
  137. package/dist/core/formatters/ls.cjs +179 -0
  138. package/dist/core/formatters/ls.d.cts +20 -0
  139. package/dist/core/formatters/ls.d.cts.map +1 -0
  140. package/dist/core/formatters/ls.d.mts +20 -0
  141. package/dist/core/formatters/ls.d.mts.map +1 -0
  142. package/dist/core/formatters/ls.mjs +179 -0
  143. package/dist/core/formatters/ls.mjs.map +1 -0
  144. package/dist/core/formatters/mount.cjs +55 -0
  145. package/dist/core/formatters/mount.d.cts +15 -0
  146. package/dist/core/formatters/mount.d.cts.map +1 -0
  147. package/dist/core/formatters/mount.d.mts +15 -0
  148. package/dist/core/formatters/mount.d.mts.map +1 -0
  149. package/dist/core/formatters/mount.mjs +55 -0
  150. package/dist/core/formatters/mount.mjs.map +1 -0
  151. package/dist/core/formatters/read.cjs +100 -0
  152. package/dist/core/formatters/read.d.cts +22 -0
  153. package/dist/core/formatters/read.d.cts.map +1 -0
  154. package/dist/core/formatters/read.d.mts +22 -0
  155. package/dist/core/formatters/read.d.mts.map +1 -0
  156. package/dist/core/formatters/read.mjs +100 -0
  157. package/dist/core/formatters/read.mjs.map +1 -0
  158. package/dist/core/formatters/search.cjs +44 -0
  159. package/dist/core/formatters/search.d.mts +1 -0
  160. package/dist/core/formatters/search.mjs +44 -0
  161. package/dist/core/formatters/search.mjs.map +1 -0
  162. package/dist/core/formatters/stat.cjs +155 -0
  163. package/dist/core/formatters/stat.d.cts +15 -0
  164. package/dist/core/formatters/stat.d.cts.map +1 -0
  165. package/dist/core/formatters/stat.d.mts +15 -0
  166. package/dist/core/formatters/stat.d.mts.map +1 -0
  167. package/dist/core/formatters/stat.mjs +155 -0
  168. package/dist/core/formatters/stat.mjs.map +1 -0
  169. package/dist/core/formatters/write.cjs +51 -0
  170. package/dist/core/formatters/write.d.cts +22 -0
  171. package/dist/core/formatters/write.d.cts.map +1 -0
  172. package/dist/core/formatters/write.d.mts +22 -0
  173. package/dist/core/formatters/write.d.mts.map +1 -0
  174. package/dist/core/formatters/write.mjs +51 -0
  175. package/dist/core/formatters/write.mjs.map +1 -0
  176. package/dist/core/helpers/exec-args.cjs +142 -0
  177. package/dist/core/helpers/exec-args.d.cts +46 -0
  178. package/dist/core/helpers/exec-args.d.cts.map +1 -0
  179. package/dist/core/helpers/exec-args.d.mts +46 -0
  180. package/dist/core/helpers/exec-args.d.mts.map +1 -0
  181. package/dist/core/helpers/exec-args.mjs +139 -0
  182. package/dist/core/helpers/exec-args.mjs.map +1 -0
  183. package/dist/core/helpers/stdin.cjs +41 -0
  184. package/dist/core/helpers/stdin.d.cts +15 -0
  185. package/dist/core/helpers/stdin.d.cts.map +1 -0
  186. package/dist/core/helpers/stdin.d.mts +15 -0
  187. package/dist/core/helpers/stdin.d.mts.map +1 -0
  188. package/dist/core/helpers/stdin.mjs +41 -0
  189. package/dist/core/helpers/stdin.mjs.map +1 -0
  190. package/dist/core/index.cjs +49 -0
  191. package/dist/core/index.d.cts +24 -0
  192. package/dist/core/index.d.mts +25 -0
  193. package/dist/core/index.mjs +24 -0
  194. package/dist/core/path-utils.cjs +1 -0
  195. package/dist/core/path-utils.mjs +3 -0
  196. package/dist/core/types.d.cts +24 -0
  197. package/dist/core/types.d.cts.map +1 -0
  198. package/dist/core/types.d.mts +24 -0
  199. package/dist/core/types.d.mts.map +1 -0
  200. package/dist/errors.cjs +0 -11
  201. package/dist/errors.mjs +1 -11
  202. package/dist/errors.mjs.map +1 -1
  203. package/dist/explorer/actions.cjs +113 -48
  204. package/dist/explorer/actions.mjs +113 -48
  205. package/dist/explorer/actions.mjs.map +1 -1
  206. package/dist/explorer/components/dialog.cjs +287 -10
  207. package/dist/explorer/components/dialog.mjs +287 -10
  208. package/dist/explorer/components/dialog.mjs.map +1 -1
  209. package/dist/explorer/components/file-list.mjs.map +1 -1
  210. package/dist/explorer/components/metadata-panel.cjs +121 -24
  211. package/dist/explorer/components/metadata-panel.mjs +121 -24
  212. package/dist/explorer/components/metadata-panel.mjs.map +1 -1
  213. package/dist/explorer/screen.cjs +72 -21
  214. package/dist/explorer/screen.d.cts +23 -0
  215. package/dist/explorer/screen.d.cts.map +1 -0
  216. package/dist/explorer/screen.d.mts +23 -0
  217. package/dist/explorer/screen.d.mts.map +1 -0
  218. package/dist/explorer/screen.mjs +73 -22
  219. package/dist/explorer/screen.mjs.map +1 -1
  220. package/dist/explorer/theme.cjs +4 -2
  221. package/dist/explorer/theme.mjs +4 -2
  222. package/dist/explorer/theme.mjs.map +1 -1
  223. package/dist/index.cjs +7 -1
  224. package/dist/index.d.cts +4 -1
  225. package/dist/index.d.mts +4 -1
  226. package/dist/index.mjs +4 -1
  227. package/dist/mcp/http-transport.cjs +68 -0
  228. package/dist/mcp/http-transport.mjs +68 -0
  229. package/dist/mcp/http-transport.mjs.map +1 -0
  230. package/dist/mcp/prompts.cjs +48 -0
  231. package/dist/mcp/prompts.mjs +48 -0
  232. package/dist/mcp/prompts.mjs.map +1 -0
  233. package/dist/mcp/resources.cjs +25 -0
  234. package/dist/mcp/resources.mjs +25 -0
  235. package/dist/mcp/resources.mjs.map +1 -0
  236. package/dist/mcp/server.cjs +30 -0
  237. package/dist/mcp/server.mjs +30 -0
  238. package/dist/mcp/server.mjs.map +1 -0
  239. package/dist/mcp/tools.cjs +196 -0
  240. package/dist/mcp/tools.mjs +196 -0
  241. package/dist/mcp/tools.mjs.map +1 -0
  242. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/index.d.cts +10 -0
  243. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/index.d.cts.map +1 -0
  244. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/index.d.mts +10 -0
  245. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/index.d.mts.map +1 -0
  246. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/types.d.cts +46 -0
  247. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/types.d.cts.map +1 -0
  248. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/types.d.mts +46 -0
  249. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/types.d.mts.map +1 -0
  250. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/urlpattern.cjs +902 -0
  251. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/urlpattern.mjs +902 -0
  252. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/urlpattern.mjs.map +1 -0
  253. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/index.cjs +6 -0
  254. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/index.mjs +8 -0
  255. package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/index.mjs.map +1 -0
  256. package/dist/path-utils.cjs +2 -1
  257. package/dist/path-utils.d.cts +50 -0
  258. package/dist/path-utils.d.cts.map +1 -0
  259. package/dist/path-utils.d.mts +50 -0
  260. package/dist/path-utils.d.mts.map +1 -0
  261. package/dist/path-utils.mjs +1 -1
  262. package/dist/repl.cjs +485 -0
  263. package/dist/repl.d.cts +15 -0
  264. package/dist/repl.d.cts.map +1 -0
  265. package/dist/repl.d.mts +16 -0
  266. package/dist/repl.d.mts.map +1 -0
  267. package/dist/repl.mjs +485 -0
  268. package/dist/repl.mjs.map +1 -0
  269. package/dist/serve.cjs +146 -0
  270. package/dist/serve.d.cts +41 -0
  271. package/dist/serve.d.cts.map +1 -0
  272. package/dist/serve.d.mts +41 -0
  273. package/dist/serve.d.mts.map +1 -0
  274. package/dist/serve.mjs +146 -0
  275. package/dist/serve.mjs.map +1 -0
  276. package/dist/ui/header.cjs +1 -49
  277. package/dist/ui/header.mjs +1 -47
  278. package/dist/ui/header.mjs.map +1 -1
  279. package/dist/ui/index.cjs +2 -11
  280. package/dist/ui/index.mjs +2 -8
  281. package/dist/ui/index.mjs.map +1 -1
  282. package/dist/ui/terminal.cjs +1 -10
  283. package/dist/ui/terminal.mjs +1 -8
  284. package/dist/ui/terminal.mjs.map +1 -1
  285. package/package.json +32 -9
  286. package/dist/commands/exec.cjs +0 -46
  287. package/dist/commands/exec.mjs +0 -45
  288. package/dist/commands/exec.mjs.map +0 -1
  289. package/dist/commands/explain.cjs +0 -244
  290. package/dist/commands/explain.mjs +0 -242
  291. package/dist/commands/explain.mjs.map +0 -1
  292. package/dist/commands/index.cjs +0 -8
  293. package/dist/commands/index.mjs +0 -10
  294. package/dist/commands/ls.cjs +0 -143
  295. package/dist/commands/ls.mjs +0 -143
  296. package/dist/commands/ls.mjs.map +0 -1
  297. package/dist/commands/mount.mjs.map +0 -1
  298. package/dist/commands/read.cjs +0 -65
  299. package/dist/commands/read.mjs +0 -64
  300. package/dist/commands/read.mjs.map +0 -1
  301. package/dist/commands/serve.cjs +0 -144
  302. package/dist/commands/serve.mjs +0 -143
  303. package/dist/commands/serve.mjs.map +0 -1
  304. package/dist/commands/stat.cjs +0 -113
  305. package/dist/commands/stat.mjs +0 -112
  306. package/dist/commands/stat.mjs.map +0 -1
  307. package/dist/commands/write.cjs +0 -52
  308. package/dist/commands/write.mjs +0 -51
  309. package/dist/commands/write.mjs.map +0 -1
  310. package/dist/config/provider-factory.cjs +0 -93
  311. package/dist/config/provider-factory.mjs +0 -94
  312. package/dist/config/provider-factory.mjs.map +0 -1
  313. package/dist/config/uri-parser.cjs +0 -92
  314. package/dist/config/uri-parser.mjs +0 -92
  315. package/dist/config/uri-parser.mjs.map +0 -1
  316. package/dist/runtime.cjs +0 -96
  317. package/dist/runtime.mjs +0 -96
  318. package/dist/runtime.mjs.map +0 -1
@@ -0,0 +1,24 @@
1
+ import { formatDeleteOutput } from "./formatters/delete.mjs";
2
+ import { formatExecOutput } from "./formatters/exec.mjs";
3
+ import { formatExplainOutput } from "./formatters/explain.mjs";
4
+ import { formatLsOutput } from "./formatters/ls.mjs";
5
+ import { formatMountListOutput } from "./formatters/mount.mjs";
6
+ import { formatReadOutput } from "./formatters/read.mjs";
7
+ import { formatStatOutput } from "./formatters/stat.mjs";
8
+ import { formatWriteOutput } from "./formatters/write.mjs";
9
+ import { cliPathToCanonical, parseCliPath } from "../path-utils.mjs";
10
+ import "./path-utils.mjs";
11
+ import { createDeleteCommand } from "./commands/delete.mjs";
12
+ import { readStdin } from "./helpers/stdin.mjs";
13
+ import { RESERVED_OPTIONS, parseExecArgs, parseExecArgsWithStdin, parseValueBySchema, schemaTypeToYargs } from "./helpers/exec-args.mjs";
14
+ import { createExecCommand } from "./commands/exec.mjs";
15
+ import { createExplainCommand } from "./commands/explain.mjs";
16
+ import { createLsCommand } from "./commands/ls.mjs";
17
+ import { createMountCommand } from "./commands/mount.mjs";
18
+ import { createReadCommand } from "./commands/read.mjs";
19
+ import { createStatCommand } from "./commands/stat.mjs";
20
+ import { createWriteCommand } from "./commands/write.mjs";
21
+ import { commandFactories } from "./commands/index.mjs";
22
+ import { AFSCommandExecutor } from "./executor/index.mjs";
23
+
24
+ export { AFSCommandExecutor, RESERVED_OPTIONS, cliPathToCanonical, commandFactories, createDeleteCommand, createExecCommand, createExplainCommand, createLsCommand, createMountCommand, createReadCommand, createStatCommand, createWriteCommand, formatDeleteOutput, formatExecOutput, formatExplainOutput, formatLsOutput, formatMountListOutput, formatReadOutput, formatStatOutput, formatWriteOutput, parseCliPath, parseExecArgs, parseExecArgsWithStdin, parseValueBySchema, readStdin, schemaTypeToYargs };
@@ -0,0 +1 @@
1
+ const require_path_utils = require('../path-utils.cjs');
@@ -0,0 +1,3 @@
1
+ import { cliPathToCanonical, parseCliPath } from "../path-utils.mjs";
2
+
3
+ export { };
@@ -0,0 +1,24 @@
1
+ //#region src/core/types.d.ts
2
+ /**
3
+ * CLI Core Types
4
+ *
5
+ * Minimal type definitions for the core CLI layer.
6
+ * Uses AFS native types (AFSListResult, AFSReadResult, etc.) directly.
7
+ */
8
+ type ViewType = "default" | "json" | "yaml" | "llm" | "human";
9
+ /**
10
+ * Simplified JSON Schema type for CLI parameter parsing
11
+ */
12
+ interface JSONSchema {
13
+ type?: "string" | "number" | "integer" | "boolean" | "array" | "object" | "null";
14
+ properties?: Record<string, JSONSchema>;
15
+ items?: JSONSchema;
16
+ required?: string[];
17
+ description?: string;
18
+ default?: unknown;
19
+ enum?: unknown[];
20
+ [key: string]: unknown;
21
+ }
22
+ //#endregion
23
+ export { JSONSchema, ViewType };
24
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/core/types.ts"],"mappings":";;AAWA;;;;;KAAY,QAAA;;;;UASK,UAAA;EACf,IAAA;EACA,UAAA,GAAa,MAAA,SAAe,UAAA;EAC5B,KAAA,GAAQ,UAAA;EACR,QAAA;EACA,WAAA;EACA,OAAA;EACA,IAAA;EAAA,CACC,GAAA;AAAA"}
@@ -0,0 +1,24 @@
1
+ //#region src/core/types.d.ts
2
+ /**
3
+ * CLI Core Types
4
+ *
5
+ * Minimal type definitions for the core CLI layer.
6
+ * Uses AFS native types (AFSListResult, AFSReadResult, etc.) directly.
7
+ */
8
+ type ViewType = "default" | "json" | "yaml" | "llm" | "human";
9
+ /**
10
+ * Simplified JSON Schema type for CLI parameter parsing
11
+ */
12
+ interface JSONSchema {
13
+ type?: "string" | "number" | "integer" | "boolean" | "array" | "object" | "null";
14
+ properties?: Record<string, JSONSchema>;
15
+ items?: JSONSchema;
16
+ required?: string[];
17
+ description?: string;
18
+ default?: unknown;
19
+ enum?: unknown[];
20
+ [key: string]: unknown;
21
+ }
22
+ //#endregion
23
+ export { JSONSchema, ViewType };
24
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/core/types.ts"],"mappings":";;AAWA;;;;;KAAY,QAAA;;;;UASK,UAAA;EACf,IAAA;EACA,UAAA,GAAa,MAAA,SAAe,UAAA;EAC5B,KAAA,GAAQ,UAAA;EACR,QAAA;EACA,WAAA;EACA,OAAA;EACA,IAAA;EAAA,CACC,GAAA;AAAA"}
package/dist/errors.cjs CHANGED
@@ -13,17 +13,6 @@ const ExitCode = {
13
13
  PARTIAL: 4,
14
14
  RUNTIME_ERROR: 5
15
15
  };
16
- /**
17
- * CLI Error with exit code
18
- */
19
- var CLIError = class extends Error {
20
- constructor(message, exitCode = ExitCode.RUNTIME_ERROR) {
21
- super(message);
22
- this.exitCode = exitCode;
23
- this.name = "CLIError";
24
- }
25
- };
26
16
 
27
17
  //#endregion
28
- exports.CLIError = CLIError;
29
18
  exports.ExitCode = ExitCode;
package/dist/errors.mjs CHANGED
@@ -12,17 +12,7 @@ const ExitCode = {
12
12
  PARTIAL: 4,
13
13
  RUNTIME_ERROR: 5
14
14
  };
15
- /**
16
- * CLI Error with exit code
17
- */
18
- var CLIError = class extends Error {
19
- constructor(message, exitCode = ExitCode.RUNTIME_ERROR) {
20
- super(message);
21
- this.exitCode = exitCode;
22
- this.name = "CLIError";
23
- }
24
- };
25
15
 
26
16
  //#endregion
27
- export { CLIError, ExitCode };
17
+ export { ExitCode };
28
18
  //# sourceMappingURL=errors.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * AFS CLI Exit Codes\n *\n * Exit codes are part of the protocol - agents and scripts depend on them.\n */\nexport const ExitCode = {\n /** Operation successful */\n OK: 0,\n /** Path or resource not found */\n NOT_FOUND: 1,\n /** Permission denied */\n PERMISSION_DENIED: 2,\n /** Conflict (e.g., concurrent modification) */\n CONFLICT: 3,\n /** Partial success (some operations succeeded, some failed) */\n PARTIAL: 4,\n /** Runtime error */\n RUNTIME_ERROR: 5,\n} as const;\n\nexport type ExitCodeType = (typeof ExitCode)[keyof typeof ExitCode];\n\n/**\n * CLI Error with exit code\n */\nexport class CLIError extends Error {\n constructor(\n message: string,\n public exitCode: ExitCodeType = ExitCode.RUNTIME_ERROR,\n ) {\n super(message);\n this.name = \"CLIError\";\n }\n}\n\n/**\n * Not found error\n */\nexport class NotFoundError extends CLIError {\n constructor(message: string) {\n super(message, ExitCode.NOT_FOUND);\n this.name = \"NotFoundError\";\n }\n}\n\n/**\n * Permission denied error\n */\nexport class PermissionDeniedError extends CLIError {\n constructor(message: string) {\n super(message, ExitCode.PERMISSION_DENIED);\n this.name = \"PermissionDeniedError\";\n }\n}\n"],"mappings":";;;;;;AAKA,MAAa,WAAW;CAEtB,IAAI;CAEJ,WAAW;CAEX,mBAAmB;CAEnB,UAAU;CAEV,SAAS;CAET,eAAe;CAChB;;;;AAOD,IAAa,WAAb,cAA8B,MAAM;CAClC,YACE,SACA,AAAO,WAAyB,SAAS,eACzC;AACA,QAAM,QAAQ;EAFP;AAGP,OAAK,OAAO"}
1
+ {"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * AFS CLI Exit Codes\n *\n * Exit codes are part of the protocol - agents and scripts depend on them.\n */\nexport const ExitCode = {\n /** Operation successful */\n OK: 0,\n /** Path or resource not found */\n NOT_FOUND: 1,\n /** Permission denied */\n PERMISSION_DENIED: 2,\n /** Conflict (e.g., concurrent modification) */\n CONFLICT: 3,\n /** Partial success (some operations succeeded, some failed) */\n PARTIAL: 4,\n /** Runtime error */\n RUNTIME_ERROR: 5,\n} as const;\n\nexport type ExitCodeType = (typeof ExitCode)[keyof typeof ExitCode];\n\n/**\n * CLI Error with exit code\n */\nexport class CLIError extends Error {\n constructor(\n message: string,\n public exitCode: ExitCodeType = ExitCode.RUNTIME_ERROR,\n ) {\n super(message);\n this.name = \"CLIError\";\n }\n}\n\n/**\n * Not found error\n */\nexport class NotFoundError extends CLIError {\n constructor(message: string) {\n super(message, ExitCode.NOT_FOUND);\n this.name = \"NotFoundError\";\n }\n}\n\n/**\n * Permission denied error\n */\nexport class PermissionDeniedError extends CLIError {\n constructor(message: string) {\n super(message, ExitCode.PERMISSION_DENIED);\n this.name = \"PermissionDeniedError\";\n }\n}\n"],"mappings":";;;;;;AAKA,MAAa,WAAW;CAEtB,IAAI;CAEJ,WAAW;CAEX,mBAAmB;CAEnB,UAAU;CAEV,SAAS;CAET,eAAe;CAChB"}
@@ -1,17 +1,41 @@
1
1
 
2
2
  //#region src/explorer/actions.ts
3
3
  /**
4
+ * Check if an entry is executable based on its meta
5
+ */
6
+ function isExecutable(meta) {
7
+ if (!meta) return false;
8
+ if (Array.isArray(meta.kinds)) return meta.kinds.includes("afs:executable");
9
+ return meta.kind === "afs:executable";
10
+ }
11
+ /**
12
+ * Check if a value is a valid directory-indicating childrenCount
13
+ *
14
+ * Per Provider Protocol spec:
15
+ * - childrenCount > 0: known children → directory
16
+ * - childrenCount = -1: unknown children count → directory
17
+ * - childrenCount = 0 or undefined: leaf node → file
18
+ */
19
+ function isDirectory(childrenCount) {
20
+ if (typeof childrenCount !== "number" || Number.isNaN(childrenCount)) return false;
21
+ return childrenCount === -1 || childrenCount > 0;
22
+ }
23
+ /**
4
24
  * Convert AFS entry to explorer entry
25
+ *
26
+ * Type determination priority:
27
+ * 1. afs:executable → exec
28
+ * 2. afs:link → link
29
+ * 3. childrenCount > 0 or -1 → directory
30
+ * 4. Otherwise (childrenCount = 0, undefined, invalid) → file
5
31
  */
6
32
  function toExplorerEntry(entry, _basePath) {
7
33
  const name = entry.path.split("/").pop() || entry.path;
8
- const metadata = entry.metadata || {};
9
- const entryType = entry.type || metadata.type;
34
+ const metadata = entry.meta || {};
10
35
  let type = "file";
11
- if (entryType === "directory" || entryType === "module") type = "directory";
12
- else if (entryType === "exec") type = "exec";
13
- else if (entryType === "link") type = "link";
14
- else if (metadata.childrenCount !== void 0 || entry.path === "/modules" || entry.path.startsWith("/modules/") && !entry.path.includes(".")) type = "directory";
36
+ if (isExecutable(metadata)) type = "exec";
37
+ else if (metadata.kind === "afs:link" || metadata.kinds?.includes("afs:link")) type = "link";
38
+ else if (isDirectory(metadata.childrenCount)) type = "directory";
15
39
  return {
16
40
  name,
17
41
  path: entry.path,
@@ -21,7 +45,13 @@ function toExplorerEntry(entry, _basePath) {
21
45
  childrenCount: metadata.childrenCount,
22
46
  hash: metadata.hash,
23
47
  description: metadata.description,
24
- provider: metadata.provider
48
+ provider: metadata.provider,
49
+ icon: metadata.icon,
50
+ kind: metadata.kind,
51
+ kinds: Array.isArray(metadata.kinds) ? metadata.kinds : void 0,
52
+ label: metadata.label,
53
+ tags: Array.isArray(metadata.tags) ? metadata.tags : void 0,
54
+ actions: entry.actions
25
55
  };
26
56
  }
27
57
  /**
@@ -35,20 +65,43 @@ function createUpEntry(parentPath) {
35
65
  };
36
66
  }
37
67
  /**
68
+ * Build immediate children from a list of deep paths
69
+ * For example, if path is "/" and entries contain "/github/ArcBlock/afs",
70
+ * this returns a virtual directory entry for "/github"
71
+ */
72
+ function buildImmediateChildren(path, afsEntries) {
73
+ const normalizedPath = path === "/" ? "" : path;
74
+ const pathDepth = normalizedPath === "" ? 0 : normalizedPath.split("/").filter(Boolean).length;
75
+ const childrenMap = /* @__PURE__ */ new Map();
76
+ for (const entry of afsEntries) {
77
+ if (entry.path === path) continue;
78
+ const entryParts = entry.path.split("/").filter(Boolean);
79
+ const childName = entryParts[pathDepth];
80
+ if (!childName) continue;
81
+ const childPath = `/${entryParts.slice(0, pathDepth + 1).join("/")}`;
82
+ if (entryParts.length === pathDepth + 1) childrenMap.set(childName, toExplorerEntry(entry, path));
83
+ else if (!childrenMap.has(childName)) childrenMap.set(childName, {
84
+ name: childName,
85
+ path: childPath,
86
+ type: "directory",
87
+ childrenCount: -1
88
+ });
89
+ }
90
+ return childrenMap;
91
+ }
92
+ /**
38
93
  * Load directory entries from AFS
39
94
  */
40
- async function loadDirectory(runtime, path) {
95
+ async function loadDirectory(afs, path) {
41
96
  try {
42
- const result = await runtime.list(path, { maxDepth: 1 });
97
+ const result = await afs.list(path, { maxDepth: 1 });
43
98
  const entries = [];
44
99
  if (path !== "/") {
45
100
  const parentPath = path.split("/").slice(0, -1).join("/") || "/";
46
101
  entries.push(createUpEntry(parentPath));
47
102
  }
48
- for (const entry of result.data) {
49
- if (entry.path === path) continue;
50
- entries.push(toExplorerEntry(entry, path));
51
- }
103
+ const childrenMap = buildImmediateChildren(path, result.data);
104
+ entries.push(...childrenMap.values());
52
105
  entries.sort((a, b) => {
53
106
  if (a.type === "up") return -1;
54
107
  if (b.type === "up") return 1;
@@ -67,37 +120,35 @@ async function loadDirectory(runtime, path) {
67
120
  }
68
121
  }
69
122
  /**
70
- * Load metadata for an entry
123
+ * Load metadata for an entry using stat() to get enriched data (including actions)
71
124
  */
72
- async function loadMetadata(runtime, entry) {
125
+ async function loadMetadata(afs, entry) {
73
126
  if (entry.type === "up") return;
74
127
  try {
75
- const afsEntry = (await runtime.list(entry.path, { maxDepth: 0 })).data[0];
76
- if (!afsEntry) return {
128
+ const data = (await afs.stat(entry.path)).data;
129
+ if (!data) return {
77
130
  path: entry.path,
78
- type: entry.type,
79
131
  size: entry.size,
80
132
  modified: entry.modified
81
133
  };
82
- const metadata = afsEntry.metadata || {};
134
+ const meta = data.meta || {};
83
135
  return {
84
136
  path: entry.path,
85
- type: entry.type,
86
- size: metadata.size,
87
- modified: afsEntry.updatedAt instanceof Date ? afsEntry.updatedAt : void 0,
88
- childrenCount: metadata.childrenCount,
89
- hash: metadata.hash,
90
- description: metadata.description,
91
- provider: metadata.provider,
92
- mountPath: metadata.mountPath,
93
- uri: metadata.uri,
94
- permissions: metadata.permissions,
95
- extra: metadata
137
+ size: meta.size,
138
+ modified: data.updatedAt instanceof Date ? data.updatedAt : void 0,
139
+ childrenCount: meta.childrenCount,
140
+ hash: meta.hash,
141
+ description: meta.description,
142
+ provider: meta.provider,
143
+ mountPath: meta.mountPath,
144
+ uri: meta.uri,
145
+ permissions: meta.permissions,
146
+ actions: data.actions,
147
+ extra: meta
96
148
  };
97
149
  } catch {
98
150
  return {
99
151
  path: entry.path,
100
- type: entry.type,
101
152
  size: entry.size,
102
153
  modified: entry.modified
103
154
  };
@@ -106,20 +157,17 @@ async function loadMetadata(runtime, entry) {
106
157
  /**
107
158
  * Get explain output for an entry
108
159
  */
109
- async function getExplain(runtime, path) {
160
+ async function getExplain(afs, path) {
110
161
  try {
111
- const entry = (await runtime.list(path, { maxDepth: 0 })).data[0];
162
+ const entry = (await afs.list(path, { maxDepth: 0 })).data[0];
112
163
  if (!entry) return {
113
164
  content: "",
114
165
  error: "Entry not found"
115
166
  };
116
- const metadata = entry.metadata || {};
167
+ const metadata = entry.meta || {};
117
168
  const lines = [];
118
169
  lines.push(`OBJECT ${path}`);
119
170
  lines.push("");
120
- lines.push("TYPE");
121
- lines.push(metadata.type || "unknown");
122
- lines.push("");
123
171
  if (metadata.description) {
124
172
  lines.push("DESCRIPTION");
125
173
  lines.push(metadata.description);
@@ -156,31 +204,48 @@ async function getExplain(runtime, path) {
156
204
  /**
157
205
  * Execute an action on an entry
158
206
  *
159
- * Note: The AFSRuntime doesn't currently expose exec functionality.
160
- * This is a placeholder that returns a "not available" message.
207
+ * For executable entries (kinds includes "afs:executable"), this calls
208
+ * the underlying exec command. The action parameter is currently not used
209
+ * but reserved for future action selection.
161
210
  */
162
- async function executeAction(_runtime, path, action, _params) {
163
- return {
164
- success: false,
165
- message: `Action '${action}' on '${path}' is not available in the explorer`
166
- };
211
+ async function executeAction(afs, path, _action, params) {
212
+ try {
213
+ const result = await afs.exec(path, params || {}, {});
214
+ return {
215
+ success: result.success,
216
+ message: result.error?.message,
217
+ data: result.data
218
+ };
219
+ } catch (error) {
220
+ return {
221
+ success: false,
222
+ message: error instanceof Error ? error.message : String(error)
223
+ };
224
+ }
167
225
  }
168
226
  /**
169
227
  * Read file content
170
228
  */
171
- async function readFileContent(runtime, path) {
229
+ async function readFileContent(afs, path) {
172
230
  try {
173
- const entry = (await runtime.read(path)).data;
231
+ const entry = (await afs.read(path)).data;
174
232
  if (!entry) return {
175
233
  content: "",
176
234
  error: "File not found"
177
235
  };
178
236
  const rawContent = entry.content;
179
- if (rawContent === void 0) return {
237
+ if (rawContent === void 0 || rawContent === null) return {
180
238
  content: "",
181
239
  error: "No content available"
182
240
  };
183
- return { content: typeof rawContent === "string" ? rawContent : Buffer.from(rawContent).toString("utf-8") };
241
+ let content;
242
+ if (typeof rawContent === "string") content = rawContent;
243
+ else if (Buffer.isBuffer(rawContent)) content = rawContent.toString("utf-8");
244
+ else if (rawContent instanceof Uint8Array) content = Buffer.from(rawContent).toString("utf-8");
245
+ else if (rawContent instanceof ArrayBuffer) content = Buffer.from(new Uint8Array(rawContent)).toString("utf-8");
246
+ else if (typeof rawContent === "object") content = JSON.stringify(rawContent, null, 2);
247
+ else content = String(rawContent);
248
+ return { content };
184
249
  } catch (error) {
185
250
  return {
186
251
  content: "",
@@ -1,16 +1,40 @@
1
1
  //#region src/explorer/actions.ts
2
2
  /**
3
+ * Check if an entry is executable based on its meta
4
+ */
5
+ function isExecutable(meta) {
6
+ if (!meta) return false;
7
+ if (Array.isArray(meta.kinds)) return meta.kinds.includes("afs:executable");
8
+ return meta.kind === "afs:executable";
9
+ }
10
+ /**
11
+ * Check if a value is a valid directory-indicating childrenCount
12
+ *
13
+ * Per Provider Protocol spec:
14
+ * - childrenCount > 0: known children → directory
15
+ * - childrenCount = -1: unknown children count → directory
16
+ * - childrenCount = 0 or undefined: leaf node → file
17
+ */
18
+ function isDirectory(childrenCount) {
19
+ if (typeof childrenCount !== "number" || Number.isNaN(childrenCount)) return false;
20
+ return childrenCount === -1 || childrenCount > 0;
21
+ }
22
+ /**
3
23
  * Convert AFS entry to explorer entry
24
+ *
25
+ * Type determination priority:
26
+ * 1. afs:executable → exec
27
+ * 2. afs:link → link
28
+ * 3. childrenCount > 0 or -1 → directory
29
+ * 4. Otherwise (childrenCount = 0, undefined, invalid) → file
4
30
  */
5
31
  function toExplorerEntry(entry, _basePath) {
6
32
  const name = entry.path.split("/").pop() || entry.path;
7
- const metadata = entry.metadata || {};
8
- const entryType = entry.type || metadata.type;
33
+ const metadata = entry.meta || {};
9
34
  let type = "file";
10
- if (entryType === "directory" || entryType === "module") type = "directory";
11
- else if (entryType === "exec") type = "exec";
12
- else if (entryType === "link") type = "link";
13
- else if (metadata.childrenCount !== void 0 || entry.path === "/modules" || entry.path.startsWith("/modules/") && !entry.path.includes(".")) type = "directory";
35
+ if (isExecutable(metadata)) type = "exec";
36
+ else if (metadata.kind === "afs:link" || metadata.kinds?.includes("afs:link")) type = "link";
37
+ else if (isDirectory(metadata.childrenCount)) type = "directory";
14
38
  return {
15
39
  name,
16
40
  path: entry.path,
@@ -20,7 +44,13 @@ function toExplorerEntry(entry, _basePath) {
20
44
  childrenCount: metadata.childrenCount,
21
45
  hash: metadata.hash,
22
46
  description: metadata.description,
23
- provider: metadata.provider
47
+ provider: metadata.provider,
48
+ icon: metadata.icon,
49
+ kind: metadata.kind,
50
+ kinds: Array.isArray(metadata.kinds) ? metadata.kinds : void 0,
51
+ label: metadata.label,
52
+ tags: Array.isArray(metadata.tags) ? metadata.tags : void 0,
53
+ actions: entry.actions
24
54
  };
25
55
  }
26
56
  /**
@@ -34,20 +64,43 @@ function createUpEntry(parentPath) {
34
64
  };
35
65
  }
36
66
  /**
67
+ * Build immediate children from a list of deep paths
68
+ * For example, if path is "/" and entries contain "/github/ArcBlock/afs",
69
+ * this returns a virtual directory entry for "/github"
70
+ */
71
+ function buildImmediateChildren(path, afsEntries) {
72
+ const normalizedPath = path === "/" ? "" : path;
73
+ const pathDepth = normalizedPath === "" ? 0 : normalizedPath.split("/").filter(Boolean).length;
74
+ const childrenMap = /* @__PURE__ */ new Map();
75
+ for (const entry of afsEntries) {
76
+ if (entry.path === path) continue;
77
+ const entryParts = entry.path.split("/").filter(Boolean);
78
+ const childName = entryParts[pathDepth];
79
+ if (!childName) continue;
80
+ const childPath = `/${entryParts.slice(0, pathDepth + 1).join("/")}`;
81
+ if (entryParts.length === pathDepth + 1) childrenMap.set(childName, toExplorerEntry(entry, path));
82
+ else if (!childrenMap.has(childName)) childrenMap.set(childName, {
83
+ name: childName,
84
+ path: childPath,
85
+ type: "directory",
86
+ childrenCount: -1
87
+ });
88
+ }
89
+ return childrenMap;
90
+ }
91
+ /**
37
92
  * Load directory entries from AFS
38
93
  */
39
- async function loadDirectory(runtime, path) {
94
+ async function loadDirectory(afs, path) {
40
95
  try {
41
- const result = await runtime.list(path, { maxDepth: 1 });
96
+ const result = await afs.list(path, { maxDepth: 1 });
42
97
  const entries = [];
43
98
  if (path !== "/") {
44
99
  const parentPath = path.split("/").slice(0, -1).join("/") || "/";
45
100
  entries.push(createUpEntry(parentPath));
46
101
  }
47
- for (const entry of result.data) {
48
- if (entry.path === path) continue;
49
- entries.push(toExplorerEntry(entry, path));
50
- }
102
+ const childrenMap = buildImmediateChildren(path, result.data);
103
+ entries.push(...childrenMap.values());
51
104
  entries.sort((a, b) => {
52
105
  if (a.type === "up") return -1;
53
106
  if (b.type === "up") return 1;
@@ -66,37 +119,35 @@ async function loadDirectory(runtime, path) {
66
119
  }
67
120
  }
68
121
  /**
69
- * Load metadata for an entry
122
+ * Load metadata for an entry using stat() to get enriched data (including actions)
70
123
  */
71
- async function loadMetadata(runtime, entry) {
124
+ async function loadMetadata(afs, entry) {
72
125
  if (entry.type === "up") return;
73
126
  try {
74
- const afsEntry = (await runtime.list(entry.path, { maxDepth: 0 })).data[0];
75
- if (!afsEntry) return {
127
+ const data = (await afs.stat(entry.path)).data;
128
+ if (!data) return {
76
129
  path: entry.path,
77
- type: entry.type,
78
130
  size: entry.size,
79
131
  modified: entry.modified
80
132
  };
81
- const metadata = afsEntry.metadata || {};
133
+ const meta = data.meta || {};
82
134
  return {
83
135
  path: entry.path,
84
- type: entry.type,
85
- size: metadata.size,
86
- modified: afsEntry.updatedAt instanceof Date ? afsEntry.updatedAt : void 0,
87
- childrenCount: metadata.childrenCount,
88
- hash: metadata.hash,
89
- description: metadata.description,
90
- provider: metadata.provider,
91
- mountPath: metadata.mountPath,
92
- uri: metadata.uri,
93
- permissions: metadata.permissions,
94
- extra: metadata
136
+ size: meta.size,
137
+ modified: data.updatedAt instanceof Date ? data.updatedAt : void 0,
138
+ childrenCount: meta.childrenCount,
139
+ hash: meta.hash,
140
+ description: meta.description,
141
+ provider: meta.provider,
142
+ mountPath: meta.mountPath,
143
+ uri: meta.uri,
144
+ permissions: meta.permissions,
145
+ actions: data.actions,
146
+ extra: meta
95
147
  };
96
148
  } catch {
97
149
  return {
98
150
  path: entry.path,
99
- type: entry.type,
100
151
  size: entry.size,
101
152
  modified: entry.modified
102
153
  };
@@ -105,20 +156,17 @@ async function loadMetadata(runtime, entry) {
105
156
  /**
106
157
  * Get explain output for an entry
107
158
  */
108
- async function getExplain(runtime, path) {
159
+ async function getExplain(afs, path) {
109
160
  try {
110
- const entry = (await runtime.list(path, { maxDepth: 0 })).data[0];
161
+ const entry = (await afs.list(path, { maxDepth: 0 })).data[0];
111
162
  if (!entry) return {
112
163
  content: "",
113
164
  error: "Entry not found"
114
165
  };
115
- const metadata = entry.metadata || {};
166
+ const metadata = entry.meta || {};
116
167
  const lines = [];
117
168
  lines.push(`OBJECT ${path}`);
118
169
  lines.push("");
119
- lines.push("TYPE");
120
- lines.push(metadata.type || "unknown");
121
- lines.push("");
122
170
  if (metadata.description) {
123
171
  lines.push("DESCRIPTION");
124
172
  lines.push(metadata.description);
@@ -155,31 +203,48 @@ async function getExplain(runtime, path) {
155
203
  /**
156
204
  * Execute an action on an entry
157
205
  *
158
- * Note: The AFSRuntime doesn't currently expose exec functionality.
159
- * This is a placeholder that returns a "not available" message.
206
+ * For executable entries (kinds includes "afs:executable"), this calls
207
+ * the underlying exec command. The action parameter is currently not used
208
+ * but reserved for future action selection.
160
209
  */
161
- async function executeAction(_runtime, path, action, _params) {
162
- return {
163
- success: false,
164
- message: `Action '${action}' on '${path}' is not available in the explorer`
165
- };
210
+ async function executeAction(afs, path, _action, params) {
211
+ try {
212
+ const result = await afs.exec(path, params || {}, {});
213
+ return {
214
+ success: result.success,
215
+ message: result.error?.message,
216
+ data: result.data
217
+ };
218
+ } catch (error) {
219
+ return {
220
+ success: false,
221
+ message: error instanceof Error ? error.message : String(error)
222
+ };
223
+ }
166
224
  }
167
225
  /**
168
226
  * Read file content
169
227
  */
170
- async function readFileContent(runtime, path) {
228
+ async function readFileContent(afs, path) {
171
229
  try {
172
- const entry = (await runtime.read(path)).data;
230
+ const entry = (await afs.read(path)).data;
173
231
  if (!entry) return {
174
232
  content: "",
175
233
  error: "File not found"
176
234
  };
177
235
  const rawContent = entry.content;
178
- if (rawContent === void 0) return {
236
+ if (rawContent === void 0 || rawContent === null) return {
179
237
  content: "",
180
238
  error: "No content available"
181
239
  };
182
- return { content: typeof rawContent === "string" ? rawContent : Buffer.from(rawContent).toString("utf-8") };
240
+ let content;
241
+ if (typeof rawContent === "string") content = rawContent;
242
+ else if (Buffer.isBuffer(rawContent)) content = rawContent.toString("utf-8");
243
+ else if (rawContent instanceof Uint8Array) content = Buffer.from(rawContent).toString("utf-8");
244
+ else if (rawContent instanceof ArrayBuffer) content = Buffer.from(new Uint8Array(rawContent)).toString("utf-8");
245
+ else if (typeof rawContent === "object") content = JSON.stringify(rawContent, null, 2);
246
+ else content = String(rawContent);
247
+ return { content };
183
248
  } catch (error) {
184
249
  return {
185
250
  content: "",