safeword 0.31.0 → 0.32.1

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-T3G27MSZ.js} +2 -2
  2. package/dist/{chunk-WHBITLEV.js → chunk-7IQAVAM7.js} +2 -2
  3. package/dist/{chunk-S6T3OR74.js → chunk-CWE7DTMG.js} +93 -4
  4. package/dist/chunk-CWE7DTMG.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-WUK3RFWI.js} +2 -2
  9. package/dist/{reset-JCR2CGGV.js → reset-LMQYYGUG.js} +2 -2
  10. package/dist/{setup-MVKAEMEM.js → setup-NCYV7URM.js} +4 -4
  11. package/dist/{sync-config-YCLEY5IN.js → sync-config-D77T4OIV.js} +2 -2
  12. package/dist/{upgrade-NS3QWFUY.js → upgrade-4H3A2YY3.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-T3G27MSZ.js.map} +0 -0
  30. /package/dist/{chunk-WHBITLEV.js.map → chunk-7IQAVAM7.js.map} +0 -0
  31. /package/dist/{diff-MHN76NZR.js.map → diff-WUK3RFWI.js.map} +0 -0
  32. /package/dist/{reset-JCR2CGGV.js.map → reset-LMQYYGUG.js.map} +0 -0
  33. /package/dist/{setup-MVKAEMEM.js.map → setup-NCYV7URM.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-4H3A2YY3.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-CWE7DTMG.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-T3G27MSZ.js.map
@@ -3,7 +3,7 @@ import {
3
3
  addInstalledPack,
4
4
  isGitRepo,
5
5
  isPackInstalled
6
- } from "./chunk-S6T3OR74.js";
6
+ } from "./chunk-CWE7DTMG.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-7IQAVAM7.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
 
@@ -2382,9 +2448,10 @@ var SAFEWORD_SCHEMA = {
2382
2448
  // BDD skill split into phase files (v0.16.0)
2383
2449
  ".cursor/rules/safeword-bdd-orchestrating.mdc",
2384
2450
  ".safeword/commands/tdd.md",
2385
- // Brainstorming skill removed - never used, BDD discovery phase covers this (v0.16.0)
2451
+ // Brainstorming skill: old safeword-* skill removed (v0.16.0); cursor rule was
2452
+ // re-introduced under same name (PR #103) for the new short-name brainstorm skill,
2453
+ // so .cursor/rules/safeword-brainstorming.mdc is no longer deprecated.
2386
2454
  ".claude/skills/safeword-brainstorming/SKILL.md",
2387
- ".cursor/rules/safeword-brainstorming.mdc",
2388
2455
  // Writing-plans skill removed - redundant with BDD decomposition + Claude Code native plan mode (v0.16.0)
2389
2456
  ".claude/skills/safeword-writing-plans/SKILL.md",
2390
2457
  ".cursor/rules/safeword-writing-plans.mdc",
@@ -2499,6 +2566,11 @@ var SAFEWORD_SCHEMA = {
2499
2566
  ".safeword/hooks/lib/test-runner.ts": { template: "hooks/lib/test-runner.ts" },
2500
2567
  ".safeword/hooks/lib/update-cache.ts": { template: "hooks/lib/update-cache.ts" },
2501
2568
  ".safeword/hooks/lib/version.ts": { template: "hooks/lib/version.ts" },
2569
+ // Generated at setup/upgrade from SAFEWORD_SCHEMA itself — the prefix list
2570
+ // the auto-upgrade hook uses to decide which files to stage. See owned-paths.ts.
2571
+ ".safeword/hooks/lib/owned-paths.ts": {
2572
+ generator: () => generateOwnedPathsModule(SAFEWORD_SCHEMA)
2573
+ },
2502
2574
  // Hooks - TypeScript with Bun runtime
2503
2575
  ".safeword/hooks/session-verify-agents.ts": {
2504
2576
  template: "hooks/session-verify-agents.ts"
@@ -2533,6 +2605,9 @@ var SAFEWORD_SCHEMA = {
2533
2605
  ".safeword/hooks/pre-tool-config-guard.ts": {
2534
2606
  template: "hooks/pre-tool-config-guard.ts"
2535
2607
  },
2608
+ ".safeword/hooks/pre-tool-git-bare-fix.sh": {
2609
+ template: "hooks/pre-tool-git-bare-fix.sh"
2610
+ },
2536
2611
  ".safeword/hooks/session-auto-upgrade.ts": {
2537
2612
  template: "hooks/session-auto-upgrade.ts"
2538
2613
  },
@@ -2662,6 +2737,9 @@ var SAFEWORD_SCHEMA = {
2662
2737
  ".claude/skills/brainstorm/SKILL.md": {
2663
2738
  template: "skills/brainstorm/SKILL.md"
2664
2739
  },
2740
+ ".claude/skills/elicit/SKILL.md": {
2741
+ template: "skills/elicit/SKILL.md"
2742
+ },
2665
2743
  ".claude/skills/tdd-review/SKILL.md": {
2666
2744
  template: "skills/tdd-review/SKILL.md"
2667
2745
  },
@@ -2669,15 +2747,24 @@ var SAFEWORD_SCHEMA = {
2669
2747
  ".cursor/rules/safeword-core.mdc": {
2670
2748
  template: "cursor/rules/safeword-core.mdc"
2671
2749
  },
2750
+ ".cursor/rules/safeword-brainstorming.mdc": {
2751
+ template: "cursor/rules/safeword-brainstorming.mdc"
2752
+ },
2672
2753
  ".cursor/rules/safeword-debugging.mdc": {
2673
2754
  template: "cursor/rules/safeword-debugging.mdc"
2674
2755
  },
2756
+ ".cursor/rules/safeword-elicitation.mdc": {
2757
+ template: "cursor/rules/safeword-elicitation.mdc"
2758
+ },
2675
2759
  ".cursor/rules/safeword-quality-reviewing.mdc": {
2676
2760
  template: "cursor/rules/safeword-quality-reviewing.mdc"
2677
2761
  },
2678
2762
  ".cursor/rules/safeword-refactoring.mdc": {
2679
2763
  template: "cursor/rules/safeword-refactoring.mdc"
2680
2764
  },
2765
+ ".cursor/rules/safeword-tdd-review.mdc": {
2766
+ template: "cursor/rules/safeword-tdd-review.mdc"
2767
+ },
2681
2768
  ".cursor/rules/safeword-testing.mdc": {
2682
2769
  template: "cursor/rules/safeword-testing.mdc"
2683
2770
  },
@@ -2858,6 +2945,8 @@ var PYPROJECT_TOML = "pyproject.toml";
2858
2945
  var CLIPPY_CONFIG_FILES = ["clippy.toml", ".clippy.toml"];
2859
2946
  var RUSTFMT_CONFIG_FILES = ["rustfmt.toml", ".rustfmt.toml"];
2860
2947
  var ESLINT_CONFIG_FILES = [
2948
+ "eslint.config.ts",
2949
+ "eslint.config.mts",
2861
2950
  "eslint.config.mjs",
2862
2951
  "eslint.config.js",
2863
2952
  "eslint.config.cjs",
@@ -3045,4 +3134,4 @@ export {
3045
3134
  detectLanguages2,
3046
3135
  createProjectContext
3047
3136
  };
3048
- //# sourceMappingURL=chunk-S6T3OR74.js.map
3137
+ //# sourceMappingURL=chunk-CWE7DTMG.js.map