safeword 0.30.2 → 0.31.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 (28) hide show
  1. package/dist/{check-KU5QI4TK.js → check-ASCK2RGI.js} +2 -2
  2. package/dist/{chunk-VKYVBKM6.js → chunk-S6T3OR74.js} +53 -30
  3. package/dist/chunk-S6T3OR74.js.map +1 -0
  4. package/dist/{chunk-37EMD6NO.js → chunk-WHBITLEV.js} +2 -2
  5. package/dist/cli.js +5 -5
  6. package/dist/{diff-NUCYYB5G.js → diff-MHN76NZR.js} +2 -2
  7. package/dist/{reset-DRUPPK3U.js → reset-JCR2CGGV.js} +2 -2
  8. package/dist/{setup-UBRPTBRY.js → setup-MVKAEMEM.js} +3 -3
  9. package/dist/{upgrade-I4T5ULZO.js → upgrade-NS3QWFUY.js} +3 -3
  10. package/package.json +1 -1
  11. package/templates/commands/audit.md +6 -0
  12. package/templates/commands/verify.md +56 -16
  13. package/templates/hooks/lib/quality.ts +91 -70
  14. package/templates/hooks/lib/skill-invocation-log.ts +87 -0
  15. package/templates/hooks/lib/update-cache.ts +65 -0
  16. package/templates/hooks/lib/version.ts +79 -0
  17. package/templates/hooks/session-auto-upgrade.ts +163 -0
  18. package/templates/hooks/session-update-check.ts +81 -0
  19. package/templates/hooks/stop-quality.ts +46 -3
  20. package/templates/skills/audit/SKILL.md +6 -0
  21. package/templates/skills/verify/SKILL.md +58 -39
  22. package/dist/chunk-VKYVBKM6.js.map +0 -1
  23. /package/dist/{check-KU5QI4TK.js.map → check-ASCK2RGI.js.map} +0 -0
  24. /package/dist/{chunk-37EMD6NO.js.map → chunk-WHBITLEV.js.map} +0 -0
  25. /package/dist/{diff-NUCYYB5G.js.map → diff-MHN76NZR.js.map} +0 -0
  26. /package/dist/{reset-DRUPPK3U.js.map → reset-JCR2CGGV.js.map} +0 -0
  27. /package/dist/{setup-UBRPTBRY.js.map → setup-MVKAEMEM.js.map} +0 -0
  28. /package/dist/{upgrade-I4T5ULZO.js.map → upgrade-NS3QWFUY.js.map} +0 -0
@@ -6,7 +6,7 @@ import {
6
6
  createProjectContext,
7
7
  getMissingPacks,
8
8
  reconcile
9
- } from "./chunk-VKYVBKM6.js";
9
+ } from "./chunk-S6T3OR74.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-KU5QI4TK.js.map
192
+ //# sourceMappingURL=check-ASCK2RGI.js.map
@@ -33,6 +33,7 @@ function setupGoTooling() {
33
33
 
34
34
  // src/packs/config.ts
35
35
  import nodePath from "path";
36
+ import process2 from "process";
36
37
  var CONFIG_PATH = ".safeword/config.json";
37
38
  function readConfig(cwd) {
38
39
  const configPath = nodePath.join(cwd, CONFIG_PATH);
@@ -507,14 +508,11 @@ function planMissingDirectories(directories, cwd, isGitRepo2) {
507
508
  }
508
509
  return { actions, created };
509
510
  }
510
- function planTextPatches(patches, cwd, isGitRepo2) {
511
+ function planTextPatches(patches, isGitRepo2) {
511
512
  const actions = [];
512
513
  for (const [filePath, definition] of Object.entries(patches)) {
513
514
  if (shouldSkipForNonGit(filePath, isGitRepo2)) continue;
514
- const content = readFileSafe(nodePath7.join(cwd, filePath)) ?? "";
515
- if (!content.includes(definition.marker)) {
516
- actions.push({ type: "text-patch", path: filePath, definition });
517
- }
515
+ actions.push({ type: "text-patch", path: filePath, definition });
518
516
  }
519
517
  return actions;
520
518
  }
@@ -536,18 +534,6 @@ function planOwnedFileWrites(files, ctx) {
536
534
  function planManagedFileWrites(files, ctx) {
537
535
  return planFileWrites(files, ctx, (filePath, c) => exists(nodePath7.join(c.cwd, filePath)));
538
536
  }
539
- function planTextPatchesWithCreation(patches, ctx) {
540
- const actions = [];
541
- const created = [];
542
- for (const [filePath, definition] of Object.entries(patches)) {
543
- if (shouldSkipForNonGit(filePath, ctx.isGitRepo)) continue;
544
- actions.push({ type: "text-patch", path: filePath, definition });
545
- if (definition.createIfMissing && !exists(nodePath7.join(ctx.cwd, filePath))) {
546
- created.push(filePath);
547
- }
548
- }
549
- return { actions, created };
550
- }
551
537
  function planExistingDirectoriesRemoval(directories, cwd) {
552
538
  const actions = [];
553
539
  const removed = [];
@@ -642,9 +628,13 @@ function computeInstallPlan(schema, ctx) {
642
628
  for (const [filePath, definition] of Object.entries(schema.jsonMerges)) {
643
629
  actions.push({ type: "json-merge", path: filePath, definition });
644
630
  }
645
- const patches = planTextPatchesWithCreation(schema.textPatches, ctx);
646
- actions.push(...patches.actions);
647
- wouldCreate.push(...patches.created);
631
+ const textPatchActions = planTextPatches(schema.textPatches, ctx.isGitRepo);
632
+ actions.push(...textPatchActions);
633
+ for (const action of textPatchActions) {
634
+ if (action.type === "text-patch" && !exists(nodePath7.join(ctx.cwd, action.path))) {
635
+ wouldCreate.push(action.path);
636
+ }
637
+ }
648
638
  const packagesToInstall = computePackagesToInstall(
649
639
  schema,
650
640
  ctx.projectType,
@@ -717,7 +707,7 @@ function computeUpgradePlan(schema, ctx) {
717
707
  for (const [filePath, definition] of Object.entries(schema.jsonMerges)) {
718
708
  actions.push({ type: "json-merge", path: filePath, definition });
719
709
  }
720
- actions.push(...planTextPatches(schema.textPatches, ctx.cwd, ctx.isGitRepo));
710
+ actions.push(...planTextPatches(schema.textPatches, ctx.isGitRepo));
721
711
  const packagesToInstall = computePackagesToInstall(
722
712
  schema,
723
713
  ctx.projectType,
@@ -1464,7 +1454,7 @@ var rustManagedFiles = {
1464
1454
  // src/packs/sql/dialect.ts
1465
1455
  import { existsSync as existsSync6, readFileSync as readFileSync5 } from "fs";
1466
1456
  import nodePath11 from "path";
1467
- import process2 from "process";
1457
+ import process3 from "process";
1468
1458
  import YAML2 from "yaml";
1469
1459
  var ADAPTER_TO_DIALECT = {
1470
1460
  postgres: "postgres",
@@ -1560,7 +1550,7 @@ function detectFromProfiles(cwd) {
1560
1550
  const candidates = [
1561
1551
  nodePath11.join(dbtProjectDirectory, "profiles.yml"),
1562
1552
  nodePath11.join(dbtProjectDirectory, "dbt", "profiles.yml"),
1563
- nodePath11.join(process2.env.HOME ?? "", ".dbt", "profiles.yml")
1553
+ nodePath11.join(process3.env.HOME ?? "", ".dbt", "profiles.yml")
1564
1554
  ];
1565
1555
  for (const profilesPath of candidates) {
1566
1556
  const adapterType = resolveProfileType(profilesPath, profileName);
@@ -1931,6 +1921,9 @@ var HOOKS_DIR = '"$CLAUDE_PROJECT_DIR"/.safeword/hooks';
1931
1921
  function hook(command) {
1932
1922
  return { hooks: [{ type: "command", command }] };
1933
1923
  }
1924
+ function asyncHook(command) {
1925
+ return { hooks: [{ type: "command", command, async: true }] };
1926
+ }
1934
1927
  function matchedHook(matcher, command) {
1935
1928
  return { matcher, hooks: [{ type: "command", command }] };
1936
1929
  }
@@ -1938,10 +1931,12 @@ var EDIT_TOOLS = "Edit|Write|MultiEdit|NotebookEdit";
1938
1931
  var SETTINGS_HOOKS = {
1939
1932
  SessionStart: [
1940
1933
  hook(`bash ${HOOKS_DIR}/session-bun-check.sh`),
1934
+ hook(`bun ${HOOKS_DIR}/session-auto-upgrade.ts`),
1941
1935
  hook(`bun ${HOOKS_DIR}/session-verify-agents.ts`),
1942
1936
  hook(`bun ${HOOKS_DIR}/session-version.ts`),
1943
1937
  hook(`bun ${HOOKS_DIR}/session-lint-check.ts`),
1944
- matchedHook("compact", `bun ${HOOKS_DIR}/session-compact-context.ts`)
1938
+ matchedHook("compact", `bun ${HOOKS_DIR}/session-compact-context.ts`),
1939
+ asyncHook(`bun ${HOOKS_DIR}/session-update-check.ts`)
1945
1940
  ],
1946
1941
  UserPromptSubmit: [
1947
1942
  hook(`bun ${HOOKS_DIR}/prompt-timestamp.ts`),
@@ -2497,8 +2492,13 @@ var SAFEWORD_SCHEMA = {
2497
2492
  ".safeword/hooks/lib/lint.ts": { template: "hooks/lib/lint.ts" },
2498
2493
  ".safeword/hooks/lib/quality.ts": { template: "hooks/lib/quality.ts" },
2499
2494
  ".safeword/hooks/lib/quality-state.ts": { template: "hooks/lib/quality-state.ts" },
2495
+ ".safeword/hooks/lib/skill-invocation-log.ts": {
2496
+ template: "hooks/lib/skill-invocation-log.ts"
2497
+ },
2500
2498
  ".safeword/hooks/lib/scenario-format.ts": { template: "hooks/lib/scenario-format.ts" },
2501
2499
  ".safeword/hooks/lib/test-runner.ts": { template: "hooks/lib/test-runner.ts" },
2500
+ ".safeword/hooks/lib/update-cache.ts": { template: "hooks/lib/update-cache.ts" },
2501
+ ".safeword/hooks/lib/version.ts": { template: "hooks/lib/version.ts" },
2502
2502
  // Hooks - TypeScript with Bun runtime
2503
2503
  ".safeword/hooks/session-verify-agents.ts": {
2504
2504
  template: "hooks/session-verify-agents.ts"
@@ -2533,6 +2533,12 @@ var SAFEWORD_SCHEMA = {
2533
2533
  ".safeword/hooks/pre-tool-config-guard.ts": {
2534
2534
  template: "hooks/pre-tool-config-guard.ts"
2535
2535
  },
2536
+ ".safeword/hooks/session-auto-upgrade.ts": {
2537
+ template: "hooks/session-auto-upgrade.ts"
2538
+ },
2539
+ ".safeword/hooks/session-update-check.ts": {
2540
+ template: "hooks/session-update-check.ts"
2541
+ },
2536
2542
  ".safeword/hooks/session-cleanup-quality.ts": {
2537
2543
  template: "hooks/session-cleanup-quality.ts"
2538
2544
  },
@@ -2804,8 +2810,7 @@ var SAFEWORD_SCHEMA = {
2804
2810
  "AGENTS.md": {
2805
2811
  operation: "prepend",
2806
2812
  content: AGENTS_MD_LINK,
2807
- marker: ".safeword/SAFEWORD.md",
2808
- createIfMissing: true
2813
+ marker: ".safeword/SAFEWORD.md"
2809
2814
  },
2810
2815
  "CLAUDE.md": {
2811
2816
  operation: "prepend",
@@ -2818,9 +2823,27 @@ var SAFEWORD_SCHEMA = {
2818
2823
  // backticks) still trigger prepending the new `@` import block on top.
2819
2824
  // Existing prose lingers harmlessly — agents skim it; only the import
2820
2825
  // is functionally load-bearing.
2821
- marker: "@./.safeword/SAFEWORD.md",
2822
- createIfMissing: false
2823
- // Only patch if exists, don't create (AGENTS.md is primary)
2826
+ marker: "@./.safeword/SAFEWORD.md"
2827
+ },
2828
+ ".gitignore": {
2829
+ operation: "append",
2830
+ content: "\n# Safeword - Local cache and transient state\n.safeword/.update-cache.json\n.safeword-project/quality-state*.json\n",
2831
+ marker: ".safeword/.update-cache.json"
2832
+ }
2833
+ },
2834
+ // Content predicate parity — files that must contain specific strings.
2835
+ // Different from ownedFiles (which requires byte equality between two files):
2836
+ // contracts assert one-way "this file must include these tokens" invariants.
2837
+ // Used by runParity() in src/parity.ts for both release tests and pre-commit
2838
+ // (see ticket 144). Path key = file relative to repo root.
2839
+ contracts: {
2840
+ "packages/cli/templates/hooks/lib/quality.ts": {
2841
+ // Cursor's stop hook imports QUALITY_REVIEW_MESSAGE. The export must exist
2842
+ // or Cursor users get a broken hook. The four marker strings (CONFIDENT,
2843
+ // BLOCKED, Tried:, Need:) define the binary-terminal shape from ticket 143.
2844
+ // Removing any of them would silently regress the prompt back to legacy
2845
+ // free-form review.
2846
+ requires: ["QUALITY_REVIEW_MESSAGE", "CONFIDENT", "BLOCKED", "Tried:", "Need:"]
2824
2847
  }
2825
2848
  },
2826
2849
  // NPM packages to install (JS/TS specific packages from typescript pack)
@@ -3022,4 +3045,4 @@ export {
3022
3045
  detectLanguages2,
3023
3046
  createProjectContext
3024
3047
  };
3025
- //# sourceMappingURL=chunk-VKYVBKM6.js.map
3048
+ //# sourceMappingURL=chunk-S6T3OR74.js.map