@primitive.ai/prim 0.1.0-alpha.91 → 0.1.0-alpha.93

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.
Files changed (40) hide show
  1. package/README.md +34 -2
  2. package/dist/{chunk-67VNLLBN.js → chunk-2GP5UFV7.js} +1 -0
  3. package/dist/{chunk-VW3FDYRT.js → chunk-36TWVNBE.js} +6 -6
  4. package/dist/{chunk-HU4PW6I6.js → chunk-C3VAA5CG.js} +1 -1
  5. package/dist/{chunk-FOLKHXLJ.js → chunk-DCJN6LZH.js} +37 -5
  6. package/dist/{chunk-M6RIJVRE.js → chunk-DSWT6BCC.js} +78 -4
  7. package/dist/{chunk-FBAYCS3X.js → chunk-DXJQR4QI.js} +150 -38
  8. package/dist/{chunk-PCVGBE5B.js → chunk-G2VMA2QO.js} +2 -1
  9. package/dist/{chunk-NAHHFSLH.js → chunk-ICM2XCXS.js} +2 -2
  10. package/dist/{chunk-OAAP2MY6.js → chunk-K7D2EYBS.js} +2 -2
  11. package/dist/{chunk-5AFRMOPX.js → chunk-OH3EZXYX.js} +1 -1
  12. package/dist/{chunk-KFXF2V5G.js → chunk-OTHKG76J.js} +1 -1
  13. package/dist/chunk-OYHYCK4K.js +13 -0
  14. package/dist/{chunk-FKXFUUWJ.js → chunk-TYAHC25F.js} +1 -1
  15. package/dist/{chunk-5GYQ4J3D.js → chunk-UKUAAAXE.js} +2 -2
  16. package/dist/{chunk-EWZMDD44.js → chunk-X64HTHUF.js} +22 -3
  17. package/dist/{chunk-WX52U7Z2.js → chunk-ZU563PQI.js} +58 -2
  18. package/dist/daemon/server.js +382 -124
  19. package/dist/hook-runtime/daemon/server.js +382 -124
  20. package/dist/hook-runtime/hooks/post-commit.js +57 -39
  21. package/dist/hook-runtime/hooks/post-rewrite.js +58 -40
  22. package/dist/hook-runtime/hooks/post-tool-use.js +111 -78
  23. package/dist/hook-runtime/hooks/pre-tool-use.js +48 -26
  24. package/dist/hook-runtime/hooks/prim-hook.js +157 -117
  25. package/dist/hook-runtime/hooks/session-end.js +1 -1
  26. package/dist/hook-runtime/hooks/session-start.js +38 -4
  27. package/dist/hook-runtime/index.js +1293 -526
  28. package/dist/hook-runtime/statusline-main.js +23 -1
  29. package/dist/hooks/post-commit.js +11 -8
  30. package/dist/hooks/post-rewrite.js +11 -8
  31. package/dist/hooks/post-tool-use.js +13 -15
  32. package/dist/hooks/pre-commit.js +4 -4
  33. package/dist/hooks/pre-tool-use.js +10 -12
  34. package/dist/hooks/prim-hook.js +17 -14
  35. package/dist/hooks/session-end.js +4 -4
  36. package/dist/hooks/session-start.js +12 -36
  37. package/dist/index.js +867 -291
  38. package/dist/statusline-main.js +23 -1
  39. package/package.json +1 -1
  40. package/dist/chunk-BTNNEH2W.js +0 -79
@@ -597,6 +597,27 @@ function decisionIngestionStatus(cwd) {
597
597
  return isRepoActiveForCapture(cwd) ? "enabled" : "disabled";
598
598
  }
599
599
 
600
+ // src/lib/delivery-backlog.ts
601
+ var MS_PER_SECOND = 1e3;
602
+ var MS_PER_MINUTE = 60 * MS_PER_SECOND;
603
+ var MS_PER_HOUR = 60 * MS_PER_MINUTE;
604
+ var MS_PER_DAY = 24 * MS_PER_HOUR;
605
+ function isNonNegativeInteger(value) {
606
+ return typeof value === "number" && Number.isInteger(value) && value >= 0;
607
+ }
608
+ function isPositiveInteger(value) {
609
+ return isNonNegativeInteger(value) && value > 0;
610
+ }
611
+ function deliveryBacklogState(ingestion) {
612
+ if (ingestion?.healthy !== false) return void 0;
613
+ const failures = ingestion.consecutiveFailures;
614
+ const failedWithoutProgress = failures !== 0 && !(isPositiveInteger(failures) && isPositiveInteger(ingestion.lastFailedDrainAcknowledgedCount));
615
+ if (failedWithoutProgress) return "failing";
616
+ const retained = ingestion.lastRetainedBucketCount;
617
+ if (!isNonNegativeInteger(retained)) return "failing";
618
+ return retained > 0 ? "retained" : "draining";
619
+ }
620
+
600
621
  // src/lib/presence.ts
601
622
  var DECISION_ORIGIN = "https://app.getprimitive.ai";
602
623
  function validDecisionUrl(value) {
@@ -671,7 +692,8 @@ function formatStatusline(version, snapshot, resolveIngestionStatus, options = {
671
692
  if (snapshot.ingestion?.healthy === false) {
672
693
  const pending = snapshot.ingestion.pendingCount;
673
694
  const qualifier = snapshot.ingestion.pendingSampled ? "at least " : "";
674
- return `primitive ${version} (daemon: degraded \xB7 delivery: stalled${typeof pending === "number" ? ` \xB7 ${qualifier}${String(pending)} pending` : ""}${repositorySuffix}${ingestionSuffix(ingestionStatus)})`;
695
+ const delivery = deliveryBacklogState(snapshot.ingestion) === "draining" && snapshot.heartbeat?.healthy === true ? "draining" : "stalled";
696
+ return `primitive ${version} (daemon: degraded \xB7 delivery: ${delivery}${typeof pending === "number" ? ` \xB7 ${qualifier}${String(pending)} pending` : ""}${repositorySuffix}${ingestionSuffix(ingestionStatus)})`;
675
697
  }
676
698
  if (snapshot.heartbeat?.healthy === false) {
677
699
  return `primitive ${version} (daemon: degraded \xB7 presence: unavailable${repositorySuffix}${ingestionSuffix(ingestionStatus)})`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primitive.ai/prim",
3
- "version": "0.1.0-alpha.91",
3
+ "version": "0.1.0-alpha.93",
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",
@@ -1,79 +0,0 @@
1
- import {
2
- terminalSafeLine
3
- } from "./chunk-PCVGBE5B.js";
4
-
5
- // src/lib/ansi.ts
6
- var ANSI_CODES = {
7
- yellow: "\x1B[33m",
8
- magenta: "\x1B[35m",
9
- blue: "\x1B[34m",
10
- cyan: "\x1B[36m",
11
- green: "\x1B[32m",
12
- red: "\x1B[31m",
13
- // 256-color approximation of the orange trigger marker (xterm 208).
14
- orange: "\x1B[38;5;208m",
15
- gray: "\x1B[90m"
16
- };
17
- var ANSI_RESET = "\x1B[0m";
18
- var ANSI_DIM = "\x1B[2m";
19
- var ANSI_BOLD = "\x1B[1m";
20
- function supportsColor() {
21
- if (process.env.NO_COLOR !== void 0 && process.env.NO_COLOR !== "") {
22
- return false;
23
- }
24
- return process.stderr.isTTY === true;
25
- }
26
- function color(text, c) {
27
- if (!supportsColor()) {
28
- return text;
29
- }
30
- return `${ANSI_CODES[c]}${text}${ANSI_RESET}`;
31
- }
32
- function dim(text) {
33
- if (!supportsColor()) {
34
- return text;
35
- }
36
- return `${ANSI_DIM}${text}${ANSI_RESET}`;
37
- }
38
- function bold(text) {
39
- if (!supportsColor()) {
40
- return text;
41
- }
42
- return `${ANSI_BOLD}${text}${ANSI_RESET}`;
43
- }
44
- var AREA_COLORS = {
45
- auth: "yellow",
46
- data: "magenta",
47
- mobile: "blue",
48
- infra: "cyan",
49
- ui: "green",
50
- billing: "orange",
51
- api: "blue",
52
- docs: "gray",
53
- testing: "gray"
54
- };
55
- function colorForArea(area) {
56
- if (!area) {
57
- return "gray";
58
- }
59
- return AREA_COLORS[area] ?? "gray";
60
- }
61
- var MAX_HEALTH_ERROR_LENGTH = 240;
62
- function boundedHealthError(value) {
63
- if (!value) return void 0;
64
- const clean = terminalSafeLine(value);
65
- if (!clean) return void 0;
66
- return clean.length <= MAX_HEALTH_ERROR_LENGTH ? clean : `${clean.slice(0, MAX_HEALTH_ERROR_LENGTH - 1)}\u2026`;
67
- }
68
- function stripAnsi(text) {
69
- return text.replace(/\u001b\[[0-9;]*m/g, "");
70
- }
71
-
72
- export {
73
- color,
74
- dim,
75
- bold,
76
- colorForArea,
77
- boundedHealthError,
78
- stripAnsi
79
- };