@datename/fastcode-termux 0.1.6-beta → 0.1.6

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 (246) hide show
  1. package/README.md +6 -24
  2. package/dist/agent/guards.d.ts +0 -8
  3. package/dist/agent/guards.js +0 -195
  4. package/dist/agent/protocol.js +1 -4
  5. package/dist/agent/tools.d.ts +1 -3
  6. package/dist/agent/tools.js +377 -2
  7. package/dist/app.js +103 -335
  8. package/dist/cli.js +311 -362
  9. package/dist/commands/index.js +0 -22
  10. package/dist/commands/login.d.ts +2 -4
  11. package/dist/commands/login.js +10 -12
  12. package/dist/commands/logout.js +16 -8
  13. package/dist/commands/model.d.ts +0 -13
  14. package/dist/commands/model.js +22 -42
  15. package/dist/commands/provider.d.ts +0 -13
  16. package/dist/commands/provider.js +9 -20
  17. package/dist/commands/whoami.js +5 -6
  18. package/dist/config/store.d.ts +12 -32
  19. package/dist/config/store.js +65 -117
  20. package/dist/config/trust.d.ts +8 -21
  21. package/dist/config/trust.js +13 -99
  22. package/dist/lib/diagnostics.d.ts +4 -29
  23. package/dist/lib/diagnostics.js +4 -60
  24. package/dist/lib/http.d.ts +1 -11
  25. package/dist/lib/http.js +4 -62
  26. package/dist/providers/anthropic.d.ts +0 -1
  27. package/dist/providers/anthropic.js +0 -12
  28. package/dist/providers/custom.d.ts +0 -9
  29. package/dist/providers/deepseek.d.ts +0 -10
  30. package/dist/providers/deepseek.js +1 -2
  31. package/dist/providers/google.d.ts +0 -9
  32. package/dist/providers/groq.d.ts +0 -10
  33. package/dist/providers/groq.js +1 -2
  34. package/dist/providers/index.d.ts +201 -10
  35. package/dist/providers/index.js +0 -30
  36. package/dist/providers/mistral.d.ts +0 -10
  37. package/dist/providers/mistral.js +1 -2
  38. package/dist/providers/moonshot.d.ts +0 -10
  39. package/dist/providers/moonshot.js +1 -2
  40. package/dist/providers/ollama.d.ts +0 -9
  41. package/dist/providers/openai.d.ts +0 -10
  42. package/dist/providers/openai.js +1 -2
  43. package/dist/providers/openaiCompatible.d.ts +0 -9
  44. package/dist/providers/openaiCompatible.js +10 -58
  45. package/dist/providers/openrouter.d.ts +0 -10
  46. package/dist/providers/openrouter.js +1 -2
  47. package/dist/providers/qwen.d.ts +0 -10
  48. package/dist/providers/qwen.js +1 -2
  49. package/dist/providers/xai.d.ts +0 -10
  50. package/dist/providers/xai.js +1 -2
  51. package/dist/providers/zhipu.d.ts +0 -10
  52. package/dist/providers/zhipu.js +1 -2
  53. package/dist/session/log.d.ts +12 -35
  54. package/dist/session/log.js +10 -206
  55. package/dist/types.d.ts +1 -60
  56. package/dist/ui/Message.d.ts +7 -1
  57. package/dist/ui/Message.js +2 -13
  58. package/dist/ui/Prompt.d.ts +2 -1
  59. package/dist/ui/Prompt.js +2 -2
  60. package/dist/ui/Spinner.js +5 -11
  61. package/dist/ui/StatusBar.d.ts +1 -2
  62. package/dist/ui/StatusBar.js +5 -6
  63. package/package.json +1 -1
  64. package/src/agent/guards.ts +0 -196
  65. package/src/agent/protocol.ts +1 -4
  66. package/src/agent/tools.ts +377 -3
  67. package/src/app.ts +103 -335
  68. package/src/cli.ts +3 -30
  69. package/src/commands/index.ts +0 -22
  70. package/src/commands/login.ts +10 -12
  71. package/src/commands/logout.ts +16 -8
  72. package/src/commands/model.ts +22 -42
  73. package/src/commands/provider.ts +9 -20
  74. package/src/commands/whoami.ts +5 -6
  75. package/src/config/store.ts +69 -122
  76. package/src/config/trust.ts +21 -137
  77. package/src/lib/diagnostics.ts +4 -60
  78. package/src/lib/http.ts +4 -66
  79. package/src/providers/anthropic.ts +1 -13
  80. package/src/providers/deepseek.ts +1 -2
  81. package/src/providers/groq.ts +1 -2
  82. package/src/providers/index.ts +1 -32
  83. package/src/providers/mistral.ts +1 -2
  84. package/src/providers/moonshot.ts +1 -2
  85. package/src/providers/openai.ts +1 -2
  86. package/src/providers/openaiCompatible.ts +10 -58
  87. package/src/providers/openrouter.ts +1 -2
  88. package/src/providers/qwen.ts +1 -2
  89. package/src/providers/xai.ts +1 -2
  90. package/src/providers/zhipu.ts +1 -2
  91. package/src/session/log.ts +28 -267
  92. package/src/types.ts +1 -63
  93. package/src/ui/Message.ts +2 -13
  94. package/src/ui/Prompt.ts +2 -2
  95. package/src/ui/Spinner.ts +5 -11
  96. package/src/ui/StatusBar.ts +5 -6
  97. package/dist/agent/approval.d.ts +0 -50
  98. package/dist/agent/approval.js +0 -7
  99. package/dist/agent/compaction.d.ts +0 -39
  100. package/dist/agent/compaction.js +0 -227
  101. package/dist/agent/context.d.ts +0 -29
  102. package/dist/agent/context.js +0 -62
  103. package/dist/agent/ignore.d.ts +0 -11
  104. package/dist/agent/ignore.js +0 -129
  105. package/dist/agent/process-tree.d.ts +0 -2
  106. package/dist/agent/process-tree.js +0 -31
  107. package/dist/agent/protocol-mode.d.ts +0 -6
  108. package/dist/agent/protocol-mode.js +0 -51
  109. package/dist/agent/registry.d.ts +0 -17
  110. package/dist/agent/registry.js +0 -90
  111. package/dist/agent/runner.d.ts +0 -106
  112. package/dist/agent/runner.js +0 -352
  113. package/dist/agent/shell-session.d.ts +0 -37
  114. package/dist/agent/shell-session.js +0 -400
  115. package/dist/agent/stream.d.ts +0 -29
  116. package/dist/agent/stream.js +0 -103
  117. package/dist/agent/tool-schemas.d.ts +0 -2
  118. package/dist/agent/tool-schemas.js +0 -63
  119. package/dist/agent/tools/append_file.d.ts +0 -2
  120. package/dist/agent/tools/append_file.js +0 -26
  121. package/dist/agent/tools/apply_patch.d.ts +0 -10
  122. package/dist/agent/tools/apply_patch.js +0 -52
  123. package/dist/agent/tools/copy_file.d.ts +0 -2
  124. package/dist/agent/tools/copy_file.js +0 -30
  125. package/dist/agent/tools/delete_file.d.ts +0 -2
  126. package/dist/agent/tools/delete_file.js +0 -24
  127. package/dist/agent/tools/grep.d.ts +0 -2
  128. package/dist/agent/tools/grep.js +0 -23
  129. package/dist/agent/tools/index.d.ts +0 -2
  130. package/dist/agent/tools/index.js +0 -32
  131. package/dist/agent/tools/list_files.d.ts +0 -2
  132. package/dist/agent/tools/list_files.js +0 -17
  133. package/dist/agent/tools/make_dir.d.ts +0 -2
  134. package/dist/agent/tools/make_dir.js +0 -24
  135. package/dist/agent/tools/move_path.d.ts +0 -2
  136. package/dist/agent/tools/move_path.js +0 -47
  137. package/dist/agent/tools/paths.d.ts +0 -7
  138. package/dist/agent/tools/paths.js +0 -84
  139. package/dist/agent/tools/pwd.d.ts +0 -2
  140. package/dist/agent/tools/pwd.js +0 -10
  141. package/dist/agent/tools/read_file.d.ts +0 -2
  142. package/dist/agent/tools/read_file.js +0 -21
  143. package/dist/agent/tools/read_many.d.ts +0 -2
  144. package/dist/agent/tools/read_many.js +0 -25
  145. package/dist/agent/tools/readers.d.ts +0 -6
  146. package/dist/agent/tools/readers.js +0 -216
  147. package/dist/agent/tools/replace_in_file.d.ts +0 -2
  148. package/dist/agent/tools/replace_in_file.js +0 -30
  149. package/dist/agent/tools/shell.d.ts +0 -2
  150. package/dist/agent/tools/shell.js +0 -48
  151. package/dist/agent/tools/stat_path.d.ts +0 -2
  152. package/dist/agent/tools/stat_path.js +0 -31
  153. package/dist/agent/tools/types.d.ts +0 -39
  154. package/dist/agent/tools/types.js +0 -1
  155. package/dist/agent/tools/validate.d.ts +0 -6
  156. package/dist/agent/tools/validate.js +0 -29
  157. package/dist/agent/tools/write_file.d.ts +0 -2
  158. package/dist/agent/tools/write_file.js +0 -26
  159. package/dist/commands/attach.d.ts +0 -9
  160. package/dist/commands/attach.js +0 -15
  161. package/dist/commands/bg.d.ts +0 -7
  162. package/dist/commands/bg.js +0 -9
  163. package/dist/commands/cancel.d.ts +0 -10
  164. package/dist/commands/cancel.js +0 -10
  165. package/dist/commands/compact.d.ts +0 -10
  166. package/dist/commands/compact.js +0 -22
  167. package/dist/commands/context.d.ts +0 -7
  168. package/dist/commands/context.js +0 -24
  169. package/dist/commands/edit.d.ts +0 -10
  170. package/dist/commands/edit.js +0 -36
  171. package/dist/commands/effort.d.ts +0 -25
  172. package/dist/commands/effort.js +0 -48
  173. package/dist/commands/expand.d.ts +0 -10
  174. package/dist/commands/expand.js +0 -8
  175. package/dist/commands/jobs.d.ts +0 -7
  176. package/dist/commands/jobs.js +0 -16
  177. package/dist/commands/kill.d.ts +0 -7
  178. package/dist/commands/kill.js +0 -11
  179. package/dist/commands/steer.d.ts +0 -11
  180. package/dist/commands/steer.js +0 -13
  181. package/dist/lib/model-meta.d.ts +0 -19
  182. package/dist/lib/model-meta.js +0 -113
  183. package/dist/lib/native-tools.d.ts +0 -12
  184. package/dist/lib/native-tools.js +0 -21
  185. package/dist/lib/net.d.ts +0 -33
  186. package/dist/lib/net.js +0 -168
  187. package/dist/patch/apply.d.ts +0 -15
  188. package/dist/patch/apply.js +0 -172
  189. package/dist/patch/parse.d.ts +0 -29
  190. package/dist/patch/parse.js +0 -112
  191. package/dist/patch/plan.d.ts +0 -49
  192. package/dist/patch/plan.js +0 -273
  193. package/dist/session/projection.d.ts +0 -43
  194. package/dist/session/projection.js +0 -257
  195. package/dist/ui/Picker.d.ts +0 -8
  196. package/dist/ui/Picker.js +0 -24
  197. package/src/agent/approval.ts +0 -47
  198. package/src/agent/compaction.ts +0 -276
  199. package/src/agent/context.ts +0 -97
  200. package/src/agent/ignore.ts +0 -147
  201. package/src/agent/process-tree.ts +0 -32
  202. package/src/agent/protocol-mode.ts +0 -59
  203. package/src/agent/registry.ts +0 -98
  204. package/src/agent/runner.ts +0 -443
  205. package/src/agent/shell-session.ts +0 -449
  206. package/src/agent/stream.ts +0 -143
  207. package/src/agent/tool-schemas.ts +0 -67
  208. package/src/agent/tools/append_file.ts +0 -28
  209. package/src/agent/tools/apply_patch.ts +0 -54
  210. package/src/agent/tools/copy_file.ts +0 -32
  211. package/src/agent/tools/delete_file.ts +0 -26
  212. package/src/agent/tools/grep.ts +0 -25
  213. package/src/agent/tools/index.ts +0 -34
  214. package/src/agent/tools/list_files.ts +0 -19
  215. package/src/agent/tools/make_dir.ts +0 -26
  216. package/src/agent/tools/move_path.ts +0 -50
  217. package/src/agent/tools/paths.ts +0 -92
  218. package/src/agent/tools/pwd.ts +0 -12
  219. package/src/agent/tools/read_file.ts +0 -23
  220. package/src/agent/tools/read_many.ts +0 -27
  221. package/src/agent/tools/readers.ts +0 -228
  222. package/src/agent/tools/replace_in_file.ts +0 -32
  223. package/src/agent/tools/shell.ts +0 -53
  224. package/src/agent/tools/stat_path.ts +0 -33
  225. package/src/agent/tools/types.ts +0 -42
  226. package/src/agent/tools/validate.ts +0 -35
  227. package/src/agent/tools/write_file.ts +0 -28
  228. package/src/commands/attach.ts +0 -16
  229. package/src/commands/bg.ts +0 -9
  230. package/src/commands/cancel.ts +0 -10
  231. package/src/commands/compact.ts +0 -23
  232. package/src/commands/context.ts +0 -25
  233. package/src/commands/edit.ts +0 -37
  234. package/src/commands/effort.ts +0 -49
  235. package/src/commands/expand.ts +0 -8
  236. package/src/commands/jobs.ts +0 -17
  237. package/src/commands/kill.ts +0 -12
  238. package/src/commands/steer.ts +0 -13
  239. package/src/lib/model-meta.ts +0 -138
  240. package/src/lib/native-tools.ts +0 -32
  241. package/src/lib/net.ts +0 -204
  242. package/src/patch/apply.ts +0 -194
  243. package/src/patch/parse.ts +0 -131
  244. package/src/patch/plan.ts +0 -317
  245. package/src/session/projection.ts +0 -308
  246. package/src/ui/Picker.ts +0 -24
@@ -1,48 +0,0 @@
1
- import { executeShellCommand, pollShellSession } from "../shell-session.js";
2
- import { invalid, numberOption } from "./validate.js";
3
- export const shellTool = {
4
- name: "shell",
5
- requiresTrust: true,
6
- stateScope: "turn",
7
- revalidate: ["trust", "sandboxRoots"],
8
- approvalHints: { mayRequireApproval: true },
9
- prepare(call) {
10
- if (typeof call.session_id === "string" && call.session_id.trim())
11
- return { ok: true };
12
- if (typeof call.command !== "string" || call.command.trim() === "")
13
- return invalid("command must be a non-empty string");
14
- return { ok: true };
15
- },
16
- async execute(call, ctx) {
17
- if (typeof call.session_id === "string" && call.session_id.trim()) {
18
- const polled = await pollShellSession(call.session_id, numberOption(call.waitMs, 0));
19
- if (!polled)
20
- return { ok: false, output: `unknown shell session: ${call.session_id}` };
21
- return formatPoll(call.session_id, polled);
22
- }
23
- const result = await executeShellCommand(call.command, ctx.cwd, {
24
- signal: ctx.signal,
25
- turn: ctx.turn,
26
- timeoutMs: numberOption(call.timeoutMs, 120000),
27
- });
28
- return formatExec(result);
29
- },
30
- };
31
- function formatExec(result) {
32
- if (result.status !== "running")
33
- return { ok: result.ok, output: result.output || `[command ${result.status}]` };
34
- const header = `[session ${result.sessionId}] running`;
35
- const body = result.output ? "\n" + result.output : "";
36
- return {
37
- ok: true,
38
- output: `${header}${body}\n\nPoll with: {"tool":"shell","session_id":"${result.sessionId}"}`,
39
- };
40
- }
41
- function formatPoll(id, result) {
42
- const status = result.status === "running"
43
- ? `running (next poll ~${Math.round((result.nextPollMs ?? 1000) / 1000)}s)`
44
- : `${result.status}${result.exitCode !== undefined && result.exitCode !== null ? ` (exit ${result.exitCode})` : ""}`;
45
- const header = `[session ${id}] ${status}`;
46
- const body = result.output ? "\n" + result.output : result.status === "running" ? "\n(no new output)" : "";
47
- return { ok: result.ok, output: header + body };
48
- }
@@ -1,2 +0,0 @@
1
- import type { Tool } from "./types.js";
2
- export declare const statPathTool: Tool;
@@ -1,31 +0,0 @@
1
- import { stat } from "node:fs/promises";
2
- import { resolvePath } from "./paths.js";
3
- import { invalid, preparePath, requiredString } from "./validate.js";
4
- export const statPathTool = {
5
- name: "stat_path",
6
- stateScope: "call",
7
- revalidate: ["sandboxRoots"],
8
- prepare(call, ctx) {
9
- let path;
10
- try {
11
- path = requiredString(call, "path");
12
- }
13
- catch (err) {
14
- return invalid(err.message);
15
- }
16
- return preparePath(ctx.cwd, path);
17
- },
18
- async execute(call, ctx) {
19
- const file = resolvePath(ctx.cwd, call);
20
- const info = await stat(file);
21
- return {
22
- ok: true,
23
- output: JSON.stringify({
24
- path: file,
25
- type: info.isDirectory() ? "dir" : info.isFile() ? "file" : "other",
26
- size: info.size,
27
- modified: info.mtime.toISOString(),
28
- }, null, 2),
29
- };
30
- },
31
- };
@@ -1,39 +0,0 @@
1
- export type StateScope = "call" | "turn" | "session";
2
- export type RevalidateKey = "trust" | "sandboxRoots" | "schema" | "modelCaps";
3
- export interface SideEffects {
4
- touched?: string[];
5
- created?: string[];
6
- removed?: string[];
7
- }
8
- export interface ToolCall {
9
- tool: string;
10
- [key: string]: any;
11
- }
12
- export interface ToolResult {
13
- ok: boolean;
14
- output: string;
15
- sideEffects?: SideEffects;
16
- }
17
- export interface ToolCtx {
18
- cwd: string;
19
- signal?: AbortSignal;
20
- turn?: number;
21
- }
22
- export type Prepared = {
23
- ok: true;
24
- } | {
25
- ok: false;
26
- output: string;
27
- };
28
- export interface ApprovalHints {
29
- mayRequireApproval: boolean;
30
- }
31
- export interface Tool {
32
- name: string;
33
- requiresTrust?: boolean;
34
- stateScope: StateScope;
35
- revalidate?: RevalidateKey[];
36
- approvalHints?: ApprovalHints;
37
- prepare(call: ToolCall, ctx: ToolCtx): Prepared;
38
- execute(call: ToolCall, ctx: ToolCtx): Promise<ToolResult>;
39
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- import type { Prepared, ToolCall } from "./types.js";
2
- export declare function invalid(output: string): Prepared;
3
- export declare function requiredString(call: ToolCall, key: string): string;
4
- export declare function stringArray(call: ToolCall, key: string): string[];
5
- export declare function numberOption(value: any, fallback: number): number;
6
- export declare function preparePath(cwd: string, raw: string): Prepared;
@@ -1,29 +0,0 @@
1
- import { sandboxPath } from "./paths.js";
2
- export function invalid(output) {
3
- return { ok: false, output };
4
- }
5
- export function requiredString(call, key) {
6
- const value = call[key];
7
- if (typeof value !== "string")
8
- throw new Error(`${key} must be a string`);
9
- return value;
10
- }
11
- export function stringArray(call, key) {
12
- const value = call[key];
13
- if (!Array.isArray(value) || !value.every((item) => typeof item === "string")) {
14
- throw new Error(`${key} must be an array of strings`);
15
- }
16
- return value;
17
- }
18
- export function numberOption(value, fallback) {
19
- return typeof value === "number" && Number.isFinite(value) ? value : fallback;
20
- }
21
- export function preparePath(cwd, raw) {
22
- try {
23
- sandboxPath(cwd, raw);
24
- return { ok: true };
25
- }
26
- catch (err) {
27
- return invalid(err?.message ?? String(err));
28
- }
29
- }
@@ -1,2 +0,0 @@
1
- import type { Tool } from "./types.js";
2
- export declare const writeFileTool: Tool;
@@ -1,26 +0,0 @@
1
- import { mkdir, writeFile } from "node:fs/promises";
2
- import { dirname } from "node:path";
3
- import { resolvePath } from "./paths.js";
4
- import { invalid, preparePath, requiredString } from "./validate.js";
5
- export const writeFileTool = {
6
- name: "write_file",
7
- requiresTrust: true,
8
- stateScope: "turn",
9
- revalidate: ["trust", "sandboxRoots"],
10
- prepare(call, ctx) {
11
- try {
12
- requiredString(call, "path");
13
- requiredString(call, "content");
14
- }
15
- catch (err) {
16
- return invalid(err.message);
17
- }
18
- return preparePath(ctx.cwd, requiredString(call, "path"));
19
- },
20
- async execute(call, ctx) {
21
- const file = resolvePath(ctx.cwd, call);
22
- await mkdir(dirname(file), { recursive: true });
23
- await writeFile(file, requiredString(call, "content"), "utf8");
24
- return { ok: true, output: `wrote ${file}`, sideEffects: { touched: [file] } };
25
- },
26
- };
@@ -1,9 +0,0 @@
1
- export declare const attachCommand: {
2
- name: string;
3
- description: string;
4
- run({ args }: {
5
- args: any;
6
- }): Promise<{
7
- message: string;
8
- }>;
9
- };
@@ -1,15 +0,0 @@
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
- };
@@ -1,7 +0,0 @@
1
- export declare const bgCommand: {
2
- name: string;
3
- description: string;
4
- run(): {
5
- message: string;
6
- };
7
- };
@@ -1,9 +0,0 @@
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
- };
@@ -1,10 +0,0 @@
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
- };
@@ -1,10 +0,0 @@
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
- };
@@ -1,10 +0,0 @@
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
- };
@@ -1,22 +0,0 @@
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
- };
@@ -1,7 +0,0 @@
1
- export declare const contextCommand: {
2
- name: string;
3
- description: string;
4
- run(ctx: any): {
5
- message: string;
6
- };
7
- };
@@ -1,24 +0,0 @@
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
- };
@@ -1,10 +0,0 @@
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
- };
@@ -1,36 +0,0 @@
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
- };
@@ -1,25 +0,0 @@
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
- };
@@ -1,48 +0,0 @@
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
- }
@@ -1,10 +0,0 @@
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
- };
@@ -1,8 +0,0 @@
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
- };
@@ -1,7 +0,0 @@
1
- export declare const jobsCommand: {
2
- name: string;
3
- description: string;
4
- run(): {
5
- message: string;
6
- };
7
- };
@@ -1,16 +0,0 @@
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
- };
@@ -1,7 +0,0 @@
1
- export declare const killCommand: {
2
- name: string;
3
- description: string;
4
- run(ctx: any): {
5
- message: string;
6
- };
7
- };
@@ -1,11 +0,0 @@
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
- };
@@ -1,11 +0,0 @@
1
- export declare const steerCommand: {
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
- };
@@ -1,13 +0,0 @@
1
- export const steerCommand = {
2
- name: "steer",
3
- description: "Add guidance to the next request of an active run (/steer <text>)",
4
- run({ args, state, actions }) {
5
- const text = args.join(" ").trim();
6
- if (!text)
7
- return { message: "Usage: /steer <guidance>" };
8
- if (!state.busy)
9
- return { message: "No active run. Just send the guidance as the next message." };
10
- actions.steer(text);
11
- return { message: "Steering queued for the next request." };
12
- },
13
- };
@@ -1,19 +0,0 @@
1
- export interface ModelMeta {
2
- contextWindow: number;
3
- supportsTools: boolean;
4
- charsPerToken: number;
5
- maxOutputTokens?: number;
6
- }
7
- export interface EstTokenOptions {
8
- providerId?: string;
9
- model?: string;
10
- charsPerToken?: number;
11
- }
12
- export declare const UNKNOWN_MODEL_META: ModelMeta;
13
- export declare function modelMetaOverridePath(): string;
14
- export declare function clearModelMetaCache(): void;
15
- export declare function getModelMeta(providerId?: string, model?: string): ModelMeta;
16
- export declare function estTokens(text: string, options?: number | EstTokenOptions): number;
17
- export declare function estMessagesTokens(messages: Array<{
18
- content: string;
19
- }>, options?: EstTokenOptions): number;