@neuvybe/jarvis 0.1.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.
- package/dist/index.js +183 -0
- package/package.json +34 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
|
|
6
|
+
// ../../packages/shared/dist/logger.js
|
|
7
|
+
var ORDER = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
8
|
+
function formatMeta(meta) {
|
|
9
|
+
try {
|
|
10
|
+
return JSON.stringify(meta, (_key, value) => {
|
|
11
|
+
if (value instanceof Error) {
|
|
12
|
+
return { name: value.name, message: value.message, stack: value.stack };
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
});
|
|
16
|
+
} catch {
|
|
17
|
+
return "[unserializable meta]";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
var Logger = class {
|
|
21
|
+
level;
|
|
22
|
+
constructor(level = "info") {
|
|
23
|
+
this.level = level;
|
|
24
|
+
}
|
|
25
|
+
setLevel(level) {
|
|
26
|
+
this.level = level;
|
|
27
|
+
}
|
|
28
|
+
getLevel() {
|
|
29
|
+
return this.level;
|
|
30
|
+
}
|
|
31
|
+
debug(message, meta) {
|
|
32
|
+
this.emit("debug", message, meta);
|
|
33
|
+
}
|
|
34
|
+
info(message, meta) {
|
|
35
|
+
this.emit("info", message, meta);
|
|
36
|
+
}
|
|
37
|
+
warn(message, meta) {
|
|
38
|
+
this.emit("warn", message, meta);
|
|
39
|
+
}
|
|
40
|
+
error(message, meta) {
|
|
41
|
+
this.emit("error", message, meta);
|
|
42
|
+
}
|
|
43
|
+
emit(level, message, meta) {
|
|
44
|
+
if (ORDER[level] < ORDER[this.level])
|
|
45
|
+
return;
|
|
46
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
47
|
+
const tag = `[${ts}] ${level.toUpperCase()}`;
|
|
48
|
+
const line = meta !== void 0 ? `${tag} ${message} ${formatMeta(meta)}` : `${tag} ${message}`;
|
|
49
|
+
if (level === "error") {
|
|
50
|
+
console.error(line);
|
|
51
|
+
} else if (level === "warn") {
|
|
52
|
+
console.warn(line);
|
|
53
|
+
} else {
|
|
54
|
+
console.log(line);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var logger = new Logger();
|
|
59
|
+
|
|
60
|
+
// src/index.ts
|
|
61
|
+
var COMMANDS = [
|
|
62
|
+
"init",
|
|
63
|
+
"start",
|
|
64
|
+
"stop",
|
|
65
|
+
"restart",
|
|
66
|
+
"status",
|
|
67
|
+
"doctor",
|
|
68
|
+
"devices",
|
|
69
|
+
"upgrade",
|
|
70
|
+
"config"
|
|
71
|
+
];
|
|
72
|
+
var USAGE = `jarvis - voice-first personal agent
|
|
73
|
+
|
|
74
|
+
Usage:
|
|
75
|
+
jarvis [options] Start a Jarvis session (primary activation)
|
|
76
|
+
jarvis <command> [options]
|
|
77
|
+
|
|
78
|
+
Commands:
|
|
79
|
+
init First-run setup
|
|
80
|
+
start Start the local core service
|
|
81
|
+
stop Stop the local core service
|
|
82
|
+
restart Restart the local core service
|
|
83
|
+
status Show service/core/config status
|
|
84
|
+
doctor Run diagnostics
|
|
85
|
+
devices List audio devices
|
|
86
|
+
upgrade Upgrade the installed CLI/core
|
|
87
|
+
config Inspect/edit configuration
|
|
88
|
+
|
|
89
|
+
Options:
|
|
90
|
+
--log-level <debug|info|warn|error> Set log verbosity
|
|
91
|
+
--project <path> Approved project scope (default: cwd)
|
|
92
|
+
--text, --no-voice Force text-only operation
|
|
93
|
+
-h, --help Print usage
|
|
94
|
+
-v, --version Print version
|
|
95
|
+
`;
|
|
96
|
+
function readVersion() {
|
|
97
|
+
try {
|
|
98
|
+
const raw = readFileSync(new URL("../package.json", import.meta.url), "utf8");
|
|
99
|
+
const parsed = JSON.parse(raw);
|
|
100
|
+
return typeof parsed.version === "string" ? parsed.version : "0.0.0";
|
|
101
|
+
} catch {
|
|
102
|
+
return "0.0.0";
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function isLogLevel(value) {
|
|
106
|
+
return value === "debug" || value === "info" || value === "warn" || value === "error";
|
|
107
|
+
}
|
|
108
|
+
var STUB_MESSAGES = {
|
|
109
|
+
init: "initializing...",
|
|
110
|
+
start: "starting...",
|
|
111
|
+
stop: "stopping...",
|
|
112
|
+
restart: "restarting...",
|
|
113
|
+
status: "status: not implemented yet",
|
|
114
|
+
doctor: "running diagnostics...",
|
|
115
|
+
devices: "listing devices...",
|
|
116
|
+
upgrade: "checking for upgrades...",
|
|
117
|
+
config: "config: not implemented yet"
|
|
118
|
+
};
|
|
119
|
+
function run(argv) {
|
|
120
|
+
let command;
|
|
121
|
+
let project;
|
|
122
|
+
let textOnly = false;
|
|
123
|
+
let wantHelp = false;
|
|
124
|
+
let wantVersion = false;
|
|
125
|
+
for (let i = 0; i < argv.length; i++) {
|
|
126
|
+
const arg = argv[i];
|
|
127
|
+
if (arg === "-h" || arg === "--help") {
|
|
128
|
+
wantHelp = true;
|
|
129
|
+
} else if (arg === "-v" || arg === "--version") {
|
|
130
|
+
wantVersion = true;
|
|
131
|
+
} else if (arg === "--text" || arg === "--no-voice") {
|
|
132
|
+
textOnly = true;
|
|
133
|
+
} else if (arg === "--log-level") {
|
|
134
|
+
const value = argv[++i];
|
|
135
|
+
if (value === void 0 || !isLogLevel(value)) {
|
|
136
|
+
process.stderr.write("error: --log-level expects one of debug|info|warn|error\n");
|
|
137
|
+
return 1;
|
|
138
|
+
}
|
|
139
|
+
logger.setLevel(value);
|
|
140
|
+
} else if (arg === "--project") {
|
|
141
|
+
const value = argv[++i];
|
|
142
|
+
if (value === void 0) {
|
|
143
|
+
process.stderr.write("error: --project expects a path\n");
|
|
144
|
+
return 1;
|
|
145
|
+
}
|
|
146
|
+
project = value;
|
|
147
|
+
} else if (arg.startsWith("-")) {
|
|
148
|
+
process.stderr.write(`error: unknown option '${arg}'
|
|
149
|
+
|
|
150
|
+
${USAGE}`);
|
|
151
|
+
return 1;
|
|
152
|
+
} else if (command === void 0) {
|
|
153
|
+
command = arg;
|
|
154
|
+
} else {
|
|
155
|
+
process.stderr.write(`error: unexpected argument '${arg}'
|
|
156
|
+
|
|
157
|
+
${USAGE}`);
|
|
158
|
+
return 1;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (wantVersion) {
|
|
162
|
+
process.stdout.write(`${readVersion()}
|
|
163
|
+
`);
|
|
164
|
+
return 0;
|
|
165
|
+
}
|
|
166
|
+
if (wantHelp) {
|
|
167
|
+
process.stdout.write(USAGE);
|
|
168
|
+
return 0;
|
|
169
|
+
}
|
|
170
|
+
if (command === void 0) {
|
|
171
|
+
logger.info("activating...", { project: project ?? process.cwd(), textOnly });
|
|
172
|
+
return 0;
|
|
173
|
+
}
|
|
174
|
+
if (!COMMANDS.includes(command)) {
|
|
175
|
+
process.stderr.write(`error: unknown command '${command}'
|
|
176
|
+
|
|
177
|
+
${USAGE}`);
|
|
178
|
+
return 1;
|
|
179
|
+
}
|
|
180
|
+
logger.info(STUB_MESSAGES[command]);
|
|
181
|
+
return 0;
|
|
182
|
+
}
|
|
183
|
+
process.exitCode = run(process.argv.slice(2));
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@neuvybe/jarvis",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Jarvis - a voice-first personal agent (CLI).",
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"homepage": "https://github.com/neuvybe/jarvis#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/neuvybe/jarvis/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/neuvybe/jarvis.git",
|
|
15
|
+
"directory": "apps/cli"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"jarvis": "dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"main": "dist/index.js",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"dev": "tsx --conditions=development --env-file-if-exists=../../.env watch src/index.ts",
|
|
29
|
+
"start": "tsx --conditions=development --env-file-if-exists=../../.env src/index.ts",
|
|
30
|
+
"build": "tsc -b",
|
|
31
|
+
"bundle": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.js",
|
|
32
|
+
"clean": "tsc -b --clean"
|
|
33
|
+
}
|
|
34
|
+
}
|