Merge branch 'feature/council-state-deny' into unify/skills-20261112-night
README.md conflict with the queue-cleanup timer sentence resolved by keeping both: the unify paragraph plus the council deny sentence. install.sh auto-merged (queue-cleanup state dir, pycache prune, council-deny call), shellcheck clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
590b430d37
5 files changed
+111
-6
No files matched your search
@@ -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]));
|
||||
@@ -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"));
|
||||
|
||||
@@ -62,6 +62,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
|
||||
|
||||
Reference in new issue
Block a user