@primitive.ai/prim 0.1.0-alpha.126 → 0.1.0-alpha.128
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 +211 -1
- package/SKILL.md +6 -1
- package/dist/{chunk-ZKXNJB6U.js → chunk-3KPTVK4N.js} +70 -78
- package/dist/{chunk-6KXQQ7CQ.js → chunk-4DYEBYKM.js} +3 -5
- package/dist/{chunk-NJBN3WXF.js → chunk-6QAXVFRJ.js} +1900 -179
- package/dist/{chunk-R6NDP7OF.js → chunk-ANMNGGTN.js} +2 -2
- package/dist/{chunk-PPZ56EVJ.js → chunk-B3ICJZXV.js} +4 -2
- package/dist/{chunk-5D2C6RCH.js → chunk-C357P37M.js} +4 -4
- package/dist/{chunk-DT7E3SD5.js → chunk-E57UVUJL.js} +6 -6
- package/dist/{chunk-KKUDAQQZ.js → chunk-EQWUCFXK.js} +3 -3
- package/dist/{chunk-JFWJN2ME.js → chunk-M6KIDB5R.js} +119 -5
- package/dist/{chunk-NBNQI3YJ.js → chunk-N6PZE7HX.js} +6 -3
- package/dist/{chunk-O73J3KQQ.js → chunk-NYDM4HSS.js} +8 -5
- package/dist/{chunk-74DQDWLW.js → chunk-P4O7L7JZ.js} +7 -2
- package/dist/{chunk-L32WYFJT.js → chunk-PRJ7P6J5.js} +135 -12
- package/dist/{chunk-ND6TYHNI.js → chunk-PTZ6BWSU.js} +2 -2
- package/dist/{chunk-BFYJLI7V.js → chunk-QQ3G5SXX.js} +1 -1
- package/dist/{chunk-EZXIKEMA.js → chunk-RDT2IV2Z.js} +9 -7
- package/dist/{chunk-TI37ME2D.js → chunk-VLT2KGPE.js} +47 -38
- package/dist/{chunk-YP4OXKNX.js → chunk-WEGZGF3K.js} +1 -1
- package/dist/{chunk-C5VBPHOS.js → chunk-XINFTNA2.js} +23 -9
- package/dist/{chunk-FYYHBOOM.js → chunk-ZCT23NBS.js} +2 -2
- package/dist/daemon/server.js +1976 -442
- package/dist/hook-runtime/daemon/server.js +1976 -442
- package/dist/hook-runtime/hooks/post-commit.js +592 -212
- package/dist/hook-runtime/hooks/post-rewrite.js +584 -204
- package/dist/hook-runtime/hooks/post-tool-use.js +1997 -575
- package/dist/hook-runtime/hooks/pre-commit.js +1742 -350
- package/dist/hook-runtime/hooks/pre-tool-use-worker.js +1656 -261
- package/dist/hook-runtime/hooks/prim-hook.js +1992 -573
- package/dist/hook-runtime/hooks/session-end.js +549 -180
- package/dist/hook-runtime/hooks/session-start.js +2213 -596
- package/dist/hook-runtime/index.js +5318 -2423
- package/dist/hook-runtime/statusline-main.js +531 -150
- package/dist/hooks/post-commit.js +7 -7
- package/dist/hooks/post-rewrite.js +6 -6
- package/dist/hooks/post-tool-use.js +18 -18
- package/dist/hooks/pre-commit.js +4 -4
- package/dist/hooks/pre-tool-use-worker.js +14 -15
- package/dist/hooks/prim-hook.js +16 -16
- package/dist/hooks/session-end.js +4 -4
- package/dist/hooks/session-start.js +95 -21
- package/dist/index.js +1386 -299
- package/dist/statusline-main.js +531 -150
- package/package.json +1 -1
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
recordPostCommitFired
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-QQ3G5SXX.js";
|
|
5
5
|
import {
|
|
6
6
|
unattendedEnv
|
|
7
7
|
} from "../chunk-OYHYCK4K.js";
|
|
8
8
|
import {
|
|
9
9
|
commitAttributionFromEnvironment,
|
|
10
10
|
toCommitMove
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-ZCT23NBS.js";
|
|
12
12
|
import {
|
|
13
13
|
getOrCreateWorkspaceId
|
|
14
14
|
} from "../chunk-EZXEWFDG.js";
|
|
15
15
|
import {
|
|
16
16
|
appendMove,
|
|
17
17
|
resolveOrg
|
|
18
|
-
} from "../chunk-
|
|
19
|
-
import "../chunk-
|
|
18
|
+
} from "../chunk-N6PZE7HX.js";
|
|
19
|
+
import "../chunk-P4O7L7JZ.js";
|
|
20
20
|
import {
|
|
21
21
|
cachedCollectScopeAdmits
|
|
22
|
-
} from "../chunk-
|
|
23
|
-
import "../chunk-
|
|
22
|
+
} from "../chunk-NYDM4HSS.js";
|
|
23
|
+
import "../chunk-3KPTVK4N.js";
|
|
24
24
|
import {
|
|
25
25
|
githubRepositoryFullName,
|
|
26
26
|
isRepoActiveForCapture,
|
|
27
27
|
repoSyncId,
|
|
28
28
|
resolveRepositoryContext
|
|
29
|
-
} from "../chunk-
|
|
29
|
+
} from "../chunk-6QAXVFRJ.js";
|
|
30
30
|
import "../chunk-JSBRDJBE.js";
|
|
31
31
|
|
|
32
32
|
// src/hooks/post-commit.ts
|
|
@@ -5,25 +5,25 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
canonicalRewritePairs,
|
|
7
7
|
toRewriteMove
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-ZCT23NBS.js";
|
|
9
9
|
import {
|
|
10
10
|
getOrCreateWorkspaceId
|
|
11
11
|
} from "../chunk-EZXEWFDG.js";
|
|
12
12
|
import {
|
|
13
13
|
appendMove,
|
|
14
14
|
resolveOrg
|
|
15
|
-
} from "../chunk-
|
|
16
|
-
import "../chunk-
|
|
15
|
+
} from "../chunk-N6PZE7HX.js";
|
|
16
|
+
import "../chunk-P4O7L7JZ.js";
|
|
17
17
|
import {
|
|
18
18
|
cachedCollectScopeAdmits
|
|
19
|
-
} from "../chunk-
|
|
20
|
-
import "../chunk-
|
|
19
|
+
} from "../chunk-NYDM4HSS.js";
|
|
20
|
+
import "../chunk-3KPTVK4N.js";
|
|
21
21
|
import {
|
|
22
22
|
githubRepositoryFullName,
|
|
23
23
|
isRepoActiveForCapture,
|
|
24
24
|
repoSyncId,
|
|
25
25
|
resolveRepositoryContext
|
|
26
|
-
} from "../chunk-
|
|
26
|
+
} from "../chunk-6QAXVFRJ.js";
|
|
27
27
|
import "../chunk-JSBRDJBE.js";
|
|
28
28
|
|
|
29
29
|
// src/hooks/post-rewrite.ts
|
|
@@ -4,58 +4,58 @@ import {
|
|
|
4
4
|
buildOrganizationBoundMoveRequest,
|
|
5
5
|
parseOrganizationBinding,
|
|
6
6
|
requireDurableIngestAcknowledgement
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-VLT2KGPE.js";
|
|
8
8
|
import {
|
|
9
9
|
enrichHookPayloadWithFileRefs,
|
|
10
10
|
preserveHookFileMetadata
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-C357P37M.js";
|
|
12
12
|
import {
|
|
13
13
|
appendCodexContext,
|
|
14
14
|
prepareCodexContext
|
|
15
|
-
} from "../chunk-
|
|
16
|
-
import "../chunk-
|
|
15
|
+
} from "../chunk-E57UVUJL.js";
|
|
16
|
+
import "../chunk-4DYEBYKM.js";
|
|
17
17
|
import {
|
|
18
18
|
postToolInvocationId,
|
|
19
19
|
toMove,
|
|
20
20
|
toolOutcomeFor
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-ZCT23NBS.js";
|
|
22
22
|
import {
|
|
23
23
|
getOrCreateWorkspaceId
|
|
24
24
|
} from "../chunk-EZXEWFDG.js";
|
|
25
25
|
import {
|
|
26
26
|
appendMove,
|
|
27
27
|
resolveOrg
|
|
28
|
-
} from "../chunk-
|
|
29
|
-
import "../chunk-
|
|
28
|
+
} from "../chunk-N6PZE7HX.js";
|
|
29
|
+
import "../chunk-WEGZGF3K.js";
|
|
30
30
|
import {
|
|
31
31
|
observeDemoInvocation
|
|
32
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-ANMNGGTN.js";
|
|
33
33
|
import {
|
|
34
34
|
normalizeEnvelope,
|
|
35
35
|
readHookStdin,
|
|
36
36
|
shouldSuppressImportedCursorHandler
|
|
37
|
-
} from "../chunk-
|
|
38
|
-
import "../chunk-
|
|
39
|
-
import "../chunk-
|
|
37
|
+
} from "../chunk-PTZ6BWSU.js";
|
|
38
|
+
import "../chunk-EQWUCFXK.js";
|
|
39
|
+
import "../chunk-PRJ7P6J5.js";
|
|
40
40
|
import {
|
|
41
41
|
scrubFromCwd
|
|
42
|
-
} from "../chunk-
|
|
42
|
+
} from "../chunk-P4O7L7JZ.js";
|
|
43
43
|
import {
|
|
44
44
|
bold,
|
|
45
45
|
cachedCollectScopeAdmits,
|
|
46
46
|
color
|
|
47
|
-
} from "../chunk-
|
|
47
|
+
} from "../chunk-NYDM4HSS.js";
|
|
48
48
|
import {
|
|
49
49
|
getClient,
|
|
50
|
-
getPinnedClient
|
|
51
|
-
|
|
52
|
-
} from "../chunk-ZKXNJB6U.js";
|
|
50
|
+
getPinnedClient
|
|
51
|
+
} from "../chunk-3KPTVK4N.js";
|
|
53
52
|
import {
|
|
54
53
|
currentBranch,
|
|
55
54
|
isRepoActiveForCapture,
|
|
56
55
|
repoSyncId,
|
|
57
|
-
resolveRepositoryContext
|
|
58
|
-
|
|
56
|
+
resolveRepositoryContext,
|
|
57
|
+
terminalSafeLine
|
|
58
|
+
} from "../chunk-6QAXVFRJ.js";
|
|
59
59
|
import {
|
|
60
60
|
parseAgent
|
|
61
61
|
} from "../chunk-KZB4ABIB.js";
|
package/dist/hooks/pre-commit.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
checkAffectedDecisions,
|
|
4
4
|
formatDecisionsWarning
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-RDT2IV2Z.js";
|
|
6
|
+
import "../chunk-WEGZGF3K.js";
|
|
7
|
+
import "../chunk-3KPTVK4N.js";
|
|
8
|
+
import "../chunk-6QAXVFRJ.js";
|
|
9
9
|
import "../chunk-JSBRDJBE.js";
|
|
10
10
|
|
|
11
11
|
// src/hooks/pre-commit.ts
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
PREFLIGHT_PROTOCOL_VERSION,
|
|
4
4
|
PREFLIGHT_TIMEOUT_MS,
|
|
5
5
|
boundedClientVersion,
|
|
6
|
+
coverageNote,
|
|
6
7
|
editPreview,
|
|
7
8
|
hasConfirmedConflict,
|
|
8
9
|
proposalFor,
|
|
@@ -14,15 +15,15 @@ import {
|
|
|
14
15
|
toolInputDigest,
|
|
15
16
|
unverifiedResult,
|
|
16
17
|
waitForPreflight
|
|
17
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-XINFTNA2.js";
|
|
18
19
|
import {
|
|
19
20
|
observeDemoInvocation
|
|
20
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-ANMNGGTN.js";
|
|
21
22
|
import {
|
|
22
23
|
normalizeEnvelope,
|
|
23
24
|
readHookStdin,
|
|
24
25
|
shouldSuppressImportedCursorHandler
|
|
25
|
-
} from "../chunk-
|
|
26
|
+
} from "../chunk-PTZ6BWSU.js";
|
|
26
27
|
import {
|
|
27
28
|
buildCodexOutput,
|
|
28
29
|
buildCursorOutput,
|
|
@@ -34,21 +35,22 @@ import {
|
|
|
34
35
|
failOpenHermes,
|
|
35
36
|
failOpenOutput,
|
|
36
37
|
readHookMode
|
|
37
|
-
} from "../chunk-
|
|
38
|
-
import "../chunk-
|
|
39
|
-
import "../chunk-
|
|
38
|
+
} from "../chunk-EQWUCFXK.js";
|
|
39
|
+
import "../chunk-PRJ7P6J5.js";
|
|
40
|
+
import "../chunk-P4O7L7JZ.js";
|
|
40
41
|
import {
|
|
41
42
|
cachedCollectScopeAdmits
|
|
42
|
-
} from "../chunk-
|
|
43
|
-
import "../chunk-
|
|
43
|
+
} from "../chunk-NYDM4HSS.js";
|
|
44
|
+
import "../chunk-3KPTVK4N.js";
|
|
44
45
|
import {
|
|
45
46
|
canonicalGitRoot,
|
|
47
|
+
cloudSetupPointer,
|
|
46
48
|
currentBranch,
|
|
47
49
|
githubRepositoryFullName,
|
|
48
50
|
packageVersion,
|
|
49
51
|
repoActiveFlag,
|
|
50
52
|
repoSyncId
|
|
51
|
-
} from "../chunk-
|
|
53
|
+
} from "../chunk-6QAXVFRJ.js";
|
|
52
54
|
import {
|
|
53
55
|
parseAgent
|
|
54
56
|
} from "../chunk-KZB4ABIB.js";
|
|
@@ -186,7 +188,7 @@ async function main() {
|
|
|
186
188
|
const callId = invocationId(envelope);
|
|
187
189
|
if (!binding || typeof sessionId !== "string" || !sessionId || !callId) {
|
|
188
190
|
await unverified(
|
|
189
|
-
!binding ? "GitHub repo connection is required" : "Session or tool identity is missing"
|
|
191
|
+
!binding ? cloudSetupPointer("GitHub repo connection is required") : "Session or tool identity is missing"
|
|
190
192
|
);
|
|
191
193
|
return;
|
|
192
194
|
}
|
|
@@ -236,15 +238,12 @@ async function main() {
|
|
|
236
238
|
if (result2.verdict === "unavailable") {
|
|
237
239
|
result2.unavailable = `${result2.unavailable || "Decision check is unavailable"}; change was not verified.`;
|
|
238
240
|
}
|
|
239
|
-
const coverage = response.evaluationCoverage;
|
|
240
241
|
const notes = [
|
|
241
242
|
...targets.coverage === "unverified" ? [
|
|
242
243
|
"[primitive] Some mutation targets could not be resolved; the complete change was not verified."
|
|
243
244
|
] : [],
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
] : []
|
|
247
|
-
];
|
|
245
|
+
coverageNote(response)
|
|
246
|
+
].filter(Boolean);
|
|
248
247
|
if (notes.length > 0) {
|
|
249
248
|
const note = notes.join("\n");
|
|
250
249
|
result2.reason = [result2.reason, note].filter(Boolean).join("\n");
|
package/dist/hooks/prim-hook.js
CHANGED
|
@@ -8,58 +8,58 @@ import {
|
|
|
8
8
|
acknowledgeDecisionFeedback,
|
|
9
9
|
leaseDecisionFeedback,
|
|
10
10
|
renderFeedback
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-B3ICJZXV.js";
|
|
12
12
|
import {
|
|
13
13
|
recordConversationCaptured
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-QQ3G5SXX.js";
|
|
15
15
|
import {
|
|
16
16
|
unattendedEnv
|
|
17
17
|
} from "../chunk-OYHYCK4K.js";
|
|
18
18
|
import {
|
|
19
19
|
enrichHookPayloadWithFileRefs,
|
|
20
20
|
preserveHookFileMetadata
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-C357P37M.js";
|
|
22
22
|
import {
|
|
23
23
|
prepareCodexContext
|
|
24
|
-
} from "../chunk-
|
|
25
|
-
import "../chunk-
|
|
24
|
+
} from "../chunk-E57UVUJL.js";
|
|
25
|
+
import "../chunk-4DYEBYKM.js";
|
|
26
26
|
import {
|
|
27
27
|
postToolInvocationId,
|
|
28
28
|
shouldFlushAfter,
|
|
29
29
|
toMove
|
|
30
|
-
} from "../chunk-
|
|
30
|
+
} from "../chunk-ZCT23NBS.js";
|
|
31
31
|
import {
|
|
32
32
|
getOrCreateWorkspaceId
|
|
33
33
|
} from "../chunk-EZXEWFDG.js";
|
|
34
34
|
import {
|
|
35
35
|
appendMove,
|
|
36
36
|
resolveOrg
|
|
37
|
-
} from "../chunk-
|
|
38
|
-
import "../chunk-
|
|
37
|
+
} from "../chunk-N6PZE7HX.js";
|
|
38
|
+
import "../chunk-WEGZGF3K.js";
|
|
39
39
|
import {
|
|
40
40
|
observeDemoInvocation
|
|
41
|
-
} from "../chunk-
|
|
41
|
+
} from "../chunk-ANMNGGTN.js";
|
|
42
42
|
import {
|
|
43
43
|
normalizeEnvelope,
|
|
44
44
|
readHookStdin,
|
|
45
45
|
shouldSuppressImportedCursorHandler
|
|
46
|
-
} from "../chunk-
|
|
47
|
-
import "../chunk-
|
|
48
|
-
import "../chunk-
|
|
46
|
+
} from "../chunk-PTZ6BWSU.js";
|
|
47
|
+
import "../chunk-EQWUCFXK.js";
|
|
48
|
+
import "../chunk-PRJ7P6J5.js";
|
|
49
49
|
import {
|
|
50
50
|
scrubFromCwd,
|
|
51
51
|
writeHookDebug
|
|
52
|
-
} from "../chunk-
|
|
52
|
+
} from "../chunk-P4O7L7JZ.js";
|
|
53
53
|
import {
|
|
54
54
|
cachedCollectScopeAdmits
|
|
55
|
-
} from "../chunk-
|
|
56
|
-
import "../chunk-
|
|
55
|
+
} from "../chunk-NYDM4HSS.js";
|
|
56
|
+
import "../chunk-3KPTVK4N.js";
|
|
57
57
|
import {
|
|
58
58
|
currentBranch,
|
|
59
59
|
isRepoActiveForCapture,
|
|
60
60
|
repoSyncId,
|
|
61
61
|
resolveRepositoryContext
|
|
62
|
-
} from "../chunk-
|
|
62
|
+
} from "../chunk-6QAXVFRJ.js";
|
|
63
63
|
import {
|
|
64
64
|
parseAgent
|
|
65
65
|
} from "../chunk-KZB4ABIB.js";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
daemonRequest
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-WEGZGF3K.js";
|
|
5
5
|
import {
|
|
6
6
|
normalizeEnvelope,
|
|
7
7
|
readHookStdin,
|
|
8
8
|
shouldSuppressImportedCursorHandler
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-PTZ6BWSU.js";
|
|
10
|
+
import "../chunk-PRJ7P6J5.js";
|
|
11
11
|
import {
|
|
12
12
|
isRepoActiveForCapture
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-6QAXVFRJ.js";
|
|
14
14
|
import {
|
|
15
15
|
parseAgent
|
|
16
16
|
} from "../chunk-KZB4ABIB.js";
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
bindRepository,
|
|
4
|
+
diagnoseCloudSession,
|
|
4
5
|
ensureEffectiveGitHook,
|
|
5
6
|
hasUsableCodexGuidance,
|
|
6
7
|
hasUsableCursorSkill,
|
|
7
8
|
kickDaemonEnsure,
|
|
8
9
|
refreshClaudePlugins,
|
|
9
10
|
warmBinCache
|
|
10
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-M6KIDB5R.js";
|
|
11
12
|
import {
|
|
12
13
|
buildHookOutput,
|
|
13
14
|
handoffHookOutput
|
|
@@ -17,62 +18,99 @@ import {
|
|
|
17
18
|
acknowledgeDecisionFeedback,
|
|
18
19
|
leaseDecisionFeedback,
|
|
19
20
|
renderFeedback
|
|
20
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-B3ICJZXV.js";
|
|
21
22
|
import {
|
|
22
23
|
clearHooksWired,
|
|
23
24
|
recordHooksWired
|
|
24
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-QQ3G5SXX.js";
|
|
25
26
|
import "../chunk-OYHYCK4K.js";
|
|
26
27
|
import {
|
|
27
28
|
prepareCodexContext
|
|
28
|
-
} from "../chunk-
|
|
29
|
-
import "../chunk-
|
|
29
|
+
} from "../chunk-E57UVUJL.js";
|
|
30
|
+
import "../chunk-4DYEBYKM.js";
|
|
30
31
|
import {
|
|
31
32
|
getOrCreateWorkspaceId
|
|
32
33
|
} from "../chunk-EZXEWFDG.js";
|
|
33
34
|
import {
|
|
34
35
|
daemonRequest
|
|
35
|
-
} from "../chunk-
|
|
36
|
+
} from "../chunk-WEGZGF3K.js";
|
|
36
37
|
import {
|
|
37
38
|
normalizeEnvelope,
|
|
38
39
|
readHookStdin,
|
|
39
40
|
shouldSuppressImportedCursorHandler
|
|
40
|
-
} from "../chunk-
|
|
41
|
+
} from "../chunk-PTZ6BWSU.js";
|
|
41
42
|
import {
|
|
42
43
|
MANAGED_GIT_HOOK_NAMES
|
|
43
|
-
} from "../chunk-
|
|
44
|
+
} from "../chunk-PRJ7P6J5.js";
|
|
44
45
|
import {
|
|
45
46
|
fetchAndCacheCollectScope
|
|
46
|
-
} from "../chunk-
|
|
47
|
+
} from "../chunk-NYDM4HSS.js";
|
|
47
48
|
import {
|
|
48
49
|
getSiteUrl,
|
|
49
50
|
isSessionEnded
|
|
50
|
-
} from "../chunk-
|
|
51
|
+
} from "../chunk-3KPTVK4N.js";
|
|
51
52
|
import {
|
|
53
|
+
CLOUD_CREDENTIALS_REMEDY,
|
|
54
|
+
CLOUD_REJECTED_CREDENTIALS_NOTICE,
|
|
55
|
+
ENVIRONMENT_CREDENTIAL_REMEDY,
|
|
56
|
+
ensureSessionIdentity,
|
|
52
57
|
gitToplevel,
|
|
53
58
|
hasMachineConfiguration,
|
|
59
|
+
isClaudeCloudSession,
|
|
54
60
|
isRepoActiveForCapture,
|
|
61
|
+
markActivationImplicit,
|
|
55
62
|
repoActiveFlag,
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
sessionIdentityMessage,
|
|
64
|
+
sessionIdentityMode,
|
|
65
|
+
setRepoActive,
|
|
66
|
+
withdrawImplicitActivation
|
|
67
|
+
} from "../chunk-6QAXVFRJ.js";
|
|
58
68
|
import {
|
|
59
69
|
parseAgent
|
|
60
70
|
} from "../chunk-KZB4ABIB.js";
|
|
61
71
|
import "../chunk-JSBRDJBE.js";
|
|
62
72
|
|
|
63
73
|
// src/hooks/reauth-notice.ts
|
|
74
|
+
function sharedEnvironment() {
|
|
75
|
+
try {
|
|
76
|
+
return sessionIdentityMode();
|
|
77
|
+
} catch {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
64
81
|
var REAUTH_NOTICE = "[prim] authentication ended \u2014 run `prim auth login` to resume decision capture";
|
|
65
82
|
function reauthNoticeFields(agent) {
|
|
66
|
-
if (agent === "claude_code")
|
|
83
|
+
if (agent === "claude_code") {
|
|
84
|
+
if (isClaudeCloudSession()) {
|
|
85
|
+
const notice = !hasMachineConfiguration() ? `Primitive is not connected in this Claude Code cloud session: its sign-in ended. To fix it, ${CLOUD_CREDENTIALS_REMEDY}.` : sharedEnvironment() ? `Primitive is not connected in this Claude Code cloud session: its environment credential was rejected. To fix it, ${ENVIRONMENT_CREDENTIAL_REMEDY}.` : CLOUD_REJECTED_CREDENTIALS_NOTICE;
|
|
86
|
+
return {
|
|
87
|
+
systemMessage: notice,
|
|
88
|
+
additionalContext: `${notice} Tell the user this in one sentence before starting their task.`
|
|
89
|
+
};
|
|
90
|
+
}
|
|
67
91
|
return {
|
|
68
92
|
systemMessage: hasMachineConfiguration() ? "[prim] machine delivery paused; local capture remains saved. Run `prim auth status` and ask your administrator to enable or rotate machine credentials." : REAUTH_NOTICE
|
|
69
93
|
};
|
|
94
|
+
}
|
|
70
95
|
return;
|
|
71
96
|
}
|
|
72
97
|
|
|
73
98
|
// src/hooks/session-start-core.ts
|
|
74
99
|
var DAEMON_TIMEOUT_MS = 250;
|
|
75
100
|
var REPOSITORY_BIND_TIMEOUT_MS = 1e3;
|
|
101
|
+
var CLOUD_REPOSITORY_BIND_TIMEOUT_MS = 1e4;
|
|
102
|
+
var SESSION_IDENTITY_TIMEOUT_MS = 35e3;
|
|
103
|
+
function sessionIdentityNotice(outcome) {
|
|
104
|
+
if (!outcome || outcome.status === "ok") return void 0;
|
|
105
|
+
const notice = `${sessionIdentityMessage(outcome)} Until then, nothing this session captures is sent to Primitive.`;
|
|
106
|
+
return outcome.status === "link_required" ? {
|
|
107
|
+
notice,
|
|
108
|
+
instruction: `${notice} Before starting their task, tell the user this in one sentence. When they agree, run \`prim auth link\` as a background command (it waits until they finish signing in), and give them the sign-in URL and code it prints as soon as they appear.`
|
|
109
|
+
} : {
|
|
110
|
+
notice,
|
|
111
|
+
instruction: `${notice} Tell the user this in one sentence before starting their task.`
|
|
112
|
+
};
|
|
113
|
+
}
|
|
76
114
|
var PRIM_TRIGGER = "When this task chooses between plausible approaches or establishes or changes a lasting goal, priority, constraint, invariant, default, commitment, tradeoff, exception, or shared instruction";
|
|
77
115
|
var PRIM_EXCLUSIONS = "Never invoke `prim` for routine implementation that merely follows an existing decision made before this task or for temporary tactics; they never qualify, including for evaluation.";
|
|
78
116
|
function primReminder(action, rationaleAction) {
|
|
@@ -93,6 +131,7 @@ async function activeProjectRoot(cwd) {
|
|
|
93
131
|
if (!shellGateActive) {
|
|
94
132
|
try {
|
|
95
133
|
setRepoActive(root, true);
|
|
134
|
+
markActivationImplicit(root);
|
|
96
135
|
shellGateActive = true;
|
|
97
136
|
} catch {
|
|
98
137
|
}
|
|
@@ -114,7 +153,9 @@ async function activeProjectRoot(cwd) {
|
|
|
114
153
|
}
|
|
115
154
|
try {
|
|
116
155
|
const binding = await bindRepository(root, {
|
|
117
|
-
signal: AbortSignal.timeout(
|
|
156
|
+
signal: AbortSignal.timeout(
|
|
157
|
+
isClaudeCloudSession() ? CLOUD_REPOSITORY_BIND_TIMEOUT_MS : REPOSITORY_BIND_TIMEOUT_MS
|
|
158
|
+
),
|
|
118
159
|
quietRefresh: true
|
|
119
160
|
});
|
|
120
161
|
try {
|
|
@@ -122,14 +163,16 @@ async function activeProjectRoot(cwd) {
|
|
|
122
163
|
} catch {
|
|
123
164
|
}
|
|
124
165
|
return { root, binding };
|
|
125
|
-
} catch {
|
|
166
|
+
} catch (error) {
|
|
167
|
+
return { root, bindFailure: error };
|
|
126
168
|
}
|
|
127
|
-
return { root };
|
|
128
169
|
} catch {
|
|
129
170
|
return null;
|
|
130
171
|
}
|
|
131
172
|
}
|
|
132
|
-
function claudeBindingReminder(binding) {
|
|
173
|
+
function claudeBindingReminder(binding, cloud = false) {
|
|
174
|
+
if (cloud && binding.status !== "connected")
|
|
175
|
+
return `GitHub repo connection is required before Primitive can attribute work in ${binding.repositoryFullName}, and it cannot be completed from this Claude Code cloud session. Before doing task work, tell the user exactly: "Primitive needs a one-time GitHub connection for ${binding.repositoryFullName}. Run \`prim github connect\` in a clone of it on your own machine, then start a new cloud session." Then continue the user's request.`;
|
|
133
176
|
if (binding.status === "connected") {
|
|
134
177
|
return `The GitHub repo connection is complete for ${binding.repositoryFullName}. It enables repository-specific file attribution, Conflict Gate verification, and commit correlation. In your first response, begin with exactly: "GitHub repo connection is complete for ${binding.repositoryFullName}. It enables repository-specific file attribution, Conflict Gate verification, and commit correlation." Then continue the user's request.`;
|
|
135
178
|
}
|
|
@@ -153,6 +196,7 @@ async function processSessionStart(raw, agent, feedbackSignal) {
|
|
|
153
196
|
return { output: buildHookOutput({}) };
|
|
154
197
|
}
|
|
155
198
|
const cwd = envelope.cwd ?? process.cwd();
|
|
199
|
+
withdrawImplicitActivation(cwd);
|
|
156
200
|
if (!gitToplevel(cwd) || !isRepoActiveForCapture(cwd)) {
|
|
157
201
|
if (repoActiveFlag(cwd) === "false") clearHooksWired(cwd);
|
|
158
202
|
return { output: agent === "cursor" ? {} : buildHookOutput({}) };
|
|
@@ -168,11 +212,31 @@ async function processSessionStart(raw, agent, feedbackSignal) {
|
|
|
168
212
|
let active = false;
|
|
169
213
|
let skillState = { installed: 0, refreshed: 0 };
|
|
170
214
|
let claudeBinding;
|
|
215
|
+
let bindFailure;
|
|
216
|
+
let identityNotice;
|
|
171
217
|
if (agent === "claude_code") {
|
|
218
|
+
let identityMode = false;
|
|
219
|
+
try {
|
|
220
|
+
identityMode = sessionIdentityMode();
|
|
221
|
+
} catch {
|
|
222
|
+
}
|
|
223
|
+
if (identityMode) {
|
|
224
|
+
try {
|
|
225
|
+
identityNotice = sessionIdentityNotice(
|
|
226
|
+
await ensureSessionIdentity({
|
|
227
|
+
cwd,
|
|
228
|
+
explicit: true,
|
|
229
|
+
signal: AbortSignal.timeout(SESSION_IDENTITY_TIMEOUT_MS)
|
|
230
|
+
})
|
|
231
|
+
);
|
|
232
|
+
} catch {
|
|
233
|
+
}
|
|
234
|
+
}
|
|
172
235
|
const activeProject = await activeProjectRoot(cwd);
|
|
173
236
|
projectRoot = activeProject?.root ?? null;
|
|
174
237
|
active = projectRoot !== null;
|
|
175
238
|
claudeBinding = activeProject?.binding;
|
|
239
|
+
bindFailure = activeProject?.bindFailure;
|
|
176
240
|
try {
|
|
177
241
|
skillState = await refreshClaudePlugins(
|
|
178
242
|
cwd,
|
|
@@ -181,7 +245,7 @@ async function processSessionStart(raw, agent, feedbackSignal) {
|
|
|
181
245
|
} catch {
|
|
182
246
|
}
|
|
183
247
|
}
|
|
184
|
-
if (isSessionEnded() && agent !== "codex" && agent !== "cursor") {
|
|
248
|
+
if (isSessionEnded() && agent !== "codex" && agent !== "cursor" && !identityNotice) {
|
|
185
249
|
const notice = reauthNoticeFields(agent);
|
|
186
250
|
if (notice) {
|
|
187
251
|
return {
|
|
@@ -244,8 +308,16 @@ async function processSessionStart(raw, agent, feedbackSignal) {
|
|
|
244
308
|
};
|
|
245
309
|
}
|
|
246
310
|
if (agent === "claude_code") {
|
|
311
|
+
let cloudNotice = identityNotice?.notice;
|
|
312
|
+
if (active && !claudeBinding && isClaudeCloudSession() && !identityNotice) {
|
|
313
|
+
try {
|
|
314
|
+
cloudNotice = await diagnoseCloudSession({ cwd: projectRoot ?? cwd, bindFailure });
|
|
315
|
+
} catch {
|
|
316
|
+
}
|
|
317
|
+
}
|
|
247
318
|
const additionalContext = [
|
|
248
|
-
|
|
319
|
+
identityNotice ? identityNotice.instruction : cloudNotice ? `${cloudNotice} Tell the user this in one sentence before starting their task.` : void 0,
|
|
320
|
+
claudeBinding ? claudeBindingReminder(claudeBinding, isClaudeCloudSession()) : void 0,
|
|
249
321
|
active && skillState.installed > 0 ? PRIM_SKILL_REMINDER : void 0
|
|
250
322
|
].filter((value) => value !== void 0).join("\n\n");
|
|
251
323
|
const reloadSkills = skillState.refreshed > 0;
|
|
@@ -261,7 +333,7 @@ async function processSessionStart(raw, agent, feedbackSignal) {
|
|
|
261
333
|
const rendered = lease ? renderFeedback(lease) : void 0;
|
|
262
334
|
return {
|
|
263
335
|
output: buildHookOutput({
|
|
264
|
-
systemMessage: rendered?.systemMessage,
|
|
336
|
+
systemMessage: [cloudNotice, rendered?.systemMessage].filter(Boolean).join("\n\n") || void 0,
|
|
265
337
|
additionalContext,
|
|
266
338
|
reloadSkills
|
|
267
339
|
}),
|
|
@@ -276,7 +348,9 @@ async function processSessionStart(raw, agent, feedbackSignal) {
|
|
|
276
348
|
};
|
|
277
349
|
}
|
|
278
350
|
}
|
|
279
|
-
return {
|
|
351
|
+
return {
|
|
352
|
+
output: buildHookOutput({ systemMessage: cloudNotice, additionalContext, reloadSkills })
|
|
353
|
+
};
|
|
280
354
|
}
|
|
281
355
|
await activeProjectRoot(cwd);
|
|
282
356
|
return { output: buildHookOutput({}) };
|