@agent-smith/cli 0.0.17 → 0.0.18
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/agent.d.ts +1 -1
- package/dist/cmd/clicmds/cmds.js +8 -12
- package/dist/cmd/lib/execute_task.js +11 -0
- package/dist/cmd/lib/utils.js +8 -0
- package/dist/conf.d.ts +2 -2
- package/dist/conf.js +2 -2
- package/dist/db/write.d.ts +2 -1
- package/dist/db/write.js +22 -7
- package/dist/index.js +0 -0
- package/package.json +9 -9
package/dist/agent.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LmTaskBuilder } from "@agent-smith/lmtask";
|
|
2
2
|
import { marked } from 'marked';
|
|
3
3
|
import { FeatureType, RunMode } from "./interfaces.js";
|
|
4
|
-
declare let brain: import("@agent-smith/brain").AgentBrain
|
|
4
|
+
declare let brain: import("@agent-smith/brain").AgentBrain<Record<string, any>>;
|
|
5
5
|
declare const modelsForExpert: Record<string, string>;
|
|
6
6
|
declare const taskBuilder: LmTaskBuilder<FeatureType>;
|
|
7
7
|
declare function initAgent(mode: RunMode, isVerbose?: boolean): Promise<boolean>;
|
package/dist/cmd/clicmds/cmds.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { formatMode,
|
|
1
|
+
import { formatMode, runMode } from "../../state/state.js";
|
|
2
2
|
import { getFeatureSpec, readFeaturesDirs } from "../../state/features.js";
|
|
3
3
|
import { readAliases, readFeatures } from "../../db/read.js";
|
|
4
|
-
import { updateAliases, updateFeatures } from "../../db/write.js";
|
|
5
|
-
import {
|
|
4
|
+
import { cleanupFeaturePaths, updateAliases, updateFeatures } from "../../db/write.js";
|
|
5
|
+
import { processConfPath } from "../../conf.js";
|
|
6
6
|
import { executeActionCmd } from "../lib/execute_action.js";
|
|
7
7
|
import { initAgent, marked, taskBuilder } from "../../agent.js";
|
|
8
8
|
import { executeJobCmd, readJob } from "../lib/execute_job.js";
|
|
@@ -51,10 +51,6 @@ let cmds = {
|
|
|
51
51
|
description: "process config file",
|
|
52
52
|
args: "arguments: \n-path (required): the path to the config.yml file"
|
|
53
53
|
},
|
|
54
|
-
update: {
|
|
55
|
-
cmd: _updateFeaturesCmd,
|
|
56
|
-
description: "reparse the features dirs and update the list",
|
|
57
|
-
}
|
|
58
54
|
};
|
|
59
55
|
function initAliases() {
|
|
60
56
|
const aliases = readAliases();
|
|
@@ -97,19 +93,19 @@ async function pingCmd(args = [], options) {
|
|
|
97
93
|
const isUp = await initAgent(runMode.value, _isVerbose);
|
|
98
94
|
return isUp;
|
|
99
95
|
}
|
|
100
|
-
async function _updateFeaturesCmd(args = [], options) {
|
|
101
|
-
await initFeatures();
|
|
102
|
-
console.log("Features updated");
|
|
103
|
-
}
|
|
104
96
|
async function _updateConfCmd(args = [], options) {
|
|
105
97
|
if (args.length == 0) {
|
|
106
98
|
console.warn("Provide a config.yml file path");
|
|
107
99
|
return;
|
|
108
100
|
}
|
|
109
|
-
const allPaths = await
|
|
101
|
+
const allPaths = await processConfPath(args[0]);
|
|
110
102
|
const feats = readFeaturesDirs(allPaths);
|
|
111
103
|
updateFeatures(feats);
|
|
112
104
|
updateAliases(feats);
|
|
105
|
+
const deleted = cleanupFeaturePaths(allPaths);
|
|
106
|
+
for (const el of deleted) {
|
|
107
|
+
console.log("- [feature path]", el);
|
|
108
|
+
}
|
|
113
109
|
}
|
|
114
110
|
async function _readJobCmd(args = [], options) {
|
|
115
111
|
if (args.length == 0) {
|
|
@@ -5,6 +5,10 @@ import { initTaskVars, readPromptFile, readTask } from "./utils.js";
|
|
|
5
5
|
import { readClipboard } from "../sys/clipboard.js";
|
|
6
6
|
async function executeTaskCmd(args = [], options = {}) {
|
|
7
7
|
await initAgent(runMode.value);
|
|
8
|
+
if (isDebug.value) {
|
|
9
|
+
console.log("Task args:", args);
|
|
10
|
+
console.log("Task options:", options);
|
|
11
|
+
}
|
|
8
12
|
const name = args.shift();
|
|
9
13
|
const params = args.filter((x) => x.length > 0);
|
|
10
14
|
let pr;
|
|
@@ -31,6 +35,10 @@ async function executeTaskCmd(args = [], options = {}) {
|
|
|
31
35
|
const taskSpec = taskBuilder.readFromYaml(res.ymlTask);
|
|
32
36
|
const task = taskBuilder.fromYaml(res.ymlTask);
|
|
33
37
|
const { conf, vars } = initTaskVars(args);
|
|
38
|
+
if (isDebug.value) {
|
|
39
|
+
console.log("Task conf:", conf);
|
|
40
|
+
console.log("Task vars:", vars);
|
|
41
|
+
}
|
|
34
42
|
let m = taskSpec.model.name;
|
|
35
43
|
let t = taskSpec.template.name;
|
|
36
44
|
if (conf?.model) {
|
|
@@ -51,6 +59,9 @@ async function executeTaskCmd(args = [], options = {}) {
|
|
|
51
59
|
if (isDebug.value) {
|
|
52
60
|
conf.debug = true;
|
|
53
61
|
}
|
|
62
|
+
if (isDebug.value) {
|
|
63
|
+
console.log("Vars", vars);
|
|
64
|
+
}
|
|
54
65
|
const data = await task.run({ prompt: pr, ...vars }, conf);
|
|
55
66
|
if (data?.error) {
|
|
56
67
|
return { ok: false, data: {}, error: `Error executing task: ${data.error}` };
|
package/dist/cmd/lib/utils.js
CHANGED
|
@@ -88,6 +88,14 @@ function initTaskVars(args) {
|
|
|
88
88
|
conf.model = v;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
+
else if (k == "ip") {
|
|
92
|
+
const ip = {};
|
|
93
|
+
v.split(",").forEach((p) => {
|
|
94
|
+
const s = p.split(":");
|
|
95
|
+
ip[s[0]] = parseFloat(s[1]);
|
|
96
|
+
});
|
|
97
|
+
conf.inferParams = ip;
|
|
98
|
+
}
|
|
91
99
|
else {
|
|
92
100
|
vars[k] = v;
|
|
93
101
|
}
|
package/dist/conf.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const confDir: string;
|
|
2
2
|
declare const dbPath: string;
|
|
3
3
|
declare function createConfDirIfNotExists(): boolean;
|
|
4
|
-
declare function
|
|
5
|
-
export { confDir, dbPath, createConfDirIfNotExists,
|
|
4
|
+
declare function processConfPath(confPath: string): Promise<Array<string>>;
|
|
5
|
+
export { confDir, dbPath, createConfDirIfNotExists, processConfPath, };
|
package/dist/conf.js
CHANGED
|
@@ -12,7 +12,7 @@ function createConfDirIfNotExists() {
|
|
|
12
12
|
}
|
|
13
13
|
return true;
|
|
14
14
|
}
|
|
15
|
-
async function
|
|
15
|
+
async function processConfPath(confPath) {
|
|
16
16
|
const { found, data } = readConf(confPath);
|
|
17
17
|
if (!found) {
|
|
18
18
|
console.warn(`Config file ${confPath} not found`);
|
|
@@ -37,4 +37,4 @@ async function updateConf(confPath) {
|
|
|
37
37
|
}
|
|
38
38
|
return allPaths;
|
|
39
39
|
}
|
|
40
|
-
export { confDir, dbPath, createConfDirIfNotExists,
|
|
40
|
+
export { confDir, dbPath, createConfDirIfNotExists, processConfPath, };
|
package/dist/db/write.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Features } from "../interfaces.js";
|
|
|
2
2
|
declare function insertDefaultFilepaths(): void;
|
|
3
3
|
declare function insertFeaturesPathIfNotExists(path: string): boolean;
|
|
4
4
|
declare function insertPluginIfNotExists(n: string, p: string): boolean;
|
|
5
|
+
declare function cleanupFeaturePaths(paths: Array<string>): Array<string>;
|
|
5
6
|
declare function updateAliases(feats: Features): void;
|
|
6
7
|
declare function updateFeatures(feats: Features): void;
|
|
7
|
-
export { insertDefaultFilepaths, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, updateAliases, };
|
|
8
|
+
export { insertDefaultFilepaths, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, updateAliases, cleanupFeaturePaths, };
|
package/dist/db/write.js
CHANGED
|
@@ -29,6 +29,19 @@ function insertPluginIfNotExists(n, p) {
|
|
|
29
29
|
stmt.run(n, p);
|
|
30
30
|
return false;
|
|
31
31
|
}
|
|
32
|
+
function cleanupFeaturePaths(paths) {
|
|
33
|
+
const stmt = db.prepare("SELECT path FROM featurespath");
|
|
34
|
+
const rows = stmt.all();
|
|
35
|
+
const deleted = new Array();
|
|
36
|
+
for (const entry of rows) {
|
|
37
|
+
if (!paths.includes(entry.path)) {
|
|
38
|
+
const deleteStmt = db.prepare("DELETE FROM featurespath WHERE path = ?");
|
|
39
|
+
deleteStmt.run(entry.path);
|
|
40
|
+
deleted.push(entry.path);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return deleted;
|
|
44
|
+
}
|
|
32
45
|
function _updateAlias(existingAliases, name, type) {
|
|
33
46
|
if (!existingAliases.includes(name)) {
|
|
34
47
|
const insertStmt = db.prepare("INSERT INTO aliases (name, type) VALUES (?, ?)");
|
|
@@ -58,17 +71,19 @@ function upsertAndCleanFeatures(feats, type) {
|
|
|
58
71
|
const stmt = db.prepare(`SELECT name FROM ${type}`);
|
|
59
72
|
const rows = stmt.all();
|
|
60
73
|
const names = rows.map(row => row.name);
|
|
61
|
-
feats.forEach((feat) => {
|
|
62
|
-
if (!names.includes(feat.name)) {
|
|
63
|
-
const insertStmt = db.prepare(`INSERT INTO ${type} (name, path, ext) VALUES (?, ?, ?)`);
|
|
64
|
-
insertStmt.run(feat.name, feat.path, feat.ext);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
74
|
const availableFeatsNames = feats.map((f) => f.name);
|
|
68
75
|
names.forEach((name) => {
|
|
69
76
|
if (!availableFeatsNames.includes(name)) {
|
|
70
77
|
const deleteStmt = db.prepare(`DELETE FROM ${type} WHERE name = ?`);
|
|
71
78
|
deleteStmt.run(name);
|
|
79
|
+
console.log("-", "[" + type + "]", name);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
feats.forEach((feat) => {
|
|
83
|
+
if (!names.includes(feat.name)) {
|
|
84
|
+
const insertStmt = db.prepare(`INSERT INTO ${type} (name, path, ext) VALUES (?, ?, ?)`);
|
|
85
|
+
insertStmt.run(feat.name, feat.path, feat.ext);
|
|
86
|
+
console.log("+", "[" + type + "]", feat.name, feat.path);
|
|
72
87
|
}
|
|
73
88
|
});
|
|
74
89
|
}
|
|
@@ -78,4 +93,4 @@ function updateFeatures(feats) {
|
|
|
78
93
|
upsertAndCleanFeatures(feats.action, "action");
|
|
79
94
|
upsertAndCleanFeatures(feats.cmd, "cmd");
|
|
80
95
|
}
|
|
81
|
-
export { insertDefaultFilepaths, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, updateAliases, };
|
|
96
|
+
export { insertDefaultFilepaths, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, updateAliases, cleanupFeaturePaths, };
|
package/dist/index.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@agent-smith/cli",
|
|
3
3
|
"description": "Agent Smith: terminal client for language model agents",
|
|
4
4
|
"repository": "https://github.com/synw/agent-smith",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.18",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"buildrl": "rm -rf dist/* && rollup -c",
|
|
8
8
|
"build": "rm -rf dist/* && tsc",
|
|
@@ -10,34 +10,34 @@
|
|
|
10
10
|
"watch": "tsc -p . -w"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@agent-smith/brain": "^0.0.
|
|
13
|
+
"@agent-smith/brain": "^0.0.32",
|
|
14
14
|
"@agent-smith/jobs": "^0.0.11",
|
|
15
|
-
"@agent-smith/lmtask": "^0.0.
|
|
15
|
+
"@agent-smith/lmtask": "^0.0.23",
|
|
16
16
|
"@inquirer/prompts": "^7.0.0",
|
|
17
17
|
"@inquirer/select": "^4.0.0",
|
|
18
18
|
"@vue/reactivity": "^3.5.12",
|
|
19
|
-
"better-sqlite3": "^11.
|
|
19
|
+
"better-sqlite3": "^11.5.0",
|
|
20
20
|
"clipboardy": "^4.0.0",
|
|
21
21
|
"commander": "^12.1.0",
|
|
22
22
|
"draftlog": "^1.0.13",
|
|
23
23
|
"marked-terminal": "^7.1.0",
|
|
24
|
-
"modprompt": "^0.
|
|
24
|
+
"modprompt": "^0.9.0",
|
|
25
25
|
"python-shell": "^5.0.0",
|
|
26
|
-
"yaml": "^2.
|
|
26
|
+
"yaml": "^2.6.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@agent-smith/tmem-jobs": "^0.0.4",
|
|
30
30
|
"@commander-js/extra-typings": "^12.1.0",
|
|
31
31
|
"@locallm/types": "^0.1.5",
|
|
32
32
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
33
|
-
"@rollup/plugin-typescript": "^12.1.
|
|
33
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
|
34
34
|
"@types/better-sqlite3": "^7.6.11",
|
|
35
35
|
"@types/marked-terminal": "^6.1.1",
|
|
36
|
-
"@types/node": "^22.7.
|
|
36
|
+
"@types/node": "^22.7.9",
|
|
37
37
|
"restmix": "^0.5.0",
|
|
38
38
|
"rollup": "^4.24.0",
|
|
39
39
|
"ts-node": "^10.9.2",
|
|
40
|
-
"tslib": "2.
|
|
40
|
+
"tslib": "2.8.0",
|
|
41
41
|
"typescript": "^5.6.3"
|
|
42
42
|
},
|
|
43
43
|
"type": "module",
|