@h-rig/cli 0.0.6-alpha.90 → 0.0.6-alpha.92
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 +18 -19
- package/dist/bin/build-rig-binaries.js +22 -10
- package/dist/bin/rig.d.ts +71 -1
- package/dist/bin/rig.js +15078 -11169
- package/dist/config/rig-default-config.yml +5 -0
- package/dist/src/app/drone-ui.d.ts +11 -14
- package/dist/src/app/drone-ui.js +70 -86
- package/dist/src/commands/_async-ui.d.ts +1 -4
- package/dist/src/commands/_async-ui.js +9 -111
- package/dist/src/commands/_cli-format.d.ts +16 -9
- package/dist/src/commands/_cli-format.js +167 -295
- package/dist/src/commands/_connection-state.d.ts +11 -1
- package/dist/src/commands/_connection-state.js +50 -5
- package/dist/src/commands/_doctor-checks.d.ts +0 -6
- package/dist/src/commands/_doctor-checks.js +79 -382
- package/dist/src/commands/_help-catalog.d.ts +1 -1
- package/dist/src/commands/_help-catalog.js +217 -157
- package/dist/src/commands/_inprocess-services.d.ts +33 -0
- package/dist/src/commands/_inprocess-services.js +102 -0
- package/dist/src/commands/_json-output.js +4 -0
- package/dist/src/commands/_lazy-reconcile.d.ts +34 -0
- package/dist/src/commands/_lazy-reconcile.js +102 -0
- package/dist/src/commands/_paths.js +1 -1
- package/dist/src/commands/_pi-frontend.d.ts +18 -10
- package/dist/src/commands/_pi-frontend.js +37 -715
- package/dist/src/commands/_pi-install.js +18 -36
- package/dist/src/commands/_policy.d.ts +1 -1
- package/dist/src/commands/_policy.js +56 -15
- package/dist/src/commands/_run-bridge.d.ts +114 -0
- package/dist/src/commands/_run-bridge.js +387 -0
- package/dist/src/commands/_run-diagnostics.d.ts +9 -0
- package/dist/src/commands/_run-diagnostics.js +51 -0
- package/dist/src/commands/_run-driver-helpers.d.ts +8 -81
- package/dist/src/commands/_run-driver-helpers.js +79 -283
- package/dist/src/commands/_run-projection.d.ts +50 -0
- package/dist/src/commands/_run-projection.js +349 -0
- package/dist/src/commands/_run-subcommands.d.ts +3 -0
- package/dist/src/commands/_run-subcommands.js +31 -0
- package/dist/src/commands/_spinner.js +1 -1
- package/dist/src/commands/agent.d.ts +1 -1
- package/dist/src/commands/agent.js +8559 -239
- package/dist/src/commands/dist.d.ts +1 -1
- package/dist/src/commands/dist.js +27 -19
- package/dist/src/commands/doctor.d.ts +1 -1
- package/dist/src/commands/doctor.js +93 -475
- package/dist/src/commands/github.d.ts +1 -1
- package/dist/src/commands/github.js +113 -387
- package/dist/src/commands/inbox.d.ts +22 -24
- package/dist/src/commands/inbox.js +420 -691
- package/dist/src/commands/init.d.ts +6 -16
- package/dist/src/commands/init.js +334 -971
- package/dist/src/commands/inspect.d.ts +19 -2
- package/dist/src/commands/inspect.js +644 -610
- package/dist/src/commands/pi.d.ts +1 -1
- package/dist/src/commands/plugin.d.ts +1 -1
- package/dist/src/commands/plugin.js +486 -7
- package/dist/src/commands/profile-and-review.d.ts +1 -1
- package/dist/src/commands/profile-and-review.js +94 -56
- package/dist/src/commands/queue.js +1 -21
- package/dist/src/commands/remote.d.ts +1 -1
- package/dist/src/commands/remote.js +837 -14
- package/dist/src/commands/repo-git-harness.d.ts +1 -1
- package/dist/src/commands/repo-git-harness.js +57 -14
- package/dist/src/commands/run.d.ts +20 -2
- package/dist/src/commands/run.js +17579 -1759
- package/dist/src/commands/server.d.ts +2 -6
- package/dist/src/commands/server.js +141 -723
- package/dist/src/commands/setup.d.ts +1 -1
- package/dist/src/commands/setup.js +102 -484
- package/dist/src/commands/stats.d.ts +13 -10
- package/dist/src/commands/stats.js +689 -761
- package/dist/src/commands/task-run-driver.d.ts +50 -88
- package/dist/src/commands/task-run-driver.js +116 -2717
- package/dist/src/commands/task.d.ts +34 -13
- package/dist/src/commands/task.js +668 -2523
- package/dist/src/commands/test.d.ts +1 -1
- package/dist/src/commands/triage.d.ts +11 -0
- package/dist/src/commands/triage.js +227 -0
- package/dist/src/commands/workspace.d.ts +1 -1
- package/dist/src/commands.d.ts +0 -16
- package/dist/src/commands.js +16657 -12250
- package/dist/src/index.js +16528 -12497
- package/dist/src/launcher.js +4 -0
- package/dist/src/operator-cli.d.ts +2 -0
- package/dist/src/operator-cli.js +17837 -0
- package/dist/src/operator-entry.d.ts +1 -0
- package/dist/src/operator-entry.js +3 -0
- package/package.json +18 -12
- package/dist/src/app/board.d.ts +0 -23
- package/dist/src/app/board.js +0 -1786
- package/dist/src/app/theme.d.ts +0 -47
- package/dist/src/app/theme.js +0 -150
- package/dist/src/commands/_authority-runs.d.ts +0 -22
- package/dist/src/commands/_authority-runs.js +0 -110
- package/dist/src/commands/_operator-surface.d.ts +0 -34
- package/dist/src/commands/_operator-surface.js +0 -220
- package/dist/src/commands/_operator-view.d.ts +0 -30
- package/dist/src/commands/_operator-view.js +0 -1070
- package/dist/src/commands/_preflight.d.ts +0 -22
- package/dist/src/commands/_preflight.js +0 -540
- package/dist/src/commands/_run-replay.d.ts +0 -24
- package/dist/src/commands/_run-replay.js +0 -142
- package/dist/src/commands/_server-client.d.ts +0 -186
- package/dist/src/commands/_server-client.js +0 -681
- package/dist/src/commands/_snapshot-upload.d.ts +0 -39
- package/dist/src/commands/_snapshot-upload.js +0 -455
- package/dist/src/commands/_task-picker.d.ts +0 -9
- package/dist/src/commands/_task-picker.js +0 -201
- package/dist/src/commands/browser.d.ts +0 -65
- package/dist/src/commands/browser.js +0 -1173
- package/dist/src/commands/connect.d.ts +0 -7
- package/dist/src/commands/connect.js +0 -419
- package/dist/src/commands/inspector.d.ts +0 -3
- package/dist/src/commands/inspector.js +0 -263
- package/dist/src/commands/task-report-bug.d.ts +0 -19
- package/dist/src/commands/task-report-bug.js +0 -1281
- package/dist/src/report-bug.d.ts +0 -44
- package/dist/src/report-bug.js +0 -260
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RunnerContext } from "../runner";
|
|
2
|
-
import type { CommandOutcome } from "@rig/runtime
|
|
2
|
+
import type { CommandOutcome } from "@rig/runtime";
|
|
3
3
|
export declare function executeRepo(context: RunnerContext, args: string[]): Promise<CommandOutcome>;
|
|
4
4
|
export declare function executeGit(context: RunnerContext, args: string[]): Promise<CommandOutcome>;
|
|
5
5
|
export declare function executeHarness(context: RunnerContext, args: string[]): Promise<CommandOutcome>;
|
|
@@ -100,23 +100,67 @@ function withMutedConsole(mute, fn) {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
// packages/cli/src/commands/_policy.ts
|
|
103
|
-
import { appendFileSync, mkdirSync } from "fs";
|
|
103
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync } from "fs";
|
|
104
|
+
import { resolve as resolve2 } from "path";
|
|
105
|
+
|
|
106
|
+
// packages/cli/src/commands/_paths.ts
|
|
104
107
|
import { resolve } from "path";
|
|
105
|
-
import {
|
|
106
|
-
|
|
108
|
+
import { resolveMonorepoRoot } from "@rig/runtime/layout";
|
|
109
|
+
function resolveControlPlaneHostStateRoot(projectRoot) {
|
|
110
|
+
return resolve(projectRoot, ".rig");
|
|
111
|
+
}
|
|
112
|
+
function resolveControlPlaneHostLogsDir(projectRoot) {
|
|
113
|
+
return resolve(resolveControlPlaneHostStateRoot(projectRoot), "logs");
|
|
114
|
+
}
|
|
115
|
+
function resolveControlPlaneDefinitionRoot(projectRoot) {
|
|
116
|
+
return resolve(projectRoot, "rig");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// packages/cli/src/commands/_policy.ts
|
|
120
|
+
function loadPolicyFile(projectRoot) {
|
|
121
|
+
const policyPath = resolve2(resolveControlPlaneDefinitionRoot(projectRoot), "policy", "policy.json");
|
|
122
|
+
if (!existsSync(policyPath)) {
|
|
123
|
+
return { mode: "observe", rules: [] };
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
const parsed = JSON.parse(readFileSync(policyPath, "utf8"));
|
|
127
|
+
const mode = parsed.mode === "off" || parsed.mode === "observe" || parsed.mode === "enforce" ? parsed.mode : "observe";
|
|
128
|
+
const rules = Array.isArray(parsed.rules) ? parsed.rules.filter((value) => Boolean(value && typeof value === "object" && !Array.isArray(value))).map((value, index) => ({
|
|
129
|
+
id: typeof value.id === "string" && value.id.trim() ? value.id.trim() : `rule-${index + 1}`,
|
|
130
|
+
reason: typeof value.reason === "string" && value.reason.trim() ? value.reason.trim() : undefined,
|
|
131
|
+
match: typeof value.match === "string" && value.match.trim() ? value.match.trim() : undefined,
|
|
132
|
+
command: typeof value.command === "string" && value.command.trim() ? value.command.trim() : undefined
|
|
133
|
+
})) : [];
|
|
134
|
+
return { mode, rules };
|
|
135
|
+
} catch {
|
|
136
|
+
return { mode: "observe", rules: [] };
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function matchingRules(command, rules) {
|
|
140
|
+
return rules.filter((rule) => {
|
|
141
|
+
const rawPattern = rule.command ?? rule.match;
|
|
142
|
+
if (!rawPattern)
|
|
143
|
+
return false;
|
|
144
|
+
try {
|
|
145
|
+
return new RegExp(rawPattern, "i").test(command);
|
|
146
|
+
} catch {
|
|
147
|
+
return command.includes(rawPattern);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
107
151
|
function resolveEffectivePolicyMode(context) {
|
|
108
152
|
const envMode = process.env.RIG_BASH_MODE;
|
|
109
153
|
if (envMode === "off" || envMode === "observe" || envMode === "enforce") {
|
|
110
154
|
return envMode;
|
|
111
155
|
}
|
|
112
|
-
return context.policyMode
|
|
156
|
+
return context.policyMode ?? loadPolicyFile(context.projectRoot).mode;
|
|
113
157
|
}
|
|
114
158
|
function appendControlledBashAudit(context, mode, command, args, matchedRuleIds, action) {
|
|
115
159
|
if (mode === "off") {
|
|
116
160
|
return;
|
|
117
161
|
}
|
|
118
|
-
const logsDir =
|
|
119
|
-
const logFile =
|
|
162
|
+
const logsDir = resolveControlPlaneHostLogsDir(context.projectRoot);
|
|
163
|
+
const logFile = resolve2(logsDir, "controlled-bash.jsonl");
|
|
120
164
|
mkdirSync(logsDir, { recursive: true });
|
|
121
165
|
const payload = {
|
|
122
166
|
timestamp: new Date().toISOString(),
|
|
@@ -137,25 +181,24 @@ function appendControlledBashAudit(context, mode, command, args, matchedRuleIds,
|
|
|
137
181
|
async function enforceNativeCommandPolicy(context, args, options) {
|
|
138
182
|
const mode = resolveEffectivePolicyMode(context);
|
|
139
183
|
const command = formatCommand([options.commandPrefix, ...args]);
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
});
|
|
144
|
-
const action = resolveAction2(mode, decision.matchedRules);
|
|
145
|
-
const matchedRuleIds = decision.matchedRules.map((rule) => rule.id);
|
|
184
|
+
const rules = matchingRules(command, loadPolicyFile(context.projectRoot).rules);
|
|
185
|
+
const matchedRuleIds = rules.map((rule) => rule.id);
|
|
186
|
+
const action = rules.length === 0 ? "allow" : mode === "enforce" ? "block" : "warn";
|
|
146
187
|
await context.emitEvent("policy.decision", {
|
|
147
188
|
target: "command",
|
|
148
189
|
command,
|
|
149
190
|
mode,
|
|
150
191
|
allowed: action !== "block",
|
|
151
192
|
matchedRuleIds,
|
|
152
|
-
reasons:
|
|
193
|
+
reasons: rules.map((rule) => rule.reason).filter(Boolean)
|
|
153
194
|
});
|
|
154
195
|
if (options.writeAuditLog) {
|
|
155
196
|
appendControlledBashAudit(context, mode, command, args, matchedRuleIds, action === "block" ? "blocked" : action === "warn" ? "warn" : undefined);
|
|
156
197
|
}
|
|
157
198
|
if (action === "block") {
|
|
158
|
-
throw new CliError(`Policy blocked command: ${command}`, 126, {
|
|
199
|
+
throw new CliError(`Policy blocked command: ${command}`, 126, {
|
|
200
|
+
hint: "Review rig/policy/policy.json, or re-run with `--policy-mode observe` to log instead of block."
|
|
201
|
+
});
|
|
159
202
|
}
|
|
160
203
|
}
|
|
161
204
|
|
|
@@ -1,3 +1,21 @@
|
|
|
1
1
|
import { type RunnerContext } from "../runner";
|
|
2
|
-
import type { CommandOutcome } from "@rig/runtime
|
|
3
|
-
|
|
2
|
+
import type { CommandOutcome } from "@rig/runtime";
|
|
3
|
+
import { type RigExtensionTask, type RunControl } from "./_run-bridge";
|
|
4
|
+
import { type RunJoinTarget, type RunProjectionRecord } from "./_run-projection";
|
|
5
|
+
export type RunTaskLike = RigExtensionTask & Record<string, unknown>;
|
|
6
|
+
export interface RunExecutorDeps {
|
|
7
|
+
readonly listRuns?: (projectRoot: string) => Promise<RunProjectionRecord[]>;
|
|
8
|
+
readonly getRun?: (projectRoot: string, runId: string) => Promise<RunProjectionRecord | null>;
|
|
9
|
+
readonly resolveJoin?: (projectRoot: string, runId: string) => Promise<RunJoinTarget | null>;
|
|
10
|
+
readonly dispatch?: (input: {
|
|
11
|
+
readonly projectRoot: string;
|
|
12
|
+
readonly taskId: string;
|
|
13
|
+
readonly title?: string | null;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
readonly runId: string;
|
|
16
|
+
}>;
|
|
17
|
+
readonly listTasks?: (projectRoot: string) => Promise<readonly RunTaskLike[]>;
|
|
18
|
+
readonly appendLocal?: (record: RunProjectionRecord, text: string) => Promise<void>;
|
|
19
|
+
readonly deliverRemote?: (projectRoot: string, runId: string, control: RunControl) => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export declare function executeRun(context: RunnerContext, args: string[], deps?: RunExecutorDeps): Promise<CommandOutcome>;
|