@agent-smith/cli 0.0.4 → 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 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, clearOutput, marked, modelsForExpert, taskReader };
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
- import logUpdate from 'log-update';
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
- if (formatMode.value == "markdown") {
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, clearOutput, marked, modelsForExpert, taskReader };
38
+ export { brain, initAgent, marked, modelsForExpert, taskReader };
@@ -4,7 +4,7 @@ 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 { clearOutput, initAgent, marked, taskReader } from "../../agent.js";
7
+ import { initAgent, marked, taskReader } 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";
@@ -101,12 +101,12 @@ async function _executeTaskCmd(args = [], options) {
101
101
  if (!ok) {
102
102
  console.warn(error);
103
103
  }
104
- clearOutput();
105
104
  if (formatMode.value == "markdown") {
105
+ console.log("\n\n------------------\n");
106
106
  console.log(marked.parse(data).trim());
107
107
  }
108
108
  else {
109
- console.log(data);
109
+ console.log();
110
110
  }
111
111
  return data;
112
112
  }
@@ -43,13 +43,13 @@ const modes = {
43
43
  console.log("Markdown output mode");
44
44
  }
45
45
  },
46
- description: "use markdown output (default)"
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 "
@@ -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
- logUpdate("Ingesting prompt ...");
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}` };
@@ -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 {
@@ -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("markdown");
12
+ const formatMode = ref("text");
13
13
  const promptfile = ref("");
14
14
  const lastCmd = reactive({
15
15
  name: "",
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.4",
5
+ "version": "0.0.5",
6
6
  "scripts": {
7
7
  "buildrl": "rm -rf dist/* && rollup -c",
8
8
  "build": "rm -rf dist/* && tsc",
@@ -19,7 +19,7 @@
19
19
  "better-sqlite3": "^11.2.1",
20
20
  "clipboardy": "^4.0.0",
21
21
  "commander": "^12.1.0",
22
- "log-update": "^6.1.0",
22
+ "draftlog": "^1.0.13",
23
23
  "marked-terminal": "^7.1.0",
24
24
  "modprompt": "^0.7.7",
25
25
  "python-shell": "^5.0.0",