@arhan-w/ibex 0.0.0-stage → 3.6.1
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 +306 -2
- package/npm-package/LICENSE +21 -0
- package/npm-package/README.md +178 -0
- package/npm-package/bin/goat.js +3 -0
- package/npm-package/bin/ibex.js +78 -0
- package/npm-package/package.json +58 -0
- package/npm-package/scripts/install-binary.js +168 -0
- package/package.json +69 -6
- package/src/agent.ts +695 -0
- package/src/agents/loader.ts +110 -0
- package/src/ambient.d.ts +2 -0
- package/src/code/extract.ts +292 -0
- package/src/code/find.ts +244 -0
- package/src/code/grammars.ts +88 -0
- package/src/code/indexer.ts +242 -0
- package/src/code/semantic.ts +253 -0
- package/src/code/slash.ts +88 -0
- package/src/code/tool.ts +40 -0
- package/src/collab/client.ts +141 -0
- package/src/collab/handlers.ts +141 -0
- package/src/collab/invite.ts +39 -0
- package/src/collab/relay.ts +106 -0
- package/src/collab/sync.ts +131 -0
- package/src/commands.tsx +943 -0
- package/src/computer.ts +629 -0
- package/src/config.ts +318 -0
- package/src/constants.ts +18 -0
- package/src/context.ts +73 -0
- package/src/data/providers.json +2342 -0
- package/src/diff.ts +50 -0
- package/src/doctor.ts +443 -0
- package/src/errors.ts +139 -0
- package/src/gflash.ts +170 -0
- package/src/hooks.ts +133 -0
- package/src/ide/assets.gen.ts +3 -0
- package/src/ide/index.html +844 -0
- package/src/ide/server.ts +506 -0
- package/src/ide/vendor/marked.umd.js +80 -0
- package/src/ide/vendor/vs/base/browser/ui/codicons/codicon/codicon.ttf +0 -0
- package/src/ide/vendor/vs/base/worker/workerMain.js +31 -0
- package/src/ide/vendor/vs/basic-languages/abap/abap.js +10 -0
- package/src/ide/vendor/vs/basic-languages/apex/apex.js +10 -0
- package/src/ide/vendor/vs/basic-languages/azcli/azcli.js +10 -0
- package/src/ide/vendor/vs/basic-languages/bat/bat.js +10 -0
- package/src/ide/vendor/vs/basic-languages/bicep/bicep.js +11 -0
- package/src/ide/vendor/vs/basic-languages/cameligo/cameligo.js +10 -0
- package/src/ide/vendor/vs/basic-languages/clojure/clojure.js +10 -0
- package/src/ide/vendor/vs/basic-languages/coffee/coffee.js +10 -0
- package/src/ide/vendor/vs/basic-languages/cpp/cpp.js +10 -0
- package/src/ide/vendor/vs/basic-languages/csharp/csharp.js +10 -0
- package/src/ide/vendor/vs/basic-languages/csp/csp.js +10 -0
- package/src/ide/vendor/vs/basic-languages/css/css.js +12 -0
- package/src/ide/vendor/vs/basic-languages/cypher/cypher.js +10 -0
- package/src/ide/vendor/vs/basic-languages/dart/dart.js +10 -0
- package/src/ide/vendor/vs/basic-languages/dockerfile/dockerfile.js +10 -0
- package/src/ide/vendor/vs/basic-languages/ecl/ecl.js +10 -0
- package/src/ide/vendor/vs/basic-languages/elixir/elixir.js +10 -0
- package/src/ide/vendor/vs/basic-languages/flow9/flow9.js +10 -0
- package/src/ide/vendor/vs/basic-languages/freemarker2/freemarker2.js +12 -0
- package/src/ide/vendor/vs/basic-languages/fsharp/fsharp.js +10 -0
- package/src/ide/vendor/vs/basic-languages/go/go.js +10 -0
- package/src/ide/vendor/vs/basic-languages/graphql/graphql.js +10 -0
- package/src/ide/vendor/vs/basic-languages/handlebars/handlebars.js +10 -0
- package/src/ide/vendor/vs/basic-languages/hcl/hcl.js +10 -0
- package/src/ide/vendor/vs/basic-languages/html/html.js +10 -0
- package/src/ide/vendor/vs/basic-languages/ini/ini.js +10 -0
- package/src/ide/vendor/vs/basic-languages/java/java.js +10 -0
- package/src/ide/vendor/vs/basic-languages/javascript/javascript.js +10 -0
- package/src/ide/vendor/vs/basic-languages/julia/julia.js +10 -0
- package/src/ide/vendor/vs/basic-languages/kotlin/kotlin.js +10 -0
- package/src/ide/vendor/vs/basic-languages/less/less.js +11 -0
- package/src/ide/vendor/vs/basic-languages/lexon/lexon.js +10 -0
- package/src/ide/vendor/vs/basic-languages/liquid/liquid.js +10 -0
- package/src/ide/vendor/vs/basic-languages/lua/lua.js +10 -0
- package/src/ide/vendor/vs/basic-languages/m3/m3.js +10 -0
- package/src/ide/vendor/vs/basic-languages/markdown/markdown.js +10 -0
- package/src/ide/vendor/vs/basic-languages/mdx/mdx.js +10 -0
- package/src/ide/vendor/vs/basic-languages/mips/mips.js +10 -0
- package/src/ide/vendor/vs/basic-languages/msdax/msdax.js +10 -0
- package/src/ide/vendor/vs/basic-languages/mysql/mysql.js +10 -0
- package/src/ide/vendor/vs/basic-languages/objective-c/objective-c.js +10 -0
- package/src/ide/vendor/vs/basic-languages/pascal/pascal.js +10 -0
- package/src/ide/vendor/vs/basic-languages/pascaligo/pascaligo.js +10 -0
- package/src/ide/vendor/vs/basic-languages/perl/perl.js +10 -0
- package/src/ide/vendor/vs/basic-languages/pgsql/pgsql.js +10 -0
- package/src/ide/vendor/vs/basic-languages/php/php.js +10 -0
- package/src/ide/vendor/vs/basic-languages/pla/pla.js +10 -0
- package/src/ide/vendor/vs/basic-languages/postiats/postiats.js +10 -0
- package/src/ide/vendor/vs/basic-languages/powerquery/powerquery.js +10 -0
- package/src/ide/vendor/vs/basic-languages/powershell/powershell.js +10 -0
- package/src/ide/vendor/vs/basic-languages/protobuf/protobuf.js +11 -0
- package/src/ide/vendor/vs/basic-languages/pug/pug.js +10 -0
- package/src/ide/vendor/vs/basic-languages/python/python.js +10 -0
- package/src/ide/vendor/vs/basic-languages/qsharp/qsharp.js +10 -0
- package/src/ide/vendor/vs/basic-languages/r/r.js +10 -0
- package/src/ide/vendor/vs/basic-languages/razor/razor.js +10 -0
- package/src/ide/vendor/vs/basic-languages/redis/redis.js +10 -0
- package/src/ide/vendor/vs/basic-languages/redshift/redshift.js +10 -0
- package/src/ide/vendor/vs/basic-languages/restructuredtext/restructuredtext.js +10 -0
- package/src/ide/vendor/vs/basic-languages/ruby/ruby.js +10 -0
- package/src/ide/vendor/vs/basic-languages/rust/rust.js +10 -0
- package/src/ide/vendor/vs/basic-languages/sb/sb.js +10 -0
- package/src/ide/vendor/vs/basic-languages/scala/scala.js +10 -0
- package/src/ide/vendor/vs/basic-languages/scheme/scheme.js +10 -0
- package/src/ide/vendor/vs/basic-languages/scss/scss.js +12 -0
- package/src/ide/vendor/vs/basic-languages/shell/shell.js +10 -0
- package/src/ide/vendor/vs/basic-languages/solidity/solidity.js +10 -0
- package/src/ide/vendor/vs/basic-languages/sophia/sophia.js +10 -0
- package/src/ide/vendor/vs/basic-languages/sparql/sparql.js +10 -0
- package/src/ide/vendor/vs/basic-languages/sql/sql.js +10 -0
- package/src/ide/vendor/vs/basic-languages/st/st.js +10 -0
- package/src/ide/vendor/vs/basic-languages/swift/swift.js +13 -0
- package/src/ide/vendor/vs/basic-languages/systemverilog/systemverilog.js +10 -0
- package/src/ide/vendor/vs/basic-languages/tcl/tcl.js +10 -0
- package/src/ide/vendor/vs/basic-languages/twig/twig.js +10 -0
- package/src/ide/vendor/vs/basic-languages/typescript/typescript.js +10 -0
- package/src/ide/vendor/vs/basic-languages/typespec/typespec.js +10 -0
- package/src/ide/vendor/vs/basic-languages/vb/vb.js +10 -0
- package/src/ide/vendor/vs/basic-languages/wgsl/wgsl.js +307 -0
- package/src/ide/vendor/vs/basic-languages/xml/xml.js +10 -0
- package/src/ide/vendor/vs/basic-languages/yaml/yaml.js +10 -0
- package/src/ide/vendor/vs/editor/editor.main.css +8 -0
- package/src/ide/vendor/vs/editor/editor.main.js +798 -0
- package/src/ide/vendor/vs/language/css/cssMode.js +13 -0
- package/src/ide/vendor/vs/language/css/cssWorker.js +77 -0
- package/src/ide/vendor/vs/language/html/htmlMode.js +13 -0
- package/src/ide/vendor/vs/language/html/htmlWorker.js +454 -0
- package/src/ide/vendor/vs/language/json/jsonMode.js +19 -0
- package/src/ide/vendor/vs/language/json/jsonWorker.js +42 -0
- package/src/ide/vendor/vs/language/typescript/tsMode.js +20 -0
- package/src/ide/vendor/vs/language/typescript/tsWorker.js +51328 -0
- package/src/ide/vendor/vs/loader.js +11 -0
- package/src/index-shared.ts +117 -0
- package/src/index.ts +586 -0
- package/src/llm.ts +721 -0
- package/src/logger.ts +39 -0
- package/src/mcp/client.ts +121 -0
- package/src/mcp/types.ts +27 -0
- package/src/oauth.ts +205 -0
- package/src/onboarding.ts +140 -0
- package/src/palette.tsx +199 -0
- package/src/permissions.ts +123 -0
- package/src/plugins/loader.ts +120 -0
- package/src/plugins/marketplace.ts +252 -0
- package/src/plugins/sandbox.ts +303 -0
- package/src/plugins/tar.ts +241 -0
- package/src/pricing.ts +78 -0
- package/src/protocol/client.ts +102 -0
- package/src/protocol/rpc.ts +43 -0
- package/src/protocol/serve.ts +136 -0
- package/src/providers.ts +402 -0
- package/src/rate-limiter.ts +101 -0
- package/src/refs.ts +97 -0
- package/src/runtime.ts +144 -0
- package/src/session.ts +401 -0
- package/src/skills/loader.ts +136 -0
- package/src/statusline.ts +70 -0
- package/src/system-prompt.ts +28 -0
- package/src/tools.ts +1280 -0
- package/src/tui.tsx +1355 -0
- package/src/update.ts +236 -0
- package/src/vendor/flashServer.ts +2 -0
- package/src/vendor/gemini-web2api/gemini_web2api.py +1136 -0
- package/src/virtual-list.tsx +125 -0
- package/src/window.ts +31 -0
- package/tsconfig.json +16 -0
package/src/commands.tsx
ADDED
|
@@ -0,0 +1,943 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slash commands — Claude Code-style palette.
|
|
3
|
+
* Each command gets a SlashIO context; returns true if handled.
|
|
4
|
+
*/
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import type { GoatConfig } from "./config.ts";
|
|
9
|
+
import { appDir, configPath, saveConfig, splitModel, MODEL_ALIASES } from "./config.ts";
|
|
10
|
+
import type { ProviderRegistry } from "./providers.ts";
|
|
11
|
+
import { CredentialStore, OAUTH_PROVIDERS, type Credential } from "./providers.ts";
|
|
12
|
+
import { Session, listSessions, allSessions, searchSessions } from "./session.ts";
|
|
13
|
+
import { cacheSavings, costUsd, fmtUsd } from "./pricing.ts";
|
|
14
|
+
import { contextWindow } from "./window.ts";
|
|
15
|
+
import { unifiedDiff, diffStats } from "./diff.ts";
|
|
16
|
+
import { contentChars, estimateTokens, textOf } from "./llm.ts";
|
|
17
|
+
import { loginDevice, loginImport, loginOauth, type LoginIO } from "./oauth.ts";
|
|
18
|
+
import { loadPlugins, pluginSkills } from "./plugins/loader.ts";
|
|
19
|
+
import type { McpClient } from "./mcp/client.ts";
|
|
20
|
+
import type { SkillDef } from "./skills/loader.ts";
|
|
21
|
+
import type { CollabSession } from "./collab/client.ts";
|
|
22
|
+
import { runCodeSlash } from "./code/slash.ts";
|
|
23
|
+
import { installPlugin, listInstalled, removePlugin, updatePlugin, searchPlugins, parseGoatUri, DEFAULT_REGISTRY_URL } from "./plugins/marketplace.ts";
|
|
24
|
+
import { resolveRepos } from "./config.ts";
|
|
25
|
+
import { ULTRACODE_FANOUT } from "./constants.ts";
|
|
26
|
+
import { runDoctor } from "./doctor.ts";
|
|
27
|
+
|
|
28
|
+
export const SLASH_COMMANDS = [
|
|
29
|
+
"/help", "/model", "/models", "/providers", "/auth", "/logout",
|
|
30
|
+
"/new", "/clear", "/compact", "/sessions", "/resume", "/rename", "/export",
|
|
31
|
+
"/mcp", "/skills", "/plugin", "/cost", "/usage", "/context", "/config",
|
|
32
|
+
"/status", "/memory", "/doctor", "/init", "/review", "/ultraplan", "/undo", "/rewind", "/permissions", "/search", "/tasks", "/quit",
|
|
33
|
+
"/peers", "/handoff", "/share", "/leave", "/index", "/find", "/marketplace",
|
|
34
|
+
"/recover", "/fork", "/diff", "/agents",
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
export interface SlashIO {
|
|
38
|
+
cfg: GoatConfig;
|
|
39
|
+
setCfg(next: GoatConfig | ((c: GoatConfig) => GoatConfig)): void;
|
|
40
|
+
registry: ProviderRegistry;
|
|
41
|
+
session: Session;
|
|
42
|
+
setSession(s: Session): void;
|
|
43
|
+
saveCfg(cfg: GoatConfig): void;
|
|
44
|
+
push(node: ReactNode): void;
|
|
45
|
+
exit(): void;
|
|
46
|
+
mcp: McpClient | null;
|
|
47
|
+
skills: SkillDef[];
|
|
48
|
+
/** Revert the last turn's file mutations; null = no toolkit yet. */
|
|
49
|
+
undoTurn(): number | null;
|
|
50
|
+
/** Rewind transcript + files to the start of turn n (1-based). null = unavailable. */
|
|
51
|
+
rewindTurn(n: number): { files: number; msgs: number } | null;
|
|
52
|
+
/** Tools the user always-allowed for this session (memory only). */
|
|
53
|
+
sessionRules(): string[];
|
|
54
|
+
backgroundTasks(): { id: string; cmd: string; status: string; started: number }[];
|
|
55
|
+
setMode(mode: "default" | "acceptEdits" | "plan" | "bypass"): void;
|
|
56
|
+
runTurn(text: string | import("./llm.ts").ContentPart[]): Promise<void>;
|
|
57
|
+
/** Clear the boot-time auth banner once credentials are set. */
|
|
58
|
+
clearAuthBanner(): void;
|
|
59
|
+
/** Summarize old context with the model; resolves to a status line. */
|
|
60
|
+
compactNow(): Promise<string>;
|
|
61
|
+
/** Re-scan plugin dirs; returns total active skills+commands. */
|
|
62
|
+
reloadPlugins(): number;
|
|
63
|
+
/** Every file mutation captured this session (for /diff); empty = none. */
|
|
64
|
+
sessionSnaps(): Array<{ path: string; before: string; after: string }>;
|
|
65
|
+
/** Custom subagent definitions (for /agents). */
|
|
66
|
+
customAgents(): Array<{ name: string; description: string; tools?: string[] }>;
|
|
67
|
+
/** Active collab session (Pillar B). */
|
|
68
|
+
collab?: CollabSession | null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export async function runSlash(line: string, io: SlashIO): Promise<boolean> {
|
|
72
|
+
const parts = line.trim().split(/\s+/);
|
|
73
|
+
const cmd = parts[0];
|
|
74
|
+
const rest = parts.slice(1);
|
|
75
|
+
const arg = rest[0] ?? "";
|
|
76
|
+
|
|
77
|
+
switch (cmd) {
|
|
78
|
+
case "/quit":
|
|
79
|
+
case "/exit":
|
|
80
|
+
io.push(<ExitNote />);
|
|
81
|
+
io.exit();
|
|
82
|
+
return true;
|
|
83
|
+
|
|
84
|
+
case "/help":
|
|
85
|
+
io.push(<HelpList />);
|
|
86
|
+
return true;
|
|
87
|
+
|
|
88
|
+
case "/doctor": {
|
|
89
|
+
const fix = rest.includes("--fix");
|
|
90
|
+
const json = rest.includes("--json");
|
|
91
|
+
const exitCode = await runDoctor(fix, json);
|
|
92
|
+
if (exitCode === 2) {
|
|
93
|
+
io.push(<Text color="#f87171">✗ Some checks failed</Text>);
|
|
94
|
+
} else if (exitCode === 1) {
|
|
95
|
+
io.push(<Text color="#fbbf24">⚠ Some warnings</Text>);
|
|
96
|
+
} else {
|
|
97
|
+
io.push(<Text color="#4ade80">✓ All checks passed</Text>);
|
|
98
|
+
}
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
case "/model": {
|
|
103
|
+
if (!arg) {
|
|
104
|
+
io.push(<Text>current model: <Text color="#a855f7">{io.cfg.model}</Text></Text>);
|
|
105
|
+
io.push(<Text dimColor color="#7c8390"> aliases: {Object.keys(MODEL_ALIASES).join(" · ")} — e.g. /model sonnet</Text>);
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
const next = { ...io.cfg, model: arg };
|
|
109
|
+
splitModel(next); // expands aliases too
|
|
110
|
+
io.setCfg(next);
|
|
111
|
+
io.saveCfg(next);
|
|
112
|
+
io.session.model = next.model;
|
|
113
|
+
io.push(<Text color="#4ade80">✓ model → {next.model}</Text>);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
case "/models": {
|
|
118
|
+
const p = io.registry.get(io.cfg.provider);
|
|
119
|
+
if (!p) { io.push(<Text color="#f87171">✗ unknown provider</Text>); return true; }
|
|
120
|
+
const live = rest.includes("--live") || rest.includes("fetch");
|
|
121
|
+
let models = p.models;
|
|
122
|
+
if (live) {
|
|
123
|
+
try {
|
|
124
|
+
const cred = io.registry.resolveCredential(p.id);
|
|
125
|
+
const headers: Record<string, string> = {};
|
|
126
|
+
if (cred?.apiKey) {
|
|
127
|
+
if (p.format === "claude") { headers["x-api-key"] = cred.apiKey; headers["anthropic-version"] = "2023-06-01"; }
|
|
128
|
+
else headers["authorization"] = `Bearer ${cred.apiKey}`;
|
|
129
|
+
} else if (cred?.accessToken) {
|
|
130
|
+
headers["authorization"] = `Bearer ${cred.accessToken}`;
|
|
131
|
+
}
|
|
132
|
+
const url = `${p.baseUrl.replace(/\/+$/, "")}/models`;
|
|
133
|
+
const res = await fetch(url, { headers, signal: AbortSignal.timeout(8000) });
|
|
134
|
+
if (res.ok) {
|
|
135
|
+
const body = await res.json() as any;
|
|
136
|
+
const list: string[] = Array.isArray(body?.data)
|
|
137
|
+
? body.data.map((m: any) => String(m.id ?? m.name ?? "")).filter(Boolean)
|
|
138
|
+
: Array.isArray(body?.models)
|
|
139
|
+
? body.models.map((m: any) => String(m.name ?? m.id ?? "").replace(/^models\//, "")).filter(Boolean)
|
|
140
|
+
: [];
|
|
141
|
+
if (list.length) models = [...new Set([...list, ...p.models])];
|
|
142
|
+
}
|
|
143
|
+
} catch { /* fall back to catalog */ }
|
|
144
|
+
}
|
|
145
|
+
const shown = models.length ? models : ["(no catalog models — type any model id, or try /models --live)"];
|
|
146
|
+
io.push(
|
|
147
|
+
<Box flexDirection="column">
|
|
148
|
+
{shown.slice(0, 40).map((m) => {
|
|
149
|
+
const full = `${p.id}/${m}`;
|
|
150
|
+
const cur = full === io.cfg.model;
|
|
151
|
+
return <Text key={m}><Text color={cur ? "#4ade80" : undefined}>{cur ? "● " : " "}</Text>{full}{cur ? <Text dimColor color="#7c8390"> ← current</Text> : null}</Text>;
|
|
152
|
+
})}
|
|
153
|
+
{shown.length > 40 && <Text dimColor color="#7c8390"> … {shown.length - 40} more</Text>}
|
|
154
|
+
</Box>,
|
|
155
|
+
);
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
case "/providers": {
|
|
160
|
+
const rows = io.registry.listAll();
|
|
161
|
+
let ready = 0;
|
|
162
|
+
for (const p of rows) if (io.registry.resolveCredential(p.id)) ready++;
|
|
163
|
+
io.push(
|
|
164
|
+
<Box flexDirection="column">
|
|
165
|
+
{rows.slice(0, 40).map((p) => {
|
|
166
|
+
const has = io.registry.resolveCredential(p.id);
|
|
167
|
+
return (
|
|
168
|
+
<Text key={p.id}>
|
|
169
|
+
<Text color={has ? "#4ade80" : "#7c8390"}>{has ? "✓" : " "} </Text>
|
|
170
|
+
<Text>{p.id.padEnd(28)}</Text>
|
|
171
|
+
<Text dimColor color="#7c8390"> [{fmtShort(p.format)}] {p.baseUrl.slice(0, 48)}</Text>
|
|
172
|
+
</Text>
|
|
173
|
+
);
|
|
174
|
+
})}
|
|
175
|
+
{rows.length > 40 && <Text dimColor color="#7c8390"> … {rows.length - 40} more</Text>}
|
|
176
|
+
</Box>,
|
|
177
|
+
);
|
|
178
|
+
io.push(<Text dimColor color="#7c8390"> {ready}/{rows.length} configured</Text>);
|
|
179
|
+
if (io.registry.hasGoatedFlash())
|
|
180
|
+
io.push(<Text dimColor color="#a855f7"> ⚡ goated-flash: active (free fallback, no key)</Text>);
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
case "/auth": {
|
|
185
|
+
if (arg === "--list" || (arg === "" && rest.includes("--list"))) {
|
|
186
|
+
io.push(<Text>OAuth providers (run /auth <id> --oauth):</Text>);
|
|
187
|
+
for (const [k, meta] of Object.entries(OAUTH_PROVIDERS))
|
|
188
|
+
io.push(<Text key={k}><Text color="#a855f7">{k.padEnd(16)}</Text><Text dimColor color="#7c8390">{meta.label}</Text></Text>);
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
if (!arg) {
|
|
192
|
+
io.push(<Text>usage: /auth <provider> --key <K> | --oauth | --list</Text>);
|
|
193
|
+
io.push(<Text dimColor color="#7c8390"> oauth: {Object.keys(OAUTH_PROVIDERS).join(", ")}</Text>);
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
const pid = arg;
|
|
197
|
+
if (rest.includes("--key")) {
|
|
198
|
+
const idx = rest.indexOf("--key") + 1;
|
|
199
|
+
const key = rest[idx];
|
|
200
|
+
if (!key) { io.push(<Text color="#f87171">usage: /auth <provider> --key <KEY></Text>); return true; }
|
|
201
|
+
io.registry.store.put(pid, { kind: "api_key", apiKey: key, expiresAt: 0 });
|
|
202
|
+
io.clearAuthBanner();
|
|
203
|
+
io.push(<Text color="#4ade80">✓ stored key for {pid}</Text>);
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
if (rest.includes("--oauth")) {
|
|
207
|
+
void oauthLogin(pid, io);
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
io.push(<Text>usage: /auth <provider> --key <K> | --oauth</Text>);
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
case "/logout": {
|
|
215
|
+
if (arg && io.registry.store.remove(arg))
|
|
216
|
+
io.push(<Text color="#4ade80">✓ credentials cleared for {arg}</Text>);
|
|
217
|
+
else io.push(<Text>usage: /logout <provider></Text>);
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
case "/new": {
|
|
222
|
+
io.session.save();
|
|
223
|
+
const s = Session.new(process.cwd(), io.cfg.model);
|
|
224
|
+
io.setSession(s);
|
|
225
|
+
io.push(<Text color="#4ade80">✓ new session</Text>);
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
case "/clear": {
|
|
230
|
+
io.session.messages = [];
|
|
231
|
+
io.session.compactedFrom = 0;
|
|
232
|
+
io.push(<Text color="#4ade80">✓ context cleared</Text>);
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
case "/compact": {
|
|
237
|
+
const msgs = io.session.messages;
|
|
238
|
+
if (msgs.length <= 12) {
|
|
239
|
+
io.push(<Text dimColor color="#7c8390"> nothing to compact yet — context is still small</Text>);
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
io.push(<Text dimColor color="#7c8390"> ✻ summarizing context…</Text>);
|
|
243
|
+
void io.compactNow().then((status) => io.push(<Text color="#4ade80">✓ {status}</Text>));
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
case "/sessions": {
|
|
248
|
+
const rows = listSessions();
|
|
249
|
+
io.push(
|
|
250
|
+
<Box flexDirection="column">
|
|
251
|
+
{rows.slice(0, 20).map((r) => (
|
|
252
|
+
<Text key={r.id}>
|
|
253
|
+
<Text color="#a855f7">{r.id}</Text> {r.model.padEnd(34)} {r.title.slice(0, 52)}
|
|
254
|
+
</Text>
|
|
255
|
+
))}
|
|
256
|
+
{rows.length === 0 && <Text dimColor color="#7c8390"> (no saved sessions)</Text>}
|
|
257
|
+
</Box>,
|
|
258
|
+
);
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
case "/fork": {
|
|
263
|
+
const name = rest.join(" ") || undefined;
|
|
264
|
+
const forked = io.session.fork(name);
|
|
265
|
+
io.setSession(forked);
|
|
266
|
+
io.push(<Text color="#4ade80">✓ forked session → {forked.id}</Text>);
|
|
267
|
+
io.push(<Text dimColor color="#7c8390"> branch: "{forked.title}" · parent: {io.session.subagentForks?.[io.session.subagentForks.length - 1]?.childId ?? "unknown"}</Text>);
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
case "/search": {
|
|
272
|
+
if (!arg) { io.push(<Text>usage: /search <query> (then /resume <id> to jump in)</Text>); return true; }
|
|
273
|
+
const hits = searchSessions(arg, 8);
|
|
274
|
+
if (!hits.length) { io.push(<Text dimColor color="#7c8390"> no saved session mentions "{arg}"</Text>); return true; }
|
|
275
|
+
io.push(
|
|
276
|
+
<Box flexDirection="column">
|
|
277
|
+
<Text> {hits.length} session(s) match "{arg}":</Text>
|
|
278
|
+
{hits.map((h) => (
|
|
279
|
+
<Text key={h.id}>
|
|
280
|
+
<Text color="#a855f7"> /resume {h.id}</Text>
|
|
281
|
+
<Text dimColor color="#7c8390"> · {new Date(h.createdAt * 1000).toISOString().slice(0, 10)} · {h.hits}× · {h.snippet.slice(0, 72)}</Text>
|
|
282
|
+
</Text>
|
|
283
|
+
))}
|
|
284
|
+
</Box>,
|
|
285
|
+
);
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
case "/resume": {
|
|
290
|
+
if (!arg) { io.push(<Text>usage: /resume <id> (see /sessions)</Text>); return true; }
|
|
291
|
+
try {
|
|
292
|
+
const s = Session.loadById(arg);
|
|
293
|
+
io.setSession(s);
|
|
294
|
+
io.push(<Text color="#4ade80">✓ resumed {arg}</Text>);
|
|
295
|
+
} catch {
|
|
296
|
+
io.push(<Text color="#f87171">✗ no such session</Text>);
|
|
297
|
+
}
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
case "/mcp": {
|
|
302
|
+
if (!io.mcp || io.mcp.servers.size === 0) {
|
|
303
|
+
io.push(<Text dimColor color="#7c8390"> no MCP servers connected — add to .mcp.json or config.json mcpServers</Text>);
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
io.push(
|
|
307
|
+
<Box flexDirection="column">
|
|
308
|
+
{[...io.mcp.servers.values()].map((e) => (
|
|
309
|
+
<Text key={e.name}>
|
|
310
|
+
<Text color="#4ade80">✓ </Text>{e.name}
|
|
311
|
+
<Text dimColor color="#7c8390"> {e.tools.size} tools</Text>
|
|
312
|
+
</Text>
|
|
313
|
+
))}
|
|
314
|
+
</Box>,
|
|
315
|
+
);
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
case "/skills": {
|
|
320
|
+
if (!io.skills.length) {
|
|
321
|
+
io.push(<Text dimColor color="#7c8390"> no skills found — add ~/.goatcode/skills/<name>/SKILL.md</Text>);
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
io.push(
|
|
325
|
+
<Box flexDirection="column">
|
|
326
|
+
{io.skills.map((sk) => (
|
|
327
|
+
<Text key={sk.name}>
|
|
328
|
+
<Text color="#a855f7">/{sk.name}</Text>
|
|
329
|
+
<Text dimColor color="#7c8390"> {sk.description}</Text>
|
|
330
|
+
</Text>
|
|
331
|
+
))}
|
|
332
|
+
</Box>,
|
|
333
|
+
);
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
case "/plugin": {
|
|
338
|
+
if (arg.toLowerCase() === "reload") {
|
|
339
|
+
const n = io.reloadPlugins();
|
|
340
|
+
io.push(<Text color="#4ade80">✓ plugins reloaded — {n} skill/command(s) active</Text>);
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
const dirs = io.cfg.pluginDirs ?? [];
|
|
344
|
+
if (!dirs.length) {
|
|
345
|
+
io.push(<Text dimColor color="#7c8390"> no plugin dirs — list dirs under "plugins" in config.json (commands/<name>.md + skills/<name>/SKILL.md)</Text>);
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
const pl = loadPlugins(dirs);
|
|
349
|
+
io.push(
|
|
350
|
+
<Box flexDirection="column">
|
|
351
|
+
{pl.map((p) => {
|
|
352
|
+
const sk = pluginSkills([p]);
|
|
353
|
+
return (
|
|
354
|
+
<Text key={p.dir}>
|
|
355
|
+
<Text color="#4ade80">✓ </Text>{p.manifest.name ?? p.dir}
|
|
356
|
+
<Text dimColor color="#7c8390"> {sk.length} command/skill(s): {sk.map((s) => "/" + s.name).join(" ")}</Text>
|
|
357
|
+
</Text>
|
|
358
|
+
);
|
|
359
|
+
})}
|
|
360
|
+
{pl.length < dirs.length && <Text color="#f87171"> {dirs.length - pl.length} dir(s) not found</Text>}
|
|
361
|
+
</Box>,
|
|
362
|
+
);
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
case "/cost": {
|
|
367
|
+
const u = io.session.usage;
|
|
368
|
+
const est = io.session.messages.reduce((s, m) => s + estimateTokens(m.content), 0);
|
|
369
|
+
io.push(<Text> session: {io.session.messages.length} messages · {u.in} in / {u.out} out tokens{u.in ? "" : " (no usage reported yet)"} · est context ~{est} · model {io.cfg.model}</Text>);
|
|
370
|
+
const cost = costUsd(io.cfg.model, u);
|
|
371
|
+
if (cost != null)
|
|
372
|
+
io.push(<Text color="#4ade80"> ≈ {fmtUsd(cost)} this session ({io.cfg.model} rates, live)</Text>);
|
|
373
|
+
else
|
|
374
|
+
io.push(<Text dimColor color="#7c8390"> no price known for {io.cfg.model} — tokens still counted above</Text>);
|
|
375
|
+
if (io.cfg.budgetUsd && io.cfg.budgetUsd > 0) {
|
|
376
|
+
const spent = cost ?? 0;
|
|
377
|
+
const pct = Math.min(100, Math.round((spent / io.cfg.budgetUsd) * 100));
|
|
378
|
+
io.push(<Text color={pct >= 90 ? "#f87171" : pct >= 70 ? "#facc15" : "#7c8390"}> budget: {fmtUsd(spent)} / {fmtUsd(io.cfg.budgetUsd)} ({pct}%) — the agent stops at 100%</Text>);
|
|
379
|
+
}
|
|
380
|
+
const saved = cacheSavings(io.cfg.model, u);
|
|
381
|
+
if (saved != null)
|
|
382
|
+
io.push(<Text color="#a855f7"> ⚡ prompt cache: {(u.cacheRead ?? 0).toLocaleString()} tok read — saved ~{fmtUsd(saved)}</Text>);
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
case "/context": {
|
|
387
|
+
const ctx = io.session.context();
|
|
388
|
+
const est = ctx.reduce((s, m) => s + estimateTokens(m.content), 0);
|
|
389
|
+
const imgs = ctx.reduce((s, m) => s + (typeof m.content === "object" ? m.content.filter((p) => p.type === "image").length : 0), 0);
|
|
390
|
+
io.push(<Text> context window: {ctx.length} messages · ~{est.toLocaleString()} tokens{imgs ? ` · ${imgs} image(s)` : ""} (estimate)</Text>);
|
|
391
|
+
if (io.session.usage.in)
|
|
392
|
+
io.push(<Text dimColor color="#7c8390"> last measured from API: {io.session.usage.in.toLocaleString()} prompt / {io.session.usage.out.toLocaleString()} completion</Text>);
|
|
393
|
+
const win = io.cfg.contextWindow ?? contextWindow(io.cfg.modelId);
|
|
394
|
+
io.push(<Text> model window: {win.toLocaleString()} tokens · ~{Math.round((est / win) * 100)}% used{io.session.usage.cacheRead ? ` · ${(io.session.usage.cacheRead ?? 0).toLocaleString()} tok served from cache` : ""}</Text>);
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
case "/config": {
|
|
399
|
+
io.push(<Text> file: {configPath()}</Text>);
|
|
400
|
+
io.push(<Text> model: {io.cfg.model} · max_tokens {io.cfg.maxTokens} · auto_approve {String(io.cfg.autoApprove)}</Text>);
|
|
401
|
+
io.push(<Text> edits: change the JSON directly, or use /model · /auth · /mcp (they save for you)</Text>);
|
|
402
|
+
if (io.registry.hasGoatedFlash())
|
|
403
|
+
io.push(<Text dimColor color="#7c8390"> goated-flash: active — Goated-Flash-Free embedded model, no key needed</Text>);
|
|
404
|
+
return true;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
case "/doctor": {
|
|
408
|
+
io.push(<Text> ✓ bun {Bun.version}</Text>);
|
|
409
|
+
io.push(<Text> ✓ {io.registry.listAll().length} providers loaded</Text>);
|
|
410
|
+
const creds = io.registry.listAll().filter((p) => io.registry.resolveCredential(p.id)).length;
|
|
411
|
+
io.push(<Text> ✓ {creds} providers with credentials</Text>);
|
|
412
|
+
io.push(<Text> {io.mcp && io.mcp.servers.size ? `✓ ${io.mcp.servers.size} MCP servers` : "· no MCP servers"}</Text>);
|
|
413
|
+
io.push(<Text> {io.skills.length ? `✓ ${io.skills.length} skills` : "· no skills"}</Text>);
|
|
414
|
+
// live HEAD probe on the active provider (catches dead base URLs)
|
|
415
|
+
const p = io.registry.get(io.cfg.provider);
|
|
416
|
+
if (!p) io.push(<Text color="#f87171">✗ provider '{io.cfg.provider}' not in catalog</Text>);
|
|
417
|
+
else if (!io.registry.resolveCredential(p.id)) io.push(<Text color="#f87171">✗ {p.id}: no credentials — /auth {p.id} --key …</Text>);
|
|
418
|
+
else {
|
|
419
|
+
io.push(<Text dimColor color="#7c8390"> probing {p.baseUrl} …</Text>);
|
|
420
|
+
void probeProvider(p.baseUrl).then((r) =>
|
|
421
|
+
io.push(r.ok
|
|
422
|
+
? <Text color="#4ade80">✓ {p.id} reachable ({r.ms}ms, HTTP {r.status})</Text>
|
|
423
|
+
: <Text color="#f87171">✗ {p.id} unreachable: {r.error ?? `HTTP ${r.status}`}</Text>),
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
return true;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
case "/export": {
|
|
430
|
+
const fmt = ["md", "html"].includes(arg.toLowerCase()) ? arg.toLowerCase() : "md";
|
|
431
|
+
const file = rest.find((r) => !["md", "html"].includes(r.toLowerCase()))
|
|
432
|
+
?? join(io.session.cwd, `goat-session-${io.session.id}.${fmt}`);
|
|
433
|
+
try {
|
|
434
|
+
writeFileSync(file, renderTranscript(io.session, fmt), "utf8");
|
|
435
|
+
io.push(<Text color="#4ade80">✓ exported {io.session.messages.length} messages → {file}</Text>);
|
|
436
|
+
} catch (e: any) {
|
|
437
|
+
io.push(<Text color="#f87171">✗ export failed: {e?.message ?? e}</Text>);
|
|
438
|
+
}
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
case "/init": {
|
|
443
|
+
void io.runTurn(
|
|
444
|
+
"Analyze this codebase and create (or rewrite) a GOAT.md file at the project root — the memory file every future GoatCode session loads first.\n\n" +
|
|
445
|
+
"Method: read the build/config files (package.json, pyproject.toml, Cargo.toml, go.mod, Makefile, CI workflows) and the 5-10 most important source files before writing anything. Do not guess.\n\n" +
|
|
446
|
+
"GOAT.md must contain, in this order, terse and factual:\n" +
|
|
447
|
+
"1. one-paragraph project overview (what it is, who uses it)\n" +
|
|
448
|
+
"2. commands — exact invocations for: install, build, run, test (single test too), lint/typecheck\n" +
|
|
449
|
+
"3. architecture — directory layout as a tree with one-line notes, data flow for the core loop\n" +
|
|
450
|
+
"4. conventions actually observed in the code (naming, file layout, error style, comment density) — with one file:line example each\n" +
|
|
451
|
+
"5. gotchas — non-obvious constraints, env vars, flaky spots, anything that would burn a new session\n\n" +
|
|
452
|
+
"Keep it under ~150 lines. Bad GOAT.md is worse than none: every claim must be something you verified by reading a file.",
|
|
453
|
+
);
|
|
454
|
+
return true;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
case "/review": {
|
|
458
|
+
const target = rest.join(" ") || "the current branch changes";
|
|
459
|
+
void io.runTurn(`Review ${target}. Report bugs, security issues, and simplifications — most severe first.`);
|
|
460
|
+
return true;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
case "/ultraplan": {
|
|
464
|
+
const topic = rest.join(" ") || "this project";
|
|
465
|
+
const n = Math.min(ULTRACODE_FANOUT, 8);
|
|
466
|
+
const scouts = [
|
|
467
|
+
`Deep audit of ${topic}: read every source file, list all functions/classes, dependencies, and their coupling. Report in markdown with file:line references.`,
|
|
468
|
+
`Security audit of ${topic}: find injection vectors, hardcoded secrets, privilege escalation paths, SSRF/prototype-polution risks, unsafe eval/exec patterns.`,
|
|
469
|
+
`Performance audit of ${topic}: find O(n²) loops, redundant work, un-indexed lookups, unbounded allocations, missing caches, blocking I/O in hot paths.`,
|
|
470
|
+
`Architecture review of ${topic}: identify circular dependencies, leaky abstractions, god objects, violated boundaries, and single points of failure.`,
|
|
471
|
+
`Testing gaps in ${topic}: find untested edge cases, missing error paths, flaky test assumptions, absent integration coverage, and brittle fixtures.`,
|
|
472
|
+
`DevX and DX friction in ${topic}: find confusing APIs, missing docs, unclear error messages, inconsistent naming, and setup blockers for new contributors.`,
|
|
473
|
+
];
|
|
474
|
+
const prompt =
|
|
475
|
+
"You are an elite code-review strategist. Decompose the analysis into " + n +
|
|
476
|
+
" independent scouts that explore " + topic + " in parallel, then synthesize a single prioritized plan.\n\n" +
|
|
477
|
+
"SPAWN " + n + " task calls IN ONE MESSAGE. Each task gets one of these roles (pick the best fit each time, rotate):\n" +
|
|
478
|
+
scouts.map((s, i) => (i + 1) + ". " + s).join("\n") +
|
|
479
|
+
"\n\nAfter all scouts return, read every report and produce a single unified plan:\n" +
|
|
480
|
+
"- Critical bugs (must fix now)\n- Security vulnerabilities\n- Performance bottlenecks\n- Architecture debt\n- Testing gaps\n- DX improvements\n- Nice-to-haves\n" +
|
|
481
|
+
"For each item: name, one-line description, file:line location, and suggested fix. Keep the plan under ~200 lines.";
|
|
482
|
+
void io.runTurn(prompt);
|
|
483
|
+
return true;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
case "/rename": {
|
|
487
|
+
const t = rest.join(" ").trim();
|
|
488
|
+
if (!t) { io.push(<Text>usage: /rename <short title></Text>); return true; }
|
|
489
|
+
io.session.title = t.slice(0, 80);
|
|
490
|
+
io.session.save();
|
|
491
|
+
io.push(<Text color="#4ade80">✓ session renamed → “{io.session.title}”</Text>);
|
|
492
|
+
return true;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
case "/usage": {
|
|
496
|
+
const u = io.session.usage;
|
|
497
|
+
const turns = io.session.messages.filter((m) => m.role === "assistant" && !m.toolCalls?.length).length;
|
|
498
|
+
const chars = io.session.messages.reduce((s, m) => s + contentChars(m.content), 0);
|
|
499
|
+
const avgIn = turns ? Math.round(u.in / turns) : 0;
|
|
500
|
+
io.push(
|
|
501
|
+
<Box flexDirection="column">
|
|
502
|
+
<Text> tokens: <Text color="#a855f7">{u.in.toLocaleString()}</Text> in · <Text color="#a855f7">{u.out.toLocaleString()}</Text> out · {turns || io.session.messages.length} turns</Text>
|
|
503
|
+
<Text dimColor color="#7c8390"> avg {avgIn.toLocaleString()} in/turn · {io.session.messages.length} messages · ~{Math.round(chars / 4).toLocaleString()} tok in history · compacted: {io.session.compactedFrom > 0 ? `first ${io.session.compactedFrom} msgs folded` : "no"}</Text>
|
|
504
|
+
</Box>,
|
|
505
|
+
);
|
|
506
|
+
if (rest.join(" ").trim() === "all" || rest.join(" ").trim() === "-a") {
|
|
507
|
+
const all = allSessions();
|
|
508
|
+
const byModel = new Map<string, { in: number; out: number; cost: number; n: number }>();
|
|
509
|
+
const byDay = new Map<string, { in: number; out: number; cost: number; n: number }>();
|
|
510
|
+
let tin = 0, tout = 0, tcost = 0, unknownCost = false;
|
|
511
|
+
for (const s of all) {
|
|
512
|
+
const c = costUsd(s.model, s.usage);
|
|
513
|
+
if (c == null) unknownCost = true;
|
|
514
|
+
for (const [key, bucket] of [
|
|
515
|
+
[s.model || "(none)", byModel],
|
|
516
|
+
[new Date(s.createdAt * 1000).toISOString().slice(0, 10), byDay],
|
|
517
|
+
] as const) {
|
|
518
|
+
const b = bucket.get(key) ?? { in: 0, out: 0, cost: 0, n: 0 };
|
|
519
|
+
b.in += s.usage.in; b.out += s.usage.out; b.cost += c ?? 0; b.n++;
|
|
520
|
+
bucket.set(key, b);
|
|
521
|
+
}
|
|
522
|
+
tin += s.usage.in; tout += s.usage.out; tcost += c ?? 0;
|
|
523
|
+
}
|
|
524
|
+
io.push(
|
|
525
|
+
<Box flexDirection="column" marginTop={1}>
|
|
526
|
+
<Text> <Text bold color="#a855f7">all time</Text> · {all.length} sessions · {tin.toLocaleString()} in / {tout.toLocaleString()} out tokens · <Text color="#4ade80">{fmtUsd(tcost)}</Text>{unknownCost ? <Text dimColor color="#7c8390"> (some models unpriced)</Text> : null}</Text>
|
|
527
|
+
</Box>,
|
|
528
|
+
);
|
|
529
|
+
const days = [...byDay.entries()].sort((a, b) => b[0].localeCompare(a[0])).slice(0, 7);
|
|
530
|
+
if (days.length) {
|
|
531
|
+
io.push(<Text dimColor color="#7c8390"> </Text>); io.push(<Text dimColor color="#7c8390"> days</Text>);
|
|
532
|
+
for (const [day, b] of days)
|
|
533
|
+
io.push(<Text> {day} {String(b.n).padStart(3)} sess {b.in.toLocaleString().padStart(12)} in {b.out.toLocaleString().padStart(10)} out <Text color="#4ade80">{fmtUsd(b.cost)}</Text></Text>);
|
|
534
|
+
}
|
|
535
|
+
const models = [...byModel.entries()].sort((a, b) => (b[1].cost ?? 0) - (a[1].cost ?? 0)).slice(0, 6);
|
|
536
|
+
if (models.length) {
|
|
537
|
+
io.push(<Text dimColor color="#7c8390"> </Text>); io.push(<Text dimColor color="#7c8390"> models</Text>);
|
|
538
|
+
for (const [model, b] of models)
|
|
539
|
+
io.push(<Text> {model.padEnd(34).slice(0, 34)} {b.in.toLocaleString().padStart(12)} in {b.out.toLocaleString().padStart(10)} out <Text color="#4ade80">{fmtUsd(b.cost)}</Text></Text>);
|
|
540
|
+
}
|
|
541
|
+
} else {
|
|
542
|
+
io.push(<Text dimColor color="#7c8390"> /usage all — cost across every stored session</Text>);
|
|
543
|
+
}
|
|
544
|
+
return true;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
case "/status": {
|
|
548
|
+
const p = io.registry.get(io.cfg.provider);
|
|
549
|
+
const cred = io.registry.resolveCredential(io.cfg.provider);
|
|
550
|
+
io.push(
|
|
551
|
+
<Box flexDirection="column">
|
|
552
|
+
<Text> model <Text color="#a855f7">{io.cfg.model}</Text>{p ? <Text dimColor color="#7c8390"> [{fmtShort(p.format)}]</Text> : null}</Text>
|
|
553
|
+
<Text> auth {cred ? <Text color="#4ade80">✓ {cred.kind === "oauth" ? "oauth token" : "api key"} ({io.cfg.provider})</Text> : <Text color="#f87171">✗ no credentials for {io.cfg.provider} — /auth {io.cfg.provider} --key …</Text>}</Text>
|
|
554
|
+
<Text> ext {io.mcp?.servers.size ?? 0} mcp · {io.skills.length} skills · plugins {io.cfg.pluginDirs?.length ?? 0}</Text>
|
|
555
|
+
<Text> sess {io.session.id} · “{(io.session.title || "untitled").slice(0, 40)}” · {gitBranch(io.session.cwd)}</Text>
|
|
556
|
+
</Box>,
|
|
557
|
+
);
|
|
558
|
+
return true;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
case "/memory": {
|
|
562
|
+
const files = [join(appDir(), "GOAT.md"), join(io.session.cwd, "GOAT.md")];
|
|
563
|
+
const rows = files
|
|
564
|
+
.filter((f) => existsSync(f))
|
|
565
|
+
.map((f) => ({ f, text: readFileSync(f, "utf8") }));
|
|
566
|
+
if (!rows.length) {
|
|
567
|
+
io.push(<Text dimColor color="#7c8390"> no memory yet — start a line with # or run /init to create GOAT.md</Text>);
|
|
568
|
+
return true;
|
|
569
|
+
}
|
|
570
|
+
io.push(
|
|
571
|
+
<Box flexDirection="column">
|
|
572
|
+
{rows.map(({ f, text }) => (
|
|
573
|
+
<Box key={f} flexDirection="column">
|
|
574
|
+
<Text color="#a855f7"> {f}</Text>
|
|
575
|
+
<Text dimColor color="#7c8390">{text.split("\n").slice(-12).map((l) => " " + l).join("\n")}</Text>
|
|
576
|
+
</Box>
|
|
577
|
+
))}
|
|
578
|
+
</Box>,
|
|
579
|
+
);
|
|
580
|
+
return true;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
case "/permissions": {
|
|
584
|
+
const rules = io.sessionRules();
|
|
585
|
+
if (!rules.length) io.push(<Text dimColor color="#7c8390"> no session rules — pick "always allow" on any prompt to add one (memory only, never saved)</Text>);
|
|
586
|
+
else io.push(
|
|
587
|
+
<Box flexDirection="column">
|
|
588
|
+
<Text> always-allowed this session:</Text>
|
|
589
|
+
{rules.map((r) => <Text key={r} color="#4ade80"> ✓ {r}</Text>)}
|
|
590
|
+
</Box>,
|
|
591
|
+
);
|
|
592
|
+
return true;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
case "/rewind": {
|
|
596
|
+
const marks = io.session.turnMarks;
|
|
597
|
+
if (!marks.length) { io.push(<Text dimColor color="#7c8390"> no rewindable turns yet (marks start with this release)</Text>); return true; }
|
|
598
|
+
const n = parseInt(arg, 10);
|
|
599
|
+
if (Number.isNaN(n)) {
|
|
600
|
+
// picker: last 10 turns with their first user line
|
|
601
|
+
const rows = marks.slice(-10).map((mark, i) => {
|
|
602
|
+
const idx = marks.length - Math.min(10, marks.length) + i;
|
|
603
|
+
const m = io.session.messages[mark];
|
|
604
|
+
const head = (m ? textOf(m.content) : "").replace(/\s+/g, " ").slice(0, 64);
|
|
605
|
+
return { idx, head };
|
|
606
|
+
});
|
|
607
|
+
io.push(
|
|
608
|
+
<Box flexDirection="column">
|
|
609
|
+
<Text> rewind to which turn? (files + transcript restored)</Text>
|
|
610
|
+
{rows.map((r) => (
|
|
611
|
+
<Text key={r.idx}>
|
|
612
|
+
<Text color="#a855f7"> /rewind {r.idx + 1}</Text>
|
|
613
|
+
<Text dimColor color="#7c8390"> · {r.head || "(image turn)"}</Text>
|
|
614
|
+
</Text>
|
|
615
|
+
))}
|
|
616
|
+
</Box>,
|
|
617
|
+
);
|
|
618
|
+
return true;
|
|
619
|
+
}
|
|
620
|
+
const res = io.rewindTurn(n);
|
|
621
|
+
if (!res) io.push(<Text color="#f87171">✗ turn {n} not available (1–{marks.length})</Text>);
|
|
622
|
+
else io.push(<Text color="#4ade80">✓ rewound to turn {n} — transcript back to {res.msgs} messages · {res.files} file mutation{res.files === 1 ? "" : "s"} restored</Text>);
|
|
623
|
+
return true;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
case "/undo": {
|
|
627
|
+
const r = io.undoTurn();
|
|
628
|
+
if (r === null) io.push(<Text color="#f87171">✗ no tool kit yet — run a turn first</Text>);
|
|
629
|
+
else if (r === 0) io.push(<Text dimColor color="#7c8390"> nothing to undo from the last turn</Text>);
|
|
630
|
+
else io.push(<Text color="#4ade80">✓ reverted {r} file mutation{r > 1 ? "s" : ""} from the last turn</Text>);
|
|
631
|
+
return true;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
case "/diff": {
|
|
635
|
+
const snaps = io.sessionSnaps();
|
|
636
|
+
if (!snaps.length) { io.push(<Text dimColor color="#7c8390"> no file changes this session yet</Text>); return true; }
|
|
637
|
+
// collapse to the latest state per file, with +additions/-deletions
|
|
638
|
+
const perFile = new Map<string, { before: string; after: string; ops: number }>();
|
|
639
|
+
for (const s of snaps) {
|
|
640
|
+
const cur = perFile.get(s.path);
|
|
641
|
+
if (cur) { cur.after = s.after; cur.ops++; }
|
|
642
|
+
else perFile.set(s.path, { before: s.before, after: s.after, ops: 1 });
|
|
643
|
+
}
|
|
644
|
+
let adds = 0, dels = 0;
|
|
645
|
+
const rows: ReactNode[] = [];
|
|
646
|
+
for (const [path, f] of perFile) {
|
|
647
|
+
const stats = diffStats(unifiedDiff(f.before, f.after, 0));
|
|
648
|
+
adds += stats.added; dels += stats.removed;
|
|
649
|
+
const isNew = f.before === "";
|
|
650
|
+
rows.push(
|
|
651
|
+
<Text key={path}>
|
|
652
|
+
<Text color={isNew ? "#4ade80" : "#a855f7"}>{isNew ? "+" : "±"}</Text>{" "}
|
|
653
|
+
<Text>{path}</Text>
|
|
654
|
+
<Text color="#4ade80"> +{stats.added}</Text>
|
|
655
|
+
<Text color="#f87171"> -{stats.removed}</Text>
|
|
656
|
+
{f.ops > 1 ? <Text dimColor color="#7c8390"> ({f.ops} edits)</Text> : null}
|
|
657
|
+
</Text>,
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
io.push(
|
|
661
|
+
<Box flexDirection="column">
|
|
662
|
+
<Text bold>Session changes — {perFile.size} file{perFile.size === 1 ? "" : "s"}</Text>
|
|
663
|
+
{rows}
|
|
664
|
+
<Text dimColor color="#7c8390"> total: <Text color="#4ade80">+{adds}</Text> / <Text color="#f87171">-{dels}</Text> lines · /undo to revert the last turn</Text>
|
|
665
|
+
</Box>,
|
|
666
|
+
);
|
|
667
|
+
return true;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
case "/agents": {
|
|
671
|
+
const list = io.customAgents();
|
|
672
|
+
if (!list.length) {
|
|
673
|
+
io.push(
|
|
674
|
+
<Box flexDirection="column">
|
|
675
|
+
<Text dimColor color="#7c8390"> no custom subagents</Text>
|
|
676
|
+
<Text dimColor color="#7c8390"> add one: ~/.goatcode/agents/name.md with frontmatter:</Text>
|
|
677
|
+
<Text dimColor color="#7c8390"> ---</Text>
|
|
678
|
+
<Text dimColor color="#7c8390"> description: what this agent is for</Text>
|
|
679
|
+
<Text dimColor color="#7c8390"> tools: read, grep, glob, bash</Text>
|
|
680
|
+
<Text dimColor color="#7c8390"> ---</Text>
|
|
681
|
+
<Text dimColor color="#7c8390"> (markdown body = the agent's system prompt)</Text>
|
|
682
|
+
</Box>,
|
|
683
|
+
);
|
|
684
|
+
return true;
|
|
685
|
+
}
|
|
686
|
+
io.push(
|
|
687
|
+
<Box flexDirection="column">
|
|
688
|
+
<Text bold>Custom subagents — pass as task subagent_type</Text>
|
|
689
|
+
{list.map((a) => (
|
|
690
|
+
<Text key={a.name}>
|
|
691
|
+
<Text color="#a855f7">{a.name.padEnd(16)}</Text>
|
|
692
|
+
<Text dimColor color="#7c8390"> {a.description}{a.tools?.length ? ` · tools: ${a.tools.join(",")}` : " · all tools"}</Text>
|
|
693
|
+
</Text>
|
|
694
|
+
))}
|
|
695
|
+
</Box>,
|
|
696
|
+
);
|
|
697
|
+
return true;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
case "/tasks": {
|
|
701
|
+
const rows = io.backgroundTasks();
|
|
702
|
+
if (!rows.length) { io.push(<Text dimColor color="#7c8390"> no background tasks</Text>); return true; }
|
|
703
|
+
io.push(
|
|
704
|
+
<Box flexDirection="column">
|
|
705
|
+
{rows.map((t) => (
|
|
706
|
+
<Text key={t.id}>
|
|
707
|
+
<Text color="#a855f7">{t.id.padEnd(24)}</Text>
|
|
708
|
+
<Text color={t.status === "running" ? "#facc15" : t.status.startsWith("exit") ? "#f87171" : "#4ade80"}>
|
|
709
|
+
{t.status === "running" ? "● running" : "✓ done"}
|
|
710
|
+
</Text>
|
|
711
|
+
<Text dimColor color="#7c8390"> {t.cmd.slice(0, 48)}</Text>
|
|
712
|
+
</Text>
|
|
713
|
+
))}
|
|
714
|
+
</Box>,
|
|
715
|
+
);
|
|
716
|
+
return true;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
case "/recover": {
|
|
720
|
+
const recovery = await io.session.recover();
|
|
721
|
+
if (recovery.recovered) {
|
|
722
|
+
io.push(<Text color="#4ade80">✓ recovered {recovery.tools.length} pending tool call(s) from last turn</Text>);
|
|
723
|
+
for (const tool of recovery.tools) {
|
|
724
|
+
await io.runTurn(`${tool.tool}(${JSON.stringify(tool.args)})`);
|
|
725
|
+
}
|
|
726
|
+
} else {
|
|
727
|
+
io.push(<Text dimColor color="#7c8390"> no pending work to recover</Text>);
|
|
728
|
+
}
|
|
729
|
+
return true;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
case "/index":
|
|
733
|
+
case "/find": {
|
|
734
|
+
void runCodeSlash(line, {
|
|
735
|
+
roots: resolveRepos(io.cfg.repos, process.cwd()),
|
|
736
|
+
push: (n: any) => io.push(<Text color="#7c8390"> {typeof n?.text === "string" ? n.text : String(n?.text ?? n ?? "")}</Text>),
|
|
737
|
+
});
|
|
738
|
+
return true;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
case "/marketplace": {
|
|
742
|
+
const q = arg;
|
|
743
|
+
io.push(<Text dimColor color="#7c8390"> marketplace: {DEFAULT_REGISTRY_URL}</Text>);
|
|
744
|
+
(async () => {
|
|
745
|
+
try {
|
|
746
|
+
const res = q ? await searchPlugins(q, io.cfg) : listInstalled(io.cfg);
|
|
747
|
+
if (typeof res === "string") { io.push(<Text color="#f87171"> {res}</Text>); return; }
|
|
748
|
+
const items = "plugins" in res ? res.plugins : res;
|
|
749
|
+
const list = items as Array<{ name: string; version: string; description: string }>;
|
|
750
|
+
if (!list.length) { io.push(<Text dimColor color="#7c8390"> no results</Text>); return; }
|
|
751
|
+
io.push(
|
|
752
|
+
<Box flexDirection="column">
|
|
753
|
+
{list.map((p) => (
|
|
754
|
+
<Text key={p.name}> <Text color="#4ade80">✓ {p.name}</Text> <Text dimColor color="#7c8390">v{p.version}</Text> — {p.description}</Text>
|
|
755
|
+
))}
|
|
756
|
+
</Box>,
|
|
757
|
+
);
|
|
758
|
+
} catch (e: any) { io.push(<Text color="#f87171"> marketplace error: {e?.message ?? e}</Text>); }
|
|
759
|
+
})();
|
|
760
|
+
return true;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
case "/peers": {
|
|
764
|
+
const cs = io.collab;
|
|
765
|
+
if (!cs) { io.push(<Text dimColor color="#7c8390"> collab: not active</Text>); return true; }
|
|
766
|
+
const peers = cs.peers();
|
|
767
|
+
io.push(<Text> peers: {peers.length ? peers.map((p) => p.name).join(", ") : "(none)"}</Text>);
|
|
768
|
+
const holder = cs.holder();
|
|
769
|
+
io.push(<Text> turn: <Text color="#a855f7">{holder === cs.actor ? "you" : holder ?? "unknown"}</Text></Text>);
|
|
770
|
+
return true;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
case "/handoff": {
|
|
774
|
+
const cs = io.collab;
|
|
775
|
+
if (!cs) { io.push(<Text dimColor color="#7c8390"> collab: not active</Text>); return true; }
|
|
776
|
+
const target = rest.join(" ").trim();
|
|
777
|
+
if (!target) { io.push(<Text>usage: /handoff <peer name></Text>); return true; }
|
|
778
|
+
if (!cs.peers().some((p) => p.name === target)) { io.push(<Text color="#f87171">✗ no such peer "{target}" (see /peers)</Text>); return true; }
|
|
779
|
+
if (cs.holder() !== cs.actor) { io.push(<Text color="#f87171">✗ only the turn holder can hand off</Text>); return true; }
|
|
780
|
+
cs.grant(target);
|
|
781
|
+
io.push(<Text color="#4ade80">✓ turn handed to {target}</Text>);
|
|
782
|
+
return true;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
case "/share": {
|
|
786
|
+
const cs = io.collab;
|
|
787
|
+
if (!cs) { io.push(<Text dimColor color="#7c8390"> collab: not active</Text>); return true; }
|
|
788
|
+
io.push(<Text> invite code:</Text>);
|
|
789
|
+
io.push(<Text dimColor color="#7c8390"> {cs.inviteCode}</Text>);
|
|
790
|
+
return true;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
case "/leave": {
|
|
794
|
+
const cs = io.collab;
|
|
795
|
+
if (!cs) { io.push(<Text dimColor color="#7c8390"> collab: not active</Text>); return true; }
|
|
796
|
+
cs.close();
|
|
797
|
+
io.push(<Text color="#4ade80">✓ left the collab room</Text>);
|
|
798
|
+
return true;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
default:
|
|
802
|
+
io.push(<Text color="#f87171">✗ unknown command {cmd}</Text>);
|
|
803
|
+
return true;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
async function oauthLogin(pid: string, io: SlashIO): Promise<void> {
|
|
808
|
+
const meta = OAUTH_PROVIDERS[pid];
|
|
809
|
+
if (!meta) {
|
|
810
|
+
io.push(<Text color="#f87171">✗ {pid} has no OAuth flow — try: {Object.keys(OAUTH_PROVIDERS).join(", ")}</Text>);
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
const io2: LoginIO = {
|
|
814
|
+
print: (s) => io.push(<Text>{s}</Text>),
|
|
815
|
+
prompt: async (q) => {
|
|
816
|
+
// Ink can't nest a second TextInput mid-render; fall back to raw stdin.
|
|
817
|
+
process.stdout.write(q);
|
|
818
|
+
return new Promise<string>((res) => {
|
|
819
|
+
let buf = "";
|
|
820
|
+
const onData = (d: Buffer) => {
|
|
821
|
+
buf += d.toString("utf8");
|
|
822
|
+
const nl = buf.indexOf("\n");
|
|
823
|
+
if (nl >= 0) {
|
|
824
|
+
process.stdin.removeListener("data", onData);
|
|
825
|
+
res(buf.slice(0, nl).trim());
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
process.stdin.setRawMode?.(false);
|
|
829
|
+
process.stdin.on("data", onData);
|
|
830
|
+
});
|
|
831
|
+
},
|
|
832
|
+
};
|
|
833
|
+
try {
|
|
834
|
+
let cred: Credential;
|
|
835
|
+
const flow = meta.flow ?? "browser";
|
|
836
|
+
if (flow === "device") cred = await loginDevice(pid, io2);
|
|
837
|
+
else if (flow === "import") cred = await loginImport(pid, io2);
|
|
838
|
+
else cred = await loginOauth(pid, io2);
|
|
839
|
+
io.registry.store.put(pid, cred);
|
|
840
|
+
io.clearAuthBanner();
|
|
841
|
+
io.push(<Text color="#4ade80">✓ logged in to {pid}</Text>);
|
|
842
|
+
io.push(<Text dimColor color="#7c8390"> try: /model {pid}/{meta.model_prefix}-…</Text>);
|
|
843
|
+
} catch (e: any) {
|
|
844
|
+
io.push(<Text color="#f87171">✗ login failed: {e?.message ?? String(e)}</Text>);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
function fmtShort(f: string): string {
|
|
849
|
+
return { openai: "oai", claude: "ant", "openai-responses": "rsp", gemini: "gem" }[f] ?? f;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/** Live HEAD probe of a provider base URL — used by /doctor. */
|
|
853
|
+
async function probeProvider(baseUrl: string): Promise<{ ok: boolean; ms: number; status?: number; error?: string }> {
|
|
854
|
+
const t0 = Date.now();
|
|
855
|
+
try {
|
|
856
|
+
const res = await fetch(baseUrl, { method: "HEAD", redirect: "follow", signal: AbortSignal.timeout(8000) });
|
|
857
|
+
return { ok: res.ok, ms: Date.now() - t0, status: res.status };
|
|
858
|
+
} catch (e: any) {
|
|
859
|
+
return { ok: false, ms: Date.now() - t0, error: String(e?.message ?? e).slice(0, 120) };
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/** Render the conversation to markdown or HTML for /export. */
|
|
864
|
+
function renderTranscript(session: Session, fmt: string): string {
|
|
865
|
+
const title = session.title || session.id;
|
|
866
|
+
const head = fmt === "html"
|
|
867
|
+
? `<!doctype html><html><head><meta charset="utf-8"><title>${escapeHtml(title)}</title>
|
|
868
|
+
<style>body{font:14px/1.5 ui-monospace,monospace;max-width:880px;margin:2em auto;padding:0 1em;color:#111}
|
|
869
|
+
pre{background:#f4f4f4;padding:1em;overflow:auto}.user{color:#0066cc}.tool{color:#888;font-size:12px}
|
|
870
|
+
.assistant{color:#008800}h1{border-bottom:1px solid #ccc}</style></head><body>`
|
|
871
|
+
: `# ${title}\n\n`;
|
|
872
|
+
const tail = fmt === "html" ? "</body></html>" : "";
|
|
873
|
+
const body = session.messages.map((m) => {
|
|
874
|
+
const role = m.role;
|
|
875
|
+
const text = textOf(m.content);
|
|
876
|
+
const tools = m.toolCalls?.map((tc) => `- ${tc.name}(${JSON.stringify(tc.arguments).slice(0, 120)})`).join("\n");
|
|
877
|
+
if (fmt === "html") {
|
|
878
|
+
return `<pre class="${role}"><b>[${role}]</b>\n${escapeHtml(text)}${tools ? `\n${escapeHtml(tools)}` : ""}</pre>`;
|
|
879
|
+
}
|
|
880
|
+
return `[${role}] ${text.split("\n").map((l) => " " + l).join("\n")}${tools ? `\n${tools}` : ""}`;
|
|
881
|
+
}).join("\n\n");
|
|
882
|
+
return head + body + tail;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
function escapeHtml(s: string): string {
|
|
886
|
+
return s.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ }[c]!));
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/** Current git branch (best-effort) for /status. */
|
|
890
|
+
function gitBranch(cwd: string): string {
|
|
891
|
+
try {
|
|
892
|
+
const head = Bun.spawnSync({ cmd: ["git", "rev-parse", "--abbrev-ref", "HEAD"], cwd, stderr: "ignore", stdout: "pipe" });
|
|
893
|
+
if (head.exitCode !== 0) return "not a git repo";
|
|
894
|
+
return new TextDecoder().decode(head.stdout).trim();
|
|
895
|
+
} catch {
|
|
896
|
+
return "";
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
// ---------- tiny presentational components ----------
|
|
901
|
+
import { Box, Text } from "ink";
|
|
902
|
+
|
|
903
|
+
function ExitNote() {
|
|
904
|
+
return <Text dimColor color="#7c8390">bye</Text>;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
function HelpList() {
|
|
908
|
+
return (
|
|
909
|
+
<Box flexDirection="column">
|
|
910
|
+
{SLASH_COMMANDS.map((c) => (
|
|
911
|
+
<Text key={c}><Text color="#a855f7">{c.padEnd(14)}</Text><Text dimColor color="#7c8390"> {descOf(c)}</Text></Text>
|
|
912
|
+
))}
|
|
913
|
+
</Box>
|
|
914
|
+
);
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
export const COMMAND_DESC: Record<string, string> = {
|
|
918
|
+
"/help": "show help", "/model": "switch model", "/models": "list models",
|
|
919
|
+
"/providers": "list providers", "/auth": "add credentials", "/logout": "clear credentials",
|
|
920
|
+
"/new": "new session", "/clear": "clear context", "/compact": "fold old context into a digest",
|
|
921
|
+
"/sessions": "list sessions", "/resume": "resume a session", "/mcp": "manage MCP servers",
|
|
922
|
+
"/skills": "list skills", "/plugin": "manage plugins", "/cost": "session cost",
|
|
923
|
+
"/usage": "token usage stats", "/context": "context usage", "/config": "show config file + values",
|
|
924
|
+
"/status": "session + provider status", "/memory": "show GOAT.md", "/rename": "rename the session",
|
|
925
|
+
"/export": "save the conversation (md/html)", "/doctor": "diagnose install (live probe)",
|
|
926
|
+
"/init": "create GOAT.md", "/review": "review a PR", "/undo": "revert last turn's file changes",
|
|
927
|
+
"/diff": "show every file change made this session (+/- lines per file)",
|
|
928
|
+
"/agents": "list custom subagents (task subagent_type values)",
|
|
929
|
+
"/tasks": "list background bash tasks", "/ultraplan": "decompose into parallel scouts → unified plan",
|
|
930
|
+
"/quit": "exit",
|
|
931
|
+
"/rewind": "jump transcript + files back to a turn", "/search": "full-text search saved sessions",
|
|
932
|
+
"/permissions": "list always-allow rules this session",
|
|
933
|
+
"/index": "build/refresh the workspace code index", "/find": "ranked symbol lookup across repos",
|
|
934
|
+
"/share": "invite into this session (relay)", "/leave": "leave the collab session",
|
|
935
|
+
"/peers": "list connected peers", "/handoff": "give the turn to a peer",
|
|
936
|
+
"/marketplace": "browse/install plugins",
|
|
937
|
+
"/recover": "recover pending tool calls from a crashed turn",
|
|
938
|
+
"/fork": "create a branch from current session (preserves conversation history)",
|
|
939
|
+
};
|
|
940
|
+
|
|
941
|
+
function descOf(cmd: string): string {
|
|
942
|
+
return COMMAND_DESC[cmd] ?? "";
|
|
943
|
+
}
|