@primitive.ai/prim 0.1.0-alpha.112 → 0.1.0-alpha.113
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 +7 -4
- package/SKILL.md +10 -16
- package/dist/hook-runtime/hooks/pre-tool-use.js +30 -6
- package/dist/hook-runtime/index.js +13 -65
- package/dist/hooks/pre-tool-use.js +30 -6
- package/dist/index.js +13 -65
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ presence — from the command line and via session + git hooks.
|
|
|
10
10
|
> [!NOTE]
|
|
11
11
|
> **Conflict Gates** check each edit against the decision graph and surface any
|
|
12
12
|
> load-bearing decision it conflicts with. When **Enforcement** is enabled for your
|
|
13
|
-
> organization, gates can warn, pause, or block a conflicting edit until you
|
|
13
|
+
> organization, gates can warn, pause, or block a conflicting edit until you resolve
|
|
14
14
|
> the decision and retry. Automatic decision capture in active repositories is separate.
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
@@ -365,7 +365,7 @@ would create a cycle (exit 2); an unresolved id exits 4.
|
|
|
365
365
|
### Reconcile
|
|
366
366
|
|
|
367
367
|
```bash
|
|
368
|
-
prim reconcile <id> #
|
|
368
|
+
prim reconcile <id> # Rejected: human_approval_required (exit 2)
|
|
369
369
|
```
|
|
370
370
|
|
|
371
371
|
Record what happened after resolving a specific conflict:
|
|
@@ -381,8 +381,11 @@ The conflict output supplies the check ID. Only the person whose edit was
|
|
|
381
381
|
checked can resolve that check. Repeating the same outcome is safe; changing an
|
|
382
382
|
already recorded outcome is rejected. These declarations do not issue a bypass.
|
|
383
383
|
|
|
384
|
-
|
|
385
|
-
|
|
384
|
+
Bypasses are disabled until an agent host can supply verifiable human approval.
|
|
385
|
+
Bare `prim reconcile <id>` rejects locally, including with `--yes`,
|
|
386
|
+
`--non-interactive`, or `--flag`. Sandbox escalation and automatic approval
|
|
387
|
+
review do not authorize an override. A blocked edit must remain blocked or be
|
|
388
|
+
changed to respect the governing Decisions.
|
|
386
389
|
|
|
387
390
|
### Hooks
|
|
388
391
|
|
package/SKILL.md
CHANGED
|
@@ -9,7 +9,7 @@ description: Use the prim CLI for Primitive’s decision graph. MUST INVOKE befo
|
|
|
9
9
|
|
|
10
10
|
## Mental model
|
|
11
11
|
|
|
12
|
-
In an active repo, prim passively captures the **decisions** your team makes -- which library, which pattern, which config value -- into a queryable graph, and links them: a decision can depend on earlier decisions (auto-linked from shared files, or related by hand — see *Relate decisions*) and reference the files it touched. **Conflict Gates** can check a later change against that graph and surface any load-bearing decision it conflicts with. When **Enforcement** is enabled for an organization, prim can warn, pause, or block the edit until you
|
|
12
|
+
In an active repo, prim passively captures the **decisions** your team makes -- which library, which pattern, which config value -- into a queryable graph, and links them: a decision can depend on earlier decisions (auto-linked from shared files, or related by hand — see *Relate decisions*) and reference the files it touched. **Conflict Gates** can check a later change against that graph and surface any load-bearing decision it conflicts with. When **Enforcement** is enabled for an organization, prim can warn, pause, or block the edit until you resolve the conflict. Capture in active repos runs independently.
|
|
13
13
|
|
|
14
14
|
Low-level capture runs automatically in active repos through the session hooks installed by `npx --yes @primitive.ai/prim claude install` (Claude Code), `npx --yes @primitive.ai/prim cursor install` (Cursor), `npx --yes @primitive.ai/prim codex install` (Codex), or `npx --yes @primitive.ai/prim hermes install` (Hermes). An inactive repo is not passively captured. Deliberately record higher-order forks in the road through `prim decisions create` as described below. Your job is also to **read** the graph before load-bearing edits and **answer** the occasional rationale confirmation. (Responding to Conflict Gates applies only once Enforcement is enabled — see below.)
|
|
15
15
|
|
|
@@ -34,12 +34,12 @@ The CLI auto-refreshes a still-valid session from the stored refresh token (proa
|
|
|
34
34
|
|
|
35
35
|
## Conflict Gates & Enforcement
|
|
36
36
|
|
|
37
|
-
**Conflict Gates** check each edit against the decision graph before it lands and surface any load-bearing decision it conflicts with. When **Enforcement** is enabled for an organization, a conflicting edit can be warned, blocked, or paused for confirmation until you
|
|
37
|
+
**Conflict Gates** check each edit against the decision graph before it lands and surface any load-bearing decision it conflicts with. When **Enforcement** is enabled for an organization, a conflicting edit can be warned, blocked, or paused for confirmation until you resolve the conflict. Automatic decision capture in active repos (above) runs independently.
|
|
38
38
|
|
|
39
39
|
When Enforcement is enabled, before an edit (Claude Code: Edit/Write/MultiEdit; Cursor: Write/Delete/Shell; Codex: apply_patch; Hermes: write_file/patch) a PreToolUse hook scores the target file against the graph:
|
|
40
40
|
|
|
41
|
-
- **deny** -- the edit is blocked
|
|
42
|
-
- **warn / additional context** -- the edit proceeds, but a relevant prior decision is surfaced. Read it. Cursor, Codex, and Hermes
|
|
41
|
+
- **deny** -- the edit is blocked. Name each governing Decision and the proposed conflicting edit. Overriding a Decision requires explicit human approval for that specific override. Reconcile bypasses are disabled until a host can provide verifiable human approval; keep the edit blocked and choose a compatible approach.
|
|
42
|
+
- **warn / additional context** -- the edit proceeds, but a relevant prior decision is surfaced. Read it. Cursor, Codex, and Hermes map a would-be `ask` to **deny**. Do not change gate settings, use sandbox escalation, or request prefix permissions to evade the block. Automatic approval review, `--yes`, and an agent assertion are not human approval.
|
|
43
43
|
- **"decision check skipped / not verified" or "... partial / truncated"** -- the check could not fully run. Treat constraints as UNKNOWN, not clear; never read silence as approval.
|
|
44
44
|
|
|
45
45
|
When enabled, the gate sends its preflight check directly to Primitive and fail-opens on infrastructure errors (for example, a network failure or org-unbound token) -- a service problem would not block your edit. That is why an "unavailable" note matters: it is the honest signal that the check, not your edit, is what failed.
|
|
@@ -64,17 +64,11 @@ internal record ID is needed to construct a link. Full IDs remain accepted only
|
|
|
64
64
|
as legacy inputs; never ask for or print them. Public JSON identity fields contain
|
|
65
65
|
prefixed short IDs; `shortId` remains a bare eight-character compatibility alias.
|
|
66
66
|
|
|
67
|
-
##
|
|
67
|
+
## Record a resolution
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
Bare `prim reconcile <idOrShortId>` rejects with `human_approval_required` and exit 2. It cannot grant permission to edit, including with `--flag`, `--yes`, or `--non-interactive`.
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
✓ Conflict caught before merge · N decisions saved · <author>'s intent preserved
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
`N` is the reconciled decision's downstream live-dependent count, shown as `N+` when the server caps it.
|
|
71
|
+
After resolving a conflict, record the actual outcome with `prim reconcile <id> --check <checkId> --outcome followed|superseded`. Use `followed` when you retained the Decision. Use `superseded` only after an explicitly authorized replacement has already been persisted. Recording an outcome does not bypass the gate or change a Decision.
|
|
78
72
|
|
|
79
73
|
## Answer rationale confirmations
|
|
80
74
|
|
|
@@ -364,8 +358,8 @@ Examples:
|
|
|
364
358
|
## Pitfalls
|
|
365
359
|
|
|
366
360
|
- **An "unavailable" / "not verified" decision check is not an all-clear.** Treat constraints as UNKNOWN and proceed deliberately; never read the silence as approval — the same holds for Conflict Gates once enabled.
|
|
367
|
-
- **When Enforcement is enabled, a `deny` means a real prior decision conflicts.**
|
|
368
|
-
- **Reconcile bypasses are
|
|
361
|
+
- **When Enforcement is enabled, a `deny` means a real prior decision conflicts.** Keep the edit blocked and pick an approach that respects it; intention alone never authorizes an override.
|
|
362
|
+
- **Reconcile bypasses are disabled.** Human approval cannot be inferred from tool execution or automatic review.
|
|
369
363
|
- **Capture of coding activity is automatic only in active repos; never inject moves by hand.** If an active repo's decisions aren't showing up, check that the session hooks are installed (`claude status` / `cursor status` / `codex status` / `hermes status`) and the daemon is running. Deliberately authoring a higher-order fork—either at the user's request or under the conservative proactive policy above—is a separate, supported path through `decisions create`; in an inactive repo, honor the per-invocation approval boundary above.
|
|
370
364
|
- **Don't fabricate rationale on a confirmation.** If you don't know why a decision was made, say so rather than guessing.
|
|
371
365
|
|
|
@@ -373,4 +367,4 @@ Examples:
|
|
|
373
367
|
|
|
374
368
|
If the user clearly made a durable fork-in-the-road decision, check recent decisions and record it now if it is not already present when capture is active — asking the single rationale question first when the why is not deducible from available context. When capture is inactive, record it only if the user explicitly requested that create; otherwise present it for the per-invocation approval above. If a strong higher-order decision was only inferred, decide whether it clears the interruption budget; if so, ask the single concise confirmation question after reporting the completed work. Otherwise say nothing about Primitive.
|
|
375
369
|
|
|
376
|
-
If Conflict Gates are enabled and one denied or warned you, report which decision(s) it named and
|
|
370
|
+
If Conflict Gates are enabled and one denied or warned you, report which decision(s) it named and how the conflict was resolved or why the edit remains blocked. If you read the graph before a load-bearing change, note what you found so the user can verify in the dashboard.
|
|
@@ -28592,24 +28592,47 @@ async function requestPreflight(request2, signal = AbortSignal.timeout(PREFLIGHT
|
|
|
28592
28592
|
});
|
|
28593
28593
|
return parsePreflightResponse(response);
|
|
28594
28594
|
}
|
|
28595
|
-
function
|
|
28595
|
+
function proposedChangeExcerpt(proposal) {
|
|
28596
|
+
try {
|
|
28597
|
+
const input = JSON.parse(proposal);
|
|
28598
|
+
if (input && typeof input === "object") {
|
|
28599
|
+
for (const key of ["new_string", "new_str", "content", "command"]) {
|
|
28600
|
+
if (typeof input[key] === "string") return boundedHealthError(input[key]);
|
|
28601
|
+
}
|
|
28602
|
+
}
|
|
28603
|
+
} catch {
|
|
28604
|
+
}
|
|
28605
|
+
return boundedHealthError(proposal);
|
|
28606
|
+
}
|
|
28607
|
+
function resultForPreflight(response, preview = "Review the requested change.", invocation) {
|
|
28596
28608
|
const verdict = response.verdict === "block" ? "deny" : response.verdict;
|
|
28597
28609
|
const message = boundedHealthError(response.message) ?? "";
|
|
28598
28610
|
const unavailable = message || boundedHealthError(response.reasonCode);
|
|
28599
28611
|
const safe = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
|
|
28600
28612
|
const directives = response.conflicts.flatMap((value) => {
|
|
28601
28613
|
if (!value || typeof value !== "object") return [];
|
|
28602
|
-
const { decisionId, shortId } = value;
|
|
28614
|
+
const { decisionId, shortId, title } = value;
|
|
28603
28615
|
const id = typeof shortId === "string" && /^[0-9a-f]{8}$/u.test(shortId) ? `dec_${shortId}` : typeof decisionId === "string" && /^dec_[0-9a-f]{8}$/u.test(decisionId) ? decisionId : void 0;
|
|
28604
28616
|
if (!id) return [];
|
|
28605
28617
|
return [
|
|
28606
|
-
`
|
|
28618
|
+
`Governing Decision ${id}${typeof title === "string" && boundedHealthError(title) ? `: ${boundedHealthError(title)}` : ""}.`,
|
|
28607
28619
|
...response.checkId && safe.test(response.checkId) ? [
|
|
28608
|
-
`Check: ${response.checkId}. After resolving, record the confirmed outcome: prim reconcile ${id} --check ${response.checkId} --outcome followed (retained Decision), or --outcome superseded (after replacing it).
|
|
28620
|
+
`Check: ${response.checkId}. After resolving, record the confirmed outcome: prim reconcile ${id} --check ${response.checkId} --outcome followed (retained Decision), or --outcome superseded (after replacing it). Recording a resolution does not authorize an override.`
|
|
28609
28621
|
] : []
|
|
28610
28622
|
];
|
|
28611
28623
|
});
|
|
28612
|
-
const
|
|
28624
|
+
const blocked = response.verdict === "ask" || response.verdict === "block";
|
|
28625
|
+
const proposal = invocation ? proposedChangeExcerpt(invocation.proposal) : void 0;
|
|
28626
|
+
const editContext = blocked && invocation ? [
|
|
28627
|
+
`Proposed edit to: ${invocation.paths.map((path) => boundedHealthError(path)).join(", ")}.`,
|
|
28628
|
+
...proposal ? [`Proposed change (excerpt): ${proposal}`] : []
|
|
28629
|
+
] : [];
|
|
28630
|
+
const approvalContext = blocked ? [
|
|
28631
|
+
"Overriding these Decisions requires explicit human approval naming each Decision and the proposed conflicting edit.",
|
|
28632
|
+
"Reconcile bypasses are disabled: this host integration cannot provide verifiable human approval for a bypass. Keep the edit blocked and choose a compatible change.",
|
|
28633
|
+
"Sandbox escalation, automatic review, prefix permissions, --yes, and an agent's assertion of approval do not authorize an override."
|
|
28634
|
+
] : [];
|
|
28635
|
+
const guidance = [message, ...editContext, ...new Set(directives), ...approvalContext].filter(Boolean).join("\n");
|
|
28613
28636
|
const reason = response.conflicts.length > 0 || response.verdict === "ask" || response.verdict === "block" ? approvalSummary(
|
|
28614
28637
|
{
|
|
28615
28638
|
conflicts: response.conflicts,
|
|
@@ -28819,7 +28842,8 @@ async function main() {
|
|
|
28819
28842
|
}
|
|
28820
28843
|
result = resultForPreflight(
|
|
28821
28844
|
response,
|
|
28822
|
-
editPreview(toolName, envelope.tool_input, targets.paths)
|
|
28845
|
+
editPreview(toolName, envelope.tool_input, targets.paths),
|
|
28846
|
+
request2
|
|
28823
28847
|
);
|
|
28824
28848
|
} catch (error) {
|
|
28825
28849
|
await emitUnverified(preflightFailure(error), envelope);
|
|
@@ -58239,34 +58239,10 @@ function registerMovesCommands(program3) {
|
|
|
58239
58239
|
}
|
|
58240
58240
|
|
|
58241
58241
|
// src/commands/reconcile.ts
|
|
58242
|
-
var EXIT_OK4 = 0;
|
|
58243
58242
|
var EXIT_USAGE2 = 2;
|
|
58244
58243
|
var EXIT_SERVER = 3;
|
|
58245
58244
|
var HTTP_CLIENT_ERROR_MIN = 400;
|
|
58246
58245
|
var HTTP_SERVER_ERROR_MIN = 500;
|
|
58247
|
-
function isOk(value) {
|
|
58248
|
-
if (typeof value !== "object" || value === null) {
|
|
58249
|
-
return false;
|
|
58250
|
-
}
|
|
58251
|
-
const v = value;
|
|
58252
|
-
return v.ok === true && typeof v.bypassId === "string" && typeof v.expiresAt === "number";
|
|
58253
|
-
}
|
|
58254
|
-
function formatExpiresIn(expiresAt) {
|
|
58255
|
-
const remainingMs = expiresAt - Date.now();
|
|
58256
|
-
if (remainingMs <= 0) {
|
|
58257
|
-
return "expired";
|
|
58258
|
-
}
|
|
58259
|
-
const SECONDS_PER_MINUTE = 60;
|
|
58260
|
-
const minutes = Math.floor(remainingMs / (SECONDS_PER_MINUTE * 1e3));
|
|
58261
|
-
const seconds = Math.floor(remainingMs / 1e3 % SECONDS_PER_MINUTE);
|
|
58262
|
-
if (minutes === 0) {
|
|
58263
|
-
return `${seconds}s`;
|
|
58264
|
-
}
|
|
58265
|
-
return `${minutes}m${seconds.toString().padStart(2, "0")}s`;
|
|
58266
|
-
}
|
|
58267
|
-
function renderDecisionIdentifier(short, id) {
|
|
58268
|
-
return renderIdentifier({ id, shortId: short });
|
|
58269
|
-
}
|
|
58270
58246
|
function isDomainRejection(err) {
|
|
58271
58247
|
return err instanceof HttpError && err.status >= HTTP_CLIENT_ERROR_MIN && err.status < HTTP_SERVER_ERROR_MIN;
|
|
58272
58248
|
}
|
|
@@ -58275,48 +58251,23 @@ async function performReconcile(idOrShortId, opts = {}) {
|
|
|
58275
58251
|
await performResolution(idOrShortId, opts);
|
|
58276
58252
|
return;
|
|
58277
58253
|
}
|
|
58278
|
-
const
|
|
58279
|
-
|
|
58280
|
-
if (opts.flag) {
|
|
58281
|
-
body.conflictFlagId = opts.flag;
|
|
58282
|
-
}
|
|
58283
|
-
let response;
|
|
58284
|
-
try {
|
|
58285
|
-
response = await client.post("/api/cli/reconcile/issue", body);
|
|
58286
|
-
} catch (err) {
|
|
58287
|
-
if (isDomainRejection(err)) {
|
|
58288
|
-
process.stderr.write(`[prim] reconcile rejected: ${err.message}
|
|
58254
|
+
const message = "Overriding a governing Decision requires explicit human approval. This host cannot provide verifiable human approval, so reconcile bypasses are disabled. Keep the edit blocked and choose a compatible change.";
|
|
58255
|
+
process.stderr.write(`[prim] reconcile rejected: ${message}
|
|
58289
58256
|
`);
|
|
58290
|
-
|
|
58291
|
-
|
|
58292
|
-
|
|
58293
|
-
|
|
58294
|
-
|
|
58295
|
-
|
|
58296
|
-
|
|
58297
|
-
|
|
58298
|
-
|
|
58299
|
-
return;
|
|
58300
|
-
}
|
|
58301
|
-
if (isOk(response)) {
|
|
58302
|
-
const ident = renderDecisionIdentifier(response.decisionShortId, response.decisionId);
|
|
58303
|
-
const verb = response.reissued ? "reissued" : "issued";
|
|
58304
|
-
process.stderr.write(
|
|
58305
|
-
`[prim] reconcile bypass ${verb} for ${ident} (expires in ${formatExpiresIn(response.expiresAt)})
|
|
58306
|
-
`
|
|
58307
|
-
);
|
|
58308
|
-
console.log(JSON.stringify(response, null, 2));
|
|
58309
|
-
process.exitCode = EXIT_OK4;
|
|
58310
|
-
return;
|
|
58311
|
-
}
|
|
58312
|
-
process.stderr.write("[prim] reconcile: malformed server response\n");
|
|
58313
|
-
console.log(JSON.stringify({ ok: false, response }, null, 2));
|
|
58314
|
-
process.exitCode = EXIT_SERVER;
|
|
58257
|
+
console.log(
|
|
58258
|
+
JSON.stringify({
|
|
58259
|
+
ok: false,
|
|
58260
|
+
error: "human_approval_required",
|
|
58261
|
+
decisionId: decisionIdentifier(idOrShortId),
|
|
58262
|
+
message
|
|
58263
|
+
})
|
|
58264
|
+
);
|
|
58265
|
+
process.exitCode = EXIT_USAGE2;
|
|
58315
58266
|
}
|
|
58316
58267
|
async function performResolution(idOrShortId, opts) {
|
|
58317
58268
|
if (!opts.check || !["followed", "superseded"].includes(opts.outcome ?? "") || opts.flag) {
|
|
58318
58269
|
process.stderr.write(
|
|
58319
|
-
"[prim] resolution requires --check <checkId> and --outcome followed|superseded; --flag is
|
|
58270
|
+
"[prim] resolution requires --check <checkId> and --outcome followed|superseded; --flag is unsupported because bypasses are disabled\n"
|
|
58320
58271
|
);
|
|
58321
58272
|
console.log(JSON.stringify({ ok: false, error: "invalid_resolution_arguments" }));
|
|
58322
58273
|
process.exitCode = EXIT_USAGE2;
|
|
@@ -58346,10 +58297,7 @@ async function performResolution(idOrShortId, opts) {
|
|
|
58346
58297
|
}
|
|
58347
58298
|
}
|
|
58348
58299
|
function registerReconcileCommands(program3) {
|
|
58349
|
-
program3.command("reconcile <idOrShortId>").description("Record a resolution
|
|
58350
|
-
"--flag <conflictFlagId>",
|
|
58351
|
-
"Specific flag id to bind the bypass to (default: the decision's latest unack'd flag)"
|
|
58352
|
-
).option("--check <checkId>", "Original conflict check to resolve; does not issue a bypass").option(
|
|
58300
|
+
program3.command("reconcile <idOrShortId>").description("Record a resolution for Conflict Gates Enforcement; bypasses are disabled").option("--flag <conflictFlagId>", "Legacy bypass flag (always rejected)").option("--check <checkId>", "Original conflict check to resolve; does not issue a bypass").option(
|
|
58353
58301
|
"--outcome <outcome>",
|
|
58354
58302
|
"Confirmed resolution: followed or superseded (requires --check)"
|
|
58355
58303
|
).option("--json", "(reserved; STDOUT is always JSON)").action(async (idOrShortId, opts) => {
|
|
@@ -210,24 +210,47 @@ async function requestPreflight(request, signal = AbortSignal.timeout(PREFLIGHT_
|
|
|
210
210
|
});
|
|
211
211
|
return parsePreflightResponse(response);
|
|
212
212
|
}
|
|
213
|
-
function
|
|
213
|
+
function proposedChangeExcerpt(proposal) {
|
|
214
|
+
try {
|
|
215
|
+
const input = JSON.parse(proposal);
|
|
216
|
+
if (input && typeof input === "object") {
|
|
217
|
+
for (const key of ["new_string", "new_str", "content", "command"]) {
|
|
218
|
+
if (typeof input[key] === "string") return boundedHealthError(input[key]);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
} catch {
|
|
222
|
+
}
|
|
223
|
+
return boundedHealthError(proposal);
|
|
224
|
+
}
|
|
225
|
+
function resultForPreflight(response, preview = "Review the requested change.", invocation) {
|
|
214
226
|
const verdict = response.verdict === "block" ? "deny" : response.verdict;
|
|
215
227
|
const message = boundedHealthError(response.message) ?? "";
|
|
216
228
|
const unavailable = message || boundedHealthError(response.reasonCode);
|
|
217
229
|
const safe = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
|
|
218
230
|
const directives = response.conflicts.flatMap((value) => {
|
|
219
231
|
if (!value || typeof value !== "object") return [];
|
|
220
|
-
const { decisionId, shortId } = value;
|
|
232
|
+
const { decisionId, shortId, title } = value;
|
|
221
233
|
const id = typeof shortId === "string" && /^[0-9a-f]{8}$/u.test(shortId) ? `dec_${shortId}` : typeof decisionId === "string" && /^dec_[0-9a-f]{8}$/u.test(decisionId) ? decisionId : void 0;
|
|
222
234
|
if (!id) return [];
|
|
223
235
|
return [
|
|
224
|
-
`
|
|
236
|
+
`Governing Decision ${id}${typeof title === "string" && boundedHealthError(title) ? `: ${boundedHealthError(title)}` : ""}.`,
|
|
225
237
|
...response.checkId && safe.test(response.checkId) ? [
|
|
226
|
-
`Check: ${response.checkId}. After resolving, record the confirmed outcome: prim reconcile ${id} --check ${response.checkId} --outcome followed (retained Decision), or --outcome superseded (after replacing it).
|
|
238
|
+
`Check: ${response.checkId}. After resolving, record the confirmed outcome: prim reconcile ${id} --check ${response.checkId} --outcome followed (retained Decision), or --outcome superseded (after replacing it). Recording a resolution does not authorize an override.`
|
|
227
239
|
] : []
|
|
228
240
|
];
|
|
229
241
|
});
|
|
230
|
-
const
|
|
242
|
+
const blocked = response.verdict === "ask" || response.verdict === "block";
|
|
243
|
+
const proposal = invocation ? proposedChangeExcerpt(invocation.proposal) : void 0;
|
|
244
|
+
const editContext = blocked && invocation ? [
|
|
245
|
+
`Proposed edit to: ${invocation.paths.map((path) => boundedHealthError(path)).join(", ")}.`,
|
|
246
|
+
...proposal ? [`Proposed change (excerpt): ${proposal}`] : []
|
|
247
|
+
] : [];
|
|
248
|
+
const approvalContext = blocked ? [
|
|
249
|
+
"Overriding these Decisions requires explicit human approval naming each Decision and the proposed conflicting edit.",
|
|
250
|
+
"Reconcile bypasses are disabled: this host integration cannot provide verifiable human approval for a bypass. Keep the edit blocked and choose a compatible change.",
|
|
251
|
+
"Sandbox escalation, automatic review, prefix permissions, --yes, and an agent's assertion of approval do not authorize an override."
|
|
252
|
+
] : [];
|
|
253
|
+
const guidance = [message, ...editContext, ...new Set(directives), ...approvalContext].filter(Boolean).join("\n");
|
|
231
254
|
const reason = response.conflicts.length > 0 || response.verdict === "ask" || response.verdict === "block" ? approvalSummary(
|
|
232
255
|
{
|
|
233
256
|
conflicts: response.conflicts,
|
|
@@ -437,7 +460,8 @@ async function main() {
|
|
|
437
460
|
}
|
|
438
461
|
result = resultForPreflight(
|
|
439
462
|
response,
|
|
440
|
-
editPreview(toolName, envelope.tool_input, targets.paths)
|
|
463
|
+
editPreview(toolName, envelope.tool_input, targets.paths),
|
|
464
|
+
request
|
|
441
465
|
);
|
|
442
466
|
} catch (error) {
|
|
443
467
|
await emitUnverified(preflightFailure(error), envelope);
|
package/dist/index.js
CHANGED
|
@@ -9536,34 +9536,10 @@ function registerMovesCommands(program2) {
|
|
|
9536
9536
|
}
|
|
9537
9537
|
|
|
9538
9538
|
// src/commands/reconcile.ts
|
|
9539
|
-
var EXIT_OK4 = 0;
|
|
9540
9539
|
var EXIT_USAGE2 = 2;
|
|
9541
9540
|
var EXIT_SERVER = 3;
|
|
9542
9541
|
var HTTP_CLIENT_ERROR_MIN = 400;
|
|
9543
9542
|
var HTTP_SERVER_ERROR_MIN = 500;
|
|
9544
|
-
function isOk(value) {
|
|
9545
|
-
if (typeof value !== "object" || value === null) {
|
|
9546
|
-
return false;
|
|
9547
|
-
}
|
|
9548
|
-
const v = value;
|
|
9549
|
-
return v.ok === true && typeof v.bypassId === "string" && typeof v.expiresAt === "number";
|
|
9550
|
-
}
|
|
9551
|
-
function formatExpiresIn(expiresAt) {
|
|
9552
|
-
const remainingMs = expiresAt - Date.now();
|
|
9553
|
-
if (remainingMs <= 0) {
|
|
9554
|
-
return "expired";
|
|
9555
|
-
}
|
|
9556
|
-
const SECONDS_PER_MINUTE = 60;
|
|
9557
|
-
const minutes = Math.floor(remainingMs / (SECONDS_PER_MINUTE * 1e3));
|
|
9558
|
-
const seconds = Math.floor(remainingMs / 1e3 % SECONDS_PER_MINUTE);
|
|
9559
|
-
if (minutes === 0) {
|
|
9560
|
-
return `${seconds}s`;
|
|
9561
|
-
}
|
|
9562
|
-
return `${minutes}m${seconds.toString().padStart(2, "0")}s`;
|
|
9563
|
-
}
|
|
9564
|
-
function renderDecisionIdentifier(short, id) {
|
|
9565
|
-
return renderIdentifier({ id, shortId: short });
|
|
9566
|
-
}
|
|
9567
9543
|
function isDomainRejection(err) {
|
|
9568
9544
|
return err instanceof HttpError && err.status >= HTTP_CLIENT_ERROR_MIN && err.status < HTTP_SERVER_ERROR_MIN;
|
|
9569
9545
|
}
|
|
@@ -9572,48 +9548,23 @@ async function performReconcile(idOrShortId, opts = {}) {
|
|
|
9572
9548
|
await performResolution(idOrShortId, opts);
|
|
9573
9549
|
return;
|
|
9574
9550
|
}
|
|
9575
|
-
const
|
|
9576
|
-
|
|
9577
|
-
if (opts.flag) {
|
|
9578
|
-
body.conflictFlagId = opts.flag;
|
|
9579
|
-
}
|
|
9580
|
-
let response;
|
|
9581
|
-
try {
|
|
9582
|
-
response = await client.post("/api/cli/reconcile/issue", body);
|
|
9583
|
-
} catch (err) {
|
|
9584
|
-
if (isDomainRejection(err)) {
|
|
9585
|
-
process.stderr.write(`[prim] reconcile rejected: ${err.message}
|
|
9551
|
+
const message = "Overriding a governing Decision requires explicit human approval. This host cannot provide verifiable human approval, so reconcile bypasses are disabled. Keep the edit blocked and choose a compatible change.";
|
|
9552
|
+
process.stderr.write(`[prim] reconcile rejected: ${message}
|
|
9586
9553
|
`);
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
return;
|
|
9597
|
-
}
|
|
9598
|
-
if (isOk(response)) {
|
|
9599
|
-
const ident = renderDecisionIdentifier(response.decisionShortId, response.decisionId);
|
|
9600
|
-
const verb = response.reissued ? "reissued" : "issued";
|
|
9601
|
-
process.stderr.write(
|
|
9602
|
-
`[prim] reconcile bypass ${verb} for ${ident} (expires in ${formatExpiresIn(response.expiresAt)})
|
|
9603
|
-
`
|
|
9604
|
-
);
|
|
9605
|
-
console.log(JSON.stringify(response, null, 2));
|
|
9606
|
-
process.exitCode = EXIT_OK4;
|
|
9607
|
-
return;
|
|
9608
|
-
}
|
|
9609
|
-
process.stderr.write("[prim] reconcile: malformed server response\n");
|
|
9610
|
-
console.log(JSON.stringify({ ok: false, response }, null, 2));
|
|
9611
|
-
process.exitCode = EXIT_SERVER;
|
|
9554
|
+
console.log(
|
|
9555
|
+
JSON.stringify({
|
|
9556
|
+
ok: false,
|
|
9557
|
+
error: "human_approval_required",
|
|
9558
|
+
decisionId: decisionIdentifier(idOrShortId),
|
|
9559
|
+
message
|
|
9560
|
+
})
|
|
9561
|
+
);
|
|
9562
|
+
process.exitCode = EXIT_USAGE2;
|
|
9612
9563
|
}
|
|
9613
9564
|
async function performResolution(idOrShortId, opts) {
|
|
9614
9565
|
if (!opts.check || !["followed", "superseded"].includes(opts.outcome ?? "") || opts.flag) {
|
|
9615
9566
|
process.stderr.write(
|
|
9616
|
-
"[prim] resolution requires --check <checkId> and --outcome followed|superseded; --flag is
|
|
9567
|
+
"[prim] resolution requires --check <checkId> and --outcome followed|superseded; --flag is unsupported because bypasses are disabled\n"
|
|
9617
9568
|
);
|
|
9618
9569
|
console.log(JSON.stringify({ ok: false, error: "invalid_resolution_arguments" }));
|
|
9619
9570
|
process.exitCode = EXIT_USAGE2;
|
|
@@ -9643,10 +9594,7 @@ async function performResolution(idOrShortId, opts) {
|
|
|
9643
9594
|
}
|
|
9644
9595
|
}
|
|
9645
9596
|
function registerReconcileCommands(program2) {
|
|
9646
|
-
program2.command("reconcile <idOrShortId>").description("Record a resolution
|
|
9647
|
-
"--flag <conflictFlagId>",
|
|
9648
|
-
"Specific flag id to bind the bypass to (default: the decision's latest unack'd flag)"
|
|
9649
|
-
).option("--check <checkId>", "Original conflict check to resolve; does not issue a bypass").option(
|
|
9597
|
+
program2.command("reconcile <idOrShortId>").description("Record a resolution for Conflict Gates Enforcement; bypasses are disabled").option("--flag <conflictFlagId>", "Legacy bypass flag (always rejected)").option("--check <checkId>", "Original conflict check to resolve; does not issue a bypass").option(
|
|
9650
9598
|
"--outcome <outcome>",
|
|
9651
9599
|
"Confirmed resolution: followed or superseded (requires --check)"
|
|
9652
9600
|
).option("--json", "(reserved; STDOUT is always JSON)").action(async (idOrShortId, opts) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primitive.ai/prim",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.113",
|
|
4
4
|
"description": "CLI for Primitive's decision graph — passive decision capture, conflict gate, and team presence",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"format": "biome check --fix src/ scripts/",
|
|
63
63
|
"format:check": "biome check src/ scripts/",
|
|
64
64
|
"typecheck": "tsc --noEmit",
|
|
65
|
+
"check:reconcile-golden": "node scripts/check-reconcile-golden.mjs",
|
|
65
66
|
"test": "vitest run",
|
|
66
67
|
"test:watch": "vitest",
|
|
67
68
|
"test:coverage": "vitest run --coverage"
|