@primitive.ai/prim 0.1.0-alpha.111 → 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 +1017 -591
- 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 +10 -11
- 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/dist/index.js
CHANGED
|
@@ -19,18 +19,18 @@ import {
|
|
|
19
19
|
resolveRepositoryBinding,
|
|
20
20
|
uninstallGitHookAtPath,
|
|
21
21
|
uninstallProjectGitHook
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-7DVEH7FO.js";
|
|
23
23
|
import {
|
|
24
24
|
requireDurableIngestAcknowledgement
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-BXLH4LDU.js";
|
|
26
26
|
import {
|
|
27
27
|
checkAffectedDecisions,
|
|
28
28
|
daemonOrDirectGet,
|
|
29
29
|
formatDecisionsWarning
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-NEQI2VLM.js";
|
|
31
31
|
import {
|
|
32
32
|
fetchFeedbackCapability
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-FTW4ZCBA.js";
|
|
34
34
|
import {
|
|
35
35
|
POST_COMMIT_GRACE_MS,
|
|
36
36
|
clearHooksWired,
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
rotationIdentity,
|
|
57
57
|
sweepOrphanedDrainProgress,
|
|
58
58
|
writeDrainCheckpoint
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-HMD5K6W7.js";
|
|
60
60
|
import {
|
|
61
61
|
RUN_ID,
|
|
62
62
|
demoCommand,
|
|
@@ -75,7 +75,7 @@ import {
|
|
|
75
75
|
readDemoJson,
|
|
76
76
|
readRun,
|
|
77
77
|
saveRun
|
|
78
|
-
} from "./chunk-
|
|
78
|
+
} from "./chunk-JDIAPBY7.js";
|
|
79
79
|
import {
|
|
80
80
|
MS_PER_SECOND,
|
|
81
81
|
deliveryBacklogState,
|
|
@@ -84,7 +84,7 @@ import {
|
|
|
84
84
|
formatStatusline,
|
|
85
85
|
formatTeammates,
|
|
86
86
|
repositoryBindingDiagnosticLabel
|
|
87
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-DWAXFXDG.js";
|
|
88
88
|
import {
|
|
89
89
|
bold,
|
|
90
90
|
boundedHealthError,
|
|
@@ -109,12 +109,13 @@ import {
|
|
|
109
109
|
isMoveIngestRequest,
|
|
110
110
|
isReconcileResolutionResponse,
|
|
111
111
|
stripAnsi
|
|
112
|
-
} from "./chunk-
|
|
112
|
+
} from "./chunk-IZXLH3R5.js";
|
|
113
113
|
import {
|
|
114
114
|
CliManagementResponseError,
|
|
115
115
|
HttpError,
|
|
116
116
|
clearStoredCredentials,
|
|
117
117
|
commitCredentials,
|
|
118
|
+
decisionIdentifier,
|
|
118
119
|
getClient,
|
|
119
120
|
getPinnedClient,
|
|
120
121
|
getPinnedManagementClient,
|
|
@@ -126,7 +127,7 @@ import {
|
|
|
126
127
|
setStoredToken,
|
|
127
128
|
stripControlChars,
|
|
128
129
|
terminalSafeLine
|
|
129
|
-
} from "./chunk-
|
|
130
|
+
} from "./chunk-6JHKKLA2.js";
|
|
130
131
|
import {
|
|
131
132
|
MANAGED_GIT_HOOK_NAMES,
|
|
132
133
|
assertOwnedHookRuntime,
|
|
@@ -154,7 +155,7 @@ import {
|
|
|
154
155
|
import {
|
|
155
156
|
daemonIsLive,
|
|
156
157
|
daemonRequest
|
|
157
|
-
} from "./chunk-
|
|
158
|
+
} from "./chunk-J5HBSRAV.js";
|
|
158
159
|
import {
|
|
159
160
|
REFRESH_TOKEN_PATH,
|
|
160
161
|
TOKEN_FILE_PATH,
|
|
@@ -4428,6 +4429,155 @@ function registerDaemonCommands(program2) {
|
|
|
4428
4429
|
// src/commands/decisions.ts
|
|
4429
4430
|
import { Option as Option3 } from "commander";
|
|
4430
4431
|
|
|
4432
|
+
// src/decisions/recent.ts
|
|
4433
|
+
var RECENT_TIMEOUT_MS = 1e4;
|
|
4434
|
+
var defaultDeps = { getClient };
|
|
4435
|
+
async function fetchRecent(args, deps = defaultDeps) {
|
|
4436
|
+
if (args.author !== void 0 && args.author.trim() === "") {
|
|
4437
|
+
return {
|
|
4438
|
+
decisions: [],
|
|
4439
|
+
unavailable: "--author must be a non-empty name"
|
|
4440
|
+
};
|
|
4441
|
+
}
|
|
4442
|
+
const params = new URLSearchParams();
|
|
4443
|
+
if (args.limit !== void 0) {
|
|
4444
|
+
params.set("limit", String(args.limit));
|
|
4445
|
+
}
|
|
4446
|
+
if (args.since !== void 0) {
|
|
4447
|
+
params.set("since", args.since);
|
|
4448
|
+
}
|
|
4449
|
+
if (args.author !== void 0) {
|
|
4450
|
+
params.set("author", args.author);
|
|
4451
|
+
}
|
|
4452
|
+
try {
|
|
4453
|
+
const client = deps.getClient();
|
|
4454
|
+
const res = await daemonOrDirectGet(
|
|
4455
|
+
"decisions_recent",
|
|
4456
|
+
`/api/cli/decisions/recent?${params.toString()}`,
|
|
4457
|
+
client,
|
|
4458
|
+
deps.timeoutMs ?? RECENT_TIMEOUT_MS
|
|
4459
|
+
);
|
|
4460
|
+
if (args.author !== void 0 && res.author === void 0 && res.unavailable === void 0) {
|
|
4461
|
+
return {
|
|
4462
|
+
decisions: [],
|
|
4463
|
+
unavailable: "--author requires a newer Primitive backend (no author echo in response); retry without --author for the team-wide feed"
|
|
4464
|
+
};
|
|
4465
|
+
}
|
|
4466
|
+
const result = { decisions: res.decisions };
|
|
4467
|
+
if (res.viewerHasDecisions !== void 0) {
|
|
4468
|
+
result.viewerHasDecisions = res.viewerHasDecisions;
|
|
4469
|
+
}
|
|
4470
|
+
if (res.author !== void 0) {
|
|
4471
|
+
result.author = res.author;
|
|
4472
|
+
}
|
|
4473
|
+
if (res.authorHasDecisions !== void 0) {
|
|
4474
|
+
result.authorHasDecisions = res.authorHasDecisions;
|
|
4475
|
+
}
|
|
4476
|
+
if (res.windowTotal !== void 0) {
|
|
4477
|
+
result.windowTotal = res.windowTotal;
|
|
4478
|
+
}
|
|
4479
|
+
if (res.windowTotalCapped !== void 0) {
|
|
4480
|
+
result.windowTotalCapped = res.windowTotalCapped;
|
|
4481
|
+
}
|
|
4482
|
+
if (res.unavailable !== void 0) {
|
|
4483
|
+
result.unavailable = res.unavailable;
|
|
4484
|
+
}
|
|
4485
|
+
return result;
|
|
4486
|
+
} catch (err) {
|
|
4487
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
4488
|
+
return { decisions: [], unavailable: `recent feed failed: ${detail}` };
|
|
4489
|
+
}
|
|
4490
|
+
}
|
|
4491
|
+
var ZERO_PAD_TWO = 2;
|
|
4492
|
+
function pad2(n) {
|
|
4493
|
+
return n.toString().padStart(ZERO_PAD_TWO, "0");
|
|
4494
|
+
}
|
|
4495
|
+
function formatClock(ms) {
|
|
4496
|
+
const d = new Date(ms);
|
|
4497
|
+
return `${pad2(d.getHours())}:${pad2(d.getMinutes())}`;
|
|
4498
|
+
}
|
|
4499
|
+
function authorLabel(row) {
|
|
4500
|
+
if (!row.authorIsSelf) {
|
|
4501
|
+
return terminalSafeLine(row.authorName);
|
|
4502
|
+
}
|
|
4503
|
+
switch (row.producerKind) {
|
|
4504
|
+
case "claude_code":
|
|
4505
|
+
return "Your Claude Code";
|
|
4506
|
+
case "codex":
|
|
4507
|
+
return "Your Codex";
|
|
4508
|
+
case "cursor":
|
|
4509
|
+
return "Your Cursor";
|
|
4510
|
+
case "hermes":
|
|
4511
|
+
return "Your Hermes";
|
|
4512
|
+
case "chat":
|
|
4513
|
+
return "Your chat";
|
|
4514
|
+
case "spec_edit":
|
|
4515
|
+
return "Your spec edit";
|
|
4516
|
+
case "cli":
|
|
4517
|
+
return "Your CLI";
|
|
4518
|
+
default:
|
|
4519
|
+
return `Your ${terminalSafeLine(row.authorName)}`;
|
|
4520
|
+
}
|
|
4521
|
+
}
|
|
4522
|
+
var AUTHOR_WIDTH = 18;
|
|
4523
|
+
var AREA_WIDTH = 12;
|
|
4524
|
+
function padRight(s, width) {
|
|
4525
|
+
return s.length >= width ? `${s.slice(0, width - 1)} ` : s.padEnd(width, " ");
|
|
4526
|
+
}
|
|
4527
|
+
function formatRecentRow(row) {
|
|
4528
|
+
const clock = formatClock(row.classifiedAt);
|
|
4529
|
+
const author = padRight(authorLabel(row), AUTHOR_WIDTH);
|
|
4530
|
+
const area = terminalSafeLine(row.area ?? "");
|
|
4531
|
+
const areaText = area ? `\u2022 ${area}` : "\u2022";
|
|
4532
|
+
const areaPlain = padRight(areaText, AREA_WIDTH);
|
|
4533
|
+
const areaCol = area ? areaPlain.replace("\u2022", color("\u2022", colorForArea(area))) : areaPlain;
|
|
4534
|
+
return ` ${clock} ${author}${areaCol}${terminalSafeLine(row.intent)}`;
|
|
4535
|
+
}
|
|
4536
|
+
var RECENT_LIMIT_CEILING = 100;
|
|
4537
|
+
function remainingHint(result) {
|
|
4538
|
+
const { windowTotal } = result;
|
|
4539
|
+
if (windowTotal === void 0 || windowTotal <= result.decisions.length) {
|
|
4540
|
+
return;
|
|
4541
|
+
}
|
|
4542
|
+
const remaining = windowTotal - result.decisions.length;
|
|
4543
|
+
const remainingText = result.windowTotalCapped === true ? `${remaining}+` : String(remaining);
|
|
4544
|
+
if (windowTotal <= RECENT_LIMIT_CEILING) {
|
|
4545
|
+
return `${remainingText} more not shown \u2014 re-run with --limit ${windowTotal} to see all`;
|
|
4546
|
+
}
|
|
4547
|
+
return `${remainingText} more not shown \u2014 re-run with --limit ${RECENT_LIMIT_CEILING} for the newest ${RECENT_LIMIT_CEILING} (the full set exceeds the feed cap)`;
|
|
4548
|
+
}
|
|
4549
|
+
function formatRecentHuman(result) {
|
|
4550
|
+
if (result.unavailable !== void 0) {
|
|
4551
|
+
return `[prim] recent \xB7 feed not verified \u2014 ${terminalSafeLine(result.unavailable)}`;
|
|
4552
|
+
}
|
|
4553
|
+
if (result.author !== void 0 && result.decisions.length === 0) {
|
|
4554
|
+
if (result.authorHasDecisions === true) {
|
|
4555
|
+
return `[prim] recent \xB7 ${terminalSafeLine(result.author.name)} \xB7 0 decisions in this window (older decisions exist \u2014 widen --since)`;
|
|
4556
|
+
}
|
|
4557
|
+
if (result.authorHasDecisions === false) {
|
|
4558
|
+
return `[prim] recent \xB7 ${terminalSafeLine(result.author.name)} \xB7 no feed-visible decisions yet (if unexpected, check prim setup/doctor on their machine and the repo they work in)`;
|
|
4559
|
+
}
|
|
4560
|
+
return `[prim] recent \xB7 ${terminalSafeLine(result.author.name)} \xB7 0 decisions`;
|
|
4561
|
+
}
|
|
4562
|
+
const label2 = result.author === void 0 ? "recent" : `recent \xB7 ${terminalSafeLine(result.author.name)}`;
|
|
4563
|
+
if (result.decisions.length === 0) {
|
|
4564
|
+
return "[prim] recent \xB7 0 decisions";
|
|
4565
|
+
}
|
|
4566
|
+
const header = `[prim] ${label2} \xB7 ${String(result.decisions.length)} decision(s)`;
|
|
4567
|
+
const hint = remainingHint(result);
|
|
4568
|
+
const lines = [hint === void 0 ? header : `${header} \xB7 ${hint}`];
|
|
4569
|
+
for (const row of result.decisions) {
|
|
4570
|
+
lines.push(formatRecentRow(row));
|
|
4571
|
+
}
|
|
4572
|
+
return lines.join("\n");
|
|
4573
|
+
}
|
|
4574
|
+
function formatRecentJson(result) {
|
|
4575
|
+
return JSON.stringify(result, null, 2);
|
|
4576
|
+
}
|
|
4577
|
+
function renderIdentifier(row) {
|
|
4578
|
+
return decisionIdentifier(row.id, row.shortId) ?? "Decision identity unavailable";
|
|
4579
|
+
}
|
|
4580
|
+
|
|
4431
4581
|
// src/decisions/cascade-renderer.ts
|
|
4432
4582
|
var DEPENDENTS_INLINE_LIMIT = 5;
|
|
4433
4583
|
var KNOWLEDGE_INLINE_LIMIT = 4;
|
|
@@ -4578,8 +4728,7 @@ function triggerLine(result) {
|
|
|
4578
4728
|
}
|
|
4579
4729
|
function renderCascade(result) {
|
|
4580
4730
|
const d = result.decision;
|
|
4581
|
-
const
|
|
4582
|
-
const id = shortId ? `dec_${shortId}` : terminalSafeLine(d.id);
|
|
4731
|
+
const id = renderIdentifier(d);
|
|
4583
4732
|
const idColored = color(id, "orange");
|
|
4584
4733
|
const header = `what this would break \xB7 ${String(result.fanOut)} decision(s) \xB7 enforcing`;
|
|
4585
4734
|
const lines = [header, "", "knowledge"];
|
|
@@ -4627,10 +4776,10 @@ function renderCascade(result) {
|
|
|
4627
4776
|
// src/decisions/cascade.ts
|
|
4628
4777
|
var NOT_FOUND_RE = /not found/i;
|
|
4629
4778
|
var CASCADE_TIMEOUT_MS = 1e4;
|
|
4630
|
-
var
|
|
4779
|
+
var defaultDeps2 = { getClient };
|
|
4631
4780
|
var CascadeNotFoundError = class extends Error {
|
|
4632
|
-
constructor(
|
|
4633
|
-
super(
|
|
4781
|
+
constructor(_idOrShortId) {
|
|
4782
|
+
super("Decision not found");
|
|
4634
4783
|
this.name = "CascadeNotFoundError";
|
|
4635
4784
|
}
|
|
4636
4785
|
};
|
|
@@ -4643,7 +4792,7 @@ function normalizeCascade(raw) {
|
|
|
4643
4792
|
}
|
|
4644
4793
|
};
|
|
4645
4794
|
}
|
|
4646
|
-
async function fetchCascade(idOrShortId, deps =
|
|
4795
|
+
async function fetchCascade(idOrShortId, deps = defaultDeps2) {
|
|
4647
4796
|
const params = new URLSearchParams({ id: idOrShortId });
|
|
4648
4797
|
const client = deps.getClient();
|
|
4649
4798
|
try {
|
|
@@ -4665,169 +4814,15 @@ function formatCascadeJson(result) {
|
|
|
4665
4814
|
return JSON.stringify(result, null, 2);
|
|
4666
4815
|
}
|
|
4667
4816
|
|
|
4668
|
-
// src/decisions/recent.ts
|
|
4669
|
-
var RECENT_TIMEOUT_MS = 1e4;
|
|
4670
|
-
var defaultDeps2 = { getClient };
|
|
4671
|
-
async function fetchRecent(args, deps = defaultDeps2) {
|
|
4672
|
-
if (args.author !== void 0 && args.author.trim() === "") {
|
|
4673
|
-
return {
|
|
4674
|
-
decisions: [],
|
|
4675
|
-
unavailable: "--author must be a non-empty name"
|
|
4676
|
-
};
|
|
4677
|
-
}
|
|
4678
|
-
const params = new URLSearchParams();
|
|
4679
|
-
if (args.limit !== void 0) {
|
|
4680
|
-
params.set("limit", String(args.limit));
|
|
4681
|
-
}
|
|
4682
|
-
if (args.since !== void 0) {
|
|
4683
|
-
params.set("since", args.since);
|
|
4684
|
-
}
|
|
4685
|
-
if (args.author !== void 0) {
|
|
4686
|
-
params.set("author", args.author);
|
|
4687
|
-
}
|
|
4688
|
-
try {
|
|
4689
|
-
const client = deps.getClient();
|
|
4690
|
-
const res = await daemonOrDirectGet(
|
|
4691
|
-
"decisions_recent",
|
|
4692
|
-
`/api/cli/decisions/recent?${params.toString()}`,
|
|
4693
|
-
client,
|
|
4694
|
-
deps.timeoutMs ?? RECENT_TIMEOUT_MS
|
|
4695
|
-
);
|
|
4696
|
-
if (args.author !== void 0 && res.author === void 0 && res.unavailable === void 0) {
|
|
4697
|
-
return {
|
|
4698
|
-
decisions: [],
|
|
4699
|
-
unavailable: "--author requires a newer Primitive backend (no author echo in response); retry without --author for the team-wide feed"
|
|
4700
|
-
};
|
|
4701
|
-
}
|
|
4702
|
-
const result = { decisions: res.decisions };
|
|
4703
|
-
if (res.viewerHasDecisions !== void 0) {
|
|
4704
|
-
result.viewerHasDecisions = res.viewerHasDecisions;
|
|
4705
|
-
}
|
|
4706
|
-
if (res.author !== void 0) {
|
|
4707
|
-
result.author = res.author;
|
|
4708
|
-
}
|
|
4709
|
-
if (res.authorHasDecisions !== void 0) {
|
|
4710
|
-
result.authorHasDecisions = res.authorHasDecisions;
|
|
4711
|
-
}
|
|
4712
|
-
if (res.windowTotal !== void 0) {
|
|
4713
|
-
result.windowTotal = res.windowTotal;
|
|
4714
|
-
}
|
|
4715
|
-
if (res.windowTotalCapped !== void 0) {
|
|
4716
|
-
result.windowTotalCapped = res.windowTotalCapped;
|
|
4717
|
-
}
|
|
4718
|
-
if (res.unavailable !== void 0) {
|
|
4719
|
-
result.unavailable = res.unavailable;
|
|
4720
|
-
}
|
|
4721
|
-
return result;
|
|
4722
|
-
} catch (err) {
|
|
4723
|
-
const detail = err instanceof Error ? err.message : String(err);
|
|
4724
|
-
return { decisions: [], unavailable: `recent feed failed: ${detail}` };
|
|
4725
|
-
}
|
|
4726
|
-
}
|
|
4727
|
-
var SHORT_ID_PREFIX = "dec_";
|
|
4728
|
-
var ZERO_PAD_TWO = 2;
|
|
4729
|
-
function pad2(n) {
|
|
4730
|
-
return n.toString().padStart(ZERO_PAD_TWO, "0");
|
|
4731
|
-
}
|
|
4732
|
-
function formatClock(ms) {
|
|
4733
|
-
const d = new Date(ms);
|
|
4734
|
-
return `${pad2(d.getHours())}:${pad2(d.getMinutes())}`;
|
|
4735
|
-
}
|
|
4736
|
-
function authorLabel(row) {
|
|
4737
|
-
if (!row.authorIsSelf) {
|
|
4738
|
-
return terminalSafeLine(row.authorName);
|
|
4739
|
-
}
|
|
4740
|
-
switch (row.producerKind) {
|
|
4741
|
-
case "claude_code":
|
|
4742
|
-
return "Your Claude Code";
|
|
4743
|
-
case "codex":
|
|
4744
|
-
return "Your Codex";
|
|
4745
|
-
case "cursor":
|
|
4746
|
-
return "Your Cursor";
|
|
4747
|
-
case "hermes":
|
|
4748
|
-
return "Your Hermes";
|
|
4749
|
-
case "chat":
|
|
4750
|
-
return "Your chat";
|
|
4751
|
-
case "spec_edit":
|
|
4752
|
-
return "Your spec edit";
|
|
4753
|
-
case "cli":
|
|
4754
|
-
return "Your CLI";
|
|
4755
|
-
default:
|
|
4756
|
-
return `Your ${terminalSafeLine(row.authorName)}`;
|
|
4757
|
-
}
|
|
4758
|
-
}
|
|
4759
|
-
var AUTHOR_WIDTH = 18;
|
|
4760
|
-
var AREA_WIDTH = 12;
|
|
4761
|
-
function padRight(s, width) {
|
|
4762
|
-
return s.length >= width ? `${s.slice(0, width - 1)} ` : s.padEnd(width, " ");
|
|
4763
|
-
}
|
|
4764
|
-
function formatRecentRow(row) {
|
|
4765
|
-
const clock = formatClock(row.classifiedAt);
|
|
4766
|
-
const author = padRight(authorLabel(row), AUTHOR_WIDTH);
|
|
4767
|
-
const area = terminalSafeLine(row.area ?? "");
|
|
4768
|
-
const areaText = area ? `\u2022 ${area}` : "\u2022";
|
|
4769
|
-
const areaPlain = padRight(areaText, AREA_WIDTH);
|
|
4770
|
-
const areaCol = area ? areaPlain.replace("\u2022", color("\u2022", colorForArea(area))) : areaPlain;
|
|
4771
|
-
return ` ${clock} ${author}${areaCol}${terminalSafeLine(row.intent)}`;
|
|
4772
|
-
}
|
|
4773
|
-
var RECENT_LIMIT_CEILING = 100;
|
|
4774
|
-
function remainingHint(result) {
|
|
4775
|
-
const { windowTotal } = result;
|
|
4776
|
-
if (windowTotal === void 0 || windowTotal <= result.decisions.length) {
|
|
4777
|
-
return;
|
|
4778
|
-
}
|
|
4779
|
-
const remaining = windowTotal - result.decisions.length;
|
|
4780
|
-
const remainingText = result.windowTotalCapped === true ? `${remaining}+` : String(remaining);
|
|
4781
|
-
if (windowTotal <= RECENT_LIMIT_CEILING) {
|
|
4782
|
-
return `${remainingText} more not shown \u2014 re-run with --limit ${windowTotal} to see all`;
|
|
4783
|
-
}
|
|
4784
|
-
return `${remainingText} more not shown \u2014 re-run with --limit ${RECENT_LIMIT_CEILING} for the newest ${RECENT_LIMIT_CEILING} (the full set exceeds the feed cap)`;
|
|
4785
|
-
}
|
|
4786
|
-
function formatRecentHuman(result) {
|
|
4787
|
-
if (result.unavailable !== void 0) {
|
|
4788
|
-
return `[prim] recent \xB7 feed not verified \u2014 ${terminalSafeLine(result.unavailable)}`;
|
|
4789
|
-
}
|
|
4790
|
-
if (result.author !== void 0 && result.decisions.length === 0) {
|
|
4791
|
-
if (result.authorHasDecisions === true) {
|
|
4792
|
-
return `[prim] recent \xB7 ${terminalSafeLine(result.author.name)} \xB7 0 decisions in this window (older decisions exist \u2014 widen --since)`;
|
|
4793
|
-
}
|
|
4794
|
-
if (result.authorHasDecisions === false) {
|
|
4795
|
-
return `[prim] recent \xB7 ${terminalSafeLine(result.author.name)} \xB7 no feed-visible decisions yet (if unexpected, check prim setup/doctor on their machine and the repo they work in)`;
|
|
4796
|
-
}
|
|
4797
|
-
return `[prim] recent \xB7 ${terminalSafeLine(result.author.name)} \xB7 0 decisions`;
|
|
4798
|
-
}
|
|
4799
|
-
const label2 = result.author === void 0 ? "recent" : `recent \xB7 ${terminalSafeLine(result.author.name)}`;
|
|
4800
|
-
if (result.decisions.length === 0) {
|
|
4801
|
-
return "[prim] recent \xB7 0 decisions";
|
|
4802
|
-
}
|
|
4803
|
-
const header = `[prim] ${label2} \xB7 ${String(result.decisions.length)} decision(s)`;
|
|
4804
|
-
const hint = remainingHint(result);
|
|
4805
|
-
const lines = [hint === void 0 ? header : `${header} \xB7 ${hint}`];
|
|
4806
|
-
for (const row of result.decisions) {
|
|
4807
|
-
lines.push(formatRecentRow(row));
|
|
4808
|
-
}
|
|
4809
|
-
return lines.join("\n");
|
|
4810
|
-
}
|
|
4811
|
-
function formatRecentJson(result) {
|
|
4812
|
-
return JSON.stringify(result, null, 2);
|
|
4813
|
-
}
|
|
4814
|
-
function renderIdentifier(row) {
|
|
4815
|
-
const shortId = terminalSafeLine(row.shortId ?? "");
|
|
4816
|
-
if (shortId) {
|
|
4817
|
-
return `${SHORT_ID_PREFIX}${shortId}`;
|
|
4818
|
-
}
|
|
4819
|
-
return terminalSafeLine(row.id);
|
|
4820
|
-
}
|
|
4821
|
-
|
|
4822
4817
|
// src/decisions/confirm.ts
|
|
4823
4818
|
var CONFIRM_TIMEOUT_MS = 1e4;
|
|
4824
4819
|
var defaultDeps3 = { getClient };
|
|
4825
4820
|
var NOT_FOUND_RE2 = /not found/i;
|
|
4826
|
-
var AMBIGUOUS_RE = /ambiguous/i;
|
|
4821
|
+
var AMBIGUOUS_RE = /ambiguous|Decision identity unavailable; retry after identity repair/i;
|
|
4827
4822
|
var NOT_AUTHOR_RE = /author/i;
|
|
4828
4823
|
var ConfirmNotFoundError = class extends Error {
|
|
4829
|
-
constructor(
|
|
4830
|
-
super(
|
|
4824
|
+
constructor(_idOrShortId) {
|
|
4825
|
+
super("Decision not found");
|
|
4831
4826
|
this.name = "ConfirmNotFoundError";
|
|
4832
4827
|
}
|
|
4833
4828
|
};
|
|
@@ -4885,7 +4880,7 @@ function formatConfirmHuman(result) {
|
|
|
4885
4880
|
return `[prim] ${id} has no pending confirmation request \u2014 nothing to acknowledge.`;
|
|
4886
4881
|
}
|
|
4887
4882
|
case "ambiguous":
|
|
4888
|
-
return
|
|
4883
|
+
return "[prim] Decision identity unavailable; retry after identity repair.";
|
|
4889
4884
|
default:
|
|
4890
4885
|
return "[prim] only the decision's author can respond to its confirmation prompt.";
|
|
4891
4886
|
}
|
|
@@ -5054,7 +5049,7 @@ var PAST_PARTICIPLE = {
|
|
|
5054
5049
|
};
|
|
5055
5050
|
var ORG_UNBOUND_MESSAGE = "CLI token is not bound to an organization";
|
|
5056
5051
|
var NOT_AUTHOR_MESSAGE = "Only the decision's author can perform this action";
|
|
5057
|
-
var AMBIGUOUS_MESSAGE = "
|
|
5052
|
+
var AMBIGUOUS_MESSAGE = "Decision identity unavailable; retry after identity repair";
|
|
5058
5053
|
var DECISION_NOT_FOUND_MESSAGE = "Decision not found";
|
|
5059
5054
|
var REPLACEMENT_NOT_FOUND_MESSAGE = "Replacement decision not found";
|
|
5060
5055
|
var SELF_REPLACEMENT_MESSAGE = "A decision cannot supersede itself";
|
|
@@ -5135,7 +5130,7 @@ function classifyHttpError2(error) {
|
|
|
5135
5130
|
if (error.status === 403 && message === NOT_AUTHOR_MESSAGE) {
|
|
5136
5131
|
return failure2("not_author", DECISION_LIFECYCLE_EXIT.rejected, error.status);
|
|
5137
5132
|
}
|
|
5138
|
-
if (error.status === 409 && message === AMBIGUOUS_MESSAGE) {
|
|
5133
|
+
if (error.status === 409 && (message === AMBIGUOUS_MESSAGE || message === "shortId is ambiguous in this organization; retry with the full decision id")) {
|
|
5139
5134
|
return failure2("ambiguous_identifier", DECISION_LIFECYCLE_EXIT.rejected, error.status);
|
|
5140
5135
|
}
|
|
5141
5136
|
if (error.status === 409 && IMMUTABLE_MESSAGE.test(message)) {
|
|
@@ -5183,7 +5178,7 @@ function formatFailureHuman(operation, result) {
|
|
|
5183
5178
|
case "not_author":
|
|
5184
5179
|
return `[prim] ${verb} rejected: only the Decision's author can ${verb} it.`;
|
|
5185
5180
|
case "ambiguous_identifier":
|
|
5186
|
-
return `[prim] ${verb} rejected:
|
|
5181
|
+
return `[prim] ${verb} rejected: Decision identity unavailable; retry after identity repair.`;
|
|
5187
5182
|
case "immutable":
|
|
5188
5183
|
return `[prim] ${verb} rejected: this Decision is immutable; supersede it to change it.`;
|
|
5189
5184
|
case "illegal_transition":
|
|
@@ -5283,7 +5278,7 @@ function supersedeDecision(id, by, dependencies = defaultDependencies3) {
|
|
|
5283
5278
|
var RELATE_TIMEOUT_MS = 1e4;
|
|
5284
5279
|
var defaultDeps5 = { getClient };
|
|
5285
5280
|
var NOT_FOUND_RE3 = /not found/i;
|
|
5286
|
-
var AMBIGUOUS_RE2 = /ambiguous/i;
|
|
5281
|
+
var AMBIGUOUS_RE2 = /ambiguous|Decision identity unavailable; retry after identity repair/i;
|
|
5287
5282
|
var CYCLE_RE = /cycle/i;
|
|
5288
5283
|
var LinkNotFoundError = class extends Error {
|
|
5289
5284
|
constructor(which) {
|
|
@@ -5347,8 +5342,7 @@ function formatRelateHuman(result) {
|
|
|
5347
5342
|
case "would_cycle":
|
|
5348
5343
|
return `[prim] refusing to link \u2014 ${outcome.detail}.`;
|
|
5349
5344
|
default: {
|
|
5350
|
-
|
|
5351
|
-
return `[prim] the ${outcome.which} id "${typed}" is ambiguous in this organization \u2014 retry with the full decision id.`;
|
|
5345
|
+
return `[prim] the ${outcome.which} Decision identity is unavailable; retry after identity repair.`;
|
|
5352
5346
|
}
|
|
5353
5347
|
}
|
|
5354
5348
|
}
|
|
@@ -6063,8 +6057,8 @@ function colorStatus(status) {
|
|
|
6063
6057
|
var SHOW_TIMEOUT_MS = 1e4;
|
|
6064
6058
|
var defaultDeps7 = { getClient };
|
|
6065
6059
|
var DecisionNotFoundError = class extends Error {
|
|
6066
|
-
constructor(
|
|
6067
|
-
super(
|
|
6060
|
+
constructor(_idOrShortId) {
|
|
6061
|
+
super("Decision not found");
|
|
6068
6062
|
this.name = "DecisionNotFoundError";
|
|
6069
6063
|
}
|
|
6070
6064
|
};
|
|
@@ -9568,7 +9562,7 @@ function formatExpiresIn(expiresAt) {
|
|
|
9568
9562
|
return `${minutes}m${seconds.toString().padStart(2, "0")}s`;
|
|
9569
9563
|
}
|
|
9570
9564
|
function renderDecisionIdentifier(short, id) {
|
|
9571
|
-
return
|
|
9565
|
+
return renderIdentifier({ id, shortId: short });
|
|
9572
9566
|
}
|
|
9573
9567
|
function isDomainRejection(err) {
|
|
9574
9568
|
return err instanceof HttpError && err.status >= HTTP_CLIENT_ERROR_MIN && err.status < HTTP_SERVER_ERROR_MIN;
|
package/dist/statusline-main.js
CHANGED
|
@@ -382,10 +382,6 @@ function getSiteUrlForEnvironment(primApiUrl) {
|
|
|
382
382
|
}
|
|
383
383
|
var CLI_MANAGEMENT_RESPONSE_MAX_BYTES = 2 * 1024 * 1024;
|
|
384
384
|
|
|
385
|
-
// src/daemon/client.ts
|
|
386
|
-
import { createConnection } from "net";
|
|
387
|
-
import { join as join7 } from "path";
|
|
388
|
-
|
|
389
385
|
// src/daemon/principal.ts
|
|
390
386
|
import { createHash as createHash3 } from "crypto";
|
|
391
387
|
var PRINCIPAL_COMPONENT_MAX_LENGTH = 512;
|
|
@@ -412,6 +408,7 @@ function resolveDaemonPrincipal(token = resolveAuthCredential()?.token) {
|
|
|
412
408
|
// src/daemon/protocol.ts
|
|
413
409
|
var DAEMON_JSON_REQUEST_MAX_BYTES = 64 * 1024;
|
|
414
410
|
var DAEMON_JSON_RESPONSE_MAX_BYTES = 8 * 1024 * 1024;
|
|
411
|
+
var DECISION_IDENTITY_VERSION = 7;
|
|
415
412
|
function isRecord(value) {
|
|
416
413
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
417
414
|
}
|
|
@@ -424,6 +421,7 @@ function parseDaemonResponseEnvelope(value) {
|
|
|
424
421
|
if (value.error !== void 0 && typeof value.error !== "string") return void 0;
|
|
425
422
|
return {
|
|
426
423
|
id: value.id,
|
|
424
|
+
...typeof value.decisionIdentityVersion === "number" ? { decisionIdentityVersion: value.decisionIdentityVersion } : {},
|
|
427
425
|
ok: value.ok,
|
|
428
426
|
...value.result === void 0 ? {} : { result: value.result },
|
|
429
427
|
...value.error === void 0 ? {} : { error: value.error }
|
|
@@ -431,6 +429,8 @@ function parseDaemonResponseEnvelope(value) {
|
|
|
431
429
|
}
|
|
432
430
|
|
|
433
431
|
// src/daemon/client.ts
|
|
432
|
+
import { createConnection } from "net";
|
|
433
|
+
import { join as join7 } from "path";
|
|
434
434
|
var SOCK_PATH = join7(primConfigDirectory(), "sock");
|
|
435
435
|
var DEFAULT_TIMEOUT_MS = 250;
|
|
436
436
|
var nextRequestId = 1;
|
|
@@ -503,7 +503,9 @@ function daemonRequest(method, params = {}, opts = {}) {
|
|
|
503
503
|
return;
|
|
504
504
|
}
|
|
505
505
|
clearTimeout(timer);
|
|
506
|
-
settle(
|
|
506
|
+
settle(
|
|
507
|
+
(!(method.startsWith("decisions_") || method.startsWith("decision_")) || res.decisionIdentityVersion === DECISION_IDENTITY_VERSION) && res.ok && res.result !== void 0 ? res.result : null
|
|
508
|
+
);
|
|
507
509
|
} catch {
|
|
508
510
|
clearTimeout(timer);
|
|
509
511
|
settle(null);
|
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.112",
|
|
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",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"contracts:generate": "node scripts/generate-cli-contract.mjs --write",
|
|
53
53
|
"contracts:check": "node scripts/generate-cli-contract.mjs --check",
|
|
54
54
|
"contracts:provenance": "node scripts/update-cli-contract.mjs --check",
|
|
55
|
+
"check:decision-identity-golden": "node scripts/check-decision-identity-golden.mjs",
|
|
55
56
|
"check:approval-copy-golden": "node scripts/check-approval-copy-golden.mjs",
|
|
56
57
|
"contracts:update": "node scripts/update-cli-contract.mjs",
|
|
57
58
|
"postbuild": "chmod +x ./dist/index.js ./dist/statusline-main.js ./dist/hooks/pre-commit.js ./dist/hooks/post-commit.js ./dist/hooks/post-rewrite.js ./dist/hooks/prim-hook.js ./dist/hooks/pre-tool-use.js ./dist/hooks/post-tool-use.js ./dist/hooks/session-start.js ./dist/hooks/session-end.js ./dist/daemon/server.js && node scripts/check-hook-runtime.mjs",
|