claude-warden 1.1.5 → 1.1.7

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.cjs +161 -74
  2. package/package.json +11 -10
package/dist/index.cjs CHANGED
@@ -18139,6 +18139,10 @@ var require_dist2 = __commonJS({
18139
18139
  var import_bash_parser = __toESM(require_src(), 1);
18140
18140
  var import_path = require("path");
18141
18141
  var HEREDOC_REGEX = /<<-?\s*['"]?\w+['"]?/;
18142
+ function preprocessCatHeredocs(input) {
18143
+ const regex = /\$\(cat\s+<<-?\s*['"]?(\w+)['"]?\n([\s\S]*?)\n\1\s*\)/g;
18144
+ return input.replace(regex, "__HEREDOC_TEXT__");
18145
+ }
18142
18146
  function convertCommand(node) {
18143
18147
  if (!node.name) return null;
18144
18148
  const command = node.name.text.includes("/") ? (0, import_path.basename)(node.name.text) : node.name.text;
@@ -18258,6 +18262,7 @@ function parseCommand(input) {
18258
18262
  if (!input || !input.trim()) {
18259
18263
  return { commands: [], hasSubshell: false, subshellCommands: [], parseError: false };
18260
18264
  }
18265
+ input = preprocessCatHeredocs(input);
18261
18266
  const hasHeredoc = HEREDOC_REGEX.test(input);
18262
18267
  if (hasHeredoc) {
18263
18268
  const firstLine = input.split("\n")[0];
@@ -18784,6 +18789,144 @@ var import_os = require("os");
18784
18789
  var import_path2 = require("path");
18785
18790
 
18786
18791
  // src/defaults.ts
18792
+ var SAFE_DEV_TOOLS = [
18793
+ "jest",
18794
+ "vitest",
18795
+ "tsc",
18796
+ "eslint",
18797
+ "prettier",
18798
+ "mkdirp",
18799
+ "concurrently",
18800
+ "turbo",
18801
+ "next",
18802
+ "nuxt",
18803
+ "vite",
18804
+ "astro",
18805
+ "playwright",
18806
+ "cypress",
18807
+ "mocha",
18808
+ "nyc",
18809
+ "c8",
18810
+ "ts-jest",
18811
+ "tsup",
18812
+ "esbuild",
18813
+ "rollup",
18814
+ "webpack",
18815
+ "prisma",
18816
+ "drizzle-kit",
18817
+ "typeorm",
18818
+ "knex",
18819
+ "sequelize-cli",
18820
+ "tailwindcss",
18821
+ "postcss",
18822
+ "autoprefixer",
18823
+ "lint-staged",
18824
+ "husky",
18825
+ "changeset",
18826
+ "semantic-release",
18827
+ "lerna",
18828
+ "nx",
18829
+ "create-react-app",
18830
+ "create-next-app",
18831
+ "create-vite",
18832
+ "degit",
18833
+ "storybook",
18834
+ "wrangler",
18835
+ "netlify",
18836
+ "vercel",
18837
+ "json"
18838
+ ];
18839
+ var SCRIPT_RUNNERS = ["tsx", "ts-node", "nodemon"];
18840
+ var REGISTRY_OPS = ["publish", "unpublish", "deprecate", "owner", "access", "token", "adduser", "login", "logout"];
18841
+ var SAFE_PKG_MANAGER_CMDS = [
18842
+ "install",
18843
+ "add",
18844
+ "remove",
18845
+ "uninstall",
18846
+ "update",
18847
+ "upgrade",
18848
+ "outdated",
18849
+ "ls",
18850
+ "list",
18851
+ "run",
18852
+ "test",
18853
+ "start",
18854
+ "build",
18855
+ "init",
18856
+ "create",
18857
+ "info",
18858
+ "view",
18859
+ "show",
18860
+ "why",
18861
+ "pack",
18862
+ "cache",
18863
+ "config",
18864
+ "get",
18865
+ "set",
18866
+ "version",
18867
+ "help",
18868
+ "exec",
18869
+ "dedupe",
18870
+ "prune",
18871
+ "audit",
18872
+ "completion"
18873
+ ];
18874
+ var VERSION_HELP_FLAGS = {
18875
+ match: { anyArgMatches: ["^--(version|help)$", "^-[vh]$"] },
18876
+ decision: "allow",
18877
+ description: "Version/help flags"
18878
+ };
18879
+ function anyArgMatchesPattern(items) {
18880
+ return `^(${items.join("|")})$`;
18881
+ }
18882
+ function safeDevToolsPattern() {
18883
+ return {
18884
+ match: { anyArgMatches: [anyArgMatchesPattern(SAFE_DEV_TOOLS)] },
18885
+ decision: "allow",
18886
+ description: "Well-known dev tools"
18887
+ };
18888
+ }
18889
+ function scriptRunnersPattern() {
18890
+ return {
18891
+ match: { anyArgMatches: [anyArgMatchesPattern(SCRIPT_RUNNERS)] },
18892
+ decision: "ask",
18893
+ reason: "Script runners can execute arbitrary code"
18894
+ };
18895
+ }
18896
+ function registryOpsPattern() {
18897
+ return {
18898
+ match: { anyArgMatches: [anyArgMatchesPattern(REGISTRY_OPS)] },
18899
+ decision: "ask",
18900
+ reason: "Registry modification"
18901
+ };
18902
+ }
18903
+ function pkgManagerRule(command, extraSafeCmds = []) {
18904
+ const safeCmds = [...SAFE_PKG_MANAGER_CMDS, ...extraSafeCmds];
18905
+ return {
18906
+ command,
18907
+ default: "ask",
18908
+ argPatterns: [
18909
+ registryOpsPattern(),
18910
+ {
18911
+ match: { anyArgMatches: [anyArgMatchesPattern(safeCmds)] },
18912
+ decision: "allow",
18913
+ description: `Standard ${command} commands`
18914
+ },
18915
+ VERSION_HELP_FLAGS
18916
+ ]
18917
+ };
18918
+ }
18919
+ function pkgRunnerRule(command) {
18920
+ return {
18921
+ command,
18922
+ default: "ask",
18923
+ argPatterns: [
18924
+ safeDevToolsPattern(),
18925
+ scriptRunnersPattern(),
18926
+ VERSION_HELP_FLAGS
18927
+ ]
18928
+ };
18929
+ }
18787
18930
  var DEFAULT_CONFIG = {
18788
18931
  defaultDecision: "ask",
18789
18932
  askOnSubshell: true,
@@ -18945,27 +19088,13 @@ var DEFAULT_CONFIG = {
18945
19088
  ]
18946
19089
  },
18947
19090
  // --- Shell interpreters ---
18948
- {
18949
- command: "bash",
18950
- default: "ask",
18951
- argPatterns: [
18952
- { match: { anyArgMatches: ["^--(version|help)$"] }, decision: "allow", description: "Version/help flags" }
18953
- ]
18954
- },
18955
- {
18956
- command: "sh",
18957
- default: "ask",
18958
- argPatterns: [
18959
- { match: { anyArgMatches: ["^--(version|help)$"] }, decision: "allow", description: "Version/help flags" }
18960
- ]
18961
- },
18962
- {
18963
- command: "zsh",
19091
+ ...["bash", "sh", "zsh"].map((cmd) => ({
19092
+ command: cmd,
18964
19093
  default: "ask",
18965
19094
  argPatterns: [
18966
19095
  { match: { anyArgMatches: ["^--(version|help)$"] }, decision: "allow", description: "Version/help flags" }
18967
19096
  ]
18968
- },
19097
+ })),
18969
19098
  // --- Node.js ecosystem ---
18970
19099
  {
18971
19100
  command: "node",
@@ -18976,74 +19105,32 @@ var DEFAULT_CONFIG = {
18976
19105
  { match: { noArgs: true }, decision: "ask", reason: "Interactive REPL" }
18977
19106
  ]
18978
19107
  },
18979
- {
18980
- command: "npx",
18981
- default: "ask",
18982
- argPatterns: [
18983
- {
18984
- match: { anyArgMatches: ["^(jest|vitest|tsx|ts-node|tsc|eslint|prettier|mkdirp|concurrently|turbo|next|nuxt|vite|astro|playwright|cypress|mocha|nyc|c8|nodemon|ts-jest|tsup|esbuild|rollup|webpack|prisma|drizzle-kit|typeorm|knex|sequelize-cli|tailwindcss|postcss|autoprefixer|lint-staged|husky|changeset|semantic-release|lerna|nx|create-react-app|create-next-app|create-vite|degit|storybook|wrangler|netlify|vercel|json)$"] },
18985
- decision: "allow",
18986
- description: "Well-known dev tools"
18987
- },
18988
- { match: { anyArgMatches: ["^--(version|help)$", "^-[vh]$"] }, decision: "allow", description: "Version/help flags" }
18989
- ]
18990
- },
18991
- {
18992
- command: "bunx",
18993
- default: "ask",
18994
- argPatterns: [
18995
- {
18996
- match: { anyArgMatches: ["^(jest|vitest|tsx|ts-node|tsc|eslint|prettier|mkdirp|concurrently|turbo|next|nuxt|vite|astro|playwright|cypress|mocha|nyc|c8|nodemon|ts-jest|tsup|esbuild|rollup|webpack|prisma|drizzle-kit|typeorm|knex|sequelize-cli|tailwindcss|postcss|autoprefixer|lint-staged|husky|changeset|semantic-release|lerna|nx|create-react-app|create-next-app|create-vite|degit|storybook|wrangler|netlify|vercel|json)$"] },
18997
- decision: "allow",
18998
- description: "Well-known dev tools"
18999
- },
19000
- { match: { anyArgMatches: ["^--(version|help)$", "^-[vh]$"] }, decision: "allow", description: "Version/help flags" }
19001
- ]
19002
- },
19003
- {
19004
- command: "npm",
19005
- default: "allow",
19006
- argPatterns: [
19007
- { match: { anyArgMatches: ["^(publish|unpublish|deprecate|owner|access|token|adduser|login)$"] }, decision: "ask", reason: "Registry modification" }
19008
- ]
19009
- },
19010
- {
19011
- command: "pnpm",
19012
- default: "allow",
19013
- argPatterns: [
19014
- { match: { anyArgMatches: ["^(publish|unpublish|deprecate|owner|access|token|adduser|login)$"] }, decision: "ask", reason: "Registry modification" }
19015
- ]
19016
- },
19017
- {
19018
- command: "yarn",
19019
- default: "allow",
19020
- argPatterns: [
19021
- { match: { anyArgMatches: ["^(publish|unpublish|owner|access|token|login|logout)$"] }, decision: "ask", reason: "Registry modification" }
19022
- ]
19023
- },
19108
+ // npx / bunx — package runners
19109
+ pkgRunnerRule("npx"),
19110
+ pkgRunnerRule("bunx"),
19111
+ // npm / pnpm / yarn — package managers
19112
+ pkgManagerRule("npm", ["ci", "search", "explain", "prefix", "root", "fund", "doctor", "diff", "pkg", "query", "shrinkwrap"]),
19113
+ pkgManagerRule("pnpm", ["store", "fetch", "doctor", "patch"]),
19114
+ pkgManagerRule("yarn", ["up", "dlx", "workspaces"]),
19115
+ // bun runtime + package manager
19024
19116
  {
19025
19117
  command: "bun",
19026
19118
  default: "ask",
19027
19119
  argPatterns: [
19028
- { match: { anyArgMatches: ["^(install|add|remove|run|test|build|init|create|pm|x|upgrade|link|unlink)$"] }, decision: "allow", description: "Standard bun commands" },
19029
- { match: { anyArgMatches: ["^--(version|help)$"] }, decision: "allow" }
19120
+ { match: { anyArgMatches: [anyArgMatchesPattern([...SAFE_PKG_MANAGER_CMDS, "ci", "pm", "x", "link", "unlink"])] }, decision: "allow", description: "Standard bun commands" },
19121
+ safeDevToolsPattern(),
19122
+ scriptRunnersPattern(),
19123
+ VERSION_HELP_FLAGS
19030
19124
  ]
19031
19125
  },
19032
19126
  // --- Python ---
19033
- {
19034
- command: "python",
19127
+ ...["python", "python3"].map((cmd) => ({
19128
+ command: cmd,
19035
19129
  default: "ask",
19036
19130
  argPatterns: [
19037
19131
  { match: { anyArgMatches: ["^--(version|help)$", "^-V$"] }, decision: "allow" }
19038
19132
  ]
19039
- },
19040
- {
19041
- command: "python3",
19042
- default: "ask",
19043
- argPatterns: [
19044
- { match: { anyArgMatches: ["^--(version|help)$", "^-V$"] }, decision: "allow" }
19045
- ]
19046
- },
19133
+ })),
19047
19134
  { command: "pip", default: "allow" },
19048
19135
  { command: "pip3", default: "allow" },
19049
19136
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-warden",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "Smart command safety filter for Claude Code — auto-approves safe commands, blocks dangerous ones",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -28,6 +28,15 @@
28
28
  "README.md",
29
29
  "LICENSE"
30
30
  ],
31
+ "scripts": {
32
+ "build": "tsup",
33
+ "dev": "tsup --watch",
34
+ "test": "vitest run",
35
+ "test:watch": "vitest",
36
+ "typecheck": "tsc --noEmit",
37
+ "eval": "node dist/index.cjs",
38
+ "prepublishOnly": "pnpm run build && pnpm run test"
39
+ },
31
40
  "devDependencies": {
32
41
  "@types/node": "^20.0.0",
33
42
  "bash-parser": "^0.5.0",
@@ -35,13 +44,5 @@
35
44
  "typescript": "^5.4.0",
36
45
  "vitest": "^1.6.0",
37
46
  "yaml": "^2.4.0"
38
- },
39
- "scripts": {
40
- "build": "tsup",
41
- "dev": "tsup --watch",
42
- "test": "vitest run",
43
- "test:watch": "vitest",
44
- "typecheck": "tsc --noEmit",
45
- "eval": "node dist/index.cjs"
46
47
  }
47
- }
48
+ }