@wildorder/nightshift 0.13.0 → 0.15.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/README.md +64 -26
- package/dist/agent-probe.d.ts +21 -2
- package/dist/agent-probe.d.ts.map +1 -1
- package/dist/agent-probe.js +76 -22
- package/dist/agent-probe.js.map +1 -1
- package/dist/agent-runner.d.ts +90 -2
- package/dist/agent-runner.d.ts.map +1 -1
- package/dist/agent-runner.js +382 -24
- package/dist/agent-runner.js.map +1 -1
- package/dist/agent-summary.d.ts +15 -0
- package/dist/agent-summary.d.ts.map +1 -1
- package/dist/agent-summary.js +32 -2
- package/dist/agent-summary.js.map +1 -1
- package/dist/as-built.d.ts +6 -0
- package/dist/as-built.d.ts.map +1 -1
- package/dist/as-built.js +7 -0
- package/dist/as-built.js.map +1 -1
- package/dist/author.d.ts +13 -3
- package/dist/author.d.ts.map +1 -1
- package/dist/author.js +267 -30
- package/dist/author.js.map +1 -1
- package/dist/ci-init.d.ts.map +1 -1
- package/dist/ci-init.js +17 -12
- package/dist/ci-init.js.map +1 -1
- package/dist/cli.js +74 -15
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +13 -0
- package/dist/config.js.map +1 -1
- package/dist/crash-report.d.ts +58 -0
- package/dist/crash-report.d.ts.map +1 -0
- package/dist/crash-report.js +115 -0
- package/dist/crash-report.js.map +1 -0
- package/dist/decide.js +1 -1
- package/dist/decide.js.map +1 -1
- package/dist/decider-review.d.ts +33 -5
- package/dist/decider-review.d.ts.map +1 -1
- package/dist/decider-review.js +55 -9
- package/dist/decider-review.js.map +1 -1
- package/dist/decision-ledger.d.ts +44 -1
- package/dist/decision-ledger.d.ts.map +1 -1
- package/dist/decision-ledger.js +46 -1
- package/dist/decision-ledger.js.map +1 -1
- package/dist/decision-view.d.ts +10 -1
- package/dist/decision-view.d.ts.map +1 -1
- package/dist/decision-view.js +41 -0
- package/dist/decision-view.js.map +1 -1
- package/dist/manifest.d.ts +29 -1
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +236 -11
- package/dist/manifest.js.map +1 -1
- package/dist/permits.d.ts +135 -0
- package/dist/permits.d.ts.map +1 -0
- package/dist/permits.js +397 -0
- package/dist/permits.js.map +1 -0
- package/dist/publish.d.ts +35 -0
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +149 -16
- package/dist/publish.js.map +1 -1
- package/dist/run-program.d.ts +53 -2
- package/dist/run-program.d.ts.map +1 -1
- package/dist/run-program.js +539 -56
- package/dist/run-program.js.map +1 -1
- package/dist/whole-program-review.d.ts +4 -0
- package/dist/whole-program-review.d.ts.map +1 -1
- package/dist/whole-program-review.js +9 -1
- package/dist/whole-program-review.js.map +1 -1
- package/package.json +2 -2
- package/dist/verify-allowlist.d.ts +0 -23
- package/dist/verify-allowlist.d.ts.map +0 -1
- package/dist/verify-allowlist.js +0 -46
- package/dist/verify-allowlist.js.map +0 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { AgentConfig, NightshiftConfig, PermitsConfig } from "./config.js";
|
|
2
|
+
/**
|
|
3
|
+
* The permission posture nightshift derives for each agent spawn — from the
|
|
4
|
+
* agent's role, the provider it runs, and the host it runs on — replacing
|
|
5
|
+
* the hand-written `--permission-mode`/`--allowedTools` flags an operator
|
|
6
|
+
* used to maintain by hand. See docs/programs's WS-01 spec for the full
|
|
7
|
+
* design: this module builds no judge of its own, it only chooses among
|
|
8
|
+
* containments the providers already ship (claude's `auto` classifier and
|
|
9
|
+
* OS sandbox, codex's workspace-write sandbox).
|
|
10
|
+
*/
|
|
11
|
+
/** The five spawn seats; postures are fixed, never configured. */
|
|
12
|
+
export type AgentRole = "agent" | "recoveryAgent" | "authorAgent" | "deciderAgent" | "reviewerAgent";
|
|
13
|
+
export type Posture = "workspace" | "read-only";
|
|
14
|
+
/**
|
|
15
|
+
* Fixed per-role postures — mirrors the write/exec split `agent-probe.ts`
|
|
16
|
+
* already encoded as WRITE_ROLES/EXEC_ROLES. Exported so the probe sources
|
|
17
|
+
* its write/read split from here rather than keeping a second copy that can
|
|
18
|
+
* drift.
|
|
19
|
+
*/
|
|
20
|
+
export declare const ROLE_POSTURE: Record<AgentRole, Posture>;
|
|
21
|
+
/**
|
|
22
|
+
* The containment/mode label rendered on the `permissions:` startup line and
|
|
23
|
+
* the doctor probe. `unmanaged` covers a provider this module has no flag
|
|
24
|
+
* vocabulary for (gemini, cursor-agent, …) — SC-07's seven labels are all
|
|
25
|
+
* claude/codex-specific; this is the honest label for everything else.
|
|
26
|
+
*/
|
|
27
|
+
export type ContainmentLabel = "ephemeral" | "auto+sandbox" | "auto" | "read-only" | "operator-configured" | "fallback (acceptEdits+verify)" | "fallback (detection failed)" | "read-only fallback (default+verify)" | "read-only fallback (detection failed)" | "unmanaged";
|
|
28
|
+
export interface DerivedInvocation {
|
|
29
|
+
/** Same command/promptMode; args carry the derived flags appended, or are untouched when operator-configured. */
|
|
30
|
+
agent: AgentConfig;
|
|
31
|
+
label: ContainmentLabel;
|
|
32
|
+
operatorConfigured: boolean;
|
|
33
|
+
/** The settings file this invocation reads, when one applies (claude only). */
|
|
34
|
+
settingsPath?: string;
|
|
35
|
+
/** An extra sentence for the startup line — e.g. codex's deny-rules caveat. */
|
|
36
|
+
note?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* True when the agent's own args already carry a permission-bearing flag —
|
|
40
|
+
* `--flag value` and `--flag=value` both match. An agent that trips this is
|
|
41
|
+
* spawned untouched and labeled operator-configured; rewriting an operator's
|
|
42
|
+
* authored flags is the override the charter forbids.
|
|
43
|
+
*/
|
|
44
|
+
export declare function hasExplicitPermissionFlag(agent: AgentConfig): boolean;
|
|
45
|
+
/** One `--allowedTools`/settings allow entry per configured verify command. Relocated from verify-allowlist.ts. */
|
|
46
|
+
export declare function claudeVerifyAllowedTools(verify: Record<string, string>): string[];
|
|
47
|
+
/** The workspace settings file: verify rules + permits.allow/deny, plus a sandbox block on darwin/linux. */
|
|
48
|
+
export declare function workspaceSettingsContent(verify: Record<string, string>, permits: PermitsConfig | undefined, platform: NodeJS.Platform): string;
|
|
49
|
+
/** The read-only settings file: same allow/deny lists, never a sandbox block. */
|
|
50
|
+
export declare function readOnlySettingsContent(verify: Record<string, string>, permits: PermitsConfig | undefined): string;
|
|
51
|
+
export interface ClaudeCapabilities {
|
|
52
|
+
/** False when `--help` could not be run at all (not on PATH, spawn error). */
|
|
53
|
+
detected: boolean;
|
|
54
|
+
autoMode: boolean;
|
|
55
|
+
dontAskMode: boolean;
|
|
56
|
+
permissionPrompts: boolean;
|
|
57
|
+
}
|
|
58
|
+
/** Injectable boundary: resolves to the CLI's `--help` text, rejects on spawn failure. */
|
|
59
|
+
export type ClaudeHelpRunner = (command: string) => Promise<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Turns a finished `--help` spawn into its text or a rejection. Exported so
|
|
62
|
+
* the nonzero-exit-code case (a `claude` on PATH that fails, rather than a
|
|
63
|
+
* missing command) is unit-testable without an actual child process: a
|
|
64
|
+
* nonzero exit must be reported as a detection failure, never parsed as if
|
|
65
|
+
* it were successful help output.
|
|
66
|
+
*/
|
|
67
|
+
export declare function helpRunnerOutcome(code: number | null, output: string): string;
|
|
68
|
+
export declare const defaultClaudeHelpRunner: ClaudeHelpRunner;
|
|
69
|
+
/** Parses `claude --help` text into capabilities. Exported for fixture-driven tests. */
|
|
70
|
+
export declare function parseClaudeHelp(helpText: string): ClaudeCapabilities;
|
|
71
|
+
export declare function detectClaudeCapabilities(command: string, helpRunner?: ClaudeHelpRunner): Promise<ClaudeCapabilities>;
|
|
72
|
+
/** Test-only: clears the process-wide capability cache between fixture scenarios. */
|
|
73
|
+
export declare function resetClaudeCapabilityCacheForTests(): void;
|
|
74
|
+
export interface DerivationInput {
|
|
75
|
+
role: AgentRole;
|
|
76
|
+
agent: AgentConfig;
|
|
77
|
+
/** Raw `NIGHTSHIFT_CONTAINMENT` value; only `"ephemeral"` has meaning. */
|
|
78
|
+
containmentEnv: string | undefined;
|
|
79
|
+
platform: NodeJS.Platform;
|
|
80
|
+
/** Undefined for a non-claude command — capabilities are claude-specific. */
|
|
81
|
+
claudeCapabilities: ClaudeCapabilities | undefined;
|
|
82
|
+
workspaceSettingsPath: string;
|
|
83
|
+
readOnlySettingsPath: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The whole derivation, pure: role + posture + containment + capabilities +
|
|
87
|
+
* the agent's existing args -> the flags to spawn with. No I/O — capability
|
|
88
|
+
* detection and the settings-file write happen in the context builder below.
|
|
89
|
+
*/
|
|
90
|
+
export declare function deriveAgentInvocation(input: DerivationInput): DerivedInvocation;
|
|
91
|
+
export interface PermitsContext {
|
|
92
|
+
workspaceSettingsPath: string;
|
|
93
|
+
readOnlySettingsPath: string;
|
|
94
|
+
derive(role: AgentRole, agent: AgentConfig): Promise<DerivedInvocation>;
|
|
95
|
+
/**
|
|
96
|
+
* Removes the settings files this context wrote. The owner of a context
|
|
97
|
+
* (the command that built it) calls this when its spawns are done; a
|
|
98
|
+
* process-exit hook removes whatever an owner never got to, so a crash or
|
|
99
|
+
* an early return does not leave the pair behind in the OS temp directory.
|
|
100
|
+
* Optional so a test fake that only implements `derive` stays a valid
|
|
101
|
+
* context; owners call it as `permits.dispose?.()`.
|
|
102
|
+
*/
|
|
103
|
+
dispose?(): Promise<void>;
|
|
104
|
+
}
|
|
105
|
+
/** Injectable filesystem boundary for the settings-file write and removal. */
|
|
106
|
+
export interface PermitsFs {
|
|
107
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
108
|
+
/** Optional so a write-capturing fake stays valid; removal is then a no-op. */
|
|
109
|
+
rm?(path: string): Promise<void>;
|
|
110
|
+
}
|
|
111
|
+
export interface BuildPermitsContextOptions {
|
|
112
|
+
config: NightshiftConfig;
|
|
113
|
+
platform?: NodeJS.Platform;
|
|
114
|
+
/** Defaults to `process.env.NIGHTSHIFT_CONTAINMENT`. */
|
|
115
|
+
containmentEnv?: string | undefined;
|
|
116
|
+
helpRunner?: ClaudeHelpRunner;
|
|
117
|
+
fs?: PermitsFs;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Builds the run's (or doctor probe's, or as-built refresh's) one
|
|
121
|
+
* `PermitsContext`: writes the two settings files once under `os.tmpdir()`
|
|
122
|
+
* and returns a `derive` function that detects claude's capabilities on
|
|
123
|
+
* first use per command string and applies the pure derivation above.
|
|
124
|
+
*/
|
|
125
|
+
export declare function buildPermitsContext(options: BuildPermitsContextOptions): Promise<PermitsContext>;
|
|
126
|
+
/**
|
|
127
|
+
* A context that appends nothing and detects nothing — the injectable
|
|
128
|
+
* default for options that accept `permits` optionally, so a test exercising
|
|
129
|
+
* unrelated logic spawns exactly as it did before this workstream. Every
|
|
130
|
+
* real entry point (`run`, `doctor --agents`, `nightshift author`,
|
|
131
|
+
* `nightshift as-built`/`publish`) builds and passes a real context instead
|
|
132
|
+
* of relying on this default.
|
|
133
|
+
*/
|
|
134
|
+
export declare const NOOP_PERMITS_CONTEXT: PermitsContext;
|
|
135
|
+
//# sourceMappingURL=permits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permits.d.ts","sourceRoot":"","sources":["../src/permits.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEhF;;;;;;;;GAQG;AAEH,kEAAkE;AAClE,MAAM,MAAM,SAAS,GACjB,OAAO,GACP,eAAe,GACf,aAAa,GACb,cAAc,GACd,eAAe,CAAC;AAEpB,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG,WAAW,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,CAMnD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GACxB,WAAW,GACX,cAAc,G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G,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC;AAgCD,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,gBAAgB,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC3B,wDAAwD;IACxD,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,EAAE,CAAC,EAAE,SAAS,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,cAAc,CAAC,CAkDzB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,EAAE,cASlC,CAAC"}
|
package/dist/permits.js
ADDED
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { rmSync } from "node:fs";
|
|
3
|
+
import { rm as nodeRm, writeFile as nodeWriteFile } from "node:fs/promises";
|
|
4
|
+
import { platform as osPlatform, tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import crossSpawn from "cross-spawn";
|
|
7
|
+
/**
|
|
8
|
+
* Fixed per-role postures — mirrors the write/exec split `agent-probe.ts`
|
|
9
|
+
* already encoded as WRITE_ROLES/EXEC_ROLES. Exported so the probe sources
|
|
10
|
+
* its write/read split from here rather than keeping a second copy that can
|
|
11
|
+
* drift.
|
|
12
|
+
*/
|
|
13
|
+
export const ROLE_POSTURE = {
|
|
14
|
+
agent: "workspace",
|
|
15
|
+
recoveryAgent: "workspace",
|
|
16
|
+
authorAgent: "workspace",
|
|
17
|
+
deciderAgent: "read-only",
|
|
18
|
+
reviewerAgent: "read-only",
|
|
19
|
+
};
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Explicit flags win (SC-05)
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
const CLAUDE_PERMISSION_FLAGS = [
|
|
24
|
+
"--permission-mode",
|
|
25
|
+
"--allowedTools",
|
|
26
|
+
"--allowed-tools",
|
|
27
|
+
"--disallowedTools",
|
|
28
|
+
"--dangerously-skip-permissions",
|
|
29
|
+
"--settings",
|
|
30
|
+
];
|
|
31
|
+
const CODEX_SANDBOX_FLAG = "--sandbox";
|
|
32
|
+
function permissionFlagsFor(command) {
|
|
33
|
+
if (command === "claude")
|
|
34
|
+
return CLAUDE_PERMISSION_FLAGS;
|
|
35
|
+
if (command === "codex")
|
|
36
|
+
return [CODEX_SANDBOX_FLAG];
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
// Command transcript observability (WS-02)
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
const OUTPUT_FORMAT_FLAG = "--output-format";
|
|
43
|
+
/** True when the agent's own args already pin an output format — an operator
|
|
44
|
+
* who chose one (stream-json or otherwise) keeps it untouched. */
|
|
45
|
+
function hasOutputFormatFlag(agent) {
|
|
46
|
+
return agent.args.some((arg) => {
|
|
47
|
+
const token = arg.includes("=") ? arg.slice(0, arg.indexOf("=")) : arg;
|
|
48
|
+
return token === OUTPUT_FORMAT_FLAG;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The two flags that turn a Claude spawn's stdout into the NDJSON stream
|
|
53
|
+
* `src/agent-runner.ts`'s demultiplexer reads (WS-02). `--verbose` is
|
|
54
|
+
* required alongside `--output-format stream-json`: in print mode the CLI
|
|
55
|
+
* emits only the final result event unless `--verbose` is set, and the
|
|
56
|
+
* demultiplexer needs the intermediate `tool_use` events. Empty when the
|
|
57
|
+
* agent already pins its own output format — this derivation only adds
|
|
58
|
+
* flags, it never overrides one an operator wrote.
|
|
59
|
+
*/
|
|
60
|
+
function observabilityFlags(agent) {
|
|
61
|
+
return hasOutputFormatFlag(agent) ? [] : [OUTPUT_FORMAT_FLAG, "stream-json", "--verbose"];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* True when the agent's own args already carry a permission-bearing flag —
|
|
65
|
+
* `--flag value` and `--flag=value` both match. An agent that trips this is
|
|
66
|
+
* spawned untouched and labeled operator-configured; rewriting an operator's
|
|
67
|
+
* authored flags is the override the charter forbids.
|
|
68
|
+
*/
|
|
69
|
+
export function hasExplicitPermissionFlag(agent) {
|
|
70
|
+
const flags = permissionFlagsFor(agent.command);
|
|
71
|
+
if (flags.length === 0)
|
|
72
|
+
return false;
|
|
73
|
+
return agent.args.some((arg) => {
|
|
74
|
+
const token = arg.includes("=") ? arg.slice(0, arg.indexOf("=")) : arg;
|
|
75
|
+
return flags.includes(token);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
// permits config -> settings file content
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
/** One `--allowedTools`/settings allow entry per configured verify command. Relocated from verify-allowlist.ts. */
|
|
82
|
+
export function claudeVerifyAllowedTools(verify) {
|
|
83
|
+
return Object.values(verify).map((command) => `Bash(${command}:*)`);
|
|
84
|
+
}
|
|
85
|
+
function baseAllowDeny(verify, permits) {
|
|
86
|
+
return {
|
|
87
|
+
allow: [...claudeVerifyAllowedTools(verify), ...(permits?.allow ?? [])],
|
|
88
|
+
deny: [...(permits?.deny ?? [])],
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/** The workspace settings file: verify rules + permits.allow/deny, plus a sandbox block on darwin/linux. */
|
|
92
|
+
export function workspaceSettingsContent(verify, permits, platform) {
|
|
93
|
+
const { allow, deny } = baseAllowDeny(verify, permits);
|
|
94
|
+
const settings = { permissions: { allow, deny } };
|
|
95
|
+
if (platform === "darwin" || platform === "linux") {
|
|
96
|
+
settings.sandbox = { enabled: true, autoAllowBashIfSandboxed: true };
|
|
97
|
+
}
|
|
98
|
+
return JSON.stringify(settings, null, 2);
|
|
99
|
+
}
|
|
100
|
+
/** The read-only settings file: same allow/deny lists, never a sandbox block. */
|
|
101
|
+
export function readOnlySettingsContent(verify, permits) {
|
|
102
|
+
const { allow, deny } = baseAllowDeny(verify, permits);
|
|
103
|
+
return JSON.stringify({ permissions: { allow, deny } }, null, 2);
|
|
104
|
+
}
|
|
105
|
+
const UNDETECTED_CAPABILITIES = {
|
|
106
|
+
detected: false,
|
|
107
|
+
autoMode: false,
|
|
108
|
+
dontAskMode: false,
|
|
109
|
+
permissionPrompts: false,
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Turns a finished `--help` spawn into its text or a rejection. Exported so
|
|
113
|
+
* the nonzero-exit-code case (a `claude` on PATH that fails, rather than a
|
|
114
|
+
* missing command) is unit-testable without an actual child process: a
|
|
115
|
+
* nonzero exit must be reported as a detection failure, never parsed as if
|
|
116
|
+
* it were successful help output.
|
|
117
|
+
*/
|
|
118
|
+
export function helpRunnerOutcome(code, output) {
|
|
119
|
+
if (code === 0)
|
|
120
|
+
return output;
|
|
121
|
+
throw new Error(`claude --help exited with code ${code ?? "null"}: ${output.slice(0, 500)}`);
|
|
122
|
+
}
|
|
123
|
+
export const defaultClaudeHelpRunner = (command) => new Promise((resolvePromise, rejectPromise) => {
|
|
124
|
+
let output = "";
|
|
125
|
+
const child = crossSpawn(command, ["--help"], {
|
|
126
|
+
windowsHide: true,
|
|
127
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
128
|
+
});
|
|
129
|
+
child.stdout?.setEncoding("utf8");
|
|
130
|
+
child.stderr?.setEncoding("utf8");
|
|
131
|
+
child.stdout?.on("data", (chunk) => (output += chunk));
|
|
132
|
+
child.stderr?.on("data", (chunk) => (output += chunk));
|
|
133
|
+
child.on("error", rejectPromise);
|
|
134
|
+
child.on("close", (code) => {
|
|
135
|
+
try {
|
|
136
|
+
resolvePromise(helpRunnerOutcome(code, output));
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
rejectPromise(error);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
/** The `--permission-mode` option's own text, up to the next `--flag` line. */
|
|
144
|
+
function optionBlock(helpText, flag) {
|
|
145
|
+
const idx = helpText.indexOf(flag);
|
|
146
|
+
if (idx === -1)
|
|
147
|
+
return "";
|
|
148
|
+
const rest = helpText.slice(idx + flag.length);
|
|
149
|
+
const stop = rest.match(/\n[^\S\r\n]*--/u);
|
|
150
|
+
return stop?.index === undefined ? rest : rest.slice(0, stop.index);
|
|
151
|
+
}
|
|
152
|
+
/** Parses `claude --help` text into capabilities. Exported for fixture-driven tests. */
|
|
153
|
+
export function parseClaudeHelp(helpText) {
|
|
154
|
+
const modeBlock = optionBlock(helpText, "--permission-mode");
|
|
155
|
+
return {
|
|
156
|
+
detected: true,
|
|
157
|
+
autoMode: /"auto"/u.test(modeBlock),
|
|
158
|
+
dontAskMode: /"dontAsk"/u.test(modeBlock),
|
|
159
|
+
permissionPrompts: /--permission-prompts\b/u.test(helpText),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Detects once per process per resolved command string, caching the promise
|
|
164
|
+
* so concurrent derivations for the same command share one spawn. Detection
|
|
165
|
+
* failure (not on PATH, a throwing help runner) is reported as
|
|
166
|
+
* `detected: false`, never thrown — the derivation then takes the fallback.
|
|
167
|
+
*/
|
|
168
|
+
const capabilityCache = new Map();
|
|
169
|
+
export function detectClaudeCapabilities(command, helpRunner = defaultClaudeHelpRunner) {
|
|
170
|
+
let cached = capabilityCache.get(command);
|
|
171
|
+
if (!cached) {
|
|
172
|
+
cached = helpRunner(command).then(parseClaudeHelp).catch(() => UNDETECTED_CAPABILITIES);
|
|
173
|
+
capabilityCache.set(command, cached);
|
|
174
|
+
}
|
|
175
|
+
return cached;
|
|
176
|
+
}
|
|
177
|
+
/** Test-only: clears the process-wide capability cache between fixture scenarios. */
|
|
178
|
+
export function resetClaudeCapabilityCacheForTests() {
|
|
179
|
+
capabilityCache.clear();
|
|
180
|
+
}
|
|
181
|
+
function deriveClaude(input) {
|
|
182
|
+
const { agent, role, containmentEnv, platform, claudeCapabilities, workspaceSettingsPath, readOnlySettingsPath } = input;
|
|
183
|
+
const posture = ROLE_POSTURE[role];
|
|
184
|
+
const caps = claudeCapabilities ?? UNDETECTED_CAPABILITIES;
|
|
185
|
+
const observability = observabilityFlags(agent);
|
|
186
|
+
if (posture === "read-only") {
|
|
187
|
+
if (caps.dontAskMode) {
|
|
188
|
+
const args = [...agent.args, "--permission-mode", "dontAsk", "--settings", readOnlySettingsPath];
|
|
189
|
+
if (caps.permissionPrompts)
|
|
190
|
+
args.push("--permission-prompts", "none");
|
|
191
|
+
args.push(...observability);
|
|
192
|
+
return {
|
|
193
|
+
agent: { ...agent, args },
|
|
194
|
+
label: "read-only",
|
|
195
|
+
operatorConfigured: false,
|
|
196
|
+
settingsPath: readOnlySettingsPath,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
const args = [
|
|
200
|
+
...agent.args,
|
|
201
|
+
"--permission-mode",
|
|
202
|
+
"default",
|
|
203
|
+
"--settings",
|
|
204
|
+
readOnlySettingsPath,
|
|
205
|
+
...observability,
|
|
206
|
+
];
|
|
207
|
+
return {
|
|
208
|
+
agent: { ...agent, args },
|
|
209
|
+
label: caps.detected ? "read-only fallback (default+verify)" : "read-only fallback (detection failed)",
|
|
210
|
+
operatorConfigured: false,
|
|
211
|
+
settingsPath: readOnlySettingsPath,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
// workspace posture
|
|
215
|
+
if (containmentEnv === "ephemeral") {
|
|
216
|
+
const args = [
|
|
217
|
+
...agent.args,
|
|
218
|
+
"--dangerously-skip-permissions",
|
|
219
|
+
"--settings",
|
|
220
|
+
workspaceSettingsPath,
|
|
221
|
+
...observability,
|
|
222
|
+
];
|
|
223
|
+
return {
|
|
224
|
+
agent: { ...agent, args },
|
|
225
|
+
label: "ephemeral",
|
|
226
|
+
operatorConfigured: false,
|
|
227
|
+
settingsPath: workspaceSettingsPath,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
if (caps.autoMode) {
|
|
231
|
+
const args = [...agent.args, "--permission-mode", "auto", "--settings", workspaceSettingsPath];
|
|
232
|
+
if (caps.permissionPrompts)
|
|
233
|
+
args.push("--permission-prompts", "none");
|
|
234
|
+
args.push(...observability);
|
|
235
|
+
const sandboxed = platform === "darwin" || platform === "linux";
|
|
236
|
+
return {
|
|
237
|
+
agent: { ...agent, args },
|
|
238
|
+
label: sandboxed ? "auto+sandbox" : "auto",
|
|
239
|
+
operatorConfigured: false,
|
|
240
|
+
settingsPath: workspaceSettingsPath,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
const args = [
|
|
244
|
+
...agent.args,
|
|
245
|
+
"--permission-mode",
|
|
246
|
+
"acceptEdits",
|
|
247
|
+
"--settings",
|
|
248
|
+
workspaceSettingsPath,
|
|
249
|
+
...observability,
|
|
250
|
+
];
|
|
251
|
+
return {
|
|
252
|
+
agent: { ...agent, args },
|
|
253
|
+
label: caps.detected ? "fallback (acceptEdits+verify)" : "fallback (detection failed)",
|
|
254
|
+
operatorConfigured: false,
|
|
255
|
+
settingsPath: workspaceSettingsPath,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
const CODEX_DENY_NOTE = "codex has no per-command deny rules; permits.deny does not bind on this seat.";
|
|
259
|
+
function deriveCodex(input) {
|
|
260
|
+
const { agent, role, containmentEnv, platform } = input;
|
|
261
|
+
const posture = ROLE_POSTURE[role];
|
|
262
|
+
if (posture === "read-only") {
|
|
263
|
+
// Said explicitly, never assumed: `codex exec` ships read-only by
|
|
264
|
+
// default, but a user config can widen that default (a Windows
|
|
265
|
+
// `sandbox = "elevated"` setting, a trusted-project entry), and a seat
|
|
266
|
+
// labeled read-only that can write is the legibility failure this
|
|
267
|
+
// module exists to prevent. Independent of containment — a read-only
|
|
268
|
+
// seat has no reason to escalate on an ephemeral host either.
|
|
269
|
+
const args = [...agent.args, "--sandbox", "read-only"];
|
|
270
|
+
return { agent: { ...agent, args }, label: "read-only", operatorConfigured: false, note: CODEX_DENY_NOTE };
|
|
271
|
+
}
|
|
272
|
+
if (containmentEnv === "ephemeral") {
|
|
273
|
+
// Left at its own sandbox — an ephemeral host has no reason to escalate
|
|
274
|
+
// codex further, and codex ships no skip-permissions equivalent.
|
|
275
|
+
return { agent, label: "ephemeral", operatorConfigured: false, note: CODEX_DENY_NOTE };
|
|
276
|
+
}
|
|
277
|
+
const args = [...agent.args, "--sandbox", "workspace-write"];
|
|
278
|
+
const sandboxed = platform === "darwin" || platform === "linux";
|
|
279
|
+
return {
|
|
280
|
+
agent: { ...agent, args },
|
|
281
|
+
label: sandboxed ? "auto+sandbox" : "auto",
|
|
282
|
+
operatorConfigured: false,
|
|
283
|
+
note: CODEX_DENY_NOTE,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* The whole derivation, pure: role + posture + containment + capabilities +
|
|
288
|
+
* the agent's existing args -> the flags to spawn with. No I/O — capability
|
|
289
|
+
* detection and the settings-file write happen in the context builder below.
|
|
290
|
+
*/
|
|
291
|
+
export function deriveAgentInvocation(input) {
|
|
292
|
+
if (hasExplicitPermissionFlag(input.agent)) {
|
|
293
|
+
return { agent: input.agent, label: "operator-configured", operatorConfigured: true };
|
|
294
|
+
}
|
|
295
|
+
if (input.agent.command === "claude")
|
|
296
|
+
return deriveClaude(input);
|
|
297
|
+
if (input.agent.command === "codex")
|
|
298
|
+
return deriveCodex(input);
|
|
299
|
+
// Any other provider: no known flag vocabulary — deriving the wrong flag
|
|
300
|
+
// is worse than deriving none.
|
|
301
|
+
return { agent: input.agent, label: "unmanaged", operatorConfigured: false };
|
|
302
|
+
}
|
|
303
|
+
const realPermitsFs = {
|
|
304
|
+
writeFile: (path, content) => nodeWriteFile(path, content, "utf8"),
|
|
305
|
+
rm: (path) => nodeRm(path, { force: true }),
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* Settings files written by contexts that have not been disposed yet. One
|
|
309
|
+
* exit hook, registered on first use, removes them synchronously — the only
|
|
310
|
+
* kind of work an `exit` handler can do — so a run that crashes mid-way, a
|
|
311
|
+
* test process, or a command that never reaches its own dispose still leaves
|
|
312
|
+
* the temp directory as it found it.
|
|
313
|
+
*/
|
|
314
|
+
const undisposedSettingsPaths = new Set();
|
|
315
|
+
let exitHookRegistered = false;
|
|
316
|
+
function registerExitCleanup() {
|
|
317
|
+
if (exitHookRegistered)
|
|
318
|
+
return;
|
|
319
|
+
exitHookRegistered = true;
|
|
320
|
+
process.on("exit", () => {
|
|
321
|
+
for (const path of undisposedSettingsPaths) {
|
|
322
|
+
try {
|
|
323
|
+
rmSync(path, { force: true });
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
// Best effort at exit; nothing useful can be reported from here.
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
undisposedSettingsPaths.clear();
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Builds the run's (or doctor probe's, or as-built refresh's) one
|
|
334
|
+
* `PermitsContext`: writes the two settings files once under `os.tmpdir()`
|
|
335
|
+
* and returns a `derive` function that detects claude's capabilities on
|
|
336
|
+
* first use per command string and applies the pure derivation above.
|
|
337
|
+
*/
|
|
338
|
+
export async function buildPermitsContext(options) {
|
|
339
|
+
const platform = options.platform ?? osPlatform();
|
|
340
|
+
const containmentEnv = options.containmentEnv ?? process.env.NIGHTSHIFT_CONTAINMENT;
|
|
341
|
+
const helpRunner = options.helpRunner ?? defaultClaudeHelpRunner;
|
|
342
|
+
const fs = options.fs ?? realPermitsFs;
|
|
343
|
+
const nonce = randomBytes(4).toString("hex");
|
|
344
|
+
const workspaceSettingsPath = join(tmpdir(), `nightshift-permits-${nonce}-workspace.json`);
|
|
345
|
+
const readOnlySettingsPath = join(tmpdir(), `nightshift-permits-${nonce}-read-only.json`);
|
|
346
|
+
await fs.writeFile(workspaceSettingsPath, workspaceSettingsContent(options.config.verify, options.config.permits, platform));
|
|
347
|
+
await fs.writeFile(readOnlySettingsPath, readOnlySettingsContent(options.config.verify, options.config.permits));
|
|
348
|
+
// Only real files are tracked for exit cleanup; an injected fake fs wrote
|
|
349
|
+
// nowhere the hook could (or should) remove.
|
|
350
|
+
const tracked = options.fs === undefined;
|
|
351
|
+
if (tracked) {
|
|
352
|
+
registerExitCleanup();
|
|
353
|
+
undisposedSettingsPaths.add(workspaceSettingsPath);
|
|
354
|
+
undisposedSettingsPaths.add(readOnlySettingsPath);
|
|
355
|
+
}
|
|
356
|
+
return {
|
|
357
|
+
workspaceSettingsPath,
|
|
358
|
+
readOnlySettingsPath,
|
|
359
|
+
async dispose() {
|
|
360
|
+
for (const path of [workspaceSettingsPath, readOnlySettingsPath]) {
|
|
361
|
+
undisposedSettingsPaths.delete(path);
|
|
362
|
+
await fs.rm?.(path);
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
async derive(role, agent) {
|
|
366
|
+
const claudeCapabilities = agent.command === "claude" ? await detectClaudeCapabilities(agent.command, helpRunner) : undefined;
|
|
367
|
+
return deriveAgentInvocation({
|
|
368
|
+
role,
|
|
369
|
+
agent,
|
|
370
|
+
containmentEnv,
|
|
371
|
+
platform,
|
|
372
|
+
claudeCapabilities,
|
|
373
|
+
workspaceSettingsPath,
|
|
374
|
+
readOnlySettingsPath,
|
|
375
|
+
});
|
|
376
|
+
},
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* A context that appends nothing and detects nothing — the injectable
|
|
381
|
+
* default for options that accept `permits` optionally, so a test exercising
|
|
382
|
+
* unrelated logic spawns exactly as it did before this workstream. Every
|
|
383
|
+
* real entry point (`run`, `doctor --agents`, `nightshift author`,
|
|
384
|
+
* `nightshift as-built`/`publish`) builds and passes a real context instead
|
|
385
|
+
* of relying on this default.
|
|
386
|
+
*/
|
|
387
|
+
export const NOOP_PERMITS_CONTEXT = {
|
|
388
|
+
workspaceSettingsPath: "",
|
|
389
|
+
readOnlySettingsPath: "",
|
|
390
|
+
derive(_role, agent) {
|
|
391
|
+
return Promise.resolve({ agent, label: "operator-configured", operatorConfigured: true });
|
|
392
|
+
},
|
|
393
|
+
dispose() {
|
|
394
|
+
return Promise.resolve();
|
|
395
|
+
},
|
|
396
|
+
};
|
|
397
|
+
//# sourceMappingURL=permits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permits.js","sourceRoot":"","sources":["../src/permits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,UAAU,MAAM,aAAa,CAAC;AAuBrC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAA+B;IACtD,KAAK,EAAE,WAAW;IAClB,aAAa,EAAE,WAAW;IAC1B,WAAW,EAAE,WAAW;IACxB,YAAY,EAAE,WAAW;IACzB,aAAa,EAAE,WAAW;CAC3B,CAAC;AA+BF,8EAA8E;AAC9E,6BAA6B;AAC7B,8EAA8E;AAE9E,MAAM,uBAAuB,GAAG;IAC9B,mBAAmB;IACnB,gBAAgB;IAChB,iBAAiB;IACjB,mBAAmB;IACnB,gCAAgC;IAChC,YAAY;CACb,CAAC;AACF,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAEvC,SAAS,kBAAkB,CAAC,OAAe;IACzC,IAAI,OAAO,KAAK,QAAQ;QAAE,OAAO,uBAAuB,CAAC;IACzD,IAAI,OAAO,KAAK,OAAO;QAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACrD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,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CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAmB;IAClD,qBAAqB,EAAE,EAAE;IACzB,oBAAoB,EAAE,EAAE;IACxB,MAAM,CAAC,KAAK,EAAE,KAAK;QACjB,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO;QACL,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF,CAAC"}
|
package/dist/publish.d.ts
CHANGED
|
@@ -55,6 +55,17 @@ export interface GhClient {
|
|
|
55
55
|
updateComment(cwd: string, commentId: string, body: string): Promise<void>;
|
|
56
56
|
/** Removes a now-stale nightshift-authored comment. */
|
|
57
57
|
deleteComment(cwd: string, commentId: string): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* GitHub's mergeability computation for a PR, as raw gh strings. `mergeable`
|
|
60
|
+
* is one of MERGEABLE | CONFLICTING | UNKNOWN; `mergeStateStatus` is the
|
|
61
|
+
* fuller state (CLEAN | DIRTY | BLOCKED | BEHIND | DRAFT | UNSTABLE |
|
|
62
|
+
* HAS_HOOKS | UNKNOWN). Normalization and the UNKNOWN retry live in
|
|
63
|
+
* `publish`, not here, so the boundary stays thin and the retry is testable.
|
|
64
|
+
*/
|
|
65
|
+
viewMergeability(cwd: string, prNumber: number): Promise<{
|
|
66
|
+
mergeable: string;
|
|
67
|
+
mergeStateStatus: string;
|
|
68
|
+
}>;
|
|
58
69
|
}
|
|
59
70
|
/**
|
|
60
71
|
* Git operations `publish` needs beyond `program-branch.ts`'s derivation —
|
|
@@ -112,7 +123,23 @@ export interface PublishOptions {
|
|
|
112
123
|
/** Passed straight through to the pre-publish as-built refresh; default reviewer runner. */
|
|
113
124
|
agentRunner?: AgentRunner;
|
|
114
125
|
log?: (line: string) => void;
|
|
126
|
+
/** Injected for tests so the UNKNOWN retry does not actually wait. */
|
|
127
|
+
sleep?: (ms: number) => Promise<void>;
|
|
115
128
|
}
|
|
129
|
+
/** GitHub's answer to "does this PR merge cleanly into its base?" */
|
|
130
|
+
export type MergeableState = "mergeable" | "conflicting" | "unknown";
|
|
131
|
+
/** What the pre-publish base sync did. */
|
|
132
|
+
export type BaseSyncOutcome = {
|
|
133
|
+
status: "up-to-date";
|
|
134
|
+
} | {
|
|
135
|
+
status: "merged";
|
|
136
|
+
} | {
|
|
137
|
+
status: "conflict";
|
|
138
|
+
paths: string[];
|
|
139
|
+
} | {
|
|
140
|
+
status: "skipped";
|
|
141
|
+
reason: string;
|
|
142
|
+
};
|
|
116
143
|
export interface PublishResult {
|
|
117
144
|
prNumber: number;
|
|
118
145
|
prUrl: string;
|
|
@@ -121,7 +148,15 @@ export interface PublishResult {
|
|
|
121
148
|
escalationComments: number;
|
|
122
149
|
/** Report-continuation comments upserted this publish (0 when the report fits). */
|
|
123
150
|
continuationComments: number;
|
|
151
|
+
/** GitHub's mergeable state for the upserted PR (SC-07). */
|
|
152
|
+
mergeable: MergeableState;
|
|
153
|
+
/** What the pre-publish base sync did (SC-08). */
|
|
154
|
+
baseSync: BaseSyncOutcome;
|
|
124
155
|
}
|
|
156
|
+
/** The named `nightshift publish` / `nightshift run --publish` mergeability line (SC-07). */
|
|
157
|
+
export declare function mergeabilityLine(mergeable: MergeableState): string;
|
|
158
|
+
/** The named `nightshift publish` / `nightshift run --publish` base-sync line (SC-08). */
|
|
159
|
+
export declare function baseSyncLine(baseSync: BaseSyncOutcome): string;
|
|
125
160
|
interface ReportChunk {
|
|
126
161
|
/** A verbatim, contiguous slice of the report — never rewritten or decorated. */
|
|
127
162
|
payload: string;
|
package/dist/publish.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAKA,OAAO,EAAwB,KAAK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