@agent-smith/cli 0.0.3 → 0.0.5
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 -2
- package/dist/agent.js +3 -12
- package/dist/cmd/clicmds/cmds.d.ts +5 -0
- package/dist/cmd/clicmds/cmds.js +138 -0
- package/dist/cmd/{options → clicmds}/modes.js +2 -2
- package/dist/cmd/cmds.d.ts +2 -3
- package/dist/cmd/cmds.js +7 -161
- package/dist/cmd/lib/execute_job.js +8 -1
- package/dist/cmd/lib/execute_task.js +1 -2
- package/dist/cmd/lib/utils.js +2 -2
- package/dist/conf.d.ts +2 -1
- package/dist/conf.js +29 -1
- package/dist/db/db.d.ts +1 -2
- package/dist/db/db.js +4 -6
- package/dist/index.js +2 -2
- package/dist/main.d.ts +1 -1
- package/dist/main.js +1 -1
- package/dist/state/state.js +3 -7
- package/package.json +6 -6
- /package/dist/cmd/{options → clicmds}/modes.d.ts +0 -0
package/dist/agent.d.ts
CHANGED
|
@@ -10,6 +10,5 @@ declare const taskReader: {
|
|
|
10
10
|
};
|
|
11
11
|
readDir: (dir: string) => Array<string>;
|
|
12
12
|
};
|
|
13
|
-
declare function clearOutput(): void;
|
|
14
13
|
declare function initAgent(mode: RunMode, isVerbose?: boolean): Promise<boolean>;
|
|
15
|
-
export { brain, initAgent,
|
|
14
|
+
export { brain, initAgent, marked, modelsForExpert, taskReader };
|
package/dist/agent.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useAgentBrain } from "@agent-smith/brain";
|
|
2
2
|
import { useLmTask } from "@agent-smith/lmtask";
|
|
3
|
-
|
|
3
|
+
;
|
|
4
4
|
import { marked } from 'marked';
|
|
5
5
|
import { markedTerminal } from 'marked-terminal';
|
|
6
|
-
import { formatMode } from "./state/state.js";
|
|
7
6
|
marked.use(markedTerminal());
|
|
8
7
|
let brain = useAgentBrain();
|
|
9
8
|
const modelsForExpert = {};
|
|
@@ -12,18 +11,10 @@ async function initExperts() {
|
|
|
12
11
|
brain.experts.forEach((ex) => {
|
|
13
12
|
ex.setOnStartEmit(() => console.log(""));
|
|
14
13
|
ex.setOnToken((t) => {
|
|
15
|
-
|
|
16
|
-
logUpdate(marked.parse(ex.stream.get() + t).trim());
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
logUpdate((ex.stream.get() + t).trim());
|
|
20
|
-
}
|
|
14
|
+
process.stdout.write(t);
|
|
21
15
|
});
|
|
22
16
|
});
|
|
23
17
|
}
|
|
24
|
-
function clearOutput() {
|
|
25
|
-
logUpdate.clear();
|
|
26
|
-
}
|
|
27
18
|
async function initAgent(mode, isVerbose = false) {
|
|
28
19
|
if (!brain.state.get().isOn) {
|
|
29
20
|
brain.resetExperts();
|
|
@@ -44,4 +35,4 @@ async function initAgent(mode, isVerbose = false) {
|
|
|
44
35
|
}
|
|
45
36
|
return brainUp;
|
|
46
37
|
}
|
|
47
|
-
export { brain, initAgent,
|
|
38
|
+
export { brain, initAgent, marked, modelsForExpert, taskReader };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Cmd } from "../../interfaces.js";
|
|
2
|
+
declare let cmds: Record<string, Cmd>;
|
|
3
|
+
declare function initCmds(): Promise<Record<string, Cmd>>;
|
|
4
|
+
declare function pingCmd(args: Array<string> | undefined, options: any): Promise<boolean>;
|
|
5
|
+
export { cmds, initCmds, pingCmd };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { formatMode, initFeatures, runMode } from "../../state/state.js";
|
|
2
|
+
import { getFeatureSpec, readFeaturesDirs } from "../../state/features.js";
|
|
3
|
+
import { readFeatures } from "../../db/read.js";
|
|
4
|
+
import { updateFeatures } from "../../db/write.js";
|
|
5
|
+
import { updateConf } from "../../conf.js";
|
|
6
|
+
import { executeActionCmd } from "../lib/execute_action.js";
|
|
7
|
+
import { initAgent, marked, taskReader } from "../../agent.js";
|
|
8
|
+
import { executeJobCmd, readJob } from "../lib/execute_job.js";
|
|
9
|
+
import { executeTaskCmd } from "../lib/execute_task.js";
|
|
10
|
+
import { readCmds } from "../sys/read_cmds.js";
|
|
11
|
+
let cmds = {
|
|
12
|
+
q: {
|
|
13
|
+
cmd: async () => process.exit(0),
|
|
14
|
+
description: "exit the cli"
|
|
15
|
+
},
|
|
16
|
+
ping: {
|
|
17
|
+
cmd: async () => pingCmd(["verbose"], undefined),
|
|
18
|
+
description: "ping inference servers",
|
|
19
|
+
},
|
|
20
|
+
lt: {
|
|
21
|
+
cmd: _listTasksCmd,
|
|
22
|
+
description: "list all the tasks"
|
|
23
|
+
},
|
|
24
|
+
rt: {
|
|
25
|
+
cmd: _readTaskCmd,
|
|
26
|
+
description: "read a task",
|
|
27
|
+
args: "arguments: \n-task (required): the task name"
|
|
28
|
+
},
|
|
29
|
+
rj: {
|
|
30
|
+
cmd: _readJobCmd,
|
|
31
|
+
description: "read a job",
|
|
32
|
+
args: "arguments: \n-job (required): the job name"
|
|
33
|
+
},
|
|
34
|
+
t: {
|
|
35
|
+
cmd: _executeTaskCmd,
|
|
36
|
+
description: "execute a task",
|
|
37
|
+
args: "arguments: \n-task (required): the task name\n-args: prompt and other arguments if any for the task"
|
|
38
|
+
},
|
|
39
|
+
j: {
|
|
40
|
+
cmd: _executeJobCmd,
|
|
41
|
+
description: "execute a job",
|
|
42
|
+
args: "arguments: \n-job (required): the job name\n-args: arguments if any for the job"
|
|
43
|
+
},
|
|
44
|
+
a: {
|
|
45
|
+
cmd: executeActionCmd,
|
|
46
|
+
description: "execute an action",
|
|
47
|
+
args: "arguments: \n-action (required): the task name\n-args: other arguments if any for the action"
|
|
48
|
+
},
|
|
49
|
+
conf: {
|
|
50
|
+
cmd: _updateConfCmd,
|
|
51
|
+
description: "process config file",
|
|
52
|
+
args: "arguments: \n-path (required): the path to the config.yml file"
|
|
53
|
+
},
|
|
54
|
+
update: {
|
|
55
|
+
cmd: _updateFeaturesCmd,
|
|
56
|
+
description: "reparse the features dirs and update the list",
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
async function initCmds() {
|
|
60
|
+
for (const dirpath of new Set(Object.values(readFeatures().cmd))) {
|
|
61
|
+
const c = await readCmds(`${dirpath}`);
|
|
62
|
+
cmds = { ...cmds, ...c };
|
|
63
|
+
}
|
|
64
|
+
return cmds;
|
|
65
|
+
}
|
|
66
|
+
async function pingCmd(args = [], options) {
|
|
67
|
+
let _isVerbose = false;
|
|
68
|
+
if (args.length > 0) {
|
|
69
|
+
_isVerbose = args[0] == "verbose";
|
|
70
|
+
}
|
|
71
|
+
const isUp = await initAgent(runMode.value, _isVerbose);
|
|
72
|
+
return isUp;
|
|
73
|
+
}
|
|
74
|
+
async function _updateFeaturesCmd(args = [], options) {
|
|
75
|
+
await initFeatures();
|
|
76
|
+
console.log("Features updated");
|
|
77
|
+
}
|
|
78
|
+
async function _updateConfCmd(args = [], options) {
|
|
79
|
+
if (args.length == 0) {
|
|
80
|
+
console.warn("Provide a config.yml file path");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const allPaths = await updateConf(args[0]);
|
|
84
|
+
const feats = readFeaturesDirs(allPaths);
|
|
85
|
+
updateFeatures(feats);
|
|
86
|
+
}
|
|
87
|
+
async function _readJobCmd(args = [], options) {
|
|
88
|
+
if (args.length == 0) {
|
|
89
|
+
console.warn("Provide a job name");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const t = await readJob(args[0]);
|
|
93
|
+
console.log(t.data);
|
|
94
|
+
}
|
|
95
|
+
async function _executeTaskCmd(args = [], options) {
|
|
96
|
+
if (args.length == 0) {
|
|
97
|
+
console.warn("Provide a task name");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const { ok, data, error } = await executeTaskCmd(args);
|
|
101
|
+
if (!ok) {
|
|
102
|
+
console.warn(error);
|
|
103
|
+
}
|
|
104
|
+
if (formatMode.value == "markdown") {
|
|
105
|
+
console.log("\n\n------------------\n");
|
|
106
|
+
console.log(marked.parse(data).trim());
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
console.log();
|
|
110
|
+
}
|
|
111
|
+
return data;
|
|
112
|
+
}
|
|
113
|
+
async function _executeJobCmd(args = [], options) {
|
|
114
|
+
if (args.length == 0) {
|
|
115
|
+
console.warn("Provide a job name");
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const name = args.shift();
|
|
119
|
+
const res = await executeJobCmd(name, args);
|
|
120
|
+
return res;
|
|
121
|
+
}
|
|
122
|
+
async function _readTaskCmd(args = [], options) {
|
|
123
|
+
if (args.length == 0) {
|
|
124
|
+
console.warn("Provide a task name");
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const { found, path } = getFeatureSpec(args[0], "task");
|
|
128
|
+
if (!found) {
|
|
129
|
+
console.warn(`FeatureType ${args[0]} not found`);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const r = taskReader.read(path);
|
|
133
|
+
console.log(r.task);
|
|
134
|
+
}
|
|
135
|
+
async function _listTasksCmd(args = [], options) {
|
|
136
|
+
Object.keys(readFeatures().task).forEach((t) => console.log("-", t));
|
|
137
|
+
}
|
|
138
|
+
export { cmds, initCmds, pingCmd };
|
|
@@ -43,13 +43,13 @@ const modes = {
|
|
|
43
43
|
console.log("Markdown output mode");
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
description: "use markdown output
|
|
46
|
+
description: "use markdown output"
|
|
47
47
|
},
|
|
48
48
|
"-otxt": {
|
|
49
49
|
cmd: async () => {
|
|
50
50
|
formatMode.value = "text";
|
|
51
51
|
if (runMode.value == "cli") {
|
|
52
|
-
console.log("Text output mode");
|
|
52
|
+
console.log("Text output mode (default)");
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
description: "use text output "
|
package/dist/cmd/cmds.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
declare function
|
|
2
|
+
declare function initCliCmds(): Promise<void>;
|
|
3
3
|
declare function runCmd(cmdName: string, args?: Array<string>): Promise<void>;
|
|
4
|
-
declare function pingCmd(args: Array<string> | undefined, options: any): Promise<boolean>;
|
|
5
4
|
declare function buildCmds(): Promise<Command>;
|
|
6
5
|
declare function parseCmd(): Promise<void>;
|
|
7
|
-
export {
|
|
6
|
+
export { runCmd, buildCmds, parseCmd, initCliCmds };
|
package/dist/cmd/cmds.js
CHANGED
|
@@ -1,157 +1,11 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import {
|
|
3
|
-
import { modes } from "./
|
|
4
|
-
import { executeTaskCmd } from "./lib/execute_task.js";
|
|
5
|
-
import { clearOutput, initAgent, marked, taskReader } from "../agent.js";
|
|
6
|
-
import { executeActionCmd } from "./lib/execute_action.js";
|
|
7
|
-
import { executeJobCmd, readJob } from "./lib/execute_job.js";
|
|
8
|
-
import { readCmds } from "./sys/read_cmds.js";
|
|
2
|
+
import { lastCmd } from "../state/state.js";
|
|
3
|
+
import { modes } from "./clicmds/modes.js";
|
|
9
4
|
import { processOutput, setOptions } from "./lib/utils.js";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import { buildPluginsPaths } from "../state/plugins.js";
|
|
15
|
-
let cmds = {
|
|
16
|
-
q: {
|
|
17
|
-
cmd: async () => process.exit(0),
|
|
18
|
-
description: "exit the cli"
|
|
19
|
-
},
|
|
20
|
-
ping: {
|
|
21
|
-
cmd: async () => pingCmd(["verbose"], undefined),
|
|
22
|
-
description: "ping inference servers",
|
|
23
|
-
},
|
|
24
|
-
lt: {
|
|
25
|
-
cmd: _listTasksCmd,
|
|
26
|
-
description: "list all the tasks"
|
|
27
|
-
},
|
|
28
|
-
rt: {
|
|
29
|
-
cmd: _readTaskCmd,
|
|
30
|
-
description: "read a task",
|
|
31
|
-
args: "arguments: \n-task (required): the task name"
|
|
32
|
-
},
|
|
33
|
-
rj: {
|
|
34
|
-
cmd: _readJobCmd,
|
|
35
|
-
description: "read a job",
|
|
36
|
-
args: "arguments: \n-job (required): the job name"
|
|
37
|
-
},
|
|
38
|
-
t: {
|
|
39
|
-
cmd: _executeTaskCmd,
|
|
40
|
-
description: "execute a task",
|
|
41
|
-
args: "arguments: \n-task (required): the task name\n-args: prompt and other arguments if any for the task"
|
|
42
|
-
},
|
|
43
|
-
j: {
|
|
44
|
-
cmd: _executeJobCmd,
|
|
45
|
-
description: "execute a job",
|
|
46
|
-
args: "arguments: \n-job (required): the job name\n-args: arguments if any for the job"
|
|
47
|
-
},
|
|
48
|
-
a: {
|
|
49
|
-
cmd: executeActionCmd,
|
|
50
|
-
description: "execute an action",
|
|
51
|
-
args: "arguments: \n-action (required): the task name\n-args: other arguments if any for the action"
|
|
52
|
-
},
|
|
53
|
-
conf: {
|
|
54
|
-
cmd: _updateConfCmd,
|
|
55
|
-
description: "process config file",
|
|
56
|
-
args: "arguments: \n-path (required): the path to the config.yml file"
|
|
57
|
-
},
|
|
58
|
-
update: {
|
|
59
|
-
cmd: _updateFeaturesCmd,
|
|
60
|
-
description: "reparse the features dirs and update the list",
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
let cliCmds = { ...cmds, ...modes };
|
|
64
|
-
async function initCmds() {
|
|
65
|
-
for (const dirpath of new Set(Object.values(readFeatures().cmd))) {
|
|
66
|
-
const c = await readCmds(`${dirpath}`);
|
|
67
|
-
cmds = { ...cmds, ...c };
|
|
68
|
-
}
|
|
69
|
-
cliCmds = { ...cmds, ...modes };
|
|
70
|
-
}
|
|
71
|
-
async function _updateFeaturesCmd(args = [], options) {
|
|
72
|
-
await initFeatures();
|
|
73
|
-
console.log("Features updated");
|
|
74
|
-
}
|
|
75
|
-
async function _updateConfCmd(args = [], options) {
|
|
76
|
-
if (args.length == 0) {
|
|
77
|
-
console.warn("Provide a config.yml file path");
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const { found, data } = readConf(args[0]);
|
|
81
|
-
if (!found) {
|
|
82
|
-
console.warn(`Config file ${args[0]} not found`);
|
|
83
|
-
}
|
|
84
|
-
const p = new Array();
|
|
85
|
-
if ("features" in data) {
|
|
86
|
-
p.push(...data.features);
|
|
87
|
-
const fts = new Array();
|
|
88
|
-
data.features.forEach((f) => {
|
|
89
|
-
if (!fts.includes(f)) {
|
|
90
|
-
insertFeaturesPathIfNotExists(f);
|
|
91
|
-
fts.push(f);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
if ("plugins" in data) {
|
|
96
|
-
const plugins = await buildPluginsPaths(data.plugins);
|
|
97
|
-
plugins.forEach((_pl) => {
|
|
98
|
-
p.push(_pl.path);
|
|
99
|
-
insertPluginIfNotExists(_pl.name, _pl.path);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
const feats = readFeaturesDirs(p);
|
|
103
|
-
updateFeatures(feats);
|
|
104
|
-
}
|
|
105
|
-
async function _readJobCmd(args = [], options) {
|
|
106
|
-
if (args.length == 0) {
|
|
107
|
-
console.warn("Provide a job name");
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const t = await readJob(args[0]);
|
|
111
|
-
console.log(t.data);
|
|
112
|
-
}
|
|
113
|
-
async function _executeTaskCmd(args = [], options) {
|
|
114
|
-
if (args.length == 0) {
|
|
115
|
-
console.warn("Provide a task name");
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
const { ok, data, error } = await executeTaskCmd(args);
|
|
119
|
-
if (!ok) {
|
|
120
|
-
console.warn(error);
|
|
121
|
-
}
|
|
122
|
-
clearOutput();
|
|
123
|
-
if (formatMode.value == "markdown") {
|
|
124
|
-
console.log(marked.parse(data).trim());
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
console.log(data);
|
|
128
|
-
}
|
|
129
|
-
return data;
|
|
130
|
-
}
|
|
131
|
-
async function _executeJobCmd(args = [], options) {
|
|
132
|
-
if (args.length == 0) {
|
|
133
|
-
console.warn("Provide a job name");
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
const name = args.shift();
|
|
137
|
-
const res = await executeJobCmd(name, args);
|
|
138
|
-
return res;
|
|
139
|
-
}
|
|
140
|
-
async function _readTaskCmd(args = [], options) {
|
|
141
|
-
if (args.length == 0) {
|
|
142
|
-
console.warn("Provide a task name");
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
const { found, path } = getFeatureSpec(args[0], "task");
|
|
146
|
-
if (!found) {
|
|
147
|
-
console.warn(`FeatureType ${args[0]} not found`);
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
const r = taskReader.read(path);
|
|
151
|
-
console.log(r.task);
|
|
152
|
-
}
|
|
153
|
-
async function _listTasksCmd(args = [], options) {
|
|
154
|
-
Object.keys(readFeatures().task).forEach((t) => console.log("-", t));
|
|
5
|
+
import { cmds, initCmds } from "./clicmds/cmds.js";
|
|
6
|
+
let cliCmds = {};
|
|
7
|
+
async function initCliCmds() {
|
|
8
|
+
cliCmds = await initCmds();
|
|
155
9
|
}
|
|
156
10
|
async function runCmd(cmdName, args = []) {
|
|
157
11
|
if (!(cmdName in cliCmds)) {
|
|
@@ -163,14 +17,6 @@ async function runCmd(cmdName, args = []) {
|
|
|
163
17
|
lastCmd.name = cmdName;
|
|
164
18
|
lastCmd.args = args;
|
|
165
19
|
}
|
|
166
|
-
async function pingCmd(args = [], options) {
|
|
167
|
-
let _isVerbose = false;
|
|
168
|
-
if (args.length > 0) {
|
|
169
|
-
_isVerbose = args[0] == "verbose";
|
|
170
|
-
}
|
|
171
|
-
const isUp = await initAgent(runMode.value, _isVerbose);
|
|
172
|
-
return isUp;
|
|
173
|
-
}
|
|
174
20
|
async function buildCmds() {
|
|
175
21
|
const program = new Command();
|
|
176
22
|
for (const [name, spec] of Object.entries(cmds)) {
|
|
@@ -203,4 +49,4 @@ async function parseCmd() {
|
|
|
203
49
|
const program = await buildCmds();
|
|
204
50
|
await program.parseAsync();
|
|
205
51
|
}
|
|
206
|
-
export {
|
|
52
|
+
export { runCmd, buildCmds, parseCmd, initCliCmds };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import YAML from 'yaml';
|
|
2
2
|
import { default as fs } from "fs";
|
|
3
3
|
import { useAgentJob } from "@agent-smith/jobs";
|
|
4
|
-
import { brain, taskReader } from '../../agent.js';
|
|
4
|
+
import { brain, marked, taskReader } from '../../agent.js';
|
|
5
5
|
import { getFeatureSpec } from '../../state/features.js';
|
|
6
|
+
import { formatMode } from '../../state/state.js';
|
|
6
7
|
async function executeJobCmd(name, args = []) {
|
|
7
8
|
const { job, found } = await _dispatchReadJob(name);
|
|
8
9
|
if (!found) {
|
|
@@ -16,6 +17,12 @@ async function executeJobCmd(name, args = []) {
|
|
|
16
17
|
brain.expertsForModelsInfo();
|
|
17
18
|
try {
|
|
18
19
|
res = await job.runTask(name, params);
|
|
20
|
+
if ("text" in res) {
|
|
21
|
+
if (formatMode.value == "markdown") {
|
|
22
|
+
console.log("\n\n------------------\n");
|
|
23
|
+
console.log(marked.parse(res.text).trim());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
19
26
|
}
|
|
20
27
|
catch (err) {
|
|
21
28
|
console.log("ERR", err);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { initAgent, taskReader } from "../../agent.js";
|
|
2
|
-
import logUpdate from "log-update";
|
|
3
2
|
import { getFeatureSpec } from "../../state/features.js";
|
|
4
3
|
import { runMode } from "../../state/state.js";
|
|
5
4
|
async function executeTaskCmd(args = [], options = {}) {
|
|
@@ -18,7 +17,7 @@ async function executeTaskCmd(args = [], options = {}) {
|
|
|
18
17
|
vars[t[0]] = t[1];
|
|
19
18
|
}
|
|
20
19
|
});
|
|
21
|
-
|
|
20
|
+
console.log("Ingesting prompt ...");
|
|
22
21
|
const data = await task.run({ prompt: pr, ...vars });
|
|
23
22
|
if (data?.error) {
|
|
24
23
|
return { ok: false, data: {}, error: `Error executing task: ${data.error}` };
|
package/dist/cmd/lib/utils.js
CHANGED
|
@@ -2,7 +2,7 @@ import { default as fs } from "fs";
|
|
|
2
2
|
import { outputMode, promptfile } from "../../state/state.js";
|
|
3
3
|
import { inputMode, runMode } from "../../state/state.js";
|
|
4
4
|
import { readClipboard, writeToClipboard } from "../sys/clipboard.js";
|
|
5
|
-
import { modes } from "../
|
|
5
|
+
import { modes } from "../clicmds/modes.js";
|
|
6
6
|
async function setOptions(options, args = []) {
|
|
7
7
|
if (runMode.value == "cli") {
|
|
8
8
|
return args;
|
|
@@ -39,7 +39,7 @@ async function processOutput(res) {
|
|
|
39
39
|
hasOutput = true;
|
|
40
40
|
}
|
|
41
41
|
if (!hasOutput) {
|
|
42
|
-
throw new Error(`No data in res: ${res}`);
|
|
42
|
+
throw new Error(`No data in res: ${JSON.stringify(res, null, " ")}`);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
else {
|
package/dist/conf.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare const confDir: string;
|
|
2
2
|
declare const dbPath: string;
|
|
3
3
|
declare function createConfDirIfNotExists(): boolean;
|
|
4
|
-
|
|
4
|
+
declare function updateConf(confPath: string): Promise<Array<string>>;
|
|
5
|
+
export { confDir, dbPath, createConfDirIfNotExists, updateConf, };
|
package/dist/conf.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { default as fs } from "fs";
|
|
3
|
+
import { readConf } from "./cmd/sys/read_conf.js";
|
|
4
|
+
import { insertFeaturesPathIfNotExists, insertPluginIfNotExists } from "./db/write.js";
|
|
5
|
+
import { buildPluginsPaths } from "./state/plugins.js";
|
|
3
6
|
const confDir = path.join(process.env.HOME, ".config/agent-smith/cli");
|
|
4
7
|
const dbPath = path.join(confDir, "config.db");
|
|
5
8
|
function createConfDirIfNotExists() {
|
|
@@ -9,4 +12,29 @@ function createConfDirIfNotExists() {
|
|
|
9
12
|
}
|
|
10
13
|
return true;
|
|
11
14
|
}
|
|
12
|
-
|
|
15
|
+
async function updateConf(confPath) {
|
|
16
|
+
const { found, data } = readConf(confPath);
|
|
17
|
+
if (!found) {
|
|
18
|
+
console.warn(`Config file ${confPath} not found`);
|
|
19
|
+
}
|
|
20
|
+
const allPaths = new Array();
|
|
21
|
+
if ("features" in data) {
|
|
22
|
+
allPaths.push(...data.features);
|
|
23
|
+
const fts = new Array();
|
|
24
|
+
data.features.forEach((f) => {
|
|
25
|
+
if (!fts.includes(f)) {
|
|
26
|
+
insertFeaturesPathIfNotExists(f);
|
|
27
|
+
fts.push(f);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if ("plugins" in data) {
|
|
32
|
+
const plugins = await buildPluginsPaths(data.plugins);
|
|
33
|
+
plugins.forEach((_pl) => {
|
|
34
|
+
allPaths.push(_pl.path);
|
|
35
|
+
insertPluginIfNotExists(_pl.name, _pl.path);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return allPaths;
|
|
39
|
+
}
|
|
40
|
+
export { confDir, dbPath, createConfDirIfNotExists, updateConf, };
|
package/dist/db/db.d.ts
CHANGED
package/dist/db/db.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import DatabaseConstructor from "better-sqlite3";
|
|
2
2
|
import { schemas } from "./schemas.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
let db = new DatabaseConstructor(dbPath);
|
|
3
|
+
import { dbPath } from "../conf.js";
|
|
4
|
+
let db;
|
|
6
5
|
function initDb(isVerbose = false) {
|
|
6
|
+
db = new DatabaseConstructor(dbPath);
|
|
7
7
|
schemas.forEach((s) => {
|
|
8
8
|
db.exec(s);
|
|
9
9
|
if (isVerbose) {
|
|
@@ -11,6 +11,4 @@ function initDb(isVerbose = false) {
|
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
export { db, initDb, dbPopulateDefaults, };
|
|
14
|
+
export { db, initDb, };
|
package/dist/index.js
CHANGED
|
@@ -3,13 +3,13 @@ import { argv } from 'process';
|
|
|
3
3
|
import { query } from "./cli.js";
|
|
4
4
|
import { initState, runMode } from './state/state.js';
|
|
5
5
|
import { initAgent } from './agent.js';
|
|
6
|
-
import {
|
|
6
|
+
import { initCliCmds, parseCmd } from './cmd/cmds.js';
|
|
7
7
|
async function main() {
|
|
8
8
|
if (argv.length == 2) {
|
|
9
9
|
runMode.value = "cli";
|
|
10
10
|
}
|
|
11
11
|
await initState();
|
|
12
|
-
await
|
|
12
|
+
await initCliCmds();
|
|
13
13
|
await initAgent(runMode.value);
|
|
14
14
|
switch (runMode.value) {
|
|
15
15
|
case "cli":
|
package/dist/main.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execute, run } from "./cmd/sys/execute.js";
|
|
2
2
|
import { executeJobCmd } from "./cmd/lib/execute_job.js";
|
|
3
3
|
import { writeToClipboard } from "./cmd/sys/clipboard.js";
|
|
4
|
-
import { pingCmd } from "./cmd/cmds.js";
|
|
4
|
+
import { pingCmd } from "./cmd/clicmds/cmds.js";
|
|
5
5
|
export { execute, run, pingCmd, executeJobCmd, writeToClipboard, };
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execute, run } from "./cmd/sys/execute.js";
|
|
2
2
|
import { executeJobCmd } from "./cmd/lib/execute_job.js";
|
|
3
3
|
import { writeToClipboard } from "./cmd/sys/clipboard.js";
|
|
4
|
-
import { pingCmd } from "./cmd/cmds.js";
|
|
4
|
+
import { pingCmd } from "./cmd/clicmds/cmds.js";
|
|
5
5
|
export { execute, run, pingCmd, executeJobCmd, writeToClipboard, };
|
package/dist/state/state.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { reactive, ref } from "@vue/reactivity";
|
|
2
2
|
import { createConfDirIfNotExists, confDir } from "../conf.js";
|
|
3
|
-
import { initDb
|
|
3
|
+
import { initDb } from "../db/db.js";
|
|
4
4
|
import { readFeaturePaths } from "../db/read.js";
|
|
5
5
|
import { updateFeatures } from "../db/write.js";
|
|
6
6
|
import { readFeaturesDirs } from "./features.js";
|
|
@@ -9,7 +9,7 @@ let pyShell;
|
|
|
9
9
|
const inputMode = ref("manual");
|
|
10
10
|
const outputMode = ref("txt");
|
|
11
11
|
const runMode = ref("cmd");
|
|
12
|
-
const formatMode = ref("
|
|
12
|
+
const formatMode = ref("text");
|
|
13
13
|
const promptfile = ref("");
|
|
14
14
|
const lastCmd = reactive({
|
|
15
15
|
name: "",
|
|
@@ -19,12 +19,8 @@ function initConf() {
|
|
|
19
19
|
const exists = createConfDirIfNotExists();
|
|
20
20
|
if (!exists) {
|
|
21
21
|
console.log("Created configuration directory", confDir);
|
|
22
|
-
initDb();
|
|
23
|
-
dbPopulateDefaults();
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
initDb();
|
|
27
22
|
}
|
|
23
|
+
initDb();
|
|
28
24
|
}
|
|
29
25
|
async function initFeatures() {
|
|
30
26
|
const fp = readFeaturePaths();
|
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.5",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"buildrl": "rm -rf dist/* && rollup -c",
|
|
8
8
|
"build": "rm -rf dist/* && tsc",
|
|
@@ -11,17 +11,17 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@agent-smith/brain": "^0.0.18",
|
|
14
|
-
"@agent-smith/jobs": "^0.0.
|
|
15
|
-
"@agent-smith/lmtask": "^0.0.
|
|
14
|
+
"@agent-smith/jobs": "^0.0.8",
|
|
15
|
+
"@agent-smith/lmtask": "^0.0.12",
|
|
16
16
|
"@inquirer/prompts": "^5.3.8",
|
|
17
17
|
"@inquirer/select": "^2.4.7",
|
|
18
18
|
"@vue/reactivity": "^3.4.38",
|
|
19
19
|
"better-sqlite3": "^11.2.1",
|
|
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.7.
|
|
24
|
+
"modprompt": "^0.7.7",
|
|
25
25
|
"python-shell": "^5.0.0",
|
|
26
26
|
"yaml": "^2.5.0"
|
|
27
27
|
},
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
34
34
|
"@types/better-sqlite3": "^7.6.11",
|
|
35
35
|
"@types/marked-terminal": "^6.1.1",
|
|
36
|
-
"@types/node": "^22.5.
|
|
36
|
+
"@types/node": "^22.5.1",
|
|
37
37
|
"rollup": "^4.21.1",
|
|
38
38
|
"ts-node": "^10.9.2",
|
|
39
39
|
"tslib": "2.7.0",
|
|
File without changes
|