@chances-ai/cli 1.0.0 → 3.0.0
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/dist/boot/create-app.d.ts +3 -1
- package/dist/boot/create-app.d.ts.map +1 -1
- package/dist/boot/create-app.js +5 -6
- package/dist/boot/create-app.js.map +1 -1
- package/dist/boot/load-runtime.d.ts +7 -1
- package/dist/boot/load-runtime.d.ts.map +1 -1
- package/dist/boot/load-runtime.js +24 -4
- package/dist/boot/load-runtime.js.map +1 -1
- package/dist/commands/chat.d.ts +9 -1
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +95 -39
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/discover.d.ts +39 -0
- package/dist/commands/discover.d.ts.map +1 -0
- package/dist/commands/discover.js +280 -0
- package/dist/commands/discover.js.map +1 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +5 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/prompt.d.ts.map +1 -1
- package/dist/commands/prompt.js +30 -5
- package/dist/commands/prompt.js.map +1 -1
- package/dist/commands/stats.d.ts +42 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/stats.js +172 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +4 -0
- package/dist/entrypoints/cli.js.map +1 -1
- package/dist/slash/clear.d.ts +13 -0
- package/dist/slash/clear.d.ts.map +1 -0
- package/dist/slash/clear.js +28 -0
- package/dist/slash/clear.js.map +1 -0
- package/dist/slash/compact.d.ts +4 -0
- package/dist/slash/compact.d.ts.map +1 -0
- package/dist/slash/compact.js +68 -0
- package/dist/slash/compact.js.map +1 -0
- package/dist/slash/help.d.ts +13 -0
- package/dist/slash/help.d.ts.map +1 -0
- package/dist/slash/help.js +34 -0
- package/dist/slash/help.js.map +1 -0
- package/dist/slash/index.d.ts +22 -0
- package/dist/slash/index.d.ts.map +1 -0
- package/dist/slash/index.js +20 -0
- package/dist/slash/index.js.map +1 -0
- package/dist/slash/logout.d.ts +15 -0
- package/dist/slash/logout.d.ts.map +1 -0
- package/dist/slash/logout.js +44 -0
- package/dist/slash/logout.js.map +1 -0
- package/dist/slash/model.d.ts +14 -0
- package/dist/slash/model.d.ts.map +1 -0
- package/dist/slash/model.js +87 -0
- package/dist/slash/model.js.map +1 -0
- package/dist/slash/persist.d.ts +16 -0
- package/dist/slash/persist.d.ts.map +1 -0
- package/dist/slash/persist.js +46 -0
- package/dist/slash/persist.js.map +1 -0
- package/dist/slash/provider.d.ts +17 -0
- package/dist/slash/provider.d.ts.map +1 -0
- package/dist/slash/provider.js +98 -0
- package/dist/slash/provider.js.map +1 -0
- package/dist/slash/resume.d.ts +15 -0
- package/dist/slash/resume.d.ts.map +1 -0
- package/dist/slash/resume.js +76 -0
- package/dist/slash/resume.js.map +1 -0
- package/package.json +15 -13
|
@@ -2,7 +2,9 @@ import { AgentEngine } from "@chances-ai/core";
|
|
|
2
2
|
import { type PermissionResolver } from "@chances-ai/tools";
|
|
3
3
|
import type { SessionManager } from "@chances-ai/session";
|
|
4
4
|
import type { AppContext } from "./load-runtime.js";
|
|
5
|
-
/** Wires an AgentEngine for a given session and permission resolver.
|
|
5
|
+
/** Wires an AgentEngine for a given session and permission resolver. Passes
|
|
6
|
+
* the AppContext's `selection` (mutable model preference) through so a later
|
|
7
|
+
* `/model` slash command can mutate it without rebuilding the engine. */
|
|
6
8
|
export declare function buildEngine(ctx: AppContext, session: SessionManager, resolver: PermissionResolver): AgentEngine;
|
|
7
9
|
/** Auto-resolver for non-interactive modes: approve only when --yes was passed. */
|
|
8
10
|
export declare function autoResolver(approve: boolean): PermissionResolver;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-app.d.ts","sourceRoot":"","sources":["../../src/boot/create-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-app.d.ts","sourceRoot":"","sources":["../../src/boot/create-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;yEAEyE;AACzE,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,kBAAkB,GAAG,WAAW,CAa/G;AAED,mFAAmF;AACnF,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,kBAAkB,CAEjE"}
|
package/dist/boot/create-app.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { AgentEngine } from "@chances-ai/core";
|
|
2
|
-
import { MemoryStore } from "@chances-ai/memory";
|
|
3
2
|
import { PermissionGate } from "@chances-ai/tools";
|
|
4
|
-
/** Wires an AgentEngine for a given session and permission resolver.
|
|
3
|
+
/** Wires an AgentEngine for a given session and permission resolver. Passes
|
|
4
|
+
* the AppContext's `selection` (mutable model preference) through so a later
|
|
5
|
+
* `/model` slash command can mutate it without rebuilding the engine. */
|
|
5
6
|
export function buildEngine(ctx, session, resolver) {
|
|
6
7
|
const gate = new PermissionGate(ctx.config.permissions, resolver);
|
|
7
|
-
const memory = new MemoryStore(ctx.workspaceRoot);
|
|
8
8
|
return new AgentEngine({
|
|
9
9
|
bus: ctx.bus,
|
|
10
10
|
router: ctx.router,
|
|
11
11
|
tools: ctx.tools,
|
|
12
12
|
gate,
|
|
13
13
|
session,
|
|
14
|
-
memory,
|
|
14
|
+
memory: ctx.memory,
|
|
15
15
|
plugins: ctx.plugins,
|
|
16
16
|
workspaceRoot: ctx.workspaceRoot,
|
|
17
|
-
|
|
18
|
-
preferredProvider: ctx.config.provider,
|
|
17
|
+
selection: ctx.selection,
|
|
19
18
|
});
|
|
20
19
|
}
|
|
21
20
|
/** Auto-resolver for non-interactive modes: approve only when --yes was passed. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-app.js","sourceRoot":"","sources":["../../src/boot/create-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"create-app.js","sourceRoot":"","sources":["../../src/boot/create-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAA2B,MAAM,mBAAmB,CAAC;AAI5E;;yEAEyE;AACzE,MAAM,UAAU,WAAW,CAAC,GAAe,EAAE,OAAuB,EAAE,QAA4B;IAChG,MAAM,IAAI,GAAG,IAAI,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAClE,OAAO,IAAI,WAAW,CAAC;QACrB,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,IAAI;QACJ,OAAO;QACP,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,SAAS,EAAE,GAAG,CAAC,SAAS;KACzB,CAAC,CAAC;AACL,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC3C,OAAO,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC;AAC7B,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { EventBus, FeatureFlags, Logger, type LogLevel } from "@chances-ai/runtime";
|
|
1
|
+
import { EventBus, FeatureFlags, Logger, ModelSelection, type LogLevel } from "@chances-ai/runtime";
|
|
2
2
|
import { AuthStore, type ChancesConfig, type ExternalPluginEntry } from "@chances-ai/config";
|
|
3
3
|
import { ModelRegistry, ModelRouter } from "@chances-ai/ai";
|
|
4
4
|
import { ToolRegistry } from "@chances-ai/tools";
|
|
5
|
+
import { MemoryStore } from "@chances-ai/memory";
|
|
5
6
|
import { TelemetrySink } from "@chances-ai/telemetry";
|
|
6
7
|
import { PluginHost, type Plugin } from "@chances-ai/plugin-api";
|
|
7
8
|
export interface AppContext {
|
|
@@ -13,9 +14,14 @@ export interface AppContext {
|
|
|
13
14
|
registry: ModelRegistry;
|
|
14
15
|
router: ModelRouter;
|
|
15
16
|
tools: ToolRegistry;
|
|
17
|
+
memory: MemoryStore;
|
|
16
18
|
telemetry: TelemetrySink;
|
|
17
19
|
plugins: PluginHost | undefined;
|
|
18
20
|
workspaceRoot: string;
|
|
21
|
+
/** Mutable model preference seeded from config; `/model` mutates this so the
|
|
22
|
+
* next turn picks up the choice without rebuilding the engine. Built-in
|
|
23
|
+
* slash commands receive the same instance via closure capture. */
|
|
24
|
+
selection: ModelSelection;
|
|
19
25
|
}
|
|
20
26
|
export interface RuntimeOverrides {
|
|
21
27
|
provider?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-runtime.d.ts","sourceRoot":"","sources":["../../src/boot/load-runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load-runtime.d.ts","sourceRoot":"","sources":["../../src/boot/load-runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,cAAc,EACd,KAAK,QAAQ,EACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,SAAS,EAET,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,aAAa,EACb,WAAW,EAGZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAgB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAe,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGjE,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,QAAQ,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,aAAa,CAAC;IACzB,OAAO,EAAE,UAAU,GAAG,SAAS,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB;;uEAEmE;IACnE,SAAS,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,iFAAiF;AACjF,wBAAsB,WAAW,CAAC,SAAS,GAAE,gBAAqB,GAAG,OAAO,CAAC,UAAU,CAAC,CAyCvF;AA2CD;;;yBAGyB;AACzB,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,mBAAmB,EAC1B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,CAAC,CAsBjB"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
1
2
|
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
2
3
|
import { pathToFileURL } from "node:url";
|
|
3
|
-
import { EventBus, FeatureFlags, Logger, } from "@chances-ai/runtime";
|
|
4
|
+
import { EventBus, FeatureFlags, Logger, ModelSelection, } from "@chances-ai/runtime";
|
|
4
5
|
import { AuthStore, loadConfig, } from "@chances-ai/config";
|
|
5
|
-
import { ModelRegistry, ModelRouter, buildRegistry } from "@chances-ai/ai";
|
|
6
|
+
import { KNOWN_MODELS, ModelRegistry, ModelRouter, buildRegistry, envByProviderFrom, } from "@chances-ai/ai";
|
|
6
7
|
import { ToolRegistry, builtinTools } from "@chances-ai/tools";
|
|
8
|
+
import { MemoryStore, memoryTools } from "@chances-ai/memory";
|
|
7
9
|
import { TelemetrySink } from "@chances-ai/telemetry";
|
|
8
10
|
import { PluginHost } from "@chances-ai/plugin-api";
|
|
9
11
|
import { loggerPlugin } from "@chances-ai/plugin-logger";
|
|
@@ -17,16 +19,34 @@ export async function loadRuntime(overrides = {}) {
|
|
|
17
19
|
const bus = new EventBus();
|
|
18
20
|
const flags = new FeatureFlags();
|
|
19
21
|
const logger = new Logger(bus, overrides.logLevel ?? "warn");
|
|
20
|
-
const auth = new AuthStore();
|
|
22
|
+
const auth = new AuthStore(process.env, { envByProvider: envByProviderFrom(KNOWN_MODELS) });
|
|
21
23
|
const registry = buildRegistry({ apiKeyFor: (p) => auth.apiKey(p) });
|
|
22
24
|
const router = new ModelRouter(registry);
|
|
23
25
|
const tools = new ToolRegistry();
|
|
24
26
|
for (const tool of builtinTools)
|
|
25
27
|
tools.register(tool);
|
|
28
|
+
const memory = new MemoryStore({ workspaceRoot: config.workspaceRoot, homeDir: homedir() });
|
|
29
|
+
for (const tool of memoryTools(memory))
|
|
30
|
+
tools.register(tool);
|
|
26
31
|
const telemetry = new TelemetrySink(config.workspaceRoot);
|
|
27
32
|
telemetry.attach(bus);
|
|
28
33
|
const plugins = await loadPlugins(config, bus, logger, tools);
|
|
29
|
-
|
|
34
|
+
const selection = new ModelSelection({ provider: config.provider, model: config.model });
|
|
35
|
+
return {
|
|
36
|
+
bus,
|
|
37
|
+
logger,
|
|
38
|
+
flags,
|
|
39
|
+
config,
|
|
40
|
+
auth,
|
|
41
|
+
registry,
|
|
42
|
+
router,
|
|
43
|
+
tools,
|
|
44
|
+
memory,
|
|
45
|
+
telemetry,
|
|
46
|
+
plugins,
|
|
47
|
+
workspaceRoot: config.workspaceRoot,
|
|
48
|
+
selection,
|
|
49
|
+
};
|
|
30
50
|
}
|
|
31
51
|
/**
|
|
32
52
|
* Builds and loads the plugin host. Returns `undefined` when no plugin is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-runtime.js","sourceRoot":"","sources":["../../src/boot/load-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,MAAM,
|
|
1
|
+
{"version":3,"file":"load-runtime.js","sourceRoot":"","sources":["../../src/boot/load-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,cAAc,GAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,SAAS,EACT,UAAU,GAGX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,YAAY,EACZ,aAAa,EACb,WAAW,EACX,aAAa,EACb,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB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@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { AppContext } from "../boot/load-runtime.js";
|
|
2
2
|
import type { CliCommand } from "./registry.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Interactive Ink chat with respawn-loop semantics. A slash command like
|
|
5
|
+
* `/resume <id>` requests a respawn; the outer loop tears down the current
|
|
6
|
+
* engine + TUI instance and re-enters with the chosen session. `/clear`
|
|
7
|
+
* stays in-session (no respawn) — see slash/clear.ts.
|
|
8
|
+
*
|
|
9
|
+
* One ChatViewModel and one ModalController are recreated per session so
|
|
10
|
+
* scrollback and any in-flight modal cleanly reset on respawn.
|
|
11
|
+
*/
|
|
4
12
|
export declare function runInteractive(ctx: AppContext): Promise<number>;
|
|
5
13
|
export declare const chatCommand: CliCommand;
|
|
6
14
|
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/commands/chat.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/commands/chat.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAIhD;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CA6FrE;AAED,eAAO,MAAM,WAAW,EAAE,UAczB,CAAC"}
|
package/dist/commands/chat.js
CHANGED
|
@@ -1,48 +1,104 @@
|
|
|
1
1
|
import { CancellationTokenSource } from "@chances-ai/runtime";
|
|
2
2
|
import { SessionManager, SessionStore } from "@chances-ai/session";
|
|
3
|
-
import { parseSlashInput } from "@chances-ai/plugin-api";
|
|
4
|
-
import { ChatViewModel, renderChat } from "@chances-ai/tui";
|
|
3
|
+
import { parseSlashInput, PluginHost } from "@chances-ai/plugin-api";
|
|
4
|
+
import { ChatViewModel, ModalController, renderChat } from "@chances-ai/tui";
|
|
5
5
|
import { buildEngine } from "../boot/create-app.js";
|
|
6
6
|
import { runPrompt } from "./prompt.js";
|
|
7
|
-
|
|
7
|
+
import { registerBuiltinSlashCommands } from "../slash/index.js";
|
|
8
|
+
/**
|
|
9
|
+
* Interactive Ink chat with respawn-loop semantics. A slash command like
|
|
10
|
+
* `/resume <id>` requests a respawn; the outer loop tears down the current
|
|
11
|
+
* engine + TUI instance and re-enters with the chosen session. `/clear`
|
|
12
|
+
* stays in-session (no respawn) — see slash/clear.ts.
|
|
13
|
+
*
|
|
14
|
+
* One ChatViewModel and one ModalController are recreated per session so
|
|
15
|
+
* scrollback and any in-flight modal cleanly reset on respawn.
|
|
16
|
+
*/
|
|
8
17
|
export async function runInteractive(ctx) {
|
|
9
18
|
const store = new SessionStore(ctx.workspaceRoot);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
19
|
+
let resumeFromId;
|
|
20
|
+
while (true) {
|
|
21
|
+
const session = resumeFromId
|
|
22
|
+
? SessionManager.resume(resumeFromId, store) ?? SessionManager.create("interactive", store)
|
|
23
|
+
: SessionManager.create("interactive", store);
|
|
24
|
+
// Restore session-saved model choice on respawn so `/resume` lands on the
|
|
25
|
+
// model the user was using when they last touched this session.
|
|
26
|
+
const savedChoice = session.modelChoice();
|
|
27
|
+
if (savedChoice)
|
|
28
|
+
ctx.selection.set(savedChoice);
|
|
29
|
+
const vm = new ChatViewModel();
|
|
30
|
+
vm.attach(ctx.bus);
|
|
31
|
+
const modal = new ModalController();
|
|
32
|
+
const engine = buildEngine(ctx, session, vm.requestPermission);
|
|
33
|
+
// Built-in slash commands need their own per-respawn PluginHost so a
|
|
34
|
+
// session swap (re-enter) doesn't carry stale captured deps. External
|
|
35
|
+
// plugin hooks/tools (loaded via config) live on ctx.plugins and are
|
|
36
|
+
// shared across respawns — keep them, layer builtins on top.
|
|
37
|
+
const builtinHost = new PluginHost(ctx.bus, ctx.logger, ctx.tools);
|
|
38
|
+
let respawnRequest = undefined;
|
|
39
|
+
await registerBuiltinSlashCommands(builtinHost, {
|
|
40
|
+
ctx,
|
|
41
|
+
vm,
|
|
42
|
+
session,
|
|
43
|
+
store,
|
|
44
|
+
respawn: (id) => {
|
|
45
|
+
respawnRequest = id;
|
|
46
|
+
// Unmount on the next macrotask so dispatchSlash can return and the
|
|
47
|
+
// caller can append the slash command's output line before teardown.
|
|
48
|
+
setTimeout(() => handle.unmount(), 0);
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
// Snapshot the dispatchable command list for the autocomplete hint —
|
|
52
|
+
// covers builtins + externally-loaded plugin commands. Recomputed per
|
|
53
|
+
// respawn; if a plugin registers a command mid-session the hint won't
|
|
54
|
+
// update until the next respawn, which is fine (plugins shouldn't be
|
|
55
|
+
// hot-swapping their command set).
|
|
56
|
+
const availableSlashCommands = [
|
|
57
|
+
...builtinHost.slashCommands(),
|
|
58
|
+
...(ctx.plugins ? ctx.plugins.slashCommands() : []),
|
|
59
|
+
].map((c) => ({ name: c.name, description: c.description }));
|
|
60
|
+
const handle = renderChat(vm, async (prompt) => {
|
|
61
|
+
const cts = new CancellationTokenSource();
|
|
62
|
+
try {
|
|
63
|
+
await engine.runTurn(prompt, cts.token);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
ctx.bus.emit({
|
|
67
|
+
type: "error",
|
|
68
|
+
code: "UNKNOWN",
|
|
69
|
+
message: err instanceof Error ? err.message : String(err),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}, async (line) => {
|
|
73
|
+
const { name, args } = parseSlashInput(line);
|
|
74
|
+
if (!name) {
|
|
75
|
+
vm.pushError("Unknown command: /");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
// Built-in first; external plugins second. Both can register the
|
|
79
|
+
// same name, but built-ins win — keep this dispatch path simple.
|
|
80
|
+
let result = await builtinHost.dispatchSlash(name, args, { openModal: modal.open });
|
|
81
|
+
if (!result.ok && ctx.plugins) {
|
|
82
|
+
result = await ctx.plugins.dispatchSlash(name, args, { openModal: modal.open });
|
|
83
|
+
}
|
|
84
|
+
if (!result.ok) {
|
|
85
|
+
vm.pushError(`Unknown command: /${name}`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (result.output) {
|
|
89
|
+
if (result.isError)
|
|
90
|
+
vm.pushError(result.output);
|
|
91
|
+
else
|
|
92
|
+
vm.pushInfo(result.output);
|
|
93
|
+
}
|
|
94
|
+
}, modal, availableSlashCommands);
|
|
95
|
+
await handle.waitUntilExit();
|
|
96
|
+
vm.detach();
|
|
97
|
+
await builtinHost.dispose();
|
|
98
|
+
if (respawnRequest === undefined || respawnRequest === "exit")
|
|
99
|
+
return 0;
|
|
100
|
+
resumeFromId = respawnRequest;
|
|
101
|
+
}
|
|
46
102
|
}
|
|
47
103
|
export const chatCommand = {
|
|
48
104
|
name: "chat",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/commands/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB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;gBAClB,IAAI,MAAM,CAAC,OAAO;oBAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;;oBAC3C,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAClC,CAAC;QACH,CAAC,EACD,KAAK,EACL,sBAAsB,CACvB,CAAC;QAEF,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC;QAC7B,EAAE,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,cAAc,KAAK,SAAS,IAAI,cAAc,KAAK,MAAM;YAAE,OAAO,CAAC,CAAC;QACxE,YAAY,GAAG,cAAc,CAAC;IAChC,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAe;IACrC,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,8DAA8D;IAC3E,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI;QACjB,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QAC7D,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kFAAkF,CAAC,CAAC;YACzG,OAAO,CAAC,CAAC;QACX,CAAC;QACD,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { CliArgs, CliCommand } from "./registry.js";
|
|
2
|
+
/**
|
|
3
|
+
* `chances discover` — read-only detection of foreign CLI agent configs in the
|
|
4
|
+
* current workspace and user home (claude-code, cursor, pi). It NEVER writes
|
|
5
|
+
* anything: the goal is to show what would be importable so the user can decide
|
|
6
|
+
* what to copy over by hand. v0 only enumerates known fields and flags unknown
|
|
7
|
+
* keys for awareness; no automatic import.
|
|
8
|
+
*/
|
|
9
|
+
type ToolId = "claude-code" | "cursor" | "pi";
|
|
10
|
+
interface DetectedFile {
|
|
11
|
+
path: string;
|
|
12
|
+
scope: "project" | "user";
|
|
13
|
+
bytes: number;
|
|
14
|
+
modified: string;
|
|
15
|
+
parseError?: string;
|
|
16
|
+
importable?: Record<string, unknown>;
|
|
17
|
+
unknownFields?: string[];
|
|
18
|
+
}
|
|
19
|
+
interface ToolDetection {
|
|
20
|
+
tool: ToolId;
|
|
21
|
+
files: DetectedFile[];
|
|
22
|
+
}
|
|
23
|
+
export interface DiscoveryReport {
|
|
24
|
+
workspaceRoot: string;
|
|
25
|
+
homeDir: string;
|
|
26
|
+
scannedPaths: string[];
|
|
27
|
+
tools: ToolDetection[];
|
|
28
|
+
totalFilesFound: number;
|
|
29
|
+
}
|
|
30
|
+
export interface DiscoverDeps {
|
|
31
|
+
homeDir: string;
|
|
32
|
+
workspaceRoot: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function runDiscoveryScan(workspaceRoot: string, homeDir: string): DiscoveryReport;
|
|
35
|
+
export declare function formatDiscoveryText(report: DiscoveryReport): string;
|
|
36
|
+
export declare function runDiscover(args: CliArgs, deps: DiscoverDeps): number;
|
|
37
|
+
export declare const discoverCommand: CliCommand;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=discover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../src/commands/discover.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEzD;;;;;;GAMG;AAEH,KAAK,MAAM,GAAG,aAAa,GAAG,QAAQ,GAAG,IAA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