@imdeadpool/guardex 7.1.0 → 7.1.1

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 CHANGED
@@ -308,6 +308,15 @@ Being honest about where this still has issues:
308
308
  <details open>
309
309
  <summary><strong>v7.x</strong></summary>
310
310
 
311
+ ### v7.1.1
312
+ - Bumped `@imdeadpool/guardex` from `7.1.0` to `7.1.1` so the current
313
+ `main` payload can publish under a fresh npm version after `7.1.0` reached
314
+ the registry.
315
+ - Direct maintainer `npm publish` now checks npm during `prepublishOnly` and
316
+ bumps package release metadata to the next unpublished patch version when the
317
+ committed version is already published. GitHub Actions release publishes keep
318
+ the committed metadata so packed and signed assets stay aligned.
319
+
311
320
  ### v7.0.43
312
321
  - Budget-friendly CI defaults for gitguardex-managed projects: live
313
322
  workflows drop `push: main`, gate per-PR jobs on `pull_request.draft
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imdeadpool/guardex",
3
- "version": "7.1.0",
3
+ "version": "7.1.1",
4
4
  "description": "Guardian T-Rex for your multi-agent repo. Isolated worktrees, file locks, and PR-only merges stop parallel Codex & Claude agents from overwriting each other's work. Auto-wires Oh My Codex, Oh My Claude, OpenSpec, and Caveman.",
5
5
  "license": "MIT",
6
6
  "preferGlobal": true,
@@ -12,6 +12,7 @@
12
12
  },
13
13
  "scripts": {
14
14
  "test": "node --test test/*.test.js",
15
+ "prepublishOnly": "node scripts/prepublish-bump-version.js",
15
16
  "agent:codex": "bash ./scripts/codex-agent.sh",
16
17
  "agent:branch:start": "bash ./scripts/agent-branch-start.sh",
17
18
  "agent:branch:finish": "bash ./scripts/agent-branch-finish.sh",
@@ -40,6 +41,7 @@
40
41
  "files": [
41
42
  "bin",
42
43
  "src",
44
+ "scripts/prepublish-bump-version.js",
43
45
  "skills",
44
46
  "templates",
45
47
  "README.md",
@@ -0,0 +1,191 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const cp = require('node:child_process');
5
+ const fs = require('node:fs');
6
+ const path = require('node:path');
7
+
8
+ function readJson(filePath) {
9
+ return JSON.parse(fs.readFileSync(filePath, 'utf8'));
10
+ }
11
+
12
+ function writeJson(filePath, value) {
13
+ fs.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`, 'utf8');
14
+ }
15
+
16
+ function escapeRegexLiteral(value) {
17
+ return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
18
+ }
19
+
20
+ function nextPatchVersion(version) {
21
+ const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(String(version || '').trim());
22
+ if (!match) {
23
+ throw new Error(`Cannot auto-bump non-plain semver version: ${version}`);
24
+ }
25
+ return `${match[1]}.${match[2]}.${Number(match[3]) + 1}`;
26
+ }
27
+
28
+ function defaultNpmView(name, version) {
29
+ const result = cp.spawnSync('npm', ['view', `${name}@${version}`, 'version', '--json'], {
30
+ encoding: 'utf8',
31
+ stdio: ['ignore', 'pipe', 'pipe'],
32
+ });
33
+
34
+ if (result.status === 0) {
35
+ return { state: 'published' };
36
+ }
37
+
38
+ const details = `${result.stdout || ''}\n${result.stderr || ''}`.trim();
39
+ if (/E404|404\s+Not Found|No match found|is not in this registry/i.test(details)) {
40
+ return { state: 'unpublished' };
41
+ }
42
+
43
+ if (result.error) {
44
+ return { state: 'error', message: result.error.message };
45
+ }
46
+
47
+ return { state: 'error', message: details || `npm view exited with status ${result.status}` };
48
+ }
49
+
50
+ function shouldSkip(env) {
51
+ if (env.GUARDEX_SKIP_PUBLISH_BUMP === '1') {
52
+ return 'GUARDEX_SKIP_PUBLISH_BUMP=1';
53
+ }
54
+ if (env.npm_config_dry_run === 'true') {
55
+ return 'npm publish --dry-run';
56
+ }
57
+ if (env.GITHUB_ACTIONS === 'true' && env.GUARDEX_ALLOW_PUBLISH_BUMP !== '1') {
58
+ return 'GitHub Actions release workflows keep package.json as the release source of truth';
59
+ }
60
+ return null;
61
+ }
62
+
63
+ function findPublishableVersion({ name, version, npmView, maxAttempts = 100 }) {
64
+ let candidate = version;
65
+ for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
66
+ const check = npmView(name, candidate);
67
+ if (check.state === 'unpublished') {
68
+ return { version: candidate, changed: candidate !== version };
69
+ }
70
+ if (check.state !== 'published') {
71
+ throw new Error(
72
+ `Unable to verify ${name}@${candidate} on npm: ${check.message || `state=${check.state}`}`,
73
+ );
74
+ }
75
+ candidate = nextPatchVersion(candidate);
76
+ }
77
+
78
+ throw new Error(`Unable to find an unpublished patch version after ${maxAttempts} attempts`);
79
+ }
80
+
81
+ function updatePackageLock(repoRoot, name, version) {
82
+ const lockPath = path.join(repoRoot, 'package-lock.json');
83
+ if (!fs.existsSync(lockPath)) {
84
+ return false;
85
+ }
86
+
87
+ const lockfile = readJson(lockPath);
88
+ lockfile.name = name;
89
+ lockfile.version = version;
90
+ if (lockfile.packages && lockfile.packages['']) {
91
+ lockfile.packages[''].name = name;
92
+ lockfile.packages[''].version = version;
93
+ }
94
+ writeJson(lockPath, lockfile);
95
+ return true;
96
+ }
97
+
98
+ function buildReleaseNote(name, previousVersion, version) {
99
+ return (
100
+ `### v${version}\n` +
101
+ `- Bumped \`${name}\` from \`${previousVersion}\` to \`${version}\` so direct\n` +
102
+ ` \`npm publish\` can continue after \`${previousVersion}\` reached the registry.\n\n`
103
+ );
104
+ }
105
+
106
+ function updateReadmeReleaseNote(repoRoot, name, previousVersion, version) {
107
+ const readmePath = path.join(repoRoot, 'README.md');
108
+ if (!fs.existsSync(readmePath)) {
109
+ return false;
110
+ }
111
+
112
+ const readme = fs.readFileSync(readmePath, 'utf8');
113
+ const headingPattern = new RegExp(`^###\\s+v${escapeRegexLiteral(version)}\\b`, 'm');
114
+ if (headingPattern.test(readme)) {
115
+ return false;
116
+ }
117
+
118
+ const releaseNote = buildReleaseNote(name, previousVersion, version);
119
+ const major = String(version).split('.')[0];
120
+ const majorSummaryPattern = new RegExp(
121
+ `(<summary><strong>v${escapeRegexLiteral(major)}\\.x</strong></summary>\\n\\n)`,
122
+ );
123
+ if (majorSummaryPattern.test(readme)) {
124
+ fs.writeFileSync(readmePath, readme.replace(majorSummaryPattern, `$1${releaseNote}`), 'utf8');
125
+ return true;
126
+ }
127
+
128
+ if (/## Release notes\n\n/.test(readme)) {
129
+ fs.writeFileSync(readmePath, readme.replace(/## Release notes\n\n/, `## Release notes\n\n${releaseNote}`), 'utf8');
130
+ return true;
131
+ }
132
+
133
+ throw new Error('README.md is missing a Release notes section for the generated publish bump');
134
+ }
135
+
136
+ function runPrepublishBump(options = {}) {
137
+ const repoRoot = options.repoRoot || path.resolve(__dirname, '..');
138
+ const env = options.env || process.env;
139
+ const log = options.log || console.log;
140
+ const npmView = options.npmView || defaultNpmView;
141
+ const skipReason = shouldSkip(env);
142
+
143
+ if (skipReason) {
144
+ log(`[guardex] prepublish version bump skipped: ${skipReason}.`);
145
+ return { changed: false, reason: 'skipped' };
146
+ }
147
+
148
+ const packagePath = path.join(repoRoot, 'package.json');
149
+ const packageJson = readJson(packagePath);
150
+ if (!packageJson.name || !packageJson.version) {
151
+ throw new Error('package.json must include name and version before publish');
152
+ }
153
+
154
+ const next = findPublishableVersion({
155
+ name: packageJson.name,
156
+ version: packageJson.version,
157
+ npmView,
158
+ });
159
+
160
+ if (!next.changed) {
161
+ log(`[guardex] ${packageJson.name}@${packageJson.version} is not published yet; keeping package version.`);
162
+ return { changed: false, version: packageJson.version };
163
+ }
164
+
165
+ const previousVersion = packageJson.version;
166
+ packageJson.version = next.version;
167
+ writeJson(packagePath, packageJson);
168
+ updatePackageLock(repoRoot, packageJson.name, next.version);
169
+ updateReadmeReleaseNote(repoRoot, packageJson.name, previousVersion, next.version);
170
+ log(`[guardex] bumped ${packageJson.name} from ${previousVersion} to ${next.version} before npm publish.`);
171
+ return { changed: true, version: next.version, previousVersion };
172
+ }
173
+
174
+ if (require.main === module) {
175
+ try {
176
+ runPrepublishBump();
177
+ } catch (error) {
178
+ console.error(`[guardex] prepublish version bump failed: ${error.message}`);
179
+ process.exitCode = 1;
180
+ }
181
+ }
182
+
183
+ module.exports = {
184
+ defaultNpmView,
185
+ buildReleaseNote,
186
+ findPublishableVersion,
187
+ nextPatchVersion,
188
+ runPrepublishBump,
189
+ shouldSkip,
190
+ updateReadmeReleaseNote,
191
+ };
@@ -0,0 +1,279 @@
1
+ 'use strict';
2
+
3
+ // Live agent-lane activity: the W1 producer (`gx agents set-status`) and the
4
+ // jump selector (`gx agents jump`). The core functions are dependency-injected
5
+ // (session store + surface writer) so they unit-test without a live tmux/kitty.
6
+ const path = require('node:path');
7
+
8
+ const { TOOL_NAME } = require('../context');
9
+ const {
10
+ readAgentSession,
11
+ listAgentSessions,
12
+ updateAgentSession,
13
+ } = require('./sessions');
14
+ const { selectTerminalBackend } = require('../terminal');
15
+
16
+ // Canonical states a lane can be in, surfaced as cockpit pane icons.
17
+ const ACTIVITY_STATES = ['working', 'waiting', 'done', 'idle'];
18
+
19
+ const DEFAULT_ICONS = {
20
+ working: '🤖',
21
+ waiting: '💬',
22
+ done: '✅',
23
+ idle: '·',
24
+ };
25
+
26
+ // Aliases an agent hook or human might send; everything maps to one canonical
27
+ // state so callers do not need to memorize exact tokens.
28
+ const ACTIVITY_ALIASES = {
29
+ work: 'working',
30
+ working: 'working',
31
+ busy: 'working',
32
+ running: 'working',
33
+ active: 'working',
34
+ thinking: 'working',
35
+ wait: 'waiting',
36
+ waiting: 'waiting',
37
+ input: 'waiting',
38
+ blocked: 'waiting',
39
+ prompt: 'waiting',
40
+ attention: 'waiting',
41
+ done: 'done',
42
+ complete: 'done',
43
+ completed: 'done',
44
+ finished: 'done',
45
+ stop: 'done',
46
+ idle: 'idle',
47
+ none: 'idle',
48
+ clear: 'idle',
49
+ };
50
+
51
+ // Lower-priority jump targets sort after; waiting outranks done.
52
+ const JUMP_PRIORITY = { waiting: 0, done: 1 };
53
+
54
+ function normalizeActivity(raw) {
55
+ const key = String(raw === undefined || raw === null ? '' : raw).trim().toLowerCase();
56
+ if (!key) return '';
57
+ if (ACTIVITY_ALIASES[key]) return ACTIVITY_ALIASES[key];
58
+ return ACTIVITY_STATES.includes(key) ? key : '';
59
+ }
60
+
61
+ function activityIcon(activity, icons = DEFAULT_ICONS) {
62
+ const normalized = normalizeActivity(activity);
63
+ return (icons && icons[normalized]) || '';
64
+ }
65
+
66
+ function laneName(session) {
67
+ const value = session && typeof session === 'object' ? session : {};
68
+ const branch = typeof value.branch === 'string' ? value.branch : '';
69
+ const tail = branch.includes('/') ? branch.slice(branch.lastIndexOf('/') + 1) : branch;
70
+ const title = typeof value.title === 'string' ? value.title.trim() : '';
71
+ return title || tail || (typeof value.id === 'string' ? value.id : '') || 'agent';
72
+ }
73
+
74
+ // "🤖 fix-auth" — icon plus the short lane name. Falls back gracefully when an
75
+ // icon or name is missing.
76
+ function windowLabel(session, activity, icons = DEFAULT_ICONS) {
77
+ const icon = activityIcon(activity, icons);
78
+ const name = laneName(session);
79
+ if (!icon) return name;
80
+ return name ? `${icon} ${name}` : icon;
81
+ }
82
+
83
+ function sessionPaneTarget(session) {
84
+ const value = session && typeof session === 'object' ? session : {};
85
+ const tmux = value.tmux && typeof value.tmux === 'object' ? value.tmux : {};
86
+ return (
87
+ tmux.target ||
88
+ tmux.paneId ||
89
+ value.tmuxTarget ||
90
+ tmux.session ||
91
+ value.tmuxSession ||
92
+ ''
93
+ );
94
+ }
95
+
96
+ function sessionBackendName(session) {
97
+ const value = session && typeof session === 'object' ? session : {};
98
+ const tmux = value.tmux && typeof value.tmux === 'object' ? value.tmux : {};
99
+ if (tmux.backend) return String(tmux.backend);
100
+ if (value.terminal) return String(value.terminal);
101
+ return 'tmux';
102
+ }
103
+
104
+ function resolveSession(repoRoot, options = {}, deps = {}) {
105
+ const read = deps.readAgentSession || readAgentSession;
106
+ const list = deps.listAgentSessions || listAgentSessions;
107
+
108
+ // A malformed --session id or a corrupt session file must surface as a clean
109
+ // "no lane matched", not a thrown stack trace.
110
+ try {
111
+ if (options.sessionId) {
112
+ return read(repoRoot, options.sessionId);
113
+ }
114
+
115
+ const sessions = list(repoRoot);
116
+ if (options.branch) {
117
+ return sessions.find((session) => session.branch === options.branch) || null;
118
+ }
119
+
120
+ const worktree = options.worktree || options.cwd;
121
+ if (worktree) {
122
+ const target = path.resolve(worktree);
123
+ return (
124
+ sessions.find(
125
+ (session) => session.worktreePath && path.resolve(session.worktreePath) === target,
126
+ ) || null
127
+ );
128
+ }
129
+ } catch (_error) {
130
+ return null;
131
+ }
132
+ return null;
133
+ }
134
+
135
+ // Best-effort: apply the status label to the lane's pane. Never throws — a dead
136
+ // or absent multiplexer must not fail set-status.
137
+ function applySurface(context, deps = {}) {
138
+ const { target, label } = context;
139
+ if (!target) return { applied: false, reason: 'no-target' };
140
+ const apply = deps.applyWindowStatus;
141
+ if (typeof apply !== 'function') return { applied: false, reason: 'no-surface' };
142
+ try {
143
+ apply({ target, label, backend: sessionBackendName(context.session), activity: context.activity });
144
+ return { applied: true };
145
+ } catch (error) {
146
+ return { applied: false, reason: 'surface-error', error: error && error.message };
147
+ }
148
+ }
149
+
150
+ // Producer core: persist the activity onto the session and (best-effort) write
151
+ // its label to the cockpit pane. `deps` injects the session store + surface.
152
+ function setAgentActivity(repoRoot, options = {}, deps = {}) {
153
+ const activity = normalizeActivity(options.activity);
154
+ if (!activity) {
155
+ throw new Error(
156
+ `Unknown agent activity: ${options.activity}. Use one of: ${ACTIVITY_STATES.join(', ')}.`,
157
+ );
158
+ }
159
+
160
+ const session = resolveSession(repoRoot, options, deps);
161
+ if (!session) {
162
+ return { ok: false, reason: 'session-not-found', activity };
163
+ }
164
+
165
+ const update = deps.updateAgentSession || updateAgentSession;
166
+ const updated = update(repoRoot, session.id, { activity }) || session;
167
+ const label = windowLabel(updated, activity, options.icons);
168
+ const target = sessionPaneTarget(updated);
169
+ const surface = applySurface({ session: updated, label, target, activity }, deps);
170
+
171
+ return { ok: true, activity, sessionId: session.id, label, target, surface };
172
+ }
173
+
174
+ function jumpFilter(options = {}) {
175
+ if (options.waiting && !options.done) return new Set(['waiting']);
176
+ if (options.done && !options.waiting) return new Set(['done']);
177
+ return new Set(['waiting', 'done']);
178
+ }
179
+
180
+ // Pick the lane most in need of attention: waiting before done, newest first,
181
+ // restricted to lanes that actually have a cockpit pane to focus.
182
+ function selectJumpTarget(sessions, options = {}) {
183
+ const wanted = jumpFilter(options);
184
+ const candidates = (Array.isArray(sessions) ? sessions : [])
185
+ .filter((session) => wanted.has(normalizeActivity(session.activity)))
186
+ .filter((session) => sessionPaneTarget(session));
187
+
188
+ candidates.sort((left, right) => {
189
+ const leftPriority = JUMP_PRIORITY[normalizeActivity(left.activity)] ?? 9;
190
+ const rightPriority = JUMP_PRIORITY[normalizeActivity(right.activity)] ?? 9;
191
+ if (leftPriority !== rightPriority) return leftPriority - rightPriority;
192
+ return String(right.updatedAt || '').localeCompare(String(left.updatedAt || ''));
193
+ });
194
+
195
+ return candidates[0] || null;
196
+ }
197
+
198
+ // CLI wrapper for `gx agents set-status`: wires the live terminal backend in as
199
+ // the surface writer, then delegates to the pure core.
200
+ function runSetStatusCommand(repoRoot, options = {}, deps = {}) {
201
+ // When invoked from inside a lane (e.g. an agent hook) with no explicit
202
+ // selector, fall back to the current working directory's worktree.
203
+ const resolved = options.sessionId || options.branch || options.worktree
204
+ ? options
205
+ : { ...options, worktree: process.cwd() };
206
+ let backend = null;
207
+ const result = setAgentActivity(repoRoot, resolved, {
208
+ ...deps,
209
+ applyWindowStatus({ target, label, backend: sessionBackend }) {
210
+ // Honor an explicit --backend, else the lane's recorded backend (matching
211
+ // runJumpCommand), else auto-detect.
212
+ const backendName = options.backend || sessionBackend || 'auto';
213
+ if (!backend) backend = (deps.selectTerminalBackend || selectTerminalBackend)(backendName);
214
+ if (backend && typeof backend.setWindowStatus === 'function') {
215
+ backend.setWindowStatus(target, label);
216
+ }
217
+ },
218
+ });
219
+
220
+ if (!result.ok) {
221
+ return {
222
+ status: 1,
223
+ stderr: `[${TOOL_NAME}] No agent lane matched for set-status (use --session, --branch, or --worktree).\n`,
224
+ };
225
+ }
226
+
227
+ const applied = result.surface && result.surface.applied;
228
+ const note = applied ? '' : ` (surface ${result.surface ? result.surface.reason : 'skipped'})`;
229
+ return {
230
+ status: 0,
231
+ stdout: `[${TOOL_NAME}] ${result.sessionId} -> ${result.activity} ${result.label}${note}\n`,
232
+ };
233
+ }
234
+
235
+ // CLI wrapper for `gx agents jump`.
236
+ function runJumpCommand(repoRoot, options = {}, deps = {}) {
237
+ const list = deps.listAgentSessions || listAgentSessions;
238
+ const target = selectJumpTarget(list(repoRoot), options);
239
+ if (!target) {
240
+ return { status: 1, stderr: `[${TOOL_NAME}] No waiting/done agent lane to jump to.\n` };
241
+ }
242
+
243
+ const paneTarget = sessionPaneTarget(target);
244
+ if (options.print) {
245
+ return { status: 0, stdout: `${paneTarget}\n` };
246
+ }
247
+
248
+ try {
249
+ const backendName = options.backend || sessionBackendName(target);
250
+ const backend = (deps.selectTerminalBackend || selectTerminalBackend)(backendName);
251
+ backend.focusPane(paneTarget);
252
+ } catch (error) {
253
+ return {
254
+ status: 1,
255
+ stderr: `[${TOOL_NAME}] Could not focus ${paneTarget}: ${error && error.message}\n`,
256
+ };
257
+ }
258
+
259
+ return {
260
+ status: 0,
261
+ stdout: `[${TOOL_NAME}] Jumped to ${target.id} (${normalizeActivity(target.activity)}) ${paneTarget}\n`,
262
+ };
263
+ }
264
+
265
+ module.exports = {
266
+ ACTIVITY_STATES,
267
+ DEFAULT_ICONS,
268
+ normalizeActivity,
269
+ activityIcon,
270
+ laneName,
271
+ windowLabel,
272
+ sessionPaneTarget,
273
+ sessionBackendName,
274
+ resolveSession,
275
+ setAgentActivity,
276
+ selectJumpTarget,
277
+ runSetStatusCommand,
278
+ runJumpCommand,
279
+ };
package/src/cli/args.js CHANGED
@@ -373,6 +373,12 @@ function parseAgentsArgs(rawArgs) {
373
373
  sessionId: '',
374
374
  finishArgs: [],
375
375
  metadata: {},
376
+ activity: '',
377
+ worktree: '',
378
+ backend: '',
379
+ waiting: false,
380
+ done: false,
381
+ print: false,
376
382
  };
377
383
  let terminalProvided = false;
378
384
 
@@ -421,6 +427,54 @@ function parseAgentsArgs(rawArgs) {
421
427
  index += 1;
422
428
  continue;
423
429
  }
430
+ if (arg === '--session') {
431
+ const next = rest[index + 1];
432
+ if (!next) {
433
+ throw new Error('--session requires an agent session id');
434
+ }
435
+ options.sessionId = next;
436
+ index += 1;
437
+ continue;
438
+ }
439
+ if (arg === '--activity' || arg === '--status') {
440
+ const next = rest[index + 1];
441
+ if (!next || next.startsWith('-')) {
442
+ throw new Error('--activity requires a state (working, waiting, done, idle)');
443
+ }
444
+ options.activity = next;
445
+ index += 1;
446
+ continue;
447
+ }
448
+ if (arg === '--worktree') {
449
+ const next = rest[index + 1];
450
+ if (!next) {
451
+ throw new Error('--worktree requires a path');
452
+ }
453
+ options.worktree = next;
454
+ index += 1;
455
+ continue;
456
+ }
457
+ if (arg === '--backend') {
458
+ const next = rest[index + 1];
459
+ if (!next || next.startsWith('-')) {
460
+ throw new Error('--backend requires auto, kitty, or tmux');
461
+ }
462
+ options.backend = next;
463
+ index += 1;
464
+ continue;
465
+ }
466
+ if (arg === '--waiting') {
467
+ options.waiting = true;
468
+ continue;
469
+ }
470
+ if (arg === '--done') {
471
+ options.done = true;
472
+ continue;
473
+ }
474
+ if (arg === '--print') {
475
+ options.print = true;
476
+ continue;
477
+ }
424
478
  if (arg === '--json') {
425
479
  options.json = true;
426
480
  continue;
@@ -592,7 +646,7 @@ function parseAgentsArgs(rawArgs) {
592
646
  throw new Error(`Unknown option: ${arg}`);
593
647
  }
594
648
 
595
- if (!['start', 'stop', 'status', 'files', 'diff', 'locks', 'finish', 'cleanup-sessions'].includes(options.subcommand)) {
649
+ if (!['start', 'stop', 'status', 'files', 'diff', 'locks', 'finish', 'cleanup-sessions', 'set-status', 'jump'].includes(options.subcommand)) {
596
650
  throw new Error(`Unknown agents subcommand: ${options.subcommand}`);
597
651
  }
598
652
  if (options.pid !== null && options.subcommand !== 'stop') {
@@ -638,8 +692,17 @@ function parseAgentsArgs(rawArgs) {
638
692
  throw new Error('agents finish accepts only one of --session or --branch');
639
693
  }
640
694
  }
641
- if (options.branch && !['files', 'diff', 'locks', 'finish'].includes(options.subcommand)) {
642
- throw new Error('--branch is only supported with `gx agents files|diff|locks|finish`');
695
+ if (options.branch && !['files', 'diff', 'locks', 'finish', 'set-status', 'jump'].includes(options.subcommand)) {
696
+ throw new Error('--branch is only supported with `gx agents files|diff|locks|finish|set-status|jump`');
697
+ }
698
+ if ((options.activity || options.worktree) && !['set-status'].includes(options.subcommand)) {
699
+ throw new Error('--activity and --worktree are only supported with `gx agents set-status`');
700
+ }
701
+ if ((options.waiting || options.done || options.print) && !['jump'].includes(options.subcommand)) {
702
+ throw new Error('--waiting, --done, and --print are only supported with `gx agents jump`');
703
+ }
704
+ if (options.subcommand === 'set-status' && !options.activity) {
705
+ throw new Error('gx agents set-status requires --activity <working|waiting|done|idle>');
643
706
  }
644
707
  if (
645
708
  options.json &&
@@ -11,6 +11,7 @@ const { resolveRepoRoot } = require('../../git');
11
11
  const { run } = require('../../core/runtime');
12
12
  const agentInspect = require('../../agents/inspect');
13
13
  const agentStatus = require('../../agents/status');
14
+ const agentActivity = require('../../agents/activity');
14
15
  const agentCleanupSessions = require('../../agents/cleanup-sessions');
15
16
  const agentsFinishModule = require('../../agents/finish');
16
17
  const agentsStart = require('../../agents/start');
@@ -171,6 +172,22 @@ function agents(rawArgs) {
171
172
  const repoRoot = resolveRepoRoot(options.target);
172
173
  const statePath = agentsStatePathForRepo(repoRoot);
173
174
 
175
+ if (options.subcommand === 'set-status') {
176
+ const result = agentActivity.runSetStatusCommand(repoRoot, options);
177
+ if (result.stdout) process.stdout.write(result.stdout);
178
+ if (result.stderr) process.stderr.write(result.stderr);
179
+ process.exitCode = result.status;
180
+ return;
181
+ }
182
+
183
+ if (options.subcommand === 'jump') {
184
+ const result = agentActivity.runJumpCommand(repoRoot, options);
185
+ if (result.stdout) process.stdout.write(result.stdout);
186
+ if (result.stderr) process.stderr.write(result.stderr);
187
+ process.exitCode = result.status;
188
+ return;
189
+ }
190
+
174
191
  if (options.subcommand === 'finish') {
175
192
  const result = finishAgentSession(repoRoot, options);
176
193
  if (options.json) {
@@ -329,6 +329,29 @@ function whoOwns(file, { cwd = process.cwd(), repoPath } = {}) {
329
329
  return { file: rel, owner: owners.length === 1 ? owners[0] : null, owners, conflict: owners.length > 1 };
330
330
  }
331
331
 
332
+ // Slim "radar" projection of a lane for list_agents — who-is-on-what at a
333
+ // glance, ~80% smaller than the full record. File LISTS collapse to counts and
334
+ // the worktree path is dropped; an agent that needs detail (worktree path,
335
+ // exact dirty/lock files, full PR) calls repo_state / my_context, or passes
336
+ // detail:true to list_agents. Pure.
337
+ function radarRecord(a) {
338
+ const r = { repo: a.repo, branch: a.branch };
339
+ if (a.agent) r.agent = a.agent;
340
+ if (a.task && a.task !== a.branch) r.task = a.task;
341
+ if (a.dirty && a.dirty.length) r.dirty = a.dirty.length;
342
+ if (a.locks && a.locks.length) r.locks = a.locks.length;
343
+ if (a.pr && a.pr.number != null) r.pr = a.pr.number;
344
+ if (a.prLookupError) r.prLookupError = a.prLookupError;
345
+ if (a.lastCommit && a.lastCommit.date) r.last = a.lastCommit.date.slice(0, 10);
346
+ if (a.stale) {
347
+ r.stale = true;
348
+ if (a.ageDays != null) r.ageDays = a.ageDays; // age is the actionable bit for a prune candidate
349
+ }
350
+ if (a.warning) r.onPrimary = true; // lane editing the primary checkout (unsafe)
351
+ if (a.pushed === false) r.unpushed = true;
352
+ return r;
353
+ }
354
+
332
355
  function myContext({ cwd = process.cwd(), includePr = true } = {}) {
333
356
  const here = git(cwd, ['rev-parse', '--show-toplevel']);
334
357
  if (!here) return { error: 'not a git repo', cwd };
@@ -358,6 +381,7 @@ module.exports = {
358
381
  repoState,
359
382
  whoOwns,
360
383
  myContext,
384
+ radarRecord,
361
385
  indexPrsByBranch,
362
386
  daysSince,
363
387
  STALE_DAYS,