@primitive.ai/prim 0.1.0-alpha.98 → 0.1.0-alpha.99

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 +11 -0
  2. package/dist/{chunk-7IPGD6CD.js → chunk-25DDRMWS.js} +2 -2
  3. package/dist/{chunk-B6EPQ4YH.js → chunk-2IRLFOEL.js} +123 -19
  4. package/dist/{chunk-WKLYYT63.js → chunk-2Q3OGSTV.js} +3 -3
  5. package/dist/{chunk-2DPLT2CQ.js → chunk-5LRKJTLA.js} +1 -1
  6. package/dist/{chunk-AN6XTFIN.js → chunk-6C3CCVDI.js} +2 -2
  7. package/dist/{chunk-NIQAVFP6.js → chunk-7VIMU2HR.js} +1 -1
  8. package/dist/{chunk-2DA2B4EC.js → chunk-EJPKZT5M.js} +2 -2
  9. package/dist/{chunk-HUZXBJJ5.js → chunk-FK7FJPWS.js} +1 -1
  10. package/dist/{chunk-QPMLAD2C.js → chunk-JJI7FU24.js} +2 -2
  11. package/dist/{chunk-PPZBEOWK.js → chunk-JJYS7IPD.js} +3 -3
  12. package/dist/{chunk-RT7DXMTN.js → chunk-K4JWJ6OM.js} +79 -266
  13. package/dist/{chunk-3X77XQGW.js → chunk-KGBMU76T.js} +1 -1
  14. package/dist/{chunk-JOR67B5T.js → chunk-O2WV5SQZ.js} +8 -8
  15. package/dist/{chunk-IL443QTF.js → chunk-X5BN67D2.js} +2 -2
  16. package/dist/{chunk-6QK75B7G.js → chunk-XG7S3LIL.js} +214 -11
  17. package/dist/{chunk-MN4X6RR6.js → chunk-XPS6LG6I.js} +5 -7
  18. package/dist/{chunk-BIAWZMCK.js → chunk-ZNLIGT3J.js} +2 -2
  19. package/dist/daemon/server.js +247 -180
  20. package/dist/hook-runtime/daemon/server.js +247 -180
  21. package/dist/hook-runtime/hooks/post-commit.js +114 -59
  22. package/dist/hook-runtime/hooks/post-rewrite.js +109 -54
  23. package/dist/hook-runtime/hooks/post-tool-use.js +256 -156
  24. package/dist/hook-runtime/hooks/pre-commit.js +177 -33
  25. package/dist/hook-runtime/hooks/pre-tool-use.js +237 -137
  26. package/dist/hook-runtime/hooks/prim-hook.js +281 -181
  27. package/dist/hook-runtime/hooks/session-start.js +209 -109
  28. package/dist/hook-runtime/index.js +615 -515
  29. package/dist/hook-runtime/statusline-main.js +71 -16
  30. package/dist/hooks/post-commit.js +7 -7
  31. package/dist/hooks/post-rewrite.js +6 -6
  32. package/dist/hooks/post-tool-use.js +13 -13
  33. package/dist/hooks/pre-commit.js +4 -4
  34. package/dist/hooks/pre-tool-use.js +10 -11
  35. package/dist/hooks/prim-hook.js +14 -14
  36. package/dist/hooks/session-end.js +4 -4
  37. package/dist/hooks/session-start.js +11 -11
  38. package/dist/index.js +20 -20
  39. package/dist/statusline-main.js +71 -16
  40. package/package.json +1 -1
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/commands/statusline.ts
4
- import { readFileSync as readFileSync5 } from "fs";
5
- import { dirname as dirname5, resolve as resolve3 } from "path";
6
- import { fileURLToPath } from "url";
4
+ import { readFileSync as readFileSync7 } from "fs";
5
+ import { dirname as dirname6, resolve as resolve3 } from "path";
6
+ import { fileURLToPath as fileURLToPath2 } from "url";
7
7
 
8
8
  // src/client.ts
9
9
  import { createHash as createHash2 } from "crypto";
10
- import { chmodSync, existsSync as existsSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync3, rmSync as rmSync3 } from "fs";
11
- import { dirname as dirname3 } from "path";
10
+ import { chmodSync as chmodSync2, existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync5, rmSync as rmSync3 } from "fs";
11
+ import { dirname as dirname4 } from "path";
12
12
 
13
13
  // src/lib/atomic-file.ts
14
14
  import { randomUUID } from "crypto";
@@ -278,6 +278,61 @@ import { existsSync, mkdirSync as mkdirSync2, readFileSync as readFileSync2, rmS
278
278
  import { dirname as dirname2, join as join3 } from "path";
279
279
  var syncSleeper = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
280
280
 
281
+ // src/daemon/client-instance-id.ts
282
+ import { randomBytes as randomBytes2 } from "crypto";
283
+ import { chmodSync, lstatSync, readFileSync as readFileSync3 } from "fs";
284
+ import { join as join4 } from "path";
285
+ var INSTANCE_BODY_CHARS = 43;
286
+ var INSTANCE_PREFIX = "pci_";
287
+ var MAX_STORED_BYTES = INSTANCE_PREFIX.length + INSTANCE_BODY_CHARS + 1;
288
+
289
+ // src/lib/bin-path.ts
290
+ import { existsSync as existsSync2, readFileSync as readFileSync4 } from "fs";
291
+ import { dirname as dirname3, isAbsolute as isAbsolute2, join as join5 } from "path";
292
+ import { fileURLToPath } from "url";
293
+ var PKG_NAME = "@primitive.ai/prim";
294
+ var ROOT_WALK_LIMIT = 6;
295
+ var resolvedRoot;
296
+ function locateRoot() {
297
+ if (resolvedRoot !== void 0) {
298
+ return resolvedRoot;
299
+ }
300
+ let dir = dirname3(fileURLToPath(import.meta.url));
301
+ for (let depth = 0; depth < ROOT_WALK_LIMIT; depth++) {
302
+ const manifestPath = join5(dir, "package.json");
303
+ if (existsSync2(manifestPath)) {
304
+ try {
305
+ const manifest = JSON.parse(readFileSync4(manifestPath, "utf-8"));
306
+ if (manifest.name === PKG_NAME && manifest.bin) {
307
+ resolvedRoot = { dir, version: manifest.version, bin: manifest.bin };
308
+ return resolvedRoot;
309
+ }
310
+ } catch {
311
+ }
312
+ }
313
+ const parent = dirname3(dir);
314
+ if (parent === dir) {
315
+ break;
316
+ }
317
+ dir = parent;
318
+ }
319
+ resolvedRoot = null;
320
+ return resolvedRoot;
321
+ }
322
+ function packageVersion() {
323
+ return locateRoot()?.version ?? null;
324
+ }
325
+ var PRIM_CONFIG_SHELL_RESOLVER = [
326
+ 'prim_absolute() { case "$1" in [/]* ) ;; *) return 1 ;; esac; case "$1" in [[:space:]]*|*[[:space:]]|*[/][/]*|*[/].[/]*|*[/]..[/]*|*[/].|*[/]..|?*[/]) return 1 ;; esac; }; ',
327
+ 'prim_config=${PRIM_CONFIG_DIR:-}; if ! prim_absolute "$prim_config"; then prim_config=${XDG_CONFIG_HOME:-}; if prim_absolute "$prim_config"; then ',
328
+ 'case "$prim_config" in /) prim_config=/prim ;; *) prim_config="$prim_config/prim" ;; esac; ',
329
+ 'else prim_home=${HOME:-}; prim_absolute "$prim_home" || exit 78; case "$prim_home" in /) prim_config=/.config/prim ;; *) prim_config="$prim_home/.config/prim" ;; esac; ',
330
+ "fi; fi; "
331
+ ].join("");
332
+
333
+ // src/lib/ingest-uploader.ts
334
+ var runtimeVersion = process.env.PRIM_RUNTIME_VERSION ?? packageVersion();
335
+
281
336
  // src/lib/terminal-safe.ts
282
337
  function replaceIsolatedSurrogates(value) {
283
338
  let out = "";
@@ -329,7 +384,7 @@ var CLI_MANAGEMENT_RESPONSE_MAX_BYTES = 2 * 1024 * 1024;
329
384
 
330
385
  // src/daemon/client.ts
331
386
  import { createConnection } from "net";
332
- import { join as join5 } from "path";
387
+ import { join as join7 } from "path";
333
388
 
334
389
  // src/daemon/principal.ts
335
390
  import { createHash as createHash3 } from "crypto";
@@ -376,7 +431,7 @@ function parseDaemonResponseEnvelope(value) {
376
431
  }
377
432
 
378
433
  // src/daemon/client.ts
379
- var SOCK_PATH = join5(primConfigDirectory(), "sock");
434
+ var SOCK_PATH = join7(primConfigDirectory(), "sock");
380
435
  var DEFAULT_TIMEOUT_MS = 250;
381
436
  var nextRequestId = 1;
382
437
  function daemonRequest(method, params = {}, opts = {}) {
@@ -465,15 +520,15 @@ function daemonRequest(method, params = {}, opts = {}) {
465
520
 
466
521
  // src/lib/activation.ts
467
522
  import { execFileSync as execFileSync2 } from "child_process";
468
- import { existsSync as existsSync3, readFileSync as readFileSync4 } from "fs";
523
+ import { existsSync as existsSync4, readFileSync as readFileSync6 } from "fs";
469
524
  import { homedir as homedir2 } from "os";
470
- import { join as join6 } from "path";
525
+ import { join as join8 } from "path";
471
526
 
472
527
  // src/lib/git.ts
473
528
  import { execFileSync } from "child_process";
474
529
  import { createHash as createHash4 } from "crypto";
475
- import { lstatSync, realpathSync } from "fs";
476
- import { basename, dirname as dirname4, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "path";
530
+ import { lstatSync as lstatSync2, realpathSync } from "fs";
531
+ import { basename, dirname as dirname5, isAbsolute as isAbsolute3, relative, resolve as resolve2, sep } from "path";
477
532
  var GIT_TIMEOUT_MS = 1e3;
478
533
  var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
479
534
  var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]{1,100}$/u;
@@ -576,10 +631,10 @@ function hasProjectPrimInstall(cwd) {
576
631
  const root = gitToplevel(cwd);
577
632
  if (root === null || root === homedir2()) return false;
578
633
  for (const rel of PROJECT_INSTALL_FILES) {
579
- const path = join6(root, rel);
580
- if (existsSync3(path)) {
634
+ const path = join8(root, rel);
635
+ if (existsSync4(path)) {
581
636
  try {
582
- const content = readFileSync4(path, "utf-8");
637
+ const content = readFileSync6(path, "utf-8");
583
638
  if (PRIM_HOOK_BINS.some((bin) => content.includes(bin))) return true;
584
639
  } catch {
585
640
  }
@@ -726,7 +781,7 @@ function formatStatusline(version, snapshot, resolveIngestionStatus, options = {
726
781
  var STATUSLINE_TIMEOUT_MS = 200;
727
782
  function readPackageVersion() {
728
783
  try {
729
- const here = dirname5(fileURLToPath(import.meta.url));
784
+ const here = dirname6(fileURLToPath2(import.meta.url));
730
785
  const candidates = [
731
786
  // Schema-v2 runtimes staged a manifest beside this standalone bundle.
732
787
  // Keep resolving it while those legacy launchers transition to schema v3.
@@ -736,7 +791,7 @@ function readPackageVersion() {
736
791
  ];
737
792
  for (const path of candidates) {
738
793
  try {
739
- const pkg = JSON.parse(readFileSync5(path, "utf-8"));
794
+ const pkg = JSON.parse(readFileSync7(path, "utf-8"));
740
795
  if (pkg.version) {
741
796
  return pkg.version;
742
797
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primitive.ai/prim",
3
- "version": "0.1.0-alpha.98",
3
+ "version": "0.1.0-alpha.99",
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",