@primitive.ai/prim 0.1.0-alpha.110 → 0.1.0-alpha.112
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 +11 -1
- package/SKILL.md +12 -2
- package/dist/{chunk-KQ4WBK5R.js → chunk-3KKEV7VI.js} +2 -2
- package/dist/{chunk-2IRLFOEL.js → chunk-6JHKKLA2.js} +79 -1
- package/dist/{chunk-IQZA65NV.js → chunk-7DVEH7FO.js} +1 -1
- package/dist/{chunk-W4ZEPZLK.js → chunk-BXLH4LDU.js} +1 -1
- package/dist/{chunk-GA2RXPJL.js → chunk-DWAXFXDG.js} +2 -2
- package/dist/{chunk-7VIMU2HR.js → chunk-FTW4ZCBA.js} +2 -2
- package/dist/{chunk-JJI7FU24.js → chunk-HMD5K6W7.js} +1 -1
- package/dist/{chunk-HTRFPXMD.js → chunk-IW5HCCOW.js} +3 -3
- package/dist/{chunk-UDBBJWQH.js → chunk-IZXLH3R5.js} +930 -582
- package/dist/{chunk-5LRKJTLA.js → chunk-J5HBSRAV.js} +7 -5
- package/dist/{chunk-5BLGBSDM.js → chunk-JDIAPBY7.js} +1 -1
- package/dist/{chunk-2Q3OGSTV.js → chunk-NEQI2VLM.js} +2 -2
- package/dist/{chunk-AOJ254C2.js → chunk-PJW6JZMH.js} +4 -4
- package/dist/{chunk-43ZKL27W.js → chunk-RTULPLS7.js} +1 -1
- package/dist/{chunk-CTRAJCPN.js → chunk-XV6C5ZV2.js} +1 -1
- package/dist/daemon/server.js +1184 -754
- package/dist/hook-runtime/daemon/server.js +1184 -754
- package/dist/hook-runtime/hooks/post-commit.js +929 -581
- package/dist/hook-runtime/hooks/post-rewrite.js +929 -581
- package/dist/hook-runtime/hooks/post-tool-use.js +1015 -588
- package/dist/hook-runtime/hooks/pre-commit.js +85 -6
- package/dist/hook-runtime/hooks/pre-tool-use.js +1018 -592
- package/dist/hook-runtime/hooks/prim-hook.js +1016 -589
- package/dist/hook-runtime/hooks/session-end.js +14 -12
- package/dist/hook-runtime/hooks/session-start.js +1016 -589
- package/dist/hook-runtime/index.js +1211 -791
- package/dist/hook-runtime/statusline-main.js +7 -5
- package/dist/hooks/post-commit.js +5 -5
- package/dist/hooks/post-rewrite.js +5 -5
- package/dist/hooks/post-tool-use.js +12 -12
- package/dist/hooks/pre-commit.js +3 -3
- package/dist/hooks/pre-tool-use.js +11 -12
- package/dist/hooks/prim-hook.js +12 -12
- package/dist/hooks/session-end.js +1 -1
- package/dist/hooks/session-start.js +7 -7
- package/dist/index.js +177 -183
- package/dist/statusline-main.js +7 -5
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -330,7 +330,7 @@ prim decisions link <child> --on <parent> # Relate: <child> depends on <paren
|
|
|
330
330
|
prim decisions unlink <child> --on <parent> # Remove that dependency
|
|
331
331
|
```
|
|
332
332
|
|
|
333
|
-
`<id>`
|
|
333
|
+
`<id>` uses the canonical `dec_<8 hex>` Decision ID; bare short IDs and legacy full IDs remain accepted as inputs. STDOUT is machine-readable
|
|
334
334
|
JSON; human-readable status goes to STDERR.
|
|
335
335
|
|
|
336
336
|
`decisions check` uses the checkout's current Primitive repository binding and
|
|
@@ -521,3 +521,13 @@ pnpm lint # Lint
|
|
|
521
521
|
## License
|
|
522
522
|
|
|
523
523
|
[MIT](LICENSE)
|
|
524
|
+
|
|
525
|
+
### Decision identifiers
|
|
526
|
+
|
|
527
|
+
Decision IDs printed by prim are `dec_` followed by eight lowercase hexadecimal
|
|
528
|
+
characters. Use the same ID in commands and at
|
|
529
|
+
`https://app.getprimitive.ai/decisions/dec_<short>`. Public JSON fields such as
|
|
530
|
+
`id`, `decisionId`, and relationship references use this prefixed ID; the
|
|
531
|
+
`shortId` compatibility field contains the eight characters without the prefix.
|
|
532
|
+
Existing full record IDs remain accepted as inputs. Upgrade the backend before
|
|
533
|
+
this CLI; an unavailable identity produces an error rather than a storage ID.
|
package/SKILL.md
CHANGED
|
@@ -29,7 +29,7 @@ The CLI auto-refreshes a still-valid session from the stored refresh token (proa
|
|
|
29
29
|
|
|
30
30
|
1. Every command accepts `--help`. When unsure of flags, run `npx --yes @primitive.ai/prim <cmd> --help` rather than guessing.
|
|
31
31
|
2. The CLI prints API errors as one-liners to stderr and exits non-zero. Treat any non-zero exit as actionable. If auth-related, re-check `auth status`.
|
|
32
|
-
3. `<idOrShortId>` arguments
|
|
32
|
+
3. `<idOrShortId>` arguments use the `dec_<8 hex>` ID shown in feeds and gate reasons. Bare short IDs and legacy full IDs remain accepted as inputs.
|
|
33
33
|
4. In `npx --yes @primitive.ai/prim ...`, `npx --yes` is npm's flag and only skips npm's package-install confirmation. It is not user consent for a Primitive action. Prim's global flag appears after the package name: `npx --yes @primitive.ai/prim --yes ...`.
|
|
34
34
|
|
|
35
35
|
## Conflict Gates & Enforcement
|
|
@@ -54,6 +54,16 @@ Before presenting decision reads, use the current conversation, task, and availa
|
|
|
54
54
|
|
|
55
55
|
Then tailor the delivery to this requester, not a generic reader. Take your cues from the signals actually present — durable preferences in memory, the format and depth they've used or asked for earlier in the conversation, and the shape of their current goal — and match the form (a one-line answer, a table, grouped headers, or prose), the depth (a bare intent versus full rationale, alternatives, and tradeoffs), the altitude (strategic direction versus specific ids and files), the fields they actually track, and the register of the exchange. Where a preference isn't evidenced, default to a concise, skimmable summary — read taste from signal the way you read rationale, never conjuring a persona from thin air. Tailoring changes how the facts land, never which facts: keep every conflict, supersession, and consequential tradeoff in view even when the requester wants it terse, and never let style override the `unavailable`, truncation, and count semantics above.
|
|
56
56
|
|
|
57
|
+
## Referring to Decisions
|
|
58
|
+
|
|
59
|
+
A Decision's public ID is `dec_<8 lowercase hex characters>`. Use it in commands,
|
|
60
|
+
written references, and links: `https://app.getprimitive.ai/decisions/dec_<short>`.
|
|
61
|
+
Use `webUrl` when present; otherwise build that URL from the public `id` or
|
|
62
|
+
`decisionId`. Intent-labelled Markdown links are supported. No lookup of an
|
|
63
|
+
internal record ID is needed to construct a link. Full IDs remain accepted only
|
|
64
|
+
as legacy inputs; never ask for or print them. Public JSON identity fields contain
|
|
65
|
+
prefixed short IDs; `shortId` remains a bare eight-character compatibility alias.
|
|
66
|
+
|
|
57
67
|
## Reconcile and the verdict footer
|
|
58
68
|
|
|
59
69
|
Reconcile and the verdict footer are part of Conflict Gates **Enforcement**; the `reconcile` command stays available regardless. When Enforcement is enabled for your organization:
|
|
@@ -307,7 +317,7 @@ Safe to run repeatedly:
|
|
|
307
317
|
|
|
308
318
|
- **Idempotent** — re-linking an existing edge (or unlinking a missing one) is a no-op that still exits 0 (`already_linked` / `not_linked`).
|
|
309
319
|
- **Acyclic** — a self-loop, or any link that would close a dependency cycle, is refused with exit 2 (with the offending chain when it's short enough to render); the graph stays a DAG.
|
|
310
|
-
- **Exit codes** (treat non-zero as actionable): `0` success or no-op; `2` a refused link (self-loop, cycle, or an
|
|
320
|
+
- **Exit codes** (treat non-zero as actionable): `0` success or no-op; `2` a refused link (self-loop, cycle, or an unavailable identity — retry after identity repair); `4` an id that doesn't resolve. After a non-zero exit, branch on the exit code and the `[prim]` STDERR verdict, **not** on STDOUT keys: only the exit-0 outcomes carry the full `{ outcome, childId, childShortId, parentId, parentShortId }`; a refused link prints a smaller `{ outcome, … }`, and an unresolved id (exit 4) prints nothing to STDOUT.
|
|
311
321
|
|
|
312
322
|
Like authoring, relate only what the user asks for — don't invent relationships they didn't state.
|
|
313
323
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
boundedHealthError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IZXLH3R5.js";
|
|
4
4
|
import {
|
|
5
5
|
terminalSafeLine
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6JHKKLA2.js";
|
|
7
7
|
|
|
8
8
|
// src/hooks/redact.ts
|
|
9
9
|
import { existsSync, readFileSync, statSync } from "fs";
|
|
@@ -25,6 +25,83 @@ import {
|
|
|
25
25
|
workosConnectTokenEndpoint
|
|
26
26
|
} from "./chunk-XG7S3LIL.js";
|
|
27
27
|
|
|
28
|
+
// src/decisions/identity.ts
|
|
29
|
+
var PUBLIC_ID = /^dec_[0-9a-f]{8}$/u;
|
|
30
|
+
var BARE_ID = /^[0-9a-f]{8}$/u;
|
|
31
|
+
var OPAQUE_FIELDS = /* @__PURE__ */ new Set([
|
|
32
|
+
"cursor",
|
|
33
|
+
"continueCursor",
|
|
34
|
+
"nextCursor",
|
|
35
|
+
"reviewToken",
|
|
36
|
+
"bypassToken"
|
|
37
|
+
]);
|
|
38
|
+
function decisionIdentifier(id, shortId) {
|
|
39
|
+
if (typeof id === "string" && PUBLIC_ID.test(id)) return id;
|
|
40
|
+
if (typeof shortId === "string" && BARE_ID.test(shortId)) return `dec_${shortId}`;
|
|
41
|
+
if (typeof id === "string" && BARE_ID.test(id)) return `dec_${id}`;
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
function publicDecisionResponse(value) {
|
|
45
|
+
const replacements = /* @__PURE__ */ new Map();
|
|
46
|
+
const referenceKeys = /* @__PURE__ */ new Set([
|
|
47
|
+
"decisionId",
|
|
48
|
+
"childId",
|
|
49
|
+
"parentId",
|
|
50
|
+
"supersededBy",
|
|
51
|
+
"activationDecisionId"
|
|
52
|
+
]);
|
|
53
|
+
function visit(input, field = "") {
|
|
54
|
+
if (OPAQUE_FIELDS.has(field) || input === null || input === void 0) return input;
|
|
55
|
+
if (Array.isArray(input)) return input.map((item) => visit(item, field));
|
|
56
|
+
if (typeof input === "string" && (referenceKeys.has(field) || /DecisionIds$/u.test(field))) {
|
|
57
|
+
const id = decisionIdentifier(input);
|
|
58
|
+
if (!id) throw new Error("Decision identity unavailable; update Primitive and retry");
|
|
59
|
+
return id;
|
|
60
|
+
}
|
|
61
|
+
if (typeof input !== "object") return input;
|
|
62
|
+
const row = { ...input };
|
|
63
|
+
for (const [idKey, shortKey] of [
|
|
64
|
+
["id", "shortId"],
|
|
65
|
+
["_id", "shortId"],
|
|
66
|
+
["decisionId", "shortId"],
|
|
67
|
+
["childId", "childShortId"],
|
|
68
|
+
["parentId", "parentShortId"]
|
|
69
|
+
]) {
|
|
70
|
+
if (!(idKey in row) || (idKey === "id" || idKey === "_id") && !("intent" in row || "shortId" in row))
|
|
71
|
+
continue;
|
|
72
|
+
const id = decisionIdentifier(
|
|
73
|
+
row[idKey],
|
|
74
|
+
row[shortKey] ?? (idKey === "decisionId" ? row.decisionShortId : void 0)
|
|
75
|
+
);
|
|
76
|
+
if (!id) throw new Error("Decision identity unavailable; update Primitive and retry");
|
|
77
|
+
const previous = row[idKey];
|
|
78
|
+
if (typeof previous === "string" && !PUBLIC_ID.test(previous) && !BARE_ID.test(previous)) {
|
|
79
|
+
replacements.set(previous, id);
|
|
80
|
+
}
|
|
81
|
+
if (shortKey in row) row[shortKey] = id.slice(4);
|
|
82
|
+
if (idKey === "decisionId" && "decisionShortId" in row) row.decisionShortId = id.slice(4);
|
|
83
|
+
row[idKey] = id;
|
|
84
|
+
}
|
|
85
|
+
return Object.fromEntries(Object.entries(row).map(([key, item]) => [key, visit(item, key)]));
|
|
86
|
+
}
|
|
87
|
+
const projected = visit(value);
|
|
88
|
+
function replace(input, field = "") {
|
|
89
|
+
if (OPAQUE_FIELDS.has(field)) return input;
|
|
90
|
+
if (typeof input === "string") {
|
|
91
|
+
let output = input;
|
|
92
|
+
for (const [raw, id] of replacements) if (raw !== id) output = output.replaceAll(raw, id);
|
|
93
|
+
return output;
|
|
94
|
+
}
|
|
95
|
+
if (Array.isArray(input)) return input.map((item) => replace(item, field));
|
|
96
|
+
if (input && typeof input === "object")
|
|
97
|
+
return Object.fromEntries(
|
|
98
|
+
Object.entries(input).map(([key, item]) => [key, replace(item, key)])
|
|
99
|
+
);
|
|
100
|
+
return input;
|
|
101
|
+
}
|
|
102
|
+
return replace(projected);
|
|
103
|
+
}
|
|
104
|
+
|
|
28
105
|
// src/client.ts
|
|
29
106
|
import { createHash } from "crypto";
|
|
30
107
|
import { chmodSync as chmodSync2, existsSync, mkdirSync, readFileSync as readFileSync2, rmSync } from "fs";
|
|
@@ -656,7 +733,7 @@ async function responseValue(response) {
|
|
|
656
733
|
const message = typeof errorRecord?.error === "string" ? errorRecord.error : `HTTP ${response.status}`;
|
|
657
734
|
throw new HttpError(response.status, message, errorBody);
|
|
658
735
|
}
|
|
659
|
-
return response.json();
|
|
736
|
+
return publicDecisionResponse(await response.json());
|
|
660
737
|
}
|
|
661
738
|
async function request(method, path, body, options) {
|
|
662
739
|
const siteUrl = getSiteUrl();
|
|
@@ -746,6 +823,7 @@ async function getPinnedManagementClient(options = {}) {
|
|
|
746
823
|
}
|
|
747
824
|
|
|
748
825
|
export {
|
|
826
|
+
decisionIdentifier,
|
|
749
827
|
terminalSafeText,
|
|
750
828
|
terminalSafeLine,
|
|
751
829
|
isTerminalSafeText,
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
isTerminalSafeText,
|
|
4
4
|
terminalSafeLine,
|
|
5
5
|
terminalSafeText
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6JHKKLA2.js";
|
|
7
7
|
|
|
8
8
|
// src/decisions/feedback.ts
|
|
9
9
|
var FEEDBACK_PROTOCOL_VERSION = 2;
|
|
@@ -19,7 +19,7 @@ var SHORT_ID = /^[0-9a-f]{8}$/u;
|
|
|
19
19
|
var MAX_EVENT_ID_CHARS = 128;
|
|
20
20
|
var MAX_RAW_INTENT_CODE_UNITS = 512;
|
|
21
21
|
var MAX_FEEDBACK_WEB_URL_CHARS = 2048;
|
|
22
|
-
var SAFE_PUBLISH_DECISION_ID = /^[
|
|
22
|
+
var SAFE_PUBLISH_DECISION_ID = /^dec_[0-9a-f]{8}$/u;
|
|
23
23
|
function isRecord(value) {
|
|
24
24
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25
25
|
}
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
analyzeShellTargets,
|
|
6
6
|
extractFileTargets
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-XV6C5ZV2.js";
|
|
8
8
|
import {
|
|
9
9
|
scrubEnvironmentPaths
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-3KKEV7VI.js";
|
|
11
11
|
import {
|
|
12
12
|
cachedCollectScopeAdmits
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-IZXLH3R5.js";
|
|
14
14
|
import {
|
|
15
15
|
canonicalRepositoryPath,
|
|
16
16
|
currentBranch,
|