safeword 0.30.3 → 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-VBN3JZIG.js → check-ASCK2RGI.js} +2 -2
  2. package/dist/{chunk-A52DHYLS.js → chunk-S6T3OR74.js} +50 -23
  3. package/dist/chunk-S6T3OR74.js.map +1 -0
  4. package/dist/{chunk-BKF5HT4X.js → chunk-WHBITLEV.js} +2 -2
  5. package/dist/cli.js +5 -5
  6. package/dist/{diff-BAVMQXPM.js → diff-MHN76NZR.js} +2 -2
  7. package/dist/{reset-PK4EDGHL.js → reset-JCR2CGGV.js} +2 -2
  8. package/dist/{setup-OYB44GSY.js → setup-MVKAEMEM.js} +3 -3
  9. package/dist/{upgrade-HPCP322I.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-A52DHYLS.js.map +0 -1
  23. /package/dist/{check-VBN3JZIG.js.map → check-ASCK2RGI.js.map} +0 -0
  24. /package/dist/{chunk-BKF5HT4X.js.map → chunk-WHBITLEV.js.map} +0 -0
  25. /package/dist/{diff-BAVMQXPM.js.map → diff-MHN76NZR.js.map} +0 -0
  26. /package/dist/{reset-PK4EDGHL.js.map → reset-JCR2CGGV.js.map} +0 -0
  27. /package/dist/{setup-OYB44GSY.js.map → setup-MVKAEMEM.js.map} +0 -0
  28. /package/dist/{upgrade-HPCP322I.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-A52DHYLS.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-VBN3JZIG.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);
@@ -533,17 +534,6 @@ function planOwnedFileWrites(files, ctx) {
533
534
  function planManagedFileWrites(files, ctx) {
534
535
  return planFileWrites(files, ctx, (filePath, c) => exists(nodePath7.join(c.cwd, filePath)));
535
536
  }
536
- function planTextPatchesWithCreation(patches, ctx) {
537
- const actions = planTextPatches(patches, ctx.isGitRepo);
538
- const created = [];
539
- for (const [filePath, definition] of Object.entries(patches)) {
540
- if (shouldSkipForNonGit(filePath, ctx.isGitRepo)) continue;
541
- if (definition.createIfMissing && !exists(nodePath7.join(ctx.cwd, filePath))) {
542
- created.push(filePath);
543
- }
544
- }
545
- return { actions, created };
546
- }
547
537
  function planExistingDirectoriesRemoval(directories, cwd) {
548
538
  const actions = [];
549
539
  const removed = [];
@@ -638,9 +628,13 @@ function computeInstallPlan(schema, ctx) {
638
628
  for (const [filePath, definition] of Object.entries(schema.jsonMerges)) {
639
629
  actions.push({ type: "json-merge", path: filePath, definition });
640
630
  }
641
- const patches = planTextPatchesWithCreation(schema.textPatches, ctx);
642
- actions.push(...patches.actions);
643
- 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
+ }
644
638
  const packagesToInstall = computePackagesToInstall(
645
639
  schema,
646
640
  ctx.projectType,
@@ -1460,7 +1454,7 @@ var rustManagedFiles = {
1460
1454
  // src/packs/sql/dialect.ts
1461
1455
  import { existsSync as existsSync6, readFileSync as readFileSync5 } from "fs";
1462
1456
  import nodePath11 from "path";
1463
- import process2 from "process";
1457
+ import process3 from "process";
1464
1458
  import YAML2 from "yaml";
1465
1459
  var ADAPTER_TO_DIALECT = {
1466
1460
  postgres: "postgres",
@@ -1556,7 +1550,7 @@ function detectFromProfiles(cwd) {
1556
1550
  const candidates = [
1557
1551
  nodePath11.join(dbtProjectDirectory, "profiles.yml"),
1558
1552
  nodePath11.join(dbtProjectDirectory, "dbt", "profiles.yml"),
1559
- nodePath11.join(process2.env.HOME ?? "", ".dbt", "profiles.yml")
1553
+ nodePath11.join(process3.env.HOME ?? "", ".dbt", "profiles.yml")
1560
1554
  ];
1561
1555
  for (const profilesPath of candidates) {
1562
1556
  const adapterType = resolveProfileType(profilesPath, profileName);
@@ -1927,6 +1921,9 @@ var HOOKS_DIR = '"$CLAUDE_PROJECT_DIR"/.safeword/hooks';
1927
1921
  function hook(command) {
1928
1922
  return { hooks: [{ type: "command", command }] };
1929
1923
  }
1924
+ function asyncHook(command) {
1925
+ return { hooks: [{ type: "command", command, async: true }] };
1926
+ }
1930
1927
  function matchedHook(matcher, command) {
1931
1928
  return { matcher, hooks: [{ type: "command", command }] };
1932
1929
  }
@@ -1934,10 +1931,12 @@ var EDIT_TOOLS = "Edit|Write|MultiEdit|NotebookEdit";
1934
1931
  var SETTINGS_HOOKS = {
1935
1932
  SessionStart: [
1936
1933
  hook(`bash ${HOOKS_DIR}/session-bun-check.sh`),
1934
+ hook(`bun ${HOOKS_DIR}/session-auto-upgrade.ts`),
1937
1935
  hook(`bun ${HOOKS_DIR}/session-verify-agents.ts`),
1938
1936
  hook(`bun ${HOOKS_DIR}/session-version.ts`),
1939
1937
  hook(`bun ${HOOKS_DIR}/session-lint-check.ts`),
1940
- 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`)
1941
1940
  ],
1942
1941
  UserPromptSubmit: [
1943
1942
  hook(`bun ${HOOKS_DIR}/prompt-timestamp.ts`),
@@ -2493,8 +2492,13 @@ var SAFEWORD_SCHEMA = {
2493
2492
  ".safeword/hooks/lib/lint.ts": { template: "hooks/lib/lint.ts" },
2494
2493
  ".safeword/hooks/lib/quality.ts": { template: "hooks/lib/quality.ts" },
2495
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
+ },
2496
2498
  ".safeword/hooks/lib/scenario-format.ts": { template: "hooks/lib/scenario-format.ts" },
2497
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" },
2498
2502
  // Hooks - TypeScript with Bun runtime
2499
2503
  ".safeword/hooks/session-verify-agents.ts": {
2500
2504
  template: "hooks/session-verify-agents.ts"
@@ -2529,6 +2533,12 @@ var SAFEWORD_SCHEMA = {
2529
2533
  ".safeword/hooks/pre-tool-config-guard.ts": {
2530
2534
  template: "hooks/pre-tool-config-guard.ts"
2531
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
+ },
2532
2542
  ".safeword/hooks/session-cleanup-quality.ts": {
2533
2543
  template: "hooks/session-cleanup-quality.ts"
2534
2544
  },
@@ -2800,8 +2810,7 @@ var SAFEWORD_SCHEMA = {
2800
2810
  "AGENTS.md": {
2801
2811
  operation: "prepend",
2802
2812
  content: AGENTS_MD_LINK,
2803
- marker: ".safeword/SAFEWORD.md",
2804
- createIfMissing: true
2813
+ marker: ".safeword/SAFEWORD.md"
2805
2814
  },
2806
2815
  "CLAUDE.md": {
2807
2816
  operation: "prepend",
@@ -2814,9 +2823,27 @@ var SAFEWORD_SCHEMA = {
2814
2823
  // backticks) still trigger prepending the new `@` import block on top.
2815
2824
  // Existing prose lingers harmlessly — agents skim it; only the import
2816
2825
  // is functionally load-bearing.
2817
- marker: "@./.safeword/SAFEWORD.md",
2818
- createIfMissing: false
2819
- // 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:"]
2820
2847
  }
2821
2848
  },
2822
2849
  // NPM packages to install (JS/TS specific packages from typescript pack)
@@ -3018,4 +3045,4 @@ export {
3018
3045
  detectLanguages2,
3019
3046
  createProjectContext
3020
3047
  };
3021
- //# sourceMappingURL=chunk-A52DHYLS.js.map
3048
+ //# sourceMappingURL=chunk-S6T3OR74.js.map