@primitive.ai/prim 0.1.0-alpha.25 → 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.
Files changed (2) hide show
  1. package/dist/index.js +43 -7
  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 = ["Bash(npx --yes @primitive.ai/prim@latest:*)"];
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
@@ -472,13 +475,16 @@ function applyStatusLine(settings) {
472
475
  function applyPermissions(settings) {
473
476
  const permissions = settings.permissions ?? {};
474
477
  const allow = permissions.allow ?? [];
475
- const withoutPrim = allow.filter((rule) => !ALL_PRIM_PERMISSION_RULES.has(rule));
476
- const nextAllow = [...withoutPrim, PRIM_PERMISSION_RULE];
477
- const unchanged = allow.length === nextAllow.length && allow.every((rule, i) => rule === nextAllow[i]);
478
- if (unchanged) {
478
+ const hasCanonical = allow.includes(PRIM_PERMISSION_RULE);
479
+ const hasLegacy = allow.some((rule) => LEGACY_PRIM_PERMISSION_RULES.includes(rule));
480
+ if (hasCanonical && !hasLegacy) {
479
481
  return settings;
480
482
  }
481
- return { ...settings, permissions: { ...permissions, allow: nextAllow } };
483
+ const withoutPrim = allow.filter((rule) => !ALL_PRIM_PERMISSION_RULES.has(rule));
484
+ return {
485
+ ...settings,
486
+ permissions: { ...permissions, allow: [...withoutPrim, PRIM_PERMISSION_RULE] }
487
+ };
482
488
  }
483
489
  function removePrimPermission(settings) {
484
490
  const permissions = settings.permissions;
@@ -579,6 +585,21 @@ function performUninstall(scope) {
579
585
  changed
580
586
  };
581
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
+ }
582
603
  function performStatus() {
583
604
  const statusFor = (path) => {
584
605
  const settings = readSettings(path);
@@ -620,6 +641,17 @@ function registerClaudeCommands(program2) {
620
641
  }
621
642
  console.log(JSON.stringify(result, null, JSON_INDENT));
622
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
+ });
623
655
  claude.command("uninstall").description("Remove all prim hooks + the prim statusline from settings.json").option(
624
656
  "--scope <scope>",
625
657
  "project (default, the repo's .claude/settings.json) or user (~/.claude/settings.json)"
@@ -2323,6 +2355,10 @@ function registerSetupCommand(program2) {
2323
2355
  return false;
2324
2356
  }
2325
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
+ }
2326
2362
  if (isAuthed(run(["auth", "status", "--json"], true).stdout)) {
2327
2363
  note("auth \xB7 already authenticated");
2328
2364
  results.auth = "ok";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primitive.ai/prim",
3
- "version": "0.1.0-alpha.25",
3
+ "version": "0.1.0-alpha.27",
4
4
  "description": "CLI for Primitive's decision graph — passive decision capture, conflict gate, and team presence",
5
5
  "type": "module",
6
6
  "license": "MIT",