@agent-smith/cli 0.0.118 → 0.0.120
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/README.md +27 -24
- package/dist/cmd/base.js +8 -1
- package/dist/cmd/build.js +6 -1
- package/dist/cmd/cmds.d.ts +2 -1
- package/dist/cmd/cmds.js +21 -1
- package/dist/cmd/features.d.ts +1 -2
- package/dist/cmd/features.js +17 -19
- package/dist/index.js +0 -0
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -50,29 +50,33 @@ This installs the `lm` command globally.
|
|
|
50
50
|
|
|
51
51
|
## Quick Start
|
|
52
52
|
|
|
53
|
-
### 1.
|
|
53
|
+
### 1. Initialize a config file
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
Run `lm conf` to initialize. A basic config file will be created (`~/.config/agent-smith/config.yml` on Linux):
|
|
56
|
+
|
|
57
|
+
```yaml
|
|
58
|
+
backends:
|
|
59
|
+
default: llamacpp
|
|
60
|
+
llamacpp:
|
|
61
|
+
url: http://localhost:8080/v1
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 2. Configure your backend
|
|
65
|
+
|
|
66
|
+
Customize your config:
|
|
56
67
|
|
|
57
68
|
```yaml
|
|
58
69
|
backends:
|
|
59
70
|
default: "llamacpp"
|
|
60
71
|
llamacpp:
|
|
61
|
-
type: "openai"
|
|
62
72
|
url: "http://localhost:8080/v1"
|
|
63
73
|
openrouter:
|
|
64
74
|
type: "openai"
|
|
65
75
|
url: "https://openrouter.ai/api/v1"
|
|
66
|
-
apiKey: "$OPENROUTER_API_KEY"
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### 2. Sync Configuration
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
lm conf ~/.config/agent-smith/config.yml
|
|
76
|
+
apiKey: "$OPENROUTER_API_KEY" # env variable
|
|
73
77
|
```
|
|
74
78
|
|
|
75
|
-
This processes the YAML config and populates the SQLite database at `~/.config/agent-smith/config.db
|
|
79
|
+
Run `lm conf` again to synchronize. This processes the YAML config and populates the SQLite database (at `~/.config/agent-smith/config.db` on Linux).
|
|
76
80
|
|
|
77
81
|
### 3. Run a Quick Query
|
|
78
82
|
|
|
@@ -161,12 +165,12 @@ lm q "Write a poem" \
|
|
|
161
165
|
|
|
162
166
|
**Clipboard input:**
|
|
163
167
|
```bash
|
|
164
|
-
lm q "Summarize this" --
|
|
168
|
+
lm q "Summarize this" --ic
|
|
165
169
|
```
|
|
166
170
|
|
|
167
171
|
**File input:**
|
|
168
172
|
```bash
|
|
169
|
-
lm q "Analyze" --
|
|
173
|
+
lm q "Analyze" --if
|
|
170
174
|
```
|
|
171
175
|
|
|
172
176
|
**Markdown output:**
|
|
@@ -176,7 +180,7 @@ lm q "Generate a report" --markdown-output
|
|
|
176
180
|
|
|
177
181
|
**Clipboard output:**
|
|
178
182
|
```bash
|
|
179
|
-
lm q "Generate code" --
|
|
183
|
+
lm q "Generate code" --oc
|
|
180
184
|
```
|
|
181
185
|
|
|
182
186
|
### Chat Mode for Tasks
|
|
@@ -219,27 +223,26 @@ backends:
|
|
|
219
223
|
url: "http://localhost:8080/v1"
|
|
220
224
|
```
|
|
221
225
|
|
|
226
|
+
Run `lm conf` to synchronize the conf db
|
|
227
|
+
|
|
222
228
|
### Step 3: Create an Agent
|
|
223
229
|
|
|
224
230
|
Create `~/my-agents/features/agents/shell-demo.yml`:
|
|
225
231
|
|
|
226
232
|
```yaml
|
|
227
|
-
|
|
228
|
-
description: A demo agent with shell tool access
|
|
233
|
+
description: A demo agent
|
|
229
234
|
prompt: |-
|
|
230
|
-
|
|
235
|
+
Custom prompt here.
|
|
236
|
+
User input: {prompt}
|
|
237
|
+
template:
|
|
238
|
+
system: |-
|
|
239
|
+
Custom system prompt here
|
|
231
240
|
model: qwen4b
|
|
232
241
|
inferParams:
|
|
233
242
|
min_p: 0
|
|
234
243
|
top_k: 20
|
|
235
244
|
top_p: 0.95
|
|
236
245
|
temperature: 0.4
|
|
237
|
-
toolsList:
|
|
238
|
-
- shell
|
|
239
|
-
variables:
|
|
240
|
-
required:
|
|
241
|
-
workspace:
|
|
242
|
-
description: The local directory path where to operate
|
|
243
246
|
```
|
|
244
247
|
|
|
245
248
|
### Step 4: Register and Run
|
|
@@ -249,7 +252,7 @@ variables:
|
|
|
249
252
|
lm update
|
|
250
253
|
|
|
251
254
|
# Run with a prompt and variable
|
|
252
|
-
lm
|
|
255
|
+
lm demo "user prompt here" -v # -v is to see thinking tokens
|
|
253
256
|
```
|
|
254
257
|
|
|
255
258
|
## API Reference
|
package/dist/cmd/base.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Option } from "commander";
|
|
2
2
|
import { conf, state } from "@agent-smith/core";
|
|
3
3
|
import { parseCommandArgs } from "../utils.js";
|
|
4
|
-
import { processAgentCmd, processAgentsCmd, recreateDbCmd, resetDbCmd } from "./cmds.js";
|
|
4
|
+
import { manageWorkspaces, processAgentCmd, processAgentsCmd, recreateDbCmd, resetDbCmd } from "./cmds.js";
|
|
5
5
|
import { displayOptions, inferenceOptions } from "../options.js";
|
|
6
6
|
function initBaseCommands(program) {
|
|
7
7
|
/*program.command("ping")
|
|
@@ -59,6 +59,13 @@ function initBaseCommands(program) {
|
|
|
59
59
|
.action(async (...args) => {
|
|
60
60
|
await recreateDbCmd();
|
|
61
61
|
});
|
|
62
|
+
const wsCmd = program.command("ws")
|
|
63
|
+
.description("manage the workspaces")
|
|
64
|
+
.action(async (...args) => {
|
|
65
|
+
const ca = parseCommandArgs(args);
|
|
66
|
+
await manageWorkspaces(ca.args, ca.options);
|
|
67
|
+
});
|
|
68
|
+
wsCmd.addOption(new Option("-a, --activate <name>", "activate a workspace"));
|
|
62
69
|
return program;
|
|
63
70
|
}
|
|
64
71
|
export { initBaseCommands };
|
package/dist/cmd/build.js
CHANGED
|
@@ -21,7 +21,12 @@ async function chat(options, agent, mcpServers) {
|
|
|
21
21
|
await query(program);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
/* console.log("CHAT HISTORY", agent.history.length);
|
|
25
|
+
agent.history.forEach(t => {
|
|
26
|
+
const turn = { ...t };
|
|
27
|
+
delete turn.stats;
|
|
28
|
+
console.log(turn)
|
|
29
|
+
});*/
|
|
25
30
|
//options.history = undefined;
|
|
26
31
|
//console.log("RUN W PROMPT", prompt);
|
|
27
32
|
options.params = chatInferenceParams;
|
package/dist/cmd/cmds.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ declare function resetDbCmd(): Promise<any>;
|
|
|
5
5
|
declare function recreateDbCmd(): Promise<any>;
|
|
6
6
|
declare function processAgentsCmd(args: Array<string>, options: Record<string, any>): Promise<void>;
|
|
7
7
|
declare function processAgentCmd(args: Array<string>, options: Record<string, any>): Promise<any>;
|
|
8
|
-
|
|
8
|
+
declare function manageWorkspaces(args: Array<string>, options: Record<string, any>): Promise<void>;
|
|
9
|
+
export { initUserCmds, processAgentCmd, processAgentsCmd, resetDbCmd, recreateDbCmd, manageWorkspaces, };
|
package/dist/cmd/cmds.js
CHANGED
|
@@ -139,4 +139,24 @@ async function processAgentCmd(args, options) {
|
|
|
139
139
|
}
|
|
140
140
|
//console.log(JSON.stringify(ts, null, " "));
|
|
141
141
|
}
|
|
142
|
-
|
|
142
|
+
async function manageWorkspaces(args, options) {
|
|
143
|
+
if (!options?.activate) {
|
|
144
|
+
const { found, setting } = db.readSetting("workspace");
|
|
145
|
+
const dws = found ? setting : null;
|
|
146
|
+
const ws = db.readWorkspaces();
|
|
147
|
+
ws.forEach(w => {
|
|
148
|
+
const msg = dws == w.name ? colors.bold(w.name) + " " + colors.yellow("[active]") : colors.bold(w.name);
|
|
149
|
+
console.log("- " + msg + " " + w.path);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
const { found, workspace } = db.readWorkspace(options.activate);
|
|
154
|
+
if (!found) {
|
|
155
|
+
runtimeDataError(`Workspace ${options.activate} not found`);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
db.upsertSetting("workspace", workspace.name);
|
|
159
|
+
console.log(`Workspace ${colors.bold(options.activate)} activated`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export { initUserCmds, processAgentCmd, processAgentsCmd, resetDbCmd, recreateDbCmd, manageWorkspaces, };
|
package/dist/cmd/features.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { InferenceResult } from "@agent-smith/types";
|
|
2
2
|
declare function executeWorkflowCmd(name: string, wargs: Array<any>): Promise<any>;
|
|
3
|
-
declare function executeTaskCmd(name: string, targs?: Array<any>): Promise<InferenceResult>;
|
|
4
3
|
declare function executeAgentCmd(name: string, targs?: Array<any>): Promise<InferenceResult>;
|
|
5
4
|
declare function executeActionCmd(name: string, aargs: Array<any>, quiet?: boolean): Promise<any>;
|
|
6
|
-
export { executeWorkflowCmd,
|
|
5
|
+
export { executeWorkflowCmd, executeActionCmd, executeAgentCmd, };
|
package/dist/cmd/features.js
CHANGED
|
@@ -4,28 +4,19 @@ import { useInferenceCallbacks } from "./callbacks.js";
|
|
|
4
4
|
import { chat } from "./build.js";
|
|
5
5
|
async function executeWorkflowCmd(name, wargs) {
|
|
6
6
|
//console.log("WF INITIAL ARGS", typeof wargs, wargs.slice(0, -1));
|
|
7
|
-
const
|
|
8
|
-
//console.log("WF ARGS",
|
|
9
|
-
//console.log("WF OPTS", options);
|
|
10
|
-
return await executeWorkflow(name, args, options);
|
|
11
|
-
}
|
|
12
|
-
async function executeTaskCmd(name, targs = []) {
|
|
13
|
-
const ca = parseCommandArgs(targs);
|
|
14
|
-
//console.log("ARGS", ca);
|
|
7
|
+
const ca = parseCommandArgs(wargs);
|
|
8
|
+
//console.log("WF ARGS", ca);
|
|
15
9
|
const inferenceCallbacks = useInferenceCallbacks(name, ca.options);
|
|
16
10
|
const options = { ...ca.options, ...inferenceCallbacks };
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const tr = await tsk.execute();
|
|
20
|
-
//console.log("TR", tr);
|
|
21
|
-
if (ca?.options.chat) {
|
|
11
|
+
return await executeWorkflow(name, wargs, options);
|
|
12
|
+
/*if (ca?.options.chat) {
|
|
22
13
|
await chat(options, tsk.agent, tsk.mcpServers);
|
|
23
|
-
}
|
|
24
|
-
return tr;
|
|
14
|
+
}*/
|
|
25
15
|
}
|
|
26
16
|
async function executeAgentCmd(name, targs = []) {
|
|
27
17
|
//console.log("EXEC AGENT", name);
|
|
28
18
|
const ca = parseCommandArgs(targs);
|
|
19
|
+
//console.log("Agent ARGs", ca);
|
|
29
20
|
ca.options.isAgent = true;
|
|
30
21
|
ca.options.confirmToolUsage = confirmToolUsage;
|
|
31
22
|
const inferenceCallbacks = useInferenceCallbacks(name, ca.options);
|
|
@@ -35,16 +26,23 @@ async function executeAgentCmd(name, targs = []) {
|
|
|
35
26
|
//console.log("CA", ca);
|
|
36
27
|
const tr = await tsk.execute();
|
|
37
28
|
//console.dir(tsk.agent.history, { depth: 6 });
|
|
29
|
+
if (tr?.text) {
|
|
30
|
+
if (!tr.text.endsWith("\n")) {
|
|
31
|
+
console.log();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
38
34
|
if (ca?.options.chat) {
|
|
39
35
|
await chat(options, tsk.agent, tsk.mcpServers);
|
|
40
36
|
}
|
|
41
37
|
return tr;
|
|
42
38
|
}
|
|
43
39
|
async function executeActionCmd(name, aargs, quiet = false) {
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
const ca = parseCommandArgs(aargs);
|
|
41
|
+
//console.log("AARGs", ca);
|
|
42
|
+
const inferenceCallbacks = useInferenceCallbacks(name, ca.options);
|
|
43
|
+
const options = { ...ca.options, ...inferenceCallbacks };
|
|
46
44
|
//console.log("CMDA", args)
|
|
47
|
-
const params =
|
|
45
|
+
const params = aargs;
|
|
48
46
|
const ip = await getInputFromOptions(options);
|
|
49
47
|
if (ip !== null) {
|
|
50
48
|
params.push(ip);
|
|
@@ -54,4 +52,4 @@ async function executeActionCmd(name, aargs, quiet = false) {
|
|
|
54
52
|
}
|
|
55
53
|
return await executeAction(name, params, options, quiet);
|
|
56
54
|
}
|
|
57
|
-
export { executeWorkflowCmd,
|
|
55
|
+
export { executeWorkflowCmd, executeActionCmd, executeAgentCmd, };
|
package/dist/index.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-smith/cli",
|
|
3
3
|
"description": "Agent Smith: terminal client for language model agents",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.120",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rm -rf dist/* && tsc",
|
|
7
7
|
"cli": "node --loader ts-node/esm bin/index.ts",
|
|
8
8
|
"watch": "tsc --noCheck -p . -w"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@agent-smith/core": "^0.0.
|
|
12
|
-
"@inquirer/prompts": "^8.
|
|
13
|
-
"@vue/reactivity": "^3.5.
|
|
11
|
+
"@agent-smith/core": "^0.0.8",
|
|
12
|
+
"@inquirer/prompts": "^8.5.2",
|
|
13
|
+
"@vue/reactivity": "^3.5.38",
|
|
14
14
|
"ansi-colors": "^4.1.3",
|
|
15
15
|
"clipboardy": "^5.3.1",
|
|
16
|
-
"commander": "^
|
|
16
|
+
"commander": "^15.0.0",
|
|
17
17
|
"marked-terminal": "^7.3.0",
|
|
18
|
-
"ora": "^9.
|
|
19
|
-
"yaml": "^2.
|
|
18
|
+
"ora": "^9.4.0",
|
|
19
|
+
"yaml": "^2.9.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@agent-smith/agent": "^0.5.
|
|
23
|
-
"@agent-smith/types": "^0.0.
|
|
22
|
+
"@agent-smith/agent": "^0.5.2",
|
|
23
|
+
"@agent-smith/types": "^0.0.7",
|
|
24
24
|
"@cfworker/json-schema": "^4.1.1",
|
|
25
|
-
"@commander-js/extra-typings": "^
|
|
25
|
+
"@commander-js/extra-typings": "^15.0.0",
|
|
26
26
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
27
27
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
28
28
|
"@types/marked-terminal": "^6.1.1",
|
|
29
|
-
"@types/node": "^
|
|
29
|
+
"@types/node": "^26.0.0",
|
|
30
30
|
"ts-node": "^10.9.2",
|
|
31
31
|
"tslib": "2.8.1",
|
|
32
|
-
"typescript": "^6.0.
|
|
32
|
+
"typescript": "^6.0.3"
|
|
33
33
|
},
|
|
34
34
|
"type": "module",
|
|
35
35
|
"preferGlobal": true,
|