cmdr-agent 1.3.0 → 2.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/bin/cmdr.js +2 -1
- package/dist/bin/cmdr.js.map +1 -1
- package/dist/src/agents/executor.d.ts +32 -0
- package/dist/src/agents/executor.d.ts.map +1 -0
- package/dist/src/agents/executor.js +50 -0
- package/dist/src/agents/executor.js.map +1 -0
- package/dist/src/agents/index.d.ts +7 -0
- package/dist/src/agents/index.d.ts.map +1 -0
- package/dist/src/agents/index.js +7 -0
- package/dist/src/agents/index.js.map +1 -0
- package/dist/src/agents/registry.d.ts +36 -0
- package/dist/src/agents/registry.d.ts.map +1 -0
- package/dist/src/agents/registry.js +168 -0
- package/dist/src/agents/registry.js.map +1 -0
- package/dist/src/agents/subagent-tool.d.ts +27 -0
- package/dist/src/agents/subagent-tool.d.ts.map +1 -0
- package/dist/src/agents/subagent-tool.js +36 -0
- package/dist/src/agents/subagent-tool.js.map +1 -0
- package/dist/src/cli/args.d.ts +1 -0
- package/dist/src/cli/args.d.ts.map +1 -1
- package/dist/src/cli/args.js +4 -0
- package/dist/src/cli/args.js.map +1 -1
- package/dist/src/cli/commands.d.ts.map +1 -1
- package/dist/src/cli/commands.js +92 -4
- package/dist/src/cli/commands.js.map +1 -1
- package/dist/src/cli/ink/App.d.ts +4 -0
- package/dist/src/cli/ink/App.d.ts.map +1 -1
- package/dist/src/cli/ink/App.js +164 -20
- package/dist/src/cli/ink/App.js.map +1 -1
- package/dist/src/cli/ink/StatusBar.d.ts +17 -0
- package/dist/src/cli/ink/StatusBar.d.ts.map +1 -0
- package/dist/src/cli/ink/StatusBar.js +32 -0
- package/dist/src/cli/ink/StatusBar.js.map +1 -0
- package/dist/src/cli/repl.d.ts +1 -0
- package/dist/src/cli/repl.d.ts.map +1 -1
- package/dist/src/cli/repl.js +112 -3
- package/dist/src/cli/repl.js.map +1 -1
- package/dist/src/cli/theme.d.ts +42 -22
- package/dist/src/cli/theme.d.ts.map +1 -1
- package/dist/src/cli/theme.js +25 -1
- package/dist/src/cli/theme.js.map +1 -1
- package/dist/src/cli/themes.d.ts +57 -0
- package/dist/src/cli/themes.d.ts.map +1 -0
- package/dist/src/cli/themes.js +98 -0
- package/dist/src/cli/themes.js.map +1 -0
- package/dist/src/commands/index.d.ts +3 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/index.js +2 -0
- package/dist/src/commands/index.js.map +1 -0
- package/dist/src/commands/loader.d.ts +35 -0
- package/dist/src/commands/loader.d.ts.map +1 -0
- package/dist/src/commands/loader.js +134 -0
- package/dist/src/commands/loader.js.map +1 -0
- package/dist/src/config/config-loader.d.ts.map +1 -1
- package/dist/src/config/config-loader.js +2 -0
- package/dist/src/config/config-loader.js.map +1 -1
- package/dist/src/config/defaults.d.ts.map +1 -1
- package/dist/src/config/defaults.js +1 -0
- package/dist/src/config/defaults.js.map +1 -1
- package/dist/src/config/schema.d.ts +3 -0
- package/dist/src/config/schema.d.ts.map +1 -1
- package/dist/src/config/schema.js +1 -0
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/core/agent-runner.d.ts.map +1 -1
- package/dist/src/core/agent-runner.js +29 -4
- package/dist/src/core/agent-runner.js.map +1 -1
- package/dist/src/core/agent.d.ts +1 -1
- package/dist/src/core/agent.d.ts.map +1 -1
- package/dist/src/core/agent.js +4 -3
- package/dist/src/core/agent.js.map +1 -1
- package/dist/src/core/types.d.ts +1 -0
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/llm/model-registry.d.ts +25 -0
- package/dist/src/llm/model-registry.d.ts.map +1 -1
- package/dist/src/llm/model-registry.js +217 -24
- package/dist/src/llm/model-registry.js.map +1 -1
- package/dist/src/llm/model-watcher.d.ts +26 -0
- package/dist/src/llm/model-watcher.d.ts.map +1 -0
- package/dist/src/llm/model-watcher.js +130 -0
- package/dist/src/llm/model-watcher.js.map +1 -0
- package/dist/src/llm/ollama.d.ts +5 -0
- package/dist/src/llm/ollama.d.ts.map +1 -1
- package/dist/src/llm/ollama.js +122 -11
- package/dist/src/llm/ollama.js.map +1 -1
- package/dist/src/session/project-context.d.ts.map +1 -1
- package/dist/src/session/project-context.js +54 -4
- package/dist/src/session/project-context.js.map +1 -1
- package/package.json +2 -1
package/dist/bin/cmdr.js
CHANGED
|
@@ -11,7 +11,7 @@ import { GREEN, PURPLE, DIM, renderError, WHITE, CYAN } from '../src/cli/theme.j
|
|
|
11
11
|
import { OllamaAdapter } from '../src/llm/ollama.js';
|
|
12
12
|
import { checkForUpdate } from '../src/cli/update-checker.js';
|
|
13
13
|
import * as readline from 'readline';
|
|
14
|
-
const VERSION = '
|
|
14
|
+
const VERSION = '2.0.0';
|
|
15
15
|
/** Prompt user to pick a model from the list. */
|
|
16
16
|
function promptModelSelection(models) {
|
|
17
17
|
return new Promise((resolve) => {
|
|
@@ -94,6 +94,7 @@ async function main() {
|
|
|
94
94
|
verbose: args.verbose,
|
|
95
95
|
team: args.team,
|
|
96
96
|
maxTurns: args.maxTurns,
|
|
97
|
+
outputFormat: args.outputFormat,
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
catch (err) {
|
package/dist/bin/cmdr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmdr.js","sourceRoot":"","sources":["../../bin/cmdr.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,KAAK,QAAQ,MAAM,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AAM,CAAC,MAAM,CAAC,CAAA;QACxC,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAChC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IACvB,CAAC;IAED,2EAA2E;IAC3E,cAAc,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IAEvC,IAAI,CAAC;QACH,MAAM,SAAS,CAAC;YACd,KAAK;YACL,SAAS;YACT,OAAO,EAAE,OAAO;YAChB,aAAa,EAAE,IAAI,CAAC,MAAM;YAC1B,0BAA0B,EAAE,IAAI,CAAC,0BAA0B;YAC3D,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAC5D,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;QAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Executor — runs a subagent to completion in an isolated context.
|
|
3
|
+
*
|
|
4
|
+
* Each subagent gets its own AgentRunner with:
|
|
5
|
+
* - Restricted tool set (only tools listed in the agent definition)
|
|
6
|
+
* - Its own conversation history (does NOT pollute parent context)
|
|
7
|
+
* - Its own system prompt
|
|
8
|
+
*/
|
|
9
|
+
import type { LLMAdapter } from '../core/types.js';
|
|
10
|
+
import { ToolRegistry } from '../tools/registry.js';
|
|
11
|
+
import type { AgentDefinition } from './registry.js';
|
|
12
|
+
export interface SubagentResult {
|
|
13
|
+
output: string;
|
|
14
|
+
tokensUsed: {
|
|
15
|
+
input: number;
|
|
16
|
+
output: number;
|
|
17
|
+
};
|
|
18
|
+
turns: number;
|
|
19
|
+
}
|
|
20
|
+
export declare class AgentExecutor {
|
|
21
|
+
/**
|
|
22
|
+
* Run a subagent to completion with its own isolated context.
|
|
23
|
+
*
|
|
24
|
+
* @param definition — The agent definition (from registry)
|
|
25
|
+
* @param task — The task/question to delegate
|
|
26
|
+
* @param parentModel — The parent agent's model (used if definition.model is null)
|
|
27
|
+
* @param adapter — The LLM adapter to use
|
|
28
|
+
* @param parentToolRegistry — The parent's full tool registry (we pick allowed tools)
|
|
29
|
+
*/
|
|
30
|
+
execute(definition: AgentDefinition, task: string, parentModel: string, adapter: LLMAdapter, parentToolRegistry: ToolRegistry): Promise<SubagentResult>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/agents/executor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEpD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IAC7C,KAAK,EAAE,MAAM,CAAA;CACd;AAED,qBAAa,aAAa;IACxB;;;;;;;;OAQG;IACG,OAAO,CACX,UAAU,EAAE,eAAe,EAC3B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,UAAU,EACnB,kBAAkB,EAAE,YAAY,GAC/B,OAAO,CAAC,cAAc,CAAC;CAkC3B"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Executor — runs a subagent to completion in an isolated context.
|
|
3
|
+
*
|
|
4
|
+
* Each subagent gets its own AgentRunner with:
|
|
5
|
+
* - Restricted tool set (only tools listed in the agent definition)
|
|
6
|
+
* - Its own conversation history (does NOT pollute parent context)
|
|
7
|
+
* - Its own system prompt
|
|
8
|
+
*/
|
|
9
|
+
import { Agent } from '../core/agent.js';
|
|
10
|
+
import { ToolRegistry } from '../tools/registry.js';
|
|
11
|
+
export class AgentExecutor {
|
|
12
|
+
/**
|
|
13
|
+
* Run a subagent to completion with its own isolated context.
|
|
14
|
+
*
|
|
15
|
+
* @param definition — The agent definition (from registry)
|
|
16
|
+
* @param task — The task/question to delegate
|
|
17
|
+
* @param parentModel — The parent agent's model (used if definition.model is null)
|
|
18
|
+
* @param adapter — The LLM adapter to use
|
|
19
|
+
* @param parentToolRegistry — The parent's full tool registry (we pick allowed tools)
|
|
20
|
+
*/
|
|
21
|
+
async execute(definition, task, parentModel, adapter, parentToolRegistry) {
|
|
22
|
+
// 1. Create a restricted ToolRegistry with only the agent's allowed tools
|
|
23
|
+
const agentTools = new ToolRegistry();
|
|
24
|
+
for (const toolName of definition.tools) {
|
|
25
|
+
const tool = parentToolRegistry.get(toolName);
|
|
26
|
+
if (tool)
|
|
27
|
+
agentTools.register(tool);
|
|
28
|
+
}
|
|
29
|
+
// 2. Create Agent with the subagent's config (isolated context)
|
|
30
|
+
const agent = new Agent({
|
|
31
|
+
name: definition.name,
|
|
32
|
+
model: definition.model ?? parentModel,
|
|
33
|
+
systemPrompt: definition.systemPrompt,
|
|
34
|
+
tools: definition.tools,
|
|
35
|
+
maxTurns: definition.maxTurns,
|
|
36
|
+
temperature: definition.temperature,
|
|
37
|
+
}, adapter, agentTools);
|
|
38
|
+
// 3. Run to completion, collecting all text output
|
|
39
|
+
const result = await agent.run(task);
|
|
40
|
+
return {
|
|
41
|
+
output: result.output,
|
|
42
|
+
tokensUsed: {
|
|
43
|
+
input: result.tokenUsage.input_tokens,
|
|
44
|
+
output: result.tokenUsage.output_tokens,
|
|
45
|
+
},
|
|
46
|
+
turns: result.toolCalls.length,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/agents/executor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AASnD,MAAM,OAAO,aAAa;IACxB;;;;;;;;OAQG;IACH,KAAK,CAAC,OAAO,CACX,UAA2B,EAC3B,IAAY,EACZ,WAAmB,EACnB,OAAmB,EACnB,kBAAgC;QAEhC,0EAA0E;QAC1E,MAAM,UAAU,GAAG,IAAI,YAAY,EAAE,CAAA;QACrC,KAAK,MAAM,QAAQ,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;YACxC,MAAM,IAAI,GAAG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YAC7C,IAAI,IAAI;gBAAE,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QACrC,CAAC;QAED,gEAAgE;QAChE,MAAM,KAAK,GAAG,IAAI,KAAK,CACrB;YACE,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,WAAW;YACtC,YAAY,EAAE,UAAU,CAAC,YAAY;YACrC,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,WAAW,EAAE,UAAU,CAAC,WAAW;SACpC,EACD,OAAO,EACP,UAAU,CACX,CAAA;QAED,mDAAmD;QACnD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAEpC,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,UAAU,EAAE;gBACV,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,YAAY;gBACrC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,aAAa;aACxC;YACD,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM;SAC/B,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent system — subagents as tools.
|
|
3
|
+
*/
|
|
4
|
+
export { AgentRegistry, type AgentDefinition } from './registry.js';
|
|
5
|
+
export { AgentExecutor, type SubagentResult } from './executor.js';
|
|
6
|
+
export { createSubagentTool } from './subagent-tool.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agents/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAwB,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,aAAa,EAAuB,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Registry — discovers and manages subagent definitions from markdown files.
|
|
3
|
+
*
|
|
4
|
+
* Loading priority (project overrides user overrides bundled):
|
|
5
|
+
* .cmdr/agents/*.md — project-level (shared with team)
|
|
6
|
+
* ~/.cmdr/agents/*.md — user-level (personal agents)
|
|
7
|
+
* src/agents/bundled/*.md — bundled with cmdr (shipped defaults)
|
|
8
|
+
*/
|
|
9
|
+
export interface AgentDefinition {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
kind: 'local' | 'remote';
|
|
13
|
+
tools: string[];
|
|
14
|
+
model: string | null;
|
|
15
|
+
temperature: number;
|
|
16
|
+
maxTurns: number;
|
|
17
|
+
systemPrompt: string;
|
|
18
|
+
source: 'bundled' | 'user' | 'project';
|
|
19
|
+
filePath: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class AgentRegistry {
|
|
22
|
+
private agents;
|
|
23
|
+
/** Load all agent definitions from all three source directories. */
|
|
24
|
+
loadAll(projectRoot: string): Promise<void>;
|
|
25
|
+
/** Get a specific agent by name. */
|
|
26
|
+
get(name: string): AgentDefinition | undefined;
|
|
27
|
+
/** List all registered agents. */
|
|
28
|
+
list(): AgentDefinition[];
|
|
29
|
+
/** Check if an agent exists. */
|
|
30
|
+
has(name: string): boolean;
|
|
31
|
+
/** Register a runtime-defined agent (for programmatic use). */
|
|
32
|
+
register(def: AgentDefinition): void;
|
|
33
|
+
/** Unregister an agent. */
|
|
34
|
+
unregister(name: string): void;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/agents/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAA;IACxB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;IACtC,QAAQ,EAAE,MAAM,CAAA;CACjB;AAmJD,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAqC;IAEnD,oEAAoE;IAC9D,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBjD,oCAAoC;IACpC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAI9C,kCAAkC;IAClC,IAAI,IAAI,eAAe,EAAE;IAIzB,gCAAgC;IAChC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,+DAA+D;IAC/D,QAAQ,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;IAIpC,2BAA2B;IAC3B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAG/B"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Registry — discovers and manages subagent definitions from markdown files.
|
|
3
|
+
*
|
|
4
|
+
* Loading priority (project overrides user overrides bundled):
|
|
5
|
+
* .cmdr/agents/*.md — project-level (shared with team)
|
|
6
|
+
* ~/.cmdr/agents/*.md — user-level (personal agents)
|
|
7
|
+
* src/agents/bundled/*.md — bundled with cmdr (shipped defaults)
|
|
8
|
+
*/
|
|
9
|
+
import { readdir, readFile } from 'fs/promises';
|
|
10
|
+
import { join, dirname } from 'path';
|
|
11
|
+
import { fileURLToPath } from 'url';
|
|
12
|
+
import { existsSync } from 'fs';
|
|
13
|
+
import { homedir } from 'os';
|
|
14
|
+
function parseFrontmatter(content) {
|
|
15
|
+
const match = content.match(/^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/);
|
|
16
|
+
if (!match) {
|
|
17
|
+
return { frontmatter: {}, body: content };
|
|
18
|
+
}
|
|
19
|
+
const yamlBlock = match[1];
|
|
20
|
+
const body = match[2].trim();
|
|
21
|
+
const frontmatter = {};
|
|
22
|
+
let currentKey = '';
|
|
23
|
+
let inArray = false;
|
|
24
|
+
let arrayItems = [];
|
|
25
|
+
for (const line of yamlBlock.split('\n')) {
|
|
26
|
+
const trimmed = line.trim();
|
|
27
|
+
if (!trimmed || trimmed.startsWith('#'))
|
|
28
|
+
continue;
|
|
29
|
+
// Array item
|
|
30
|
+
if (inArray && trimmed.startsWith('- ')) {
|
|
31
|
+
arrayItems.push(trimmed.slice(2).trim());
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
// End previous array
|
|
35
|
+
if (inArray) {
|
|
36
|
+
frontmatter[currentKey] = arrayItems;
|
|
37
|
+
inArray = false;
|
|
38
|
+
arrayItems = [];
|
|
39
|
+
}
|
|
40
|
+
const colonIdx = trimmed.indexOf(':');
|
|
41
|
+
if (colonIdx === -1)
|
|
42
|
+
continue;
|
|
43
|
+
const key = trimmed.slice(0, colonIdx).trim();
|
|
44
|
+
const rawValue = trimmed.slice(colonIdx + 1).trim();
|
|
45
|
+
if (rawValue === '' || rawValue === '[]') {
|
|
46
|
+
// Could be start of an array or empty value
|
|
47
|
+
currentKey = key;
|
|
48
|
+
if (rawValue === '[]') {
|
|
49
|
+
frontmatter[key] = [];
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
inArray = true;
|
|
53
|
+
arrayItems = [];
|
|
54
|
+
}
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
// Parse value
|
|
58
|
+
if (rawValue === 'null' || rawValue === '~') {
|
|
59
|
+
frontmatter[key] = null;
|
|
60
|
+
}
|
|
61
|
+
else if (rawValue === 'true') {
|
|
62
|
+
frontmatter[key] = true;
|
|
63
|
+
}
|
|
64
|
+
else if (rawValue === 'false') {
|
|
65
|
+
frontmatter[key] = false;
|
|
66
|
+
}
|
|
67
|
+
else if (/^-?\d+(\.\d+)?$/.test(rawValue)) {
|
|
68
|
+
frontmatter[key] = Number(rawValue);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// Strip quotes
|
|
72
|
+
frontmatter[key] = rawValue.replace(/^["']|["']$/g, '');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Flush last array
|
|
76
|
+
if (inArray) {
|
|
77
|
+
frontmatter[currentKey] = arrayItems;
|
|
78
|
+
}
|
|
79
|
+
return { frontmatter: frontmatter, body };
|
|
80
|
+
}
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
// Agent file parser
|
|
83
|
+
// ---------------------------------------------------------------------------
|
|
84
|
+
function parseAgentFile(content, filePath, source) {
|
|
85
|
+
const { frontmatter, body } = parseFrontmatter(content);
|
|
86
|
+
if (!frontmatter.name || !frontmatter.description) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
name: frontmatter.name,
|
|
91
|
+
description: frontmatter.description,
|
|
92
|
+
kind: frontmatter.kind ?? 'local',
|
|
93
|
+
tools: Array.isArray(frontmatter.tools) ? frontmatter.tools : [],
|
|
94
|
+
model: frontmatter.model === undefined ? null : frontmatter.model,
|
|
95
|
+
temperature: frontmatter.temperature ?? 0.3,
|
|
96
|
+
maxTurns: frontmatter.max_turns ?? 15,
|
|
97
|
+
systemPrompt: body,
|
|
98
|
+
source,
|
|
99
|
+
filePath,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
// Directory loader
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
async function loadAgentsFromDir(dir, source) {
|
|
106
|
+
if (!existsSync(dir))
|
|
107
|
+
return [];
|
|
108
|
+
const agents = [];
|
|
109
|
+
try {
|
|
110
|
+
const entries = await readdir(dir);
|
|
111
|
+
for (const entry of entries) {
|
|
112
|
+
if (!entry.endsWith('.md'))
|
|
113
|
+
continue;
|
|
114
|
+
const filePath = join(dir, entry);
|
|
115
|
+
const content = await readFile(filePath, 'utf-8');
|
|
116
|
+
const def = parseAgentFile(content, filePath, source);
|
|
117
|
+
if (def)
|
|
118
|
+
agents.push(def);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// Directory not readable — skip silently
|
|
123
|
+
}
|
|
124
|
+
return agents;
|
|
125
|
+
}
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
// AgentRegistry
|
|
128
|
+
// ---------------------------------------------------------------------------
|
|
129
|
+
export class AgentRegistry {
|
|
130
|
+
agents = new Map();
|
|
131
|
+
/** Load all agent definitions from all three source directories. */
|
|
132
|
+
async loadAll(projectRoot) {
|
|
133
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
134
|
+
// Load in priority order: bundled first, then user, then project
|
|
135
|
+
// Later sources override earlier ones (project > user > bundled)
|
|
136
|
+
const bundledDir = join(__dirname, 'bundled');
|
|
137
|
+
const userDir = join(homedir(), '.cmdr', 'agents');
|
|
138
|
+
const projectDir = join(projectRoot, '.cmdr', 'agents');
|
|
139
|
+
const bundled = await loadAgentsFromDir(bundledDir, 'bundled');
|
|
140
|
+
const user = await loadAgentsFromDir(userDir, 'user');
|
|
141
|
+
const project = await loadAgentsFromDir(projectDir, 'project');
|
|
142
|
+
// Register in priority order — later registrations override
|
|
143
|
+
for (const def of [...bundled, ...user, ...project]) {
|
|
144
|
+
this.agents.set(def.name, def);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** Get a specific agent by name. */
|
|
148
|
+
get(name) {
|
|
149
|
+
return this.agents.get(name);
|
|
150
|
+
}
|
|
151
|
+
/** List all registered agents. */
|
|
152
|
+
list() {
|
|
153
|
+
return Array.from(this.agents.values());
|
|
154
|
+
}
|
|
155
|
+
/** Check if an agent exists. */
|
|
156
|
+
has(name) {
|
|
157
|
+
return this.agents.has(name);
|
|
158
|
+
}
|
|
159
|
+
/** Register a runtime-defined agent (for programmatic use). */
|
|
160
|
+
register(def) {
|
|
161
|
+
this.agents.set(def.name, def);
|
|
162
|
+
}
|
|
163
|
+
/** Unregister an agent. */
|
|
164
|
+
unregister(name) {
|
|
165
|
+
this.agents.delete(name);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/agents/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AAiC5B,SAAS,gBAAgB,CAAC,OAAe;IACvC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAA;IACtE,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;IAC3C,CAAC;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IAC1B,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IAC5B,MAAM,WAAW,GAA4B,EAAE,CAAA;IAE/C,IAAI,UAAU,GAAG,EAAE,CAAA;IACnB,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,IAAI,UAAU,GAAa,EAAE,CAAA;IAE7B,KAAK,MAAM,IAAI,IAAI,SAA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A;IAC9B,CAAC;IAED,+DAA+D;IAC/D,QAAQ,CAAC,GAAoB;QAC3B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAChC,CAAC;IAED,2BAA2B;IAC3B,UAAU,CAAC,IAAY;QACrB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subagent Tool — wraps a subagent definition as a standard cmdr tool.
|
|
3
|
+
*
|
|
4
|
+
* When the main agent calls this tool, it:
|
|
5
|
+
* 1. Spins up an isolated subagent with restricted tools
|
|
6
|
+
* 2. Runs the task to completion
|
|
7
|
+
* 3. Returns the subagent's output as the tool result
|
|
8
|
+
*
|
|
9
|
+
* Subagent tools have 'read' permission — they're always safe from HITL
|
|
10
|
+
* perspective because the subagent itself has restricted tools.
|
|
11
|
+
*/
|
|
12
|
+
import type { AgentDefinition } from './registry.js';
|
|
13
|
+
import { AgentExecutor } from './executor.js';
|
|
14
|
+
import type { LLMAdapter } from '../core/types.js';
|
|
15
|
+
import type { ToolRegistry } from '../tools/registry.js';
|
|
16
|
+
/**
|
|
17
|
+
* Create a tool definition that wraps a subagent.
|
|
18
|
+
*
|
|
19
|
+
* @param definition — The agent definition from the registry
|
|
20
|
+
* @param executor — The shared AgentExecutor instance
|
|
21
|
+
* @param adapter — The LLM adapter for the subagent to use
|
|
22
|
+
* @param parentToolRegistry — The parent's tool registry (subagent picks from this)
|
|
23
|
+
*/
|
|
24
|
+
export declare function createSubagentTool(definition: AgentDefinition, executor: AgentExecutor, adapter: LLMAdapter, parentToolRegistry: ToolRegistry): import("../core/types.js").ToolDefinition<{
|
|
25
|
+
task: string;
|
|
26
|
+
}>;
|
|
27
|
+
//# sourceMappingURL=subagent-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subagent-tool.d.ts","sourceRoot":"","sources":["../../../src/agents/subagent-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,eAAe,EAC3B,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,UAAU,EACnB,kBAAkB,EAAE,YAAY;;GAoBjC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subagent Tool — wraps a subagent definition as a standard cmdr tool.
|
|
3
|
+
*
|
|
4
|
+
* When the main agent calls this tool, it:
|
|
5
|
+
* 1. Spins up an isolated subagent with restricted tools
|
|
6
|
+
* 2. Runs the task to completion
|
|
7
|
+
* 3. Returns the subagent's output as the tool result
|
|
8
|
+
*
|
|
9
|
+
* Subagent tools have 'read' permission — they're always safe from HITL
|
|
10
|
+
* perspective because the subagent itself has restricted tools.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import { defineTool } from '../tools/registry.js';
|
|
14
|
+
/**
|
|
15
|
+
* Create a tool definition that wraps a subagent.
|
|
16
|
+
*
|
|
17
|
+
* @param definition — The agent definition from the registry
|
|
18
|
+
* @param executor — The shared AgentExecutor instance
|
|
19
|
+
* @param adapter — The LLM adapter for the subagent to use
|
|
20
|
+
* @param parentToolRegistry — The parent's tool registry (subagent picks from this)
|
|
21
|
+
*/
|
|
22
|
+
export function createSubagentTool(definition, executor, adapter, parentToolRegistry) {
|
|
23
|
+
return defineTool({
|
|
24
|
+
name: definition.name,
|
|
25
|
+
description: definition.description,
|
|
26
|
+
inputSchema: z.object({
|
|
27
|
+
task: z.string().describe('The specific task or question to delegate to this agent'),
|
|
28
|
+
}),
|
|
29
|
+
execute: async (input, context) => {
|
|
30
|
+
const parentModel = context.agent.model;
|
|
31
|
+
const result = await executor.execute(definition, input.task, parentModel, adapter, parentToolRegistry);
|
|
32
|
+
return { data: result.output, isError: false };
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=subagent-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subagent-tool.js","sourceRoot":"","sources":["../../../src/agents/subagent-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAMjD;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAA2B,EAC3B,QAAuB,EACvB,OAAmB,EACnB,kBAAgC;IAEhC,OAAO,UAAU,CAAC;QAChB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yDAAyD,CAAC;SACrF,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAChC,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAA;YACvC,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CACnC,UAAU,EACV,KAAK,CAAC,IAAI,EACV,WAAW,EACX,OAAO,EACP,kBAAkB,CACnB,CAAA;YACD,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;QAChD,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/src/cli/args.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,OAAO;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,0BAA0B,CAAC,EAAE,OAAO,CAAA;IACpC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,OAAO;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,0BAA0B,CAAC,EAAE,OAAO,CAAA;IACpC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,CAAA;CAC/C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAoEjD;AAED,wBAAgB,SAAS,IAAI,IAAI,CA2BhC"}
|
package/dist/src/cli/args.js
CHANGED
|
@@ -51,6 +51,9 @@ export function parseArgs(argv) {
|
|
|
51
51
|
case '-t':
|
|
52
52
|
args.team = argv[++i];
|
|
53
53
|
break;
|
|
54
|
+
case '--output-format':
|
|
55
|
+
args.outputFormat = argv[++i];
|
|
56
|
+
break;
|
|
54
57
|
default:
|
|
55
58
|
// If no flag prefix, treat as inline prompt
|
|
56
59
|
if (!arg.startsWith('-') && !args.prompt) {
|
|
@@ -80,6 +83,7 @@ export function printHelp() {
|
|
|
80
83
|
--cwd <path> Set working directory
|
|
81
84
|
--verbose Print full tool output (default: collapsed)
|
|
82
85
|
--max-turns <n> Maximum agent turns before stopping
|
|
86
|
+
--output-format <fmt> Output format: text (default), json, stream-json
|
|
83
87
|
-h, --help Show this help
|
|
84
88
|
-v, --version Show version
|
|
85
89
|
--dangerously-skip-permissions Auto-approve all tool calls (yolo mode)
|
package/dist/src/cli/args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkBH,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,MAAM,IAAI,GAAY,EAAE,CAAA;IACxB,IAAI,CAAC,GAAG,CAAC,CAAA;IAET,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QAEnB,QAAQ,GAAG,EAAE,CAAC;YACZ,KAAK,SAAS,CAAC;YACf,KAAK,IAAI;gBACP,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;gBACtB,MAAK;YACP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;gBAChE,MAAK;YACP;gBACE,4CAA4C;gBAC5C,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;oBACzC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;oBACrC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAA;gBACjB,CAAC;gBACD,MAAK;QACT,CAAC;QAED,CAAC,EAAE,CAAA;IACL,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,UAAU,SAAS;IACvB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAyBb,CAAC,CAAA;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/cli/commands.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAA8C,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/cli/commands.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAA8C,MAAM,kBAAkB,CAAA;AAoBhG,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEjE;AAED,wBAAgB,cAAc,IAAI,YAAY,EAAE,CAE/C;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAErD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAU/E"}
|
package/dist/src/cli/commands.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Slash command registry and handlers.
|
|
3
3
|
*/
|
|
4
4
|
import { PURPLE, GREEN, DIM, WHITE, commandText, dimText, YELLOW, RED, renderSessionStatus, renderContextWindow, SEPARATOR, renderInfo, } from './theme.js';
|
|
5
|
-
import {
|
|
5
|
+
import { listThemeNames, getActiveTheme, setActiveTheme } from './themes.js';
|
|
6
|
+
import { getDefaultContextLength, getModelInfo } from '../llm/model-registry.js';
|
|
6
7
|
import { countTokens } from '../llm/token-counter.js';
|
|
7
8
|
import { listSessions } from '../session/session-persistence.js';
|
|
8
9
|
import { listTeamPresets } from '../core/presets.js';
|
|
@@ -104,7 +105,11 @@ registerCommand({
|
|
|
104
105
|
'',
|
|
105
106
|
...models.map((m, i) => {
|
|
106
107
|
const current = m === context.model ? ` ${DIM('← current')}` : '';
|
|
107
|
-
|
|
108
|
+
const info = getModelInfo(m);
|
|
109
|
+
const meta = info
|
|
110
|
+
? DIM(` [${info.parameterSize}, ${(info.contextLength / 1024).toFixed(0)}k ctx${info.supportsTools ? ', tools' : ''}]`)
|
|
111
|
+
: '';
|
|
112
|
+
return ` ${GREEN(`${i + 1}.`)} ${WHITE(m)}${meta}${current}`;
|
|
108
113
|
}),
|
|
109
114
|
'',
|
|
110
115
|
` ${DIM('Switch with:')} ${GREEN('/model <name>')} ${DIM('or')} ${GREEN('/model <number>')}`,
|
|
@@ -337,8 +342,11 @@ registerCommand({
|
|
|
337
342
|
});
|
|
338
343
|
registerCommand({
|
|
339
344
|
name: 'agents',
|
|
340
|
-
description: '
|
|
341
|
-
execute: async () => {
|
|
345
|
+
description: 'List registered subagents: /agents, /agents info <name>',
|
|
346
|
+
execute: async (args) => {
|
|
347
|
+
if (args.startsWith('info ')) {
|
|
348
|
+
return `__AGENT_INFO__:${args.slice(5).trim()}`;
|
|
349
|
+
}
|
|
342
350
|
return '__AGENTS_STATUS__';
|
|
343
351
|
},
|
|
344
352
|
});
|
|
@@ -427,6 +435,86 @@ registerCommand({
|
|
|
427
435
|
return renderInfo('Usage: /skill info <name> | /skill install <path> | /skill create <name>');
|
|
428
436
|
},
|
|
429
437
|
});
|
|
438
|
+
registerCommand({
|
|
439
|
+
name: 'theme',
|
|
440
|
+
description: 'Switch theme: /theme [name], /theme list',
|
|
441
|
+
execute: async (args) => {
|
|
442
|
+
if (!args || args === 'list') {
|
|
443
|
+
const names = listThemeNames();
|
|
444
|
+
const current = getActiveTheme().name;
|
|
445
|
+
const lines = [
|
|
446
|
+
'',
|
|
447
|
+
` ${PURPLE.bold('Themes')} ${DIM(`(${names.length})`)}`,
|
|
448
|
+
'',
|
|
449
|
+
...names.map(n => {
|
|
450
|
+
const marker = n === current ? ` ${GREEN('← active')}` : '';
|
|
451
|
+
return ` ${GREEN('•')} ${WHITE(n)}${marker}`;
|
|
452
|
+
}),
|
|
453
|
+
'',
|
|
454
|
+
` ${DIM('Switch with:')} ${GREEN('/theme <name>')}`,
|
|
455
|
+
'',
|
|
456
|
+
];
|
|
457
|
+
return lines.join('\n');
|
|
458
|
+
}
|
|
459
|
+
const name = args.trim().toLowerCase();
|
|
460
|
+
if (setActiveTheme(name)) {
|
|
461
|
+
return renderInfo(`Theme set to ${GREEN(name)}`);
|
|
462
|
+
}
|
|
463
|
+
return renderInfo(`Unknown theme: ${RED(name)}. Use /theme list to see options.`);
|
|
464
|
+
},
|
|
465
|
+
});
|
|
466
|
+
registerCommand({
|
|
467
|
+
name: 'commands',
|
|
468
|
+
description: 'List custom commands',
|
|
469
|
+
execute: async () => {
|
|
470
|
+
return '__CUSTOM_COMMANDS_LIST__';
|
|
471
|
+
},
|
|
472
|
+
});
|
|
473
|
+
registerCommand({
|
|
474
|
+
name: 'command',
|
|
475
|
+
description: 'Custom command management: create <name>',
|
|
476
|
+
execute: async (args) => {
|
|
477
|
+
const parts = args.trim().split(/\s+/);
|
|
478
|
+
const sub = parts[0]?.toLowerCase();
|
|
479
|
+
const rest = parts.slice(1).join(' ');
|
|
480
|
+
if (sub === 'create' && rest)
|
|
481
|
+
return `__CUSTOM_COMMAND_CREATE__:${rest}`;
|
|
482
|
+
return renderInfo('Usage: /command create <name>');
|
|
483
|
+
},
|
|
484
|
+
});
|
|
485
|
+
registerCommand({
|
|
486
|
+
name: 'plan',
|
|
487
|
+
description: 'Toggle plan mode (read-only analysis)',
|
|
488
|
+
execute: async () => {
|
|
489
|
+
return '__PLAN_TOGGLE__';
|
|
490
|
+
},
|
|
491
|
+
});
|
|
492
|
+
registerCommand({
|
|
493
|
+
name: 'memory',
|
|
494
|
+
description: 'Context memory: /memory show, /memory refresh',
|
|
495
|
+
execute: async (args, context) => {
|
|
496
|
+
const sub = args.trim().toLowerCase();
|
|
497
|
+
if (!sub || sub === 'show') {
|
|
498
|
+
const instructions = context.session.projectContext.cmdrInstructions;
|
|
499
|
+
if (!instructions) {
|
|
500
|
+
return renderInfo('No CMDR.md context loaded.');
|
|
501
|
+
}
|
|
502
|
+
const lineCount = instructions.split('\n').length;
|
|
503
|
+
const lines = [
|
|
504
|
+
'',
|
|
505
|
+
` ${PURPLE.bold('Loaded context')} ${DIM(`(${lineCount} lines)`)}`,
|
|
506
|
+
'',
|
|
507
|
+
...instructions.split('\n').slice(0, 30).map(l => ` ${DIM('│')} ${WHITE(l)}`),
|
|
508
|
+
instructions.split('\n').length > 30 ? ` ${DIM(` ... (${lineCount - 30} more lines)`)}` : '',
|
|
509
|
+
'',
|
|
510
|
+
];
|
|
511
|
+
return lines.filter(Boolean).join('\n');
|
|
512
|
+
}
|
|
513
|
+
if (sub === 'refresh')
|
|
514
|
+
return '__MEMORY_REFRESH__';
|
|
515
|
+
return renderInfo('Usage: /memory [show|refresh]');
|
|
516
|
+
},
|
|
517
|
+
});
|
|
430
518
|
registerCommand({
|
|
431
519
|
name: 'quit',
|
|
432
520
|
description: 'Exit cmdr',
|