@primitive.ai/prim 0.1.0-alpha.120 → 0.1.0-alpha.121
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 +19 -9
- package/SKILL.md +7 -2
- package/dist/{chunk-HXICZG5J.js → chunk-2DNC2MUN.js} +4 -4
- package/dist/{chunk-NQFRQ56V.js → chunk-2PFJJO2M.js} +2 -2
- package/dist/{chunk-P2O7NLVN.js → chunk-4GYJHN26.js} +117 -18
- package/dist/{chunk-5BQ2NEMP.js → chunk-6DEROXLM.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-L52OD62C.js → chunk-BHT6X3T5.js} +14 -8
- package/dist/{chunk-D235RJNO.js → chunk-DQ4I3FLF.js} +3 -3
- package/dist/{chunk-VOC4KOOP.js → chunk-DVHD6LBQ.js} +2 -2
- package/dist/{chunk-TC4FTRYO.js → chunk-HG7FJK7R.js} +2 -2
- package/dist/{chunk-GYQOZGGF.js → chunk-JXRJLHE4.js} +2 -2
- package/dist/{chunk-2AKDX4RU.js → chunk-JZC2LHS6.js} +1 -1
- package/dist/{chunk-YTF6OCF3.js → chunk-LQLP26RL.js} +5 -5
- package/dist/{chunk-EYBE724K.js → chunk-M4NZJCPQ.js} +4 -4
- package/dist/{chunk-R2NUH4B7.js → chunk-MRDY7VQP.js} +2 -2
- package/dist/{chunk-SLDZJD6Q.js → chunk-NMZSCSMY.js} +1 -1
- package/dist/{chunk-A6M2M5A2.js → chunk-NQZLXYTW.js} +1 -1
- package/dist/{chunk-LTTF4MBE.js → chunk-OXW6PSPT.js} +2 -2
- package/dist/{chunk-U67RBNIZ.js → chunk-S3ZIMGXV.js} +1 -1
- package/dist/{chunk-LBCPRHNG.js → chunk-WN7OURQ3.js} +1 -1
- package/dist/daemon/server.js +78 -16
- package/dist/hook-runtime/daemon/server.js +78 -16
- package/dist/hook-runtime/hooks/post-commit.js +88 -26
- package/dist/hook-runtime/hooks/post-rewrite.js +82 -20
- package/dist/hook-runtime/hooks/post-tool-use.js +82 -20
- package/dist/hook-runtime/hooks/pre-commit.js +9 -5
- package/dist/hook-runtime/hooks/pre-tool-use-worker.js +12 -8
- package/dist/hook-runtime/hooks/prim-hook.js +85 -23
- package/dist/hook-runtime/hooks/session-end.js +75 -13
- package/dist/hook-runtime/hooks/session-start.js +247 -176
- package/dist/hook-runtime/index.js +1147 -692
- 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 +349 -98
- package/dist/statusline-main.js +76 -14
- package/package.json +3 -2
- package/skills/prim-welcome/SKILL.md +197 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
inspectHookRuntime
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-AKGRY7OU.js";
|
|
4
4
|
import {
|
|
5
5
|
isDemoStatusResponse
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6DEROXLM.js";
|
|
7
7
|
import {
|
|
8
8
|
atomicWriteFile,
|
|
9
9
|
primConfigDirectory,
|
|
10
10
|
withFileLock,
|
|
11
11
|
withFileLockSync
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-4GYJHN26.js";
|
|
13
13
|
|
|
14
14
|
// src/hooks/pre-tool-use-scoring.ts
|
|
15
15
|
import { isAbsolute, relative, sep } from "path";
|
|
@@ -1241,14 +1241,14 @@ function readRun(id) {
|
|
|
1241
1241
|
"cleanup",
|
|
1242
1242
|
"completed",
|
|
1243
1243
|
"skipped"
|
|
1244
|
-
].includes(run.stage) || run.needsStatus !== void 0 && typeof run.needsStatus !== "boolean" || run.server !== void 0 && !isDemoStatusResponse(run.server) || run.receipt !== void 0 && (!Number.isSafeInteger(run.receipt.revision) || run.receipt.revision < 0 || !/^[a-f0-9]{64}$/u.test(run.receipt.appliedDigest)) || typeof run.terminal !== "boolean" || !Array.isArray(run.launcher) || run.launcher.length !== 2 || run.launcher.some((value) => typeof value !== "string" || !value.startsWith("/")) || run.agent !== void 0 && !["claude_code", "codex", "cursor", "hermes"].includes(run.agent)) {
|
|
1244
|
+
].includes(run.stage) || run.needsStatus !== void 0 && typeof run.needsStatus !== "boolean" || run.server !== void 0 && !isDemoStatusResponse(run.server) || run.receipt !== void 0 && (!Number.isSafeInteger(run.receipt.revision) || run.receipt.revision < 0 || !/^[a-f0-9]{64}$/u.test(run.receipt.appliedDigest)) || typeof run.terminal !== "boolean" || !Array.isArray(run.launcher) || run.launcher.length !== 2 || run.launcher.some((value) => typeof value !== "string" || !value.startsWith("/")) || run.agent !== void 0 && !["claude_code", "codex", "cursor", "hermes"].includes(run.agent) || run.welcomeRepo !== void 0 && (typeof run.welcomeRepo !== "string" || !run.welcomeRepo.startsWith("/"))) {
|
|
1245
1245
|
throw new Error("invalid demo run state");
|
|
1246
1246
|
}
|
|
1247
1247
|
return run;
|
|
1248
1248
|
}
|
|
1249
1249
|
var saveRun = (run) => saveDemoJson(runPath(run.id), run);
|
|
1250
1250
|
var lockRun = (id, action) => withFileLockSync(`${runPath(id)}.lock`, () => action(readRun(id)), { timeoutMs: 500 });
|
|
1251
|
-
function prepareRun(agent, terminal = false) {
|
|
1251
|
+
function prepareRun(agent, terminal = false, welcomeRepo) {
|
|
1252
1252
|
const run = {
|
|
1253
1253
|
version: 2,
|
|
1254
1254
|
id: randomUUID(),
|
|
@@ -1256,7 +1256,8 @@ function prepareRun(agent, terminal = false) {
|
|
|
1256
1256
|
terminal,
|
|
1257
1257
|
agent,
|
|
1258
1258
|
preparationKey: preparationKey(agent),
|
|
1259
|
-
launcher: [process.execPath, resolve2(process.argv[1])]
|
|
1259
|
+
launcher: [process.execPath, resolve2(process.argv[1])],
|
|
1260
|
+
...welcomeRepo ? { welcomeRepo } : {}
|
|
1260
1261
|
};
|
|
1261
1262
|
saveRun(run);
|
|
1262
1263
|
return run;
|
|
@@ -1303,10 +1304,13 @@ function onboardingFinished() {
|
|
|
1303
1304
|
function finishOnboarding(outcome) {
|
|
1304
1305
|
saveDemoJson(join(demoDirectory(), "onboarding.json"), { outcome });
|
|
1305
1306
|
}
|
|
1306
|
-
function
|
|
1307
|
+
function runIds() {
|
|
1307
1308
|
const path = join(demoDirectory(), "runs");
|
|
1308
1309
|
if (!existsSync(path)) return [];
|
|
1309
|
-
return readdirSync(path).filter((name) => name.endsWith(".json") && RUN_ID.test(name.slice(0, -5))).map((name) => name.slice(0, -5))
|
|
1310
|
+
return readdirSync(path).filter((name) => name.endsWith(".json") && RUN_ID.test(name.slice(0, -5))).map((name) => name.slice(0, -5));
|
|
1311
|
+
}
|
|
1312
|
+
function pendingRuns() {
|
|
1313
|
+
return runIds().filter((id) => !["completed", "skipped"].includes(readRun(id).stage));
|
|
1310
1314
|
}
|
|
1311
1315
|
function sessionKey(agent, session) {
|
|
1312
1316
|
return createHash("sha256").update(`${agent}\0${session}`).digest("hex");
|
|
@@ -1419,6 +1423,7 @@ export {
|
|
|
1419
1423
|
demoteForMode,
|
|
1420
1424
|
analyzeShellTargets,
|
|
1421
1425
|
RUN_ID,
|
|
1426
|
+
demoDirectory,
|
|
1422
1427
|
runPath,
|
|
1423
1428
|
readDemoJson,
|
|
1424
1429
|
saveDemoJson,
|
|
@@ -1433,6 +1438,7 @@ export {
|
|
|
1433
1438
|
demoResumeCommand,
|
|
1434
1439
|
onboardingFinished,
|
|
1435
1440
|
finishOnboarding,
|
|
1441
|
+
runIds,
|
|
1436
1442
|
pendingRuns,
|
|
1437
1443
|
sessionKey,
|
|
1438
1444
|
exclusionPath,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
daemonRequest
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NMZSCSMY.js";
|
|
4
4
|
import {
|
|
5
5
|
getClient,
|
|
6
6
|
getSiteUrl,
|
|
7
7
|
terminalSafeLine
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-S3ZIMGXV.js";
|
|
9
9
|
import {
|
|
10
10
|
canonicalGitRoot,
|
|
11
11
|
canonicalRepositoryPath,
|
|
12
12
|
currentBranch,
|
|
13
13
|
repoSyncId
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-4GYJHN26.js";
|
|
15
15
|
|
|
16
16
|
// src/daemon/proxy.ts
|
|
17
17
|
var DAEMON_HTTP_TIMEOUT_MS = 1e4;
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./chunk-EZXEWFDG.js";
|
|
4
4
|
import {
|
|
5
5
|
scrubEnvironmentPaths
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-2PFJJO2M.js";
|
|
7
7
|
import {
|
|
8
8
|
isValidRepoSyncId
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4GYJHN26.js";
|
|
10
10
|
|
|
11
11
|
// src/hooks/prim-hook-core.ts
|
|
12
12
|
import { createHash, randomUUID } from "crypto";
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
cursorHooksPath,
|
|
3
3
|
hasExactCursorHandler,
|
|
4
4
|
readCursorHooks
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-AKGRY7OU.js";
|
|
6
6
|
import {
|
|
7
7
|
resolveRepositoryContext
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4GYJHN26.js";
|
|
9
9
|
|
|
10
10
|
// src/hooks/cursor-coexistence.ts
|
|
11
11
|
var CURSOR_EVENTS = /* @__PURE__ */ new Set([
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
analyzeShellTargets,
|
|
3
3
|
extractFileTargets
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BHT6X3T5.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_RULES,
|
|
7
7
|
scrub
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-2PFJJO2M.js";
|
|
9
9
|
import {
|
|
10
10
|
boundedHealthError,
|
|
11
11
|
isPreflightResponseV4
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-6DEROXLM.js";
|
|
13
13
|
import {
|
|
14
14
|
getClient,
|
|
15
15
|
terminalSafeLine
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-S3ZIMGXV.js";
|
|
17
17
|
import {
|
|
18
18
|
canonicalGitRoot,
|
|
19
19
|
canonicalRepositoryPath
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-4GYJHN26.js";
|
|
21
21
|
|
|
22
22
|
// src/hooks/approval-copy.ts
|
|
23
23
|
var MAX_EXCERPT_CHARS = 80;
|
|
@@ -4,20 +4,20 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
analyzeShellTargets,
|
|
6
6
|
extractFileTargets
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-BHT6X3T5.js";
|
|
8
8
|
import {
|
|
9
9
|
scrubEnvironmentPaths
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-2PFJJO2M.js";
|
|
11
11
|
import {
|
|
12
12
|
cachedCollectScopeAdmits
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-6DEROXLM.js";
|
|
14
14
|
import {
|
|
15
15
|
canonicalRepositoryPath,
|
|
16
16
|
currentBranch,
|
|
17
17
|
isRepoActiveForCapture,
|
|
18
18
|
relatedWorktreeTarget,
|
|
19
19
|
repoSyncId
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-4GYJHN26.js";
|
|
21
21
|
|
|
22
22
|
// src/hooks/file-refs.ts
|
|
23
23
|
var MAX_PREFLIGHT_FILE_TARGETS = 25;
|
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
saveRun,
|
|
12
12
|
sessionExcluded,
|
|
13
13
|
sessionKey
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-BHT6X3T5.js";
|
|
15
15
|
import {
|
|
16
16
|
packageVersion
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-4GYJHN26.js";
|
|
18
18
|
|
|
19
19
|
// src/demo/isolation.ts
|
|
20
20
|
import { existsSync } from "fs";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getSiteUrl
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-S3ZIMGXV.js";
|
|
4
4
|
import {
|
|
5
5
|
atomicWriteFile,
|
|
6
6
|
ensureDurableDirectory,
|
|
7
7
|
jwtOrganizationId,
|
|
8
8
|
primConfigDirectory,
|
|
9
9
|
resolveAuthCredential
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-4GYJHN26.js";
|
|
11
11
|
|
|
12
12
|
// src/journal.ts
|
|
13
13
|
import {
|
package/dist/daemon/server.js
CHANGED
|
@@ -23775,26 +23775,87 @@ function validate79(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
23775
23775
|
validate79.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
23776
23776
|
|
|
23777
23777
|
// src/lib/activation.ts
|
|
23778
|
-
import { execFileSync as
|
|
23778
|
+
import { execFileSync as execFileSync3 } from "child_process";
|
|
23779
23779
|
import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
|
|
23780
23780
|
import { homedir as homedir2 } from "os";
|
|
23781
23781
|
import { join as join9 } from "path";
|
|
23782
23782
|
|
|
23783
|
-
// src/lib/
|
|
23783
|
+
// src/lib/demo-pause.ts
|
|
23784
23784
|
import { execFileSync } from "child_process";
|
|
23785
|
+
var DEMO_PAUSE_MS = 30 * 6e4;
|
|
23786
|
+
var PAUSE_KEY = "prim.demoPause";
|
|
23787
|
+
var GIT_TIMEOUT_MS = 1e3;
|
|
23788
|
+
function git(cwd, args) {
|
|
23789
|
+
try {
|
|
23790
|
+
return execFileSync("git", args, {
|
|
23791
|
+
cwd,
|
|
23792
|
+
encoding: "utf-8",
|
|
23793
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
23794
|
+
timeout: GIT_TIMEOUT_MS
|
|
23795
|
+
});
|
|
23796
|
+
} catch {
|
|
23797
|
+
return void 0;
|
|
23798
|
+
}
|
|
23799
|
+
}
|
|
23800
|
+
function setLocal(cwd, key, value) {
|
|
23801
|
+
try {
|
|
23802
|
+
execFileSync(
|
|
23803
|
+
"git",
|
|
23804
|
+
value === null ? ["config", "--local", "--unset", key] : ["config", "--local", key, value],
|
|
23805
|
+
{ cwd, stdio: ["ignore", "ignore", "pipe"], timeout: GIT_TIMEOUT_MS }
|
|
23806
|
+
);
|
|
23807
|
+
} catch (error) {
|
|
23808
|
+
if (value !== null || error.status !== 5) throw error;
|
|
23809
|
+
}
|
|
23810
|
+
}
|
|
23811
|
+
function parsePause(value) {
|
|
23812
|
+
const [runId = "", until, previous, state] = value.trim().split(" ");
|
|
23813
|
+
const flag = previous === "true" || previous === "false" ? previous : "unset";
|
|
23814
|
+
return { runId, until: Number(until) || 0, previous: flag, ending: state !== "active" };
|
|
23815
|
+
}
|
|
23816
|
+
function readCaptureConfig(cwd) {
|
|
23817
|
+
let active;
|
|
23818
|
+
let pause;
|
|
23819
|
+
const out = git(cwd, ["config", "--get-regexp", "^prim\\.(active|demopause)$"]) ?? "";
|
|
23820
|
+
for (const line of out.split("\n")) {
|
|
23821
|
+
const space = line.indexOf(" ");
|
|
23822
|
+
const key = line.slice(0, space).toLowerCase();
|
|
23823
|
+
const value = line.slice(space + 1);
|
|
23824
|
+
if (key === "prim.active") active = value === "true" || value === "false" ? value : void 0;
|
|
23825
|
+
if (key === "prim.demopause") pause = parsePause(value);
|
|
23826
|
+
}
|
|
23827
|
+
return { active, pause };
|
|
23828
|
+
}
|
|
23829
|
+
function resumeCapture(cwd, pause) {
|
|
23830
|
+
setLocal(cwd, "prim.active", pause.previous === "unset" ? null : pause.previous);
|
|
23831
|
+
setLocal(cwd, PAUSE_KEY, null);
|
|
23832
|
+
}
|
|
23833
|
+
function healDemoPause(cwd, pause, options = {}) {
|
|
23834
|
+
if (pause.until > (options.now ?? Date.now()) && !(pause.ending && options.userPrompt))
|
|
23835
|
+
return false;
|
|
23836
|
+
try {
|
|
23837
|
+
resumeCapture(cwd, pause);
|
|
23838
|
+
return true;
|
|
23839
|
+
} catch {
|
|
23840
|
+
return false;
|
|
23841
|
+
}
|
|
23842
|
+
}
|
|
23843
|
+
|
|
23844
|
+
// src/lib/git.ts
|
|
23845
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
23785
23846
|
import { createHash as createHash5 } from "crypto";
|
|
23786
23847
|
import { lstatSync as lstatSync2, realpathSync } from "fs";
|
|
23787
23848
|
import { basename as basename2, dirname as dirname7, isAbsolute as isAbsolute3, relative, resolve as resolve2, sep } from "path";
|
|
23788
|
-
var
|
|
23849
|
+
var GIT_TIMEOUT_MS2 = 1e3;
|
|
23789
23850
|
var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
|
|
23790
23851
|
var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]{1,100}$/u;
|
|
23791
23852
|
function gitToplevel(cwd) {
|
|
23792
23853
|
try {
|
|
23793
|
-
return
|
|
23854
|
+
return execFileSync2("git", ["rev-parse", "--show-toplevel"], {
|
|
23794
23855
|
cwd,
|
|
23795
23856
|
encoding: "utf-8",
|
|
23796
23857
|
stdio: ["ignore", "pipe", "ignore"],
|
|
23797
|
-
timeout:
|
|
23858
|
+
timeout: GIT_TIMEOUT_MS2
|
|
23798
23859
|
}).trim();
|
|
23799
23860
|
} catch {
|
|
23800
23861
|
return null;
|
|
@@ -23802,11 +23863,11 @@ function gitToplevel(cwd) {
|
|
|
23802
23863
|
}
|
|
23803
23864
|
function gitValue(cwd, args) {
|
|
23804
23865
|
try {
|
|
23805
|
-
const value =
|
|
23866
|
+
const value = execFileSync2("git", args, {
|
|
23806
23867
|
cwd,
|
|
23807
23868
|
encoding: "utf-8",
|
|
23808
23869
|
stdio: ["ignore", "pipe", "ignore"],
|
|
23809
|
-
timeout:
|
|
23870
|
+
timeout: GIT_TIMEOUT_MS2
|
|
23810
23871
|
}).trim();
|
|
23811
23872
|
return value || void 0;
|
|
23812
23873
|
} catch {
|
|
@@ -23833,17 +23894,17 @@ var PRIM_ACTIVE_KEY = "prim.active";
|
|
|
23833
23894
|
var PRIM_REPO_SYNC_ID_KEY = "prim.repoSyncId";
|
|
23834
23895
|
var PRIM_REPO_SYNC_REPOSITORY_KEY = "prim.repoSyncRepository";
|
|
23835
23896
|
var PRIM_REPO_BINDING_STATE_KEY = "prim.repoBindingState";
|
|
23836
|
-
var
|
|
23897
|
+
var GIT_TIMEOUT_MS3 = 1e3;
|
|
23837
23898
|
var REPO_SYNC_ID_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
23838
23899
|
var PROJECT_INSTALL_FILES = [".claude/settings.json", ".codex/hooks.json", ".cursor/hooks.json"];
|
|
23839
23900
|
var PRIM_HOOK_BINS = ["prim-hook", "prim-pre-tool-use", "prim-post-tool-use"];
|
|
23840
23901
|
function repoActiveFlag(cwd, strict = false) {
|
|
23841
23902
|
try {
|
|
23842
|
-
const value =
|
|
23903
|
+
const value = execFileSync3("git", ["config", "--get", PRIM_ACTIVE_KEY], {
|
|
23843
23904
|
cwd,
|
|
23844
23905
|
encoding: "utf-8",
|
|
23845
23906
|
stdio: ["ignore", "pipe", "ignore"],
|
|
23846
|
-
timeout:
|
|
23907
|
+
timeout: GIT_TIMEOUT_MS3
|
|
23847
23908
|
}).trim();
|
|
23848
23909
|
if (value === "true") return "true";
|
|
23849
23910
|
if (value === "false") return "false";
|
|
@@ -23860,11 +23921,11 @@ function isValidRepoSyncId(value) {
|
|
|
23860
23921
|
}
|
|
23861
23922
|
function localGitConfigValue(cwd, key) {
|
|
23862
23923
|
try {
|
|
23863
|
-
const value =
|
|
23924
|
+
const value = execFileSync3("git", ["config", "--local", "--get", key], {
|
|
23864
23925
|
cwd,
|
|
23865
23926
|
encoding: "utf-8",
|
|
23866
23927
|
stdio: ["ignore", "pipe", "ignore"],
|
|
23867
|
-
timeout:
|
|
23928
|
+
timeout: GIT_TIMEOUT_MS3
|
|
23868
23929
|
}).trim();
|
|
23869
23930
|
return value || void 0;
|
|
23870
23931
|
} catch {
|
|
@@ -23872,10 +23933,10 @@ function localGitConfigValue(cwd, key) {
|
|
|
23872
23933
|
}
|
|
23873
23934
|
}
|
|
23874
23935
|
function setLocalGitConfigValue(cwd, key, value) {
|
|
23875
|
-
|
|
23936
|
+
execFileSync3("git", ["config", "--local", key, value], {
|
|
23876
23937
|
cwd,
|
|
23877
23938
|
stdio: ["ignore", "ignore", "pipe"],
|
|
23878
|
-
timeout:
|
|
23939
|
+
timeout: GIT_TIMEOUT_MS3
|
|
23879
23940
|
});
|
|
23880
23941
|
}
|
|
23881
23942
|
function repoSyncId(cwd) {
|
|
@@ -23908,8 +23969,9 @@ function hasProjectPrimInstall(cwd) {
|
|
|
23908
23969
|
}
|
|
23909
23970
|
return false;
|
|
23910
23971
|
}
|
|
23911
|
-
function isRepoActiveForCapture(cwd) {
|
|
23912
|
-
|
|
23972
|
+
function isRepoActiveForCapture(cwd, options = {}) {
|
|
23973
|
+
let { active: flag, pause } = readCaptureConfig(cwd);
|
|
23974
|
+
if (pause && healDemoPause(cwd, pause, options)) flag = repoActiveFlag(cwd);
|
|
23913
23975
|
if (flag === "true") return true;
|
|
23914
23976
|
if (flag === "false") return false;
|
|
23915
23977
|
return hasProjectPrimInstall(cwd);
|
|
@@ -23776,26 +23776,87 @@ function validate79(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
23776
23776
|
validate79.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
23777
23777
|
|
|
23778
23778
|
// src/lib/activation.ts
|
|
23779
|
-
import { execFileSync as
|
|
23779
|
+
import { execFileSync as execFileSync3 } from "child_process";
|
|
23780
23780
|
import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
|
|
23781
23781
|
import { homedir as homedir2 } from "os";
|
|
23782
23782
|
import { join as join9 } from "path";
|
|
23783
23783
|
|
|
23784
|
-
// src/lib/
|
|
23784
|
+
// src/lib/demo-pause.ts
|
|
23785
23785
|
import { execFileSync } from "child_process";
|
|
23786
|
+
var DEMO_PAUSE_MS = 30 * 6e4;
|
|
23787
|
+
var PAUSE_KEY = "prim.demoPause";
|
|
23788
|
+
var GIT_TIMEOUT_MS = 1e3;
|
|
23789
|
+
function git(cwd, args) {
|
|
23790
|
+
try {
|
|
23791
|
+
return execFileSync("git", args, {
|
|
23792
|
+
cwd,
|
|
23793
|
+
encoding: "utf-8",
|
|
23794
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
23795
|
+
timeout: GIT_TIMEOUT_MS
|
|
23796
|
+
});
|
|
23797
|
+
} catch {
|
|
23798
|
+
return void 0;
|
|
23799
|
+
}
|
|
23800
|
+
}
|
|
23801
|
+
function setLocal(cwd, key, value) {
|
|
23802
|
+
try {
|
|
23803
|
+
execFileSync(
|
|
23804
|
+
"git",
|
|
23805
|
+
value === null ? ["config", "--local", "--unset", key] : ["config", "--local", key, value],
|
|
23806
|
+
{ cwd, stdio: ["ignore", "ignore", "pipe"], timeout: GIT_TIMEOUT_MS }
|
|
23807
|
+
);
|
|
23808
|
+
} catch (error) {
|
|
23809
|
+
if (value !== null || error.status !== 5) throw error;
|
|
23810
|
+
}
|
|
23811
|
+
}
|
|
23812
|
+
function parsePause(value) {
|
|
23813
|
+
const [runId = "", until, previous, state] = value.trim().split(" ");
|
|
23814
|
+
const flag = previous === "true" || previous === "false" ? previous : "unset";
|
|
23815
|
+
return { runId, until: Number(until) || 0, previous: flag, ending: state !== "active" };
|
|
23816
|
+
}
|
|
23817
|
+
function readCaptureConfig(cwd) {
|
|
23818
|
+
let active;
|
|
23819
|
+
let pause;
|
|
23820
|
+
const out = git(cwd, ["config", "--get-regexp", "^prim\\.(active|demopause)$"]) ?? "";
|
|
23821
|
+
for (const line of out.split("\n")) {
|
|
23822
|
+
const space = line.indexOf(" ");
|
|
23823
|
+
const key = line.slice(0, space).toLowerCase();
|
|
23824
|
+
const value = line.slice(space + 1);
|
|
23825
|
+
if (key === "prim.active") active = value === "true" || value === "false" ? value : void 0;
|
|
23826
|
+
if (key === "prim.demopause") pause = parsePause(value);
|
|
23827
|
+
}
|
|
23828
|
+
return { active, pause };
|
|
23829
|
+
}
|
|
23830
|
+
function resumeCapture(cwd, pause) {
|
|
23831
|
+
setLocal(cwd, "prim.active", pause.previous === "unset" ? null : pause.previous);
|
|
23832
|
+
setLocal(cwd, PAUSE_KEY, null);
|
|
23833
|
+
}
|
|
23834
|
+
function healDemoPause(cwd, pause, options = {}) {
|
|
23835
|
+
if (pause.until > (options.now ?? Date.now()) && !(pause.ending && options.userPrompt))
|
|
23836
|
+
return false;
|
|
23837
|
+
try {
|
|
23838
|
+
resumeCapture(cwd, pause);
|
|
23839
|
+
return true;
|
|
23840
|
+
} catch {
|
|
23841
|
+
return false;
|
|
23842
|
+
}
|
|
23843
|
+
}
|
|
23844
|
+
|
|
23845
|
+
// src/lib/git.ts
|
|
23846
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
23786
23847
|
import { createHash as createHash5 } from "crypto";
|
|
23787
23848
|
import { lstatSync as lstatSync2, realpathSync } from "fs";
|
|
23788
23849
|
import { basename as basename2, dirname as dirname7, isAbsolute as isAbsolute3, relative, resolve as resolve2, sep } from "path";
|
|
23789
|
-
var
|
|
23850
|
+
var GIT_TIMEOUT_MS2 = 1e3;
|
|
23790
23851
|
var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
|
|
23791
23852
|
var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]{1,100}$/u;
|
|
23792
23853
|
function gitToplevel(cwd) {
|
|
23793
23854
|
try {
|
|
23794
|
-
return
|
|
23855
|
+
return execFileSync2("git", ["rev-parse", "--show-toplevel"], {
|
|
23795
23856
|
cwd,
|
|
23796
23857
|
encoding: "utf-8",
|
|
23797
23858
|
stdio: ["ignore", "pipe", "ignore"],
|
|
23798
|
-
timeout:
|
|
23859
|
+
timeout: GIT_TIMEOUT_MS2
|
|
23799
23860
|
}).trim();
|
|
23800
23861
|
} catch {
|
|
23801
23862
|
return null;
|
|
@@ -23803,11 +23864,11 @@ function gitToplevel(cwd) {
|
|
|
23803
23864
|
}
|
|
23804
23865
|
function gitValue(cwd, args) {
|
|
23805
23866
|
try {
|
|
23806
|
-
const value =
|
|
23867
|
+
const value = execFileSync2("git", args, {
|
|
23807
23868
|
cwd,
|
|
23808
23869
|
encoding: "utf-8",
|
|
23809
23870
|
stdio: ["ignore", "pipe", "ignore"],
|
|
23810
|
-
timeout:
|
|
23871
|
+
timeout: GIT_TIMEOUT_MS2
|
|
23811
23872
|
}).trim();
|
|
23812
23873
|
return value || void 0;
|
|
23813
23874
|
} catch {
|
|
@@ -23834,17 +23895,17 @@ var PRIM_ACTIVE_KEY = "prim.active";
|
|
|
23834
23895
|
var PRIM_REPO_SYNC_ID_KEY = "prim.repoSyncId";
|
|
23835
23896
|
var PRIM_REPO_SYNC_REPOSITORY_KEY = "prim.repoSyncRepository";
|
|
23836
23897
|
var PRIM_REPO_BINDING_STATE_KEY = "prim.repoBindingState";
|
|
23837
|
-
var
|
|
23898
|
+
var GIT_TIMEOUT_MS3 = 1e3;
|
|
23838
23899
|
var REPO_SYNC_ID_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
23839
23900
|
var PROJECT_INSTALL_FILES = [".claude/settings.json", ".codex/hooks.json", ".cursor/hooks.json"];
|
|
23840
23901
|
var PRIM_HOOK_BINS = ["prim-hook", "prim-pre-tool-use", "prim-post-tool-use"];
|
|
23841
23902
|
function repoActiveFlag(cwd, strict = false) {
|
|
23842
23903
|
try {
|
|
23843
|
-
const value =
|
|
23904
|
+
const value = execFileSync3("git", ["config", "--get", PRIM_ACTIVE_KEY], {
|
|
23844
23905
|
cwd,
|
|
23845
23906
|
encoding: "utf-8",
|
|
23846
23907
|
stdio: ["ignore", "pipe", "ignore"],
|
|
23847
|
-
timeout:
|
|
23908
|
+
timeout: GIT_TIMEOUT_MS3
|
|
23848
23909
|
}).trim();
|
|
23849
23910
|
if (value === "true") return "true";
|
|
23850
23911
|
if (value === "false") return "false";
|
|
@@ -23861,11 +23922,11 @@ function isValidRepoSyncId(value) {
|
|
|
23861
23922
|
}
|
|
23862
23923
|
function localGitConfigValue(cwd, key) {
|
|
23863
23924
|
try {
|
|
23864
|
-
const value =
|
|
23925
|
+
const value = execFileSync3("git", ["config", "--local", "--get", key], {
|
|
23865
23926
|
cwd,
|
|
23866
23927
|
encoding: "utf-8",
|
|
23867
23928
|
stdio: ["ignore", "pipe", "ignore"],
|
|
23868
|
-
timeout:
|
|
23929
|
+
timeout: GIT_TIMEOUT_MS3
|
|
23869
23930
|
}).trim();
|
|
23870
23931
|
return value || void 0;
|
|
23871
23932
|
} catch {
|
|
@@ -23873,10 +23934,10 @@ function localGitConfigValue(cwd, key) {
|
|
|
23873
23934
|
}
|
|
23874
23935
|
}
|
|
23875
23936
|
function setLocalGitConfigValue(cwd, key, value) {
|
|
23876
|
-
|
|
23937
|
+
execFileSync3("git", ["config", "--local", key, value], {
|
|
23877
23938
|
cwd,
|
|
23878
23939
|
stdio: ["ignore", "ignore", "pipe"],
|
|
23879
|
-
timeout:
|
|
23940
|
+
timeout: GIT_TIMEOUT_MS3
|
|
23880
23941
|
});
|
|
23881
23942
|
}
|
|
23882
23943
|
function repoSyncId(cwd) {
|
|
@@ -23909,8 +23970,9 @@ function hasProjectPrimInstall(cwd) {
|
|
|
23909
23970
|
}
|
|
23910
23971
|
return false;
|
|
23911
23972
|
}
|
|
23912
|
-
function isRepoActiveForCapture(cwd) {
|
|
23913
|
-
|
|
23973
|
+
function isRepoActiveForCapture(cwd, options = {}) {
|
|
23974
|
+
let { active: flag, pause } = readCaptureConfig(cwd);
|
|
23975
|
+
if (pause && healDemoPause(cwd, pause, options)) flag = repoActiveFlag(cwd);
|
|
23914
23976
|
if (flag === "true") return true;
|
|
23915
23977
|
if (flag === "false") return false;
|
|
23916
23978
|
return hasProjectPrimInstall(cwd);
|