@primitive.ai/prim 0.1.0-alpha.120 → 0.1.0-alpha.122
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 +45 -9
- package/SKILL.md +7 -2
- package/dist/{chunk-P2O7NLVN.js → chunk-4GYJHN26.js} +117 -18
- package/dist/{chunk-VOC4KOOP.js → chunk-4M23K2KZ.js} +2 -2
- package/dist/{chunk-NQFRQ56V.js → chunk-4NUGCUQC.js} +2 -2
- package/dist/{chunk-GYQOZGGF.js → chunk-5ME3WD3P.js} +2 -2
- package/dist/{chunk-CCGFRNAA.js → chunk-7LXRFXZG.js} +248 -127
- package/dist/{chunk-MWNRXAEB.js → chunk-AKGRY7OU.js} +1 -1
- package/dist/{chunk-D235RJNO.js → chunk-DQ4I3FLF.js} +3 -3
- package/dist/{chunk-R2NUH4B7.js → chunk-FT673ALA.js} +2 -2
- package/dist/{chunk-TC4FTRYO.js → chunk-HG7FJK7R.js} +2 -2
- package/dist/{chunk-5BQ2NEMP.js → chunk-HLMC7VS4.js} +2615 -941
- package/dist/{chunk-L52OD62C.js → chunk-JYPVPYW3.js} +14 -8
- package/dist/{chunk-2AKDX4RU.js → chunk-JZC2LHS6.js} +1 -1
- package/dist/{chunk-SLDZJD6Q.js → chunk-NMZSCSMY.js} +1 -1
- package/dist/{chunk-LTTF4MBE.js → chunk-OXW6PSPT.js} +2 -2
- package/dist/{chunk-EYBE724K.js → chunk-QG3GASJO.js} +4 -4
- package/dist/{chunk-A6M2M5A2.js → chunk-RRAC76LJ.js} +1 -1
- package/dist/{chunk-U67RBNIZ.js → chunk-S3ZIMGXV.js} +1 -1
- package/dist/{chunk-HXICZG5J.js → chunk-T2T45KF6.js} +4 -4
- package/dist/{chunk-LBCPRHNG.js → chunk-WN7OURQ3.js} +1 -1
- package/dist/{chunk-YTF6OCF3.js → chunk-ZQ7UK5US.js} +5 -5
- package/dist/daemon/server.js +2603 -867
- package/dist/hook-runtime/daemon/server.js +2603 -867
- package/dist/hook-runtime/hooks/post-commit.js +2671 -935
- package/dist/hook-runtime/hooks/post-rewrite.js +2664 -928
- package/dist/hook-runtime/hooks/post-tool-use.js +2606 -870
- package/dist/hook-runtime/hooks/pre-commit.js +9 -5
- package/dist/hook-runtime/hooks/pre-tool-use-worker.js +2625 -947
- package/dist/hook-runtime/hooks/prim-hook.js +2609 -873
- package/dist/hook-runtime/hooks/session-end.js +75 -13
- package/dist/hook-runtime/hooks/session-start.js +2801 -1056
- package/dist/hook-runtime/index.js +3741 -1556
- package/dist/hook-runtime/statusline-main.js +76 -14
- package/dist/hooks/post-commit.js +7 -7
- package/dist/hooks/post-rewrite.js +6 -6
- package/dist/hooks/post-tool-use.js +15 -15
- package/dist/hooks/pre-commit.js +4 -4
- package/dist/hooks/pre-tool-use-worker.js +9 -9
- package/dist/hooks/prim-hook.js +17 -17
- package/dist/hooks/session-end.js +4 -4
- package/dist/hooks/session-start.js +11 -11
- package/dist/index.js +419 -112
- package/dist/statusline-main.js +76 -14
- package/package.json +4 -2
- package/skills/prim-welcome/SKILL.md +197 -0
|
@@ -389,26 +389,87 @@ function daemonRequest(method, params = {}, opts = {}) {
|
|
|
389
389
|
}
|
|
390
390
|
|
|
391
391
|
// src/lib/activation.ts
|
|
392
|
-
import { execFileSync as
|
|
392
|
+
import { execFileSync as execFileSync3 } from "child_process";
|
|
393
393
|
import { existsSync, readFileSync as readFileSync2 } from "fs";
|
|
394
394
|
import { homedir as homedir2 } from "os";
|
|
395
395
|
import { join as join4 } from "path";
|
|
396
396
|
|
|
397
|
-
// src/lib/
|
|
397
|
+
// src/lib/demo-pause.ts
|
|
398
398
|
import { execFileSync } from "child_process";
|
|
399
|
+
var DEMO_PAUSE_MS = 30 * 6e4;
|
|
400
|
+
var PAUSE_KEY = "prim.demoPause";
|
|
401
|
+
var GIT_TIMEOUT_MS = 1e3;
|
|
402
|
+
function git(cwd, args) {
|
|
403
|
+
try {
|
|
404
|
+
return execFileSync("git", args, {
|
|
405
|
+
cwd,
|
|
406
|
+
encoding: "utf-8",
|
|
407
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
408
|
+
timeout: GIT_TIMEOUT_MS
|
|
409
|
+
});
|
|
410
|
+
} catch {
|
|
411
|
+
return void 0;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
function setLocal(cwd, key, value) {
|
|
415
|
+
try {
|
|
416
|
+
execFileSync(
|
|
417
|
+
"git",
|
|
418
|
+
value === null ? ["config", "--local", "--unset", key] : ["config", "--local", key, value],
|
|
419
|
+
{ cwd, stdio: ["ignore", "ignore", "pipe"], timeout: GIT_TIMEOUT_MS }
|
|
420
|
+
);
|
|
421
|
+
} catch (error) {
|
|
422
|
+
if (value !== null || error.status !== 5) throw error;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
function parsePause(value) {
|
|
426
|
+
const [runId = "", until, previous, state] = value.trim().split(" ");
|
|
427
|
+
const flag = previous === "true" || previous === "false" ? previous : "unset";
|
|
428
|
+
return { runId, until: Number(until) || 0, previous: flag, ending: state !== "active" };
|
|
429
|
+
}
|
|
430
|
+
function readCaptureConfig(cwd) {
|
|
431
|
+
let active;
|
|
432
|
+
let pause;
|
|
433
|
+
const out = git(cwd, ["config", "--get-regexp", "^prim\\.(active|demopause)$"]) ?? "";
|
|
434
|
+
for (const line of out.split("\n")) {
|
|
435
|
+
const space = line.indexOf(" ");
|
|
436
|
+
const key = line.slice(0, space).toLowerCase();
|
|
437
|
+
const value = line.slice(space + 1);
|
|
438
|
+
if (key === "prim.active") active = value === "true" || value === "false" ? value : void 0;
|
|
439
|
+
if (key === "prim.demopause") pause = parsePause(value);
|
|
440
|
+
}
|
|
441
|
+
return { active, pause };
|
|
442
|
+
}
|
|
443
|
+
function resumeCapture(cwd, pause) {
|
|
444
|
+
setLocal(cwd, "prim.active", pause.previous === "unset" ? null : pause.previous);
|
|
445
|
+
setLocal(cwd, PAUSE_KEY, null);
|
|
446
|
+
}
|
|
447
|
+
function healDemoPause(cwd, pause, options = {}) {
|
|
448
|
+
if (pause.until > (options.now ?? Date.now()) && !(pause.ending && options.userPrompt))
|
|
449
|
+
return false;
|
|
450
|
+
try {
|
|
451
|
+
resumeCapture(cwd, pause);
|
|
452
|
+
return true;
|
|
453
|
+
} catch {
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// src/lib/git.ts
|
|
459
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
399
460
|
import { createHash as createHash3 } from "crypto";
|
|
400
461
|
import { lstatSync, realpathSync } from "fs";
|
|
401
462
|
import { basename, dirname, isAbsolute as isAbsolute2, relative, resolve, sep } from "path";
|
|
402
|
-
var
|
|
463
|
+
var GIT_TIMEOUT_MS2 = 1e3;
|
|
403
464
|
var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
|
|
404
465
|
var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]{1,100}$/u;
|
|
405
466
|
function gitToplevel(cwd) {
|
|
406
467
|
try {
|
|
407
|
-
return
|
|
468
|
+
return execFileSync2("git", ["rev-parse", "--show-toplevel"], {
|
|
408
469
|
cwd,
|
|
409
470
|
encoding: "utf-8",
|
|
410
471
|
stdio: ["ignore", "pipe", "ignore"],
|
|
411
|
-
timeout:
|
|
472
|
+
timeout: GIT_TIMEOUT_MS2
|
|
412
473
|
}).trim();
|
|
413
474
|
} catch {
|
|
414
475
|
return null;
|
|
@@ -416,11 +477,11 @@ function gitToplevel(cwd) {
|
|
|
416
477
|
}
|
|
417
478
|
function gitValue(cwd, args) {
|
|
418
479
|
try {
|
|
419
|
-
const value =
|
|
480
|
+
const value = execFileSync2("git", args, {
|
|
420
481
|
cwd,
|
|
421
482
|
encoding: "utf-8",
|
|
422
483
|
stdio: ["ignore", "pipe", "ignore"],
|
|
423
|
-
timeout:
|
|
484
|
+
timeout: GIT_TIMEOUT_MS2
|
|
424
485
|
}).trim();
|
|
425
486
|
return value || void 0;
|
|
426
487
|
} catch {
|
|
@@ -499,16 +560,16 @@ function resolveRepositoryContext(cwd = process.cwd()) {
|
|
|
499
560
|
|
|
500
561
|
// src/lib/activation.ts
|
|
501
562
|
var PRIM_ACTIVE_KEY = "prim.active";
|
|
502
|
-
var
|
|
563
|
+
var GIT_TIMEOUT_MS3 = 1e3;
|
|
503
564
|
var PROJECT_INSTALL_FILES = [".claude/settings.json", ".codex/hooks.json", ".cursor/hooks.json"];
|
|
504
565
|
var PRIM_HOOK_BINS = ["prim-hook", "prim-pre-tool-use", "prim-post-tool-use"];
|
|
505
566
|
function repoActiveFlag(cwd, strict = false) {
|
|
506
567
|
try {
|
|
507
|
-
const value =
|
|
568
|
+
const value = execFileSync3("git", ["config", "--get", PRIM_ACTIVE_KEY], {
|
|
508
569
|
cwd,
|
|
509
570
|
encoding: "utf-8",
|
|
510
571
|
stdio: ["ignore", "pipe", "ignore"],
|
|
511
|
-
timeout:
|
|
572
|
+
timeout: GIT_TIMEOUT_MS3
|
|
512
573
|
}).trim();
|
|
513
574
|
if (value === "true") return "true";
|
|
514
575
|
if (value === "false") return "false";
|
|
@@ -535,8 +596,9 @@ function hasProjectPrimInstall(cwd) {
|
|
|
535
596
|
}
|
|
536
597
|
return false;
|
|
537
598
|
}
|
|
538
|
-
function isRepoActiveForCapture(cwd) {
|
|
539
|
-
|
|
599
|
+
function isRepoActiveForCapture(cwd, options = {}) {
|
|
600
|
+
let { active: flag, pause } = readCaptureConfig(cwd);
|
|
601
|
+
if (pause && healDemoPause(cwd, pause, options)) flag = repoActiveFlag(cwd);
|
|
540
602
|
if (flag === "true") return true;
|
|
541
603
|
if (flag === "false") return false;
|
|
542
604
|
return hasProjectPrimInstall(cwd);
|
|
@@ -730,7 +792,7 @@ exec "$prim_node" "$prim_entry" "$@"
|
|
|
730
792
|
`;
|
|
731
793
|
|
|
732
794
|
// src/lib/preflight-host.ts
|
|
733
|
-
import { execFileSync as
|
|
795
|
+
import { execFileSync as execFileSync4 } from "child_process";
|
|
734
796
|
|
|
735
797
|
// src/commands/claude-install.ts
|
|
736
798
|
import { existsSync as existsSync5, readFileSync as readFileSync6 } from "fs";
|