@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.
- package/LICENSE +21 -0
- package/README.md +418 -2
- package/bin/fastcode.mjs +59 -0
- package/dist/agent/approval.d.ts +50 -0
- package/dist/agent/approval.js +7 -0
- package/dist/agent/compaction.d.ts +39 -0
- package/dist/agent/compaction.js +227 -0
- package/dist/agent/context.d.ts +29 -0
- package/dist/agent/context.js +62 -0
- package/dist/agent/guards.d.ts +43 -0
- package/dist/agent/guards.js +269 -0
- package/dist/agent/ignore.d.ts +11 -0
- package/dist/agent/ignore.js +129 -0
- package/dist/agent/limits.d.ts +24 -0
- package/dist/agent/limits.js +71 -0
- package/dist/agent/process-tree.d.ts +2 -0
- package/dist/agent/process-tree.js +31 -0
- package/dist/agent/protocol-mode.d.ts +6 -0
- package/dist/agent/protocol-mode.js +51 -0
- package/dist/agent/protocol.d.ts +4 -0
- package/dist/agent/protocol.js +129 -0
- package/dist/agent/registry.d.ts +17 -0
- package/dist/agent/registry.js +90 -0
- package/dist/agent/runner.d.ts +106 -0
- package/dist/agent/runner.js +352 -0
- package/dist/agent/shell-session.d.ts +37 -0
- package/dist/agent/shell-session.js +400 -0
- package/dist/agent/stream.d.ts +29 -0
- package/dist/agent/stream.js +103 -0
- package/dist/agent/tool-schemas.d.ts +2 -0
- package/dist/agent/tool-schemas.js +63 -0
- package/dist/agent/tools/append_file.d.ts +2 -0
- package/dist/agent/tools/append_file.js +26 -0
- package/dist/agent/tools/apply_patch.d.ts +10 -0
- package/dist/agent/tools/apply_patch.js +52 -0
- package/dist/agent/tools/copy_file.d.ts +2 -0
- package/dist/agent/tools/copy_file.js +30 -0
- package/dist/agent/tools/delete_file.d.ts +2 -0
- package/dist/agent/tools/delete_file.js +24 -0
- package/dist/agent/tools/grep.d.ts +2 -0
- package/dist/agent/tools/grep.js +23 -0
- package/dist/agent/tools/index.d.ts +2 -0
- package/dist/agent/tools/index.js +32 -0
- package/dist/agent/tools/list_files.d.ts +2 -0
- package/dist/agent/tools/list_files.js +17 -0
- package/dist/agent/tools/make_dir.d.ts +2 -0
- package/dist/agent/tools/make_dir.js +24 -0
- package/dist/agent/tools/move_path.d.ts +2 -0
- package/dist/agent/tools/move_path.js +47 -0
- package/dist/agent/tools/paths.d.ts +7 -0
- package/dist/agent/tools/paths.js +84 -0
- package/dist/agent/tools/pwd.d.ts +2 -0
- package/dist/agent/tools/pwd.js +10 -0
- package/dist/agent/tools/read_file.d.ts +2 -0
- package/dist/agent/tools/read_file.js +21 -0
- package/dist/agent/tools/read_many.d.ts +2 -0
- package/dist/agent/tools/read_many.js +25 -0
- package/dist/agent/tools/readers.d.ts +6 -0
- package/dist/agent/tools/readers.js +216 -0
- package/dist/agent/tools/replace_in_file.d.ts +2 -0
- package/dist/agent/tools/replace_in_file.js +30 -0
- package/dist/agent/tools/shell.d.ts +2 -0
- package/dist/agent/tools/shell.js +48 -0
- package/dist/agent/tools/stat_path.d.ts +2 -0
- package/dist/agent/tools/stat_path.js +31 -0
- package/dist/agent/tools/types.d.ts +39 -0
- package/dist/agent/tools/types.js +1 -0
- package/dist/agent/tools/validate.d.ts +6 -0
- package/dist/agent/tools/validate.js +29 -0
- package/dist/agent/tools/write_file.d.ts +2 -0
- package/dist/agent/tools/write_file.js +26 -0
- package/dist/agent/tools.d.ts +3 -0
- package/dist/agent/tools.js +2 -0
- package/dist/app.d.ts +4 -0
- package/dist/app.js +708 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +569 -0
- package/dist/commands/about.d.ts +8 -0
- package/dist/commands/about.js +16 -0
- package/dist/commands/agent.d.ts +11 -0
- package/dist/commands/agent.js +18 -0
- package/dist/commands/attach.d.ts +9 -0
- package/dist/commands/attach.js +15 -0
- package/dist/commands/bg.d.ts +7 -0
- package/dist/commands/bg.js +9 -0
- package/dist/commands/cancel.d.ts +10 -0
- package/dist/commands/cancel.js +10 -0
- package/dist/commands/clear.d.ts +11 -0
- package/dist/commands/clear.js +9 -0
- package/dist/commands/compact.d.ts +10 -0
- package/dist/commands/compact.js +22 -0
- package/dist/commands/config.d.ts +7 -0
- package/dist/commands/config.js +24 -0
- package/dist/commands/context.d.ts +7 -0
- package/dist/commands/context.js +24 -0
- package/dist/commands/cost.d.ts +9 -0
- package/dist/commands/cost.js +13 -0
- package/dist/commands/cwd.d.ts +7 -0
- package/dist/commands/cwd.js +7 -0
- package/dist/commands/edit.d.ts +10 -0
- package/dist/commands/edit.js +36 -0
- package/dist/commands/effort.d.ts +25 -0
- package/dist/commands/effort.js +48 -0
- package/dist/commands/exit.d.ts +9 -0
- package/dist/commands/exit.js +8 -0
- package/dist/commands/expand.d.ts +10 -0
- package/dist/commands/expand.js +8 -0
- package/dist/commands/help.d.ts +6 -0
- package/dist/commands/help.js +18 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.js +80 -0
- package/dist/commands/jobs.d.ts +7 -0
- package/dist/commands/jobs.js +16 -0
- package/dist/commands/kill.d.ts +7 -0
- package/dist/commands/kill.js +11 -0
- package/dist/commands/login.d.ts +18 -0
- package/dist/commands/login.js +63 -0
- package/dist/commands/logout.d.ts +9 -0
- package/dist/commands/logout.js +45 -0
- package/dist/commands/model.d.ts +24 -0
- package/dist/commands/model.js +50 -0
- package/dist/commands/plugin.d.ts +11 -0
- package/dist/commands/plugin.js +74 -0
- package/dist/commands/provider.d.ts +24 -0
- package/dist/commands/provider.js +39 -0
- package/dist/commands/reset.d.ts +9 -0
- package/dist/commands/reset.js +13 -0
- package/dist/commands/skills.d.ts +11 -0
- package/dist/commands/skills.js +106 -0
- package/dist/commands/steer.d.ts +11 -0
- package/dist/commands/steer.js +13 -0
- package/dist/commands/system.d.ts +11 -0
- package/dist/commands/system.js +20 -0
- package/dist/commands/theme.d.ts +11 -0
- package/dist/commands/theme.js +22 -0
- package/dist/commands/tools.d.ts +7 -0
- package/dist/commands/tools.js +29 -0
- package/dist/commands/whoami.d.ts +9 -0
- package/dist/commands/whoami.js +52 -0
- package/dist/config/paths.d.ts +4 -0
- package/dist/config/paths.js +59 -0
- package/dist/config/store.d.ts +89 -0
- package/dist/config/store.js +260 -0
- package/dist/config/themes.d.ts +73 -0
- package/dist/config/themes.js +77 -0
- package/dist/config/trust.d.ts +22 -0
- package/dist/config/trust.js +153 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +31 -0
- package/dist/lib/diagnostics.d.ts +66 -0
- package/dist/lib/diagnostics.js +195 -0
- package/dist/lib/http.d.ts +23 -0
- package/dist/lib/http.js +128 -0
- package/dist/lib/markdown.d.ts +1 -0
- package/dist/lib/markdown.js +32 -0
- package/dist/lib/model-meta.d.ts +19 -0
- package/dist/lib/model-meta.js +113 -0
- package/dist/lib/native-tools.d.ts +12 -0
- package/dist/lib/native-tools.js +21 -0
- package/dist/lib/net.d.ts +33 -0
- package/dist/lib/net.js +168 -0
- package/dist/lib/pkg.d.ts +5 -0
- package/dist/lib/pkg.js +27 -0
- package/dist/lib/platform.d.ts +7 -0
- package/dist/lib/platform.js +57 -0
- package/dist/lib/startup.d.ts +6 -0
- package/dist/lib/startup.js +25 -0
- package/dist/lib/uiMode.d.ts +2 -0
- package/dist/lib/uiMode.js +7 -0
- package/dist/patch/apply.d.ts +15 -0
- package/dist/patch/apply.js +172 -0
- package/dist/patch/parse.d.ts +29 -0
- package/dist/patch/parse.js +112 -0
- package/dist/patch/plan.d.ts +49 -0
- package/dist/patch/plan.js +273 -0
- package/dist/plugins/manager.d.ts +23 -0
- package/dist/plugins/manager.js +101 -0
- package/dist/providers/anthropic.d.ts +22 -0
- package/dist/providers/anthropic.js +119 -0
- package/dist/providers/custom.d.ts +33 -0
- package/dist/providers/custom.js +25 -0
- package/dist/providers/deepseek.d.ts +34 -0
- package/dist/providers/deepseek.js +16 -0
- package/dist/providers/google.d.ts +33 -0
- package/dist/providers/google.js +19 -0
- package/dist/providers/groq.d.ts +34 -0
- package/dist/providers/groq.js +21 -0
- package/dist/providers/index.d.ts +10 -0
- package/dist/providers/index.js +67 -0
- package/dist/providers/mistral.d.ts +34 -0
- package/dist/providers/mistral.js +20 -0
- package/dist/providers/moonshot.d.ts +34 -0
- package/dist/providers/moonshot.js +23 -0
- package/dist/providers/ollama.d.ts +33 -0
- package/dist/providers/ollama.js +22 -0
- package/dist/providers/openai.d.ts +34 -0
- package/dist/providers/openai.js +26 -0
- package/dist/providers/openaiCompatible.d.ts +26 -0
- package/dist/providers/openaiCompatible.js +158 -0
- package/dist/providers/openrouter.d.ts +34 -0
- package/dist/providers/openrouter.js +27 -0
- package/dist/providers/qwen.d.ts +34 -0
- package/dist/providers/qwen.js +24 -0
- package/dist/providers/xai.d.ts +34 -0
- package/dist/providers/xai.js +19 -0
- package/dist/providers/zhipu.d.ts +34 -0
- package/dist/providers/zhipu.js +24 -0
- package/dist/session/log.d.ts +52 -0
- package/dist/session/log.js +331 -0
- package/dist/session/projection.d.ts +43 -0
- package/dist/session/projection.js +257 -0
- package/dist/skills/manager.d.ts +18 -0
- package/dist/skills/manager.js +201 -0
- package/dist/skills/parser.d.ts +18 -0
- package/dist/skills/parser.js +65 -0
- package/dist/types.d.ts +205 -0
- package/dist/types.js +1 -0
- package/dist/ui/Banner.d.ts +5 -0
- package/dist/ui/Banner.js +65 -0
- package/dist/ui/Message.d.ts +1 -0
- package/dist/ui/Message.js +24 -0
- package/dist/ui/Picker.d.ts +8 -0
- package/dist/ui/Picker.js +24 -0
- package/dist/ui/Prompt.d.ts +9 -0
- package/dist/ui/Prompt.js +38 -0
- package/dist/ui/Spinner.d.ts +5 -0
- package/dist/ui/Spinner.js +39 -0
- package/dist/ui/StatusBar.d.ts +11 -0
- package/dist/ui/StatusBar.js +20 -0
- package/dist/ui/TrustGate.d.ts +5 -0
- package/dist/ui/TrustGate.js +26 -0
- package/package.json +96 -4
- package/src/agent/approval.ts +47 -0
- package/src/agent/compaction.ts +276 -0
- package/src/agent/context.ts +97 -0
- package/src/agent/guards.ts +270 -0
- package/src/agent/ignore.ts +147 -0
- package/src/agent/limits.ts +71 -0
- package/src/agent/process-tree.ts +32 -0
- package/src/agent/protocol-mode.ts +59 -0
- package/src/agent/protocol.ts +129 -0
- package/src/agent/registry.ts +98 -0
- package/src/agent/runner.ts +443 -0
- package/src/agent/shell-session.ts +449 -0
- package/src/agent/stream.ts +143 -0
- package/src/agent/tool-schemas.ts +67 -0
- package/src/agent/tools/append_file.ts +28 -0
- package/src/agent/tools/apply_patch.ts +54 -0
- package/src/agent/tools/copy_file.ts +32 -0
- package/src/agent/tools/delete_file.ts +26 -0
- package/src/agent/tools/grep.ts +25 -0
- package/src/agent/tools/index.ts +34 -0
- package/src/agent/tools/list_files.ts +19 -0
- package/src/agent/tools/make_dir.ts +26 -0
- package/src/agent/tools/move_path.ts +50 -0
- package/src/agent/tools/paths.ts +92 -0
- package/src/agent/tools/pwd.ts +12 -0
- package/src/agent/tools/read_file.ts +23 -0
- package/src/agent/tools/read_many.ts +27 -0
- package/src/agent/tools/readers.ts +228 -0
- package/src/agent/tools/replace_in_file.ts +32 -0
- package/src/agent/tools/shell.ts +53 -0
- package/src/agent/tools/stat_path.ts +33 -0
- package/src/agent/tools/types.ts +42 -0
- package/src/agent/tools/validate.ts +35 -0
- package/src/agent/tools/write_file.ts +28 -0
- package/src/agent/tools.ts +3 -0
- package/src/app.ts +708 -0
- package/src/cli.ts +335 -0
- package/src/commands/about.ts +16 -0
- package/src/commands/agent.ts +18 -0
- package/src/commands/attach.ts +16 -0
- package/src/commands/bg.ts +9 -0
- package/src/commands/cancel.ts +10 -0
- package/src/commands/clear.ts +9 -0
- package/src/commands/compact.ts +23 -0
- package/src/commands/config.ts +24 -0
- package/src/commands/context.ts +25 -0
- package/src/commands/cost.ts +13 -0
- package/src/commands/cwd.ts +7 -0
- package/src/commands/edit.ts +37 -0
- package/src/commands/effort.ts +49 -0
- package/src/commands/exit.ts +8 -0
- package/src/commands/expand.ts +8 -0
- package/src/commands/help.ts +18 -0
- package/src/commands/index.ts +80 -0
- package/src/commands/jobs.ts +17 -0
- package/src/commands/kill.ts +12 -0
- package/src/commands/login.ts +63 -0
- package/src/commands/logout.ts +45 -0
- package/src/commands/model.ts +50 -0
- package/src/commands/plugin.ts +74 -0
- package/src/commands/provider.ts +39 -0
- package/src/commands/reset.ts +13 -0
- package/src/commands/skills.ts +106 -0
- package/src/commands/steer.ts +13 -0
- package/src/commands/system.ts +20 -0
- package/src/commands/theme.ts +22 -0
- package/src/commands/tools.ts +29 -0
- package/src/commands/whoami.ts +52 -0
- package/src/config/paths.ts +59 -0
- package/src/config/store.ts +293 -0
- package/src/config/themes.ts +77 -0
- package/src/config/trust.ts +183 -0
- package/src/index.ts +31 -0
- package/src/lib/diagnostics.ts +195 -0
- package/src/lib/http.ts +132 -0
- package/src/lib/markdown.ts +32 -0
- package/src/lib/model-meta.ts +138 -0
- package/src/lib/native-tools.ts +32 -0
- package/src/lib/net.ts +204 -0
- package/src/lib/pkg.ts +35 -0
- package/src/lib/platform.ts +57 -0
- package/src/lib/startup.ts +25 -0
- package/src/lib/uiMode.ts +7 -0
- package/src/patch/apply.ts +194 -0
- package/src/patch/parse.ts +131 -0
- package/src/patch/plan.ts +317 -0
- package/src/plugins/manager.ts +101 -0
- package/src/providers/anthropic.ts +119 -0
- package/src/providers/custom.ts +25 -0
- package/src/providers/deepseek.ts +16 -0
- package/src/providers/google.ts +19 -0
- package/src/providers/groq.ts +21 -0
- package/src/providers/index.ts +68 -0
- package/src/providers/mistral.ts +20 -0
- package/src/providers/moonshot.ts +23 -0
- package/src/providers/ollama.ts +22 -0
- package/src/providers/openai.ts +26 -0
- package/src/providers/openaiCompatible.ts +158 -0
- package/src/providers/openrouter.ts +27 -0
- package/src/providers/qwen.ts +24 -0
- package/src/providers/xai.ts +19 -0
- package/src/providers/zhipu.ts +24 -0
- package/src/session/log.ts +374 -0
- package/src/session/projection.ts +308 -0
- package/src/skills/manager.ts +201 -0
- package/src/skills/parser.ts +65 -0
- package/src/types.ts +205 -0
- package/src/ui/Banner.ts +68 -0
- package/src/ui/Message.ts +24 -0
- package/src/ui/Picker.ts +24 -0
- package/src/ui/Prompt.ts +38 -0
- package/src/ui/Spinner.ts +39 -0
- package/src/ui/StatusBar.ts +20 -0
- package/src/ui/TrustGate.ts +26 -0
- package/tsconfig.json +22 -0
|
@@ -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,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,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,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 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,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,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,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,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,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,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,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,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,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
|
+
};
|