claude-usage-limits 1.19.0 → 1.23.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.
@@ -61,6 +61,8 @@ function parseArgs(argv) {
61
61
  for (let i = 0; i < argv.length; i += 1) {
62
62
  const arg = argv[i];
63
63
  if (arg === '--dry-run') args.dryRun = true;
64
+ // Codex only: leave the [agents] subagent clamp alone.
65
+ else if (arg === '--no-agents') args.agents = false;
64
66
  else if (arg === '--host') args.host = argv[++i];
65
67
  else if (arg.startsWith('--host=')) args.host = arg.slice(7);
66
68
  else if (arg === '--effort') args.effort = argv[++i];
@@ -169,6 +171,50 @@ function describe(settings, state) {
169
171
  return lines.join('\n');
170
172
  }
171
173
 
174
+ // Write down what was changed here, so "change my effort back" has a referent.
175
+ //
176
+ // This script is the ONLY thing in the plugin that writes settings.json, and
177
+ // it was the only change the log could not name: mode.js recorded fourteen
178
+ // kinds of mode-plane change and nothing ever wrote a user-plane entry, so
179
+ // `mode --history` answered "nothing has been changed through this plugin yet"
180
+ // immediately after this had rewritten the user's baseline, and undo's whole
181
+ // user-plane branch was unreachable code.
182
+ //
183
+ // Required lazily and inside a try: a settings write that already succeeded
184
+ // must not be reported as a failure because a log line could not be added, and
185
+ // this file otherwise depends on nothing.
186
+ //
187
+ // `by` is a reading of the environment, not a claim about intent. Claude Code
188
+ // and Codex both put a session id into the environment of everything they
189
+ // launch, so a run from inside an agent session is recorded as the agent's and
190
+ // a run from the user's own shell as theirs. It is the honest half of "at
191
+ // whose instruction": who typed it, not who wanted it.
192
+ function logSettingsChange(changes, direction, env) {
193
+ if (!changes || !changes.length) return;
194
+ const e = env || process.env;
195
+ const by = e.CLAUDE_SESSION_ID || e.CODEX_SESSION_ID ? 'claude' : 'user';
196
+ try {
197
+ const mode = require('./mode.js');
198
+ for (const change of changes) {
199
+ // "effortLevel: xhigh -> low", as planApply and planRestore build them.
200
+ const at = change.indexOf(': ');
201
+ const key = at === -1 ? change : change.slice(0, at);
202
+ const rest = at === -1 ? '' : change.slice(at + 2);
203
+ const arrow = rest.indexOf(' -> ');
204
+ mode.logChange({
205
+ plane: 'user',
206
+ key,
207
+ from: arrow === -1 ? null : rest.slice(0, arrow),
208
+ to: arrow === -1 ? rest || null : rest.slice(arrow + 4),
209
+ by,
210
+ reason: direction === 'off' ? 'lowpower off' : 'lowpower on',
211
+ });
212
+ }
213
+ } catch (err) {
214
+ // A record of the change is worth less than the change itself.
215
+ }
216
+ }
217
+
172
218
  function main(argv) {
173
219
  const args = parseArgs(argv);
174
220
  const host = require('./host.js');
@@ -196,6 +242,7 @@ function main(argv) {
196
242
  if (!state && fs.existsSync(file)) fs.copyFileSync(file, file + '.usage-limits-backup');
197
243
  writeJson(file, plan.settings);
198
244
  writeJson(stateFile(), plan.state);
245
+ logSettingsChange(plan.changes, 'on');
199
246
  process.stdout.write(
200
247
  'Low power on.\n ' + (plan.changes.join('\n ') || '(nothing to change)') + '\n' +
201
248
  'Applies to new sessions. For the session you are in, run /effort ' +
@@ -216,6 +263,7 @@ function main(argv) {
216
263
  }
217
264
  writeJson(file, plan.settings);
218
265
  fs.unlinkSync(stateFile());
266
+ logSettingsChange(plan.changes, 'off');
219
267
  process.stdout.write(
220
268
  'Low power off.\n ' + (plan.changes.join('\n ') || '(nothing to change)') + '\n'
221
269
  );