@astrive-ai/cli 1.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 (67) hide show
  1. package/dist/bin.d.ts +3 -0
  2. package/dist/bin.d.ts.map +1 -0
  3. package/dist/bin.js +4 -0
  4. package/dist/bin.js.map +1 -0
  5. package/dist/cli.d.ts +20 -0
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/cli.js +74 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/commands/chat.d.ts +8 -0
  10. package/dist/commands/chat.d.ts.map +1 -0
  11. package/dist/commands/chat.js +84 -0
  12. package/dist/commands/chat.js.map +1 -0
  13. package/dist/commands/dev.d.ts +7 -0
  14. package/dist/commands/dev.d.ts.map +1 -0
  15. package/dist/commands/dev.js +51 -0
  16. package/dist/commands/dev.js.map +1 -0
  17. package/dist/commands/doctor.d.ts +7 -0
  18. package/dist/commands/doctor.d.ts.map +1 -0
  19. package/dist/commands/doctor.js +46 -0
  20. package/dist/commands/doctor.js.map +1 -0
  21. package/dist/commands/init.d.ts +7 -0
  22. package/dist/commands/init.d.ts.map +1 -0
  23. package/dist/commands/init.js +56 -0
  24. package/dist/commands/init.js.map +1 -0
  25. package/dist/commands/inspect.d.ts +7 -0
  26. package/dist/commands/inspect.d.ts.map +1 -0
  27. package/dist/commands/inspect.js +24 -0
  28. package/dist/commands/inspect.js.map +1 -0
  29. package/dist/commands/plugins.d.ts +7 -0
  30. package/dist/commands/plugins.d.ts.map +1 -0
  31. package/dist/commands/plugins.js +32 -0
  32. package/dist/commands/plugins.js.map +1 -0
  33. package/dist/commands/tools.d.ts +7 -0
  34. package/dist/commands/tools.d.ts.map +1 -0
  35. package/dist/commands/tools.js +42 -0
  36. package/dist/commands/tools.js.map +1 -0
  37. package/dist/commands/version.d.ts +8 -0
  38. package/dist/commands/version.d.ts.map +1 -0
  39. package/dist/commands/version.js +23 -0
  40. package/dist/commands/version.js.map +1 -0
  41. package/dist/index.d.ts +4 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +7 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/parser.d.ts +6 -0
  46. package/dist/parser.d.ts.map +1 -0
  47. package/dist/parser.js +43 -0
  48. package/dist/parser.js.map +1 -0
  49. package/dist/ui.d.ts +32 -0
  50. package/dist/ui.d.ts.map +1 -0
  51. package/dist/ui.js +95 -0
  52. package/dist/ui.js.map +1 -0
  53. package/package.json +29 -0
  54. package/src/bin.ts +3 -0
  55. package/src/cli.ts +97 -0
  56. package/src/commands/chat.ts +94 -0
  57. package/src/commands/dev.ts +61 -0
  58. package/src/commands/doctor.ts +50 -0
  59. package/src/commands/init.ts +64 -0
  60. package/src/commands/inspect.ts +28 -0
  61. package/src/commands/plugins.ts +35 -0
  62. package/src/commands/tools.ts +47 -0
  63. package/src/commands/version.ts +25 -0
  64. package/src/index.ts +8 -0
  65. package/src/parser.ts +41 -0
  66. package/src/ui.ts +109 -0
  67. package/tsconfig.json +8 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/commands/version.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,OAAO,cAAc;IACzB,IAAI,GAAG,SAAS,CAAC;IACjB,WAAW,GAAG,0BAA0B,CAAC;IACzC,OAAO,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAE9B,KAAK,CAAC,OAAO,CAAC,IAAc,EAAE,KAA6B;QACzD,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YAC9D,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACpD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAEhC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;YACxD,OAAO,CAAC,GAAG,CAAC,WAAW,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,6DAA6D,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export { CLI } from './cli.js';
2
+ export type { Command, Flag } from './cli.js';
3
+ export declare function run(args: string[]): Promise<void>;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAG9C,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvD"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export { CLI } from './cli.js';
2
+ import { CLI } from './cli.js';
3
+ export async function run(args) {
4
+ const cli = new CLI();
5
+ await cli.run(args);
6
+ }
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAAc;IACtC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;IACtB,MAAM,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare function parseArgs(args: string[]): {
2
+ command: string;
3
+ positional: string[];
4
+ flags: Record<string, string>;
5
+ };
6
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAwClH"}
package/dist/parser.js ADDED
@@ -0,0 +1,43 @@
1
+ export function parseArgs(args) {
2
+ const command = args.length > 0 && !args[0].startsWith('-') ? args[0] : '';
3
+ const remaining = command ? args.slice(1) : args;
4
+ const positional = [];
5
+ const flags = {};
6
+ for (let i = 0; i < remaining.length; i++) {
7
+ const arg = remaining[i];
8
+ if (arg.startsWith('--')) {
9
+ const eqIdx = arg.indexOf('=');
10
+ if (eqIdx !== -1) {
11
+ const key = arg.slice(2, eqIdx);
12
+ const value = arg.slice(eqIdx + 1);
13
+ flags[key] = value;
14
+ }
15
+ else {
16
+ const key = arg.slice(2);
17
+ // Check if next arg is a value or another flag
18
+ if (i + 1 < remaining.length && !remaining[i + 1].startsWith('-')) {
19
+ flags[key] = remaining[i + 1];
20
+ i++; // Skip the value
21
+ }
22
+ else {
23
+ flags[key] = 'true';
24
+ }
25
+ }
26
+ }
27
+ else if (arg.startsWith('-')) {
28
+ const key = arg.slice(1);
29
+ if (i + 1 < remaining.length && !remaining[i + 1].startsWith('-')) {
30
+ flags[key] = remaining[i + 1];
31
+ i++;
32
+ }
33
+ else {
34
+ flags[key] = 'true';
35
+ }
36
+ }
37
+ else {
38
+ positional.push(arg);
39
+ }
40
+ }
41
+ return { command, positional, flags };
42
+ }
43
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3E,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAEjD,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,MAAM,KAAK,GAA2B,EAAE,CAAC;IAEzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAEzB,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC/B,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;gBACjB,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;gBAChC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;gBACnC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACrB,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACzB,+CAA+C;gBAC/C,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBAClE,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC9B,CAAC,EAAE,CAAC,CAAC,iBAAiB;gBACxB,CAAC;qBAAM,CAAC;oBACN,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;gBACtB,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/B,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACzB,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAClE,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC9B,CAAC,EAAE,CAAC;YACN,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;YACtB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AACxC,CAAC"}
package/dist/ui.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ export declare const Colors: {
2
+ reset: string;
3
+ bold: string;
4
+ dim: string;
5
+ red: string;
6
+ green: string;
7
+ yellow: string;
8
+ blue: string;
9
+ magenta: string;
10
+ cyan: string;
11
+ white: string;
12
+ };
13
+ export declare function bold(text: string): string;
14
+ export declare function dim(text: string): string;
15
+ export declare function success(msg: string): void;
16
+ export declare function error(msg: string): void;
17
+ export declare function warning(msg: string): void;
18
+ export declare function info(msg: string): void;
19
+ export declare function banner(): void;
20
+ export declare function divider(): void;
21
+ export declare function table(headers: string[], rows: string[][]): void;
22
+ export declare class Spinner {
23
+ private frames;
24
+ private currentFrame;
25
+ private timer;
26
+ private message;
27
+ start(msg: string): void;
28
+ stop(msg?: string): void;
29
+ succeed(msg: string): void;
30
+ fail(msg: string): void;
31
+ }
32
+ //# sourceMappingURL=ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;;CAWlB,CAAC;AAEF,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExC;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEzC;AAED,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEvC;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEzC;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEtC;AAED,wBAAgB,MAAM,IAAI,IAAI,CAS7B;AAED,wBAAgB,OAAO,IAAI,IAAI,CAE9B;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI,CAmB/D;AAED,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAsD;IACpE,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,OAAO,CAAM;IAErB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAUxB,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;IAYxB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI1B,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAGxB"}
package/dist/ui.js ADDED
@@ -0,0 +1,95 @@
1
+ export const Colors = {
2
+ reset: "\x1b[0m",
3
+ bold: "\x1b[1m",
4
+ dim: "\x1b[2m",
5
+ red: "\x1b[31m",
6
+ green: "\x1b[32m",
7
+ yellow: "\x1b[33m",
8
+ blue: "\x1b[34m",
9
+ magenta: "\x1b[35m",
10
+ cyan: "\x1b[36m",
11
+ white: "\x1b[37m",
12
+ };
13
+ export function bold(text) {
14
+ return `${Colors.bold}${text}${Colors.reset}`;
15
+ }
16
+ export function dim(text) {
17
+ return `${Colors.dim}${text}${Colors.reset}`;
18
+ }
19
+ export function success(msg) {
20
+ console.log(`${Colors.green}✔${Colors.reset} ${msg}`);
21
+ }
22
+ export function error(msg) {
23
+ console.log(`${Colors.red}✖${Colors.reset} ${msg}`);
24
+ }
25
+ export function warning(msg) {
26
+ console.log(`${Colors.yellow}⚠${Colors.reset} ${msg}`);
27
+ }
28
+ export function info(msg) {
29
+ console.log(`${Colors.cyan}ℹ${Colors.reset} ${msg}`);
30
+ }
31
+ export function banner() {
32
+ console.log(`
33
+ ${Colors.cyan}${Colors.bold}
34
+ ___ __ _
35
+ / _ | ___ / /_ ____(_) _____
36
+ / __ |(_-</ __/ __/ / |/ / -_)
37
+ /_/ |_/___/\\__/_/ /_/|___/\\__/
38
+ ${Colors.reset}
39
+ `);
40
+ }
41
+ export function divider() {
42
+ console.log(dim('----------------------------------------'));
43
+ }
44
+ export function table(headers, rows) {
45
+ const colWidths = headers.map(h => h.length);
46
+ rows.forEach(row => {
47
+ row.forEach((cell, i) => {
48
+ colWidths[i] = Math.max(colWidths[i], String(cell).length);
49
+ });
50
+ });
51
+ const printRow = (row, isHeader = false) => {
52
+ const formatted = row.map((cell, i) => {
53
+ const padded = String(cell).padEnd(colWidths[i] + 2);
54
+ return isHeader ? bold(padded) : padded;
55
+ }).join('');
56
+ console.log(formatted);
57
+ };
58
+ printRow(headers, true);
59
+ divider();
60
+ rows.forEach(row => printRow(row));
61
+ }
62
+ export class Spinner {
63
+ frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
64
+ currentFrame = 0;
65
+ timer = null;
66
+ message = '';
67
+ start(msg) {
68
+ this.message = msg;
69
+ if (this.timer)
70
+ clearInterval(this.timer);
71
+ this.timer = setInterval(() => {
72
+ process.stdout.write(`\r${Colors.cyan}${this.frames[this.currentFrame]}${Colors.reset} ${this.message}`);
73
+ this.currentFrame = (this.currentFrame + 1) % this.frames.length;
74
+ }, 80);
75
+ }
76
+ stop(msg) {
77
+ if (this.timer) {
78
+ clearInterval(this.timer);
79
+ this.timer = null;
80
+ }
81
+ if (msg) {
82
+ process.stdout.write(`\r${msg}\n`);
83
+ }
84
+ else {
85
+ process.stdout.write('\r\x1b[K'); // clear line
86
+ }
87
+ }
88
+ succeed(msg) {
89
+ this.stop(`${Colors.green}✔${Colors.reset} ${msg}`);
90
+ }
91
+ fail(msg) {
92
+ this.stop(`${Colors.red}✖${Colors.reset} ${msg}`);
93
+ }
94
+ }
95
+ //# sourceMappingURL=ui.js.map
package/dist/ui.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,SAAS;IACf,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,UAAU;IACf,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,UAAU;IAClB,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,UAAU;IACnB,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CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC,CAAC;IACpD,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@astrive-ai/cli",
3
+ "version": "1.0.1",
4
+ "type": "module",
5
+ "bin": {
6
+ "astrive": "./dist/bin.js"
7
+ },
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ }
15
+ },
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "clean": "rm -rf dist"
19
+ },
20
+ "dependencies": {
21
+ "@astrive-ai/types": "*",
22
+ "@astrive-ai/agent": "*",
23
+ "@astrive-ai/tools": "*",
24
+ "@astrive-ai/providers": "*"
25
+ },
26
+ "devDependencies": {
27
+ "typescript": "5.4.5"
28
+ }
29
+ }
package/src/bin.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { run } from './index.js';
3
+ run(process.argv.slice(2));
package/src/cli.ts ADDED
@@ -0,0 +1,97 @@
1
+ export interface Flag {
2
+ name: string;
3
+ description: string;
4
+ type: 'string' | 'boolean';
5
+ }
6
+
7
+ export interface Command {
8
+ name: string;
9
+ description: string;
10
+ aliases?: string[];
11
+ flags?: Flag[];
12
+ execute(args: string[], flags: Record<string, string>): Promise<void>;
13
+ }
14
+
15
+ import { parseArgs } from './parser.js';
16
+ import { error, banner, info, bold, divider } from './ui.js';
17
+ import { InitCommand } from './commands/init.js';
18
+ import { ChatCommand } from './commands/chat.js';
19
+ import { DoctorCommand } from './commands/doctor.js';
20
+ import { ToolsCommand } from './commands/tools.js';
21
+ import { PluginsCommand } from './commands/plugins.js';
22
+ import { VersionCommand } from './commands/version.js';
23
+ import { DevCommand } from './commands/dev.js';
24
+ import { InspectCommand } from './commands/inspect.js';
25
+
26
+ export class CLI {
27
+ private commands = new Map<string, Command>();
28
+
29
+ constructor() {
30
+ this.register(new InitCommand());
31
+ this.register(new ChatCommand());
32
+ this.register(new DoctorCommand());
33
+ this.register(new ToolsCommand());
34
+ this.register(new PluginsCommand());
35
+ this.register(new VersionCommand());
36
+ this.register(new DevCommand());
37
+ this.register(new InspectCommand());
38
+ }
39
+
40
+ private register(cmd: Command) {
41
+ this.commands.set(cmd.name, cmd);
42
+ if (cmd.aliases) {
43
+ cmd.aliases.forEach(alias => this.commands.set(alias, cmd));
44
+ }
45
+ }
46
+
47
+ async run(args: string[]): Promise<void> {
48
+ const parsed = parseArgs(args);
49
+
50
+ if (!parsed.command || parsed.flags['help'] || parsed.flags['h']) {
51
+ this.showHelp();
52
+ return;
53
+ }
54
+
55
+ const command = this.commands.get(parsed.command);
56
+ if (!command) {
57
+ error(`Unknown command: ${parsed.command}`);
58
+ info('Run "astrive --help" to see available commands.');
59
+ process.exit(1);
60
+ }
61
+
62
+ try {
63
+ await command.execute(parsed.positional, parsed.flags);
64
+ } catch (err) {
65
+ error(`Error executing command ${command.name}:`);
66
+ console.error(err instanceof Error ? err.message : err);
67
+ process.exit(1);
68
+ }
69
+ }
70
+
71
+ private showHelp(): void {
72
+ banner();
73
+ console.log(bold('Usage:'));
74
+ console.log(' astrive <command> [options]');
75
+ console.log('');
76
+ console.log(bold('Commands:'));
77
+
78
+ // Deduplicate commands (because of aliases)
79
+ const uniqueCommands = new Set<Command>();
80
+ for (const cmd of this.commands.values()) {
81
+ uniqueCommands.add(cmd);
82
+ }
83
+
84
+ Array.from(uniqueCommands)
85
+ .sort((a, b) => a.name.localeCompare(b.name))
86
+ .forEach(cmd => {
87
+ const namePad = cmd.name.padEnd(15);
88
+ console.log(` ${namePad} ${cmd.description}`);
89
+ });
90
+
91
+ console.log('');
92
+ console.log(bold('Options:'));
93
+ console.log(' --help, -h Show help');
94
+ console.log('');
95
+ divider();
96
+ }
97
+ }
@@ -0,0 +1,94 @@
1
+ import { Command, Flag } from '../cli.js';
2
+ import { success, error, info, bold, dim, Spinner } from '../ui.js';
3
+ import * as readline from 'readline';
4
+ import { AstriveAI } from '@astrive-ai/agent';
5
+ import { AstriveConfig } from '@astrive-ai/types';
6
+
7
+ export class ChatCommand implements Command {
8
+ name = 'chat';
9
+ description = 'Start an interactive chat session';
10
+ flags: Flag[] = [
11
+ { name: 'provider', description: 'AI Provider to use', type: 'string' },
12
+ { name: 'model', description: 'Model to use', type: 'string' },
13
+ { name: 'system', description: 'System prompt', type: 'string' }
14
+ ];
15
+
16
+ async execute(args: string[], flags: Record<string, string>): Promise<void> {
17
+ const apiKey = process.env.GROQ_API_KEY;
18
+ if (!apiKey) {
19
+ error('No API key configured. Please set the GROQ_API_KEY environment variable.');
20
+ return;
21
+ }
22
+
23
+ info('Starting AstriveAI chat session...');
24
+ if (flags.provider) info(`Provider: ${flags.provider}`);
25
+ if (flags.model) info(`Model: ${flags.model}`);
26
+
27
+ info(dim('Type "exit" or "quit" to stop.'));
28
+
29
+ const config: AstriveConfig = {
30
+ providers: {
31
+ groq: { apiKey }
32
+ },
33
+ logger: {
34
+ level: 'info',
35
+ prefix: 'Astrive',
36
+ colors: true,
37
+ timestamp: true
38
+ },
39
+ systemPrompt: flags.system
40
+ };
41
+
42
+ const agent = new AstriveAI(config);
43
+ try {
44
+ await agent.init();
45
+ } catch (e: any) {
46
+ error(`Failed to initialize agent: ${e.message}`);
47
+ return;
48
+ }
49
+
50
+ const rl = readline.createInterface({
51
+ input: process.stdin as any,
52
+ output: process.stdout as any
53
+ });
54
+
55
+ const providerName = flags.provider || 'groq';
56
+ const modelName = flags.model || 'llama-3.3-70b-versatile';
57
+
58
+ const ask = () => {
59
+ rl.question(bold('You: '), async (input) => {
60
+ const trimmed = input.trim();
61
+ if (trimmed.toLowerCase() === 'exit' || trimmed.toLowerCase() === 'quit') {
62
+ rl.close();
63
+ return;
64
+ }
65
+
66
+ if (!trimmed) {
67
+ ask();
68
+ return;
69
+ }
70
+
71
+ const spinner = new Spinner();
72
+ spinner.start('Thinking...');
73
+ try {
74
+ const response = await agent.chat({ message: trimmed }, { provider: providerName, model: modelName });
75
+ spinner.stop();
76
+ console.log(`${bold('Astrive:')} ${response.content}`);
77
+ } catch (err: any) {
78
+ spinner.fail('Error generating response');
79
+ error(err.message);
80
+ }
81
+ ask();
82
+ });
83
+ };
84
+
85
+ ask();
86
+
87
+ return new Promise((resolve) => {
88
+ rl.on('close', () => {
89
+ info('Chat session ended.');
90
+ agent.destroy().catch(() => {}).finally(() => resolve());
91
+ });
92
+ });
93
+ }
94
+ }
@@ -0,0 +1,61 @@
1
+ import { Command } from '../cli.js';
2
+ import { info, success, error, dim } from '../ui.js';
3
+ import * as fs from 'fs';
4
+ import * as path from 'path';
5
+ import { spawn, ChildProcess } from 'child_process';
6
+
7
+ export class DevCommand implements Command {
8
+ name = 'dev';
9
+ description = 'Start development server with hot reload';
10
+
11
+ async execute(args: string[], flags: Record<string, string>): Promise<void> {
12
+ const cwd = process.cwd();
13
+ const entryFile = path.join(cwd, 'src', 'index.ts');
14
+
15
+ try {
16
+ await fs.promises.access(entryFile);
17
+ } catch {
18
+ error(`Entry file not found: ${entryFile}`);
19
+ return;
20
+ }
21
+
22
+ info(`Starting dev server for ${entryFile}`);
23
+ info(dim('Watching for file changes...'));
24
+
25
+ let child: ChildProcess | null = null;
26
+
27
+ const startServer = () => {
28
+ if (child) {
29
+ child.kill();
30
+ }
31
+
32
+ // We assume ts-node or similar is installed in the user's project,
33
+ // or we just use node if it's compiled. For dev we might use node with loader.
34
+ child = spawn('node', ['--loader', 'ts-node/esm', entryFile], {
35
+ stdio: 'inherit'
36
+ });
37
+
38
+ child.on('error', (err) => {
39
+ error(`Failed to start process: ${err.message}`);
40
+ });
41
+ };
42
+
43
+ startServer();
44
+
45
+ let debounceTimer: NodeJS.Timeout | null = null;
46
+
47
+ // Watch src directory
48
+ fs.watch(path.join(cwd, 'src'), { recursive: true }, (eventType, filename) => {
49
+ if (filename && filename.endsWith('.ts')) {
50
+ if (debounceTimer) clearTimeout(debounceTimer);
51
+ debounceTimer = setTimeout(() => {
52
+ info(`\nFile changed: ${filename}. Restarting...`);
53
+ startServer();
54
+ }, 300);
55
+ }
56
+ });
57
+
58
+ // Keep process alive
59
+ return new Promise(() => {});
60
+ }
61
+ }
@@ -0,0 +1,50 @@
1
+ import { Command } from '../cli.js';
2
+ import { success, error, info, table, Spinner } from '../ui.js';
3
+ import * as fs from 'fs/promises';
4
+ import * as path from 'path';
5
+
6
+ export class DoctorCommand implements Command {
7
+ name = 'doctor';
8
+ description = 'Check system configuration and dependencies';
9
+
10
+ async execute(args: string[], flags: Record<string, string>): Promise<void> {
11
+ info('Running AstriveAI System Checks...');
12
+ const results: string[][] = [['Check', 'Status', 'Message']];
13
+
14
+ // Node.js Version
15
+ const nodeVersion = process.version;
16
+ const isNodeValid = parseInt(nodeVersion.slice(1).split('.')[0]) >= 18;
17
+ results.push([
18
+ 'Node.js',
19
+ isNodeValid ? '✔' : '✖',
20
+ `Found ${nodeVersion} (Requires >= 18)`
21
+ ]);
22
+
23
+ // Check .env
24
+ const cwd = process.cwd();
25
+ try {
26
+ await fs.access(path.join(cwd, '.env'));
27
+ results.push(['.env File', '✔', 'Found']);
28
+ } catch {
29
+ results.push(['.env File', '✖', 'Not found']);
30
+ }
31
+
32
+ // Check astrive.config.js
33
+ try {
34
+ await fs.access(path.join(cwd, 'astrive.config.js'));
35
+ results.push(['Config', '✔', 'astrive.config.js found']);
36
+ } catch {
37
+ results.push(['Config', '✖', 'astrive.config.js not found']);
38
+ }
39
+
40
+ console.log();
41
+ table(['Check', 'Status', 'Message'], results.slice(1));
42
+ console.log();
43
+
44
+ if (results.some(r => r[1] === '✖')) {
45
+ error('Some checks failed. Please fix the issues above.');
46
+ } else {
47
+ success('All systems go!');
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,64 @@
1
+ import { Command, Flag } from '../cli.js';
2
+ import { success, info, Spinner } from '../ui.js';
3
+ import * as fs from 'fs/promises';
4
+ import * as path from 'path';
5
+
6
+ export class InitCommand implements Command {
7
+ name = 'init';
8
+ description = 'Initialize a new AstriveAI project';
9
+
10
+ async execute(args: string[], flags: Record<string, string>): Promise<void> {
11
+ const spinner = new Spinner();
12
+ spinner.start('Initializing AstriveAI project...');
13
+
14
+ const cwd = process.cwd();
15
+
16
+ const configContent = `// astrive.config.js
17
+ export default {
18
+ provider: 'openai',
19
+ model: 'gpt-4o',
20
+ tools: [],
21
+ plugins: [],
22
+ };
23
+ `;
24
+
25
+ const envContent = `OPENAI_API_KEY=your_openai_api_key_here
26
+ ANTHROPIC_API_KEY=your_anthropic_api_key_here
27
+ `;
28
+
29
+ const srcDir = path.join(cwd, 'src');
30
+ const indexContent = `import { Agent } from '@astrive-ai/agent';
31
+
32
+ async function main() {
33
+ const agent = new Agent();
34
+ const response = await agent.run('Hello AstriveAI!');
35
+ console.log(response);
36
+ }
37
+
38
+ main().catch(console.error);
39
+ `;
40
+
41
+ try {
42
+ await fs.writeFile(path.join(cwd, 'astrive.config.js'), configContent);
43
+ await fs.writeFile(path.join(cwd, '.env'), envContent);
44
+
45
+ try {
46
+ await fs.mkdir(srcDir);
47
+ } catch (e: any) {
48
+ if (e.code !== 'EEXIST') throw e;
49
+ }
50
+
51
+ await fs.writeFile(path.join(srcDir, 'index.ts'), indexContent);
52
+
53
+ spinner.succeed('Project initialized successfully!');
54
+
55
+ info('Next steps:');
56
+ info('1. Update your .env file with your API keys');
57
+ info('2. Run "npm install @astrive-ai/agent @astrive-ai/types @astrive-ai/tools @astrive-ai/providers"');
58
+ info('3. Run "astrive dev" to start development');
59
+ } catch (err: any) {
60
+ spinner.fail('Failed to initialize project');
61
+ throw err;
62
+ }
63
+ }
64
+ }
@@ -0,0 +1,28 @@
1
+ import { Command } from '../cli.js';
2
+ import { info, bold, error } from '../ui.js';
3
+ import * as path from 'path';
4
+
5
+ export class InspectCommand implements Command {
6
+ name = 'inspect';
7
+ description = 'Inspect agent configuration';
8
+
9
+ async execute(args: string[], flags: Record<string, string>): Promise<void> {
10
+ info('Inspecting AstriveAI configuration...');
11
+ const cwd = process.cwd();
12
+ const configPath = path.join(cwd, 'astrive.config.js');
13
+
14
+ try {
15
+ const configUrl = `file://${configPath}`;
16
+ const config = (await import(configUrl)).default;
17
+
18
+ console.log();
19
+ console.log(bold('Configuration Object:'));
20
+ console.log(JSON.stringify(config, null, 2));
21
+ console.log();
22
+
23
+ } catch (err: any) {
24
+ error(`Could not load astrive.config.js from ${configPath}`);
25
+ info(err.message);
26
+ }
27
+ }
28
+ }