feat(install): deny Edit and Write on the council config and state in every session

New scripts/council-deny.js holds the deny rules (SPOT) for ~/.claude/agents-council/** and, new, ~/.local/state/agents-council/**, where the skills' scripts keep state only they may change. enable-plugins.js takes them from it for <TARGET>/.claude/settings.local.json as before. The global install now also merges them into ~/.claude/settings.json, the only user-wide settings file, because a settings.local.json binds only sessions rooted in its own repository; the operator no longer edits settings by hand. The writer follows a settings symlink (dangling included), keeps the file mode, writes a 0600 wx temp file and renames it, and refuses invalid JSON or a non-object with exit 1 and the file untouched.

Tests: tests/test_dream.py 26 passed (denies once beside existing rules, user settings kept through a symlink with mode, dangling link kept, invalid JSON untouched with exit 1); two independent reviews, round 2 holds.

🎯 Fix: 93 %
💥 Break: 3 %
💸 Cost: 100 %
⏱️ Time: 100 %
🛡️ Security: 100 %
🏆 Score: 90
🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-13 11:22:49 +00:00
1 parent 3418738993
commit c17ac79258
5 files changed
+111 -6

No files matched your search

+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env node
"use strict";
const fs = require("fs");
const path = require("path");
const COUNCIL_DENY = ["Edit(~/.claude/agents-council/**)", "Edit(~/.local/state/agents-council/**)"];
function withCouncilDeny(data) {
data.permissions = data.permissions || {};
data.permissions.deny = [...new Set([...(data.permissions.deny || []), ...COUNCIL_DENY])];
return data;
}
module.exports = { COUNCIL_DENY, withCouncilDeny };
function resolved(settingsPath) {
let link;
try {
link = fs.lstatSync(settingsPath).isSymbolicLink();
} catch (err) {
if (err.code === "ENOENT") return settingsPath;
throw err;
}
if (!link) return settingsPath;
if (fs.existsSync(settingsPath)) return fs.realpathSync(settingsPath);
return path.resolve(path.dirname(settingsPath), fs.readlinkSync(settingsPath));
}
function main(settingsPath) {
if (!settingsPath) {
console.error("usage: council-deny.js <settings.json>");
return 2;
}
const target = resolved(settingsPath);
let data = {};
let mode = 0o600;
if (fs.existsSync(target)) {
mode = fs.statSync(target).mode & 0o777;
const raw = fs.readFileSync(target, "utf8").trim();
if (raw) {
try {
data = JSON.parse(raw);
} catch (err) {
console.error(`skills: ${settingsPath} is not valid JSON; leaving it untouched (${err.message}).`);
return 1;
}
}
}
if (typeof data !== "object" || data === null || Array.isArray(data)) {
console.error(`skills: ${settingsPath} holds no JSON object; leaving it untouched.`);
return 1;
}
const temporary = `${target}.${process.pid}`;
try {
fs.writeFileSync(temporary, JSON.stringify(withCouncilDeny(data), null, 2) + "\n", { mode, flag: "wx" });
fs.chmodSync(temporary, mode);
fs.renameSync(temporary, target);
} catch (err) {
fs.rmSync(temporary, { force: true });
throw err;
}
console.log(`skills: Edit and Write on ${COUNCIL_DENY.length} council paths denied in ${settingsPath}`);
return 0;
}
if (require.main === module) process.exit(main(process.argv[2]));
+1 -3
View File
@@ -62,9 +62,7 @@ data.env = data.env || {};
if (!data.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW) data.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW = "500000";
const PYTHON = "/usr/bin/python3 -I";
const ABSOLUTE = { python3: PYTHON, bash: "/usr/bin/bash" };
const COUNCIL_CONFIG_DENY = "Edit(~/.claude/agents-council/**)";
data.permissions = data.permissions || {};
data.permissions.deny = [...new Set([...(data.permissions.deny || []), COUNCIL_CONFIG_DENY])];
require("./council-deny").withCouncilDeny(data);
const pluginRepos = new Set(Object.values(MARKETPLACES).map((entry) => entry.source.repo));
const lock = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "skills-lock.json"), "utf8"));
+3
View File
@@ -61,6 +61,9 @@ settings="${TARGET}/.claude/settings.local.json"
if command -v node &>/dev/null; then
log "skills: auto-enabling caveman + ponytail plugins in ${settings}"
node "${REPO_ROOT}/scripts/enable-plugins.js" "${settings}"
if [[ "${TARGET}" -ef "${HOME}" ]]; then
node "${REPO_ROOT}/scripts/council-deny.js" "${HOME}/.claude/settings.json"
fi
else
warn "skills: node not found; skipped auto-enabling caveman/ponytail plugins."
fi