safeword 0.31.0 → 0.32.0

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 (35) hide show
  1. package/dist/{check-ASCK2RGI.js → check-PNWSVUZG.js} +2 -2
  2. package/dist/{chunk-WHBITLEV.js → chunk-DSPWQAEB.js} +2 -2
  3. package/dist/{chunk-S6T3OR74.js → chunk-UPAH2FHH.js} +88 -2
  4. package/dist/chunk-UPAH2FHH.js.map +1 -0
  5. package/dist/{chunk-7K3S3EYP.js → chunk-X3QSXFLN.js} +6 -2
  6. package/dist/{chunk-7K3S3EYP.js.map → chunk-X3QSXFLN.js.map} +1 -1
  7. package/dist/cli.js +6 -6
  8. package/dist/{diff-MHN76NZR.js → diff-HVRE7MNA.js} +2 -2
  9. package/dist/{reset-JCR2CGGV.js → reset-7DSNGPUW.js} +2 -2
  10. package/dist/{setup-MVKAEMEM.js → setup-R7LE7DTG.js} +4 -4
  11. package/dist/{sync-config-YCLEY5IN.js → sync-config-D77T4OIV.js} +2 -2
  12. package/dist/{upgrade-NS3QWFUY.js → upgrade-V5ZS6LTQ.js} +3 -3
  13. package/package.json +6 -6
  14. package/templates/commands/audit.md +3 -1
  15. package/templates/commands/verify.md +3 -1
  16. package/templates/cursor/rules/safeword-brainstorming.mdc +6 -0
  17. package/templates/cursor/rules/safeword-elicitation.mdc +6 -0
  18. package/templates/cursor/rules/safeword-tdd-review.mdc +6 -0
  19. package/templates/hooks/lib/update-cache.ts +7 -1
  20. package/templates/hooks/pre-tool-git-bare-fix.sh +38 -0
  21. package/templates/hooks/session-auto-upgrade.ts +2 -12
  22. package/templates/hooks/stop-quality.ts +1 -1
  23. package/templates/skills/audit/SKILL.md +4 -2
  24. package/templates/skills/bdd/DISCOVERY.md +2 -0
  25. package/templates/skills/debug/SKILL.md +2 -0
  26. package/templates/skills/elicit/SKILL.md +84 -0
  27. package/templates/skills/verify/SKILL.md +3 -1
  28. package/dist/chunk-S6T3OR74.js.map +0 -1
  29. /package/dist/{check-ASCK2RGI.js.map → check-PNWSVUZG.js.map} +0 -0
  30. /package/dist/{chunk-WHBITLEV.js.map → chunk-DSPWQAEB.js.map} +0 -0
  31. /package/dist/{diff-MHN76NZR.js.map → diff-HVRE7MNA.js.map} +0 -0
  32. /package/dist/{reset-JCR2CGGV.js.map → reset-7DSNGPUW.js.map} +0 -0
  33. /package/dist/{setup-MVKAEMEM.js.map → setup-R7LE7DTG.js.map} +0 -0
  34. /package/dist/{sync-config-YCLEY5IN.js.map → sync-config-D77T4OIV.js.map} +0 -0
  35. /package/dist/{upgrade-NS3QWFUY.js.map → upgrade-V5ZS6LTQ.js.map} +0 -0
@@ -6,7 +6,7 @@ import {
6
6
  createProjectContext,
7
7
  getMissingPacks,
8
8
  reconcile
9
- } from "./chunk-S6T3OR74.js";
9
+ } from "./chunk-UPAH2FHH.js";
10
10
  import "./chunk-YVZL7WO5.js";
11
11
  import {
12
12
  VERSION
@@ -189,4 +189,4 @@ async function check(options) {
189
189
  export {
190
190
  check
191
191
  };
192
- //# sourceMappingURL=check-ASCK2RGI.js.map
192
+ //# sourceMappingURL=check-PNWSVUZG.js.map
@@ -3,7 +3,7 @@ import {
3
3
  addInstalledPack,
4
4
  isGitRepo,
5
5
  isPackInstalled
6
- } from "./chunk-S6T3OR74.js";
6
+ } from "./chunk-UPAH2FHH.js";
7
7
 
8
8
  // src/packs/install.ts
9
9
  function installPack(packId, cwd) {
@@ -21,4 +21,4 @@ function installPack(packId, cwd) {
21
21
  export {
22
22
  installPack
23
23
  };
24
- //# sourceMappingURL=chunk-WHBITLEV.js.map
24
+ //# sourceMappingURL=chunk-DSPWQAEB.js.map
@@ -1927,6 +1927,12 @@ function asyncHook(command) {
1927
1927
  function matchedHook(matcher, command) {
1928
1928
  return { matcher, hooks: [{ type: "command", command }] };
1929
1929
  }
1930
+ function matchedHookWithIf(matcher, ifRule, command) {
1931
+ return {
1932
+ matcher,
1933
+ hooks: [{ type: "command", if: ifRule, command }]
1934
+ };
1935
+ }
1930
1936
  var EDIT_TOOLS = "Edit|Write|MultiEdit|NotebookEdit";
1931
1937
  var SETTINGS_HOOKS = {
1932
1938
  SessionStart: [
@@ -1945,7 +1951,11 @@ var SETTINGS_HOOKS = {
1945
1951
  Stop: [hook(`bun ${HOOKS_DIR}/stop-quality.ts`)],
1946
1952
  PreToolUse: [
1947
1953
  matchedHook(EDIT_TOOLS, `bun ${HOOKS_DIR}/pre-tool-quality.ts`),
1948
- matchedHook(EDIT_TOOLS, `bun ${HOOKS_DIR}/pre-tool-config-guard.ts`)
1954
+ matchedHook(EDIT_TOOLS, `bun ${HOOKS_DIR}/pre-tool-config-guard.ts`),
1955
+ // Defends ad-hoc git ops against Claude Code's parallel-worktree
1956
+ // core.bare=true race (anthropics/claude-code#58345). `if` filters at the
1957
+ // config level so non-git Bash calls incur zero hook-process spawn.
1958
+ matchedHookWithIf("Bash", "Bash(git *)", `bash ${HOOKS_DIR}/pre-tool-git-bare-fix.sh`)
1949
1959
  ],
1950
1960
  PostToolUse: [
1951
1961
  matchedHook(EDIT_TOOLS, `bun ${HOOKS_DIR}/post-tool-lint.ts`),
@@ -2267,6 +2277,62 @@ var typescriptPackages = {
2267
2277
  }
2268
2278
  };
2269
2279
 
2280
+ // src/owned-paths.ts
2281
+ function computeSafewordPathPrefixes(schema) {
2282
+ const allPaths = [
2283
+ ...Object.keys(schema.ownedFiles),
2284
+ ...Object.keys(schema.managedFiles),
2285
+ ...Object.keys(schema.jsonMerges),
2286
+ ...Object.keys(schema.textPatches)
2287
+ ];
2288
+ const prefixes = /* @__PURE__ */ new Set();
2289
+ for (const path2 of allPaths) {
2290
+ const slashIndex = path2.indexOf("/");
2291
+ prefixes.add(slashIndex === -1 ? path2 : path2.slice(0, slashIndex + 1));
2292
+ }
2293
+ return [...prefixes].toSorted((a, b) => a.localeCompare(b));
2294
+ }
2295
+ function generateOwnedPathsModule(schema) {
2296
+ const prefixes = computeSafewordPathPrefixes(schema);
2297
+ const entries = prefixes.map((prefix) => ` '${prefix}',`).join("\n");
2298
+ return `// Auto-generated by safeword from SAFEWORD_SCHEMA. Do not edit by hand.
2299
+ // Source: ownedFiles \u222A managedFiles \u222A jsonMerges \u222A textPatches \u2192 top-level prefixes.
2300
+ // Regenerated on every \`safeword setup\` and \`safeword upgrade\`.
2301
+
2302
+ export const SAFEWORD_PATHS: readonly string[] = [
2303
+ ${entries}
2304
+ ];
2305
+
2306
+ /**
2307
+ * Match a file path against the safeword-managed set. Directory prefixes
2308
+ * (entries ending in \`/\`) match by \`startsWith\`; bare file paths must
2309
+ * match exactly so e.g. \`package.json.bak\` does not match \`package.json\`.
2310
+ */
2311
+ export function isSafewordPath(file: string): boolean {
2312
+ for (const prefix of SAFEWORD_PATHS) {
2313
+ if (prefix.endsWith('/')) {
2314
+ if (file.startsWith(prefix)) return true;
2315
+ } else if (file === prefix) {
2316
+ return true;
2317
+ }
2318
+ }
2319
+ return false;
2320
+ }
2321
+
2322
+ /**
2323
+ * Pick the safeword-managed subset of files reported by \`git diff --name-only\`
2324
+ * (changed) and \`git ls-files --others --exclude-standard\` (untracked).
2325
+ * Used by the auto-upgrade hook to decide what to stage after \`safeword upgrade\`.
2326
+ */
2327
+ export function filterSafewordFiles(
2328
+ changedFiles: readonly string[],
2329
+ untrackedFiles: readonly string[],
2330
+ ): readonly string[] {
2331
+ return [...changedFiles, ...untrackedFiles].filter(f => isSafewordPath(f));
2332
+ }
2333
+ `;
2334
+ }
2335
+
2270
2336
  // src/templates/content.ts
2271
2337
  var AGENTS_MD_LINK = `**\u26A0\uFE0F ALWAYS READ FIRST:** \`.safeword/SAFEWORD.md\`
2272
2338
 
@@ -2499,6 +2565,11 @@ var SAFEWORD_SCHEMA = {
2499
2565
  ".safeword/hooks/lib/test-runner.ts": { template: "hooks/lib/test-runner.ts" },
2500
2566
  ".safeword/hooks/lib/update-cache.ts": { template: "hooks/lib/update-cache.ts" },
2501
2567
  ".safeword/hooks/lib/version.ts": { template: "hooks/lib/version.ts" },
2568
+ // Generated at setup/upgrade from SAFEWORD_SCHEMA itself — the prefix list
2569
+ // the auto-upgrade hook uses to decide which files to stage. See owned-paths.ts.
2570
+ ".safeword/hooks/lib/owned-paths.ts": {
2571
+ generator: () => generateOwnedPathsModule(SAFEWORD_SCHEMA)
2572
+ },
2502
2573
  // Hooks - TypeScript with Bun runtime
2503
2574
  ".safeword/hooks/session-verify-agents.ts": {
2504
2575
  template: "hooks/session-verify-agents.ts"
@@ -2533,6 +2604,9 @@ var SAFEWORD_SCHEMA = {
2533
2604
  ".safeword/hooks/pre-tool-config-guard.ts": {
2534
2605
  template: "hooks/pre-tool-config-guard.ts"
2535
2606
  },
2607
+ ".safeword/hooks/pre-tool-git-bare-fix.sh": {
2608
+ template: "hooks/pre-tool-git-bare-fix.sh"
2609
+ },
2536
2610
  ".safeword/hooks/session-auto-upgrade.ts": {
2537
2611
  template: "hooks/session-auto-upgrade.ts"
2538
2612
  },
@@ -2662,6 +2736,9 @@ var SAFEWORD_SCHEMA = {
2662
2736
  ".claude/skills/brainstorm/SKILL.md": {
2663
2737
  template: "skills/brainstorm/SKILL.md"
2664
2738
  },
2739
+ ".claude/skills/elicit/SKILL.md": {
2740
+ template: "skills/elicit/SKILL.md"
2741
+ },
2665
2742
  ".claude/skills/tdd-review/SKILL.md": {
2666
2743
  template: "skills/tdd-review/SKILL.md"
2667
2744
  },
@@ -2669,15 +2746,24 @@ var SAFEWORD_SCHEMA = {
2669
2746
  ".cursor/rules/safeword-core.mdc": {
2670
2747
  template: "cursor/rules/safeword-core.mdc"
2671
2748
  },
2749
+ ".cursor/rules/safeword-brainstorming.mdc": {
2750
+ template: "cursor/rules/safeword-brainstorming.mdc"
2751
+ },
2672
2752
  ".cursor/rules/safeword-debugging.mdc": {
2673
2753
  template: "cursor/rules/safeword-debugging.mdc"
2674
2754
  },
2755
+ ".cursor/rules/safeword-elicitation.mdc": {
2756
+ template: "cursor/rules/safeword-elicitation.mdc"
2757
+ },
2675
2758
  ".cursor/rules/safeword-quality-reviewing.mdc": {
2676
2759
  template: "cursor/rules/safeword-quality-reviewing.mdc"
2677
2760
  },
2678
2761
  ".cursor/rules/safeword-refactoring.mdc": {
2679
2762
  template: "cursor/rules/safeword-refactoring.mdc"
2680
2763
  },
2764
+ ".cursor/rules/safeword-tdd-review.mdc": {
2765
+ template: "cursor/rules/safeword-tdd-review.mdc"
2766
+ },
2681
2767
  ".cursor/rules/safeword-testing.mdc": {
2682
2768
  template: "cursor/rules/safeword-testing.mdc"
2683
2769
  },
@@ -3045,4 +3131,4 @@ export {
3045
3131
  detectLanguages2,
3046
3132
  createProjectContext
3047
3133
  };
3048
- //# sourceMappingURL=chunk-S6T3OR74.js.map
3134
+ //# sourceMappingURL=chunk-UPAH2FHH.js.map