@crewx/cli 0.9.0-rc.146 → 0.9.0-rc.147
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/bootstrap/codex-writable-roots.js +1 -113
- package/dist/bootstrap/crewx-cli.js +1 -84
- package/dist/builtin.js +5 -132
- package/dist/commands/agent.js +4 -118
- package/dist/commands/cal.js +2 -44
- package/dist/commands/db.js +4 -602
- package/dist/commands/detached.js +15 -620
- package/dist/commands/doctor.js +4 -649
- package/dist/commands/emit-trailer.js +2 -33
- package/dist/commands/execute.js +15 -294
- package/dist/commands/hook/command-marker.js +1 -5
- package/dist/commands/hook/install.js +8 -189
- package/dist/commands/hook/paths.js +1 -94
- package/dist/commands/hook/status.js +1 -86
- package/dist/commands/hook/uninstall.js +1 -71
- package/dist/commands/hook-dispatch.js +2 -180
- package/dist/commands/init.js +31 -437
- package/dist/commands/kill.js +1 -11
- package/dist/commands/log.js +3 -96
- package/dist/commands/parse-agent-message.js +1 -52
- package/dist/commands/parse-common-flags.js +3 -212
- package/dist/commands/ps.js +2 -117
- package/dist/commands/publish.js +7 -283
- package/dist/commands/query.js +16 -292
- package/dist/commands/registry.js +1 -33
- package/dist/commands/resolve-prompt.js +3 -76
- package/dist/commands/resolve-recipient.js +3 -47
- package/dist/commands/restart.js +18 -172
- package/dist/commands/result.js +1 -209
- package/dist/commands/shortcut.js +4 -253
- package/dist/commands/slack.js +16 -560
- package/dist/commands/stop.js +8 -119
- package/dist/commands/write-output.js +1 -24
- package/dist/index.js +1 -8
- package/dist/logging.js +10 -87
- package/dist/main.js +6 -289
- package/dist/register-builtin-tools.js +1 -9
- package/dist/slack/file-download.js +1 -134
- package/dist/slack/markdown.js +1 -33
- package/dist/utils/env-defaults.js +1 -15
- package/dist/utils/inherited-trace.js +1 -65
- package/dist/utils/product-package-root.js +1 -39
- package/dist/utils/sdk-compat.js +1 -120
- package/dist/utils/version.js +1 -28
- package/package.json +15 -15
|
@@ -1,234 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* crewx shortcut handler — thin CLI wrapper over @crewx/sdk/desktop.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* crewx shortcut status [--json]
|
|
9
|
-
* crewx shortcut install [--force] [--json]
|
|
10
|
-
* crewx shortcut uninstall [--json]
|
|
11
|
-
*
|
|
12
|
-
* All win32/foreign/superseded/force judgment lives in @crewx/sdk/desktop.
|
|
13
|
-
* This module only parses argv, forwards options, and renders the result.
|
|
14
|
-
*/
|
|
15
|
-
const desktop_1 = require("@crewx/sdk/desktop");
|
|
16
|
-
const parse_common_flags_1 = require("./parse-common-flags");
|
|
17
|
-
const NOT_WINDOWS_MESSAGE = 'NOT_WINDOWS: Desktop shortcuts are only supported on Windows.';
|
|
18
|
-
function parseShortcutFlags(args, allowForce) {
|
|
19
|
-
let json = false;
|
|
20
|
-
let force = false;
|
|
21
|
-
for (const arg of args) {
|
|
22
|
-
if (arg === '--json') {
|
|
23
|
-
json = true;
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
if (arg === '--force' && allowForce) {
|
|
27
|
-
force = true;
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
throw new parse_common_flags_1.UnknownOptionError(`Unknown option: ${arg}`);
|
|
31
|
-
}
|
|
32
|
-
return { json, force };
|
|
33
|
-
}
|
|
34
|
-
/** Forwarded verbatim to stderr as each SDK phase starts — never buffered. */
|
|
35
|
-
function onProgress(event) {
|
|
36
|
-
process.stderr.write(`[shortcut] ${event.message}\n`);
|
|
37
|
-
}
|
|
38
|
-
function printJson(payload) {
|
|
39
|
-
console.log(JSON.stringify(payload));
|
|
40
|
-
}
|
|
41
|
-
/** Prints the error and exits 1. Never returns (matches `process.exit`'s `never` type). */
|
|
42
|
-
function failWithError(err, json) {
|
|
43
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
44
|
-
if (json) {
|
|
45
|
-
printJson({ success: false, error: message });
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
console.error(`✗ ${message}`);
|
|
49
|
-
}
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
/** The SDK returns `supported:false` (no throw) for install/uninstall on non-Windows. */
|
|
53
|
-
function failNotWindows(json) {
|
|
54
|
-
if (json) {
|
|
55
|
-
printJson({ success: false, supported: false, state: 'unsupported', error: NOT_WINDOWS_MESSAGE });
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
console.error(`✗ ${NOT_WINDOWS_MESSAGE}`);
|
|
59
|
-
}
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Detects the two ways a resolved (non-thrown) install result must NOT be
|
|
64
|
-
* read as success: a `superseded` shortcut (checked via both `state` and the
|
|
65
|
-
* `errors[]` entry, since either alone could otherwise be missed) and an
|
|
66
|
-
* unconfirmed global install (`installedGlobal:false` with
|
|
67
|
-
* `GLOBAL_INSTALL_UNCONFIRMED` in errors — npm exited 0 but re-detection
|
|
68
|
-
* could not confirm it).
|
|
69
|
-
*/
|
|
70
|
-
function installFailureReason(result) {
|
|
71
|
-
const supersededError = result.errors.find((e) => e.startsWith('SUPERSEDED:'));
|
|
72
|
-
if (result.state === 'superseded' || supersededError) {
|
|
73
|
-
return supersededError ?? 'Installed shortcut belongs to a newer CrewX version; refusing to modify it.';
|
|
74
|
-
}
|
|
75
|
-
const unconfirmedError = result.errors.find((e) => e.startsWith('GLOBAL_INSTALL_UNCONFIRMED:'));
|
|
76
|
-
if (!result.installedGlobal && unconfirmedError) {
|
|
77
|
-
return unconfirmedError;
|
|
78
|
-
}
|
|
79
|
-
if (result.errors.length > 0) {
|
|
80
|
-
return result.errors[0];
|
|
81
|
-
}
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Only these two re-detected states mean the Desktop truly has no CrewX
|
|
86
|
-
* shortcut left. Everything else — `foreign`/`superseded` (SDK refused to
|
|
87
|
-
* touch it) and `installed`/`stale` (the `.lnk` unlink threw and was
|
|
88
|
-
* swallowed as "already gone" — install.ts `uninstallShortcut`) — means the
|
|
89
|
-
* file is still on disk. A success ALLOWLIST is used instead of enumerating
|
|
90
|
-
* failure states so an unlink failure (EPERM/EBUSY/locked/AV hook) that
|
|
91
|
-
* re-detects back to `installed` fails closed by construction, rather than
|
|
92
|
-
* requiring every new failure path to be added to an exclusion list.
|
|
93
|
-
*/
|
|
94
|
-
const UNINSTALL_SUCCESS_STATES = new Set(['declined', 'not-installed']);
|
|
95
|
-
function uninstallFailureReason(result) {
|
|
96
|
-
if (UNINSTALL_SUCCESS_STATES.has(result.state)) {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
const supersededError = result.errors.find((e) => e.startsWith('SUPERSEDED:'));
|
|
100
|
-
if (result.state === 'superseded' || supersededError) {
|
|
101
|
-
return supersededError ?? 'Installed shortcut belongs to a newer CrewX version; nothing was removed.';
|
|
102
|
-
}
|
|
103
|
-
if (result.state === 'foreign') {
|
|
104
|
-
const nsisError = result.errors.find((e) => e.startsWith('NSIS_PRESENT:'));
|
|
105
|
-
return nsisError ?? 'Existing Desktop shortcut is not managed by CrewX; nothing was removed.';
|
|
106
|
-
}
|
|
107
|
-
if (result.errors.length > 0) {
|
|
108
|
-
return result.errors[0];
|
|
109
|
-
}
|
|
110
|
-
return `CrewX desktop shortcut could not be removed (state: ${result.state}).`;
|
|
111
|
-
}
|
|
112
|
-
function printStatusHuman(status) {
|
|
113
|
-
switch (status.state) {
|
|
114
|
-
case 'unsupported':
|
|
115
|
-
console.log('Desktop shortcuts are only supported on Windows.');
|
|
116
|
-
break;
|
|
117
|
-
case 'not-installed':
|
|
118
|
-
console.log('No CrewX desktop shortcut installed yet.');
|
|
119
|
-
console.log('Run `crewx shortcut install` to create one.');
|
|
120
|
-
break;
|
|
121
|
-
case 'declined':
|
|
122
|
-
console.log('CrewX desktop shortcut setup was previously dismissed.');
|
|
123
|
-
console.log('Run `crewx shortcut install` to create one.');
|
|
124
|
-
break;
|
|
125
|
-
case 'installed':
|
|
126
|
-
console.log('✓ CrewX desktop shortcut is installed and up to date.');
|
|
127
|
-
if (status.shortcutPath)
|
|
128
|
-
console.log(` Shortcut: ${status.shortcutPath}`);
|
|
129
|
-
break;
|
|
130
|
-
case 'stale':
|
|
131
|
-
console.log('⚠ CrewX desktop shortcut needs an update.');
|
|
132
|
-
console.log('Run `crewx shortcut install` to refresh it.');
|
|
133
|
-
break;
|
|
134
|
-
case 'foreign':
|
|
135
|
-
console.log('⚠ A Desktop shortcut exists that CrewX does not manage.');
|
|
136
|
-
console.log('Run `crewx shortcut install --force` to replace it.');
|
|
137
|
-
break;
|
|
138
|
-
case 'superseded':
|
|
139
|
-
console.log('⚠ The installed shortcut belongs to a newer CrewX version than the one running.');
|
|
140
|
-
console.log('Update CrewX before touching the shortcut.');
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
for (const e of status.errors) {
|
|
144
|
-
console.log(` note: ${e}`);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
async function runStatus(args) {
|
|
148
|
-
const { json } = parseShortcutFlags(args, false);
|
|
149
|
-
let status;
|
|
150
|
-
try {
|
|
151
|
-
status = await (0, desktop_1.getShortcutStatus)();
|
|
152
|
-
}
|
|
153
|
-
catch (err) {
|
|
154
|
-
failWithError(err, json);
|
|
155
|
-
}
|
|
156
|
-
if (json) {
|
|
157
|
-
printJson(status);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
printStatusHuman(status);
|
|
161
|
-
}
|
|
162
|
-
async function runInstall(args) {
|
|
163
|
-
const { json, force } = parseShortcutFlags(args, true);
|
|
164
|
-
let result;
|
|
165
|
-
try {
|
|
166
|
-
result = await (0, desktop_1.installShortcut)({ force, onProgress });
|
|
167
|
-
}
|
|
168
|
-
catch (err) {
|
|
169
|
-
failWithError(err, json);
|
|
170
|
-
}
|
|
171
|
-
if (!result.supported) {
|
|
172
|
-
failNotWindows(json);
|
|
173
|
-
}
|
|
174
|
-
const failure = installFailureReason(result);
|
|
175
|
-
if (failure) {
|
|
176
|
-
if (json) {
|
|
177
|
-
printJson({ ...result, success: false });
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
console.error(`✗ ${failure}`);
|
|
181
|
-
}
|
|
182
|
-
process.exit(1);
|
|
183
|
-
}
|
|
184
|
-
if (json) {
|
|
185
|
-
printJson({ ...result, success: true });
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
if (result.changed) {
|
|
189
|
-
console.log('✓ CrewX desktop shortcut installed. Double-click "CrewX" on your Desktop to launch it.');
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
console.log('✓ CrewX desktop shortcut is already up to date. Double-click "CrewX" on your Desktop to launch it.');
|
|
193
|
-
}
|
|
194
|
-
if (result.shortcutPath)
|
|
195
|
-
console.log(` Shortcut: ${result.shortcutPath}`);
|
|
196
|
-
}
|
|
197
|
-
async function runUninstall(args) {
|
|
198
|
-
const { json } = parseShortcutFlags(args, false);
|
|
199
|
-
let result;
|
|
200
|
-
try {
|
|
201
|
-
result = await (0, desktop_1.uninstallShortcut)();
|
|
202
|
-
}
|
|
203
|
-
catch (err) {
|
|
204
|
-
failWithError(err, json);
|
|
205
|
-
}
|
|
206
|
-
if (!result.supported) {
|
|
207
|
-
failNotWindows(json);
|
|
208
|
-
}
|
|
209
|
-
const failure = uninstallFailureReason(result);
|
|
210
|
-
if (failure) {
|
|
211
|
-
if (json) {
|
|
212
|
-
printJson({ ...result, success: false });
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
console.error(`✗ ${failure}`);
|
|
216
|
-
for (const e of result.errors) {
|
|
217
|
-
if (e !== failure)
|
|
218
|
-
console.error(` note: ${e}`);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
process.exit(1);
|
|
222
|
-
}
|
|
223
|
-
if (json) {
|
|
224
|
-
printJson({ ...result, success: true });
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
console.log('✓ CrewX desktop shortcut removed.');
|
|
228
|
-
}
|
|
229
|
-
function printHelp() {
|
|
230
|
-
console.log(`
|
|
231
|
-
crewx shortcut — manage the Windows Desktop shortcut for CrewX
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.handleShortcut=b;const c=require("@crewx/sdk/desktop");const h=require("./parse-common-flags");const i="NOT_WINDOWS: Desktop shortcuts are only supported on Windows.";function a(e,t){let o=false;let s=false;for(const r of e){if(r==="--json"){o=true;continue}if(r==="--force"&&t){s=true;continue}throw new h.UnknownOptionError(`Unknown option: ${r}`)}return{json:o,force:s}}function f(e){process.stderr.write(`[shortcut] ${e.message}
|
|
2
|
+
`)}function n(e){console.log(JSON.stringify(e))}function l(e,t){const o=e instanceof Error?e.message:String(e);if(t){n({success:false,error:o})}else{console.error(`\u2717 ${o}`)}process.exit(1)}function u(e){if(e){n({success:false,supported:false,state:"unsupported",error:i})}else{console.error(`\u2717 ${i}`)}process.exit(1)}function p(e){const t=e.errors.find(s=>s.startsWith("SUPERSEDED:"));if(e.state==="superseded"||t){return t??"Installed shortcut belongs to a newer CrewX version; refusing to modify it."}const o=e.errors.find(s=>s.startsWith("GLOBAL_INSTALL_UNCONFIRMED:"));if(!e.installedGlobal&&o){return o}if(e.errors.length>0){return e.errors[0]}return null}const w=new Set(["declined","not-installed"]);function g(e){if(w.has(e.state)){return null}const t=e.errors.find(o=>o.startsWith("SUPERSEDED:"));if(e.state==="superseded"||t){return t??"Installed shortcut belongs to a newer CrewX version; nothing was removed."}if(e.state==="foreign"){const o=e.errors.find(s=>s.startsWith("NSIS_PRESENT:"));return o??"Existing Desktop shortcut is not managed by CrewX; nothing was removed."}if(e.errors.length>0){return e.errors[0]}return`CrewX desktop shortcut could not be removed (state: ${e.state}).`}function S(e){switch(e.state){case"unsupported":console.log("Desktop shortcuts are only supported on Windows.");break;case"not-installed":console.log("No CrewX desktop shortcut installed yet.");console.log("Run `crewx shortcut install` to create one.");break;case"declined":console.log("CrewX desktop shortcut setup was previously dismissed.");console.log("Run `crewx shortcut install` to create one.");break;case"installed":console.log("\u2713 CrewX desktop shortcut is installed and up to date.");if(e.shortcutPath)console.log(` Shortcut: ${e.shortcutPath}`);break;case"stale":console.log("\u26A0 CrewX desktop shortcut needs an update.");console.log("Run `crewx shortcut install` to refresh it.");break;case"foreign":console.log("\u26A0 A Desktop shortcut exists that CrewX does not manage.");console.log("Run `crewx shortcut install --force` to replace it.");break;case"superseded":console.log("\u26A0 The installed shortcut belongs to a newer CrewX version than the one running.");console.log("Update CrewX before touching the shortcut.");break}for(const t of e.errors){console.log(` note: ${t}`)}}async function k(e){const{json:t}=a(e,false);let o;try{o=await(0,c.getShortcutStatus)()}catch(s){l(s,t)}if(t){n(o);return}S(o)}async function m(e){const{json:t,force:o}=a(e,true);let s;try{s=await(0,c.installShortcut)({force:o,onProgress:f})}catch(d){l(d,t)}if(!s.supported){u(t)}const r=p(s);if(r){if(t){n({...s,success:false})}else{console.error(`\u2717 ${r}`)}process.exit(1)}if(t){n({...s,success:true});return}if(s.changed){console.log('\u2713 CrewX desktop shortcut installed. Double-click "CrewX" on your Desktop to launch it.')}else{console.log('\u2713 CrewX desktop shortcut is already up to date. Double-click "CrewX" on your Desktop to launch it.')}if(s.shortcutPath)console.log(` Shortcut: ${s.shortcutPath}`)}async function y(e){const{json:t}=a(e,false);let o;try{o=await(0,c.uninstallShortcut)()}catch(r){l(r,t)}if(!o.supported){u(t)}const s=g(o);if(s){if(t){n({...o,success:false})}else{console.error(`\u2717 ${s}`);for(const r of o.errors){if(r!==s)console.error(` note: ${r}`)}}process.exit(1)}if(t){n({...o,success:true});return}console.log("\u2713 CrewX desktop shortcut removed.")}function C(){console.log(`
|
|
3
|
+
crewx shortcut \u2014 manage the Windows Desktop shortcut for CrewX
|
|
232
4
|
|
|
233
5
|
Usage:
|
|
234
6
|
crewx shortcut status [--json]
|
|
@@ -243,25 +15,4 @@ Options:
|
|
|
243
15
|
Notes:
|
|
244
16
|
Windows only. On macOS/Linux, \`status\` reports state "unsupported" (exit 0);
|
|
245
17
|
\`install\`/\`uninstall\` exit 1 with no changes made.
|
|
246
|
-
`.trim());
|
|
247
|
-
}
|
|
248
|
-
async function handleShortcut(args) {
|
|
249
|
-
const subcommand = args[0];
|
|
250
|
-
if (!subcommand || subcommand === 'help' || subcommand === '--help' || subcommand === '-h') {
|
|
251
|
-
printHelp();
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
const rest = args.slice(1);
|
|
255
|
-
switch (subcommand) {
|
|
256
|
-
case 'status':
|
|
257
|
-
return runStatus(rest);
|
|
258
|
-
case 'install':
|
|
259
|
-
return runInstall(rest);
|
|
260
|
-
case 'uninstall':
|
|
261
|
-
return runUninstall(rest);
|
|
262
|
-
default:
|
|
263
|
-
console.error(`Unknown shortcut subcommand: ${subcommand}`);
|
|
264
|
-
console.error('Run `crewx shortcut help` for usage.');
|
|
265
|
-
process.exit(1);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
18
|
+
`.trim())}async function b(e){const t=e[0];if(!t||t==="help"||t==="--help"||t==="-h"){C();return}const o=e.slice(1);switch(t){case"status":return k(o);case"install":return m(o);case"uninstall":return y(o);default:console.error(`Unknown shortcut subcommand: ${t}`);console.error("Run `crewx shortcut help` for usage.");process.exit(1)}}
|