claude-warden 2.3.2 → 2.4.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.github/hooks/warden.json +12 -0
- package/README.md +58 -1
- package/dist/cli.cjs +20705 -0
- package/dist/codex-export.cjs +54 -48
- package/dist/copilot.cjs +20678 -0
- package/dist/index.cjs +8 -5
- package/package.json +9 -2
package/dist/codex-export.cjs
CHANGED
|
@@ -18134,9 +18134,6 @@ var require_dist2 = __commonJS({
|
|
|
18134
18134
|
var import_fs2 = require("fs");
|
|
18135
18135
|
var import_path4 = require("path");
|
|
18136
18136
|
|
|
18137
|
-
// src/evaluator.ts
|
|
18138
|
-
var import_os = require("os");
|
|
18139
|
-
|
|
18140
18137
|
// src/parser.ts
|
|
18141
18138
|
var import_bash_parser = __toESM(require_src(), 1);
|
|
18142
18139
|
var import_path = require("path");
|
|
@@ -18456,6 +18453,9 @@ function regexFallbackParse(input) {
|
|
|
18456
18453
|
return { command, originalCommand, args: args2, envPrefixes, raw: trimmed };
|
|
18457
18454
|
}
|
|
18458
18455
|
|
|
18456
|
+
// src/evaluator.ts
|
|
18457
|
+
var import_os = require("os");
|
|
18458
|
+
|
|
18459
18459
|
// src/targets.ts
|
|
18460
18460
|
var import_path2 = require("path");
|
|
18461
18461
|
|
|
@@ -19564,51 +19564,6 @@ function evaluateFlyCommand(cmd, config, targets, depth = 0) {
|
|
|
19564
19564
|
};
|
|
19565
19565
|
}
|
|
19566
19566
|
|
|
19567
|
-
// src/codex.ts
|
|
19568
|
-
function toCodexDecision(decision) {
|
|
19569
|
-
if (decision === "allow") return "allow";
|
|
19570
|
-
if (decision === "ask") return "prompt";
|
|
19571
|
-
return "forbidden";
|
|
19572
|
-
}
|
|
19573
|
-
function quote(value) {
|
|
19574
|
-
return JSON.stringify(value);
|
|
19575
|
-
}
|
|
19576
|
-
function collectCandidateCommands(config) {
|
|
19577
|
-
const names = /* @__PURE__ */ new Set();
|
|
19578
|
-
for (const layer of config.layers) {
|
|
19579
|
-
for (const name of layer.alwaysAllow) names.add(name);
|
|
19580
|
-
for (const name of layer.alwaysDeny) names.add(name);
|
|
19581
|
-
for (const rule of layer.rules) names.add(rule.command);
|
|
19582
|
-
}
|
|
19583
|
-
return [...names].map((n) => n.trim()).filter((n) => n.length > 0 && !/\s/.test(n)).sort();
|
|
19584
|
-
}
|
|
19585
|
-
function buildCodexRuleRecords(config) {
|
|
19586
|
-
const records = [];
|
|
19587
|
-
for (const command of collectCandidateCommands(config)) {
|
|
19588
|
-
const result = evaluate(parseCommand(command), config);
|
|
19589
|
-
records.push({
|
|
19590
|
-
command,
|
|
19591
|
-
decision: result.decision,
|
|
19592
|
-
reason: result.reason
|
|
19593
|
-
});
|
|
19594
|
-
}
|
|
19595
|
-
return records;
|
|
19596
|
-
}
|
|
19597
|
-
function generateCodexRules(config) {
|
|
19598
|
-
const lines = [
|
|
19599
|
-
"# Generated by claude-warden.",
|
|
19600
|
-
"# Regenerate with: pnpm codex:export-rules",
|
|
19601
|
-
""
|
|
19602
|
-
];
|
|
19603
|
-
for (const record of buildCodexRuleRecords(config)) {
|
|
19604
|
-
lines.push(
|
|
19605
|
-
`prefix_rule(pattern = [${quote(record.command)}], decision = ${quote(toCodexDecision(record.decision))}, justification = ${quote(`Warden: ${record.reason}`)})`
|
|
19606
|
-
);
|
|
19607
|
-
}
|
|
19608
|
-
lines.push("");
|
|
19609
|
-
return lines.join("\n");
|
|
19610
|
-
}
|
|
19611
|
-
|
|
19612
19567
|
// src/rules.ts
|
|
19613
19568
|
var import_fs = require("fs");
|
|
19614
19569
|
var import_yaml = __toESM(require_dist2(), 1);
|
|
@@ -20649,6 +20604,57 @@ function mergeNonLayerFields(config, raw) {
|
|
|
20649
20604
|
}
|
|
20650
20605
|
}
|
|
20651
20606
|
|
|
20607
|
+
// src/core.ts
|
|
20608
|
+
function wardenEvalWithConfig(command, config, cwd) {
|
|
20609
|
+
const parsed = parseCommand(command);
|
|
20610
|
+
return evaluate(parsed, config, cwd);
|
|
20611
|
+
}
|
|
20612
|
+
|
|
20613
|
+
// src/codex.ts
|
|
20614
|
+
function toCodexDecision(decision) {
|
|
20615
|
+
if (decision === "allow") return "allow";
|
|
20616
|
+
if (decision === "ask") return "prompt";
|
|
20617
|
+
return "forbidden";
|
|
20618
|
+
}
|
|
20619
|
+
function quote(value) {
|
|
20620
|
+
return JSON.stringify(value);
|
|
20621
|
+
}
|
|
20622
|
+
function collectCandidateCommands(config) {
|
|
20623
|
+
const names = /* @__PURE__ */ new Set();
|
|
20624
|
+
for (const layer of config.layers) {
|
|
20625
|
+
for (const name of layer.alwaysAllow) names.add(name);
|
|
20626
|
+
for (const name of layer.alwaysDeny) names.add(name);
|
|
20627
|
+
for (const rule of layer.rules) names.add(rule.command);
|
|
20628
|
+
}
|
|
20629
|
+
return [...names].map((n) => n.trim()).filter((n) => n.length > 0 && !/\s/.test(n)).sort();
|
|
20630
|
+
}
|
|
20631
|
+
function buildCodexRuleRecords(config) {
|
|
20632
|
+
const records = [];
|
|
20633
|
+
for (const command of collectCandidateCommands(config)) {
|
|
20634
|
+
const result = wardenEvalWithConfig(command, config);
|
|
20635
|
+
records.push({
|
|
20636
|
+
command,
|
|
20637
|
+
decision: result.decision,
|
|
20638
|
+
reason: result.reason
|
|
20639
|
+
});
|
|
20640
|
+
}
|
|
20641
|
+
return records;
|
|
20642
|
+
}
|
|
20643
|
+
function generateCodexRules(config) {
|
|
20644
|
+
const lines = [
|
|
20645
|
+
"# Generated by claude-warden.",
|
|
20646
|
+
"# Regenerate with: pnpm codex:export-rules",
|
|
20647
|
+
""
|
|
20648
|
+
];
|
|
20649
|
+
for (const record of buildCodexRuleRecords(config)) {
|
|
20650
|
+
lines.push(
|
|
20651
|
+
`prefix_rule(pattern = [${quote(record.command)}], decision = ${quote(toCodexDecision(record.decision))}, justification = ${quote(`Warden: ${record.reason}`)})`
|
|
20652
|
+
);
|
|
20653
|
+
}
|
|
20654
|
+
lines.push("");
|
|
20655
|
+
return lines.join("\n");
|
|
20656
|
+
}
|
|
20657
|
+
|
|
20652
20658
|
// src/codex-export.ts
|
|
20653
20659
|
function parseArgs(argv) {
|
|
20654
20660
|
let cwd = process.cwd();
|