@agent-smith/cli 0.0.1

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.
Files changed (53) hide show
  1. package/dist/agent.d.ts +15 -0
  2. package/dist/agent.js +47 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +44 -0
  5. package/dist/cmd/cmds.d.ts +7 -0
  6. package/dist/cmd/cmds.js +205 -0
  7. package/dist/cmd/lib/execute_action.d.ts +2 -0
  8. package/dist/cmd/lib/execute_action.js +58 -0
  9. package/dist/cmd/lib/execute_job.d.ts +6 -0
  10. package/dist/cmd/lib/execute_job.js +86 -0
  11. package/dist/cmd/lib/execute_task.d.ts +2 -0
  12. package/dist/cmd/lib/execute_task.js +28 -0
  13. package/dist/cmd/lib/utils.d.ts +4 -0
  14. package/dist/cmd/lib/utils.js +44 -0
  15. package/dist/cmd/options/modes.d.ts +3 -0
  16. package/dist/cmd/options/modes.js +58 -0
  17. package/dist/cmd/sys/clipboard.d.ts +3 -0
  18. package/dist/cmd/sys/clipboard.js +17 -0
  19. package/dist/cmd/sys/execute.d.ts +13 -0
  20. package/dist/cmd/sys/execute.js +44 -0
  21. package/dist/cmd/sys/read_cmds.d.ts +3 -0
  22. package/dist/cmd/sys/read_cmds.js +26 -0
  23. package/dist/cmd/sys/read_conf.d.ts +6 -0
  24. package/dist/cmd/sys/read_conf.js +11 -0
  25. package/dist/cmd/sys/read_features.d.ts +3 -0
  26. package/dist/cmd/sys/read_features.js +83 -0
  27. package/dist/cmd/sys/read_yml_action.d.ts +5 -0
  28. package/dist/cmd/sys/read_yml_action.js +11 -0
  29. package/dist/cmd/sys/run_python.d.ts +3 -0
  30. package/dist/cmd/sys/run_python.js +43 -0
  31. package/dist/conf.d.ts +4 -0
  32. package/dist/conf.js +12 -0
  33. package/dist/db/db.d.ts +5 -0
  34. package/dist/db/db.js +16 -0
  35. package/dist/db/read.d.ts +9 -0
  36. package/dist/db/read.js +53 -0
  37. package/dist/db/schemas.d.ts +2 -0
  38. package/dist/db/schemas.js +42 -0
  39. package/dist/db/write.d.ts +6 -0
  40. package/dist/db/write.js +56 -0
  41. package/dist/index.d.ts +2 -0
  42. package/dist/index.js +25 -0
  43. package/dist/interfaces.d.ts +49 -0
  44. package/dist/interfaces.js +1 -0
  45. package/dist/main.d.ts +5 -0
  46. package/dist/main.js +5 -0
  47. package/dist/state/features.d.ts +8 -0
  48. package/dist/state/features.js +29 -0
  49. package/dist/state/plugins.d.ts +6 -0
  50. package/dist/state/plugins.js +24 -0
  51. package/dist/state/state.d.ts +15 -0
  52. package/dist/state/state.js +39 -0
  53. package/package.json +60 -0
@@ -0,0 +1,44 @@
1
+ import { spawn } from "child_process";
2
+ async function execute(command, args = [], { onStdout = (data) => { }, onStderr = (data) => { }, onError = (data) => { }, stream = false, } = {
3
+ onStderr: (data) => console.log("stderr:", data),
4
+ onError: (err) => { if (err)
5
+ throw err; },
6
+ }) {
7
+ let buffer = new Array();
8
+ const child = spawn(command, args, { shell: false });
9
+ child.stdout.setEncoding('utf8');
10
+ child.stdout.on('data', (data) => {
11
+ buffer.push(data);
12
+ onStdout(data);
13
+ });
14
+ child.stderr.setEncoding('utf8');
15
+ child.stderr.on('data', (data) => onStderr(data));
16
+ child.on("error", (data) => onError(data));
17
+ let finish;
18
+ let end = new Promise((r) => finish = r);
19
+ child.on('close', () => finish(true));
20
+ await end;
21
+ if (!stream) {
22
+ return buffer.join("\n");
23
+ }
24
+ else {
25
+ return buffer.join("");
26
+ }
27
+ }
28
+ function run(command, args = [], { onStdout = (data) => { }, onStderr = (data) => { }, onError = (data) => { }, onFinished = () => { }, } = {
29
+ onStdout: (data) => console.log("stdout:", data),
30
+ onStderr: (data) => console.log("stderr:", data),
31
+ onError: (err) => { if (err)
32
+ throw err; },
33
+ onFinished: () => { },
34
+ }) {
35
+ var child = spawn(command, args);
36
+ child.stdout.setEncoding('utf8');
37
+ child.stdout.on('data', (data) => onStdout(data));
38
+ child.stderr.setEncoding('utf8');
39
+ child.stderr.on('data', (data) => onStderr(data));
40
+ child.on("error", (data) => onError(data));
41
+ child.on('close', () => onFinished());
42
+ return () => child.kill();
43
+ }
44
+ export { execute, run };
@@ -0,0 +1,3 @@
1
+ import { Cmd } from "../../interfaces.js";
2
+ declare function readCmds(dir: string): Promise<Record<string, Cmd>>;
3
+ export { readCmds };
@@ -0,0 +1,26 @@
1
+ import { default as fs } from "fs";
2
+ import { default as path } from "path";
3
+ function _readCmdsDir(dir) {
4
+ const fileNames = new Array;
5
+ fs.readdirSync(dir).forEach((filename) => {
6
+ const filepath = path.join(dir, filename);
7
+ const isDir = fs.statSync(filepath).isDirectory();
8
+ if (!isDir) {
9
+ if (filename.endsWith(".ts") || filename.endsWith(".js")) {
10
+ const name = filename.replace(".js", "").replace(".ts", "");
11
+ fileNames.push(name);
12
+ }
13
+ }
14
+ });
15
+ return fileNames;
16
+ }
17
+ async function readCmds(dir) {
18
+ const cmds = {};
19
+ const fileNames = _readCmdsDir(dir);
20
+ for (const name of fileNames) {
21
+ const { cmd } = await import(path.join(dir, name + ".js"));
22
+ cmds[name] = cmd;
23
+ }
24
+ return cmds;
25
+ }
26
+ export { readCmds };
@@ -0,0 +1,6 @@
1
+ import { ConfigFile } from "../../interfaces.js";
2
+ declare function readConf(confPath: string): {
3
+ found: boolean;
4
+ data: ConfigFile;
5
+ };
6
+ export { readConf };
@@ -0,0 +1,11 @@
1
+ import { default as fs } from "fs";
2
+ import YAML from 'yaml';
3
+ function readConf(confPath) {
4
+ if (!fs.existsSync(confPath)) {
5
+ return { data: {}, found: false };
6
+ }
7
+ const file = fs.readFileSync(confPath, 'utf8');
8
+ const data = YAML.parse(file);
9
+ return { data: data, found: true };
10
+ }
11
+ export { readConf };
@@ -0,0 +1,3 @@
1
+ import { Features } from "bin/interfaces";
2
+ declare function readFeaturesDir(dir: string): Features;
3
+ export { readFeaturesDir };
@@ -0,0 +1,83 @@
1
+ import { default as fs } from "fs";
2
+ import { default as path } from "path";
3
+ function _readDir(dir, ext) {
4
+ const fileNames = new Array;
5
+ fs.readdirSync(dir).forEach((filename) => {
6
+ const filepath = path.join(dir, filename);
7
+ const isDir = fs.statSync(filepath).isDirectory();
8
+ if (!isDir) {
9
+ for (let extension of ext) {
10
+ if (filename.endsWith(extension)) {
11
+ fileNames.push(filename);
12
+ }
13
+ }
14
+ }
15
+ });
16
+ return fileNames;
17
+ }
18
+ function readFeaturesDir(dir) {
19
+ const feats = {
20
+ task: [],
21
+ job: [],
22
+ action: [],
23
+ cmd: [],
24
+ };
25
+ let dirpath = path.join(dir, "tasks");
26
+ if (fs.existsSync(dirpath)) {
27
+ const data = _readDir(dirpath, [".yml"]);
28
+ data.forEach((filename) => {
29
+ const parts = filename.split(".");
30
+ const ext = parts.pop();
31
+ const name = parts.join("");
32
+ feats.task.push({
33
+ name: name,
34
+ path: path.join(dirpath),
35
+ ext: ext,
36
+ });
37
+ });
38
+ }
39
+ dirpath = path.join(dir, "jobs");
40
+ if (fs.existsSync(dirpath)) {
41
+ const data = _readDir(dirpath, [".yml"]);
42
+ data.forEach((filename) => {
43
+ const parts = filename.split(".");
44
+ const ext = parts.pop();
45
+ const name = parts.join("");
46
+ feats.job.push({
47
+ name: name,
48
+ path: path.join(dirpath),
49
+ ext: ext,
50
+ });
51
+ });
52
+ }
53
+ dirpath = path.join(dir, "actions");
54
+ if (fs.existsSync(dirpath)) {
55
+ const data = _readDir(dirpath, ["yml", ".js", ".py"]);
56
+ data.forEach((filename) => {
57
+ const parts = filename.split(".");
58
+ const ext = parts.pop();
59
+ const name = parts.join("");
60
+ feats.action.push({
61
+ name: name,
62
+ path: path.join(dirpath),
63
+ ext: ext,
64
+ });
65
+ });
66
+ }
67
+ dirpath = path.join(dir, "cmds");
68
+ if (fs.existsSync(dirpath)) {
69
+ const data = _readDir(dirpath, [".js"]);
70
+ data.forEach((filename) => {
71
+ const parts = filename.split(".");
72
+ const ext = parts.pop();
73
+ const name = parts.join("");
74
+ feats.cmd.push({
75
+ name: name,
76
+ path: path.join(dirpath),
77
+ ext: ext,
78
+ });
79
+ });
80
+ }
81
+ return feats;
82
+ }
83
+ export { readFeaturesDir };
@@ -0,0 +1,5 @@
1
+ declare function readYmlAction(path: string): {
2
+ found: boolean;
3
+ data: Record<string, any>;
4
+ };
5
+ export { readYmlAction };
@@ -0,0 +1,11 @@
1
+ import { default as fs } from "fs";
2
+ import YAML from 'yaml';
3
+ function readYmlAction(path) {
4
+ if (!fs.existsSync(path)) {
5
+ return { data: {}, found: false };
6
+ }
7
+ const file = fs.readFileSync(path, 'utf8');
8
+ const data = YAML.parse(file);
9
+ return { data: data, found: true };
10
+ }
11
+ export { readYmlAction };
@@ -0,0 +1,3 @@
1
+ import { PythonShell } from 'python-shell';
2
+ declare function runPyScript(rsShell: PythonShell, pythonPath: string, scriptPath: string, scriptArgs: Array<string>, handleOutputFrom?: "msg" | "stderr", onEmitLine?: CallableFunction): Promise<string[]>;
3
+ export { runPyScript };
@@ -0,0 +1,43 @@
1
+ import { PythonShell } from 'python-shell';
2
+ async function runPyScript(rsShell, pythonPath, scriptPath, scriptArgs, handleOutputFrom = "msg", onEmitLine) {
3
+ const _options = {
4
+ mode: "text",
5
+ pythonPath: pythonPath,
6
+ pythonOptions: ['-u'],
7
+ args: scriptArgs,
8
+ };
9
+ let promiseResolve;
10
+ let promise = new Promise((resolve) => promiseResolve = resolve);
11
+ rsShell = new PythonShell(scriptPath, _options);
12
+ const msgs = new Array();
13
+ function handleLine(msg) {
14
+ if (onEmitLine) {
15
+ onEmitLine(msg);
16
+ }
17
+ msgs.push(msg);
18
+ }
19
+ rsShell.on('message', function (message) {
20
+ if (handleOutputFrom == "msg") {
21
+ handleLine(message);
22
+ }
23
+ });
24
+ rsShell.on('stderr', function (err) {
25
+ console.log("STDERR", err);
26
+ if (handleOutputFrom == "stderr") {
27
+ handleLine(err);
28
+ }
29
+ else {
30
+ promiseResolve(true);
31
+ }
32
+ });
33
+ rsShell.on('pythonError', function (err) {
34
+ console.log("PYERR", `${err.message}, ${err.traceback}`);
35
+ promiseResolve(true);
36
+ });
37
+ rsShell.end(function (err, code, signal) {
38
+ promiseResolve(true);
39
+ });
40
+ await promise;
41
+ return msgs;
42
+ }
43
+ export { runPyScript };
package/dist/conf.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ declare const confDir: string;
2
+ declare const dbPath: string;
3
+ declare function createConfDirIfNotExists(): boolean;
4
+ export { confDir, dbPath, createConfDirIfNotExists, };
package/dist/conf.js ADDED
@@ -0,0 +1,12 @@
1
+ import path from "path";
2
+ import { default as fs } from "fs";
3
+ const confDir = path.join(process.env.HOME, ".config/agent-smith/cli");
4
+ const dbPath = path.join(confDir, "config.db");
5
+ function createConfDirIfNotExists() {
6
+ if (!fs.existsSync(confDir)) {
7
+ fs.mkdirSync(confDir, { recursive: true });
8
+ return false;
9
+ }
10
+ return true;
11
+ }
12
+ export { confDir, dbPath, createConfDirIfNotExists, };
@@ -0,0 +1,5 @@
1
+ import { Database } from "better-sqlite3";
2
+ declare let db: Database;
3
+ declare function initDb(isVerbose?: boolean): void;
4
+ declare function dbPopulateDefaults(): void;
5
+ export { db, initDb, dbPopulateDefaults, };
package/dist/db/db.js ADDED
@@ -0,0 +1,16 @@
1
+ import DatabaseConstructor from "better-sqlite3";
2
+ import { schemas } from "./schemas.js";
3
+ import { createConfDirIfNotExists, dbPath } from "../conf.js";
4
+ createConfDirIfNotExists();
5
+ let db = new DatabaseConstructor(dbPath);
6
+ function initDb(isVerbose = false) {
7
+ schemas.forEach((s) => {
8
+ db.exec(s);
9
+ if (isVerbose) {
10
+ console.log(`Schema executed: ${s}`);
11
+ }
12
+ });
13
+ }
14
+ function dbPopulateDefaults() {
15
+ }
16
+ export { db, initDb, dbPopulateDefaults, };
@@ -0,0 +1,9 @@
1
+ import { FeatureSpec, FeatureType } from "../interfaces.js";
2
+ declare function readFeaturePaths(): Array<string>;
3
+ declare function readPlugins(): Array<Record<string, string>>;
4
+ declare function readFeatures(): Record<FeatureType, Record<string, string>>;
5
+ declare function readFeature(name: string, type: FeatureType): {
6
+ found: boolean;
7
+ feature: FeatureSpec;
8
+ };
9
+ export { readFeatures, readFeaturePaths, readFeature, readPlugins };
@@ -0,0 +1,53 @@
1
+ import { db } from "./db.js";
2
+ function readFeaturePaths() {
3
+ const stmt = db.prepare("SELECT path FROM featurespath");
4
+ const data = stmt.all();
5
+ let f = new Array();
6
+ data.forEach((row) => {
7
+ f.push(row.path);
8
+ });
9
+ return f;
10
+ }
11
+ function readPlugins() {
12
+ const stmt = db.prepare("SELECT name, path FROM plugin");
13
+ const data = stmt.all();
14
+ let f = new Array();
15
+ data.forEach((row) => {
16
+ f.push({ name: row.name, path: row.path });
17
+ });
18
+ return f;
19
+ }
20
+ function readFeaturesType(type) {
21
+ const stmt = db.prepare(`SELECT name, path FROM ${type}`);
22
+ const data = stmt.all();
23
+ let f = {};
24
+ data.forEach((row) => {
25
+ f[row.name] = row.path;
26
+ });
27
+ return f;
28
+ }
29
+ function readFeatures() {
30
+ const feats = { task: {}, job: {}, action: {}, cmd: {} };
31
+ feats.task = readFeaturesType("task");
32
+ feats.job = readFeaturesType("job");
33
+ feats.action = readFeaturesType("action");
34
+ feats.cmd = readFeaturesType("cmd");
35
+ return feats;
36
+ }
37
+ function readFeature(name, type) {
38
+ const q = `SELECT id, path, ext FROM ${type} WHERE name='${name}'`;
39
+ const stmt = db.prepare(q);
40
+ const result = stmt.get();
41
+ if (result?.id) {
42
+ return {
43
+ found: true,
44
+ feature: {
45
+ name: result.name,
46
+ path: result.path,
47
+ ext: result.ext,
48
+ }
49
+ };
50
+ }
51
+ return { found: false, feature: {} };
52
+ }
53
+ export { readFeatures, readFeaturePaths, readFeature, readPlugins };
@@ -0,0 +1,2 @@
1
+ declare const schemas: string[];
2
+ export { schemas };
@@ -0,0 +1,42 @@
1
+ const filepaths = `CREATE TABLE IF NOT EXISTS filepath (
2
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
3
+ name TEXT UNIQUE NOT NULL,
4
+ path TEXT NOT NULL
5
+ );`;
6
+ const featurespaths = `CREATE TABLE IF NOT EXISTS featurespath (
7
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
8
+ path TEXT NOT NULL
9
+ );`;
10
+ const plugins = `CREATE TABLE IF NOT EXISTS plugin (
11
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
12
+ name TEXT UNIQUE NOT NULL,
13
+ path TEXT NOT NULL
14
+ );`;
15
+ const tasks = `CREATE TABLE IF NOT EXISTS task (
16
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
17
+ name TEXT UNIQUE NOT NULL,
18
+ path TEXT NOT NULL,
19
+ ext TEXT NOT NULL CHECK ( ext IN ('yml') )
20
+ );`;
21
+ const jobs = `CREATE TABLE IF NOT EXISTS job (
22
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
23
+ name TEXT UNIQUE NOT NULL,
24
+ path TEXT NOT NULL,
25
+ ext TEXT NOT NULL CHECK ( ext IN ('yml') )
26
+ );`;
27
+ const actions = `CREATE TABLE IF NOT EXISTS action (
28
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
29
+ name TEXT UNIQUE NOT NULL,
30
+ path TEXT NOT NULL,
31
+ ext TEXT NOT NULL CHECK ( ext IN ('yml', 'js', 'py') )
32
+ );`;
33
+ const cmds = `CREATE TABLE IF NOT EXISTS cmd (
34
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
35
+ name TEXT UNIQUE NOT NULL,
36
+ path TEXT NOT NULL,
37
+ ext TEXT NOT NULL CHECK ( ext IN ('js') )
38
+ );`;
39
+ const schemas = [
40
+ filepaths, featurespaths, tasks, jobs, actions, cmds, plugins
41
+ ];
42
+ export { schemas };
@@ -0,0 +1,6 @@
1
+ import { Features } from "../interfaces.js";
2
+ declare function insertDefaultFilepaths(): void;
3
+ declare function insertFeaturesPathIfNotExists(path: string): boolean;
4
+ declare function insertPluginIfNotExists(n: string, p: string): boolean;
5
+ declare function updateFeatures(feats: Features): void;
6
+ export { insertDefaultFilepaths, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, };
@@ -0,0 +1,56 @@
1
+ import { db } from "./db.js";
2
+ const defaultFilepaths = {
3
+ prompt: "",
4
+ override: "",
5
+ };
6
+ function insertDefaultFilepaths() {
7
+ for (const [k, v] of Object.entries(defaultFilepaths)) {
8
+ const stmt = db.prepare("INSERT INTO filepath (name, path) VALUES (?, ?)");
9
+ stmt.run(k, v);
10
+ }
11
+ }
12
+ function insertFeaturesPathIfNotExists(path) {
13
+ const stmt1 = db.prepare("SELECT * FROM featurespath WHERE path = ?");
14
+ const result = stmt1.get(path);
15
+ if (result?.id) {
16
+ return true;
17
+ }
18
+ const stmt = db.prepare("INSERT INTO featurespath (path) VALUES (?)");
19
+ stmt.run(path);
20
+ return false;
21
+ }
22
+ function insertPluginIfNotExists(n, p) {
23
+ const stmt1 = db.prepare("SELECT * FROM plugin WHERE name = ?");
24
+ const result = stmt1.get(n);
25
+ if (result?.id) {
26
+ return true;
27
+ }
28
+ const stmt = db.prepare("INSERT INTO plugin (name, path) VALUES (?,?)");
29
+ stmt.run(n, p);
30
+ return false;
31
+ }
32
+ function upsertAndCleanFeatures(feats, type) {
33
+ const stmt = db.prepare(`SELECT name FROM ${type}`);
34
+ const rows = stmt.all();
35
+ const names = rows.map(row => row.name);
36
+ feats.forEach((feat) => {
37
+ if (!names.includes(feat.name)) {
38
+ const insertStmt = db.prepare(`INSERT INTO ${type} (name, path, ext) VALUES (?, ?, ?)`);
39
+ insertStmt.run(feat.name, feat.path, feat.ext);
40
+ }
41
+ });
42
+ const availableFeatsNames = feats.map((f) => f.name);
43
+ names.forEach((name) => {
44
+ if (!availableFeatsNames.includes(name)) {
45
+ const deleteStmt = db.prepare(`DELETE FROM ${type} WHERE name = ?`);
46
+ deleteStmt.run(name);
47
+ }
48
+ });
49
+ }
50
+ function updateFeatures(feats) {
51
+ upsertAndCleanFeatures(feats.task, "task");
52
+ upsertAndCleanFeatures(feats.job, "job");
53
+ upsertAndCleanFeatures(feats.action, "action");
54
+ upsertAndCleanFeatures(feats.cmd, "cmd");
55
+ }
56
+ export { insertDefaultFilepaths, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, };
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ import { argv } from 'process';
3
+ import { query } from "./cli.js";
4
+ import { initState, runMode } from './state/state.js';
5
+ import { initAgent } from './agent.js';
6
+ import { initCmds, parseCmd } from './cmd/cmds.js';
7
+ async function main() {
8
+ if (argv.length == 2) {
9
+ runMode.value = "cli";
10
+ }
11
+ await initState();
12
+ await initCmds();
13
+ await initAgent(runMode.value);
14
+ switch (runMode.value) {
15
+ case "cli":
16
+ await query();
17
+ break;
18
+ default:
19
+ await parseCmd();
20
+ break;
21
+ }
22
+ }
23
+ (async () => {
24
+ await main();
25
+ })();
@@ -0,0 +1,49 @@
1
+ interface Cmd {
2
+ cmd: CmdExecutor;
3
+ description: string;
4
+ args?: string;
5
+ }
6
+ interface FeatureSpec {
7
+ name: string;
8
+ path: string;
9
+ ext: FeatureExtension;
10
+ }
11
+ interface Features {
12
+ task: Array<{
13
+ name: string;
14
+ path: string;
15
+ ext: TaskExtension;
16
+ }>;
17
+ job: Array<{
18
+ name: string;
19
+ path: string;
20
+ ext: JobExtension;
21
+ }>;
22
+ cmd: Array<{
23
+ name: string;
24
+ path: string;
25
+ ext: CmdExtension;
26
+ }>;
27
+ action: Array<{
28
+ name: string;
29
+ path: string;
30
+ ext: ActionExtension;
31
+ }>;
32
+ }
33
+ interface ConfigFile {
34
+ promptfile: string;
35
+ features: Array<string>;
36
+ plugins: Array<string>;
37
+ }
38
+ type CmdExecutor = (args: Array<string>, options: any) => Promise<any>;
39
+ type InputMode = "manual" | "promptfile" | "clipboard";
40
+ type OutputMode = "txt" | "clipboard";
41
+ type RunMode = "cli" | "cmd";
42
+ type FormatMode = "text" | "markdown";
43
+ type FeatureType = "task" | "job" | "action" | "cmd";
44
+ type ActionExtension = "js" | "py" | "yml";
45
+ type TaskExtension = "yml";
46
+ type JobExtension = "yml";
47
+ type CmdExtension = "js";
48
+ type FeatureExtension = TaskExtension | JobExtension | CmdExtension | ActionExtension;
49
+ export { Cmd, CmdExecutor, InputMode, OutputMode, RunMode, FormatMode, FeatureType, ActionExtension, TaskExtension, JobExtension, CmdExtension, FeatureSpec, Features, ConfigFile, FeatureExtension, };
@@ -0,0 +1 @@
1
+ export {};
package/dist/main.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { execute, run } from "./cmd/sys/execute.js";
2
+ import { executeJobCmd } from "./cmd/lib/execute_job.js";
3
+ import { writeToClipboard } from "./cmd/sys/clipboard.js";
4
+ import { pingCmd } from "./cmd/cmds.js";
5
+ export { execute, run, pingCmd, executeJobCmd, writeToClipboard, };
package/dist/main.js ADDED
@@ -0,0 +1,5 @@
1
+ import { execute, run } from "./cmd/sys/execute.js";
2
+ import { executeJobCmd } from "./cmd/lib/execute_job.js";
3
+ import { writeToClipboard } from "./cmd/sys/clipboard.js";
4
+ import { pingCmd } from "./cmd/cmds.js";
5
+ export { execute, run, pingCmd, executeJobCmd, writeToClipboard, };
@@ -0,0 +1,8 @@
1
+ import { FeatureExtension, FeatureType, Features } from "../interfaces.js";
2
+ declare function readFeaturesDirs(featuresPaths: Array<string>): Features;
3
+ declare function getFeatureSpec(name: string, type: FeatureType): {
4
+ found: boolean;
5
+ path: string;
6
+ ext: FeatureExtension;
7
+ };
8
+ export { readFeaturesDirs, getFeatureSpec, };
@@ -0,0 +1,29 @@
1
+ import { default as path } from "path";
2
+ import { readFeaturesDir } from "../cmd/sys/read_features.js";
3
+ import { readFeature } from "../db/read.js";
4
+ function readFeaturesDirs(featuresPaths) {
5
+ const feats = {
6
+ task: [],
7
+ job: [],
8
+ action: [],
9
+ cmd: [],
10
+ };
11
+ featuresPaths.forEach((dir) => {
12
+ console.log("Reading feats in", dir);
13
+ const _f = readFeaturesDir(dir);
14
+ _f.task.forEach((item) => feats.task.push(item));
15
+ _f.job.forEach((item) => feats.job.push(item));
16
+ _f.action.forEach((item) => feats.action.push(item));
17
+ _f.cmd.forEach((item) => feats.cmd.push(item));
18
+ });
19
+ return feats;
20
+ }
21
+ function getFeatureSpec(name, type) {
22
+ const { found, feature } = readFeature(name, type);
23
+ if (!found) {
24
+ return { found: false, path: "", ext: "yml" };
25
+ }
26
+ const f = path.join(feature.path, name + "." + feature.ext);
27
+ return { found: true, path: f, ext: feature.ext };
28
+ }
29
+ export { readFeaturesDirs, getFeatureSpec, };
@@ -0,0 +1,6 @@
1
+ declare function buildPluginsPaths(names: Array<string>): Promise<Array<{
2
+ name: string;
3
+ path: string;
4
+ }>>;
5
+ declare function readPluginsPaths(): Promise<Array<string>>;
6
+ export { buildPluginsPaths, readPluginsPaths };
@@ -0,0 +1,24 @@
1
+ import { execute } from "../main.js";
2
+ import { readPlugins } from "../db/read.js";
3
+ import path from "path";
4
+ async function buildPluginsPaths(names) {
5
+ const plugins = new Array();
6
+ const root = await execute("npm", ["root", "-g"]);
7
+ const rootPath = root.trim();
8
+ names.forEach((p) => {
9
+ plugins.push({
10
+ name: p,
11
+ path: path.join(rootPath, p, "dist")
12
+ });
13
+ });
14
+ return plugins;
15
+ }
16
+ async function readPluginsPaths() {
17
+ const paths = new Array();
18
+ const plugins = readPlugins();
19
+ plugins.forEach((p) => {
20
+ paths.push(p.path);
21
+ });
22
+ return paths;
23
+ }
24
+ export { buildPluginsPaths, readPluginsPaths };
@@ -0,0 +1,15 @@
1
+ import { PythonShell } from 'python-shell';
2
+ import { InputMode, RunMode, FormatMode, OutputMode } from "../interfaces.js";
3
+ declare let pyShell: PythonShell;
4
+ declare const inputMode: import("@vue/reactivity").Ref<InputMode, InputMode>;
5
+ declare const outputMode: import("@vue/reactivity").Ref<OutputMode, OutputMode>;
6
+ declare const runMode: import("@vue/reactivity").Ref<RunMode, RunMode>;
7
+ declare const formatMode: import("@vue/reactivity").Ref<FormatMode, FormatMode>;
8
+ declare const promptfile: import("@vue/reactivity").Ref<string, string>;
9
+ declare const lastCmd: {
10
+ name: string;
11
+ args: Array<string>;
12
+ };
13
+ declare function initFeatures(): Promise<void>;
14
+ declare function initState(): Promise<void>;
15
+ export { inputMode, outputMode, runMode, formatMode, lastCmd, promptfile, initState, initFeatures, pyShell, };