@agent-smith/cli 0.0.86 → 0.0.88

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.
@@ -1,15 +1,6 @@
1
1
  import clipboard from 'clipboardy';
2
- import { execute } from "./execute.js";
3
- const { platform } = process;
4
2
  async function readClipboard() {
5
- let res = "";
6
- if (platform == "linux") {
7
- res = await execute("xclip", ["-o", "-selection", "primary"]);
8
- }
9
- else {
10
- res = await clipboard.read();
11
- }
12
- return res;
3
+ return await clipboard.read();
13
4
  }
14
5
  async function writeToClipboard(data) {
15
6
  await clipboard.write(data);
@@ -1,11 +1,13 @@
1
1
  import { spawn } from "child_process";
2
+ import { platform } from "os";
2
3
  async function execute(command, args = [], { onStdout = (data) => { }, onStderr = (data) => { }, onError = (data) => { }, stream = false, } = {
3
4
  onStderr: (data) => console.log("stderr:", data),
4
5
  onError: (err) => { if (err)
5
6
  throw err; },
6
7
  }) {
7
8
  let buffer = new Array();
8
- const child = spawn(command, args, { shell: false });
9
+ const useShell = platform() === 'win32';
10
+ const child = spawn(command, args, { shell: useShell });
9
11
  child.stdout.setEncoding('utf8');
10
12
  child.stdout.on('data', (data) => {
11
13
  buffer.push(data);
@@ -32,7 +34,8 @@ function run(command, args = [], { onStdout = (data) => { }, onStderr = (data) =
32
34
  throw err; },
33
35
  onFinished: () => { },
34
36
  }) {
35
- var child = spawn(command, args);
37
+ const useShell = platform() === 'win32';
38
+ var child = spawn(command, args, { shell: useShell });
36
39
  child.stdout.setEncoding('utf8');
37
40
  child.stdout.on('data', (data) => onStdout(data));
38
41
  child.stderr.setEncoding('utf8');
package/dist/conf.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- declare const confDir: string;
2
- declare const dbPath: string;
1
+ declare const confDir: string, dbPath: string;
3
2
  declare function processConfPath(confPath: string): Promise<{
4
3
  paths: Array<string>;
5
4
  pf: string;
package/dist/conf.js CHANGED
@@ -1,17 +1,35 @@
1
- import path from "path";
2
1
  import { readConf } from "./cmd/sys/read_conf.js";
3
2
  import { upsertBackends, insertFeaturesPathIfNotExists, insertPluginIfNotExists } from "./db/write.js";
4
3
  import { buildPluginsPaths } from "./state/plugins.js";
5
4
  import { runtimeError } from "./cmd/lib/user_msgs.js";
6
5
  import { localBackends } from "./const.js";
7
- const confDir = path.join(process.env.HOME, ".config/agent-smith/cli");
8
- const dbPath = path.join(confDir, "config.db");
6
+ import { homedir } from 'os';
7
+ import { join } from 'path';
8
+ import { createDirectoryIfNotExists } from "./cmd/sys/dirs.js";
9
+ function getConfigPath(appName, filename) {
10
+ let confDir;
11
+ let dbPath;
12
+ if (process.platform === 'win32') {
13
+ confDir = join(process.env.APPDATA, appName);
14
+ dbPath = join(process.env.APPDATA, appName, filename);
15
+ }
16
+ else if (process.platform === 'darwin') {
17
+ confDir = join(homedir(), 'Library', 'Application Support', appName);
18
+ dbPath = join(homedir(), 'Library', 'Application Support', appName, filename);
19
+ }
20
+ else {
21
+ confDir = join(homedir(), '.config', appName);
22
+ dbPath = join(homedir(), '.config', appName, filename);
23
+ }
24
+ return { confDir: confDir, dbPath: dbPath };
25
+ }
26
+ const { confDir, dbPath } = getConfigPath("agent-smith", "config.db");
9
27
  async function processConfPath(confPath) {
28
+ createDirectoryIfNotExists(confDir);
10
29
  const { found, data } = readConf(confPath);
11
30
  if (!found) {
12
31
  runtimeError(`Config file ${confPath} not found`);
13
32
  }
14
- console.log(data);
15
33
  const allPaths = new Array();
16
34
  const backends = {};
17
35
  let defaultBackendName = "";
@@ -53,7 +71,6 @@ async function processConfPath(confPath) {
53
71
  }
54
72
  }
55
73
  console.log("Default backend:", defaultBackendName);
56
- console.dir(backends, { depth: 4 });
57
74
  if (!Object.keys(backends).includes(defaultBackendName)) {
58
75
  throw new Error(`Undeclared default backend: ${defaultBackendName}`);
59
76
  }
package/dist/db/db.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Database } from "better-sqlite3";
2
- declare const dbPath: string;
3
2
  declare let db: Database;
4
3
  declare function initDb(isVerbose: boolean, execSchema: boolean): void;
5
- export { db, dbPath, initDb, };
4
+ export { db, initDb, };
package/dist/db/db.js CHANGED
@@ -1,9 +1,7 @@
1
1
  import DatabaseConstructor from "better-sqlite3";
2
2
  import { schemas } from "./schemas.js";
3
- import path from "path";
4
3
  import { createDirectoryIfNotExists } from "../cmd/sys/dirs.js";
5
- const confDir = path.join(process.env.HOME ?? "~/", ".config/agent-smith/cli");
6
- const dbPath = path.join(confDir, "config.db");
4
+ import { confDir, dbPath } from "../conf.js";
7
5
  let db;
8
6
  const debugDb = false;
9
7
  function initDb(isVerbose, execSchema) {
@@ -21,4 +19,4 @@ function initDb(isVerbose, execSchema) {
21
19
  db = new DatabaseConstructor(dbPath);
22
20
  }
23
21
  }
24
- export { db, dbPath, initDb, };
22
+ export { db, initDb, };
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.86",
5
+ "version": "0.0.88",
6
6
  "scripts": {
7
7
  "buildrl": "rm -rf dist/* && rollup -c",
8
8
  "build": "rm -rf dist/* && tsc",