@datename/fastcode-termux 0.0.0-stage → 0.1.6-beta

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 (347) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +418 -2
  3. package/bin/fastcode.mjs +59 -0
  4. package/dist/agent/approval.d.ts +50 -0
  5. package/dist/agent/approval.js +7 -0
  6. package/dist/agent/compaction.d.ts +39 -0
  7. package/dist/agent/compaction.js +227 -0
  8. package/dist/agent/context.d.ts +29 -0
  9. package/dist/agent/context.js +62 -0
  10. package/dist/agent/guards.d.ts +43 -0
  11. package/dist/agent/guards.js +269 -0
  12. package/dist/agent/ignore.d.ts +11 -0
  13. package/dist/agent/ignore.js +129 -0
  14. package/dist/agent/limits.d.ts +24 -0
  15. package/dist/agent/limits.js +71 -0
  16. package/dist/agent/process-tree.d.ts +2 -0
  17. package/dist/agent/process-tree.js +31 -0
  18. package/dist/agent/protocol-mode.d.ts +6 -0
  19. package/dist/agent/protocol-mode.js +51 -0
  20. package/dist/agent/protocol.d.ts +4 -0
  21. package/dist/agent/protocol.js +129 -0
  22. package/dist/agent/registry.d.ts +17 -0
  23. package/dist/agent/registry.js +90 -0
  24. package/dist/agent/runner.d.ts +106 -0
  25. package/dist/agent/runner.js +352 -0
  26. package/dist/agent/shell-session.d.ts +37 -0
  27. package/dist/agent/shell-session.js +400 -0
  28. package/dist/agent/stream.d.ts +29 -0
  29. package/dist/agent/stream.js +103 -0
  30. package/dist/agent/tool-schemas.d.ts +2 -0
  31. package/dist/agent/tool-schemas.js +63 -0
  32. package/dist/agent/tools/append_file.d.ts +2 -0
  33. package/dist/agent/tools/append_file.js +26 -0
  34. package/dist/agent/tools/apply_patch.d.ts +10 -0
  35. package/dist/agent/tools/apply_patch.js +52 -0
  36. package/dist/agent/tools/copy_file.d.ts +2 -0
  37. package/dist/agent/tools/copy_file.js +30 -0
  38. package/dist/agent/tools/delete_file.d.ts +2 -0
  39. package/dist/agent/tools/delete_file.js +24 -0
  40. package/dist/agent/tools/grep.d.ts +2 -0
  41. package/dist/agent/tools/grep.js +23 -0
  42. package/dist/agent/tools/index.d.ts +2 -0
  43. package/dist/agent/tools/index.js +32 -0
  44. package/dist/agent/tools/list_files.d.ts +2 -0
  45. package/dist/agent/tools/list_files.js +17 -0
  46. package/dist/agent/tools/make_dir.d.ts +2 -0
  47. package/dist/agent/tools/make_dir.js +24 -0
  48. package/dist/agent/tools/move_path.d.ts +2 -0
  49. package/dist/agent/tools/move_path.js +47 -0
  50. package/dist/agent/tools/paths.d.ts +7 -0
  51. package/dist/agent/tools/paths.js +84 -0
  52. package/dist/agent/tools/pwd.d.ts +2 -0
  53. package/dist/agent/tools/pwd.js +10 -0
  54. package/dist/agent/tools/read_file.d.ts +2 -0
  55. package/dist/agent/tools/read_file.js +21 -0
  56. package/dist/agent/tools/read_many.d.ts +2 -0
  57. package/dist/agent/tools/read_many.js +25 -0
  58. package/dist/agent/tools/readers.d.ts +6 -0
  59. package/dist/agent/tools/readers.js +216 -0
  60. package/dist/agent/tools/replace_in_file.d.ts +2 -0
  61. package/dist/agent/tools/replace_in_file.js +30 -0
  62. package/dist/agent/tools/shell.d.ts +2 -0
  63. package/dist/agent/tools/shell.js +48 -0
  64. package/dist/agent/tools/stat_path.d.ts +2 -0
  65. package/dist/agent/tools/stat_path.js +31 -0
  66. package/dist/agent/tools/types.d.ts +39 -0
  67. package/dist/agent/tools/types.js +1 -0
  68. package/dist/agent/tools/validate.d.ts +6 -0
  69. package/dist/agent/tools/validate.js +29 -0
  70. package/dist/agent/tools/write_file.d.ts +2 -0
  71. package/dist/agent/tools/write_file.js +26 -0
  72. package/dist/agent/tools.d.ts +3 -0
  73. package/dist/agent/tools.js +2 -0
  74. package/dist/app.d.ts +4 -0
  75. package/dist/app.js +708 -0
  76. package/dist/cli.d.ts +1 -0
  77. package/dist/cli.js +569 -0
  78. package/dist/commands/about.d.ts +8 -0
  79. package/dist/commands/about.js +16 -0
  80. package/dist/commands/agent.d.ts +11 -0
  81. package/dist/commands/agent.js +18 -0
  82. package/dist/commands/attach.d.ts +9 -0
  83. package/dist/commands/attach.js +15 -0
  84. package/dist/commands/bg.d.ts +7 -0
  85. package/dist/commands/bg.js +9 -0
  86. package/dist/commands/cancel.d.ts +10 -0
  87. package/dist/commands/cancel.js +10 -0
  88. package/dist/commands/clear.d.ts +11 -0
  89. package/dist/commands/clear.js +9 -0
  90. package/dist/commands/compact.d.ts +10 -0
  91. package/dist/commands/compact.js +22 -0
  92. package/dist/commands/config.d.ts +7 -0
  93. package/dist/commands/config.js +24 -0
  94. package/dist/commands/context.d.ts +7 -0
  95. package/dist/commands/context.js +24 -0
  96. package/dist/commands/cost.d.ts +9 -0
  97. package/dist/commands/cost.js +13 -0
  98. package/dist/commands/cwd.d.ts +7 -0
  99. package/dist/commands/cwd.js +7 -0
  100. package/dist/commands/edit.d.ts +10 -0
  101. package/dist/commands/edit.js +36 -0
  102. package/dist/commands/effort.d.ts +25 -0
  103. package/dist/commands/effort.js +48 -0
  104. package/dist/commands/exit.d.ts +9 -0
  105. package/dist/commands/exit.js +8 -0
  106. package/dist/commands/expand.d.ts +10 -0
  107. package/dist/commands/expand.js +8 -0
  108. package/dist/commands/help.d.ts +6 -0
  109. package/dist/commands/help.js +18 -0
  110. package/dist/commands/index.d.ts +9 -0
  111. package/dist/commands/index.js +80 -0
  112. package/dist/commands/jobs.d.ts +7 -0
  113. package/dist/commands/jobs.js +16 -0
  114. package/dist/commands/kill.d.ts +7 -0
  115. package/dist/commands/kill.js +11 -0
  116. package/dist/commands/login.d.ts +18 -0
  117. package/dist/commands/login.js +63 -0
  118. package/dist/commands/logout.d.ts +9 -0
  119. package/dist/commands/logout.js +45 -0
  120. package/dist/commands/model.d.ts +24 -0
  121. package/dist/commands/model.js +50 -0
  122. package/dist/commands/plugin.d.ts +11 -0
  123. package/dist/commands/plugin.js +74 -0
  124. package/dist/commands/provider.d.ts +24 -0
  125. package/dist/commands/provider.js +39 -0
  126. package/dist/commands/reset.d.ts +9 -0
  127. package/dist/commands/reset.js +13 -0
  128. package/dist/commands/skills.d.ts +11 -0
  129. package/dist/commands/skills.js +106 -0
  130. package/dist/commands/steer.d.ts +11 -0
  131. package/dist/commands/steer.js +13 -0
  132. package/dist/commands/system.d.ts +11 -0
  133. package/dist/commands/system.js +20 -0
  134. package/dist/commands/theme.d.ts +11 -0
  135. package/dist/commands/theme.js +22 -0
  136. package/dist/commands/tools.d.ts +7 -0
  137. package/dist/commands/tools.js +29 -0
  138. package/dist/commands/whoami.d.ts +9 -0
  139. package/dist/commands/whoami.js +52 -0
  140. package/dist/config/paths.d.ts +4 -0
  141. package/dist/config/paths.js +59 -0
  142. package/dist/config/store.d.ts +89 -0
  143. package/dist/config/store.js +260 -0
  144. package/dist/config/themes.d.ts +73 -0
  145. package/dist/config/themes.js +77 -0
  146. package/dist/config/trust.d.ts +22 -0
  147. package/dist/config/trust.js +153 -0
  148. package/dist/index.d.ts +1 -0
  149. package/dist/index.js +31 -0
  150. package/dist/lib/diagnostics.d.ts +66 -0
  151. package/dist/lib/diagnostics.js +195 -0
  152. package/dist/lib/http.d.ts +23 -0
  153. package/dist/lib/http.js +128 -0
  154. package/dist/lib/markdown.d.ts +1 -0
  155. package/dist/lib/markdown.js +32 -0
  156. package/dist/lib/model-meta.d.ts +19 -0
  157. package/dist/lib/model-meta.js +113 -0
  158. package/dist/lib/native-tools.d.ts +12 -0
  159. package/dist/lib/native-tools.js +21 -0
  160. package/dist/lib/net.d.ts +33 -0
  161. package/dist/lib/net.js +168 -0
  162. package/dist/lib/pkg.d.ts +5 -0
  163. package/dist/lib/pkg.js +27 -0
  164. package/dist/lib/platform.d.ts +7 -0
  165. package/dist/lib/platform.js +57 -0
  166. package/dist/lib/startup.d.ts +6 -0
  167. package/dist/lib/startup.js +25 -0
  168. package/dist/lib/uiMode.d.ts +2 -0
  169. package/dist/lib/uiMode.js +7 -0
  170. package/dist/patch/apply.d.ts +15 -0
  171. package/dist/patch/apply.js +172 -0
  172. package/dist/patch/parse.d.ts +29 -0
  173. package/dist/patch/parse.js +112 -0
  174. package/dist/patch/plan.d.ts +49 -0
  175. package/dist/patch/plan.js +273 -0
  176. package/dist/plugins/manager.d.ts +23 -0
  177. package/dist/plugins/manager.js +101 -0
  178. package/dist/providers/anthropic.d.ts +22 -0
  179. package/dist/providers/anthropic.js +119 -0
  180. package/dist/providers/custom.d.ts +33 -0
  181. package/dist/providers/custom.js +25 -0
  182. package/dist/providers/deepseek.d.ts +34 -0
  183. package/dist/providers/deepseek.js +16 -0
  184. package/dist/providers/google.d.ts +33 -0
  185. package/dist/providers/google.js +19 -0
  186. package/dist/providers/groq.d.ts +34 -0
  187. package/dist/providers/groq.js +21 -0
  188. package/dist/providers/index.d.ts +10 -0
  189. package/dist/providers/index.js +67 -0
  190. package/dist/providers/mistral.d.ts +34 -0
  191. package/dist/providers/mistral.js +20 -0
  192. package/dist/providers/moonshot.d.ts +34 -0
  193. package/dist/providers/moonshot.js +23 -0
  194. package/dist/providers/ollama.d.ts +33 -0
  195. package/dist/providers/ollama.js +22 -0
  196. package/dist/providers/openai.d.ts +34 -0
  197. package/dist/providers/openai.js +26 -0
  198. package/dist/providers/openaiCompatible.d.ts +26 -0
  199. package/dist/providers/openaiCompatible.js +158 -0
  200. package/dist/providers/openrouter.d.ts +34 -0
  201. package/dist/providers/openrouter.js +27 -0
  202. package/dist/providers/qwen.d.ts +34 -0
  203. package/dist/providers/qwen.js +24 -0
  204. package/dist/providers/xai.d.ts +34 -0
  205. package/dist/providers/xai.js +19 -0
  206. package/dist/providers/zhipu.d.ts +34 -0
  207. package/dist/providers/zhipu.js +24 -0
  208. package/dist/session/log.d.ts +52 -0
  209. package/dist/session/log.js +331 -0
  210. package/dist/session/projection.d.ts +43 -0
  211. package/dist/session/projection.js +257 -0
  212. package/dist/skills/manager.d.ts +18 -0
  213. package/dist/skills/manager.js +201 -0
  214. package/dist/skills/parser.d.ts +18 -0
  215. package/dist/skills/parser.js +65 -0
  216. package/dist/types.d.ts +205 -0
  217. package/dist/types.js +1 -0
  218. package/dist/ui/Banner.d.ts +5 -0
  219. package/dist/ui/Banner.js +65 -0
  220. package/dist/ui/Message.d.ts +1 -0
  221. package/dist/ui/Message.js +24 -0
  222. package/dist/ui/Picker.d.ts +8 -0
  223. package/dist/ui/Picker.js +24 -0
  224. package/dist/ui/Prompt.d.ts +9 -0
  225. package/dist/ui/Prompt.js +38 -0
  226. package/dist/ui/Spinner.d.ts +5 -0
  227. package/dist/ui/Spinner.js +39 -0
  228. package/dist/ui/StatusBar.d.ts +11 -0
  229. package/dist/ui/StatusBar.js +20 -0
  230. package/dist/ui/TrustGate.d.ts +5 -0
  231. package/dist/ui/TrustGate.js +26 -0
  232. package/package.json +96 -4
  233. package/src/agent/approval.ts +47 -0
  234. package/src/agent/compaction.ts +276 -0
  235. package/src/agent/context.ts +97 -0
  236. package/src/agent/guards.ts +270 -0
  237. package/src/agent/ignore.ts +147 -0
  238. package/src/agent/limits.ts +71 -0
  239. package/src/agent/process-tree.ts +32 -0
  240. package/src/agent/protocol-mode.ts +59 -0
  241. package/src/agent/protocol.ts +129 -0
  242. package/src/agent/registry.ts +98 -0
  243. package/src/agent/runner.ts +443 -0
  244. package/src/agent/shell-session.ts +449 -0
  245. package/src/agent/stream.ts +143 -0
  246. package/src/agent/tool-schemas.ts +67 -0
  247. package/src/agent/tools/append_file.ts +28 -0
  248. package/src/agent/tools/apply_patch.ts +54 -0
  249. package/src/agent/tools/copy_file.ts +32 -0
  250. package/src/agent/tools/delete_file.ts +26 -0
  251. package/src/agent/tools/grep.ts +25 -0
  252. package/src/agent/tools/index.ts +34 -0
  253. package/src/agent/tools/list_files.ts +19 -0
  254. package/src/agent/tools/make_dir.ts +26 -0
  255. package/src/agent/tools/move_path.ts +50 -0
  256. package/src/agent/tools/paths.ts +92 -0
  257. package/src/agent/tools/pwd.ts +12 -0
  258. package/src/agent/tools/read_file.ts +23 -0
  259. package/src/agent/tools/read_many.ts +27 -0
  260. package/src/agent/tools/readers.ts +228 -0
  261. package/src/agent/tools/replace_in_file.ts +32 -0
  262. package/src/agent/tools/shell.ts +53 -0
  263. package/src/agent/tools/stat_path.ts +33 -0
  264. package/src/agent/tools/types.ts +42 -0
  265. package/src/agent/tools/validate.ts +35 -0
  266. package/src/agent/tools/write_file.ts +28 -0
  267. package/src/agent/tools.ts +3 -0
  268. package/src/app.ts +708 -0
  269. package/src/cli.ts +335 -0
  270. package/src/commands/about.ts +16 -0
  271. package/src/commands/agent.ts +18 -0
  272. package/src/commands/attach.ts +16 -0
  273. package/src/commands/bg.ts +9 -0
  274. package/src/commands/cancel.ts +10 -0
  275. package/src/commands/clear.ts +9 -0
  276. package/src/commands/compact.ts +23 -0
  277. package/src/commands/config.ts +24 -0
  278. package/src/commands/context.ts +25 -0
  279. package/src/commands/cost.ts +13 -0
  280. package/src/commands/cwd.ts +7 -0
  281. package/src/commands/edit.ts +37 -0
  282. package/src/commands/effort.ts +49 -0
  283. package/src/commands/exit.ts +8 -0
  284. package/src/commands/expand.ts +8 -0
  285. package/src/commands/help.ts +18 -0
  286. package/src/commands/index.ts +80 -0
  287. package/src/commands/jobs.ts +17 -0
  288. package/src/commands/kill.ts +12 -0
  289. package/src/commands/login.ts +63 -0
  290. package/src/commands/logout.ts +45 -0
  291. package/src/commands/model.ts +50 -0
  292. package/src/commands/plugin.ts +74 -0
  293. package/src/commands/provider.ts +39 -0
  294. package/src/commands/reset.ts +13 -0
  295. package/src/commands/skills.ts +106 -0
  296. package/src/commands/steer.ts +13 -0
  297. package/src/commands/system.ts +20 -0
  298. package/src/commands/theme.ts +22 -0
  299. package/src/commands/tools.ts +29 -0
  300. package/src/commands/whoami.ts +52 -0
  301. package/src/config/paths.ts +59 -0
  302. package/src/config/store.ts +293 -0
  303. package/src/config/themes.ts +77 -0
  304. package/src/config/trust.ts +183 -0
  305. package/src/index.ts +31 -0
  306. package/src/lib/diagnostics.ts +195 -0
  307. package/src/lib/http.ts +132 -0
  308. package/src/lib/markdown.ts +32 -0
  309. package/src/lib/model-meta.ts +138 -0
  310. package/src/lib/native-tools.ts +32 -0
  311. package/src/lib/net.ts +204 -0
  312. package/src/lib/pkg.ts +35 -0
  313. package/src/lib/platform.ts +57 -0
  314. package/src/lib/startup.ts +25 -0
  315. package/src/lib/uiMode.ts +7 -0
  316. package/src/patch/apply.ts +194 -0
  317. package/src/patch/parse.ts +131 -0
  318. package/src/patch/plan.ts +317 -0
  319. package/src/plugins/manager.ts +101 -0
  320. package/src/providers/anthropic.ts +119 -0
  321. package/src/providers/custom.ts +25 -0
  322. package/src/providers/deepseek.ts +16 -0
  323. package/src/providers/google.ts +19 -0
  324. package/src/providers/groq.ts +21 -0
  325. package/src/providers/index.ts +68 -0
  326. package/src/providers/mistral.ts +20 -0
  327. package/src/providers/moonshot.ts +23 -0
  328. package/src/providers/ollama.ts +22 -0
  329. package/src/providers/openai.ts +26 -0
  330. package/src/providers/openaiCompatible.ts +158 -0
  331. package/src/providers/openrouter.ts +27 -0
  332. package/src/providers/qwen.ts +24 -0
  333. package/src/providers/xai.ts +19 -0
  334. package/src/providers/zhipu.ts +24 -0
  335. package/src/session/log.ts +374 -0
  336. package/src/session/projection.ts +308 -0
  337. package/src/skills/manager.ts +201 -0
  338. package/src/skills/parser.ts +65 -0
  339. package/src/types.ts +205 -0
  340. package/src/ui/Banner.ts +68 -0
  341. package/src/ui/Message.ts +24 -0
  342. package/src/ui/Picker.ts +24 -0
  343. package/src/ui/Prompt.ts +38 -0
  344. package/src/ui/Spinner.ts +39 -0
  345. package/src/ui/StatusBar.ts +20 -0
  346. package/src/ui/TrustGate.ts +26 -0
  347. package/tsconfig.json +22 -0
@@ -0,0 +1,8 @@
1
+ export declare const aboutCommand: {
2
+ name: string;
3
+ description: string;
4
+ aliases: string[];
5
+ run(): {
6
+ message: string;
7
+ };
8
+ };
@@ -0,0 +1,16 @@
1
+ import { platformLabel } from "../lib/platform.js";
2
+ export const aboutCommand = {
3
+ name: "about",
4
+ description: "Show version, platform, and links.",
5
+ aliases: ["version"],
6
+ run() {
7
+ const lines = [
8
+ `FastCode — multi-LLM TUI coding assistant`,
9
+ `Platform: ${platformLabel()} • Node ${process.version}`,
10
+ ``,
11
+ `GitHub: https://github.com/dateName/fastcode-termux`,
12
+ `Skills: https://skillshub.wtf`,
13
+ ];
14
+ return { message: lines.join("\n") };
15
+ },
16
+ };
@@ -0,0 +1,11 @@
1
+ export declare const agentCommand: {
2
+ name: string;
3
+ description: string;
4
+ run({ args, state, actions }: {
5
+ args: any;
6
+ state: any;
7
+ actions: any;
8
+ }): {
9
+ message: string;
10
+ };
11
+ };
@@ -0,0 +1,18 @@
1
+ export const agentCommand = {
2
+ name: "agent",
3
+ description: "Toggle coding-agent tools. Usage: /agent [on|off|status]",
4
+ run({ args, state, actions }) {
5
+ const sub = (args[0] ?? "status").toLowerCase();
6
+ if (sub === "on") {
7
+ actions.setAgentMode(true);
8
+ return { message: "Agent mode enabled. FastCode can run shell and file tools." };
9
+ }
10
+ if (sub === "off") {
11
+ actions.setAgentMode(false);
12
+ return { message: "Agent mode disabled." };
13
+ }
14
+ return {
15
+ message: `Agent mode: ${state.agentMode ? "on" : "off"}\n\nUse /agent on to let FastCode run local shell and file tools.`,
16
+ };
17
+ },
18
+ };
@@ -0,0 +1,9 @@
1
+ export declare const attachCommand: {
2
+ name: string;
3
+ description: string;
4
+ run({ args }: {
5
+ args: any;
6
+ }): Promise<{
7
+ message: string;
8
+ }>;
9
+ };
@@ -0,0 +1,15 @@
1
+ import { pollShellSession } from "../agent/shell-session.js";
2
+ export const attachCommand = {
3
+ name: "attach",
4
+ description: "Show new output from a background shell session (/attach <id>)",
5
+ async run({ args }) {
6
+ const id = args[0];
7
+ if (!id)
8
+ return { message: "Usage: /attach <session-id> (see /jobs)" };
9
+ const result = await pollShellSession(id, 0);
10
+ if (!result)
11
+ return { message: `Unknown session: ${id}` };
12
+ const status = result.status === "running" ? "running" : `${result.status} (exit ${result.exitCode ?? "?"})`;
13
+ return { message: `[session ${id}] ${status}\n${result.output || "(no new output)"}` };
14
+ },
15
+ };
@@ -0,0 +1,7 @@
1
+ export declare const bgCommand: {
2
+ name: string;
3
+ description: string;
4
+ run(): {
5
+ message: string;
6
+ };
7
+ };
@@ -0,0 +1,9 @@
1
+ export const bgCommand = {
2
+ name: "bg",
3
+ description: "Explain backgrounding (long shell commands auto-background after ~2s)",
4
+ run() {
5
+ return {
6
+ message: "Long shell commands already return a session id after ~2s; use /jobs to list them, /attach <id> for new output, /kill <id> to stop.",
7
+ };
8
+ },
9
+ };
@@ -0,0 +1,10 @@
1
+ export declare const cancelCommand: {
2
+ name: string;
3
+ description: string;
4
+ run({ state, actions }: {
5
+ state: any;
6
+ actions: any;
7
+ }): {
8
+ message: string;
9
+ };
10
+ };
@@ -0,0 +1,10 @@
1
+ export const cancelCommand = {
2
+ name: "cancel",
3
+ description: "Cancel the active agent run (soft keyboard alternative to Esc)",
4
+ run({ state, actions }) {
5
+ if (!state.busy)
6
+ return { message: "Nothing is running." };
7
+ actions.cancelRun();
8
+ return { message: "Cancelling the active run…" };
9
+ },
10
+ };
@@ -0,0 +1,11 @@
1
+ export declare const clearCommand: {
2
+ name: string;
3
+ description: string;
4
+ aliases: string[];
5
+ run({ actions }: {
6
+ actions: any;
7
+ }): {
8
+ message: string;
9
+ silent: boolean;
10
+ };
11
+ };
@@ -0,0 +1,9 @@
1
+ export const clearCommand = {
2
+ name: "clear",
3
+ description: "Clear the current conversation history.",
4
+ aliases: ["cls"],
5
+ run({ actions }) {
6
+ actions.clearHistory();
7
+ return { message: "Conversation cleared.", silent: false };
8
+ },
9
+ };
@@ -0,0 +1,10 @@
1
+ export declare const compactCommand: {
2
+ name: string;
3
+ description: string;
4
+ run({ state, actions }: {
5
+ state: any;
6
+ actions: any;
7
+ }): {
8
+ message: string;
9
+ };
10
+ };
@@ -0,0 +1,22 @@
1
+ import { compactMessages, DEFAULT_COMPACTION_CONFIG } from "../agent/compaction.js";
2
+ import { getModelMeta } from "../lib/model-meta.js";
3
+ export const compactCommand = {
4
+ name: "compact",
5
+ description: "Force local context compaction now",
6
+ run({ state, actions }) {
7
+ const meta = getModelMeta(state.providerId, state.model);
8
+ const result = compactMessages(state.history, { ...DEFAULT_COMPACTION_CONFIG, localThresholdRatio: 0 }, {
9
+ contextWindow: meta.contextWindow,
10
+ providerId: state.providerId,
11
+ model: state.model,
12
+ force: true,
13
+ });
14
+ if (!result.compacted)
15
+ return { message: "Nothing to compact (history is already small)." };
16
+ actions.replaceHistory(result.messages);
17
+ return {
18
+ message: `[context compacted] ${result.beforeTokens} → ${result.afterTokens} tokens (${result.droppedMessages} messages summarized).` +
19
+ (result.summaryFile ? `\nSummary: ${result.summaryFile}` : ""),
20
+ };
21
+ },
22
+ };
@@ -0,0 +1,7 @@
1
+ export declare const configCommand: {
2
+ name: string;
3
+ description: string;
4
+ run(): {
5
+ message: string;
6
+ };
7
+ };
@@ -0,0 +1,24 @@
1
+ import { loadConfig } from "../config/store.js";
2
+ import { getPaths } from "../config/paths.js";
3
+ export const configCommand = {
4
+ name: "config",
5
+ description: "Print effective config & paths.",
6
+ run() {
7
+ const cfg = loadConfig();
8
+ const paths = getPaths();
9
+ const lines = [
10
+ "Config (~/.fastcode/config.json):",
11
+ JSON.stringify(cfg, null, 2),
12
+ "",
13
+ "Paths:",
14
+ ` root: ${paths.root}`,
15
+ ` config: ${paths.config}`,
16
+ ` auth: ${paths.auth}`,
17
+ ` skills: ${paths.skills}`,
18
+ ` plugins: ${paths.plugins}`,
19
+ ` cache: ${paths.cache}`,
20
+ ` sessions: ${paths.sessions}`,
21
+ ];
22
+ return { message: lines.join("\n") };
23
+ },
24
+ };
@@ -0,0 +1,7 @@
1
+ export declare const contextCommand: {
2
+ name: string;
3
+ description: string;
4
+ run(ctx: any): {
5
+ message: string;
6
+ };
7
+ };
@@ -0,0 +1,24 @@
1
+ import { DEFAULT_COMPACTION_CONFIG, heapExceeded, localThresholdTokens } from "../agent/compaction.js";
2
+ import { estMessagesTokens, getModelMeta } from "../lib/model-meta.js";
3
+ export const contextCommand = {
4
+ name: "context",
5
+ description: "Show estimated context tokens, compaction threshold, and heap usage",
6
+ run(ctx) {
7
+ const meta = getModelMeta(ctx.state.providerId, ctx.state.model);
8
+ const tokens = estMessagesTokens(ctx.state.history, {
9
+ providerId: ctx.state.providerId,
10
+ model: ctx.state.model,
11
+ });
12
+ const threshold = localThresholdTokens(DEFAULT_COMPACTION_CONFIG, meta.contextWindow);
13
+ const percent = meta.contextWindow > 0 ? (tokens / meta.contextWindow) * 100 : 0;
14
+ const heapMb = process.memoryUsage().heapUsed / 1024 / 1024;
15
+ return {
16
+ message: [
17
+ `Context: ~${tokens.toLocaleString()} / ${meta.contextWindow.toLocaleString()} tokens (${percent.toFixed(1)}%)`,
18
+ `Compaction threshold: ${threshold.toLocaleString()} tokens (${Math.round(DEFAULT_COMPACTION_CONFIG.localThresholdRatio * 100)}%)`,
19
+ `Heap: ${heapMb.toFixed(1)} MB / ${DEFAULT_COMPACTION_CONFIG.heapLimitMb} MB${heapExceeded(DEFAULT_COMPACTION_CONFIG) ? " [forced compaction]" : ""}`,
20
+ `Messages: ${ctx.state.history.length} · chars/token: ~${meta.charsPerToken}`,
21
+ ].join("\n"),
22
+ };
23
+ },
24
+ };
@@ -0,0 +1,9 @@
1
+ export declare const costCommand: {
2
+ name: string;
3
+ description: string;
4
+ run({ state }: {
5
+ state: any;
6
+ }): {
7
+ message: string;
8
+ };
9
+ };
@@ -0,0 +1,13 @@
1
+ export const costCommand = {
2
+ name: "cost",
3
+ description: "Show approximate cost & token usage for this session.",
4
+ run({ state }) {
5
+ const lines = [
6
+ `Provider: ${state.providerId}`,
7
+ `Model: ${state.model}`,
8
+ `Tokens: ${state.totalInputTokens} in / ${state.totalOutputTokens} out`,
9
+ `Cost: ~$${state.totalCostUsd.toFixed(4)}`,
10
+ ];
11
+ return { message: lines.join("\n") };
12
+ },
13
+ };
@@ -0,0 +1,7 @@
1
+ export declare const cwdCommand: {
2
+ name: string;
3
+ description: string;
4
+ run(): {
5
+ message: string;
6
+ };
7
+ };
@@ -0,0 +1,7 @@
1
+ export const cwdCommand = {
2
+ name: "cwd",
3
+ description: "Show the current agent sandbox root.",
4
+ run() {
5
+ return { message: `Agent sandbox root:\n\n\`${process.cwd()}\`` };
6
+ },
7
+ };
@@ -0,0 +1,10 @@
1
+ export declare const editCommand: {
2
+ name: string;
3
+ description: string;
4
+ run({ state, actions }: {
5
+ state: any;
6
+ actions: any;
7
+ }): {
8
+ message: string;
9
+ };
10
+ };
@@ -0,0 +1,36 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { readFileSync, unlinkSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ export const editCommand = {
6
+ name: "edit",
7
+ description: "Edit the prompt in $EDITOR (works around Ink IME issues on Termux)",
8
+ run({ state, actions }) {
9
+ const file = join(tmpdir(), `fastcode-edit-${Date.now()}.md`);
10
+ writeFileSync(file, state.draft ?? "", "utf8");
11
+ const editor = process.env["EDITOR"] || process.env["VISUAL"] || "nano";
12
+ const wasRaw = Boolean(process.stdin.isTTY && process.stdin.isRaw);
13
+ try {
14
+ if (wasRaw)
15
+ process.stdin.setRawMode(false);
16
+ const result = spawnSync(editor, [file], { stdio: "inherit" });
17
+ if (result.error)
18
+ return { message: `Could not launch ${editor}: ${result.error.message}` };
19
+ const text = readFileSync(file, "utf8").trim();
20
+ if (!text)
21
+ return { message: "Editor closed with no text." };
22
+ actions.setInput(text);
23
+ return { message: "Draft loaded into the prompt; press Enter to send." };
24
+ }
25
+ finally {
26
+ if (wasRaw)
27
+ process.stdin.setRawMode(true);
28
+ try {
29
+ unlinkSync(file);
30
+ }
31
+ catch {
32
+ // temp file may already be gone
33
+ }
34
+ }
35
+ },
36
+ };
@@ -0,0 +1,25 @@
1
+ import type { ReasoningEffort } from "../types.js";
2
+ export declare const effortCommand: {
3
+ name: string;
4
+ description: string;
5
+ run({ args, state, actions }: {
6
+ args: any;
7
+ state: any;
8
+ actions: any;
9
+ }): {
10
+ message: string;
11
+ picker?: undefined;
12
+ } | {
13
+ message: string;
14
+ picker: {
15
+ title: string;
16
+ current: any;
17
+ items: {
18
+ value: ReasoningEffort;
19
+ label: ReasoningEffort;
20
+ hint: string;
21
+ }[];
22
+ onSelect: (value: any) => any;
23
+ };
24
+ };
25
+ };
@@ -0,0 +1,48 @@
1
+ import { getProvider } from "../providers/index.js";
2
+ const EFFORTS = ["auto", "low", "medium", "high", "max"];
3
+ const HINTS = {
4
+ auto: "provider default (send nothing)",
5
+ low: "fast, minimal thinking",
6
+ medium: "balanced",
7
+ high: "deeper reasoning, slower",
8
+ max: "maximum budget where supported",
9
+ };
10
+ export const effortCommand = {
11
+ name: "effort",
12
+ description: "Set thinking effort (auto/low/medium/high/max). Usage: /effort [level]",
13
+ run({ args, state, actions }) {
14
+ const provider = getProvider(state.providerId);
15
+ const supported = provider?.supportsReasoning?.(state.model) ?? false;
16
+ const current = (state.reasoningEffort ?? "auto");
17
+ const apply = (value) => {
18
+ actions.setReasoningEffort(value);
19
+ return describe(value, provider, supported);
20
+ };
21
+ if (args.length > 0) {
22
+ const value = args[0].toLowerCase();
23
+ if (!EFFORTS.includes(value)) {
24
+ return { message: `Unknown effort "${args[0]}". Choose: ${EFFORTS.join(", ")}.` };
25
+ }
26
+ return { message: apply(value) };
27
+ }
28
+ return {
29
+ message: `Thinking effort: ${current}${supported ? "" : " (this provider has no thinking parameter)"}`,
30
+ picker: {
31
+ title: `Thinking effort · ${provider?.label ?? state.providerId}`,
32
+ current,
33
+ items: EFFORTS.map((value) => ({ value, label: value, hint: HINTS[value] })),
34
+ onSelect: (value) => actions.pushSystemMessage(apply(value)),
35
+ },
36
+ };
37
+ },
38
+ };
39
+ function describe(value, provider, supported) {
40
+ if (value === "auto") {
41
+ return "Thinking effort: auto — the provider's default is used (no thinking parameter is sent).";
42
+ }
43
+ if (!supported) {
44
+ return `Thinking effort saved as ${value}, but ${provider?.label ?? "this provider"} does not expose a thinking parameter; ` +
45
+ "requests will omit it. Switch to a reasoning-capable model/provider to use it.";
46
+ }
47
+ return `Thinking effort: ${value}. The next request will carry the provider-specific thinking parameter.`;
48
+ }
@@ -0,0 +1,9 @@
1
+ export declare const exitCommand: {
2
+ name: string;
3
+ description: string;
4
+ aliases: string[];
5
+ run(): {
6
+ message: string;
7
+ quit: boolean;
8
+ };
9
+ };
@@ -0,0 +1,8 @@
1
+ export const exitCommand = {
2
+ name: "exit",
3
+ description: "Quit FastCode.",
4
+ aliases: ["quit", "q"],
5
+ run() {
6
+ return { message: "Bye!", quit: true };
7
+ },
8
+ };
@@ -0,0 +1,10 @@
1
+ export declare const expandCommand: {
2
+ name: string;
3
+ description: string;
4
+ run({ state, actions }: {
5
+ state: any;
6
+ actions: any;
7
+ }): {
8
+ message: string;
9
+ };
10
+ };
@@ -0,0 +1,8 @@
1
+ export const expandCommand = {
2
+ name: "expand",
3
+ description: "Toggle full tool output in the transcript (stable UI defaults to collapsed)",
4
+ run({ state, actions }) {
5
+ actions.setExpanded(!state.expanded);
6
+ return { message: state.expanded ? "Tool output: collapsed." : "Tool output: expanded (new output only)." };
7
+ },
8
+ };
@@ -0,0 +1,6 @@
1
+ export declare const helpCommand: {
2
+ name: string;
3
+ description: string;
4
+ aliases: string[];
5
+ run(): any;
6
+ };
@@ -0,0 +1,18 @@
1
+ import { COMMANDS } from "./index.js";
2
+ export const helpCommand = {
3
+ name: "help",
4
+ description: "Show all available slash commands.",
5
+ aliases: ["h", "?"],
6
+ run() {
7
+ const visible = COMMANDS.filter((c) => !c.hidden);
8
+ const widest = Math.max(...visible.map((c) => c.name.length));
9
+ const lines = [
10
+ "Slash commands — type any of these at the prompt:",
11
+ "",
12
+ ...visible.map((c) => ` /${c.name.padEnd(widest)} ${c.description}`),
13
+ "",
14
+ "Press ESC to cancel a streaming response. Press Ctrl+C twice to quit.",
15
+ ];
16
+ return { message: lines.join("\n") };
17
+ },
18
+ };
@@ -0,0 +1,9 @@
1
+ export declare const COMMANDS: any;
2
+ export declare function findCommand(name: any): any;
3
+ /** Parse a raw input string. Returns undefined if it's not a slash command. */
4
+ export declare function parseSlash(input: any): {
5
+ name: any;
6
+ args: any;
7
+ raw: any;
8
+ };
9
+ export declare function runCommand(cmd: any, ctx: any): Promise<any>;
@@ -0,0 +1,80 @@
1
+ import { agentCommand } from "./agent.js";
2
+ import { cwdCommand } from "./cwd.js";
3
+ import { helpCommand } from "./help.js";
4
+ import { pluginCommand } from "./plugin.js";
5
+ import { toolsCommand } from "./tools.js";
6
+ import { clearCommand } from "./clear.js";
7
+ import { exitCommand } from "./exit.js";
8
+ import { modelCommand } from "./model.js";
9
+ import { providerCommand } from "./provider.js";
10
+ import { effortCommand } from "./effort.js";
11
+ import { loginCommand } from "./login.js";
12
+ import { logoutCommand } from "./logout.js";
13
+ import { skillsCommand } from "./skills.js";
14
+ import { themeCommand } from "./theme.js";
15
+ import { costCommand } from "./cost.js";
16
+ import { resetCommand } from "./reset.js";
17
+ import { systemCommand } from "./system.js";
18
+ import { aboutCommand } from "./about.js";
19
+ import { configCommand } from "./config.js";
20
+ import { whoamiCommand } from "./whoami.js";
21
+ import { contextCommand } from "./context.js";
22
+ import { jobsCommand } from "./jobs.js";
23
+ import { killCommand } from "./kill.js";
24
+ import { cancelCommand } from "./cancel.js";
25
+ import { steerCommand } from "./steer.js";
26
+ import { compactCommand } from "./compact.js";
27
+ import { expandCommand } from "./expand.js";
28
+ import { attachCommand } from "./attach.js";
29
+ import { bgCommand } from "./bg.js";
30
+ import { editCommand } from "./edit.js";
31
+ export const COMMANDS = [
32
+ helpCommand,
33
+ agentCommand,
34
+ toolsCommand,
35
+ cwdCommand,
36
+ pluginCommand,
37
+ clearCommand,
38
+ exitCommand,
39
+ modelCommand,
40
+ providerCommand,
41
+ effortCommand,
42
+ loginCommand,
43
+ logoutCommand,
44
+ skillsCommand,
45
+ themeCommand,
46
+ costCommand,
47
+ resetCommand,
48
+ systemCommand,
49
+ aboutCommand,
50
+ configCommand,
51
+ whoamiCommand,
52
+ contextCommand,
53
+ jobsCommand,
54
+ killCommand,
55
+ cancelCommand,
56
+ steerCommand,
57
+ compactCommand,
58
+ expandCommand,
59
+ attachCommand,
60
+ bgCommand,
61
+ editCommand,
62
+ ];
63
+ export function findCommand(name) {
64
+ const lower = name.toLowerCase();
65
+ return COMMANDS.find((c) => c.name === lower || (c.aliases ?? []).includes(lower));
66
+ }
67
+ /** Parse a raw input string. Returns undefined if it's not a slash command. */
68
+ export function parseSlash(input) {
69
+ const trimmed = input.trim();
70
+ if (!trimmed.startsWith("/"))
71
+ return undefined;
72
+ const tokens = trimmed.slice(1).split(/\s+/);
73
+ const head = tokens.shift() ?? "";
74
+ if (!head)
75
+ return undefined;
76
+ return { name: head, args: tokens, raw: trimmed };
77
+ }
78
+ export async function runCommand(cmd, ctx) {
79
+ return await cmd.run(ctx);
80
+ }
@@ -0,0 +1,7 @@
1
+ export declare const jobsCommand: {
2
+ name: string;
3
+ description: string;
4
+ run(): {
5
+ message: string;
6
+ };
7
+ };
@@ -0,0 +1,16 @@
1
+ import { listShellSessions } from "../agent/shell-session.js";
2
+ export const jobsCommand = {
3
+ name: "jobs",
4
+ description: "List background shell sessions",
5
+ run() {
6
+ const jobs = listShellSessions();
7
+ if (jobs.length === 0)
8
+ return { message: "No shell sessions. Long commands return a session id automatically." };
9
+ const lines = jobs.map((job) => {
10
+ const exit = job.exitCode === undefined || job.exitCode === null ? "" : ` exit=${job.exitCode}`;
11
+ const command = job.command.length > 80 ? job.command.slice(0, 77) + "…" : job.command;
12
+ return `${job.id} ${job.status}${exit} ${(job.bytes / 1024).toFixed(1)}KB ${command}`;
13
+ });
14
+ return { message: ["Shell sessions:", ...lines, "", "Kill one with: /kill <id>"].join("\n") };
15
+ },
16
+ };
@@ -0,0 +1,7 @@
1
+ export declare const killCommand: {
2
+ name: string;
3
+ description: string;
4
+ run(ctx: any): {
5
+ message: string;
6
+ };
7
+ };
@@ -0,0 +1,11 @@
1
+ import { killShellSession } from "../agent/shell-session.js";
2
+ export const killCommand = {
3
+ name: "kill",
4
+ description: "Kill a background shell session (/kill <id>)",
5
+ run(ctx) {
6
+ const id = ctx.args[0];
7
+ if (!id)
8
+ return { message: "Usage: /kill <session-id> (see /jobs)" };
9
+ return { message: killShellSession(id) ? `Killed ${id} (process tree).` : `No running session named ${id}.` };
10
+ },
11
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Save a provider-wide key and describe it for the terminal. `model` is kept
3
+ * for the `/login provider model key` one-liner and only recorded as the
4
+ * credential's origin — the key itself is reused by every model of that
5
+ * provider. Shared by the `/login` command and the guided flow in the app.
6
+ */
7
+ export declare function saveScopedKey(providerId: any, providerLabel: any, model: any, key: any): string;
8
+ export declare const loginCommand: {
9
+ name: string;
10
+ description: string;
11
+ run({ args, state, actions }: {
12
+ args: any;
13
+ state: any;
14
+ actions: any;
15
+ }): {
16
+ message: string;
17
+ };
18
+ };