@primitive.ai/prim 0.1.0-alpha.26 → 0.1.0-alpha.27
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/index.js +35 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -401,8 +401,11 @@ var REGISTRATIONS = [
|
|
|
401
401
|
makeRegistration("SessionStart", "*", SESSION_START_BIN),
|
|
402
402
|
makeRegistration("SessionEnd", "*", SESSION_END_BIN)
|
|
403
403
|
];
|
|
404
|
-
var PRIM_PERMISSION_RULE = "Bash(npx --yes @primitive.ai/prim
|
|
405
|
-
var LEGACY_PRIM_PERMISSION_RULES = [
|
|
404
|
+
var PRIM_PERMISSION_RULE = "Bash(npx --yes @primitive.ai/prim*)";
|
|
405
|
+
var LEGACY_PRIM_PERMISSION_RULES = [
|
|
406
|
+
"Bash(npx --yes @primitive.ai/prim@latest:*)",
|
|
407
|
+
"Bash(npx --yes @primitive.ai/prim:*)"
|
|
408
|
+
];
|
|
406
409
|
var ALL_PRIM_PERMISSION_RULES = /* @__PURE__ */ new Set([
|
|
407
410
|
PRIM_PERMISSION_RULE,
|
|
408
411
|
...LEGACY_PRIM_PERMISSION_RULES
|
|
@@ -582,6 +585,21 @@ function performUninstall(scope) {
|
|
|
582
585
|
changed
|
|
583
586
|
};
|
|
584
587
|
}
|
|
588
|
+
function performPermissionInstall(scope) {
|
|
589
|
+
const path = settingsPathFor(scope);
|
|
590
|
+
const before = readSettings(path);
|
|
591
|
+
const after = applyPermissions(before);
|
|
592
|
+
const changed = JSON.stringify(before) !== JSON.stringify(after);
|
|
593
|
+
if (changed) {
|
|
594
|
+
atomicWrite(path, after);
|
|
595
|
+
}
|
|
596
|
+
return {
|
|
597
|
+
scope,
|
|
598
|
+
path,
|
|
599
|
+
allowed: (after.permissions?.allow ?? []).includes(PRIM_PERMISSION_RULE),
|
|
600
|
+
changed
|
|
601
|
+
};
|
|
602
|
+
}
|
|
585
603
|
function performStatus() {
|
|
586
604
|
const statusFor = (path) => {
|
|
587
605
|
const settings = readSettings(path);
|
|
@@ -623,6 +641,17 @@ function registerClaudeCommands(program2) {
|
|
|
623
641
|
}
|
|
624
642
|
console.log(JSON.stringify(result, null, JSON_INDENT));
|
|
625
643
|
});
|
|
644
|
+
claude.command("preauth").description("Write only the prim allow-rule (no hooks) so prim's own npx calls never prompt").option(
|
|
645
|
+
"--scope <scope>",
|
|
646
|
+
"user (default for preauth \u2014 covers every repo) or project (this repo's .claude/settings.json)"
|
|
647
|
+
).action((opts) => {
|
|
648
|
+
const scope = resolveScope(opts.scope ?? "user");
|
|
649
|
+
const result = performPermissionInstall(scope);
|
|
650
|
+
console.error(
|
|
651
|
+
result.changed ? `[prim] prim allow-rule written (${scope} scope) at ${result.path}` : `[prim] prim allow-rule already present at ${result.path} (no changes)`
|
|
652
|
+
);
|
|
653
|
+
console.log(JSON.stringify(result, null, JSON_INDENT));
|
|
654
|
+
});
|
|
626
655
|
claude.command("uninstall").description("Remove all prim hooks + the prim statusline from settings.json").option(
|
|
627
656
|
"--scope <scope>",
|
|
628
657
|
"project (default, the repo's .claude/settings.json) or user (~/.claude/settings.json)"
|
|
@@ -2326,6 +2355,10 @@ function registerSetupCommand(program2) {
|
|
|
2326
2355
|
return false;
|
|
2327
2356
|
}
|
|
2328
2357
|
};
|
|
2358
|
+
if (agent === "claude") {
|
|
2359
|
+
note("pre-authorize \xB7 writing prim allow-rule (user scope)\u2026");
|
|
2360
|
+
results.preauth = run(["claude", "preauth", "--scope", "user"]).code === 0 ? "ok" : "skipped";
|
|
2361
|
+
}
|
|
2329
2362
|
if (isAuthed(run(["auth", "status", "--json"], true).stdout)) {
|
|
2330
2363
|
note("auth \xB7 already authenticated");
|
|
2331
2364
|
results.auth = "ok";
|
package/package.json
CHANGED