@h-rig/cli 0.0.6-alpha.94 → 0.0.6-alpha.96
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/README.md +6 -27
- package/bin/rig.js +16 -0
- package/package.json +14 -40
- package/dist/bin/build-rig-binaries.d.ts +0 -2
- package/dist/bin/build-rig-binaries.js +0 -119
- package/dist/bin/rig.d.ts +0 -72
- package/dist/bin/rig.js +0 -17855
- package/dist/config/rig-default-config.yml +0 -5
- package/dist/src/app/drone-ui.d.ts +0 -34
- package/dist/src/app/drone-ui.js +0 -278
- package/dist/src/commands/_async-ui.d.ts +0 -10
- package/dist/src/commands/_async-ui.js +0 -121
- package/dist/src/commands/_cli-format.d.ts +0 -56
- package/dist/src/commands/_cli-format.js +0 -319
- package/dist/src/commands/_connection-state.d.ts +0 -54
- package/dist/src/commands/_connection-state.js +0 -187
- package/dist/src/commands/_doctor-checks.d.ts +0 -46
- package/dist/src/commands/_doctor-checks.js +0 -352
- package/dist/src/commands/_help-catalog.d.ts +0 -51
- package/dist/src/commands/_help-catalog.js +0 -502
- package/dist/src/commands/_inprocess-services.d.ts +0 -33
- package/dist/src/commands/_inprocess-services.js +0 -102
- package/dist/src/commands/_json-output.d.ts +0 -11
- package/dist/src/commands/_json-output.js +0 -60
- package/dist/src/commands/_lazy-reconcile.d.ts +0 -34
- package/dist/src/commands/_lazy-reconcile.js +0 -102
- package/dist/src/commands/_parsers.d.ts +0 -15
- package/dist/src/commands/_parsers.js +0 -114
- package/dist/src/commands/_paths.d.ts +0 -11
- package/dist/src/commands/_paths.js +0 -50
- package/dist/src/commands/_pi-frontend.d.ts +0 -35
- package/dist/src/commands/_pi-frontend.js +0 -64
- package/dist/src/commands/_pi-install.d.ts +0 -42
- package/dist/src/commands/_pi-install.js +0 -167
- package/dist/src/commands/_policy.d.ts +0 -8
- package/dist/src/commands/_policy.js +0 -127
- package/dist/src/commands/_probes.d.ts +0 -1
- package/dist/src/commands/_probes.js +0 -13
- package/dist/src/commands/_run-bridge.d.ts +0 -114
- package/dist/src/commands/_run-bridge.js +0 -387
- package/dist/src/commands/_run-diagnostics.d.ts +0 -9
- package/dist/src/commands/_run-diagnostics.js +0 -51
- package/dist/src/commands/_run-driver-helpers.d.ts +0 -26
- package/dist/src/commands/_run-driver-helpers.js +0 -138
- package/dist/src/commands/_run-projection.d.ts +0 -50
- package/dist/src/commands/_run-projection.js +0 -349
- package/dist/src/commands/_run-subcommands.d.ts +0 -3
- package/dist/src/commands/_run-subcommands.js +0 -31
- package/dist/src/commands/_spinner.d.ts +0 -25
- package/dist/src/commands/_spinner.js +0 -65
- package/dist/src/commands/agent.d.ts +0 -3
- package/dist/src/commands/agent.js +0 -8837
- package/dist/src/commands/dist.d.ts +0 -28
- package/dist/src/commands/dist.js +0 -417
- package/dist/src/commands/doctor.d.ts +0 -3
- package/dist/src/commands/doctor.js +0 -480
- package/dist/src/commands/github.d.ts +0 -3
- package/dist/src/commands/github.js +0 -342
- package/dist/src/commands/inbox.d.ts +0 -28
- package/dist/src/commands/inbox.js +0 -579
- package/dist/src/commands/init.d.ts +0 -64
- package/dist/src/commands/init.js +0 -1541
- package/dist/src/commands/inspect.d.ts +0 -20
- package/dist/src/commands/inspect.js +0 -764
- package/dist/src/commands/pi.d.ts +0 -3
- package/dist/src/commands/pi.js +0 -177
- package/dist/src/commands/plugin.d.ts +0 -16
- package/dist/src/commands/plugin.js +0 -714
- package/dist/src/commands/profile-and-review.d.ts +0 -4
- package/dist/src/commands/profile-and-review.js +0 -223
- package/dist/src/commands/queue.d.ts +0 -3
- package/dist/src/commands/queue.js +0 -197
- package/dist/src/commands/remote.d.ts +0 -3
- package/dist/src/commands/remote.js +0 -1337
- package/dist/src/commands/repo-git-harness.d.ts +0 -5
- package/dist/src/commands/repo-git-harness.js +0 -271
- package/dist/src/commands/run.d.ts +0 -21
- package/dist/src/commands/run.js +0 -17847
- package/dist/src/commands/server.d.ts +0 -3
- package/dist/src/commands/server.js +0 -249
- package/dist/src/commands/setup.d.ts +0 -16
- package/dist/src/commands/setup.js +0 -644
- package/dist/src/commands/stats.d.ts +0 -15
- package/dist/src/commands/stats.js +0 -979
- package/dist/src/commands/task-run-driver.d.ts +0 -94
- package/dist/src/commands/task-run-driver.js +0 -203
- package/dist/src/commands/task.d.ts +0 -35
- package/dist/src/commands/task.js +0 -818
- package/dist/src/commands/test.d.ts +0 -3
- package/dist/src/commands/test.js +0 -46
- package/dist/src/commands/triage.d.ts +0 -11
- package/dist/src/commands/triage.js +0 -227
- package/dist/src/commands/workspace.d.ts +0 -3
- package/dist/src/commands/workspace.js +0 -130
- package/dist/src/commands.d.ts +0 -13
- package/dist/src/commands.js +0 -17979
- package/dist/src/index.d.ts +0 -4
- package/dist/src/index.js +0 -17991
- package/dist/src/launcher.d.ts +0 -61
- package/dist/src/launcher.js +0 -199
- package/dist/src/operator-cli.d.ts +0 -2
- package/dist/src/operator-cli.js +0 -17847
- package/dist/src/operator-entry.d.ts +0 -1
- package/dist/src/operator-entry.js +0 -3
- package/dist/src/runner.d.ts +0 -47
- package/dist/src/runner.js +0 -267
- package/dist/src/withMutedConsole.d.ts +0 -2
- package/dist/src/withMutedConsole.js +0 -42
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/src/runner.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
|
|
2
|
-
import type { PolicyMode } from "@rig/runtime/control-plane/runtime/guard-types";
|
|
3
|
-
import type { RunnerContext } from "@rig/runtime/control-plane/runtime/runner-context";
|
|
4
|
-
import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
|
|
5
|
-
import type { CommandExecutionResult, OutputMode } from "@rig/runtime/control-plane/runtime/types";
|
|
6
|
-
export type { RunnerContext } from "@rig/runtime/control-plane/runtime/runner-context";
|
|
7
|
-
/**
|
|
8
|
-
* CLI-side error with an optional remediation hint. The hint is rendered on
|
|
9
|
-
* its own line as `Next: <hint>` (and carried in the --json error payload),
|
|
10
|
-
* so every failure names the next command to run. Extends the runtime
|
|
11
|
-
* CliError so `instanceof` checks against either class keep working.
|
|
12
|
-
*/
|
|
13
|
-
export declare class CliError extends RuntimeCliError {
|
|
14
|
-
readonly hint?: string;
|
|
15
|
-
constructor(message: string, exitCode?: number, options?: {
|
|
16
|
-
readonly hint?: string;
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
export declare function withProjectRoot(projectRoot: string): void;
|
|
20
|
-
export declare function formatCommand(parts: string[]): string;
|
|
21
|
-
type AgentShellBuild = typeof buildBinary;
|
|
22
|
-
type AgentShellMaterializationOptions = {
|
|
23
|
-
readonly env?: Record<string, string | undefined>;
|
|
24
|
-
readonly cwd?: string;
|
|
25
|
-
readonly moduleDir?: string;
|
|
26
|
-
readonly build?: AgentShellBuild;
|
|
27
|
-
};
|
|
28
|
-
export declare function resolveAgentMaterializationSourceRoot(projectRoot: string, options?: AgentShellMaterializationOptions): string;
|
|
29
|
-
export declare function ensureAgentShellBinary(projectRoot: string, options?: AgentShellMaterializationOptions): Promise<string>;
|
|
30
|
-
export declare function initializeRuntime(options: {
|
|
31
|
-
projectRoot: string;
|
|
32
|
-
dryRun: boolean;
|
|
33
|
-
outputMode: OutputMode;
|
|
34
|
-
runId?: string;
|
|
35
|
-
policyMode?: PolicyMode;
|
|
36
|
-
}): Promise<RunnerContext>;
|
|
37
|
-
export declare function runCommand(context: RunnerContext, parts: string[]): Promise<CommandExecutionResult>;
|
|
38
|
-
export declare function takeFlag(args: string[], flag: string): {
|
|
39
|
-
value: boolean;
|
|
40
|
-
rest: string[];
|
|
41
|
-
};
|
|
42
|
-
export declare function takeOption(args: string[], option: string): {
|
|
43
|
-
value: string | undefined;
|
|
44
|
-
rest: string[];
|
|
45
|
-
};
|
|
46
|
-
export declare function requireNoExtraArgs(args: string[], usage: string): void;
|
|
47
|
-
export declare function requireTask(taskId: string | undefined, usage: string): string;
|
package/dist/src/runner.js
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/cli/src/runner.ts
|
|
3
|
-
var {$ } = globalThis.Bun;
|
|
4
|
-
import { existsSync, mkdirSync } from "fs";
|
|
5
|
-
import { resolve } from "path";
|
|
6
|
-
import { EventBus } from "@rig/runtime/control-plane/runtime/events";
|
|
7
|
-
import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
|
|
8
|
-
import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
|
|
9
|
-
import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
|
|
10
|
-
|
|
11
|
-
class CliError extends RuntimeCliError {
|
|
12
|
-
hint;
|
|
13
|
-
constructor(message, exitCode = 1, options = {}) {
|
|
14
|
-
super(message, exitCode);
|
|
15
|
-
if (options.hint?.trim()) {
|
|
16
|
-
this.hint = options.hint.trim();
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function withProjectRoot(projectRoot) {
|
|
21
|
-
$.cwd(projectRoot);
|
|
22
|
-
}
|
|
23
|
-
function formatCommand(parts) {
|
|
24
|
-
return parts.map((part) => /[^a-zA-Z0-9_./:-]/.test(part) ? JSON.stringify(part) : part).join(" ");
|
|
25
|
-
}
|
|
26
|
-
var AGENT_DISPATCH_SOURCE = "packages/runtime/bin/rig-agent-dispatch.ts";
|
|
27
|
-
function hasAgentDispatchSource(root) {
|
|
28
|
-
return existsSync(resolve(root, AGENT_DISPATCH_SOURCE));
|
|
29
|
-
}
|
|
30
|
-
function resolveAgentMaterializationSourceRoot(projectRoot, options = {}) {
|
|
31
|
-
const env = options.env ?? process.env;
|
|
32
|
-
const candidates = [
|
|
33
|
-
env.RIG_HOST_PROJECT_ROOT?.trim(),
|
|
34
|
-
env.PROJECT_RIG_ROOT?.trim(),
|
|
35
|
-
options.cwd ?? process.cwd(),
|
|
36
|
-
resolve(options.moduleDir ?? import.meta.dir, "../../.."),
|
|
37
|
-
projectRoot
|
|
38
|
-
].filter((value) => Boolean(value));
|
|
39
|
-
for (const candidate of candidates) {
|
|
40
|
-
const root = resolve(candidate);
|
|
41
|
-
if (hasAgentDispatchSource(root)) {
|
|
42
|
-
return root;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return resolve(projectRoot);
|
|
46
|
-
}
|
|
47
|
-
async function ensureAgentShellBinary(projectRoot, options = {}) {
|
|
48
|
-
const agentBinary = resolve(projectRoot, ".rig", "bin", "rig-agent");
|
|
49
|
-
if (existsSync(agentBinary)) {
|
|
50
|
-
return agentBinary;
|
|
51
|
-
}
|
|
52
|
-
const sourceRoot = resolveAgentMaterializationSourceRoot(projectRoot, options);
|
|
53
|
-
if (!hasAgentDispatchSource(sourceRoot)) {
|
|
54
|
-
throw new CliError(`Missing compiled agent dispatch binary at ${agentBinary}, and no Rig source checkout with ${AGENT_DISPATCH_SOURCE} was found to materialize it automatically.`, 2);
|
|
55
|
-
}
|
|
56
|
-
mkdirSync(resolve(agentBinary, ".."), { recursive: true });
|
|
57
|
-
try {
|
|
58
|
-
await (options.build ?? buildBinary)(AGENT_DISPATCH_SOURCE, agentBinary, sourceRoot, {
|
|
59
|
-
AGENT_PROJECT_ROOT: projectRoot
|
|
60
|
-
});
|
|
61
|
-
} catch (error) {
|
|
62
|
-
throw new CliError(`Missing compiled agent dispatch binary at ${agentBinary}, and automatic materialization from ${sourceRoot} failed: ${error instanceof Error ? error.message : String(error)}`, 2);
|
|
63
|
-
}
|
|
64
|
-
if (!existsSync(agentBinary)) {
|
|
65
|
-
throw new CliError(`Automatic agent dispatch materialization from ${sourceRoot} did not create ${agentBinary}.`, 2);
|
|
66
|
-
}
|
|
67
|
-
return agentBinary;
|
|
68
|
-
}
|
|
69
|
-
async function initializeRuntime(options) {
|
|
70
|
-
const eventBus = new EventBus({ projectRoot: options.projectRoot, runId: options.runId });
|
|
71
|
-
const context = {
|
|
72
|
-
projectRoot: options.projectRoot,
|
|
73
|
-
dryRun: options.dryRun,
|
|
74
|
-
outputMode: options.outputMode,
|
|
75
|
-
runId: eventBus.getRunId(),
|
|
76
|
-
policyMode: options.policyMode,
|
|
77
|
-
eventBus,
|
|
78
|
-
emitEvent: async (type, payload) => {
|
|
79
|
-
await eventBus.emit(type, payload);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
context.runCommand = async (parts) => runCommand(context, parts);
|
|
83
|
-
await context.emitEvent("runtime.init", {
|
|
84
|
-
runId: context.runId,
|
|
85
|
-
outputMode: context.outputMode,
|
|
86
|
-
dryRun: context.dryRun,
|
|
87
|
-
policyMode: context.policyMode ?? loadPolicy(options.projectRoot).mode,
|
|
88
|
-
policyFile: resolve(options.projectRoot, "rig/policy/policy.json")
|
|
89
|
-
});
|
|
90
|
-
return context;
|
|
91
|
-
}
|
|
92
|
-
async function runCommand(context, parts) {
|
|
93
|
-
if (parts.length === 0) {
|
|
94
|
-
throw new CliError("Cannot execute an empty command.");
|
|
95
|
-
}
|
|
96
|
-
const envMode = process.env.RIG_BASH_MODE;
|
|
97
|
-
const effectiveMode = context.policyMode || (envMode === "off" || envMode === "observe" || envMode === "enforce" ? envMode : loadPolicy(context.projectRoot).mode);
|
|
98
|
-
const controlledPath = `${resolve(context.projectRoot, ".rig", "bin")}:${context.projectRoot}/rig/tools:${process.env.PATH ?? ""}`;
|
|
99
|
-
const usesInfrastructureBinary = parts[0] === "rig-server";
|
|
100
|
-
const controlledBash = usesInfrastructureBinary ? null : await ensureAgentShellBinary(context.projectRoot);
|
|
101
|
-
const commandEnv = [
|
|
102
|
-
"env",
|
|
103
|
-
`PATH=${controlledPath}`,
|
|
104
|
-
`PROJECT_RIG_ROOT=${context.projectRoot}`,
|
|
105
|
-
...controlledBash ? [`BASH=${controlledBash}`] : [],
|
|
106
|
-
`RIG_BASH_MODE=${effectiveMode}`,
|
|
107
|
-
`RIG_POLICY_FILE=${resolve(context.projectRoot, "rig/policy/policy.json")}`,
|
|
108
|
-
...context.eventBus.getEventsFile() ? [`RIG_EVENTS_FILE=${context.eventBus.getEventsFile()}`] : []
|
|
109
|
-
];
|
|
110
|
-
const commandWithEnv = [...commandEnv, ...parts];
|
|
111
|
-
const formatted = formatCommand(commandWithEnv);
|
|
112
|
-
await context.emitEvent("command.received", {
|
|
113
|
-
command: commandWithEnv,
|
|
114
|
-
formattedCommand: formatted
|
|
115
|
-
});
|
|
116
|
-
const guardDecision = evaluate({
|
|
117
|
-
projectRoot: context.projectRoot,
|
|
118
|
-
evaluation: { type: "command", command: formatted }
|
|
119
|
-
});
|
|
120
|
-
const guardAction = resolveAction(effectiveMode, guardDecision.matchedRules);
|
|
121
|
-
await context.emitEvent("policy.decision", {
|
|
122
|
-
target: "command",
|
|
123
|
-
command: formatted,
|
|
124
|
-
mode: effectiveMode,
|
|
125
|
-
allowed: guardAction !== "block",
|
|
126
|
-
matchedRuleIds: guardDecision.matchedRules.map((r) => r.id),
|
|
127
|
-
reasons: guardDecision.matchedRules.map((r) => r.reason)
|
|
128
|
-
});
|
|
129
|
-
if (guardAction === "block") {
|
|
130
|
-
await context.emitEvent("command.failed", {
|
|
131
|
-
command: commandWithEnv,
|
|
132
|
-
formattedCommand: formatted,
|
|
133
|
-
reason: "Policy denied command",
|
|
134
|
-
matchedRuleIds: guardDecision.matchedRules.map((r) => r.id),
|
|
135
|
-
mode: effectiveMode
|
|
136
|
-
});
|
|
137
|
-
throw new CliError(`Policy blocked command: ${formatted}`, 126, { hint: "Review rig/policy/policy.json, or re-run with `--policy-mode observe` to log instead of block." });
|
|
138
|
-
}
|
|
139
|
-
const startedAt = new Date;
|
|
140
|
-
await context.emitEvent("command.started", {
|
|
141
|
-
command: commandWithEnv,
|
|
142
|
-
formattedCommand: formatted,
|
|
143
|
-
startedAt: startedAt.toISOString(),
|
|
144
|
-
dryRun: context.dryRun
|
|
145
|
-
});
|
|
146
|
-
if (context.dryRun) {
|
|
147
|
-
const dryResult = {
|
|
148
|
-
command: commandWithEnv,
|
|
149
|
-
formattedCommand: formatted,
|
|
150
|
-
exitCode: 0,
|
|
151
|
-
durationMs: 0,
|
|
152
|
-
startedAt: startedAt.toISOString(),
|
|
153
|
-
finishedAt: startedAt.toISOString()
|
|
154
|
-
};
|
|
155
|
-
if (context.outputMode === "text") {
|
|
156
|
-
console.log(`$ ${formatted}`);
|
|
157
|
-
}
|
|
158
|
-
await context.emitEvent("command.finished", {
|
|
159
|
-
...dryResult,
|
|
160
|
-
dryRun: true
|
|
161
|
-
});
|
|
162
|
-
return dryResult;
|
|
163
|
-
}
|
|
164
|
-
let exitCode = 0;
|
|
165
|
-
let stdout = "";
|
|
166
|
-
let stderr = "";
|
|
167
|
-
if (context.outputMode === "json") {
|
|
168
|
-
const child = Bun.spawn(commandWithEnv, {
|
|
169
|
-
cwd: context.projectRoot,
|
|
170
|
-
stdin: "inherit",
|
|
171
|
-
stdout: "pipe",
|
|
172
|
-
stderr: "pipe"
|
|
173
|
-
});
|
|
174
|
-
exitCode = await child.exited;
|
|
175
|
-
stdout = await new Response(child.stdout).text();
|
|
176
|
-
stderr = await new Response(child.stderr).text();
|
|
177
|
-
} else {
|
|
178
|
-
const child = Bun.spawn(commandWithEnv, {
|
|
179
|
-
cwd: context.projectRoot,
|
|
180
|
-
stdin: "inherit",
|
|
181
|
-
stdout: "inherit",
|
|
182
|
-
stderr: "inherit"
|
|
183
|
-
});
|
|
184
|
-
exitCode = await child.exited;
|
|
185
|
-
}
|
|
186
|
-
const finishedAt = new Date;
|
|
187
|
-
const result = {
|
|
188
|
-
command: commandWithEnv,
|
|
189
|
-
formattedCommand: formatted,
|
|
190
|
-
exitCode,
|
|
191
|
-
durationMs: finishedAt.getTime() - startedAt.getTime(),
|
|
192
|
-
startedAt: startedAt.toISOString(),
|
|
193
|
-
finishedAt: finishedAt.toISOString(),
|
|
194
|
-
stdout: context.outputMode === "json" ? stdout : undefined,
|
|
195
|
-
stderr: context.outputMode === "json" ? stderr : undefined
|
|
196
|
-
};
|
|
197
|
-
if (exitCode !== 0) {
|
|
198
|
-
await context.emitEvent("command.failed", {
|
|
199
|
-
...result
|
|
200
|
-
});
|
|
201
|
-
const errorSuffix = context.outputMode === "json" && stderr ? `
|
|
202
|
-
${stderr.trim()}` : "";
|
|
203
|
-
throw new CliError(`Command failed (${exitCode}): ${formatted}${errorSuffix}`, exitCode);
|
|
204
|
-
}
|
|
205
|
-
await context.emitEvent("command.finished", {
|
|
206
|
-
...result
|
|
207
|
-
});
|
|
208
|
-
return result;
|
|
209
|
-
}
|
|
210
|
-
function takeFlag(args, flag) {
|
|
211
|
-
const rest = [];
|
|
212
|
-
let value = false;
|
|
213
|
-
for (const arg of args) {
|
|
214
|
-
if (arg === flag) {
|
|
215
|
-
value = true;
|
|
216
|
-
continue;
|
|
217
|
-
}
|
|
218
|
-
rest.push(arg);
|
|
219
|
-
}
|
|
220
|
-
return { value, rest };
|
|
221
|
-
}
|
|
222
|
-
function takeOption(args, option) {
|
|
223
|
-
const rest = [];
|
|
224
|
-
let value;
|
|
225
|
-
for (let index = 0;index < args.length; index += 1) {
|
|
226
|
-
const current = args[index];
|
|
227
|
-
if (current === option) {
|
|
228
|
-
const next = args[index + 1];
|
|
229
|
-
if (!next || next.startsWith("-")) {
|
|
230
|
-
throw new CliError(`Missing value for ${option}`, 1, { hint: `Provide a value after ${option}, e.g. \`${option} <value>\`.` });
|
|
231
|
-
}
|
|
232
|
-
value = next;
|
|
233
|
-
index += 1;
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
236
|
-
if (current !== undefined) {
|
|
237
|
-
rest.push(current);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return { value, rest };
|
|
241
|
-
}
|
|
242
|
-
function requireNoExtraArgs(args, usage) {
|
|
243
|
-
if (args.length > 0) {
|
|
244
|
-
throw new CliError(`Unexpected arguments: ${args.join(" ")}
|
|
245
|
-
Usage: ${usage}`);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
function requireTask(taskId, usage) {
|
|
249
|
-
if (!taskId) {
|
|
250
|
-
throw new CliError(`Missing --task option.
|
|
251
|
-
Usage: ${usage}`);
|
|
252
|
-
}
|
|
253
|
-
return taskId;
|
|
254
|
-
}
|
|
255
|
-
export {
|
|
256
|
-
withProjectRoot,
|
|
257
|
-
takeOption,
|
|
258
|
-
takeFlag,
|
|
259
|
-
runCommand,
|
|
260
|
-
resolveAgentMaterializationSourceRoot,
|
|
261
|
-
requireTask,
|
|
262
|
-
requireNoExtraArgs,
|
|
263
|
-
initializeRuntime,
|
|
264
|
-
formatCommand,
|
|
265
|
-
ensureAgentShellBinary,
|
|
266
|
-
CliError
|
|
267
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/cli/src/withMutedConsole.ts
|
|
3
|
-
function isPromise(value) {
|
|
4
|
-
if (typeof value !== "object" && typeof value !== "function") {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
return value !== null && typeof value.then === "function";
|
|
8
|
-
}
|
|
9
|
-
function withMutedConsole(mute, fn) {
|
|
10
|
-
if (!mute) {
|
|
11
|
-
return fn();
|
|
12
|
-
}
|
|
13
|
-
const originalLog = console.log;
|
|
14
|
-
const originalWarn = console.warn;
|
|
15
|
-
const originalInfo = console.info;
|
|
16
|
-
const restore = () => {
|
|
17
|
-
console.log = originalLog;
|
|
18
|
-
console.warn = originalWarn;
|
|
19
|
-
console.info = originalInfo;
|
|
20
|
-
};
|
|
21
|
-
console.log = () => {};
|
|
22
|
-
console.warn = () => {};
|
|
23
|
-
console.info = () => {};
|
|
24
|
-
try {
|
|
25
|
-
const result = fn();
|
|
26
|
-
if (isPromise(result)) {
|
|
27
|
-
return result.finally(restore);
|
|
28
|
-
}
|
|
29
|
-
restore();
|
|
30
|
-
return result;
|
|
31
|
-
} catch (error) {
|
|
32
|
-
restore();
|
|
33
|
-
throw error;
|
|
34
|
-
} finally {
|
|
35
|
-
if (console.log === originalLog) {
|
|
36
|
-
restore();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
export {
|
|
41
|
-
withMutedConsole
|
|
42
|
-
};
|