@agent-smith/cli 0.0.5 → 0.0.6
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 +3 -9
- package/dist/agent.js +3 -3
- package/dist/cmd/clicmds/cmds.js +8 -3
- package/dist/cmd/lib/execute_job.js +7 -2
- package/dist/cmd/lib/execute_task.js +7 -2
- package/dist/cmd/lib/utils.d.ts +6 -1
- package/dist/cmd/lib/utils.js +22 -1
- package/dist/index.js +0 -0
- package/package.json +4 -4
package/dist/agent.d.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
+
import { LmTaskBuilder } from "@agent-smith/lmtask";
|
|
1
2
|
import { marked } from 'marked';
|
|
2
3
|
import { RunMode } from "./interfaces.js";
|
|
3
4
|
declare let brain: import("@agent-smith/brain").AgentBrain;
|
|
4
5
|
declare const modelsForExpert: Record<string, string>;
|
|
5
|
-
declare const
|
|
6
|
-
init: (taskPath: string) => import("@agent-smith/jobs").AgentTask;
|
|
7
|
-
read: (taskPath: string) => {
|
|
8
|
-
found: boolean;
|
|
9
|
-
task: import("@agent-smith/lmtask").LmTask;
|
|
10
|
-
};
|
|
11
|
-
readDir: (dir: string) => Array<string>;
|
|
12
|
-
};
|
|
6
|
+
declare const taskBuilder: LmTaskBuilder;
|
|
13
7
|
declare function initAgent(mode: RunMode, isVerbose?: boolean): Promise<boolean>;
|
|
14
|
-
export { brain, initAgent, marked, modelsForExpert,
|
|
8
|
+
export { brain, initAgent, marked, modelsForExpert, taskBuilder };
|
package/dist/agent.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useAgentBrain } from "@agent-smith/brain";
|
|
2
|
-
import {
|
|
2
|
+
import { LmTaskBuilder } from "@agent-smith/lmtask";
|
|
3
3
|
;
|
|
4
4
|
import { marked } from 'marked';
|
|
5
5
|
import { markedTerminal } from 'marked-terminal';
|
|
6
6
|
marked.use(markedTerminal());
|
|
7
7
|
let brain = useAgentBrain();
|
|
8
8
|
const modelsForExpert = {};
|
|
9
|
-
const
|
|
9
|
+
const taskBuilder = new LmTaskBuilder(brain);
|
|
10
10
|
async function initExperts() {
|
|
11
11
|
brain.experts.forEach((ex) => {
|
|
12
12
|
ex.setOnStartEmit(() => console.log(""));
|
|
@@ -35,4 +35,4 @@ async function initAgent(mode, isVerbose = false) {
|
|
|
35
35
|
}
|
|
36
36
|
return brainUp;
|
|
37
37
|
}
|
|
38
|
-
export { brain, initAgent, marked, modelsForExpert,
|
|
38
|
+
export { brain, initAgent, marked, modelsForExpert, taskBuilder };
|
package/dist/cmd/clicmds/cmds.js
CHANGED
|
@@ -4,10 +4,11 @@ import { readFeatures } from "../../db/read.js";
|
|
|
4
4
|
import { updateFeatures } from "../../db/write.js";
|
|
5
5
|
import { updateConf } from "../../conf.js";
|
|
6
6
|
import { executeActionCmd } from "../lib/execute_action.js";
|
|
7
|
-
import { initAgent, marked,
|
|
7
|
+
import { initAgent, marked, taskBuilder } from "../../agent.js";
|
|
8
8
|
import { executeJobCmd, readJob } from "../lib/execute_job.js";
|
|
9
9
|
import { executeTaskCmd } from "../lib/execute_task.js";
|
|
10
10
|
import { readCmds } from "../sys/read_cmds.js";
|
|
11
|
+
import { readTask } from "../lib/utils.js";
|
|
11
12
|
let cmds = {
|
|
12
13
|
q: {
|
|
13
14
|
cmd: async () => process.exit(0),
|
|
@@ -129,8 +130,12 @@ async function _readTaskCmd(args = [], options) {
|
|
|
129
130
|
console.warn(`FeatureType ${args[0]} not found`);
|
|
130
131
|
return;
|
|
131
132
|
}
|
|
132
|
-
const
|
|
133
|
-
|
|
133
|
+
const res = readTask(path);
|
|
134
|
+
if (!res.found) {
|
|
135
|
+
throw new Error(`Task ${args[0]}, ${path} not found`);
|
|
136
|
+
}
|
|
137
|
+
const ts = taskBuilder.readFromYaml(path);
|
|
138
|
+
console.log(ts);
|
|
134
139
|
}
|
|
135
140
|
async function _listTasksCmd(args = [], options) {
|
|
136
141
|
Object.keys(readFeatures().task).forEach((t) => console.log("-", t));
|
|
@@ -1,9 +1,10 @@
|
|
|
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, marked,
|
|
4
|
+
import { brain, marked, taskBuilder } from '../../agent.js';
|
|
5
5
|
import { getFeatureSpec } from '../../state/features.js';
|
|
6
6
|
import { formatMode } from '../../state/state.js';
|
|
7
|
+
import { readTask } from './utils.js';
|
|
7
8
|
async function executeJobCmd(name, args = []) {
|
|
8
9
|
const { job, found } = await _dispatchReadJob(name);
|
|
9
10
|
if (!found) {
|
|
@@ -76,7 +77,11 @@ async function _createJobFromSpec(spec) {
|
|
|
76
77
|
if (!found) {
|
|
77
78
|
return { found: false, job: {} };
|
|
78
79
|
}
|
|
79
|
-
const
|
|
80
|
+
const res = readTask(path);
|
|
81
|
+
if (!res.found) {
|
|
82
|
+
throw new Error(`Task ${t.name}, ${path} not found`);
|
|
83
|
+
}
|
|
84
|
+
const at = taskBuilder.fromYaml(res.ymlTask);
|
|
80
85
|
tasks[t.name] = at;
|
|
81
86
|
}
|
|
82
87
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { initAgent,
|
|
1
|
+
import { initAgent, taskBuilder } from "../../agent.js";
|
|
2
2
|
import { getFeatureSpec } from "../../state/features.js";
|
|
3
3
|
import { runMode } from "../../state/state.js";
|
|
4
|
+
import { readTask } from "./utils.js";
|
|
4
5
|
async function executeTaskCmd(args = [], options = {}) {
|
|
5
6
|
await initAgent(runMode.value);
|
|
6
7
|
const name = args.shift();
|
|
@@ -8,7 +9,11 @@ async function executeTaskCmd(args = [], options = {}) {
|
|
|
8
9
|
if (!found) {
|
|
9
10
|
return { ok: false, data: {}, error: `Task ${name} not found` };
|
|
10
11
|
}
|
|
11
|
-
const
|
|
12
|
+
const res = readTask(path);
|
|
13
|
+
if (!res.found) {
|
|
14
|
+
throw new Error(`Task ${name}, ${path} not found`);
|
|
15
|
+
}
|
|
16
|
+
const task = taskBuilder.fromYaml(res.ymlTask);
|
|
12
17
|
const pr = args.shift();
|
|
13
18
|
const vars = {};
|
|
14
19
|
args.forEach((a) => {
|
package/dist/cmd/lib/utils.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
declare function setOptions(options: Record<string, any>, args?: Array<string>): Promise<Array<string>>;
|
|
2
2
|
declare function readPromptFile(): string;
|
|
3
3
|
declare function processOutput(res: any): Promise<void>;
|
|
4
|
-
|
|
4
|
+
declare function readTask(taskpath: string): {
|
|
5
|
+
found: boolean;
|
|
6
|
+
ymlTask: string;
|
|
7
|
+
};
|
|
8
|
+
declare function readTasksDir(dir: string): Array<string>;
|
|
9
|
+
export { readPromptFile, processOutput, setOptions, readTask, readTasksDir, };
|
package/dist/cmd/lib/utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as fs } from "fs";
|
|
2
|
+
import { default as path } from "path";
|
|
2
3
|
import { outputMode, promptfile } from "../../state/state.js";
|
|
3
4
|
import { inputMode, runMode } from "../../state/state.js";
|
|
4
5
|
import { readClipboard, writeToClipboard } from "../sys/clipboard.js";
|
|
@@ -49,4 +50,24 @@ async function processOutput(res) {
|
|
|
49
50
|
await writeToClipboard(data);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
+
function readTask(taskpath) {
|
|
54
|
+
if (!fs.existsSync(taskpath)) {
|
|
55
|
+
return { ymlTask: "", found: false };
|
|
56
|
+
}
|
|
57
|
+
const data = fs.readFileSync(taskpath, 'utf8');
|
|
58
|
+
return { ymlTask: data, found: true };
|
|
59
|
+
}
|
|
60
|
+
function readTasksDir(dir) {
|
|
61
|
+
const tasks = new Array();
|
|
62
|
+
fs.readdirSync(dir).forEach((filename) => {
|
|
63
|
+
const filepath = path.join(dir, filename);
|
|
64
|
+
const isDir = fs.statSync(filepath).isDirectory();
|
|
65
|
+
if (!isDir) {
|
|
66
|
+
if (filename.endsWith(".yml")) {
|
|
67
|
+
tasks.push(filename);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return tasks;
|
|
72
|
+
}
|
|
73
|
+
export { readPromptFile, processOutput, setOptions, readTask, readTasksDir, };
|
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.6",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"buildrl": "rm -rf dist/* && rollup -c",
|
|
8
8
|
"build": "rm -rf dist/* && tsc",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@agent-smith/brain": "^0.0.18",
|
|
14
14
|
"@agent-smith/jobs": "^0.0.8",
|
|
15
|
-
"@agent-smith/lmtask": "^0.0.
|
|
15
|
+
"@agent-smith/lmtask": "^0.0.13",
|
|
16
16
|
"@inquirer/prompts": "^5.3.8",
|
|
17
17
|
"@inquirer/select": "^2.4.7",
|
|
18
18
|
"@vue/reactivity": "^3.4.38",
|
|
@@ -33,8 +33,8 @@
|
|
|
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.
|
|
37
|
-
"rollup": "^4.21.
|
|
36
|
+
"@types/node": "^22.5.2",
|
|
37
|
+
"rollup": "^4.21.2",
|
|
38
38
|
"ts-node": "^10.9.2",
|
|
39
39
|
"tslib": "2.7.0",
|
|
40
40
|
"typescript": "^5.5.4"
|