@agent-smith/cli 0.0.105 → 0.0.107

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.
@@ -3,7 +3,7 @@ import { listBackends, setBackend } from "../../state/backends.js";
3
3
  import { parseCommandArgs } from "../lib/options_parsers.js";
4
4
  import { processTaskCmd, processTasksCmd, resetDbCmd, updateFeaturesCmd } from "./cmds.js";
5
5
  import { updateConfCmd } from "./updateconf.js";
6
- import { inferenceOptions } from "../options.js";
6
+ import { displayOptions, inferenceOptions } from "../options.js";
7
7
  function initBaseCommands(program) {
8
8
  program.command("exit")
9
9
  .description("exit the cli")
@@ -34,11 +34,13 @@ function initBaseCommands(program) {
34
34
  .action(async (...args) => {
35
35
  await listBackends();
36
36
  });
37
- program.command("update")
37
+ const updateCmd = program.command("update")
38
38
  .description("update the available features: run this after adding a new feature")
39
39
  .action(async (...args) => {
40
- await updateFeaturesCmd();
40
+ const ca = parseCommandArgs(args);
41
+ await updateFeaturesCmd(ca.options);
41
42
  });
43
+ displayOptions.forEach(o => updateCmd.addOption(o));
42
44
  program.command("conf <path>")
43
45
  .description("process config file")
44
46
  .action(async (...args) => {
@@ -2,7 +2,7 @@ import { Command } from 'commander';
2
2
  import { FeatureSpec } from '../../interfaces.js';
3
3
  declare function initUserCmds(cmdFeats: Record<string, FeatureSpec>): Promise<Array<Command>>;
4
4
  declare function resetDbCmd(): Promise<any>;
5
- declare function updateFeaturesCmd(): Promise<any>;
5
+ declare function updateFeaturesCmd(options: Record<string, any>): Promise<any>;
6
6
  declare function processTasksCmd(args: Array<string>, options: Record<string, any>): Promise<void>;
7
7
  declare function processTaskCmd(args: Array<string>, options: Record<string, any>): Promise<any>;
8
8
  export { initUserCmds, processTaskCmd, processTasksCmd, resetDbCmd, updateFeaturesCmd };
@@ -1,10 +1,9 @@
1
1
  import colors from "ansi-colors";
2
2
  import path from "path";
3
3
  import YAML from 'yaml';
4
- import { cacheFilePath, dbPath } from "../../conf.js";
4
+ import { dbPath } from "../../conf.js";
5
5
  import { readFeaturePaths, readFeaturesType, readTaskSetting } from "../../db/read.js";
6
6
  import { cleanupFeaturePaths, deleteTaskSetting, updateAliases, updateFeatures, upsertTaskSettings } from "../../db/write.js";
7
- import { isCacheReady, cmds } from "../../state/auto/usercmds.js";
8
7
  import { getFeatureSpec, readFeaturesDirs } from "../../state/features.js";
9
8
  import { readPluginsPaths } from "../../state/plugins.js";
10
9
  import { runMode } from "../../state/state.js";
@@ -12,21 +11,17 @@ import { initTaskSettings, isTaskSettingsInitialized, tasksSettings } from '../.
12
11
  import { deleteFileIfExists } from "../sys/delete_file.js";
13
12
  import { readCmd } from "../sys/read_cmds.js";
14
13
  import { readTask } from "../sys/read_task.js";
15
- import { updateUserCmdsCache } from './cache.js';
16
14
  async function initUserCmds(cmdFeats) {
17
15
  const features = Object.values(cmdFeats);
18
- let endCmds = cmds;
19
- if (!isCacheReady) {
20
- updateUserCmdsCache(cacheFilePath, features);
21
- const usrCmds = [];
22
- for (const feat of features) {
23
- const cmdPath = path.join(feat.path, feat.name + "." + feat.ext);
24
- const c = await readCmd(feat.name, cmdPath);
16
+ const usrCmds = [];
17
+ for (const feat of features) {
18
+ const cmdPath = path.join(feat.path, feat.name + "." + feat.ext);
19
+ const c = await readCmd(feat.name, cmdPath);
20
+ if (c) {
25
21
  usrCmds.push(c);
26
22
  }
27
- endCmds = usrCmds;
28
23
  }
29
- return endCmds;
24
+ return usrCmds;
30
25
  }
31
26
  async function resetDbCmd() {
32
27
  if (runMode.value == "cli") {
@@ -36,18 +31,17 @@ async function resetDbCmd() {
36
31
  deleteFileIfExists(dbPath);
37
32
  console.log("Config database reset ok. Run the conf command to recreate it");
38
33
  }
39
- async function updateFeaturesCmd() {
34
+ async function updateFeaturesCmd(options) {
40
35
  const fp = readFeaturePaths();
41
36
  const pp = await readPluginsPaths();
42
37
  const paths = [...fp, ...pp];
43
- const feats = readFeaturesDirs(paths);
38
+ const feats = readFeaturesDirs(paths, options?.debug ?? false);
44
39
  updateFeatures(feats);
45
40
  updateAliases(feats);
46
41
  const deleted = cleanupFeaturePaths(paths);
47
42
  for (const el of deleted) {
48
43
  console.log("- [feature path]", el);
49
44
  }
50
- updateUserCmdsCache(cacheFilePath, feats.cmd);
51
45
  }
52
46
  async function processTasksCmd(args, options) {
53
47
  if (options?.conf) {
@@ -1,11 +1,10 @@
1
- import { cacheFilePath, processConfPath } from "../../conf.js";
1
+ import { processConfPath } from "../../conf.js";
2
2
  import { initDb } from "../../db/db.js";
3
3
  import { readFilePath } from "../../db/read.js";
4
4
  import { cleanupFeaturePaths, updateAliases, updateDataDirPath, updateFeatures, updatePromptfilePath, upsertFilePath } from "../../db/write.js";
5
5
  import { readFeaturesDirs } from "../../state/features.js";
6
6
  import { dataDirPath, promptfilePath } from "../../state/state.js";
7
7
  import { runtimeDataError, runtimeInfo } from '../lib/user_msgs.js';
8
- import { updateUserCmdsCache } from "./cache.js";
9
8
  async function updateConfCmd(args) {
10
9
  initDb(false, true);
11
10
  const { found, path } = readFilePath("conf");
@@ -34,13 +33,12 @@ async function updateConfCmd(args) {
34
33
  updateDataDirPath(dd);
35
34
  dataDirPath.value = dd;
36
35
  }
37
- const feats = readFeaturesDirs(paths);
36
+ const feats = readFeaturesDirs(paths, true);
38
37
  updateFeatures(feats);
39
38
  updateAliases(feats);
40
39
  const deleted = cleanupFeaturePaths(paths);
41
40
  for (const el of deleted) {
42
41
  console.log("- [feature path]", el);
43
42
  }
44
- updateUserCmdsCache(cacheFilePath, feats.cmd);
45
43
  }
46
44
  export { updateConfCmd, };
@@ -9,8 +9,15 @@ import { readClipboard } from "../../sys/clipboard.js";
9
9
  import { processOutput, readPromptFile } from "../utils.js";
10
10
  import { parseCommandArgs } from "../options_parsers.js";
11
11
  import { pathToFileURL } from 'url';
12
+ import { getInputFromOptions } from '../tasks/utils.js';
12
13
  async function executeAction(name, payload, options, quiet = false) {
13
14
  let run;
15
+ const inputData = await getInputFromOptions(options);
16
+ if (inputData) {
17
+ if (Array.isArray(payload)) {
18
+ payload.push(inputData);
19
+ }
20
+ }
14
21
  const { found, path, ext } = getFeatureSpec(name, "action");
15
22
  if (!found) {
16
23
  throw new Error(`Action ${name} not found at ${path}`);
@@ -117,6 +124,7 @@ function pythonAction(path) {
117
124
  final = JSON.parse(txt);
118
125
  }
119
126
  catch (e) {
127
+ console.warn("Can not parse json from python action", path, e);
120
128
  }
121
129
  }
122
130
  return final;
@@ -1,11 +1,18 @@
1
1
  import { getFeatureSpec } from "../../../state/features.js";
2
2
  import { createJsAction } from "../actions/read.js";
3
3
  import { pathToFileURL } from 'url';
4
+ import { getInputFromOptions } from "../tasks/utils.js";
4
5
  async function executeAdaptater(name, params, options) {
5
6
  const { found, path } = getFeatureSpec(name, "adaptater");
6
7
  if (!found) {
7
8
  throw new Error(`adaptater ${name} not found`);
8
9
  }
10
+ const inputData = await getInputFromOptions(options);
11
+ if (inputData) {
12
+ if (Array.isArray(params)) {
13
+ params.push(inputData);
14
+ }
15
+ }
9
16
  let run;
10
17
  const url = pathToFileURL(path).href;
11
18
  const jsa = await import(url);
@@ -1,6 +1,6 @@
1
1
  import { compile, serializeGrammar } from "@intrinsicai/gbnfgen";
2
2
  import { default as color, default as colors } from "ansi-colors";
3
- import { PromptTemplate } from "modprompt";
3
+ import { PromptTemplate, templates } from "modprompt";
4
4
  import ora from 'ora';
5
5
  import { usePerfTimer } from "../../../main.js";
6
6
  import { backend, backends, listBackends } from "../../../state/backends.js";
@@ -92,7 +92,12 @@ async function executeTask(name, payload, options) {
92
92
  let hasThink = false;
93
93
  let tpl = null;
94
94
  if (useTemplates) {
95
- tpl = new PromptTemplate(model.template ?? "none");
95
+ try {
96
+ tpl = new PromptTemplate(model.template ?? "none");
97
+ }
98
+ catch (e) {
99
+ throw new Error(`Can not load template ${model.template}\nAvailable templates: ${Object.keys(templates)}\n`);
100
+ }
96
101
  hasThink = tpl.tags?.think ? true : false;
97
102
  }
98
103
  if (options?.debug) {
@@ -110,7 +115,6 @@ async function executeTask(name, payload, options) {
110
115
  else {
111
116
  process.stdout.write(t);
112
117
  }
113
- ++emittedTokens;
114
118
  };
115
119
  let hasTools = false;
116
120
  if (task.def?.tools) {
@@ -176,7 +180,11 @@ async function executeTask(name, payload, options) {
176
180
  return;
177
181
  }
178
182
  }
179
- printToken(t);
183
+ if (!options?.quiet) {
184
+ if (!options?.isToolCall || (options?.debug || options.verbose)) {
185
+ printToken(t);
186
+ }
187
+ }
180
188
  }
181
189
  ++emittedTokens;
182
190
  };
@@ -224,7 +232,11 @@ async function executeTask(name, payload, options) {
224
232
  return;
225
233
  }
226
234
  else if (errMsg.includes("404 Not Found")) {
227
- runtimeError("The server answered with a 404 Not Found error. That usually mean that the model you are requesting does not exist on the server.");
235
+ runtimeError("The server answered with a 404 Not Found error. That might mean that the model you are requesting does not exist on the server.");
236
+ return;
237
+ }
238
+ else if (errMsg.includes("400 Bad Request")) {
239
+ runtimeError("The server answered with a 400 Bad Request error. That might mean that the model you are requesting does not exist on the server or a parameter is missing in your request.");
228
240
  return;
229
241
  }
230
242
  else if (errMsg.includes("fetch failed")) {
@@ -241,7 +253,7 @@ async function executeTask(name, payload, options) {
241
253
  }
242
254
  }
243
255
  if (!isChatMode.value || options?.isToolCall) {
244
- if (options?.debug) {
256
+ if (options?.debug && mcpServers.length > 0) {
245
257
  console.log("Closing", mcpServers.length, "mcp server(s)");
246
258
  }
247
259
  mcpServers.forEach((s) => {
@@ -123,13 +123,16 @@ async function readTask(name, payload, options, agent) {
123
123
  options.isToolCall = true;
124
124
  options.isAgent = true;
125
125
  const agres = await executeTask(toolName, params, options);
126
+ options.isAgent = false;
126
127
  options.isToolCall = false;
127
128
  if (agres?.answer?.text) {
128
129
  return agres.answer.text;
129
130
  }
130
131
  return agres;
131
132
  case "workflow":
133
+ options.isToolCall = true;
132
134
  const wres = await executeWorkflow(toolName, params, options);
135
+ options.isToolCall = false;
133
136
  return wres;
134
137
  default:
135
138
  throw new Error(`unknown tool execution function type: ${type} for ${toolName}`);
@@ -3,5 +3,6 @@ declare function openTaskSpec(name: string, isAgent?: boolean): {
3
3
  taskFileSpec: LmTaskFileSpec;
4
4
  taskPath: string;
5
5
  };
6
+ declare function getInputFromOptions(options: Record<string, any>): Promise<string | null>;
6
7
  declare function getTaskPrompt(name: string, args: Array<string>, options: Record<string, any>): Promise<string>;
7
- export { getTaskPrompt, openTaskSpec };
8
+ export { getTaskPrompt, getInputFromOptions, openTaskSpec, };
@@ -18,23 +18,31 @@ function openTaskSpec(name, isAgent = false) {
18
18
  taskFileSpec.name = name;
19
19
  return { taskFileSpec: taskFileSpec, taskPath: path };
20
20
  }
21
- async function getTaskPrompt(name, args, options) {
22
- let pr;
21
+ async function getInputFromOptions(options) {
22
+ let out = null;
23
23
  if (options?.clipboardInput === true) {
24
- pr = await readClipboard();
24
+ out = await readClipboard();
25
+ options.clipboardInput = false;
25
26
  }
26
27
  else if (options?.inputFile === true) {
27
- pr = readPromptFile();
28
+ out = readPromptFile();
29
+ options.inputFile = false;
30
+ }
31
+ return out;
32
+ }
33
+ async function getTaskPrompt(name, args, options) {
34
+ const ic = await getInputFromOptions(options);
35
+ if (ic) {
36
+ return ic;
37
+ }
38
+ let pr;
39
+ if (args[0] !== undefined) {
40
+ pr = args[0];
28
41
  }
29
42
  else {
30
- if (args[0] !== undefined) {
31
- pr = args[0];
32
- }
33
- else {
34
- runtimeDataError("task", name, "provide a prompt or use input options");
35
- throw new Error();
36
- }
43
+ runtimeDataError(options?.isAgent ? "agent" : "task", name, "provide a prompt or use input options");
44
+ throw new Error();
37
45
  }
38
46
  return pr;
39
47
  }
40
- export { getTaskPrompt, openTaskSpec };
48
+ export { getTaskPrompt, getInputFromOptions, openTaskSpec, };
@@ -1,3 +1,3 @@
1
1
  declare function executeWorkflow(wname: string, args: any, options?: Record<string, any>): Promise<any>;
2
2
  declare function executeWorkflowCmd(name: string, wargs: Array<any>): Promise<any>;
3
- export { executeWorkflow, executeWorkflowCmd, };
3
+ export { executeWorkflow, executeWorkflowCmd };
@@ -1,13 +1,13 @@
1
+ import colors from "ansi-colors";
2
+ import { pathToFileURL } from "node:url";
3
+ import { getFeatureSpec } from "../../../state/features.js";
1
4
  import { executeAction } from "../actions/cmd.js";
2
5
  import { executeAdaptater } from "../adaptaters/cmd.js";
3
6
  import { parseCommandArgs } from "../options_parsers.js";
4
7
  import { executeTask } from "../tasks/cmd.js";
5
- import { getTaskPrompt } from "../tasks/utils.js";
6
- import { readWorkflow } from "./read.js";
7
- import colors from "ansi-colors";
8
- import { getFeatureSpec } from "../../../state/features.js";
9
- import { pathToFileURL } from "node:url";
8
+ import { getInputFromOptions, getTaskPrompt } from "../tasks/utils.js";
10
9
  import { runtimeError } from "../user_msgs.js";
10
+ import { readWorkflow } from "./read.js";
11
11
  async function executeWorkflow(wname, args, options = {}) {
12
12
  const { workflow, found } = await readWorkflow(wname);
13
13
  if (!found) {
@@ -39,11 +39,19 @@ async function executeWorkflow(wname, args, options = {}) {
39
39
  if (prevStepType == "task") {
40
40
  tdata.prompt = taskRes.answer.text;
41
41
  }
42
+ else if (prevStepType == "action") {
43
+ if (taskRes?.args) {
44
+ if (typeof taskRes.args == "string") {
45
+ tdata.prompt = taskRes.args;
46
+ }
47
+ }
48
+ }
42
49
  }
43
50
  }
44
51
  if (!tdata?.prompt) {
45
52
  throw new Error(`Workflow ${wname} step ${i + 1}: provide a prompt for the task ${step.name}`);
46
53
  }
54
+ options.isAgent = false;
47
55
  const tr = await executeTask(step.name, tdata, options);
48
56
  taskRes = { ...tr, ...taskRes };
49
57
  }
@@ -62,6 +70,13 @@ async function executeWorkflow(wname, args, options = {}) {
62
70
  if (prevStepType == "task") {
63
71
  tdata.prompt = taskRes.answer.text;
64
72
  }
73
+ else if (prevStepType == "action") {
74
+ if (taskRes?.args) {
75
+ if (typeof taskRes.args == "string") {
76
+ tdata.prompt = taskRes.args;
77
+ }
78
+ }
79
+ }
65
80
  }
66
81
  }
67
82
  if (!tdata?.prompt) {
@@ -78,17 +93,28 @@ async function executeWorkflow(wname, args, options = {}) {
78
93
  break;
79
94
  case "action":
80
95
  try {
81
- const actArgs = i == 0 ? taskRes.cmdArgs : taskRes;
96
+ let actArgs;
97
+ if (i == 0) {
98
+ actArgs = taskRes.cmdArgs;
99
+ const inputData = await getInputFromOptions(options);
100
+ if (inputData) {
101
+ actArgs.push(inputData);
102
+ }
103
+ }
104
+ else {
105
+ actArgs = taskRes;
106
+ }
82
107
  const ares = await executeAction(step.name, actArgs, options, true);
108
+ if (i == finalTaskIndex && !options?.isToolCall && !options?.quiet) {
109
+ console.log(ares);
110
+ break;
111
+ }
83
112
  if (typeof ares == "string" || Array.isArray(ares)) {
84
113
  taskRes.args = ares;
85
114
  }
86
115
  else {
87
116
  taskRes = { ...ares, ...taskRes };
88
117
  }
89
- if (i == finalTaskIndex) {
90
- console.log(taskRes);
91
- }
92
118
  }
93
119
  catch (e) {
94
120
  throw new Error(`workflow action ${i + 1}: ${e}`);
@@ -96,17 +122,28 @@ async function executeWorkflow(wname, args, options = {}) {
96
122
  break;
97
123
  case "adaptater":
98
124
  try {
99
- const actArgs = i == 0 ? taskRes.cmdArgs : taskRes;
125
+ let actArgs;
126
+ if (i == 0) {
127
+ actArgs = taskRes.cmdArgs;
128
+ const inputData = await getInputFromOptions(options);
129
+ if (inputData) {
130
+ actArgs.push(inputData);
131
+ }
132
+ }
133
+ else {
134
+ actArgs = taskRes;
135
+ }
100
136
  const adres = await executeAdaptater(step.name, actArgs, options);
137
+ if (i == finalTaskIndex && !options?.isToolCall && !options?.quiet) {
138
+ console.log(adres);
139
+ break;
140
+ }
101
141
  if (typeof adres == "string" || Array.isArray(adres)) {
102
142
  taskRes.args = adres;
103
143
  }
104
144
  else {
105
145
  taskRes = { ...adres };
106
146
  }
107
- if (i == finalTaskIndex) {
108
- console.log(taskRes);
109
- }
110
147
  }
111
148
  catch (e) {
112
149
  throw new Error(`workflow adaptater ${i + 1}: ${e}`);
@@ -124,7 +161,18 @@ async function executeWorkflow(wname, args, options = {}) {
124
161
  runtimeError(`workflow ${wname}: can not import the runCmd function from step ${i} for command ${step.name}: please add a runCmd function export`);
125
162
  return;
126
163
  }
127
- const cres = await jsa.runCmd(args, options);
164
+ let cArgs;
165
+ if (i == 0) {
166
+ cArgs = taskRes.cmdArgs;
167
+ const inputData = await getInputFromOptions(options);
168
+ if (inputData) {
169
+ cArgs.push(inputData);
170
+ }
171
+ }
172
+ else {
173
+ cArgs = taskRes;
174
+ }
175
+ const cres = await jsa.runCmd(cArgs, options);
128
176
  if (typeof cres == "string" || Array.isArray(cres)) {
129
177
  taskRes.args = cres;
130
178
  }
@@ -148,4 +196,4 @@ async function executeWorkflowCmd(name, wargs) {
148
196
  const { args, options } = parseCommandArgs(wargs);
149
197
  return await executeWorkflow(name, args, options);
150
198
  }
151
- export { executeWorkflow, executeWorkflowCmd, };
199
+ export { executeWorkflow, executeWorkflowCmd };
@@ -1,3 +1,3 @@
1
1
  import { Command } from "commander";
2
- declare function readCmd(name: string, cmdPath: string): Promise<Command>;
2
+ declare function readCmd(name: string, cmdPath: string): Promise<Command | null>;
3
3
  export { readCmd };
@@ -1,12 +1,19 @@
1
1
  import { pathToFileURL } from 'url';
2
+ import { runtimeWarning } from "../lib/user_msgs.js";
2
3
  async function readCmd(name, cmdPath) {
3
- const cmds = new Array();
4
4
  const url = pathToFileURL(cmdPath).href;
5
- const { cmd } = await import(url);
6
- if (!cmd) {
7
- throw new Error(`command ${name} not found at ${cmdPath}`);
5
+ let _cmd = null;
6
+ try {
7
+ const mod = await import(url);
8
+ _cmd = mod.cmd;
8
9
  }
9
- cmds.push(cmd);
10
- return cmd;
10
+ catch (e) {
11
+ runtimeWarning(`command ${name} not found at ${cmdPath}, ${e}`);
12
+ return null;
13
+ }
14
+ if (!_cmd) {
15
+ throw new Error("no cmd");
16
+ }
17
+ return _cmd;
11
18
  }
12
19
  export { readCmd };
package/dist/db/db.js CHANGED
@@ -16,7 +16,7 @@ function initDb(isVerbose, execSchema) {
16
16
  });
17
17
  }
18
18
  else {
19
- db = new DatabaseConstructor(dbPath);
19
+ db = new DatabaseConstructor(dbPath, { fileMustExist: true });
20
20
  }
21
21
  }
22
22
  export { db, initDb, };
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { argv } from 'process';
3
3
  import { query } from "./cli.js";
4
+ import { resetDbCmd } from './cmd/clicmds/cmds.js';
5
+ import { updateConfCmd } from './cmd/clicmds/updateconf.js';
4
6
  import { buildCmds, parseCmd } from './cmd/cmds.js';
5
7
  import { formatMode, init, inputMode, isChatMode, outputMode, runMode } from './state/state.js';
6
- import { updateConfCmd } from './cmd/clicmds/updateconf.js';
7
- import { resetDbCmd } from './cmd/clicmds/cmds.js';
8
8
  async function main() {
9
9
  const nargs = argv.length;
10
10
  if (nargs == 2) {
@@ -1,12 +1,3 @@
1
- import { cmd as c1 } from "file:///home/ggg/lm/features/dist/cmds/testcmd.js";
2
- import { cmd as c2 } from "file:///home/ggg/dev/js/agent-smith-plugins/system/fs/dist/cmds/lsdir.js";
3
- import { cmd as c3 } from "file:///home/ggg/dev/js/agent-smith-plugins/code/git/dist/cmds/commit.js";
4
- import { cmd as c4 } from "file:///home/ggg/dev/js/agent-smith-plugins/code/git/dist/cmds/commita.js";
5
- import { cmd as c5 } from "file:///home/ggg/dev/js/agent-smith-plugins/vision/dist/cmds/imgs2base64.js";
6
- import { cmd as c6 } from "file:///home/ggg/dev/js/snowind-astro/features/cmds/design-component.js";
7
- import { cmd as c7 } from "file:///home/ggg/dev/js/docdundee/package/features/dist/cmds/tsdoccmd.js";
8
-
9
- const cmds = [ c1, c2, c3, c4, c5, c6, c7 ];
10
- const isCacheReady = true;
11
-
12
- export { isCacheReady, cmds }
1
+ const cmds = new Array();
2
+ const isCacheReady = false;
3
+ export { cmds, isCacheReady, };
@@ -1,5 +1,5 @@
1
1
  import { FeatureExtension, FeatureType, Features } from "../interfaces.js";
2
- declare function readFeaturesDirs(featuresPaths: Array<string>): Features;
2
+ declare function readFeaturesDirs(featuresPaths: Array<string>, isverbose?: boolean): Features;
3
3
  declare function getFeatureSpec(name: string, type: FeatureType): {
4
4
  found: boolean;
5
5
  path: string;
@@ -1,7 +1,7 @@
1
1
  import { default as path } from "path";
2
2
  import { readFeaturesDir } from "../cmd/sys/read_features.js";
3
3
  import { readFeature } from "../db/read.js";
4
- function readFeaturesDirs(featuresPaths) {
4
+ function readFeaturesDirs(featuresPaths, isverbose = false) {
5
5
  const feats = {
6
6
  task: [],
7
7
  action: [],
@@ -11,6 +11,9 @@ function readFeaturesDirs(featuresPaths) {
11
11
  agent: [],
12
12
  };
13
13
  featuresPaths.forEach((dir) => {
14
+ if (isverbose) {
15
+ console.log("Reading feats in", dir);
16
+ }
14
17
  const _f = readFeaturesDir(dir);
15
18
  _f.agent.forEach((item) => feats.agent.push(item));
16
19
  _f.task.forEach((item) => feats.task.push(item));
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.105",
5
+ "version": "0.0.107",
6
6
  "scripts": {
7
7
  "buildrl": "rm -rf dist/* && rollup -c",
8
8
  "build": "rm -rf dist/* && tsc",
@@ -10,21 +10,22 @@
10
10
  "watch": "tsc --noCheck -p . -w"
11
11
  },
12
12
  "dependencies": {
13
- "@agent-smith/agent": "^0.2.1",
14
- "@agent-smith/task": "^0.2.1",
15
- "@agent-smith/nodetask": "^0.1.0",
13
+ "@agent-smith/agent": "^0.2.2",
14
+ "@agent-smith/nodetask": "^0.1.1",
15
+ "@agent-smith/task": "^0.2.3",
16
16
  "@agent-smith/tfm": "^0.2.0",
17
17
  "@inquirer/prompts": "^8.2.0",
18
18
  "@intrinsicai/gbnfgen": "0.12.0",
19
19
  "@locallm/api": "^0.7.3",
20
- "@modelcontextprotocol/sdk": "^1.25.2",
21
- "@vue/reactivity": "^3.5.26",
20
+ "@modelcontextprotocol/sdk": "^1.25.3",
21
+ "@vue/reactivity": "^3.5.27",
22
22
  "ansi-colors": "^4.1.3",
23
- "better-sqlite3": "^12.6.0",
24
- "clipboardy": "^5.0.2",
23
+ "better-sqlite3": "^12.6.2",
24
+ "clipboardy": "^5.1.0",
25
25
  "commander": "^14.0.2",
26
26
  "marked-terminal": "^7.3.0",
27
- "ora": "^9.0.0",
27
+ "modprompt": "0.13.1",
28
+ "ora": "^9.1.0",
28
29
  "python-shell": "^5.0.0",
29
30
  "yaml": "^2.8.2"
30
31
  },
@@ -36,11 +37,10 @@
36
37
  "@rollup/plugin-typescript": "^12.3.0",
37
38
  "@types/better-sqlite3": "^7.6.13",
38
39
  "@types/marked-terminal": "^6.1.1",
39
- "@types/node": "^25.0.8",
40
+ "@types/node": "^25.0.10",
40
41
  "openai": "^6.16.0",
41
42
  "restmix": "^0.6.1",
42
- "rollup": "^4.55.1",
43
- "ts-node": "^10.9.2",
43
+ "rollup": "^4.56.0",
44
44
  "tslib": "2.8.1",
45
45
  "typescript": "^5.9.3"
46
46
  },
@@ -1,4 +0,0 @@
1
- import { FeatureSpec } from '../../interfaces.js';
2
- declare function ensureUserCmdsCacheFileExists(cacheFilePath: string): string;
3
- declare function updateUserCmdsCache(cacheFilePath: string, cmdFeats: Array<FeatureSpec>): void;
4
- export { ensureUserCmdsCacheFileExists, updateUserCmdsCache, };
@@ -1,39 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { runtimeError } from '../../utils/user_msgs.js';
4
- function createCacheFileContent(cmdFeats) {
5
- const imports = new Array();
6
- const cmdNames = new Array();
7
- let i = 1;
8
- cmdFeats.forEach(feat => {
9
- const fileName = feat.name + "." + feat.ext;
10
- const importPath = path.join(feat.path, fileName);
11
- const cmdId = `c${i}`;
12
- const line = `import { cmd as ${cmdId} } from "file://${importPath}";`;
13
- imports.push(line);
14
- cmdNames.push(cmdId);
15
- ++i;
16
- });
17
- const finalImports = imports.join("\n");
18
- const cmds = `const cmds = [ ${cmdNames.join(", ")} ];\nconst isCacheReady = true;`;
19
- const end = "export { isCacheReady, cmds }";
20
- return `${finalImports}\n\n${cmds}\n\n${end}`;
21
- }
22
- function ensureUserCmdsCacheFileExists(cacheFilePath) {
23
- const fileExists = fs.existsSync(cacheFilePath);
24
- if (!fileExists) {
25
- fs.writeFileSync(cacheFilePath, "const cmds = [];\nexport { cmds }");
26
- }
27
- return cacheFilePath;
28
- }
29
- function updateUserCmdsCache(cacheFilePath, cmdFeats) {
30
- const filePath = ensureUserCmdsCacheFileExists(cacheFilePath);
31
- const cacheFileContent = createCacheFileContent(cmdFeats);
32
- try {
33
- fs.writeFileSync(filePath, cacheFileContent);
34
- }
35
- catch (err) {
36
- runtimeError("Error writing to user commands cache file at " + filePath, `${err}`);
37
- }
38
- }
39
- export { ensureUserCmdsCacheFileExists, updateUserCmdsCache, };