@primitive.ai/prim 0.1.0-alpha.125 → 0.1.0-alpha.127
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 +140 -1
- package/SKILL.md +6 -1
- package/dist/{chunk-JFWJN2ME.js → chunk-72NIZMZN.js} +114 -5
- package/dist/{chunk-2BEUR3DU.js → chunk-A5VTE43F.js} +2 -2
- package/dist/{chunk-6OPSSJHO.js → chunk-C4QNBSWB.js} +24 -9
- package/dist/{chunk-BFYJLI7V.js → chunk-F3FDVHR7.js} +1 -1
- package/dist/{chunk-YP4OXKNX.js → chunk-H6X52UVF.js} +1 -1
- package/dist/{chunk-ND6TYHNI.js → chunk-H74RDXKP.js} +2 -2
- package/dist/{chunk-NJBN3WXF.js → chunk-HZI5PBN4.js} +785 -154
- package/dist/{chunk-FYYHBOOM.js → chunk-JCKOW45X.js} +2 -2
- package/dist/{chunk-DT7E3SD5.js → chunk-KFRGVHGB.js} +4 -4
- package/dist/{chunk-TI37ME2D.js → chunk-L6IL4N6Y.js} +16 -7
- package/dist/{chunk-HPA7RGSZ.js → chunk-MGKSZSTV.js} +7 -8
- package/dist/{chunk-ZKXNJB6U.js → chunk-NVDPKW7Z.js} +69 -29
- package/dist/{chunk-NBNQI3YJ.js → chunk-O65UVJZH.js} +6 -3
- package/dist/{chunk-74DQDWLW.js → chunk-R4EYLEIK.js} +7 -2
- package/dist/{chunk-R35M4RCY.js → chunk-RV3JFSMX.js} +4 -4
- package/dist/{chunk-PPZ56EVJ.js → chunk-TNWI3JWK.js} +1 -1
- package/dist/{chunk-6KXQQ7CQ.js → chunk-URYZDQFH.js} +3 -3
- package/dist/{chunk-L32WYFJT.js → chunk-UUQT5GMO.js} +135 -12
- package/dist/{chunk-EZXIKEMA.js → chunk-VVFVENU4.js} +6 -4
- package/dist/{chunk-O73J3KQQ.js → chunk-WGTUNUIS.js} +5 -2
- package/dist/daemon/server.js +805 -218
- package/dist/hook-runtime/daemon/server.js +805 -218
- package/dist/hook-runtime/hooks/post-commit.js +286 -59
- package/dist/hook-runtime/hooks/post-rewrite.js +278 -51
- package/dist/hook-runtime/hooks/post-tool-use.js +672 -194
- package/dist/hook-runtime/hooks/pre-commit.js +536 -88
- package/dist/hook-runtime/hooks/pre-tool-use-worker.js +616 -165
- package/dist/hook-runtime/hooks/prim-hook.js +642 -167
- package/dist/hook-runtime/hooks/session-end.js +263 -47
- package/dist/hook-runtime/hooks/session-start.js +1103 -476
- package/dist/hook-runtime/index.js +3645 -2120
- package/dist/hook-runtime/statusline-main.js +257 -29
- 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 +14 -15
- package/dist/hooks/prim-hook.js +16 -16
- package/dist/hooks/session-end.js +4 -4
- package/dist/hooks/session-start.js +49 -18
- package/dist/index.js +1014 -271
- package/dist/statusline-main.js +257 -29
- package/package.json +1 -1
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-TNWI3JWK.js";
|
|
12
12
|
import {
|
|
13
13
|
recordConversationCaptured
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-F3FDVHR7.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-RV3JFSMX.js";
|
|
22
22
|
import {
|
|
23
23
|
prepareCodexContext
|
|
24
|
-
} from "../chunk-
|
|
25
|
-
import "../chunk-
|
|
24
|
+
} from "../chunk-KFRGVHGB.js";
|
|
25
|
+
import "../chunk-URYZDQFH.js";
|
|
26
26
|
import {
|
|
27
27
|
postToolInvocationId,
|
|
28
28
|
shouldFlushAfter,
|
|
29
29
|
toMove
|
|
30
|
-
} from "../chunk-
|
|
30
|
+
} from "../chunk-JCKOW45X.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-O65UVJZH.js";
|
|
38
|
+
import "../chunk-H6X52UVF.js";
|
|
39
39
|
import {
|
|
40
40
|
observeDemoInvocation
|
|
41
|
-
} from "../chunk-
|
|
41
|
+
} from "../chunk-A5VTE43F.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-H74RDXKP.js";
|
|
47
|
+
import "../chunk-MGKSZSTV.js";
|
|
48
|
+
import "../chunk-UUQT5GMO.js";
|
|
49
49
|
import {
|
|
50
50
|
scrubFromCwd,
|
|
51
51
|
writeHookDebug
|
|
52
|
-
} from "../chunk-
|
|
52
|
+
} from "../chunk-R4EYLEIK.js";
|
|
53
53
|
import {
|
|
54
54
|
cachedCollectScopeAdmits
|
|
55
|
-
} from "../chunk-
|
|
56
|
-
import "../chunk-
|
|
55
|
+
} from "../chunk-WGTUNUIS.js";
|
|
56
|
+
import "../chunk-NVDPKW7Z.js";
|
|
57
57
|
import {
|
|
58
58
|
currentBranch,
|
|
59
59
|
isRepoActiveForCapture,
|
|
60
60
|
repoSyncId,
|
|
61
61
|
resolveRepositoryContext
|
|
62
|
-
} from "../chunk-
|
|
62
|
+
} from "../chunk-HZI5PBN4.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-H6X52UVF.js";
|
|
5
5
|
import {
|
|
6
6
|
normalizeEnvelope,
|
|
7
7
|
readHookStdin,
|
|
8
8
|
shouldSuppressImportedCursorHandler
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-H74RDXKP.js";
|
|
10
|
+
import "../chunk-UUQT5GMO.js";
|
|
11
11
|
import {
|
|
12
12
|
isRepoActiveForCapture
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-HZI5PBN4.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-72NIZMZN.js";
|
|
11
12
|
import {
|
|
12
13
|
buildHookOutput,
|
|
13
14
|
handoffHookOutput
|
|
@@ -17,44 +18,49 @@ import {
|
|
|
17
18
|
acknowledgeDecisionFeedback,
|
|
18
19
|
leaseDecisionFeedback,
|
|
19
20
|
renderFeedback
|
|
20
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-TNWI3JWK.js";
|
|
21
22
|
import {
|
|
22
23
|
clearHooksWired,
|
|
23
24
|
recordHooksWired
|
|
24
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-F3FDVHR7.js";
|
|
25
26
|
import "../chunk-OYHYCK4K.js";
|
|
26
27
|
import {
|
|
27
28
|
prepareCodexContext
|
|
28
|
-
} from "../chunk-
|
|
29
|
-
import "../chunk-
|
|
29
|
+
} from "../chunk-KFRGVHGB.js";
|
|
30
|
+
import "../chunk-URYZDQFH.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-H6X52UVF.js";
|
|
36
37
|
import {
|
|
37
38
|
normalizeEnvelope,
|
|
38
39
|
readHookStdin,
|
|
39
40
|
shouldSuppressImportedCursorHandler
|
|
40
|
-
} from "../chunk-
|
|
41
|
+
} from "../chunk-H74RDXKP.js";
|
|
41
42
|
import {
|
|
42
43
|
MANAGED_GIT_HOOK_NAMES
|
|
43
|
-
} from "../chunk-
|
|
44
|
+
} from "../chunk-UUQT5GMO.js";
|
|
44
45
|
import {
|
|
45
46
|
fetchAndCacheCollectScope
|
|
46
|
-
} from "../chunk-
|
|
47
|
+
} from "../chunk-WGTUNUIS.js";
|
|
47
48
|
import {
|
|
48
49
|
getSiteUrl,
|
|
49
50
|
isSessionEnded
|
|
50
|
-
} from "../chunk-
|
|
51
|
+
} from "../chunk-NVDPKW7Z.js";
|
|
51
52
|
import {
|
|
53
|
+
CLOUD_CREDENTIALS_REMEDY,
|
|
54
|
+
CLOUD_REJECTED_CREDENTIALS_REMEDY,
|
|
52
55
|
gitToplevel,
|
|
53
56
|
hasMachineConfiguration,
|
|
57
|
+
isClaudeCloudSession,
|
|
54
58
|
isRepoActiveForCapture,
|
|
59
|
+
markActivationImplicit,
|
|
55
60
|
repoActiveFlag,
|
|
56
|
-
setRepoActive
|
|
57
|
-
|
|
61
|
+
setRepoActive,
|
|
62
|
+
withdrawImplicitActivation
|
|
63
|
+
} from "../chunk-HZI5PBN4.js";
|
|
58
64
|
import {
|
|
59
65
|
parseAgent
|
|
60
66
|
} from "../chunk-KZB4ABIB.js";
|
|
@@ -63,16 +69,25 @@ import "../chunk-JSBRDJBE.js";
|
|
|
63
69
|
// src/hooks/reauth-notice.ts
|
|
64
70
|
var REAUTH_NOTICE = "[prim] authentication ended \u2014 run `prim auth login` to resume decision capture";
|
|
65
71
|
function reauthNoticeFields(agent) {
|
|
66
|
-
if (agent === "claude_code")
|
|
72
|
+
if (agent === "claude_code") {
|
|
73
|
+
if (isClaudeCloudSession()) {
|
|
74
|
+
const notice = `Primitive is not connected in this Claude Code cloud session: ${hasMachineConfiguration() ? `its credentials were rejected. To fix it, ${CLOUD_REJECTED_CREDENTIALS_REMEDY}` : `its sign-in ended. To fix it, ${CLOUD_CREDENTIALS_REMEDY}`}.`;
|
|
75
|
+
return {
|
|
76
|
+
systemMessage: notice,
|
|
77
|
+
additionalContext: `${notice} Tell the user this in one sentence before starting their task.`
|
|
78
|
+
};
|
|
79
|
+
}
|
|
67
80
|
return {
|
|
68
81
|
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
82
|
};
|
|
83
|
+
}
|
|
70
84
|
return;
|
|
71
85
|
}
|
|
72
86
|
|
|
73
87
|
// src/hooks/session-start-core.ts
|
|
74
88
|
var DAEMON_TIMEOUT_MS = 250;
|
|
75
89
|
var REPOSITORY_BIND_TIMEOUT_MS = 1e3;
|
|
90
|
+
var CLOUD_REPOSITORY_BIND_TIMEOUT_MS = 1e4;
|
|
76
91
|
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
92
|
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
93
|
function primReminder(action, rationaleAction) {
|
|
@@ -93,6 +108,7 @@ async function activeProjectRoot(cwd) {
|
|
|
93
108
|
if (!shellGateActive) {
|
|
94
109
|
try {
|
|
95
110
|
setRepoActive(root, true);
|
|
111
|
+
markActivationImplicit(root);
|
|
96
112
|
shellGateActive = true;
|
|
97
113
|
} catch {
|
|
98
114
|
}
|
|
@@ -114,7 +130,9 @@ async function activeProjectRoot(cwd) {
|
|
|
114
130
|
}
|
|
115
131
|
try {
|
|
116
132
|
const binding = await bindRepository(root, {
|
|
117
|
-
signal: AbortSignal.timeout(
|
|
133
|
+
signal: AbortSignal.timeout(
|
|
134
|
+
isClaudeCloudSession() ? CLOUD_REPOSITORY_BIND_TIMEOUT_MS : REPOSITORY_BIND_TIMEOUT_MS
|
|
135
|
+
),
|
|
118
136
|
quietRefresh: true
|
|
119
137
|
});
|
|
120
138
|
try {
|
|
@@ -129,7 +147,9 @@ async function activeProjectRoot(cwd) {
|
|
|
129
147
|
return null;
|
|
130
148
|
}
|
|
131
149
|
}
|
|
132
|
-
function claudeBindingReminder(binding) {
|
|
150
|
+
function claudeBindingReminder(binding, cloud = false) {
|
|
151
|
+
if (cloud && binding.status !== "connected")
|
|
152
|
+
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
153
|
if (binding.status === "connected") {
|
|
134
154
|
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
155
|
}
|
|
@@ -153,6 +173,7 @@ async function processSessionStart(raw, agent, feedbackSignal) {
|
|
|
153
173
|
return { output: buildHookOutput({}) };
|
|
154
174
|
}
|
|
155
175
|
const cwd = envelope.cwd ?? process.cwd();
|
|
176
|
+
withdrawImplicitActivation(cwd);
|
|
156
177
|
if (!gitToplevel(cwd) || !isRepoActiveForCapture(cwd)) {
|
|
157
178
|
if (repoActiveFlag(cwd) === "false") clearHooksWired(cwd);
|
|
158
179
|
return { output: agent === "cursor" ? {} : buildHookOutput({}) };
|
|
@@ -244,8 +265,16 @@ async function processSessionStart(raw, agent, feedbackSignal) {
|
|
|
244
265
|
};
|
|
245
266
|
}
|
|
246
267
|
if (agent === "claude_code") {
|
|
268
|
+
let cloudNotice;
|
|
269
|
+
if (active && !claudeBinding && isClaudeCloudSession()) {
|
|
270
|
+
try {
|
|
271
|
+
cloudNotice = await diagnoseCloudSession({ cwd: projectRoot ?? cwd });
|
|
272
|
+
} catch {
|
|
273
|
+
}
|
|
274
|
+
}
|
|
247
275
|
const additionalContext = [
|
|
248
|
-
|
|
276
|
+
cloudNotice ? `${cloudNotice} Tell the user this in one sentence before starting their task.` : void 0,
|
|
277
|
+
claudeBinding ? claudeBindingReminder(claudeBinding, isClaudeCloudSession()) : void 0,
|
|
249
278
|
active && skillState.installed > 0 ? PRIM_SKILL_REMINDER : void 0
|
|
250
279
|
].filter((value) => value !== void 0).join("\n\n");
|
|
251
280
|
const reloadSkills = skillState.refreshed > 0;
|
|
@@ -261,7 +290,7 @@ async function processSessionStart(raw, agent, feedbackSignal) {
|
|
|
261
290
|
const rendered = lease ? renderFeedback(lease) : void 0;
|
|
262
291
|
return {
|
|
263
292
|
output: buildHookOutput({
|
|
264
|
-
systemMessage: rendered?.systemMessage,
|
|
293
|
+
systemMessage: [cloudNotice, rendered?.systemMessage].filter(Boolean).join("\n\n") || void 0,
|
|
265
294
|
additionalContext,
|
|
266
295
|
reloadSkills
|
|
267
296
|
}),
|
|
@@ -276,7 +305,9 @@ async function processSessionStart(raw, agent, feedbackSignal) {
|
|
|
276
305
|
};
|
|
277
306
|
}
|
|
278
307
|
}
|
|
279
|
-
return {
|
|
308
|
+
return {
|
|
309
|
+
output: buildHookOutput({ systemMessage: cloudNotice, additionalContext, reloadSkills })
|
|
310
|
+
};
|
|
280
311
|
}
|
|
281
312
|
await activeProjectRoot(cwd);
|
|
282
313
|
return { output: buildHookOutput({}) };
|