pruff-skills 1.5.0 → 1.5.2
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/dist/cli.mjs +44 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -6384,6 +6384,25 @@ function applyOwnedEnv(settings, desired, previouslyOwned) {
|
|
|
6384
6384
|
keptUserValues
|
|
6385
6385
|
};
|
|
6386
6386
|
}
|
|
6387
|
+
function addAllowEntries(settings, permissionAllow, autoModeAllow) {
|
|
6388
|
+
const isObject = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
6389
|
+
const strings = (value) => Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
|
|
6390
|
+
const merge = (current, added) => [...current, ...added.filter((entry) => !current.includes(entry))];
|
|
6391
|
+
const permissions = isObject(settings.permissions) ? settings.permissions : {};
|
|
6392
|
+
const autoMode = isObject(settings.autoMode) ? settings.autoMode : {};
|
|
6393
|
+
const currentAutoAllow = Array.isArray(autoMode.allow) ? strings(autoMode.allow) : ["$defaults"];
|
|
6394
|
+
return {
|
|
6395
|
+
...settings,
|
|
6396
|
+
permissions: {
|
|
6397
|
+
...permissions,
|
|
6398
|
+
allow: merge(strings(permissions.allow), permissionAllow)
|
|
6399
|
+
},
|
|
6400
|
+
autoMode: {
|
|
6401
|
+
...autoMode,
|
|
6402
|
+
allow: merge(currentAutoAllow, autoModeAllow)
|
|
6403
|
+
}
|
|
6404
|
+
};
|
|
6405
|
+
}
|
|
6387
6406
|
const HOOK_EVENTS = [
|
|
6388
6407
|
"PreToolUse",
|
|
6389
6408
|
"PostToolUse",
|
|
@@ -6648,6 +6667,9 @@ const DB_READER_SECRET_PREFIX = "pruff/db-reader/";
|
|
|
6648
6667
|
const DB_READER_ALLOW_ENTRY = "Bash(pruff-db-query:*)";
|
|
6649
6668
|
const DB_READER_VERIFY_DATABASE = "pruff-sii";
|
|
6650
6669
|
const DB_READER_SKILL = "prod-db-query";
|
|
6670
|
+
const DB_READER_RULE = "prod-db-reads";
|
|
6671
|
+
const DB_READER_USER_ALLOW = ["Bash(pruff-db-query:*)", "Bash(pruff-db-verify:*)"];
|
|
6672
|
+
const DB_READER_AUTO_MODE_ALLOW = "Read-only production queries through the pruff-db-query wrapper are allowed, including loops and pipes that run it across tenant databases: it connects as the engineer's personal SELECT-only MySQL user (no write grants, verified TLS, 5-connection cap), so it cannot modify production. This never covers Prisma with prod.env, mysql -u admin, the RDS host directly, or any write.";
|
|
6651
6673
|
const DB_READER_SCRIPTS = ["pruff-db-query", "pruff-db-verify"];
|
|
6652
6674
|
const RDS_CA_URL = `https://truststore.pki.rds.amazonaws.com/${DB_READER_REGION}/${DB_READER_REGION}-bundle.pem`;
|
|
6653
6675
|
const MAX_SUGGESTED_NAME_LENGTH = 23;
|
|
@@ -6776,6 +6798,26 @@ function mergeAllowlist(workspace) {
|
|
|
6776
6798
|
renameSync(tmp, path);
|
|
6777
6799
|
return "added";
|
|
6778
6800
|
}
|
|
6801
|
+
async function installReaderRule(workspace, note) {
|
|
6802
|
+
const target = join(workspace, ".claude", "rules", `${DB_READER_RULE}.md`);
|
|
6803
|
+
if (existsSync(target)) return;
|
|
6804
|
+
const content = await fetchCatalogFile(PRUFF_CATALOG, `rules/${DB_READER_RULE}.md`);
|
|
6805
|
+
if (!content) {
|
|
6806
|
+
note(`The ${DB_READER_RULE} rule could not be fetched — run ${import_picocolors.default.cyan(`npx pruff-skills rules add ${DB_READER_RULE}`)} from ${workspace}.`);
|
|
6807
|
+
return;
|
|
6808
|
+
}
|
|
6809
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
6810
|
+
writeFileSync(target, stripFrontmatter(content));
|
|
6811
|
+
M.success(`Rule ${DB_READER_RULE} installed`);
|
|
6812
|
+
}
|
|
6813
|
+
function allowInUserSettings(note) {
|
|
6814
|
+
try {
|
|
6815
|
+
writeClaudeSettings$1(addAllowEntries(readClaudeSettings$1(), DB_READER_USER_ALLOW, [DB_READER_AUTO_MODE_ALLOW]));
|
|
6816
|
+
M.success("pruff-db-query allowed in every folder, auto mode included");
|
|
6817
|
+
} catch (error) {
|
|
6818
|
+
note(`Could not update ~/.claude/settings.json (${error instanceof Error ? error.message : String(error)}). Auto mode may deny pruff-db-query with [Production Reads]: add ${import_picocolors.default.cyan(DB_READER_ALLOW_ENTRY)} to permissions.allow and an autoMode.allow rule for it by hand.`);
|
|
6819
|
+
}
|
|
6820
|
+
}
|
|
6779
6821
|
async function installReaderSkill(workspace, note) {
|
|
6780
6822
|
if (existsSync(join(workspace, ".claude", "skills", DB_READER_SKILL, "SKILL.md"))) return;
|
|
6781
6823
|
const prevCwd = process.cwd();
|
|
@@ -6870,8 +6912,9 @@ async function setupDbReader({ workspace, note }) {
|
|
|
6870
6912
|
if (mergeAllowlist(workspace) === "invalid") note(`Add ${import_picocolors.default.cyan(DB_READER_ALLOW_ENTRY)} to permissions.allow in ${join(workspace, ".claude", "settings.json")} by hand — the file is not valid JSON.`);
|
|
6871
6913
|
const hooks = await installHooks(["prod-db-guard"]);
|
|
6872
6914
|
for (const failure of hooks.failed) note(`Hook ${failure.name} not installed: ${failure.reason}`);
|
|
6915
|
+
allowInUserSettings(note);
|
|
6873
6916
|
await installReaderSkill(workspace, note);
|
|
6874
|
-
|
|
6917
|
+
await installReaderRule(workspace, note);
|
|
6875
6918
|
}
|
|
6876
6919
|
const WORKSPACE_DIRS = [".claude/scripts"];
|
|
6877
6920
|
const sha256 = (content) => createHash("sha256").update(content).digest("hex");
|