@yasaswy.nagavolu/agents 0.26.0 → 0.26.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/README.md +13 -0
- package/bin/cli.js +135 -4
- package/content/global/hooks/cloudshell_guard.py +712 -0
- package/content/global/hooks/lib/modeDrift.js +152 -0
- package/content/global/hooks/lib/projectHooks.js +429 -0
- package/content/global/hooks/permission_mode_enforce.js +35 -0
- package/content/global/hooks/project_hook.sh +7 -4
- package/content/global/hooks/project_hook_repair.js +25 -0
- package/content/manifest.json +114 -1
- package/content/skills/README.md +4 -0
- package/content/skills/disk-cleanup/SKILL.md +3 -2
- package/content/skills/disk-cleanup/classify.ps1 +2 -1
- package/content/skills/disk-cleanup/purge_walker.ps1 +98 -0
- package/content/skills/disk-cleanup/safe_clean.ps1 +7 -4
- package/content/skills/disk-cleanup/scan.ps1 +3 -2
- package/content/skills/disk-cleanup/worktree_audit.ps1 +1 -1
- package/content/skills/make-space/SKILL.md +61 -0
- package/content/skills/make-space/allowlist.json +39 -0
- package/content/skills/make-space/make_space.ps1 +219 -0
- package/content/skills/make-space/space_guard.ps1 +84 -0
- package/content/skills/make-space/tests/conftest.py +103 -0
- package/content/skills/make-space/tests/test_make_space.py +195 -0
- package/lib/modeDrift.js +15 -0
- package/lib/projectHooks.js +15 -0
- package/lib/wiring.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -82,6 +82,19 @@ agents-cli install
|
|
|
82
82
|
`.gitlab-ci.yml`. Needs `GITLAB_RUNNER_PAT` (set it with `agents-cli
|
|
83
83
|
secrets`). Add `--json` for a machine-readable result that never contains a
|
|
84
84
|
token. Exit codes: 0 ok, 1 a step failed, 2 usage error.
|
|
85
|
+
- `agents-cli doctor [--fix] [--scan-root <dir>] [--json]` — report orphaned, missing and drifted
|
|
86
|
+
files under the install target, plus project hooks in the repo's `.claude/settings.json` and
|
|
87
|
+
`settings.local.json` whose script file is missing or that are bare `python <repo>/.claude/hooks/x.py`
|
|
88
|
+
commands (they exit 2 and block a PreToolUse call when the file goes missing). `--fix` rewrites the
|
|
89
|
+
bare ones to `sh ~/.claude/hooks/project_hook.sh .claude/hooks/x.py [args]` (fail-open launcher);
|
|
90
|
+
`--scan-root <dir>` checks every git repo directly under `<dir>` instead of the cwd repo. `install` and `update`
|
|
91
|
+
accept the same `--scan-root` plus `--fix-project-hooks` and report (or fix) bare project hooks after the run.
|
|
92
|
+
Paste-ready fix from inside any repo: `npx -y @yasaswy.nagavolu/agents@latest doctor --fix`.
|
|
93
|
+
It also flags a project `permissions.defaultMode` weaker than the global default in `~/.claude/settings.json`
|
|
94
|
+
(for example `dontAsk` under a global `bypassPermissions`); `--fix` removes it from `settings.local.json`
|
|
95
|
+
only, a committed `settings.json` is reported and never edited. The `permission_mode_enforce.js` hook
|
|
96
|
+
(harness-hygiene) does the same repair at SessionStart/UserPromptSubmit and auto-allows permission prompts
|
|
97
|
+
while the global default is `bypassPermissions`.
|
|
85
98
|
- `agents-cli --help` — show usage
|
|
86
99
|
|
|
87
100
|
### The interactive menu
|
package/bin/cli.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const path = require('node:path');
|
|
5
|
+
const fs = require('node:fs');
|
|
5
6
|
const { readFileSync } = require('node:fs');
|
|
6
7
|
|
|
7
8
|
const pkg = JSON.parse(
|
|
@@ -32,6 +33,8 @@ const { collectBundleSecrets, collectComponentSecrets, isResolved, promptForMiss
|
|
|
32
33
|
const { envPath, readSecrets, removeSecret } = require('../lib/secretsStore');
|
|
33
34
|
const { runSelfProfilePostInstall } = require('../lib/selfProfile');
|
|
34
35
|
const { checkHealth, DoctorError } = require('../lib/doctor');
|
|
36
|
+
const projectHooks = require('../lib/projectHooks');
|
|
37
|
+
const modeDrift = require('../lib/modeDrift');
|
|
35
38
|
const { checkModVersions } = require('../lib/claudeVersion');
|
|
36
39
|
|
|
37
40
|
const PACKAGE_ROOT = path.join(__dirname, '..');
|
|
@@ -60,10 +63,16 @@ Usage:
|
|
|
60
63
|
agents-cli uninstall --bundle <key> --yes Remove a bundle's installed files and settings.json wiring
|
|
61
64
|
agents-cli update --yes Update every installed bundle to the current source
|
|
62
65
|
agents-cli update --bundle <key> --yes Update one installed bundle
|
|
66
|
+
install | update [--scan-root <dir>] [--fix-project-hooks]
|
|
67
|
+
After the run, report bare project hooks of the cwd repo (or every git repo
|
|
68
|
+
under <dir>); --fix-project-hooks rewrites them to the fail-open launcher.
|
|
69
|
+
Also reports a project defaultMode weaker than the global one; with
|
|
70
|
+
--fix-project-hooks it is removed from settings.local.json
|
|
63
71
|
agents-cli secrets Prompt for any missing secrets across all installed bundles
|
|
64
72
|
agents-cli secrets --bundle <key> Prompt for missing secrets for one bundle
|
|
65
73
|
agents-cli secrets --list Show which secrets are set/missing (names only — never values)
|
|
66
|
-
agents-cli doctor
|
|
74
|
+
agents-cli doctor [--fix] [--scan-root <dir>] Report orphaned/missing/drifted files under the install target
|
|
75
|
+
and project hooks that would brick a session if their file went missing
|
|
67
76
|
agents-cli runner <sub> [flags] Install and manage a self-hosted GitLab CI runner (see "Flags for runner")
|
|
68
77
|
agents-cli --help Show this help
|
|
69
78
|
|
|
@@ -151,6 +160,20 @@ Flags for runner:
|
|
|
151
160
|
Flags for doctor:
|
|
152
161
|
--target-dir <path> Install target base, default ~/.claude (use for testing)
|
|
153
162
|
--json Print a machine-readable report instead of prose
|
|
163
|
+
--scan-root <dir> Check the project hooks of every git repo directly under <dir> (default: the repo of the cwd)
|
|
164
|
+
--fix Rewrite bare "python <repo>/.claude/hooks/x.py" project hook commands into the fail-open
|
|
165
|
+
launcher form "sh ~/.claude/hooks/project_hook.sh .claude/hooks/x.py" (needs the launcher
|
|
166
|
+
installed under the target; edits only settings.json / settings.local.json hook commands)
|
|
167
|
+
|
|
168
|
+
doctor also checks the project hooks in .claude/settings.json and settings.local.json of the repo: a hook command
|
|
169
|
+
whose script file is missing, and a bare (non-launcher) project hook command, which exits 2 if its file goes missing
|
|
170
|
+
and so blocks every tool call when it is a PreToolUse hook. A launcher-form hook with a missing file fails open but is still
|
|
171
|
+
reported. Without --fix nothing is modified.
|
|
172
|
+
|
|
173
|
+
doctor also flags a project .claude/settings.json or settings.local.json whose permissions.defaultMode is weaker
|
|
174
|
+
than the global default in <target>/settings.json (for example "dontAsk" under a global "bypassPermissions"), which
|
|
175
|
+
silently downgrades every session in that repo. --fix removes the key from settings.local.json only; a committed
|
|
176
|
+
settings.json is reported, never edited.
|
|
154
177
|
|
|
155
178
|
doctor reports, without changing anything: orphans (files/directories sitting inside
|
|
156
179
|
a path this CLI manages that the ledger does not claim — e.g. a stale file left behind
|
|
@@ -1056,7 +1079,7 @@ async function runUpdate(argv) {
|
|
|
1056
1079
|
}
|
|
1057
1080
|
|
|
1058
1081
|
function parseDoctorArgs(argv) {
|
|
1059
|
-
const args = { targetDir: null, json: false };
|
|
1082
|
+
const args = { targetDir: null, json: false, fix: false, scanRoot: null };
|
|
1060
1083
|
for (let i = 0; i < argv.length; i += 1) {
|
|
1061
1084
|
const arg = argv[i];
|
|
1062
1085
|
if (arg === '--target-dir') {
|
|
@@ -1064,6 +1087,12 @@ function parseDoctorArgs(argv) {
|
|
|
1064
1087
|
i += 1;
|
|
1065
1088
|
} else if (arg === '--json') {
|
|
1066
1089
|
args.json = true;
|
|
1090
|
+
} else if (arg === '--fix') {
|
|
1091
|
+
args.fix = true;
|
|
1092
|
+
} else if (arg === '--scan-root') {
|
|
1093
|
+
args.scanRoot = argv[i + 1];
|
|
1094
|
+
if (!args.scanRoot) throw new DoctorError('--scan-root needs a directory');
|
|
1095
|
+
i += 1;
|
|
1067
1096
|
} else {
|
|
1068
1097
|
throw new DoctorError(`Unknown doctor flag: ${arg}`);
|
|
1069
1098
|
}
|
|
@@ -1075,6 +1104,86 @@ function describeOrphan(o) {
|
|
|
1075
1104
|
return o.type === 'dir' ? `${o.relTarget}/ (directory)` : o.relTarget;
|
|
1076
1105
|
}
|
|
1077
1106
|
|
|
1107
|
+
function describeHookFinding(f) {
|
|
1108
|
+
const where = `${f.file} [${f.event || '-'}]`;
|
|
1109
|
+
if (f.kind === 'unparseable') return `${f.file}: not valid JSON, hooks not checked`;
|
|
1110
|
+
if (f.kind === 'bare-project-hook') {
|
|
1111
|
+
return `${where} bare project hook, exits 2 if its file goes missing (${projectHooks.failureEffect(f.event)})${f.fixable ? ' (fixable)' : ' (not auto-fixable)'}: ${f.command}`;
|
|
1112
|
+
}
|
|
1113
|
+
if (f.kind === 'missing-launcher') return `${where} launcher not found: ${f.script}`;
|
|
1114
|
+
return `${where} script missing${f.failsOpen ? ' (launcher: fails open, hook does not run)' : ` (FAILS CLOSED: ${projectHooks.failureEffect(f.event)})`}: ${f.script}`;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
function printProjectHookReport(step, { fixRequested }) {
|
|
1118
|
+
if (step.fixed.length > 0) {
|
|
1119
|
+
console.log(`
|
|
1120
|
+
Rewrote ${step.fixed.length} bare project hook command(s) to the fail-open launcher:`);
|
|
1121
|
+
for (const c of step.fixed) console.log(` ${c.file}
|
|
1122
|
+
- ${c.from}
|
|
1123
|
+
+ ${c.to}`);
|
|
1124
|
+
}
|
|
1125
|
+
if (step.findings.length === 0) return;
|
|
1126
|
+
console.log(`
|
|
1127
|
+
Project hooks (${step.findings.length} finding(s), ${step.repos.length} repo(s) checked):`);
|
|
1128
|
+
for (const f of step.findings) console.log(` ${describeHookFinding(f)}`);
|
|
1129
|
+
if (!fixRequested && step.findings.some((f) => f.kind === 'bare-project-hook' && f.fixable)) {
|
|
1130
|
+
console.log(` Fix: ${projectHooks.FIX_COMMAND}`);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
function printModeDriftReport(modes) {
|
|
1135
|
+
if (modes.fixed.length > 0) {
|
|
1136
|
+
console.log(`\nRemoved ${modes.fixed.length} defaultMode override(s) weaker than the global "${modes.globalMode}":`);
|
|
1137
|
+
for (const f of modes.fixed) console.log(` ${f.file} (was "${f.mode}"); a live session needs ctrl+x m once`);
|
|
1138
|
+
}
|
|
1139
|
+
if (modes.findings.length === 0) return;
|
|
1140
|
+
console.log(`\nPermission mode drift (${modes.findings.length} finding(s), ${modes.repos.length} repo(s) checked):`);
|
|
1141
|
+
for (const f of modes.findings) console.log(` ${modeDrift.describeModeFinding(f)}`);
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
function splitProjectHookFlags(argv) {
|
|
1145
|
+
const rest = [];
|
|
1146
|
+
const opts = { scanRoot: null, fix: false, targetDir: null };
|
|
1147
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
1148
|
+
const arg = argv[i];
|
|
1149
|
+
if (arg === '--fix-project-hooks') opts.fix = true;
|
|
1150
|
+
else if (arg === '--scan-root' && argv[i + 1]) {
|
|
1151
|
+
opts.scanRoot = argv[i + 1];
|
|
1152
|
+
i += 1;
|
|
1153
|
+
} else {
|
|
1154
|
+
if (arg === '--target-dir') opts.targetDir = argv[i + 1] || null;
|
|
1155
|
+
rest.push(arg);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
return { rest, opts };
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
async function withProjectHookStep(argv, run) {
|
|
1162
|
+
const { rest, opts } = splitProjectHookFlags(argv);
|
|
1163
|
+
const code = await run(rest);
|
|
1164
|
+
try {
|
|
1165
|
+
const step = projectHooks.projectHooksStep({
|
|
1166
|
+
cwd: process.cwd(),
|
|
1167
|
+
scanRoot: opts.scanRoot ? path.resolve(opts.scanRoot) : null,
|
|
1168
|
+
fix: opts.fix,
|
|
1169
|
+
targetBase: opts.targetDir || defaultTargetBase(),
|
|
1170
|
+
});
|
|
1171
|
+
if (step.error) console.error(step.error);
|
|
1172
|
+
printProjectHookReport(step, { fixRequested: opts.fix });
|
|
1173
|
+
printModeDriftReport(
|
|
1174
|
+
modeDrift.checkModeDrift({
|
|
1175
|
+
targetBase: opts.targetDir || defaultTargetBase(),
|
|
1176
|
+
cwd: process.cwd(),
|
|
1177
|
+
scanRoot: opts.scanRoot ? path.resolve(opts.scanRoot) : null,
|
|
1178
|
+
fix: opts.fix,
|
|
1179
|
+
})
|
|
1180
|
+
);
|
|
1181
|
+
} catch (err) {
|
|
1182
|
+
console.error(`project hook scan skipped: ${err.message}`);
|
|
1183
|
+
}
|
|
1184
|
+
return code;
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1078
1187
|
function runDoctor(argv) {
|
|
1079
1188
|
let args;
|
|
1080
1189
|
try {
|
|
@@ -1090,11 +1199,30 @@ function runDoctor(argv) {
|
|
|
1090
1199
|
targetBase: args.targetDir,
|
|
1091
1200
|
});
|
|
1092
1201
|
|
|
1202
|
+
const scope = {
|
|
1203
|
+
cwd: process.cwd(),
|
|
1204
|
+
scanRoot: args.scanRoot ? path.resolve(args.scanRoot) : null,
|
|
1205
|
+
targetBase: args.targetDir || defaultTargetBase(),
|
|
1206
|
+
};
|
|
1207
|
+
const modes = modeDrift.checkModeDrift({ ...scope, fix: args.fix });
|
|
1208
|
+
const hooks = projectHooks.projectHooksStep({ ...scope, fix: args.fix });
|
|
1209
|
+
if (hooks.error) {
|
|
1210
|
+
console.error(hooks.error);
|
|
1211
|
+
return 1;
|
|
1212
|
+
}
|
|
1213
|
+
const { fixed } = hooks;
|
|
1214
|
+
result.projectHooks = { repos: hooks.repos, findings: hooks.findings, fixed };
|
|
1215
|
+
result.modeDrift = { globalMode: modes.globalMode, findings: modes.findings, fixed: modes.fixed };
|
|
1216
|
+
result.healthy = result.healthy && hooks.findings.length === 0 && modes.findings.length === 0;
|
|
1217
|
+
|
|
1093
1218
|
if (args.json) {
|
|
1094
1219
|
console.log(JSON.stringify(result, null, 2));
|
|
1095
1220
|
return result.healthy ? 0 : 1;
|
|
1096
1221
|
}
|
|
1097
1222
|
|
|
1223
|
+
const printProjectHooks = () => printProjectHookReport(hooks, { fixRequested: args.fix });
|
|
1224
|
+
const printModeDrift = () => printModeDriftReport(modes);
|
|
1225
|
+
|
|
1098
1226
|
const printModVersions = () => {
|
|
1099
1227
|
if (result.modVersions.length === 0) return;
|
|
1100
1228
|
console.log('\nClaude Code version vs. installed mods:');
|
|
@@ -1104,6 +1232,7 @@ function runDoctor(argv) {
|
|
|
1104
1232
|
if (result.healthy) {
|
|
1105
1233
|
console.log(`${result.targetBase}: healthy — no orphans, no missing files, no drift.`);
|
|
1106
1234
|
printModVersions();
|
|
1235
|
+
printModeDrift();
|
|
1107
1236
|
return 0;
|
|
1108
1237
|
}
|
|
1109
1238
|
|
|
@@ -1121,6 +1250,8 @@ function runDoctor(argv) {
|
|
|
1121
1250
|
for (const d of result.drifted) console.log(` ${d.relTarget} (bundle: ${d.bundle})`);
|
|
1122
1251
|
}
|
|
1123
1252
|
printModVersions();
|
|
1253
|
+
printProjectHooks();
|
|
1254
|
+
printModeDrift();
|
|
1124
1255
|
return 1;
|
|
1125
1256
|
} catch (err) {
|
|
1126
1257
|
if (err instanceof DoctorError || err instanceof ManifestError || err instanceof LedgerError) {
|
|
@@ -1145,7 +1276,7 @@ async function main(argv) {
|
|
|
1145
1276
|
}
|
|
1146
1277
|
|
|
1147
1278
|
if (command === 'install') {
|
|
1148
|
-
return
|
|
1279
|
+
return withProjectHookStep(rest, runInstall);
|
|
1149
1280
|
}
|
|
1150
1281
|
|
|
1151
1282
|
if (command === 'uninstall') {
|
|
@@ -1157,7 +1288,7 @@ async function main(argv) {
|
|
|
1157
1288
|
}
|
|
1158
1289
|
|
|
1159
1290
|
if (command === 'update') {
|
|
1160
|
-
return
|
|
1291
|
+
return withProjectHookStep(rest, runUpdate);
|
|
1161
1292
|
}
|
|
1162
1293
|
|
|
1163
1294
|
if (command === 'doctor') {
|