@yasaswy.nagavolu/agents 0.28.1 → 0.29.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/README.md +4 -0
- package/bin/cli.js +34 -9
- package/content/global/hooks/lib/modeDrift.js +2 -2
- package/lib/bypassOnly.js +85 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,6 +114,10 @@ agents-cli install
|
|
|
114
114
|
token (the Microsoft Store stub makes it fail), a missing `hooks/pyrun.js` launcher, an unresolvable interpreter, and a
|
|
115
115
|
WindowsApps python stub ahead of a real interpreter on PATH; `--fix` rewrites the bare tokens to
|
|
116
116
|
`node <target>/hooks/pyrun.js <script>` and never edits PATH or App Execution Aliases.
|
|
117
|
+
It also checks `~/.claude/settings.json` for bypass-only, no auto mode: `permissions.defaultMode` `bypassPermissions`,
|
|
118
|
+
`permissions.disableAutoMode` `disable`, `skipDangerousModePermissionPrompt` `true`, `useAutoModeDuringPlan` `false`, and no
|
|
119
|
+
`permissions.disableBypassPermissionsMode`. `--fix`, `install` and `update` set those keys and leave every other key,
|
|
120
|
+
including `permissions.deny`, untouched; a project `defaultMode` weaker than `bypassPermissions` is flagged too.
|
|
117
121
|
It also flags a project `permissions.defaultMode` weaker than the global default in `~/.claude/settings.json`
|
|
118
122
|
(for example `dontAsk` under a global `bypassPermissions`); `--fix` removes it from `settings.local.json`
|
|
119
123
|
only, a committed `settings.json` is reported and never edited. The `permission_mode_enforce.js` hook
|
package/bin/cli.js
CHANGED
|
@@ -38,6 +38,7 @@ const { checkHealth, DoctorError } = require('../lib/doctor');
|
|
|
38
38
|
const memoryIndexCheck = require('../lib/memoryIndexCheck');
|
|
39
39
|
const projectHooks = require('../lib/projectHooks');
|
|
40
40
|
const modeDrift = require('../lib/modeDrift');
|
|
41
|
+
const bypassOnly = require('../lib/bypassOnly');
|
|
41
42
|
const permissionRules = require('../lib/permissionRules');
|
|
42
43
|
const pythonHooks = require('../lib/pythonHooks');
|
|
43
44
|
const pyrun = require('../lib/pyrun');
|
|
@@ -204,9 +205,13 @@ ahead of a real interpreter on PATH. --fix rewrites the bare tokens to "node <ta
|
|
|
204
205
|
it never edits PATH or App Execution Aliases.
|
|
205
206
|
|
|
206
207
|
doctor also flags a project .claude/settings.json or settings.local.json whose permissions.defaultMode is weaker
|
|
207
|
-
than
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
than bypassPermissions (for example "dontAsk" or "auto"), which silently downgrades every session in that repo.
|
|
209
|
+
--fix removes the key from settings.local.json only; a committed settings.json is reported, never edited.
|
|
210
|
+
|
|
211
|
+
doctor also checks <target>/settings.json for bypassPermissions only with no auto mode: permissions.defaultMode
|
|
212
|
+
"bypassPermissions", permissions.disableAutoMode "disable", skipDangerousModePermissionPrompt true,
|
|
213
|
+
useAutoModeDuringPlan false, and no permissions.disableBypassPermissionsMode. --fix (and every update) sets
|
|
214
|
+
those keys and leaves all other keys, including permissions.deny, untouched.
|
|
210
215
|
|
|
211
216
|
doctor reports, without changing anything: orphans (files/directories sitting inside
|
|
212
217
|
a path this CLI manages that the ledger does not claim — e.g. a stale file left behind
|
|
@@ -1284,6 +1289,20 @@ function printPythonLaunchReport(py) {
|
|
|
1284
1289
|
if (py.findings.length > 0 && !py.fixRequested) console.log(` Fix: ${projectHooks.FIX_COMMAND}`);
|
|
1285
1290
|
}
|
|
1286
1291
|
|
|
1292
|
+
function printBypassOnlyReport(bypass) {
|
|
1293
|
+
if (bypass.error) console.log(`
|
|
1294
|
+
${bypass.error}`);
|
|
1295
|
+
if (bypass.fixed.length > 0) {
|
|
1296
|
+
console.log(`
|
|
1297
|
+
Set ${bypass.fixed.length} key(s) in ${bypass.file} for bypassPermissions only, no auto mode:`);
|
|
1298
|
+
for (const d of bypass.fixed) console.log(` ${bypassOnly.describeDrift(d)}`);
|
|
1299
|
+
}
|
|
1300
|
+
if (bypass.findings.length === 0) return;
|
|
1301
|
+
console.log(`
|
|
1302
|
+
Bypass-only drift in ${bypass.file} (${bypass.findings.length} key(s), fix: agents-cli doctor --fix or agents-cli update):`);
|
|
1303
|
+
for (const d of bypass.findings) console.log(` ${bypassOnly.describeDrift(d)}`);
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1287
1306
|
function printModeDriftReport(modes) {
|
|
1288
1307
|
if (modes.fixed.length > 0) {
|
|
1289
1308
|
console.log(`\nRemoved ${modes.fixed.length} defaultMode override(s) weaker than the global "${modes.globalMode}":`);
|
|
@@ -1326,7 +1345,7 @@ function splitProjectHookFlags(argv) {
|
|
|
1326
1345
|
return { rest, opts };
|
|
1327
1346
|
}
|
|
1328
1347
|
|
|
1329
|
-
async function withProjectHookStep(argv, run) {
|
|
1348
|
+
async function withProjectHookStep(argv, run, { healBypass = false } = {}) {
|
|
1330
1349
|
const { rest, opts } = splitProjectHookFlags(argv);
|
|
1331
1350
|
const code = await run(rest);
|
|
1332
1351
|
try {
|
|
@@ -1338,12 +1357,15 @@ async function withProjectHookStep(argv, run) {
|
|
|
1338
1357
|
});
|
|
1339
1358
|
if (step.error) console.error(step.error);
|
|
1340
1359
|
printProjectHookReport(step, { fixRequested: opts.fix });
|
|
1360
|
+
const targetBase = opts.targetDir || defaultTargetBase();
|
|
1361
|
+
printBypassOnlyReport(bypassOnly.checkBypassOnly({ targetBase, fix: healBypass || opts.fix }));
|
|
1341
1362
|
printModeDriftReport(
|
|
1342
1363
|
modeDrift.checkModeDrift({
|
|
1343
|
-
targetBase
|
|
1364
|
+
targetBase,
|
|
1344
1365
|
cwd: process.cwd(),
|
|
1345
1366
|
scanRoot: opts.scanRoot ? path.resolve(opts.scanRoot) : null,
|
|
1346
1367
|
fix: opts.fix,
|
|
1368
|
+
expectedMode: bypassOnly.BYPASS,
|
|
1347
1369
|
})
|
|
1348
1370
|
);
|
|
1349
1371
|
printRuleMigrationReport(
|
|
@@ -1379,7 +1401,8 @@ function runDoctor(argv) {
|
|
|
1379
1401
|
scanRoot: args.scanRoot ? path.resolve(args.scanRoot) : null,
|
|
1380
1402
|
targetBase: args.targetDir || defaultTargetBase(),
|
|
1381
1403
|
};
|
|
1382
|
-
const
|
|
1404
|
+
const bypass = bypassOnly.checkBypassOnly({ targetBase: scope.targetBase, fix: args.fix });
|
|
1405
|
+
const modes = modeDrift.checkModeDrift({ ...scope, fix: args.fix, expectedMode: bypassOnly.BYPASS });
|
|
1383
1406
|
const rules = permissionRules.checkRuleMigration({ ...scope, fix: args.fix });
|
|
1384
1407
|
const hooks = projectHooks.projectHooksStep({ ...scope, fix: args.fix });
|
|
1385
1408
|
if (hooks.error) {
|
|
@@ -1402,9 +1425,10 @@ function runDoctor(argv) {
|
|
|
1402
1425
|
const { fixed } = hooks;
|
|
1403
1426
|
result.projectHooks = { repos: hooks.repos, findings: hooks.findings, fixed };
|
|
1404
1427
|
result.modeDrift = { globalMode: modes.globalMode, findings: modes.findings, fixed: modes.fixed };
|
|
1428
|
+
result.bypassOnly = { file: bypass.file, findings: bypass.findings, fixed: bypass.fixed, error: bypass.error };
|
|
1405
1429
|
result.permissionRules = { findings: rules.findings, fixed: rules.fixed };
|
|
1406
1430
|
result.pythonLaunch = { files: py.files, findings: py.findings, fixed: py.fixed, missingLaunchers: py.missingLaunchers, interpreter: py.interpreter, stubs: py.stubs };
|
|
1407
|
-
result.healthy = result.healthy && hooks.findings.length === 0 && modes.findings.length === 0 && rules.findings.length === 0 && py.healthy;
|
|
1431
|
+
result.healthy = result.healthy && hooks.findings.length === 0 && bypass.findings.length === 0 && !bypass.error && modes.findings.length === 0 && rules.findings.length === 0 && py.healthy;
|
|
1408
1432
|
|
|
1409
1433
|
if (args.json) {
|
|
1410
1434
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -1413,6 +1437,7 @@ function runDoctor(argv) {
|
|
|
1413
1437
|
|
|
1414
1438
|
const printProjectHooks = () => printProjectHookReport(hooks, { fixRequested: args.fix });
|
|
1415
1439
|
const printModeDrift = () => {
|
|
1440
|
+
printBypassOnlyReport(bypass);
|
|
1416
1441
|
printModeDriftReport(modes);
|
|
1417
1442
|
printRuleMigrationReport(rules);
|
|
1418
1443
|
};
|
|
@@ -1560,7 +1585,7 @@ async function main(argv, { captureSelection = false } = {}) {
|
|
|
1560
1585
|
}
|
|
1561
1586
|
|
|
1562
1587
|
if (command === 'install') {
|
|
1563
|
-
return withProjectHookStep(rest, args => runInstall(args, { captureSelection }));
|
|
1588
|
+
return withProjectHookStep(rest, args => runInstall(args, { captureSelection }), { healBypass: true });
|
|
1564
1589
|
}
|
|
1565
1590
|
|
|
1566
1591
|
if (command === 'uninstall') {
|
|
@@ -1572,7 +1597,7 @@ async function main(argv, { captureSelection = false } = {}) {
|
|
|
1572
1597
|
}
|
|
1573
1598
|
|
|
1574
1599
|
if (command === 'update') {
|
|
1575
|
-
return withProjectHookStep(rest, runUpdate);
|
|
1600
|
+
return withProjectHookStep(rest, runUpdate, { healBypass: true });
|
|
1576
1601
|
}
|
|
1577
1602
|
|
|
1578
1603
|
if (command === 'doctor') {
|
|
@@ -76,8 +76,8 @@ function resolveRepos({ cwd, scanRoot }) {
|
|
|
76
76
|
return scanRoot ? listGitRepos(scanRoot) : [currentRepo(cwd || process.cwd())].filter(Boolean);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
function checkModeDrift({ targetBase, cwd, scanRoot, fix = false }) {
|
|
80
|
-
const globalMode = globalDefaultMode(targetBase);
|
|
79
|
+
function checkModeDrift({ targetBase, cwd, scanRoot, fix = false, expectedMode = null }) {
|
|
80
|
+
const globalMode = expectedMode || globalDefaultMode(targetBase);
|
|
81
81
|
const repos = resolveRepos({ cwd, scanRoot });
|
|
82
82
|
if (!globalMode) return { globalMode: null, repos, findings: [], fixed: [] };
|
|
83
83
|
const fixed = fix ? repos.flatMap((repo) => fixRepoModes(repo, globalMode)) : [];
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const { readSettingsFile, reserialize, writeAtomic } = require('./projectHooks');
|
|
5
|
+
|
|
6
|
+
const BYPASS = 'bypassPermissions';
|
|
7
|
+
|
|
8
|
+
const REQUIRED = [
|
|
9
|
+
{ path: ['permissions', 'defaultMode'], value: BYPASS },
|
|
10
|
+
{ path: ['permissions', 'disableAutoMode'], value: 'disable' },
|
|
11
|
+
{ path: ['skipDangerousModePermissionPrompt'], value: true },
|
|
12
|
+
{ path: ['useAutoModeDuringPlan'], value: false },
|
|
13
|
+
];
|
|
14
|
+
const FORBIDDEN = [{ path: ['permissions', 'disableBypassPermissionsMode'] }];
|
|
15
|
+
|
|
16
|
+
const isObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
17
|
+
|
|
18
|
+
function getAt(obj, keys) {
|
|
19
|
+
let cur = obj;
|
|
20
|
+
for (const key of keys) {
|
|
21
|
+
if (!isObject(cur) || !Object.hasOwn(cur, key)) return undefined;
|
|
22
|
+
cur = cur[key];
|
|
23
|
+
}
|
|
24
|
+
return cur;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function setAt(obj, keys, value) {
|
|
28
|
+
let cur = obj;
|
|
29
|
+
for (const key of keys.slice(0, -1)) {
|
|
30
|
+
if (!isObject(cur[key])) cur[key] = {};
|
|
31
|
+
cur = cur[key];
|
|
32
|
+
}
|
|
33
|
+
cur[keys[keys.length - 1]] = value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function removeAt(obj, keys) {
|
|
37
|
+
const parent = getAt(obj, keys.slice(0, -1));
|
|
38
|
+
if (isObject(parent)) delete parent[keys[keys.length - 1]];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Keys of a settings object that break "bypassPermissions only, no auto mode". */
|
|
42
|
+
function findDrift(settings) {
|
|
43
|
+
const required = REQUIRED.filter((r) => getAt(settings, r.path) !== r.value).map((r) => ({
|
|
44
|
+
key: r.path.join('.'),
|
|
45
|
+
keys: r.path,
|
|
46
|
+
action: 'set',
|
|
47
|
+
expected: r.value,
|
|
48
|
+
actual: getAt(settings, r.path),
|
|
49
|
+
}));
|
|
50
|
+
const forbidden = FORBIDDEN.filter((f) => getAt(settings, f.path) !== undefined).map((f) => ({
|
|
51
|
+
key: f.path.join('.'),
|
|
52
|
+
keys: f.path,
|
|
53
|
+
action: 'remove',
|
|
54
|
+
expected: undefined,
|
|
55
|
+
actual: getAt(settings, f.path),
|
|
56
|
+
}));
|
|
57
|
+
return [...required, ...forbidden];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Deep-merge the required keys into settings in place; every other key is untouched. */
|
|
61
|
+
function applyDrift(settings, drift) {
|
|
62
|
+
for (const d of drift) {
|
|
63
|
+
if (d.action === 'set') setAt(settings, d.keys, d.expected);
|
|
64
|
+
else removeAt(settings, d.keys);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function checkBypassOnly({ targetBase, fix = false }) {
|
|
69
|
+
const file = path.join(targetBase, 'settings.json');
|
|
70
|
+
const loaded = readSettingsFile(file);
|
|
71
|
+
if (!loaded) return { file, missing: true, findings: [], fixed: [], error: null };
|
|
72
|
+
if (!isObject(loaded.settings)) return { file, missing: false, findings: [], fixed: [], error: `${file} is not a valid JSON object; not checked` };
|
|
73
|
+
const drift = findDrift(loaded.settings);
|
|
74
|
+
if (!fix || drift.length === 0) return { file, missing: false, findings: drift, fixed: [], error: null };
|
|
75
|
+
applyDrift(loaded.settings, drift);
|
|
76
|
+
writeAtomic(file, reserialize(loaded.settings, loaded.raw));
|
|
77
|
+
return { file, missing: false, findings: [], fixed: drift, error: null };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function describeDrift(d) {
|
|
81
|
+
const want = d.action === 'remove' ? 'must be absent' : `must be ${JSON.stringify(d.expected)}`;
|
|
82
|
+
return `${d.key} ${want}, found ${d.actual === undefined ? 'nothing' : JSON.stringify(d.actual)}`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
module.exports = { BYPASS, REQUIRED, FORBIDDEN, applyDrift, checkBypassOnly, describeDrift, findDrift };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yasaswy.nagavolu/agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "CLI for installing the yasaswy.nagavolu agent/skill/hook bundle into Claude Code and Codex. `install` opens an interactive bundle menu in a TTY (or `--bundle <key> --yes` for non-interactive installs), with hash-tracked idempotent deploys, native hook wiring, and masked secret prompting. `update` reconciles installed bundles against the current source (hash-tracked: silent overwrite, conflict diff+prompt, or --theirs/--keep-mine). `uninstall` removes a bundle's files and wiring. `secrets` re-runs secret prompting for already-installed bundles.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|