@primitive.ai/prim 0.1.0-alpha.109 → 0.1.0-alpha.110
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/dist/{chunk-AIAYIXBJ.js → chunk-43ZKL27W.js} +1 -1
- package/dist/{chunk-LFZYNNQQ.js → chunk-5BLGBSDM.js} +1 -1
- package/dist/{chunk-QJOK2VOE.js → chunk-AOJ254C2.js} +1 -1
- package/dist/{chunk-D24AUSVP.js → chunk-CTRAJCPN.js} +25 -2
- package/dist/{chunk-RXD6LFA2.js → chunk-GA2RXPJL.js} +1 -1
- package/dist/{chunk-FDXDV2AT.js → chunk-HTRFPXMD.js} +3 -3
- package/dist/{chunk-YQFJUBNU.js → chunk-KQ4WBK5R.js} +1 -1
- package/dist/{chunk-GFJ4QIVR.js → chunk-UDBBJWQH.js} +458 -86
- package/dist/{chunk-EQYIPUFX.js → chunk-W4ZEPZLK.js} +1 -1
- package/dist/daemon/server.js +458 -86
- package/dist/hook-runtime/daemon/server.js +458 -86
- package/dist/hook-runtime/hooks/post-commit.js +458 -86
- package/dist/hook-runtime/hooks/post-rewrite.js +458 -86
- package/dist/hook-runtime/hooks/post-tool-use.js +458 -86
- package/dist/hook-runtime/hooks/pre-tool-use.js +770 -300
- package/dist/hook-runtime/hooks/prim-hook.js +458 -86
- package/dist/hook-runtime/hooks/session-start.js +458 -86
- package/dist/hook-runtime/index.js +458 -86
- package/dist/hooks/post-commit.js +3 -3
- package/dist/hooks/post-rewrite.js +3 -3
- package/dist/hooks/post-tool-use.js +9 -9
- package/dist/hooks/pre-tool-use.js +85 -11
- package/dist/hooks/prim-hook.js +8 -8
- package/dist/hooks/session-start.js +3 -3
- package/dist/index.js +4 -4
- package/package.json +2 -1
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
saveRun,
|
|
12
12
|
sessionExcluded,
|
|
13
13
|
sessionKey
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-5BLGBSDM.js";
|
|
15
15
|
import {
|
|
16
16
|
packageVersion
|
|
17
17
|
} from "./chunk-XG7S3LIL.js";
|
|
@@ -113,6 +113,18 @@ function blockingReason(results) {
|
|
|
113
113
|
const parts = results.filter((result) => result.verdict === "ask" || result.verdict === "deny").flatMap((result) => [result.reason, result.additionalContext]).filter((value) => value.length > 0);
|
|
114
114
|
return [...new Set(parts)].join("\n\n") || "[primitive] conflict detected (no detail available)";
|
|
115
115
|
}
|
|
116
|
+
function approvalReason(results) {
|
|
117
|
+
const summaries = results.filter((result) => result.verdict === "ask" || result.verdict === "deny").map((result) => result.reason).filter(Boolean);
|
|
118
|
+
return [
|
|
119
|
+
...new Set(summaries),
|
|
120
|
+
"Approve runs this edit once; it does not change these decisions."
|
|
121
|
+
].join("\n");
|
|
122
|
+
}
|
|
123
|
+
function agentContext(results) {
|
|
124
|
+
return [...new Set(results.map((result) => result.additionalContext).filter(Boolean))].join(
|
|
125
|
+
"\n\n"
|
|
126
|
+
);
|
|
127
|
+
}
|
|
116
128
|
function advisoryNote(aggregate, results) {
|
|
117
129
|
const details = results.flatMap((result) => [
|
|
118
130
|
...aggregate === "warn" ? [result.reason] : [],
|
|
@@ -122,7 +134,18 @@ function advisoryNote(aggregate, results) {
|
|
|
122
134
|
return [...new Set(details.filter((value) => value.length > 0))].join("\n\n");
|
|
123
135
|
}
|
|
124
136
|
function buildHookOutput(aggregate, results) {
|
|
125
|
-
if (aggregate === "
|
|
137
|
+
if (aggregate === "ask") {
|
|
138
|
+
const context = agentContext(results);
|
|
139
|
+
return {
|
|
140
|
+
hookSpecificOutput: {
|
|
141
|
+
hookEventName: "PreToolUse",
|
|
142
|
+
permissionDecision: "ask",
|
|
143
|
+
permissionDecisionReason: approvalReason(results),
|
|
144
|
+
...context ? { additionalContext: context } : {}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (aggregate === "deny") {
|
|
126
149
|
return {
|
|
127
150
|
hookSpecificOutput: {
|
|
128
151
|
hookEventName: "PreToolUse",
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
analyzeShellTargets,
|
|
6
6
|
extractFileTargets
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-CTRAJCPN.js";
|
|
8
8
|
import {
|
|
9
9
|
scrubEnvironmentPaths
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-KQ4WBK5R.js";
|
|
11
11
|
import {
|
|
12
12
|
cachedCollectScopeAdmits
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-UDBBJWQH.js";
|
|
14
14
|
import {
|
|
15
15
|
canonicalRepositoryPath,
|
|
16
16
|
currentBranch,
|