@imdeadpool/guardex 8.4.0 → 8.4.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.
Files changed (97) hide show
  1. package/CONTRIBUTING.md +13 -4
  2. package/README.md +223 -1
  3. package/THIRD-PARTY-NOTICES.md +29 -0
  4. package/bin/multiagent-safety.js +9 -12
  5. package/package.json +4 -2
  6. package/skills/gitguardex/SKILL.md +28 -0
  7. package/skills/pr-lens/SKILL.md +87 -0
  8. package/src/abide.js +534 -0
  9. package/src/agents/activity.js +23 -4
  10. package/src/agents/inspect.js +15 -6
  11. package/src/agents/launch.js +6 -1
  12. package/src/agents/process-lease.js +84 -0
  13. package/src/agents/sessions.js +96 -16
  14. package/src/agents/start.js +18 -9
  15. package/src/agents/status.js +35 -14
  16. package/src/agents/supervise.js +87 -0
  17. package/src/budget/index.js +6 -1
  18. package/src/cli/args.js +71 -77
  19. package/src/cli/commands/agents.js +38 -10
  20. package/src/cli/commands/branch.js +116 -103
  21. package/src/cli/commands/claude.js +604 -50
  22. package/src/cli/commands/codex.js +359 -0
  23. package/src/cli/commands/context.js +52 -0
  24. package/src/cli/commands/mcp.js +5 -1
  25. package/src/cli/commands/pr.js +138 -3
  26. package/src/cli/commands/review.js +3 -1
  27. package/src/cli/commands/setup.js +25 -0
  28. package/src/cli/commands/status.js +128 -60
  29. package/src/cli/commands/storage.js +24 -0
  30. package/src/cli/commands/usage.js +48 -0
  31. package/src/cli/commands/watch.js +157 -47
  32. package/src/cli/commands/worktree-copy-ignored.js +38 -0
  33. package/src/cli/commands/worktree-estimate.js +69 -0
  34. package/src/cli/commands/worktree-hooks.js +62 -0
  35. package/src/cli/commands/worktree-navigation.js +71 -0
  36. package/src/cli/commands/worktree-provision.js +92 -0
  37. package/src/cli/main.js +229 -110
  38. package/src/cli/shared/gate-flags.js +131 -0
  39. package/src/cli/shared/scaffolding.js +31 -3
  40. package/src/cli/shared-locks.js +3 -1
  41. package/src/cockpit/pane-actions.js +43 -7
  42. package/src/context.js +373 -17
  43. package/src/doctor/index.js +29 -35
  44. package/src/finish/events.js +254 -0
  45. package/src/finish/index.js +322 -62
  46. package/src/finish/post-branch-finish-cleanup.js +316 -22
  47. package/src/finish/preflight.js +44 -1
  48. package/src/finish/progress.js +36 -0
  49. package/src/finish/review-gate.js +317 -127
  50. package/src/finish/review-receipt.js +156 -0
  51. package/src/finish/with-claims-lock.py +29 -0
  52. package/src/git/index.js +179 -42
  53. package/src/hooks/index.js +68 -3
  54. package/src/mcp/collect.js +61 -5
  55. package/src/mcp/server.js +4 -0
  56. package/src/output/index.js +167 -1
  57. package/src/pr-lens-publish.js +93 -0
  58. package/src/pr-lens.js +184 -0
  59. package/src/pr-respond.js +860 -0
  60. package/src/pr-review.js +519 -159
  61. package/src/pr.js +73 -14
  62. package/src/provider-binary.js +21 -0
  63. package/src/review-diff-context.js +90 -0
  64. package/src/review-fix.js +23 -17
  65. package/src/scaffold/agent-worktree-prep.js +14 -12
  66. package/src/scaffold/dependency-store.js +234 -0
  67. package/src/scaffold/index.js +13 -1
  68. package/src/scaffold/provision-approvals.js +83 -0
  69. package/src/scaffold/provision-config.js +169 -40
  70. package/src/shared-git-state.js +11 -1
  71. package/src/speckit/index.js +12 -1
  72. package/src/storage/run-artifacts.js +185 -0
  73. package/src/toolchain/index.js +322 -2
  74. package/src/worktree-copy-ignored.js +200 -0
  75. package/src/worktree-hook-worker.js +29 -0
  76. package/src/worktree-hooks.js +333 -0
  77. package/src/worktree-navigation.js +248 -0
  78. package/src/worktree-picker.js +89 -0
  79. package/src/worktree-quota.js +100 -0
  80. package/src/worktree-start.js +100 -0
  81. package/templates/AGENTS.multiagent-safety.md +8 -0
  82. package/templates/AGENTS.multiagent-safety.min.md +3 -1
  83. package/templates/codex/skills/gitguardex/SKILL.md +28 -0
  84. package/templates/codex/skills/opensrc/SKILL.md +24 -0
  85. package/templates/githooks/post-merge +16 -2
  86. package/templates/scripts/agent-autofinish-watch.sh +17 -18
  87. package/templates/scripts/agent-branch-finish.sh +180 -19
  88. package/templates/scripts/agent-branch-merge.sh +7 -32
  89. package/templates/scripts/agent-branch-start.sh +202 -43
  90. package/templates/scripts/agent-claude-stop-finish.sh +4 -27
  91. package/templates/scripts/agent-file-locks.py +257 -29
  92. package/templates/scripts/agent-preflight.sh +3 -0
  93. package/templates/scripts/agent-worktree-prune.sh +975 -63
  94. package/templates/scripts/codex-agent.sh +55 -5
  95. package/templates/scripts/lib/guardex-base-branch.sh +207 -0
  96. package/templates/scripts/openspec/init-change-workspace.sh +10 -18
  97. package/templates/scripts/review-bot-watch.sh +171 -4
@@ -1,21 +1,23 @@
1
1
  // `gx status` — service/repo health summary + companion-tool prompts.
2
2
  // Pure code-motion from src/cli/main.js — no behavior changes.
3
3
  const {
4
+ fs,
4
5
  path,
5
6
  packageJson,
6
7
  TOOL_NAME,
7
8
  SHORT_TOOL_NAME,
8
9
  GLOBAL_TOOLCHAIN_PACKAGES,
9
- envFlagIsTruthy,
10
+ envFlagIsTruthy
10
11
  } = require('../../context');
11
12
  const { isGitRepo } = require('../../git');
13
+ const abide = require('../../abide');
12
14
  const toolchainModule = require('../../toolchain');
13
15
  const {
14
16
  runtimeVersion,
15
17
  statusDot,
16
18
  describeCompressor,
17
19
  printToolLogsSummary,
18
- getInvokedCliName,
20
+ getInvokedCliName
19
21
  } = require('../../output');
20
22
  const { parseCommonArgs } = require('../args');
21
23
  const { extractFlag } = require('../dispatch');
@@ -23,10 +25,60 @@ const {
23
25
  runScanInternal,
24
26
  countAgentWorktrees,
25
27
  deriveNextStepHint,
26
- printStatusRepairHint,
28
+ printStatusRepairHint
27
29
  } = require('../shared/scaffolding');
28
30
  const { describeGuardexRepoToggle } = require('../shared/repo-env');
29
31
 
32
+ /**
33
+ * Best-effort check that the process at `pid` is actually the review-watcher
34
+ * and not an unrelated process that inherited the PID after an unclean exit.
35
+ *
36
+ * On Linux we read /proc/<pid>/cmdline; on other platforms we fall back to
37
+ * accepting any live process (same behaviour as before, which is still correct
38
+ * for the vast majority of cases). Never throws.
39
+ */
40
+ function _isReviewWatcherProcess(pid) {
41
+ if (process.platform !== 'linux') return true;
42
+ try {
43
+ const cmdline = fs.readFileSync(`/proc/${pid}/cmdline`, 'utf8');
44
+ return cmdline.includes('review-bot-watch');
45
+ } catch {
46
+ // /proc unavailable or process already dead; trust the kill(0) result.
47
+ return true;
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Read the review-watcher daemon's pidfile (written by review-bot-watch.sh
53
+ * --daemon) and return its live status. Returns { state: 'running', pid } or
54
+ * { state: 'stopped', pid: null }. Never throws.
55
+ *
56
+ * Uses a two-step liveness check: signal 0 (process exists) + cmdline
57
+ * verification (the process is actually review-bot-watch, not a PID-reuse
58
+ * collision).
59
+ */
60
+ function describeReviewDaemon(repoRoot) {
61
+ const pidfile = path.join(repoRoot, '.omx', 'state', 'review-bot-watch.pid');
62
+ try {
63
+ const raw = fs.readFileSync(pidfile, 'utf8').trim();
64
+ const pid = parseInt(raw, 10);
65
+ if (!pid || Number.isNaN(pid)) {
66
+ return { state: 'stopped', pid: null };
67
+ }
68
+ try {
69
+ process.kill(pid, 0);
70
+ if (!_isReviewWatcherProcess(pid)) {
71
+ return { state: 'stopped', pid: null };
72
+ }
73
+ return { state: 'running', pid };
74
+ } catch {
75
+ return { state: 'stopped', pid: null };
76
+ }
77
+ } catch {
78
+ return { state: 'stopped', pid: null };
79
+ }
80
+ }
81
+
30
82
  function collectServicesSnapshot() {
31
83
  const toolchain = toolchainModule.detectGlobalToolchainPackages();
32
84
  const npmServices = GLOBAL_TOOLCHAIN_PACKAGES.map((pkg) => {
@@ -37,7 +89,7 @@ function collectServicesSnapshot() {
37
89
  displayName: service.name,
38
90
  packageName: pkg,
39
91
  dependencyUrl: service.dependencyUrl || null,
40
- status: 'unknown',
92
+ status: 'unknown'
41
93
  };
42
94
  }
43
95
  return {
@@ -45,30 +97,32 @@ function collectServicesSnapshot() {
45
97
  displayName: service.name,
46
98
  packageName: pkg,
47
99
  dependencyUrl: service.dependencyUrl || null,
48
- status: toolchain.installed.includes(pkg) ? 'active' : 'inactive',
100
+ status: toolchain.installed.includes(pkg) ? 'active' : 'inactive'
49
101
  };
50
102
  });
51
- const localCompanionServices = toolchainModule.detectOptionalLocalCompanionTools().map((tool) => ({
52
- name: tool.name,
53
- displayName: tool.displayName || tool.name,
54
- installCommand: tool.installCommand,
55
- installArgs: Array.isArray(tool.installArgs) ? [...tool.installArgs] : [],
56
- status: tool.status,
57
- }));
103
+ const localCompanionServices = toolchainModule
104
+ .detectOptionalLocalCompanionTools()
105
+ .map((tool) => ({
106
+ name: tool.name,
107
+ displayName: tool.displayName || tool.name,
108
+ installCommand: tool.installCommand,
109
+ installArgs: Array.isArray(tool.installArgs) ? [...tool.installArgs] : [],
110
+ status: tool.status
111
+ }));
58
112
  const requiredSystemTools = toolchainModule.detectRequiredSystemTools();
59
113
  const services = [
60
114
  ...npmServices,
61
115
  ...localCompanionServices.map((tool) => ({
62
116
  name: tool.name,
63
117
  displayName: tool.displayName,
64
- status: tool.status,
118
+ status: tool.status
65
119
  })),
66
120
  ...requiredSystemTools.map((tool) => ({
67
121
  name: tool.name,
68
122
  displayName: tool.displayName || tool.name,
69
123
  command: tool.command,
70
- status: tool.status,
71
- })),
124
+ status: tool.status
125
+ }))
72
126
  ];
73
127
  return { toolchain, npmServices, localCompanionServices, requiredSystemTools, services };
74
128
  }
@@ -89,26 +143,29 @@ function maybePromptInstallMissingCompanions(snapshot) {
89
143
  const missingPackages = snapshot.npmServices
90
144
  .filter((service) => service.status !== 'active')
91
145
  .map((service) => service.packageName);
92
- const missingLocalTools = snapshot.localCompanionServices.filter((tool) => tool.status !== 'active');
146
+ const missingLocalTools = snapshot.localCompanionServices.filter(
147
+ (tool) => tool.status !== 'active'
148
+ );
93
149
  if (missingPackages.length === 0 && missingLocalTools.length === 0) {
94
150
  return { handled: false, installed: false };
95
151
  }
96
152
 
97
153
  const missingNames = [
98
154
  ...missingPackages.map((pkg) => toolchainModule.formatGlobalToolchainServiceName(pkg)),
99
- ...missingLocalTools.map((tool) => tool.displayName || tool.name),
155
+ ...missingLocalTools.map((tool) => tool.displayName || tool.name)
100
156
  ];
101
157
  console.log(`[${TOOL_NAME}] Missing companion tools: ${missingNames.join(', ')}.`);
102
158
 
103
- const promptText = toolchainModule.buildMissingCompanionInstallPrompt(missingPackages, missingLocalTools);
104
- const approved = interactive
105
- ? toolchainModule.promptYesNoStrict(promptText)
106
- : autoApproval;
159
+ const promptText = toolchainModule.buildMissingCompanionInstallPrompt(
160
+ missingPackages,
161
+ missingLocalTools
162
+ );
163
+ const approved = interactive ? toolchainModule.promptYesNoStrict(promptText) : autoApproval;
107
164
 
108
165
  if (!approved) {
109
166
  console.log(
110
167
  `[${TOOL_NAME}] Skipped companion install. Set GUARDEX_SKIP_COMPANION_PROMPT=1 to silence this prompt, ` +
111
- `or run '${getInvokedCliName()} setup --install-only' later to install manually.`,
168
+ `or run '${getInvokedCliName()} setup --install-only' later to install manually.`
112
169
  );
113
170
  return { handled: true, installed: false };
114
171
  }
@@ -116,14 +173,14 @@ function maybePromptInstallMissingCompanions(snapshot) {
116
173
  const result = toolchainModule.performCompanionInstall(missingPackages, missingLocalTools);
117
174
  if (result.status === 'installed') {
118
175
  console.log(
119
- `[${TOOL_NAME}] ✅ Companion tools installed (${(result.packages || []).join(', ')}).`,
176
+ `[${TOOL_NAME}] ✅ Companion tools installed (${(result.packages || []).join(', ')}).`
120
177
  );
121
178
  return { handled: true, installed: true };
122
179
  }
123
180
  if (result.status === 'failed') {
124
181
  console.log(
125
182
  `[${TOOL_NAME}] ⚠️ Companion install failed: ${result.reason}. ` +
126
- `Retry with '${getInvokedCliName()} setup --install-only'.`,
183
+ `Retry with '${getInvokedCliName()} setup --install-only'.`
127
184
  );
128
185
  return { handled: true, installed: false };
129
186
  }
@@ -134,7 +191,7 @@ function status(rawArgs) {
134
191
  const { found: verboseFlag, remaining: afterVerbose } = extractFlag(rawArgs, '--verbose');
135
192
  const options = parseCommonArgs(afterVerbose, {
136
193
  target: process.cwd(),
137
- json: false,
194
+ json: false
138
195
  });
139
196
  const forceExpand = envFlagIsTruthy(process.env.GUARDEX_VERBOSE_STATUS) || verboseFlag;
140
197
  const invokedBasename = getInvokedCliName();
@@ -152,16 +209,18 @@ function status(rawArgs) {
152
209
  const inGitRepo = isGitRepo(targetPath);
153
210
  const scanResult = inGitRepo ? runScanInternal({ target: targetPath, json: false }) : null;
154
211
  const repoServiceStatus = scanResult
155
- ? (scanResult.guardexEnabled === false
212
+ ? scanResult.guardexEnabled === false
156
213
  ? 'disabled'
157
- : (scanResult.errors === 0 && scanResult.warnings === 0 ? 'active' : 'degraded'))
214
+ : scanResult.errors === 0 && scanResult.warnings === 0
215
+ ? 'active'
216
+ : 'degraded'
158
217
  : 'inactive';
159
218
 
160
219
  const payload = {
161
220
  cli: {
162
221
  name: packageJson.name,
163
222
  version: packageJson.version,
164
- runtime: runtimeVersion(),
223
+ runtime: runtimeVersion()
165
224
  },
166
225
  services,
167
226
  repo: {
@@ -172,16 +231,19 @@ function status(rawArgs) {
172
231
  guardexToggle: scanResult ? scanResult.guardexToggle || null : null,
173
232
  scan: scanResult
174
233
  ? {
175
- repoRoot: scanResult.repoRoot,
176
- branch: scanResult.branch,
177
- errors: scanResult.errors,
178
- warnings: scanResult.warnings,
179
- findings: scanResult.findings.length,
180
- }
234
+ repoRoot: scanResult.repoRoot,
235
+ branch: scanResult.branch,
236
+ errors: scanResult.errors,
237
+ warnings: scanResult.warnings,
238
+ findings: scanResult.findings.length
239
+ }
181
240
  : null,
241
+ // Whether this repo's AGENTS.md / CLAUDE.md rules are being enforced.
242
+ abide: scanResult ? abide.abideSummary(scanResult.repoRoot) : null,
243
+ reviewDaemon: scanResult ? describeReviewDaemon(scanResult.repoRoot) : null
182
244
  },
183
245
  detectionError: toolchain.ok ? null : toolchain.error,
184
- compression: describeCompressor(),
246
+ compression: describeCompressor()
185
247
  };
186
248
 
187
249
  if (options.json) {
@@ -197,18 +259,19 @@ function status(rawArgs) {
197
259
  console.log(`[${TOOL_NAME}] CLI: ${payload.cli.runtime}`);
198
260
  if (!toolchain.ok) {
199
261
  const detectionError = compact
200
- ? String(toolchain.error || '').split(/\r?\n/).find(Boolean) || 'unknown error'
262
+ ? String(toolchain.error || '')
263
+ .split(/\r?\n/)
264
+ .find(Boolean) || 'unknown error'
201
265
  : toolchain.error;
202
266
  console.log(`[${TOOL_NAME}] ⚠️ Could not detect global services: ${detectionError}`);
203
267
  }
204
268
 
205
269
  if (compact) {
206
- const serviceSummary = inactiveServiceCount === 0
207
- ? `${activeServiceCount}/${services.length} ${statusDot('active')} active`
208
- : `${activeServiceCount}/${services.length} ${statusDot('degraded')} active (${inactiveServiceCount} inactive)`;
209
- console.log(
210
- `[${TOOL_NAME}] Global services: ${serviceSummary}`,
211
- );
270
+ const serviceSummary =
271
+ inactiveServiceCount === 0
272
+ ? `${activeServiceCount}/${services.length} ${statusDot('active')} active`
273
+ : `${activeServiceCount}/${services.length} ${statusDot('degraded')} active (${inactiveServiceCount} inactive)`;
274
+ console.log(`[${TOOL_NAME}] Global services: ${serviceSummary}`);
212
275
  } else {
213
276
  console.log(`[${TOOL_NAME}] Global services:`);
214
277
  for (const service of services) {
@@ -220,7 +283,7 @@ function status(rawArgs) {
220
283
  const { command, available } = payload.compression;
221
284
  if (available === false) {
222
285
  console.log(
223
- `[${TOOL_NAME}] Token compression: ${statusDot('degraded')} ${command} — not found on PATH (gx output is not compressed)`,
286
+ `[${TOOL_NAME}] Token compression: ${statusDot('degraded')} ${command} — not found on PATH (gx output is not compressed)`
224
287
  );
225
288
  } else {
226
289
  console.log(`[${TOOL_NAME}] Token compression: ${statusDot('active')} ${command}`);
@@ -232,29 +295,27 @@ function status(rawArgs) {
232
295
  if (inactiveOptionalCompanions.length > 0) {
233
296
  if (compact) {
234
297
  console.log(
235
- `[${TOOL_NAME}] Optional companion tools inactive: ${inactiveOptionalCompanions.length} (run '${SHORT_TOOL_NAME} setup')`,
298
+ `[${TOOL_NAME}] Optional companion tools inactive: ${inactiveOptionalCompanions.length} (run '${SHORT_TOOL_NAME} setup')`
236
299
  );
237
300
  } else {
238
301
  console.log(
239
- `[${TOOL_NAME}] Optional companion tools inactive: ${inactiveOptionalCompanions.join(', ')}`,
302
+ `[${TOOL_NAME}] Optional companion tools inactive: ${inactiveOptionalCompanions.join(', ')}`
240
303
  );
241
304
  for (const warning of toolchainModule.describeMissingGlobalDependencyWarnings(
242
305
  npmServices
243
306
  .filter((service) => service.status === 'inactive')
244
- .map((service) => service.packageName),
307
+ .map((service) => service.packageName)
245
308
  )) {
246
309
  console.log(`[${TOOL_NAME}] ${warning}`);
247
310
  }
248
311
  console.log(
249
- `[${TOOL_NAME}] Run '${SHORT_TOOL_NAME} setup' to install missing companions with an explicit Y/N prompt.`,
312
+ `[${TOOL_NAME}] Run '${SHORT_TOOL_NAME} setup' to install missing companions with an explicit Y/N prompt.`
250
313
  );
251
314
  }
252
315
  }
253
316
  const missingSystemTools = requiredSystemTools.filter((tool) => tool.status !== 'active');
254
317
  if (missingSystemTools.length > 0) {
255
- const tools = missingSystemTools
256
- .map((tool) => tool.displayName || tool.name)
257
- .join(', ');
318
+ const tools = missingSystemTools.map((tool) => tool.displayName || tool.name).join(', ');
258
319
  console.log(`[${TOOL_NAME}] ⚠️ Missing required system tool(s): ${tools}`);
259
320
  if (!compact) {
260
321
  for (const tool of missingSystemTools) {
@@ -266,13 +327,13 @@ function status(rawArgs) {
266
327
 
267
328
  if (!scanResult) {
268
329
  console.log(
269
- `[${TOOL_NAME}] Repo safety service: ${statusDot('inactive')} inactive (no git repository at target).`,
330
+ `[${TOOL_NAME}] Repo safety service: ${statusDot('inactive')} inactive (no git repository at target).`
270
331
  );
271
332
  const inactiveHint = deriveNextStepHint({
272
333
  scanResult: null,
273
334
  worktreeCount: 0,
274
335
  invoked: invokedBasename,
275
- inGitRepo,
336
+ inGitRepo
276
337
  });
277
338
  console.log(`[${TOOL_NAME}] Next: ${inactiveHint}`);
278
339
  printToolLogsSummary({ invokedBasename, compact });
@@ -282,7 +343,7 @@ function status(rawArgs) {
282
343
 
283
344
  if (scanResult.guardexEnabled === false) {
284
345
  console.log(
285
- `[${TOOL_NAME}] Repo safety service: ${statusDot('disabled')} disabled (${describeGuardexRepoToggle(scanResult.guardexToggle)}).`,
346
+ `[${TOOL_NAME}] Repo safety service: ${statusDot('disabled')} disabled (${describeGuardexRepoToggle(scanResult.guardexToggle)}).`
286
347
  );
287
348
  console.log(`[${TOOL_NAME}] Repo: ${scanResult.repoRoot}`);
288
349
  console.log(`[${TOOL_NAME}] Branch: ${scanResult.branch}`);
@@ -290,14 +351,14 @@ function status(rawArgs) {
290
351
  if (worktreeCountDisabled > 0) {
291
352
  const plural = worktreeCountDisabled === 1 ? 'worktree' : 'worktrees';
292
353
  console.log(
293
- `[${TOOL_NAME}] ⚠ ${worktreeCountDisabled} active agent ${plural} under .omc/agent-worktrees or .omx/agent-worktrees.`,
354
+ `[${TOOL_NAME}] ⚠ ${worktreeCountDisabled} active agent ${plural} under .omc/agent-worktrees or .omx/agent-worktrees.`
294
355
  );
295
356
  }
296
357
  const disabledHint = deriveNextStepHint({
297
358
  scanResult,
298
359
  worktreeCount: worktreeCountDisabled,
299
360
  invoked: invokedBasename,
300
- inGitRepo,
361
+ inGitRepo
301
362
  });
302
363
  console.log(`[${TOOL_NAME}] Next: ${disabledHint}`);
303
364
  printToolLogsSummary({ invokedBasename, compact });
@@ -309,32 +370,38 @@ function status(rawArgs) {
309
370
  console.log(`[${TOOL_NAME}] Repo safety service: ${statusDot('active')} active.`);
310
371
  } else if (scanResult.errors === 0) {
311
372
  console.log(
312
- `[${TOOL_NAME}] Repo safety service: ${statusDot('degraded')} degraded (${scanResult.warnings} warning(s)).`,
373
+ `[${TOOL_NAME}] Repo safety service: ${statusDot('degraded')} degraded (${scanResult.warnings} warning(s)).`
313
374
  );
314
375
  } else if (scanResult.warnings === 0) {
315
376
  console.log(
316
- `[${TOOL_NAME}] Repo safety service: ${statusDot('degraded')} degraded (${scanResult.errors} error(s)).`,
377
+ `[${TOOL_NAME}] Repo safety service: ${statusDot('degraded')} degraded (${scanResult.errors} error(s)).`
317
378
  );
318
379
  } else {
319
380
  console.log(
320
- `[${TOOL_NAME}] Repo safety service: ${statusDot('degraded')} degraded (${scanResult.errors} error(s), ${scanResult.warnings} warning(s)).`,
381
+ `[${TOOL_NAME}] Repo safety service: ${statusDot('degraded')} degraded (${scanResult.errors} error(s), ${scanResult.warnings} warning(s)).`
321
382
  );
322
383
  }
323
384
  printStatusRepairHint(scanResult);
324
385
  console.log(`[${TOOL_NAME}] Repo: ${scanResult.repoRoot}`);
325
386
  console.log(`[${TOOL_NAME}] Branch: ${scanResult.branch}`);
387
+ console.log(`[${TOOL_NAME}] ${abide.renderAbideSummary(payload.repo.abide, invokedBasename)}`);
388
+ if (payload.repo.reviewDaemon && payload.repo.reviewDaemon.state === 'running') {
389
+ console.log(
390
+ `[${TOOL_NAME}] Review watcher: ${statusDot('active')} running (pid ${payload.repo.reviewDaemon.pid})`
391
+ );
392
+ }
326
393
  const worktreeCountActive = countAgentWorktrees(scanResult.repoRoot);
327
394
  if (worktreeCountActive > 0) {
328
395
  const plural = worktreeCountActive === 1 ? 'worktree' : 'worktrees';
329
396
  console.log(
330
- `[${TOOL_NAME}] ⚠ ${worktreeCountActive} active agent ${plural} → ${invokedBasename} finish --all`,
397
+ `[${TOOL_NAME}] ⚠ ${worktreeCountActive} active agent ${plural} → ${invokedBasename} finish --all`
331
398
  );
332
399
  }
333
400
  const activeHint = deriveNextStepHint({
334
401
  scanResult,
335
402
  worktreeCount: worktreeCountActive,
336
403
  invoked: invokedBasename,
337
- inGitRepo,
404
+ inGitRepo
338
405
  });
339
406
  console.log(`[${TOOL_NAME}] Next: ${activeHint}`);
340
407
  printToolLogsSummary({ invokedBasename, compact });
@@ -347,4 +414,5 @@ module.exports = {
347
414
  status,
348
415
  collectServicesSnapshot,
349
416
  maybePromptInstallMissingCompanions,
417
+ describeReviewDaemon
350
418
  };
@@ -0,0 +1,24 @@
1
+ const { resolveRepoRoot } = require('../../git');
2
+ const { extractTargetedArgs } = require('../../core/runtime');
3
+ const { pruneDisposable } = require('../../storage/run-artifacts');
4
+
5
+ function pruneArtifacts(args) {
6
+ if (args.includes('--help') || args.includes('-h')) {
7
+ console.log(
8
+ 'Usage: gx worktree prune-artifacts [--target <repo>] [--max-bytes N] [--max-age-ms N]\nOnly registered, unchanged logs/cache in completed GX runs are eligible. Results, backups and unknown files are preserved.'
9
+ );
10
+ return;
11
+ }
12
+ const { target, passthrough } = extractTargetedArgs(args);
13
+ const options = {};
14
+ for (let index = 0; index < passthrough.length; index += 2) {
15
+ const key = { '--max-bytes': 'maxBytes', '--max-age-ms': 'maxAgeMs' }[passthrough[index]];
16
+ const raw = passthrough[index + 1];
17
+ if (!key || !/^\d+$/.test(raw || '') || !Number.isSafeInteger(Number(raw)))
18
+ throw new Error('Retention limits must be non-negative safe integers');
19
+ options[key] = Number(raw);
20
+ }
21
+ console.log(JSON.stringify(pruneDisposable(resolveRepoRoot(target), options)));
22
+ }
23
+
24
+ module.exports = { pruneArtifacts };
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ const { run } = require('../../core/runtime');
4
+
5
+ function usage(rawArgs = [], deps = {}) {
6
+ if (rawArgs.length === 1 && ['--help', '-h'].includes(rawArgs[0])) {
7
+ (deps.log || console.log)(
8
+ 'Usage: gx usage [ccusage arguments]\n' +
9
+ 'Read agent token usage from local logs using the installed ccusage CLI.\n' +
10
+ 'Default: daily report across detected agents (not scoped to the current repo).\n\n' +
11
+ ' gx usage codex session --json --offline\n' +
12
+ ' gx usage claude daily --since 20260921\n' +
13
+ ' gx usage codex session --help\n' +
14
+ ' gx usage -- --help Full ccusage help\n\n' +
15
+ 'Install: npm install -g ccusage\n' +
16
+ 'GUARDEX_CCUSAGE_BIN may select an executable or a .js/.mjs/.cjs entry point.\n' +
17
+ 'CODEX_HOME and other ccusage environment settings are preserved.\n' +
18
+ 'Token counts depend on recorded logs; costs are estimates, not invoices.\n' +
19
+ 'Pricing may be fetched unless --offline is used. GX does not install or download ccusage automatically.'
20
+ );
21
+ return;
22
+ }
23
+ const env = deps.env || process.env;
24
+ const bin = String(env.GUARDEX_CCUSAGE_BIN || '').trim() || 'ccusage';
25
+ const args = rawArgs[0] === '--' ? rawArgs.slice(1) : rawArgs.slice();
26
+ if (!args.length) args.push('daily');
27
+ const script = /\.[cm]?js$/i.test(bin);
28
+ const result = (deps.run || run)(
29
+ script ? process.execPath : bin,
30
+ script ? [bin, ...args] : args,
31
+ {
32
+ cwd: process.cwd(),
33
+ env,
34
+ stdio: 'inherit'
35
+ }
36
+ );
37
+ if (result.error) {
38
+ if (result.error.code === 'ENOENT') {
39
+ throw new Error(
40
+ `ccusage executable not found: ${bin}. Install with "npm install -g ccusage" or set GUARDEX_CCUSAGE_BIN.`
41
+ );
42
+ }
43
+ throw result.error;
44
+ }
45
+ process.exitCode = result.status ?? 1;
46
+ }
47
+
48
+ module.exports = { usage };