@sentry/junior 0.203.0 → 0.205.0
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/agent-D4nu8MQV.js +17521 -0
- package/dist/agent-hooks-DXHpTJ4m.js +4042 -0
- package/dist/agent-runner-C04colea.js +678 -0
- package/dist/api/schema.d.ts +2736 -2639
- package/dist/api/schema.js +4 -169
- package/dist/api.d.ts +23 -17
- package/dist/api.js +3881 -5326
- package/dist/app-Cb776lL8.d.ts +247 -0
- package/dist/app.d.ts +4 -520
- package/dist/app.js +9524 -11875
- package/dist/auth-pause-state-C2P3guS1.js +168 -0
- package/dist/catalog-runtime-CXw3asJD.js +7 -0
- package/dist/checkpoint-CrViJ8Ps.js +2450 -0
- package/dist/cli/chat.d.ts +20 -0
- package/dist/cli/chat.js +229 -336
- package/dist/cli/check.d.ts +8 -0
- package/dist/cli/check.js +513 -806
- package/dist/cli/env.d.ts +13 -0
- package/dist/cli/env.js +63 -12
- package/dist/cli/init.d.ts +3 -0
- package/dist/cli/init.js +90 -159
- package/dist/cli/main.d.ts +6 -0
- package/dist/cli/main.js +43 -64
- package/dist/cli/plugins.d.ts +13 -0
- package/dist/cli/plugins.js +148 -227
- package/dist/cli/run.d.ts +16 -0
- package/dist/cli/run.js +52 -8
- package/dist/cli/snapshot-create.d.ts +4 -0
- package/dist/cli/snapshot-create.js +71 -125
- package/dist/cli/upgrade.d.ts +15 -0
- package/dist/cli/upgrade.js +232 -335
- package/dist/config-BOtJQ7Pc.js +941 -0
- package/dist/context-B45_WqVX.js +298 -0
- package/dist/conversation-privacy-BZRA6Pes.js +182 -0
- package/dist/conversation-work-C6y3T5Hx.js +51 -0
- package/dist/credential-sync-Bep34IB_.js +2661 -0
- package/dist/db-BeyXKJOI.d.ts +5 -0
- package/dist/destinations-BeBiJeEM.js +29 -0
- package/dist/execution-stats-B6lgWxCK.js +373 -0
- package/dist/executor-BlUhFL7_.js +721 -0
- package/dist/experimental-CIXf7Uye.js +46 -0
- package/dist/history-ClE4toxe.d.ts +32 -0
- package/dist/history-CqTuSAdI.js +441 -0
- package/dist/instrumentation.d.ts +3 -3
- package/dist/instrumentation.js +130 -176
- package/dist/job-queue-DLMqIK74.js +63 -0
- package/dist/logging-BMJzdDlP.js +1210 -0
- package/dist/model-profile-CZmVoGdX.js +49 -0
- package/dist/nitro.d.ts +31 -36
- package/dist/nitro.js +275 -456
- package/dist/oauth-callback-server-WwG5_Zgm.js +130 -0
- package/dist/oauth-relay-CdCnu80W.js +62 -0
- package/dist/package-discovery-7a9YqLhE.js +455 -0
- package/dist/pending-auth-CUbXq06G.js +185 -0
- package/dist/plugin-module-BKGOXca2.js +81 -0
- package/dist/plugins-BI9A1vKA.d.ts +95 -0
- package/dist/plugins-egKWjgue.js +99 -0
- package/dist/private-trace-result-BLvBjy_e.js +16 -0
- package/dist/profile-T0tXE4zu.js +861 -0
- package/dist/registry-BA0__8ai.js +1419 -0
- package/dist/reporting-schema-DosTN__Q.js +105 -0
- package/dist/resolve-bvD1ORdv.js +546 -0
- package/dist/rolldown-runtime-B4FMCO8f.js +28 -0
- package/dist/runner-BXYxfIUL.js +392 -0
- package/dist/sandbox-egress-signals-ngEPjSEW.js +46 -0
- package/dist/schema-Rn8-XEaN.js +1140 -0
- package/dist/sentry-CD3SdJl-.js +26 -0
- package/dist/skills-DJOlYdBs.js +316 -0
- package/dist/spawn-h0R1bTEo.js +29 -0
- package/dist/stats-3YZn-Swi.js +2648 -0
- package/dist/store-C5qxF2ac.d.ts +208 -0
- package/dist/task-queue-CoXwd2eq.js +136 -0
- package/dist/task-runner-B2_mJZj0.js +639 -0
- package/dist/thread-state-CqZ1m-es.js +431 -0
- package/dist/turn-execution-fI6PZ0iI.js +47 -0
- package/dist/turn-lifecycle-CcnwrOcp.js +54 -0
- package/dist/usage-B5SfMb3H.js +296 -0
- package/dist/usage-schema-CKaDkH_j.js +20 -0
- package/dist/validation-DfWcvhuS.js +40 -0
- package/dist/vercel-queue-DIkVcfK4.js +167 -0
- package/dist/vercel.d.ts +6 -6
- package/dist/vercel.js +14 -6
- package/dist/version-CnXZ614E.d.ts +5 -0
- package/dist/version-oD-oPrbO.js +8 -0
- package/dist/version.d.ts +2 -4
- package/dist/version.js +2 -6
- package/dist/web-authorization-Crbzlmzo.js +76 -0
- package/dist/web-input-BOuq3oKK.js +494 -0
- package/dist/work-B91LQKHr.js +509 -0
- package/dist/worker-BcRRTe6k.js +625 -0
- package/package.json +9 -9
- package/dist/agent-hooks-GB2VPTNA.js +0 -51
- package/dist/catalog-runtime-UBLIWD3O.js +0 -14
- package/dist/chunk-2LYHWMR4.js +0 -46
- package/dist/chunk-352OWAZH.js +0 -320
- package/dist/chunk-3Y47VMHV.js +0 -6
- package/dist/chunk-3YJSKOWF.js +0 -164
- package/dist/chunk-4KSSKTQ5.js +0 -229
- package/dist/chunk-4UO6FK4G.js +0 -64
- package/dist/chunk-5AHX53NQ.js +0 -717
- package/dist/chunk-5J3E5FWA.js +0 -700
- package/dist/chunk-5PDAG6O3.js +0 -206
- package/dist/chunk-6Y5B5PEX.js +0 -80
- package/dist/chunk-7GWQ5S5R.js +0 -2086
- package/dist/chunk-7H2VZTWN.js +0 -103
- package/dist/chunk-7NL7T6VU.js +0 -406
- package/dist/chunk-A5L27LE4.js +0 -387
- package/dist/chunk-ADIAWL34.js +0 -81
- package/dist/chunk-ASTEMBKJ.js +0 -519
- package/dist/chunk-CEMMLV5L.js +0 -98
- package/dist/chunk-CM5HNV2W.js +0 -131
- package/dist/chunk-CRTRBBRI.js +0 -105
- package/dist/chunk-DA2KGZZI.js +0 -13
- package/dist/chunk-DIB4GX3G.js +0 -8
- package/dist/chunk-DKIJ2RP5.js +0 -68
- package/dist/chunk-DWPN6SCH.js +0 -172
- package/dist/chunk-EDKUFGPL.js +0 -64
- package/dist/chunk-ENY6SKIU.js +0 -1228
- package/dist/chunk-F4MGCZOX.js +0 -2943
- package/dist/chunk-FA6POGLH.js +0 -70
- package/dist/chunk-FSUR7GTG.js +0 -20475
- package/dist/chunk-GKEOHJL5.js +0 -1856
- package/dist/chunk-GMCB6W5Y.js +0 -333
- package/dist/chunk-IE2VPG7O.js +0 -1135
- package/dist/chunk-IZ5B5IHQ.js +0 -3656
- package/dist/chunk-JAL3CH4G.js +0 -27
- package/dist/chunk-KIIEUXD3.js +0 -1764
- package/dist/chunk-KXU4NIL7.js +0 -692
- package/dist/chunk-MTM5IFCY.js +0 -1190
- package/dist/chunk-N7TMSOZH.js +0 -235
- package/dist/chunk-NCEBK6PH.js +0 -36
- package/dist/chunk-NHJU2ZAL.js +0 -56
- package/dist/chunk-P6KTRNVC.js +0 -321
- package/dist/chunk-PDO5BLNM.js +0 -22
- package/dist/chunk-PDRNLLFT.js +0 -3295
- package/dist/chunk-PEQXYSSE.js +0 -45
- package/dist/chunk-PKEX2AQX.js +0 -198
- package/dist/chunk-PSJCGIGO.js +0 -1163
- package/dist/chunk-PZUSUL55.js +0 -506
- package/dist/chunk-R45M4TUS.js +0 -37
- package/dist/chunk-RC745GGZ.js +0 -122
- package/dist/chunk-SP3QKZXJ.js +0 -820
- package/dist/chunk-TXKUKMVO.js +0 -417
- package/dist/chunk-UE4GPWSD.js +0 -931
- package/dist/chunk-UIE3R5XU.js +0 -17
- package/dist/chunk-UXPG6ZIN.js +0 -84
- package/dist/chunk-VFUK3X5B.js +0 -50
- package/dist/chunk-VNMJWREK.js +0 -787
- package/dist/chunk-VZ7CSOX2.js +0 -706
- package/dist/chunk-WCNQJKFT.js +0 -10
- package/dist/chunk-WDZR3QQM.js +0 -135
- package/dist/chunk-WLYVJCHV.js +0 -1433
- package/dist/chunk-WS7NAFTM.js +0 -1520
- package/dist/chunk-X6GDDWQH.js +0 -60
- package/dist/chunk-XPDEYNQI.js +0 -102
- package/dist/chunk-XRW44VGM.js +0 -58
- package/dist/chunk-Y2CM7HXH.js +0 -111
- package/dist/chunk-Y7X25LFY.js +0 -15
- package/dist/conversation-work-VIOQ5ZF3.js +0 -54
- package/dist/db-NGDJV7YH.js +0 -26
- package/dist/discovery-DWVDM7UK.js +0 -44
- package/dist/experimental-P5FZM4CU.js +0 -12
- package/dist/oauth-callback-server-YFY7YEGK.js +0 -243
- package/dist/oauth-relay-5XPVRPYB.js +0 -8
- package/dist/plugins-YTYJMMJF.js +0 -14
- package/dist/runner-ORTNSB2Q.js +0 -522
- package/dist/sandbox-egress-signals-FIL7EGPR.js +0 -73
- package/dist/sentry-MB3NL3IR.js +0 -42
- package/dist/skills-H376WQOH.js +0 -27
- package/dist/spawn-T43WHLOS.js +0 -42
- package/dist/task-runner-LBZWF32V.js +0 -36
- package/dist/validation-REJLRKI6.js +0 -17
- package/dist/work-3KJ3RE76.js +0 -51
- package/dist/worker-QFEBU72E.js +0 -24
package/dist/cli/plugins.js
CHANGED
|
@@ -1,249 +1,170 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "../
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
pluginCliRegistrationsFromPluginSet,
|
|
8
|
-
pluginRuntimeRegistrationsFromPluginSet
|
|
9
|
-
} from "../chunk-CM5HNV2W.js";
|
|
10
|
-
import {
|
|
11
|
-
loadAppPluginSet
|
|
12
|
-
} from "../chunk-Y2CM7HXH.js";
|
|
13
|
-
import {
|
|
14
|
-
createPluginLogger,
|
|
15
|
-
setPlugins,
|
|
16
|
-
validatePlugins
|
|
17
|
-
} from "../chunk-IZ5B5IHQ.js";
|
|
18
|
-
import "../chunk-3Y47VMHV.js";
|
|
19
|
-
import {
|
|
20
|
-
getDb
|
|
21
|
-
} from "../chunk-GKEOHJL5.js";
|
|
22
|
-
import "../chunk-IE2VPG7O.js";
|
|
23
|
-
import "../chunk-5AHX53NQ.js";
|
|
24
|
-
import "../chunk-P6KTRNVC.js";
|
|
25
|
-
import "../chunk-7NL7T6VU.js";
|
|
26
|
-
import "../chunk-VFUK3X5B.js";
|
|
27
|
-
import "../chunk-ENY6SKIU.js";
|
|
28
|
-
import "../chunk-NHJU2ZAL.js";
|
|
29
|
-
import "../chunk-PKEX2AQX.js";
|
|
30
|
-
import {
|
|
31
|
-
pluginCatalogRuntime
|
|
32
|
-
} from "../chunk-WCNQJKFT.js";
|
|
33
|
-
import "../chunk-7GWQ5S5R.js";
|
|
34
|
-
import "../chunk-CEMMLV5L.js";
|
|
35
|
-
import "../chunk-N7TMSOZH.js";
|
|
36
|
-
import "../chunk-DWPN6SCH.js";
|
|
37
|
-
import "../chunk-TXKUKMVO.js";
|
|
38
|
-
import "../chunk-WS7NAFTM.js";
|
|
39
|
-
import "../chunk-PEQXYSSE.js";
|
|
40
|
-
import "../chunk-WDZR3QQM.js";
|
|
41
|
-
|
|
42
|
-
// src/cli/plugins.ts
|
|
43
|
-
import { stderr as defaultStderr, stdout as defaultStdout } from "process";
|
|
1
|
+
import { Et as getDb, _t as createPluginLogger, d as setPlugins, f as validatePlugins } from "../agent-hooks-DXHpTJ4m.js";
|
|
2
|
+
import { n as pluginCatalogRuntime } from "../catalog-runtime-CXw3asJD.js";
|
|
3
|
+
import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-DfWcvhuS.js";
|
|
4
|
+
import { a as pluginRuntimeRegistrationsFromPluginSet, i as pluginCliRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "../plugins-egKWjgue.js";
|
|
5
|
+
import { t as loadAppPluginSet } from "../plugin-module-BKGOXca2.js";
|
|
6
|
+
import { stderr, stdout } from "node:process";
|
|
44
7
|
import { createJiti } from "jiti";
|
|
45
8
|
import { Command, CommanderError } from "commander";
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
9
|
+
//#region src/cli/plugins.ts
|
|
10
|
+
/**
|
|
11
|
+
* Plugin CLI bootstrap for the local/package command line.
|
|
12
|
+
* This module imports app plugins, validates top-level namespaces before
|
|
13
|
+
* installing runtime plugin state, and dispatches only plugin-owned subcommands.
|
|
14
|
+
*/
|
|
15
|
+
const pluginCliLoader = createJiti(import.meta.url, { moduleCache: false });
|
|
16
|
+
const CORE_COMMAND_NAMES = /* @__PURE__ */ new Set([
|
|
17
|
+
"chat",
|
|
18
|
+
"check",
|
|
19
|
+
"init",
|
|
20
|
+
"snapshot",
|
|
21
|
+
"upgrade"
|
|
53
22
|
]);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
23
|
+
const PLUGIN_COMMAND_NAME_RE = /^[a-z][a-z0-9-]*$/;
|
|
24
|
+
const DEFAULT_IO = {
|
|
25
|
+
writeError: (text) => writeStream(stderr, text),
|
|
26
|
+
writeOutput: (text) => writeStream(stdout, text)
|
|
58
27
|
};
|
|
59
28
|
function writeStream(stream, text) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
stream.write(text, (error) => {
|
|
31
|
+
if (error) {
|
|
32
|
+
reject(error);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
resolve();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
69
38
|
}
|
|
39
|
+
/** Load the app plugin set once for one CLI process. */
|
|
70
40
|
async function loadCliPluginSet() {
|
|
71
|
-
|
|
72
|
-
process.cwd(),
|
|
73
|
-
async (moduleRef) => pluginCliLoader.import(moduleRef.importPath)
|
|
74
|
-
);
|
|
41
|
+
return await loadAppPluginSet(process.cwd(), async (moduleRef) => pluginCliLoader.import(moduleRef.importPath));
|
|
75
42
|
}
|
|
76
43
|
function findPluginCommand(plugins, commandName) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
return void 0;
|
|
44
|
+
for (const plugin of plugins) {
|
|
45
|
+
const command = plugin.cli?.commands.find((candidate) => candidate.name === commandName);
|
|
46
|
+
if (command) return {
|
|
47
|
+
command,
|
|
48
|
+
plugin
|
|
49
|
+
};
|
|
50
|
+
}
|
|
86
51
|
}
|
|
87
52
|
function createPluginCliHost(args) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
);
|
|
105
|
-
args.setExitCode(result ?? 0);
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
};
|
|
53
|
+
return { action(handler) {
|
|
54
|
+
return async (...actionArgs) => {
|
|
55
|
+
const pluginName = args.plugin.manifest.name;
|
|
56
|
+
const result = await handler({
|
|
57
|
+
db: getDb(),
|
|
58
|
+
command: {
|
|
59
|
+
name: args.command.name,
|
|
60
|
+
summary: args.command.summary
|
|
61
|
+
},
|
|
62
|
+
io: args.io,
|
|
63
|
+
log: createPluginLogger(pluginName),
|
|
64
|
+
plugin: { name: pluginName }
|
|
65
|
+
}, ...actionArgs);
|
|
66
|
+
args.setExitCode(result ?? 0);
|
|
67
|
+
};
|
|
68
|
+
} };
|
|
109
69
|
}
|
|
110
70
|
function createPluginCommanderCommand(args) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
71
|
+
const command = new Command(args.command.name).description(args.command.summary).exitOverride().showHelpAfterError().showSuggestionAfterError().configureOutput({
|
|
72
|
+
writeOut: (text) => {
|
|
73
|
+
args.io.writeOutput(text);
|
|
74
|
+
},
|
|
75
|
+
writeErr: (text) => {
|
|
76
|
+
args.io.writeError(text);
|
|
77
|
+
},
|
|
78
|
+
outputError: (text, write) => {
|
|
79
|
+
write(text);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
args.command.configure(command, createPluginCliHost(args));
|
|
83
|
+
return command;
|
|
124
84
|
}
|
|
125
85
|
function validateConfiguredPluginCommand(args) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
if (args.command.commands.length === 0) {
|
|
133
|
-
throw new Error(
|
|
134
|
-
`Plugin CLI command "${args.definition.name}" from plugin "${pluginName}" must define at least one subcommand`
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
if (args.command.aliases().length > 0) {
|
|
138
|
-
throw new Error(
|
|
139
|
-
`Plugin CLI command "${args.definition.name}" from plugin "${pluginName}" must not define top-level aliases`
|
|
140
|
-
);
|
|
141
|
-
}
|
|
86
|
+
const pluginName = args.plugin.manifest.name;
|
|
87
|
+
if (args.command.name() !== args.definition.name) throw new Error(`Plugin CLI command "${args.definition.name}" from plugin "${pluginName}" must not rename its top-level command`);
|
|
88
|
+
if (args.command.commands.length === 0) throw new Error(`Plugin CLI command "${args.definition.name}" from plugin "${pluginName}" must define at least one subcommand`);
|
|
89
|
+
if (args.command.aliases().length > 0) throw new Error(`Plugin CLI command "${args.definition.name}" from plugin "${pluginName}" must not define top-level aliases`);
|
|
142
90
|
}
|
|
143
91
|
function validateConfiguredPluginCommands(plugins) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
ownerByName.set(definition.name, pluginName);
|
|
166
|
-
if (typeof definition.configure !== "function") {
|
|
167
|
-
throw new Error(
|
|
168
|
-
`Plugin CLI command "${definition.name}" from plugin "${pluginName}" must define a configure function`
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
let exitCode = 0;
|
|
172
|
-
validateConfiguredPluginCommand({
|
|
173
|
-
command: createPluginCommanderCommand({
|
|
174
|
-
command: definition,
|
|
175
|
-
io: validationIo,
|
|
176
|
-
plugin,
|
|
177
|
-
setExitCode: (nextExitCode) => {
|
|
178
|
-
exitCode = nextExitCode;
|
|
179
|
-
}
|
|
180
|
-
}),
|
|
181
|
-
definition,
|
|
182
|
-
plugin
|
|
183
|
-
});
|
|
184
|
-
void exitCode;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
92
|
+
const ownerByName = /* @__PURE__ */ new Map();
|
|
93
|
+
const validationIo = DEFAULT_IO;
|
|
94
|
+
for (const plugin of plugins) for (const definition of plugin.cli?.commands ?? []) {
|
|
95
|
+
const pluginName = plugin.manifest.name;
|
|
96
|
+
const existingOwner = ownerByName.get(definition.name);
|
|
97
|
+
if (!PLUGIN_COMMAND_NAME_RE.test(definition.name)) throw new Error(`Plugin CLI command "${definition.name}" from plugin "${pluginName}" must be a lowercase command identifier`);
|
|
98
|
+
if (CORE_COMMAND_NAMES.has(definition.name)) throw new Error(`Plugin CLI command "${definition.name}" from plugin "${pluginName}" conflicts with a core command`);
|
|
99
|
+
if (existingOwner) throw new Error(`Plugin CLI command "${definition.name}" from plugin "${pluginName}" conflicts with plugin "${existingOwner}"`);
|
|
100
|
+
ownerByName.set(definition.name, pluginName);
|
|
101
|
+
if (typeof definition.configure !== "function") throw new Error(`Plugin CLI command "${definition.name}" from plugin "${pluginName}" must define a configure function`);
|
|
102
|
+
validateConfiguredPluginCommand({
|
|
103
|
+
command: createPluginCommanderCommand({
|
|
104
|
+
command: definition,
|
|
105
|
+
io: validationIo,
|
|
106
|
+
plugin,
|
|
107
|
+
setExitCode: (nextExitCode) => {}
|
|
108
|
+
}),
|
|
109
|
+
definition,
|
|
110
|
+
plugin
|
|
111
|
+
});
|
|
112
|
+
}
|
|
187
113
|
}
|
|
188
114
|
async function loadPluginRegistrations(args) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
115
|
+
const pluginSet = args.pluginSet;
|
|
116
|
+
if (!pluginSet) return {
|
|
117
|
+
cliPlugins: [],
|
|
118
|
+
runtimePlugins: []
|
|
119
|
+
};
|
|
120
|
+
const cliPlugins = pluginCliRegistrationsFromPluginSet(pluginSet);
|
|
121
|
+
const runtimePlugins = pluginRuntimeRegistrationsFromPluginSet(pluginSet);
|
|
122
|
+
const pluginConfig = pluginCatalogConfigFromPluginSet(pluginSet);
|
|
123
|
+
validatePlugins(runtimePlugins);
|
|
124
|
+
const previousPluginCatalogConfig = pluginCatalogRuntime.setConfig(pluginConfig);
|
|
125
|
+
try {
|
|
126
|
+
validatePluginRegistrations(pluginSet.registrations);
|
|
127
|
+
validatePluginEgressCredentialHooks(pluginSet.registrations);
|
|
128
|
+
args.validateConfiguredCommands?.(cliPlugins);
|
|
129
|
+
setPlugins(runtimePlugins);
|
|
130
|
+
return {
|
|
131
|
+
cliPlugins,
|
|
132
|
+
runtimePlugins
|
|
133
|
+
};
|
|
134
|
+
} catch (error) {
|
|
135
|
+
pluginCatalogRuntime.setConfig(previousPluginCatalogConfig);
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
208
138
|
}
|
|
139
|
+
/** Import configured app plugins and build the plugin CLI command dispatcher. */
|
|
209
140
|
async function loadCliPluginCommands(pluginSet) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (error instanceof CommanderError) {
|
|
238
|
-
return error.exitCode;
|
|
239
|
-
}
|
|
240
|
-
throw error;
|
|
241
|
-
}
|
|
242
|
-
return exitCode;
|
|
243
|
-
}
|
|
244
|
-
};
|
|
141
|
+
const { cliPlugins } = await loadPluginRegistrations({
|
|
142
|
+
pluginSet: pluginSet === void 0 ? await loadCliPluginSet() : pluginSet ?? void 0,
|
|
143
|
+
validateConfiguredCommands: validateConfiguredPluginCommands
|
|
144
|
+
});
|
|
145
|
+
return {
|
|
146
|
+
commandNames: cliPlugins.flatMap((plugin) => (plugin.cli?.commands ?? []).map((command) => command.name)),
|
|
147
|
+
async run(commandName, argv, io = DEFAULT_IO) {
|
|
148
|
+
const resolved = findPluginCommand(cliPlugins, commandName);
|
|
149
|
+
if (!resolved) return;
|
|
150
|
+
let exitCode = 0;
|
|
151
|
+
const command = createPluginCommanderCommand({
|
|
152
|
+
command: resolved.command,
|
|
153
|
+
io,
|
|
154
|
+
plugin: resolved.plugin,
|
|
155
|
+
setExitCode: (nextExitCode) => {
|
|
156
|
+
exitCode = nextExitCode;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
try {
|
|
160
|
+
await command.parseAsync(argv, { from: "user" });
|
|
161
|
+
} catch (error) {
|
|
162
|
+
if (error instanceof CommanderError) return error.exitCode;
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
return exitCode;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
245
168
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
loadCliPluginSet
|
|
249
|
-
};
|
|
169
|
+
//#endregion
|
|
170
|
+
export { loadCliPluginCommands, loadCliPluginSet };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/cli/run.d.ts
|
|
2
|
+
export declare const CLI_USAGE = "usage: junior init <dir>\n junior snapshot create\n junior check [dir]\n junior upgrade\n junior chat\n junior chat -p <message>";
|
|
3
|
+
interface CliHandlers {
|
|
4
|
+
runChat: (argv: string[]) => Promise<number>;
|
|
5
|
+
runInit: (dir: string) => Promise<void>;
|
|
6
|
+
runSnapshotCreate: () => Promise<void>;
|
|
7
|
+
runCheck: (dir?: string) => Promise<void>;
|
|
8
|
+
runUpgrade: () => Promise<void>;
|
|
9
|
+
runPluginCommand?: (command: string, argv: string[]) => Promise<number | undefined>;
|
|
10
|
+
}
|
|
11
|
+
interface CliIo {
|
|
12
|
+
error: (line: string) => void;
|
|
13
|
+
}
|
|
14
|
+
/** Dispatch CLI arguments to command handlers and return a process exit code. */
|
|
15
|
+
export declare function runCli(argv: string[], handlers: CliHandlers, io?: CliIo): Promise<number>;
|
|
16
|
+
//#endregion
|
package/dist/cli/run.js
CHANGED
|
@@ -1,8 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
//#region src/cli/run.ts
|
|
2
|
+
const CLI_USAGE = "usage: junior init <dir>\n junior snapshot create\n junior check [dir]\n junior upgrade\n junior chat\n junior chat -p <message>";
|
|
3
|
+
const DEFAULT_IO = { error: console.error };
|
|
4
|
+
/** Strip Node's leading argv separator while preserving command-level flags. */
|
|
5
|
+
function normalizeCliArgv(argv) {
|
|
6
|
+
return argv[0] === "--" ? argv.slice(1) : argv;
|
|
7
|
+
}
|
|
8
|
+
/** Dispatch CLI arguments to command handlers and return a process exit code. */
|
|
9
|
+
async function runCli(argv, handlers, io = DEFAULT_IO) {
|
|
10
|
+
const [command, subcommand, ...rest] = normalizeCliArgv(argv);
|
|
11
|
+
if (command === "chat") return await handlers.runChat(subcommand === void 0 ? [] : [subcommand, ...rest]);
|
|
12
|
+
if (command === "init") {
|
|
13
|
+
if (!subcommand || rest.length > 0) {
|
|
14
|
+
io.error(CLI_USAGE);
|
|
15
|
+
return 1;
|
|
16
|
+
}
|
|
17
|
+
await handlers.runInit(subcommand);
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
20
|
+
if (command === "snapshot" && subcommand === "create") {
|
|
21
|
+
if (rest.length > 0) {
|
|
22
|
+
io.error(CLI_USAGE);
|
|
23
|
+
return 1;
|
|
24
|
+
}
|
|
25
|
+
await handlers.runSnapshotCreate();
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
if (command === "check") {
|
|
29
|
+
if (rest.length > 0) {
|
|
30
|
+
io.error(CLI_USAGE);
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
|
33
|
+
await handlers.runCheck(subcommand);
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
if (command === "upgrade") {
|
|
37
|
+
if (subcommand || rest.length > 0) {
|
|
38
|
+
io.error(CLI_USAGE);
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
await handlers.runUpgrade();
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
if (command && handlers.runPluginCommand) {
|
|
45
|
+
const exitCode = await handlers.runPluginCommand(command, subcommand === void 0 ? [] : [subcommand, ...rest]);
|
|
46
|
+
if (exitCode !== void 0) return exitCode;
|
|
47
|
+
}
|
|
48
|
+
io.error(CLI_USAGE);
|
|
49
|
+
return 1;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { CLI_USAGE, runCli };
|