@primitive.ai/prim 0.1.0-alpha.127 → 0.1.0-alpha.129
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 +76 -5
- package/dist/{chunk-HZI5PBN4.js → chunk-BVGASV3B.js} +2047 -138
- package/dist/{chunk-72NIZMZN.js → chunk-DYXCJ6WZ.js} +15 -10
- package/dist/{chunk-TNWI3JWK.js → chunk-FHDTJP2C.js} +4 -2
- package/dist/{chunk-C4QNBSWB.js → chunk-HDL3UXYJ.js} +8 -8
- package/dist/{chunk-RV3JFSMX.js → chunk-IJ3W2YBM.js} +4 -4
- package/dist/{chunk-O65UVJZH.js → chunk-IZAEAALI.js} +2 -2
- package/dist/{chunk-H74RDXKP.js → chunk-KZNOT2YH.js} +2 -2
- package/dist/{chunk-R4EYLEIK.js → chunk-L7U3G4XR.js} +2 -2
- package/dist/{chunk-MGKSZSTV.js → chunk-LBZJD2I4.js} +3 -5
- package/dist/{chunk-UUQT5GMO.js → chunk-MMMY57UA.js} +22 -837
- package/dist/{chunk-H6X52UVF.js → chunk-NWWTFQP2.js} +1 -1
- package/dist/{chunk-WGTUNUIS.js → chunk-QSDWWEHF.js} +5 -5
- package/dist/{chunk-NVDPKW7Z.js → chunk-RAEOSDQ6.js} +3 -51
- package/dist/{chunk-KFRGVHGB.js → chunk-RS5ADTDF.js} +6 -6
- package/dist/{chunk-A5VTE43F.js → chunk-RWJ7WHTJ.js} +2 -2
- package/dist/{chunk-VVFVENU4.js → chunk-SJE7OWVS.js} +6 -6
- package/dist/{chunk-L6IL4N6Y.js → chunk-USJ4JGDC.js} +34 -34
- package/dist/{chunk-JCKOW45X.js → chunk-YPHDV5AS.js} +2 -2
- package/dist/{chunk-F3FDVHR7.js → chunk-YSV43WLK.js} +1 -1
- package/dist/{chunk-URYZDQFH.js → chunk-ZKIBD5MO.js} +3 -5
- package/dist/daemon/server.js +1769 -487
- package/dist/hook-runtime/daemon/server.js +1769 -487
- package/dist/hook-runtime/hooks/post-commit.js +611 -337
- package/dist/hook-runtime/hooks/post-rewrite.js +606 -332
- package/dist/hook-runtime/hooks/post-tool-use.js +1841 -683
- package/dist/hook-runtime/hooks/pre-commit.js +1713 -434
- package/dist/hook-runtime/hooks/pre-tool-use-worker.js +1308 -150
- package/dist/hook-runtime/hooks/prim-hook.js +1863 -705
- package/dist/hook-runtime/hooks/session-end.js +538 -385
- package/dist/hook-runtime/hooks/session-start.js +1379 -233
- package/dist/hook-runtime/index.js +5438 -4052
- package/dist/hook-runtime/statusline-main.js +547 -273
- 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 +9 -9
- package/dist/hooks/prim-hook.js +16 -16
- package/dist/hooks/session-end.js +4 -4
- package/dist/hooks/session-start.js +64 -22
- package/dist/index.js +396 -52
- package/dist/statusline-main.js +547 -273
- 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-YSV43WLK.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-YPHDV5AS.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-IZAEAALI.js";
|
|
19
|
+
import "../chunk-L7U3G4XR.js";
|
|
20
20
|
import {
|
|
21
21
|
cachedCollectScopeAdmits
|
|
22
|
-
} from "../chunk-
|
|
23
|
-
import "../chunk-
|
|
22
|
+
} from "../chunk-QSDWWEHF.js";
|
|
23
|
+
import "../chunk-RAEOSDQ6.js";
|
|
24
24
|
import {
|
|
25
25
|
githubRepositoryFullName,
|
|
26
26
|
isRepoActiveForCapture,
|
|
27
27
|
repoSyncId,
|
|
28
28
|
resolveRepositoryContext
|
|
29
|
-
} from "../chunk-
|
|
29
|
+
} from "../chunk-BVGASV3B.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-YPHDV5AS.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-IZAEAALI.js";
|
|
16
|
+
import "../chunk-L7U3G4XR.js";
|
|
17
17
|
import {
|
|
18
18
|
cachedCollectScopeAdmits
|
|
19
|
-
} from "../chunk-
|
|
20
|
-
import "../chunk-
|
|
19
|
+
} from "../chunk-QSDWWEHF.js";
|
|
20
|
+
import "../chunk-RAEOSDQ6.js";
|
|
21
21
|
import {
|
|
22
22
|
githubRepositoryFullName,
|
|
23
23
|
isRepoActiveForCapture,
|
|
24
24
|
repoSyncId,
|
|
25
25
|
resolveRepositoryContext
|
|
26
|
-
} from "../chunk-
|
|
26
|
+
} from "../chunk-BVGASV3B.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-USJ4JGDC.js";
|
|
8
8
|
import {
|
|
9
9
|
enrichHookPayloadWithFileRefs,
|
|
10
10
|
preserveHookFileMetadata
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-IJ3W2YBM.js";
|
|
12
12
|
import {
|
|
13
13
|
appendCodexContext,
|
|
14
14
|
prepareCodexContext
|
|
15
|
-
} from "../chunk-
|
|
16
|
-
import "../chunk-
|
|
15
|
+
} from "../chunk-RS5ADTDF.js";
|
|
16
|
+
import "../chunk-ZKIBD5MO.js";
|
|
17
17
|
import {
|
|
18
18
|
postToolInvocationId,
|
|
19
19
|
toMove,
|
|
20
20
|
toolOutcomeFor
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-YPHDV5AS.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-IZAEAALI.js";
|
|
29
|
+
import "../chunk-NWWTFQP2.js";
|
|
30
30
|
import {
|
|
31
31
|
observeDemoInvocation
|
|
32
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-RWJ7WHTJ.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-KZNOT2YH.js";
|
|
38
|
+
import "../chunk-LBZJD2I4.js";
|
|
39
|
+
import "../chunk-MMMY57UA.js";
|
|
40
40
|
import {
|
|
41
41
|
scrubFromCwd
|
|
42
|
-
} from "../chunk-
|
|
42
|
+
} from "../chunk-L7U3G4XR.js";
|
|
43
43
|
import {
|
|
44
44
|
bold,
|
|
45
45
|
cachedCollectScopeAdmits,
|
|
46
46
|
color
|
|
47
|
-
} from "../chunk-
|
|
47
|
+
} from "../chunk-QSDWWEHF.js";
|
|
48
48
|
import {
|
|
49
49
|
getClient,
|
|
50
|
-
getPinnedClient
|
|
51
|
-
|
|
52
|
-
} from "../chunk-NVDPKW7Z.js";
|
|
50
|
+
getPinnedClient
|
|
51
|
+
} from "../chunk-RAEOSDQ6.js";
|
|
53
52
|
import {
|
|
54
53
|
currentBranch,
|
|
55
54
|
isRepoActiveForCapture,
|
|
56
55
|
repoSyncId,
|
|
57
|
-
resolveRepositoryContext
|
|
58
|
-
|
|
56
|
+
resolveRepositoryContext,
|
|
57
|
+
terminalSafeLine
|
|
58
|
+
} from "../chunk-BVGASV3B.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-SJE7OWVS.js";
|
|
6
|
+
import "../chunk-NWWTFQP2.js";
|
|
7
|
+
import "../chunk-RAEOSDQ6.js";
|
|
8
|
+
import "../chunk-BVGASV3B.js";
|
|
9
9
|
import "../chunk-JSBRDJBE.js";
|
|
10
10
|
|
|
11
11
|
// src/hooks/pre-commit.ts
|
|
@@ -15,15 +15,15 @@ import {
|
|
|
15
15
|
toolInputDigest,
|
|
16
16
|
unverifiedResult,
|
|
17
17
|
waitForPreflight
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-HDL3UXYJ.js";
|
|
19
19
|
import {
|
|
20
20
|
observeDemoInvocation
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-RWJ7WHTJ.js";
|
|
22
22
|
import {
|
|
23
23
|
normalizeEnvelope,
|
|
24
24
|
readHookStdin,
|
|
25
25
|
shouldSuppressImportedCursorHandler
|
|
26
|
-
} from "../chunk-
|
|
26
|
+
} from "../chunk-KZNOT2YH.js";
|
|
27
27
|
import {
|
|
28
28
|
buildCodexOutput,
|
|
29
29
|
buildCursorOutput,
|
|
@@ -35,13 +35,13 @@ import {
|
|
|
35
35
|
failOpenHermes,
|
|
36
36
|
failOpenOutput,
|
|
37
37
|
readHookMode
|
|
38
|
-
} from "../chunk-
|
|
39
|
-
import "../chunk-
|
|
40
|
-
import "../chunk-
|
|
38
|
+
} from "../chunk-LBZJD2I4.js";
|
|
39
|
+
import "../chunk-MMMY57UA.js";
|
|
40
|
+
import "../chunk-L7U3G4XR.js";
|
|
41
41
|
import {
|
|
42
42
|
cachedCollectScopeAdmits
|
|
43
|
-
} from "../chunk-
|
|
44
|
-
import "../chunk-
|
|
43
|
+
} from "../chunk-QSDWWEHF.js";
|
|
44
|
+
import "../chunk-RAEOSDQ6.js";
|
|
45
45
|
import {
|
|
46
46
|
canonicalGitRoot,
|
|
47
47
|
cloudSetupPointer,
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
packageVersion,
|
|
51
51
|
repoActiveFlag,
|
|
52
52
|
repoSyncId
|
|
53
|
-
} from "../chunk-
|
|
53
|
+
} from "../chunk-BVGASV3B.js";
|
|
54
54
|
import {
|
|
55
55
|
parseAgent
|
|
56
56
|
} from "../chunk-KZB4ABIB.js";
|
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-FHDTJP2C.js";
|
|
12
12
|
import {
|
|
13
13
|
recordConversationCaptured
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-YSV43WLK.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-IJ3W2YBM.js";
|
|
22
22
|
import {
|
|
23
23
|
prepareCodexContext
|
|
24
|
-
} from "../chunk-
|
|
25
|
-
import "../chunk-
|
|
24
|
+
} from "../chunk-RS5ADTDF.js";
|
|
25
|
+
import "../chunk-ZKIBD5MO.js";
|
|
26
26
|
import {
|
|
27
27
|
postToolInvocationId,
|
|
28
28
|
shouldFlushAfter,
|
|
29
29
|
toMove
|
|
30
|
-
} from "../chunk-
|
|
30
|
+
} from "../chunk-YPHDV5AS.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-IZAEAALI.js";
|
|
38
|
+
import "../chunk-NWWTFQP2.js";
|
|
39
39
|
import {
|
|
40
40
|
observeDemoInvocation
|
|
41
|
-
} from "../chunk-
|
|
41
|
+
} from "../chunk-RWJ7WHTJ.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-KZNOT2YH.js";
|
|
47
|
+
import "../chunk-LBZJD2I4.js";
|
|
48
|
+
import "../chunk-MMMY57UA.js";
|
|
49
49
|
import {
|
|
50
50
|
scrubFromCwd,
|
|
51
51
|
writeHookDebug
|
|
52
|
-
} from "../chunk-
|
|
52
|
+
} from "../chunk-L7U3G4XR.js";
|
|
53
53
|
import {
|
|
54
54
|
cachedCollectScopeAdmits
|
|
55
|
-
} from "../chunk-
|
|
56
|
-
import "../chunk-
|
|
55
|
+
} from "../chunk-QSDWWEHF.js";
|
|
56
|
+
import "../chunk-RAEOSDQ6.js";
|
|
57
57
|
import {
|
|
58
58
|
currentBranch,
|
|
59
59
|
isRepoActiveForCapture,
|
|
60
60
|
repoSyncId,
|
|
61
61
|
resolveRepositoryContext
|
|
62
|
-
} from "../chunk-
|
|
62
|
+
} from "../chunk-BVGASV3B.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-NWWTFQP2.js";
|
|
5
5
|
import {
|
|
6
6
|
normalizeEnvelope,
|
|
7
7
|
readHookStdin,
|
|
8
8
|
shouldSuppressImportedCursorHandler
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-KZNOT2YH.js";
|
|
10
|
+
import "../chunk-MMMY57UA.js";
|
|
11
11
|
import {
|
|
12
12
|
isRepoActiveForCapture
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-BVGASV3B.js";
|
|
14
14
|
import {
|
|
15
15
|
parseAgent
|
|
16
16
|
} from "../chunk-KZB4ABIB.js";
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
kickDaemonEnsure,
|
|
9
9
|
refreshClaudePlugins,
|
|
10
10
|
warmBinCache
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-DYXCJ6WZ.js";
|
|
12
12
|
import {
|
|
13
13
|
buildHookOutput,
|
|
14
14
|
handoffHookOutput
|
|
@@ -18,60 +18,70 @@ import {
|
|
|
18
18
|
acknowledgeDecisionFeedback,
|
|
19
19
|
leaseDecisionFeedback,
|
|
20
20
|
renderFeedback
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-FHDTJP2C.js";
|
|
22
22
|
import {
|
|
23
23
|
clearHooksWired,
|
|
24
24
|
recordHooksWired
|
|
25
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-YSV43WLK.js";
|
|
26
26
|
import "../chunk-OYHYCK4K.js";
|
|
27
27
|
import {
|
|
28
28
|
prepareCodexContext
|
|
29
|
-
} from "../chunk-
|
|
30
|
-
import "../chunk-
|
|
29
|
+
} from "../chunk-RS5ADTDF.js";
|
|
30
|
+
import "../chunk-ZKIBD5MO.js";
|
|
31
31
|
import {
|
|
32
32
|
getOrCreateWorkspaceId
|
|
33
33
|
} from "../chunk-EZXEWFDG.js";
|
|
34
34
|
import {
|
|
35
35
|
daemonRequest
|
|
36
|
-
} from "../chunk-
|
|
36
|
+
} from "../chunk-NWWTFQP2.js";
|
|
37
37
|
import {
|
|
38
38
|
normalizeEnvelope,
|
|
39
39
|
readHookStdin,
|
|
40
40
|
shouldSuppressImportedCursorHandler
|
|
41
|
-
} from "../chunk-
|
|
42
|
-
import
|
|
43
|
-
MANAGED_GIT_HOOK_NAMES
|
|
44
|
-
} from "../chunk-UUQT5GMO.js";
|
|
41
|
+
} from "../chunk-KZNOT2YH.js";
|
|
42
|
+
import "../chunk-MMMY57UA.js";
|
|
45
43
|
import {
|
|
46
44
|
fetchAndCacheCollectScope
|
|
47
|
-
} from "../chunk-
|
|
45
|
+
} from "../chunk-QSDWWEHF.js";
|
|
48
46
|
import {
|
|
49
47
|
getSiteUrl,
|
|
50
48
|
isSessionEnded
|
|
51
|
-
} from "../chunk-
|
|
49
|
+
} from "../chunk-RAEOSDQ6.js";
|
|
52
50
|
import {
|
|
53
51
|
CLOUD_CREDENTIALS_REMEDY,
|
|
54
|
-
|
|
52
|
+
CLOUD_REJECTED_CREDENTIALS_NOTICE,
|
|
53
|
+
ENVIRONMENT_CREDENTIAL_REMEDY,
|
|
54
|
+
MANAGED_GIT_HOOK_NAMES,
|
|
55
|
+
ensureSessionIdentity,
|
|
55
56
|
gitToplevel,
|
|
56
57
|
hasMachineConfiguration,
|
|
57
58
|
isClaudeCloudSession,
|
|
58
59
|
isRepoActiveForCapture,
|
|
59
60
|
markActivationImplicit,
|
|
60
61
|
repoActiveFlag,
|
|
62
|
+
sessionIdentityMessage,
|
|
63
|
+
sessionIdentityMode,
|
|
61
64
|
setRepoActive,
|
|
62
65
|
withdrawImplicitActivation
|
|
63
|
-
} from "../chunk-
|
|
66
|
+
} from "../chunk-BVGASV3B.js";
|
|
64
67
|
import {
|
|
65
68
|
parseAgent
|
|
66
69
|
} from "../chunk-KZB4ABIB.js";
|
|
67
70
|
import "../chunk-JSBRDJBE.js";
|
|
68
71
|
|
|
69
72
|
// src/hooks/reauth-notice.ts
|
|
73
|
+
function sharedEnvironment() {
|
|
74
|
+
try {
|
|
75
|
+
return sessionIdentityMode();
|
|
76
|
+
} catch {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
70
80
|
var REAUTH_NOTICE = "[prim] authentication ended \u2014 run `prim auth login` to resume decision capture";
|
|
71
81
|
function reauthNoticeFields(agent) {
|
|
72
82
|
if (agent === "claude_code") {
|
|
73
83
|
if (isClaudeCloudSession()) {
|
|
74
|
-
const notice = `Primitive is not connected in this Claude Code cloud session:
|
|
84
|
+
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;
|
|
75
85
|
return {
|
|
76
86
|
systemMessage: notice,
|
|
77
87
|
additionalContext: `${notice} Tell the user this in one sentence before starting their task.`
|
|
@@ -88,6 +98,18 @@ function reauthNoticeFields(agent) {
|
|
|
88
98
|
var DAEMON_TIMEOUT_MS = 250;
|
|
89
99
|
var REPOSITORY_BIND_TIMEOUT_MS = 1e3;
|
|
90
100
|
var CLOUD_REPOSITORY_BIND_TIMEOUT_MS = 1e4;
|
|
101
|
+
var SESSION_IDENTITY_TIMEOUT_MS = 35e3;
|
|
102
|
+
function sessionIdentityNotice(outcome) {
|
|
103
|
+
if (!outcome || outcome.status === "ok") return void 0;
|
|
104
|
+
const notice = `${sessionIdentityMessage(outcome)} Until then, nothing this session captures is sent to Primitive.`;
|
|
105
|
+
return outcome.status === "link_required" ? {
|
|
106
|
+
notice,
|
|
107
|
+
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.`
|
|
108
|
+
} : {
|
|
109
|
+
notice,
|
|
110
|
+
instruction: `${notice} Tell the user this in one sentence before starting their task.`
|
|
111
|
+
};
|
|
112
|
+
}
|
|
91
113
|
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";
|
|
92
114
|
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.";
|
|
93
115
|
function primReminder(action, rationaleAction) {
|
|
@@ -140,9 +162,9 @@ async function activeProjectRoot(cwd) {
|
|
|
140
162
|
} catch {
|
|
141
163
|
}
|
|
142
164
|
return { root, binding };
|
|
143
|
-
} catch {
|
|
165
|
+
} catch (error) {
|
|
166
|
+
return { root, bindFailure: error };
|
|
144
167
|
}
|
|
145
|
-
return { root };
|
|
146
168
|
} catch {
|
|
147
169
|
return null;
|
|
148
170
|
}
|
|
@@ -189,11 +211,31 @@ async function processSessionStart(raw, agent, feedbackSignal) {
|
|
|
189
211
|
let active = false;
|
|
190
212
|
let skillState = { installed: 0, refreshed: 0 };
|
|
191
213
|
let claudeBinding;
|
|
214
|
+
let bindFailure;
|
|
215
|
+
let identityNotice;
|
|
192
216
|
if (agent === "claude_code") {
|
|
217
|
+
let identityMode = false;
|
|
218
|
+
try {
|
|
219
|
+
identityMode = sessionIdentityMode();
|
|
220
|
+
} catch {
|
|
221
|
+
}
|
|
222
|
+
if (identityMode) {
|
|
223
|
+
try {
|
|
224
|
+
identityNotice = sessionIdentityNotice(
|
|
225
|
+
await ensureSessionIdentity({
|
|
226
|
+
cwd,
|
|
227
|
+
explicit: true,
|
|
228
|
+
signal: AbortSignal.timeout(SESSION_IDENTITY_TIMEOUT_MS)
|
|
229
|
+
})
|
|
230
|
+
);
|
|
231
|
+
} catch {
|
|
232
|
+
}
|
|
233
|
+
}
|
|
193
234
|
const activeProject = await activeProjectRoot(cwd);
|
|
194
235
|
projectRoot = activeProject?.root ?? null;
|
|
195
236
|
active = projectRoot !== null;
|
|
196
237
|
claudeBinding = activeProject?.binding;
|
|
238
|
+
bindFailure = activeProject?.bindFailure;
|
|
197
239
|
try {
|
|
198
240
|
skillState = await refreshClaudePlugins(
|
|
199
241
|
cwd,
|
|
@@ -202,7 +244,7 @@ async function processSessionStart(raw, agent, feedbackSignal) {
|
|
|
202
244
|
} catch {
|
|
203
245
|
}
|
|
204
246
|
}
|
|
205
|
-
if (isSessionEnded() && agent !== "codex" && agent !== "cursor") {
|
|
247
|
+
if (isSessionEnded() && agent !== "codex" && agent !== "cursor" && !identityNotice) {
|
|
206
248
|
const notice = reauthNoticeFields(agent);
|
|
207
249
|
if (notice) {
|
|
208
250
|
return {
|
|
@@ -265,15 +307,15 @@ async function processSessionStart(raw, agent, feedbackSignal) {
|
|
|
265
307
|
};
|
|
266
308
|
}
|
|
267
309
|
if (agent === "claude_code") {
|
|
268
|
-
let cloudNotice;
|
|
269
|
-
if (active && !claudeBinding && isClaudeCloudSession()) {
|
|
310
|
+
let cloudNotice = identityNotice?.notice;
|
|
311
|
+
if (active && !claudeBinding && isClaudeCloudSession() && !identityNotice) {
|
|
270
312
|
try {
|
|
271
|
-
cloudNotice = await diagnoseCloudSession({ cwd: projectRoot ?? cwd });
|
|
313
|
+
cloudNotice = await diagnoseCloudSession({ cwd: projectRoot ?? cwd, bindFailure });
|
|
272
314
|
} catch {
|
|
273
315
|
}
|
|
274
316
|
}
|
|
275
317
|
const additionalContext = [
|
|
276
|
-
cloudNotice ? `${cloudNotice} Tell the user this in one sentence before starting their task.` : void 0,
|
|
318
|
+
identityNotice ? identityNotice.instruction : cloudNotice ? `${cloudNotice} Tell the user this in one sentence before starting their task.` : void 0,
|
|
277
319
|
claudeBinding ? claudeBindingReminder(claudeBinding, isClaudeCloudSession()) : void 0,
|
|
278
320
|
active && skillState.installed > 0 ? PRIM_SKILL_REMINDER : void 0
|
|
279
321
|
].filter((value) => value !== void 0).join("\n\n");
|