@yasaswy.nagavolu/agents 0.27.3 → 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 +10 -1
- package/bin/cli.js +144 -22
- package/content/global/CLAUDE.md +8 -5
- package/content/global/hooks/compact_context.py +156 -0
- package/content/global/hooks/lib/modeDrift.js +2 -2
- package/content/manifest.json +286 -1
- package/content/proxy/README.md +28 -14
- package/content/proxy/bg_process_reaper_hook.py +17 -41
- package/content/proxy/bg_process_register_hook.py +10 -5
- package/content/proxy/bg_process_registry.py +102 -139
- package/content/proxy/chat_inbox_hook.py +64 -0
- package/content/proxy/chat_ledger.py +633 -0
- package/content/proxy/mem_sampler.py +492 -0
- package/content/proxy/memory_reclaim.py +497 -0
- package/content/proxy/memory_reclaim_hook.py +86 -0
- package/content/proxy/proc_policy.py +376 -0
- package/content/proxy/reaper_kill_hook.py +179 -0
- package/content/proxy/register_mem_sampler.ps1 +75 -0
- package/content/skills/README.md +4 -0
- package/content/skills/heavy-gate-runner/SKILL.md +56 -0
- package/content/skills/heavy-gate-runner/heavy_gate_runner.py +741 -0
- package/content/skills/heavy-gate-runner/tests/conftest.py +5 -0
- package/content/skills/heavy-gate-runner/tests/test_heavy_gate_runner.py +524 -0
- package/content/skills/low-ram-advisor/SKILL.md +3 -3
- package/content/skills/low-ram-advisor/advisor.py +2 -2
- package/lib/bypassOnly.js +85 -0
- package/lib/codex-hook-adapter.js +3 -2
- package/lib/codex-trust.js +5 -1
- package/lib/codex.js +8 -3
- package/lib/doctor.js +7 -2
- package/lib/memSafety.js +247 -0
- package/lib/modelsApply.js +57 -4
- package/lib/prepack.js +28 -2
- package/lib/selfProfile.js +6 -1
- package/lib/uninstall.js +13 -0
- package/lib/wiring.js +38 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,6 +16,10 @@ a reviewed Codex contract, are retained as inert compatibility assets and listed
|
|
|
16
16
|
in Codex's compatibility report. New skills and agents are discovered during
|
|
17
17
|
updates; new hook scripts are discovered when their Claude hook registration or
|
|
18
18
|
adjacent `.deploy.json` declares the event and command.
|
|
19
|
+
Windows releases verify NPX-installed Codex hooks before and after publication in a guarded private home, including native trust, PowerShell/cmd execution, repeat installation, and unchanged live configuration.
|
|
20
|
+
|
|
21
|
+
Generated Codex hook commands use a UTF-8 base64 bootstrap so adapter paths and
|
|
22
|
+
hook commands survive PowerShell, `cmd.exe`, and POSIX shell parsing.
|
|
19
23
|
|
|
20
24
|
`install` opens an interactive checkbox menu of purpose-based bundles when
|
|
21
25
|
run in a terminal, or installs one bundle non-interactively via
|
|
@@ -97,7 +101,7 @@ agents-cli install
|
|
|
97
101
|
secrets`). Add `--json` for a machine-readable result that never contains a
|
|
98
102
|
token. Exit codes: 0 ok, 1 a step failed, 2 usage error.
|
|
99
103
|
- `agents-cli models usage [--days N] [--json] [--target-dir <path>]` — read-only report of dispatch counts and share per role, from the guard's dispatch log (`logs/agent_dispatch.jsonl`, which records `model` and `role` per dispatch); a missing or empty log prints a note and exits 0.
|
|
100
|
-
- `agents-cli models apply [--dry-run] [--target-dir <path>]` — stamp `models.json` into the static consumers: the `model:` of every deployed agent file carrying a `role:` key,
|
|
104
|
+
- `agents-cli models apply [--dry-run] [--target-dir <path>]` — stamp `models.json` into the static consumers: the `model:` of every deployed agent file carrying a `role:` key, each `settingsStamp` entry (default `env.CLAUDE_CODE_SUBAGENT_MODEL`) in `settings.json`, and the `Current:` text between the `<!--models-->` markers of `CLAUDE.md`. `models apply --source <repo>` restamps `global/CLAUDE.md` of a repo checkout from its `config/models.json`. `models.json` itself ships as a normal bundle file (a local edit survives `update` unless `--theirs`); `install` and `update` run the same step automatically. `--dry-run` prints the diff and writes nothing; the settings `model` key and any key outside `settingsStamp` are never touched. To roll a model back, change that role's id in `~/.claude/models.json` and run it.
|
|
101
105
|
- `agents-cli doctor [--fix] [--scan-root <dir>] [--json]` — report orphaned, missing and drifted
|
|
102
106
|
files under the install target, plus project hooks in the repo's `.claude/settings.json` and
|
|
103
107
|
`settings.local.json` whose script file is missing or that are bare `python <repo>/.claude/hooks/x.py`
|
|
@@ -110,6 +114,10 @@ agents-cli install
|
|
|
110
114
|
token (the Microsoft Store stub makes it fail), a missing `hooks/pyrun.js` launcher, an unresolvable interpreter, and a
|
|
111
115
|
WindowsApps python stub ahead of a real interpreter on PATH; `--fix` rewrites the bare tokens to
|
|
112
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.
|
|
113
121
|
It also flags a project `permissions.defaultMode` weaker than the global default in `~/.claude/settings.json`
|
|
114
122
|
(for example `dontAsk` under a global `bypassPermissions`); `--fix` removes it from `settings.local.json`
|
|
115
123
|
only, a committed `settings.json` is reported and never edited. The `permission_mode_enforce.js` hook
|
|
@@ -123,6 +131,7 @@ agents-cli install
|
|
|
123
131
|
(Claude Code only matches `Edit(<path>)` for file writes); `--fix`, the `project_hook_repair.js` hook and the
|
|
124
132
|
`--fix-project-hooks` flag of `install`/`update` rewrite them to `Edit(<path>)` in `settings.local.json` with duplicates
|
|
125
133
|
dropped, a committed `settings.json` is reported and never edited, bare `Write`/`NotebookEdit` are left alone.
|
|
134
|
+
- `agents-cli sampler <status|register|unregister> [--dry-run] [--target-dir <path>]` — the hidden `ClaudeMemSampler` Windows logon task of the memory-safety stack. `install` and `update` register or start it on their own when the stack is installed (idempotent, hidden, default `~/.claude` install only, skipped under `NODE_ENV=test`; `--no-scheduled-tasks` or `AGENTS_CLI_NO_SCHEDULED_TASKS=1` skips it). `--dry-run` runs `register_mem_sampler.ps1` with `-WhatIf` and changes nothing. `doctor` adds a "Memory-safety stack" block (task, wired hooks, budget file, newest sample in `logs/mem-samples.jsonl`) and exits 1 on a missing task, an unwired hook, an invalid budget file or a stale sample. See [`docs/memory-safety.md`](../../docs/memory-safety.md).
|
|
126
135
|
- `agents-cli --help` — show usage
|
|
127
136
|
|
|
128
137
|
### The interactive menu
|
package/bin/cli.js
CHANGED
|
@@ -18,7 +18,7 @@ const { formatVersionBanner } = require('../lib/version-banner');
|
|
|
18
18
|
const { bundleInstallState, installChip, installDetailLine, chipIsChange } = require('../lib/install-state');
|
|
19
19
|
const { ledgerPath } = require('../lib/ledger');
|
|
20
20
|
const { WiringError, expectedWiringRecordsForManifest } = require('../lib/wiring');
|
|
21
|
-
const { applyModels, formatPlan, ModelsError } = require('../lib/modelsApply');
|
|
21
|
+
const { applyModels, applySourceModels, formatPlan, ModelsError } = require('../lib/modelsApply');
|
|
22
22
|
const { dispatchUsage, formatUsage } = require('../lib/modelsUsage');
|
|
23
23
|
const {
|
|
24
24
|
basicMenuBundles,
|
|
@@ -38,10 +38,12 @@ 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');
|
|
44
45
|
const { checkModVersions } = require('../lib/claudeVersion');
|
|
46
|
+
const memSafety = require('../lib/memSafety');
|
|
45
47
|
|
|
46
48
|
const PACKAGE_ROOT = path.join(__dirname, '..');
|
|
47
49
|
// One styler for the whole process: colors on only for a real TTY stdout
|
|
@@ -74,15 +76,20 @@ Usage:
|
|
|
74
76
|
under <dir>); --fix-project-hooks rewrites them to the fail-open launcher.
|
|
75
77
|
Also reports a project defaultMode weaker than the global one; with
|
|
76
78
|
--fix-project-hooks it is removed from settings.local.json
|
|
77
|
-
agents-cli models apply [--dry-run] [--target-dir <path>] Stamp models.json roles into agent frontmatter (model:)
|
|
78
|
-
settingsStamp keys of settings.json
|
|
79
|
-
(also runs on every install and update)
|
|
79
|
+
agents-cli models apply [--dry-run] [--target-dir <path>] Stamp models.json roles into agent frontmatter (model:), the
|
|
80
|
+
settingsStamp keys of settings.json and the <!--models--> fragment of CLAUDE.md;
|
|
81
|
+
--dry-run prints the diff and writes nothing (also runs on every install and update)
|
|
82
|
+
agents-cli models apply --source <repo> [--dry-run] Restamp global/CLAUDE.md of a repo checkout from its config/models.json
|
|
80
83
|
agents-cli models usage [--days N] [--json] [--target-dir <path>] Dispatch counts and share per role, read from the guard's dispatch log (read-only)
|
|
81
84
|
agents-cli secrets Prompt for any missing secrets across all installed bundles
|
|
82
85
|
agents-cli secrets --bundle <key> Prompt for missing secrets for one bundle
|
|
83
86
|
agents-cli secrets --list Show which secrets are set/missing (names only — never values)
|
|
84
87
|
agents-cli doctor [--fix] [--scan-root <dir>] Report orphaned/missing/drifted files under the install target
|
|
85
88
|
and project hooks that would brick a session if their file went missing
|
|
89
|
+
agents-cli sampler <status|register|unregister> [--dry-run] [--target-dir <path>]
|
|
90
|
+
The hidden ClaudeMemSampler task of the memory-safety stack (Windows).
|
|
91
|
+
install/update register it on their own for the default ~/.claude install;
|
|
92
|
+
--dry-run runs the registration script with -WhatIf and changes nothing
|
|
86
93
|
agents-cli runner <sub> [flags] Install and manage a self-hosted GitLab CI runner (see "Flags for runner")
|
|
87
94
|
agents-cli --help Show this help
|
|
88
95
|
|
|
@@ -94,6 +101,7 @@ Runtime deployment:
|
|
|
94
101
|
Flags for install:
|
|
95
102
|
--bundle <key> Bundle to install non-interactively — run "install" with no flags to list keys
|
|
96
103
|
--yes Required with --bundle: confirms the non-interactive install
|
|
104
|
+
--no-scheduled-tasks Skip registering the hidden ClaudeMemSampler task (also on update)
|
|
97
105
|
--advanced Interactive menu: show every bundle (incl. advanced) and pick items within one
|
|
98
106
|
--profile <public|self> Which bundles the menu/listing offers (default: public). "self" adds this
|
|
99
107
|
repo's maintainer-only bundles (self-infra, self-skills, ...) on top of the
|
|
@@ -172,6 +180,11 @@ Flags for runner:
|
|
|
172
180
|
Needs a GitLab PAT in GITLAB_RUNNER_PAT (or GITLAB_TOKEN): set it with "agents-cli secrets".
|
|
173
181
|
Exit codes: 0 ok, 1 a step failed, 2 usage error.
|
|
174
182
|
|
|
183
|
+
Memory-safety stack: the agent-orchestration bundle carries the chat ledger, the idle-process reclaimer, the
|
|
184
|
+
reaper_kill recorder, the heavy gate runner and the sampler. On Windows, install/update register the hidden
|
|
185
|
+
ClaudeMemSampler logon task (idempotent, never a visible window, only for the default ~/.claude install, never
|
|
186
|
+
under NODE_ENV=test). doctor reports the task, the wired hooks, the budget file and the newest memory sample.
|
|
187
|
+
|
|
175
188
|
Flags for doctor:
|
|
176
189
|
--target-dir <path> Install target base, default ~/.claude (use for testing)
|
|
177
190
|
--json Print a machine-readable report instead of prose
|
|
@@ -192,9 +205,13 @@ ahead of a real interpreter on PATH. --fix rewrites the bare tokens to "node <ta
|
|
|
192
205
|
it never edits PATH or App Execution Aliases.
|
|
193
206
|
|
|
194
207
|
doctor also flags a project .claude/settings.json or settings.local.json whose permissions.defaultMode is weaker
|
|
195
|
-
than
|
|
196
|
-
|
|
197
|
-
|
|
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.
|
|
198
215
|
|
|
199
216
|
doctor reports, without changing anything: orphans (files/directories sitting inside
|
|
200
217
|
a path this CLI manages that the ledger does not claim — e.g. a stale file left behind
|
|
@@ -210,7 +227,7 @@ deletes or modifies anything; deciding what to do about a finding is a separate
|
|
|
210
227
|
}
|
|
211
228
|
|
|
212
229
|
function parseInstallArgs(argv) {
|
|
213
|
-
const args = { bundle: null, yes: false, targetDir: null, targetConfig: null, advanced: false, noSecrets: false, profile: 'public' };
|
|
230
|
+
const args = { bundle: null, yes: false, targetDir: null, targetConfig: null, advanced: false, noSecrets: false, noScheduledTasks: false, profile: 'public' };
|
|
214
231
|
for (let i = 0; i < argv.length; i += 1) {
|
|
215
232
|
const arg = argv[i];
|
|
216
233
|
if (arg === '--bundle') {
|
|
@@ -231,6 +248,8 @@ function parseInstallArgs(argv) {
|
|
|
231
248
|
} else if (arg === '--profile') {
|
|
232
249
|
args.profile = argv[i + 1];
|
|
233
250
|
i += 1;
|
|
251
|
+
} else if (arg === '--no-scheduled-tasks') {
|
|
252
|
+
args.noScheduledTasks = true;
|
|
234
253
|
} else {
|
|
235
254
|
throw new InstallError(`Unknown install flag: ${arg}`);
|
|
236
255
|
}
|
|
@@ -312,6 +331,25 @@ function runSelfProfileStepsIfNeeded({ profile, targetDir }) {
|
|
|
312
331
|
return result;
|
|
313
332
|
}
|
|
314
333
|
|
|
334
|
+
/**
|
|
335
|
+
* Register (or start) the hidden ClaudeMemSampler task when the memory-safety stack is installed.
|
|
336
|
+
* Idempotent; Windows and the default ~/.claude install only. Never throws: a failure is reported, not fatal.
|
|
337
|
+
*/
|
|
338
|
+
function runMemSamplerStep({ targetDir, noScheduledTasks = false, quiet = false }) {
|
|
339
|
+
const targetBase = targetDir || defaultTargetBase();
|
|
340
|
+
const ledger = readLedgerSafely(targetBase);
|
|
341
|
+
if (!memSafety.stackInstalled(ledger)) return { action: 'skipped', message: 'memory-safety stack not installed.' };
|
|
342
|
+
const env = noScheduledTasks ? { ...process.env, AGENTS_CLI_NO_SCHEDULED_TASKS: '1' } : process.env;
|
|
343
|
+
let result;
|
|
344
|
+
try {
|
|
345
|
+
result = memSafety.ensureSampler({ targetBase, env });
|
|
346
|
+
} catch (err) {
|
|
347
|
+
result = { action: 'failed', message: `sampler registration error: ${err.message}` };
|
|
348
|
+
}
|
|
349
|
+
if (!quiet && !['skipped', 'blocked'].includes(result.action)) console.log(`\nMemory sampler: ${result.message}`);
|
|
350
|
+
return result;
|
|
351
|
+
}
|
|
352
|
+
|
|
315
353
|
/**
|
|
316
354
|
* Builds an install.js progress callback that renders a live, in-place
|
|
317
355
|
* (\r-redrawn) pip-style bar while files are copied — but only when stdout
|
|
@@ -530,7 +568,7 @@ function fetchLatestVersion(pkgName, { timeoutMs = 1500 } = {}) {
|
|
|
530
568
|
});
|
|
531
569
|
}
|
|
532
570
|
|
|
533
|
-
async function runInteractiveMenu({ advanced, targetDir, targetConfig, noSecrets, profile, captureSelection = false }) {
|
|
571
|
+
async function runInteractiveMenu({ advanced, targetDir, targetConfig, noSecrets, noScheduledTasks, profile, captureSelection = false }) {
|
|
534
572
|
const { manifest, manifestPath } = loadManifest(PACKAGE_ROOT);
|
|
535
573
|
const repoRoot = path.dirname(manifestPath);
|
|
536
574
|
const candidateBundles = advanced ? advancedMenuBundles(manifest, profile) : basicMenuBundles(manifest, profile);
|
|
@@ -620,6 +658,7 @@ async function runInteractiveMenu({ advanced, targetDir, targetConfig, noSecrets
|
|
|
620
658
|
|
|
621
659
|
if (installedBundles.length > 0) {
|
|
622
660
|
runSelfProfileStepsIfNeeded({ profile, targetDir });
|
|
661
|
+
runMemSamplerStep({ targetDir, noScheduledTasks });
|
|
623
662
|
}
|
|
624
663
|
|
|
625
664
|
printFinalSummary({ installed: installedResults, skipped, targetBase: targetDir || defaultTargetBase() });
|
|
@@ -646,6 +685,7 @@ async function runInstall(argv, { captureSelection = false } = {}) {
|
|
|
646
685
|
targetDir: args.targetDir,
|
|
647
686
|
targetConfig: args.targetConfig,
|
|
648
687
|
noSecrets: args.noSecrets,
|
|
688
|
+
noScheduledTasks: args.noScheduledTasks,
|
|
649
689
|
profile: args.profile,
|
|
650
690
|
captureSelection,
|
|
651
691
|
});
|
|
@@ -672,6 +712,7 @@ async function runInstall(argv, { captureSelection = false } = {}) {
|
|
|
672
712
|
manifest,
|
|
673
713
|
});
|
|
674
714
|
runSelfProfileStepsIfNeeded({ profile: args.profile, targetDir: args.targetDir });
|
|
715
|
+
runMemSamplerStep({ targetDir: args.targetDir, noScheduledTasks: args.noScheduledTasks });
|
|
675
716
|
printPythonSyncIssues([result]);
|
|
676
717
|
printModVersionWarnings([args.bundle], result.targetBase);
|
|
677
718
|
return 0;
|
|
@@ -968,7 +1009,7 @@ async function runSecrets(argv) {
|
|
|
968
1009
|
}
|
|
969
1010
|
|
|
970
1011
|
function parseUpdateArgs(argv) {
|
|
971
|
-
const args = { bundle: null, yes: false, targetDir: null, targetConfig: null, json: false, theirs: false, keepMine: false };
|
|
1012
|
+
const args = { bundle: null, yes: false, targetDir: null, targetConfig: null, json: false, theirs: false, keepMine: false, noScheduledTasks: false };
|
|
972
1013
|
for (let i = 0; i < argv.length; i += 1) {
|
|
973
1014
|
const arg = argv[i];
|
|
974
1015
|
if (arg === '--bundle') {
|
|
@@ -988,6 +1029,8 @@ function parseUpdateArgs(argv) {
|
|
|
988
1029
|
args.theirs = true;
|
|
989
1030
|
} else if (arg === '--keep-mine') {
|
|
990
1031
|
args.keepMine = true;
|
|
1032
|
+
} else if (arg === '--no-scheduled-tasks') {
|
|
1033
|
+
args.noScheduledTasks = true;
|
|
991
1034
|
} else {
|
|
992
1035
|
throw new UpdateError(`Unknown update flag: ${arg}`);
|
|
993
1036
|
}
|
|
@@ -1062,6 +1105,8 @@ async function runUpdate(argv) {
|
|
|
1062
1105
|
mcpConfigPath: args.targetConfig,
|
|
1063
1106
|
});
|
|
1064
1107
|
|
|
1108
|
+
result.memSampler = runMemSamplerStep({ targetDir: args.targetDir, noScheduledTasks: args.noScheduledTasks, quiet: true });
|
|
1109
|
+
|
|
1065
1110
|
if (args.json) {
|
|
1066
1111
|
console.log(JSON.stringify(result, null, 2));
|
|
1067
1112
|
return result.exitCode;
|
|
@@ -1086,6 +1131,7 @@ async function runUpdate(argv) {
|
|
|
1086
1131
|
}
|
|
1087
1132
|
}
|
|
1088
1133
|
|
|
1134
|
+
if (!['skipped', 'blocked'].includes(result.memSampler.action)) console.log(`Memory sampler: ${result.memSampler.message}`);
|
|
1089
1135
|
printModelsReport(result.models);
|
|
1090
1136
|
printPythonSyncIssues(result.bundles);
|
|
1091
1137
|
printModVersionWarnings(result.bundles.map((b) => b.bundle), result.targetBase);
|
|
@@ -1111,6 +1157,7 @@ async function runUpdate(argv) {
|
|
|
1111
1157
|
function runModels(argv) {
|
|
1112
1158
|
const [sub, ...rest] = argv;
|
|
1113
1159
|
let targetDir = null;
|
|
1160
|
+
let sourceRoot = null;
|
|
1114
1161
|
let dryRun = false;
|
|
1115
1162
|
let days = null;
|
|
1116
1163
|
let json = false;
|
|
@@ -1127,6 +1174,9 @@ function runModels(argv) {
|
|
|
1127
1174
|
} else if (rest[i] === '--target-dir') {
|
|
1128
1175
|
targetDir = rest[i + 1];
|
|
1129
1176
|
i += 1;
|
|
1177
|
+
} else if (rest[i] === '--source') {
|
|
1178
|
+
sourceRoot = rest[i + 1];
|
|
1179
|
+
i += 1;
|
|
1130
1180
|
} else if (rest[i] === '--dry-run') {
|
|
1131
1181
|
dryRun = true;
|
|
1132
1182
|
} else {
|
|
@@ -1141,25 +1191,26 @@ function runModels(argv) {
|
|
|
1141
1191
|
return 0;
|
|
1142
1192
|
}
|
|
1143
1193
|
if (sub !== 'apply') {
|
|
1144
|
-
console.error('Usage: agents-cli models apply [--dry-run] [--target-dir <path>] | models usage [--days N] [--json]');
|
|
1194
|
+
console.error('Usage: agents-cli models apply [--dry-run] [--target-dir <path> | --source <repo>] | models usage [--days N] [--json]');
|
|
1145
1195
|
return 1;
|
|
1146
1196
|
}
|
|
1147
1197
|
try {
|
|
1148
|
-
const ledger = loadLedger(targetBase, pkg.version);
|
|
1149
|
-
const result = applyModels({ targetBase, ledger, dryRun });
|
|
1198
|
+
const ledger = sourceRoot ? null : loadLedger(targetBase, pkg.version);
|
|
1199
|
+
const result = sourceRoot ? applySourceModels({ repoRoot: sourceRoot, dryRun }) : applyModels({ targetBase, ledger, dryRun });
|
|
1150
1200
|
if (!result.applied) {
|
|
1151
|
-
console.log(`No models.json at ${targetBase} — install a bundle first.`);
|
|
1201
|
+
console.log(sourceRoot ? `No config/models.json at ${sourceRoot}.` : `No models.json at ${targetBase} — install a bundle first.`);
|
|
1152
1202
|
return 1;
|
|
1153
1203
|
}
|
|
1154
1204
|
if (dryRun) {
|
|
1155
1205
|
for (const line of formatPlan(result)) console.log(line);
|
|
1156
1206
|
} else {
|
|
1157
|
-
saveLedger(targetBase, ledger);
|
|
1207
|
+
if (ledger) saveLedger(targetBase, ledger);
|
|
1158
1208
|
for (const a of result.agents) console.log(`${mark('ok')} ${a.file}: model ${a.to}`);
|
|
1159
1209
|
for (const s of result.settings) console.log(`${mark('ok')} settings.json ${s.key} set to ${s.to}`);
|
|
1210
|
+
for (const i of result.instructions) console.log(`${mark('ok')} ${i.file}: ${i.to}`);
|
|
1160
1211
|
}
|
|
1161
1212
|
for (const w of result.warnings) console.log(`${mark('skip')} ${w}`);
|
|
1162
|
-
if (result.agents.length === 0 && result.settings.length === 0) console.log('Already in sync with models.json.');
|
|
1213
|
+
if (result.agents.length === 0 && result.settings.length === 0 && result.instructions.length === 0) console.log('Already in sync with models.json.');
|
|
1163
1214
|
else if (dryRun) console.log('(dry run: nothing written)');
|
|
1164
1215
|
return 0;
|
|
1165
1216
|
} catch (err) {
|
|
@@ -1238,6 +1289,20 @@ function printPythonLaunchReport(py) {
|
|
|
1238
1289
|
if (py.findings.length > 0 && !py.fixRequested) console.log(` Fix: ${projectHooks.FIX_COMMAND}`);
|
|
1239
1290
|
}
|
|
1240
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
|
+
|
|
1241
1306
|
function printModeDriftReport(modes) {
|
|
1242
1307
|
if (modes.fixed.length > 0) {
|
|
1243
1308
|
console.log(`\nRemoved ${modes.fixed.length} defaultMode override(s) weaker than the global "${modes.globalMode}":`);
|
|
@@ -1280,7 +1345,7 @@ function splitProjectHookFlags(argv) {
|
|
|
1280
1345
|
return { rest, opts };
|
|
1281
1346
|
}
|
|
1282
1347
|
|
|
1283
|
-
async function withProjectHookStep(argv, run) {
|
|
1348
|
+
async function withProjectHookStep(argv, run, { healBypass = false } = {}) {
|
|
1284
1349
|
const { rest, opts } = splitProjectHookFlags(argv);
|
|
1285
1350
|
const code = await run(rest);
|
|
1286
1351
|
try {
|
|
@@ -1292,12 +1357,15 @@ async function withProjectHookStep(argv, run) {
|
|
|
1292
1357
|
});
|
|
1293
1358
|
if (step.error) console.error(step.error);
|
|
1294
1359
|
printProjectHookReport(step, { fixRequested: opts.fix });
|
|
1360
|
+
const targetBase = opts.targetDir || defaultTargetBase();
|
|
1361
|
+
printBypassOnlyReport(bypassOnly.checkBypassOnly({ targetBase, fix: healBypass || opts.fix }));
|
|
1295
1362
|
printModeDriftReport(
|
|
1296
1363
|
modeDrift.checkModeDrift({
|
|
1297
|
-
targetBase
|
|
1364
|
+
targetBase,
|
|
1298
1365
|
cwd: process.cwd(),
|
|
1299
1366
|
scanRoot: opts.scanRoot ? path.resolve(opts.scanRoot) : null,
|
|
1300
1367
|
fix: opts.fix,
|
|
1368
|
+
expectedMode: bypassOnly.BYPASS,
|
|
1301
1369
|
})
|
|
1302
1370
|
);
|
|
1303
1371
|
printRuleMigrationReport(
|
|
@@ -1333,7 +1401,8 @@ function runDoctor(argv) {
|
|
|
1333
1401
|
scanRoot: args.scanRoot ? path.resolve(args.scanRoot) : null,
|
|
1334
1402
|
targetBase: args.targetDir || defaultTargetBase(),
|
|
1335
1403
|
};
|
|
1336
|
-
const
|
|
1404
|
+
const bypass = bypassOnly.checkBypassOnly({ targetBase: scope.targetBase, fix: args.fix });
|
|
1405
|
+
const modes = modeDrift.checkModeDrift({ ...scope, fix: args.fix, expectedMode: bypassOnly.BYPASS });
|
|
1337
1406
|
const rules = permissionRules.checkRuleMigration({ ...scope, fix: args.fix });
|
|
1338
1407
|
const hooks = projectHooks.projectHooksStep({ ...scope, fix: args.fix });
|
|
1339
1408
|
if (hooks.error) {
|
|
@@ -1356,9 +1425,10 @@ function runDoctor(argv) {
|
|
|
1356
1425
|
const { fixed } = hooks;
|
|
1357
1426
|
result.projectHooks = { repos: hooks.repos, findings: hooks.findings, fixed };
|
|
1358
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 };
|
|
1359
1429
|
result.permissionRules = { findings: rules.findings, fixed: rules.fixed };
|
|
1360
1430
|
result.pythonLaunch = { files: py.files, findings: py.findings, fixed: py.fixed, missingLaunchers: py.missingLaunchers, interpreter: py.interpreter, stubs: py.stubs };
|
|
1361
|
-
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;
|
|
1362
1432
|
|
|
1363
1433
|
if (args.json) {
|
|
1364
1434
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -1367,6 +1437,7 @@ function runDoctor(argv) {
|
|
|
1367
1437
|
|
|
1368
1438
|
const printProjectHooks = () => printProjectHookReport(hooks, { fixRequested: args.fix });
|
|
1369
1439
|
const printModeDrift = () => {
|
|
1440
|
+
printBypassOnlyReport(bypass);
|
|
1370
1441
|
printModeDriftReport(modes);
|
|
1371
1442
|
printRuleMigrationReport(rules);
|
|
1372
1443
|
};
|
|
@@ -1394,6 +1465,15 @@ function runDoctor(argv) {
|
|
|
1394
1465
|
for (const f of m.findings) console.log(` ${memoryIndexCheck.describe(f)}`);
|
|
1395
1466
|
};
|
|
1396
1467
|
|
|
1468
|
+
const printMemorySafety = () => {
|
|
1469
|
+
const m = result.memorySafety;
|
|
1470
|
+
if (!m) return;
|
|
1471
|
+
console.log('\nMemory-safety stack:');
|
|
1472
|
+
for (const line of memSafety.describeMemorySafety(m)) console.log(` ${line}`);
|
|
1473
|
+
for (const f of m.findings) console.log(` ${mark('fail')} ${f}`);
|
|
1474
|
+
for (const w of m.warnings) console.log(` ${mark('skip')} ${w}`);
|
|
1475
|
+
};
|
|
1476
|
+
|
|
1397
1477
|
const printRoutingMod = () => {
|
|
1398
1478
|
if (!result.routingMod) return;
|
|
1399
1479
|
console.log('\nModel routing:');
|
|
@@ -1408,6 +1488,7 @@ function runDoctor(argv) {
|
|
|
1408
1488
|
printModValidation();
|
|
1409
1489
|
printMemoryIndex();
|
|
1410
1490
|
printRoutingMod();
|
|
1491
|
+
printMemorySafety();
|
|
1411
1492
|
printModeDrift();
|
|
1412
1493
|
return 0;
|
|
1413
1494
|
}
|
|
@@ -1429,6 +1510,7 @@ function runDoctor(argv) {
|
|
|
1429
1510
|
printModValidation();
|
|
1430
1511
|
printMemoryIndex();
|
|
1431
1512
|
printRoutingMod();
|
|
1513
|
+
printMemorySafety();
|
|
1432
1514
|
printProjectHooks();
|
|
1433
1515
|
printPythonLaunchReport(py);
|
|
1434
1516
|
printModeDrift();
|
|
@@ -1442,6 +1524,42 @@ function runDoctor(argv) {
|
|
|
1442
1524
|
}
|
|
1443
1525
|
}
|
|
1444
1526
|
|
|
1527
|
+
function runSampler(argv) {
|
|
1528
|
+
const [sub, ...rest] = argv;
|
|
1529
|
+
let targetDir = null;
|
|
1530
|
+
let dryRun = false;
|
|
1531
|
+
for (let i = 0; i < rest.length; i += 1) {
|
|
1532
|
+
if (rest[i] === '--target-dir') {
|
|
1533
|
+
targetDir = rest[i + 1];
|
|
1534
|
+
i += 1;
|
|
1535
|
+
} else if (rest[i] === '--dry-run') dryRun = true;
|
|
1536
|
+
else {
|
|
1537
|
+
console.error(`Unknown sampler flag: ${rest[i]}`);
|
|
1538
|
+
return 1;
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
const targetBase = targetDir || defaultTargetBase();
|
|
1542
|
+
if (sub === 'status') {
|
|
1543
|
+
const { manifest } = loadManifest(PACKAGE_ROOT);
|
|
1544
|
+
const ledger = readLedgerSafely(targetBase);
|
|
1545
|
+
const report = memSafety.checkMemorySafety({ manifest, ledger, targetBase });
|
|
1546
|
+
if (!report) {
|
|
1547
|
+
console.log('memory-safety stack not installed.');
|
|
1548
|
+
return 0;
|
|
1549
|
+
}
|
|
1550
|
+
for (const line of memSafety.describeMemorySafety(report)) console.log(line);
|
|
1551
|
+
for (const f of report.findings) console.log(`${mark('fail')} ${f}`);
|
|
1552
|
+
return report.healthy ? 0 : 1;
|
|
1553
|
+
}
|
|
1554
|
+
if (sub === 'register' || sub === 'unregister') {
|
|
1555
|
+
const result = sub === 'register' ? memSafety.ensureSampler({ targetBase, dryRun, force: !!targetDir }) : memSafety.unregisterSampler({ targetBase, dryRun });
|
|
1556
|
+
console.log(result.message);
|
|
1557
|
+
return result.action === 'failed' ? 1 : 0;
|
|
1558
|
+
}
|
|
1559
|
+
console.error('Usage: agents-cli sampler <status|register|unregister> [--dry-run] [--target-dir <path>]');
|
|
1560
|
+
return 1;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1445
1563
|
async function main(argv, { captureSelection = false } = {}) {
|
|
1446
1564
|
const [command, ...rest] = argv;
|
|
1447
1565
|
if (['install','update','uninstall','doctor'].includes(command)) {
|
|
@@ -1467,7 +1585,7 @@ async function main(argv, { captureSelection = false } = {}) {
|
|
|
1467
1585
|
}
|
|
1468
1586
|
|
|
1469
1587
|
if (command === 'install') {
|
|
1470
|
-
return withProjectHookStep(rest, args => runInstall(args, { captureSelection }));
|
|
1588
|
+
return withProjectHookStep(rest, args => runInstall(args, { captureSelection }), { healBypass: true });
|
|
1471
1589
|
}
|
|
1472
1590
|
|
|
1473
1591
|
if (command === 'uninstall') {
|
|
@@ -1479,7 +1597,7 @@ async function main(argv, { captureSelection = false } = {}) {
|
|
|
1479
1597
|
}
|
|
1480
1598
|
|
|
1481
1599
|
if (command === 'update') {
|
|
1482
|
-
return withProjectHookStep(rest, runUpdate);
|
|
1600
|
+
return withProjectHookStep(rest, runUpdate, { healBypass: true });
|
|
1483
1601
|
}
|
|
1484
1602
|
|
|
1485
1603
|
if (command === 'doctor') {
|
|
@@ -1490,6 +1608,10 @@ async function main(argv, { captureSelection = false } = {}) {
|
|
|
1490
1608
|
return runModels(rest);
|
|
1491
1609
|
}
|
|
1492
1610
|
|
|
1611
|
+
if (command === 'sampler') {
|
|
1612
|
+
return runSampler(rest);
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1493
1615
|
if (command === 'runner') {
|
|
1494
1616
|
return require('../lib/runner').runRunnerCommand(rest);
|
|
1495
1617
|
}
|
package/content/global/CLAUDE.md
CHANGED
|
@@ -5,7 +5,7 @@ When doing bug fixes, always start with reproducing the bug in an E2E setting as
|
|
|
5
5
|
Use git CLI for GitLab access, never glab — we use GitLab, not GitHub.
|
|
6
6
|
Always track multi-step work with TaskCreate/TaskList/TaskUpdate (persistent across sessions), falling back to TodoWrite only if Task tools are unavailable — never printed markdown checklists. Maintain the TODO list and update the one PRD gitlab issue or the MR for that chat session.
|
|
7
7
|
When planning or modifying work, start a wayfinder map for anything too big for one session, and always mirror the TODO items in that work's PRD/issue ticket so it stays current.
|
|
8
|
-
Never `taskkill /F` or force-stop a shared daemon or another session's process — it can be serving other concurrent chats too (confirmed incident: killing the shared router mid-session broke every other active chat); restart it gracefully via its own scheduled task instead.
|
|
8
|
+
Never `taskkill /F` or force-stop a shared daemon or another session's process — it can be serving other concurrent chats too (confirmed incident: killing the shared router mid-session broke every other active chat); restart it gracefully via its own scheduled task instead; the one exception is ledger-proven idle processes stopped by the reclaimer per docs/memory-safety.md.
|
|
9
9
|
Never open a visible window or steal focus: every command, script, scheduled task, or browser I launch (PowerShell, cmd, terminals, `Start-Process`, `start`, `wt`, headed Playwright/Chrome) must run headless/hidden in the background (`-WindowStyle Hidden`/`-NoNewWindow`, `pythonw`, hidden task settings, headless browser) unless the founder explicitly asked to watch it; a popup that grabs focus is a defect (repeated, confirmed founder complaint).
|
|
10
10
|
Grill the operator once per new goal to lock scope and shared understanding; once scope is locked, execute autonomously end-to-end without re-confirming each step — grilling gates scope, not execution.
|
|
11
11
|
Never open a git issue by yourself you need to explain the issue with complete context concisely in terms of customer facing functionality so user can take a decision if this is really an issue. User also want you to find out with thorough investigation if this is really an issue as the pending git issues spam is a real problem.
|
|
@@ -23,7 +23,7 @@ Be extremely proactive to take up the tasks from our pending list of tasks. Look
|
|
|
23
23
|
|
|
24
24
|
The main chat model is the founder's choice (`/model`); it is a scarce orchestration and planning resource, so subagents run only on the two roles below, never on the main-chat models.
|
|
25
25
|
|
|
26
|
-
Roles resolve to model IDs in `~/.claude/models.json` (repo `config/models.json`) — the one place an ID lives; change a role there, then run `agents-cli models apply`, to switch or roll back. Current: worker `claude-sonnet-5-5`, assistant `claude-haiku-5-5` (main-chat models: `claude-opus-5-5`, `claude-fable-5-1`)
|
|
26
|
+
Roles resolve to model IDs in `~/.claude/models.json` (repo `config/models.json`) — the one place an ID lives; change a role there, then run `agents-cli models apply`, to switch or roll back. <!--models-->Current: worker `claude-sonnet-5-5`, assistant `claude-haiku-5-5` (main-chat models: `claude-opus-5-5`, `claude-fable-5-1`)<!--/models-->.
|
|
27
27
|
|
|
28
28
|
| Role | Work | Subagent |
|
|
29
29
|
|---|---|---|
|
|
@@ -37,7 +37,8 @@ Standalone non-Claude subagents (an agent whose entire multi-turn loop runs as a
|
|
|
37
37
|
|
|
38
38
|
- Fan-out is the standing default, never a per-request instruction: anything not already in context (a new error, screenshot, log, file, ticket, git/AWS state) is looked up by a subagent that returns conclusions and saves them to one-brain; the main loop opens nothing itself except the one line a decision needs.
|
|
39
39
|
- Dispatch threshold: if the deliverable is > ~30 lines of file content, or > 2 mechanical steps (or any step whose raw output isn't needed verbatim for a decision), it goes to a subagent (worker by default, per the rule above) that returns conclusions only, never raw file dumps. Main loop holds only: reads needed for decisions, dispatch, review, and small edits to decision docs.
|
|
40
|
-
- On Agent/Task dispatch
|
|
40
|
+
- On Agent/Task dispatch never pass `model` or `effort`: the `agent_model_guard.py` hook and `model-routing` mod set the model from `models.json` (unregistered types -> worker; `Explore`, `claude-code-guide`, `statusline-setup` -> assistant; a requested opus/fable -> worker in every project) and effort defaults to `high`.
|
|
41
|
+
- A registered agent's `role:` (stamped into `model:` by `agents-cli models apply`) governs its model; its own `model:` is respected only if it is not an opus/fable family. A non-Claude model needs a registered agent whose own `model:` names it.
|
|
41
42
|
- Loop shape: the main chat plans → a subagent executes → the main chat adversarially reviews → return to user or re-instruct subagents.
|
|
42
43
|
|
|
43
44
|
## Memory-First (every session)
|
|
@@ -48,6 +49,8 @@ At the start of every session, before substantive work, call `mcp__claude_ai_one
|
|
|
48
49
|
|
|
49
50
|
**Surprise logging.** After investigating and due diligence if it is a revelation — log it to one-brain as BOTH `log_episode` and `remember` and also update the relevant PRDs and docs with the information fanning out. Applies whether the underlying task succeeds or fails.
|
|
50
51
|
|
|
52
|
+
**Compaction.** When compacting, always preserve: the PRD issue number, the active worktree path and branch, locked scope and grilling answers, pending decisions, and the TODO task list.
|
|
53
|
+
|
|
51
54
|
## Codify Over Instruct
|
|
52
55
|
|
|
53
56
|
Prefer code over natural-language rules. Mechanical constraints (paths, formats, naming, validity) belong in hooks/scripts/validators; word instructions are reserved for intent and judgement calls (creative direction, tone, priorities) that code cannot check.
|
|
@@ -61,7 +64,7 @@ Prefer code over natural-language rules. Mechanical constraints (paths, formats,
|
|
|
61
64
|
|
|
62
65
|
## Web Search Routing
|
|
63
66
|
|
|
64
|
-
Web search is routed by **code, not this prose**: the `web_search_guard.py` PreToolUse hook denies native `WebSearch` and redirects to the `web-search` skill (Perplexity Sonar via LiteLLM, cited). You don't have to remember to prefer it — the hook enforces it. On a Sonar error, retry `--model litellm_sonar`.
|
|
67
|
+
Web search is routed by **code, not this prose**: the `web_search_guard.py` PreToolUse hook denies native `WebSearch` and redirects to the `web-search` skill (Perplexity Sonar via LiteLLM, cited). You don't have to remember to prefer it — the hook enforces it. On a Sonar error, retry `--model litellm_sonar`.
|
|
65
68
|
|
|
66
69
|
## Memory Write Mandate
|
|
67
70
|
|
|
@@ -73,4 +76,4 @@ Whenever a session adds, edits, or removes an agent (`.agent.md`), a skill (`SKI
|
|
|
73
76
|
|
|
74
77
|
1. **GitLab issue.** Post an update to the relevant issue. Check for an existing on-topic thread first (e.g. a project's own "Agent Flow"-style issue) and append there; only open a new issue if the change is a genuinely distinct thread, not a continuation of ongoing work.
|
|
75
78
|
2. **Docs.** Update any project docs (README roster tables, architecture docs) the change affects, so they don't silently go stale relative to the actual code.
|
|
76
|
-
3. **Global vs. local — check my-agents.** `C:/dev/my-agents` is the canonical SOURCE for hooks/agents deployed to `~/.claude/` (e.g. `my-agents/proxy/*.py` → `~/.claude/proxy/*.py`, `my-agents/agents/*.md` → `~/.claude/agents/*.md`) —
|
|
79
|
+
3. **Global vs. local — check my-agents.** `C:/dev/my-agents` is the canonical SOURCE for hooks/agents deployed to `~/.claude/` (e.g. `my-agents/proxy/*.py` → `~/.claude/proxy/*.py`, `my-agents/agents/*.md` → `~/.claude/agents/*.md`) — they can silently diverge. If the change touched anything under `~/.claude/` (not a project-local `.claude/` directory), it is GLOBAL/shared — the same fix must also land in the matching my-agents source file, or flag explicitly why it doesn't apply there. This is a judgment call (is this change global-shared-infra vs. project-local?), not something a hook can auto-detect — always ask "did I just edit something under `~/.claude/`?" and if yes, check my-agents.
|