@imdeadpool/guardex 7.0.43 → 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.
Files changed (68) hide show
  1. package/README.md +35 -0
  2. package/package.json +4 -1
  3. package/scripts/prepublish-bump-version.js +191 -0
  4. package/skills/gx-act/SKILL.md +82 -0
  5. package/src/agents/activity.js +279 -0
  6. package/src/agents/inspect.js +17 -4
  7. package/src/agents/launch.js +10 -1
  8. package/src/agents/status.js +9 -6
  9. package/src/budget/index.js +2 -1
  10. package/src/cli/args.js +118 -5
  11. package/src/cli/commands/agents.js +381 -0
  12. package/src/cli/commands/bootstrap.js +92 -0
  13. package/src/cli/commands/branch.js +127 -0
  14. package/src/cli/commands/claude.js +674 -0
  15. package/src/cli/commands/doctor.js +268 -0
  16. package/src/cli/commands/finish.js +26 -0
  17. package/src/cli/commands/mcp.js +122 -0
  18. package/src/cli/commands/misc.js +304 -0
  19. package/src/cli/commands/pr.js +439 -0
  20. package/src/cli/commands/prompt.js +92 -0
  21. package/src/cli/commands/release.js +305 -0
  22. package/src/cli/commands/report.js +244 -0
  23. package/src/cli/commands/review.js +32 -0
  24. package/src/cli/commands/setup.js +242 -0
  25. package/src/cli/commands/status.js +338 -0
  26. package/src/cli/commands/watch.js +234 -0
  27. package/src/cli/main.js +68 -3726
  28. package/src/cli/shared/repo-env.js +161 -0
  29. package/src/cli/shared/sandbox.js +417 -0
  30. package/src/cli/shared/scaffolding.js +535 -0
  31. package/src/cli/shared/toolchain-shims.js +420 -0
  32. package/src/context.js +229 -11
  33. package/src/core/runtime.js +6 -1
  34. package/src/doctor/index.js +42 -13
  35. package/src/finish/index.js +147 -5
  36. package/src/finish/preflight.js +177 -0
  37. package/src/finish/review-gate.js +182 -0
  38. package/src/git/index.js +446 -4
  39. package/src/hooks/index.js +0 -64
  40. package/src/mcp/collect.js +394 -0
  41. package/src/mcp/server.js +163 -0
  42. package/src/output/index.js +67 -1
  43. package/src/pr-review.js +23 -0
  44. package/src/pr.js +381 -0
  45. package/src/sandbox/index.js +13 -2
  46. package/src/scaffold/agent-worktree-prep.js +220 -0
  47. package/src/scaffold/index.js +108 -10
  48. package/src/scaffold/provision-config.js +314 -0
  49. package/src/speckit/index.js +226 -0
  50. package/src/terminal/index.js +1 -76
  51. package/src/terminal/kitty.js +20 -0
  52. package/src/terminal/tmux.js +9 -1
  53. package/src/toolchain/index.js +20 -0
  54. package/templates/AGENTS.monorepo-apps.md +26 -0
  55. package/templates/AGENTS.multiagent-safety.md +68 -344
  56. package/templates/AGENTS.multiagent-safety.min.md +11 -0
  57. package/templates/codex/skills/gx-act/SKILL.md +82 -0
  58. package/templates/githooks/pre-commit +22 -19
  59. package/templates/scripts/agent-branch-finish.sh +17 -33
  60. package/templates/scripts/agent-branch-merge.sh +4 -1
  61. package/templates/scripts/agent-branch-start.sh +115 -6
  62. package/templates/scripts/agent-file-locks.py +245 -50
  63. package/templates/scripts/agent-preflight.sh +31 -5
  64. package/templates/scripts/agent-worktree-prune.sh +1 -1
  65. package/templates/scripts/codex-agent.sh +0 -91
  66. package/src/agents/detect.js +0 -160
  67. package/src/cockpit/keybindings.js +0 -224
  68. package/src/cockpit/layout.js +0 -224
@@ -0,0 +1,92 @@
1
+ // Deprecated direct aliases: `install`, `fix`, `scan`. Pure code-motion from
2
+ // src/cli/main.js — no behavior changes.
3
+ const { TOOL_NAME } = require('../../context');
4
+ const { parseCommonArgs } = require('../args');
5
+ const { printOperations } = require('../../scaffold');
6
+ const {
7
+ runInstallInternal,
8
+ runFixInternal,
9
+ runScanInternal,
10
+ printScanResult,
11
+ setExitCodeFromScan,
12
+ } = require('../shared/scaffolding');
13
+ const { assertProtectedMainWriteAllowed } = require('../shared/sandbox');
14
+ const { describeGuardexRepoToggle } = require('../shared/repo-env');
15
+
16
+ function install(rawArgs) {
17
+ const options = parseCommonArgs(rawArgs, {
18
+ target: process.cwd(),
19
+ force: false,
20
+ skipAgents: false,
21
+ skipPackageJson: false,
22
+ skipGitignore: false,
23
+ dryRun: false,
24
+ allowProtectedBaseWrite: false,
25
+ });
26
+
27
+ assertProtectedMainWriteAllowed(options, 'install');
28
+ const payload = runInstallInternal(options);
29
+ printOperations('Install target', payload, options.dryRun);
30
+
31
+ if (!options.dryRun) {
32
+ if (payload.guardexEnabled === false) {
33
+ console.log(
34
+ `[${TOOL_NAME}] Guardex is disabled for this repo (${describeGuardexRepoToggle(payload.guardexToggle)}). Skipping repo bootstrap.`,
35
+ );
36
+ process.exitCode = 0;
37
+ return;
38
+ }
39
+ if (!options.skipAgents) {
40
+ console.log(`[${TOOL_NAME}] AGENTS.md managed policy block is configured by install.`);
41
+ }
42
+ console.log(`[${TOOL_NAME}] Installed. Next step: ${TOOL_NAME} setup`);
43
+ }
44
+
45
+ process.exitCode = 0;
46
+ }
47
+
48
+ function fix(rawArgs) {
49
+ const options = parseCommonArgs(rawArgs, {
50
+ target: process.cwd(),
51
+ dropStaleLocks: true,
52
+ skipAgents: false,
53
+ skipPackageJson: false,
54
+ skipGitignore: false,
55
+ dryRun: false,
56
+ allowProtectedBaseWrite: false,
57
+ });
58
+
59
+ assertProtectedMainWriteAllowed(options, 'fix');
60
+ const payload = runFixInternal(options);
61
+ printOperations('Fix target', payload, options.dryRun);
62
+
63
+ if (!options.dryRun) {
64
+ if (payload.guardexEnabled === false) {
65
+ console.log(
66
+ `[${TOOL_NAME}] Guardex is disabled for this repo (${describeGuardexRepoToggle(payload.guardexToggle)}). Skipping repo repair.`,
67
+ );
68
+ process.exitCode = 0;
69
+ return;
70
+ }
71
+ console.log(`[${TOOL_NAME}] Repair complete. Next step: ${TOOL_NAME} scan`);
72
+ }
73
+
74
+ process.exitCode = 0;
75
+ }
76
+
77
+ function scan(rawArgs) {
78
+ const options = parseCommonArgs(rawArgs, {
79
+ target: process.cwd(),
80
+ json: false,
81
+ });
82
+
83
+ const result = runScanInternal(options);
84
+ printScanResult(result, options.json);
85
+ setExitCodeFromScan(result);
86
+ }
87
+
88
+ module.exports = {
89
+ install,
90
+ fix,
91
+ scan,
92
+ };
@@ -0,0 +1,127 @@
1
+ // `gx branch`, `gx pivot`, `gx ship`, `gx locks`, `gx worktree` — branch
2
+ // workflow surface. Pure code-motion from src/cli/main.js.
3
+ const { TOOL_NAME, SHORT_TOOL_NAME } = require('../../context');
4
+ const { resolveRepoRoot } = require('../../git');
5
+ const {
6
+ run,
7
+ extractTargetedArgs,
8
+ runPackageAsset,
9
+ invokePackageAsset,
10
+ } = require('../../core/runtime');
11
+ const { finish, merge } = require('./finish');
12
+
13
+ function branch(rawArgs) {
14
+ const activeCwd = process.cwd();
15
+ const [subcommand, ...rest] = rawArgs;
16
+ if (subcommand === 'start') {
17
+ const { target, passthrough } = extractTargetedArgs(rest);
18
+ invokePackageAsset('branchStart', passthrough, { cwd: resolveRepoRoot(target) });
19
+ return;
20
+ }
21
+ if (subcommand === 'finish') {
22
+ const { target, passthrough } = extractTargetedArgs(rest);
23
+ invokePackageAsset('branchFinish', passthrough, {
24
+ cwd: resolveRepoRoot(target),
25
+ env: { GUARDEX_FINISH_ACTIVE_CWD: activeCwd },
26
+ });
27
+ return;
28
+ }
29
+ if (subcommand === 'merge') return merge(rest);
30
+ throw new Error(
31
+ `Usage: ${SHORT_TOOL_NAME} branch <start|finish|merge> [options] ` +
32
+ `(examples: '${SHORT_TOOL_NAME} branch start "<task>" "<agent>"', '${SHORT_TOOL_NAME} branch finish --branch <agent/...>')`,
33
+ );
34
+ }
35
+
36
+ // `gx pivot` — single-tool-call escape from a protected branch into an isolated
37
+ // agent worktree. AI agents (Claude Code / Codex) cannot set the bypass env
38
+ // vars from inside a tool call, so they need a whitelisted command that does
39
+ // the whole hop: branch+worktree creation, dirty-tree migration, and a clean
40
+ // trailer (`WORKTREE_PATH=...`, `BRANCH=...`, `NEXT_STEP=cd ...`) the agent can
41
+ // parse to know exactly where to `cd`.
42
+ //
43
+ // On an existing agent/* branch, `gx pivot` short-circuits and just prints the
44
+ // current worktree path — safe to call as a no-op.
45
+ function pivot(rawArgs) {
46
+ const { target, passthrough } = extractTargetedArgs(rawArgs);
47
+ const repoRoot = resolveRepoRoot(target);
48
+ const headProc = run('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: repoRoot });
49
+ const currentBranch = String(headProc.stdout || '').trim();
50
+ if (currentBranch.startsWith('agent/')) {
51
+ const wtProc = run('git', ['rev-parse', '--show-toplevel'], { cwd: repoRoot });
52
+ const wtPath = String(wtProc.stdout || '').trim() || repoRoot;
53
+ process.stdout.write(`[${TOOL_NAME} pivot] Already on agent branch '${currentBranch}'.\n`);
54
+ process.stdout.write(`WORKTREE_PATH=${wtPath}\n`);
55
+ process.stdout.write(`BRANCH=${currentBranch}\n`);
56
+ process.stdout.write(`NEXT_STEP=cd "${wtPath}"\n`);
57
+ process.exitCode = 0;
58
+ return;
59
+ }
60
+ const result = runPackageAsset('branchStart', passthrough, { cwd: repoRoot });
61
+ if (result.stdout) process.stdout.write(result.stdout);
62
+ if (result.stderr) process.stderr.write(result.stderr);
63
+ if (result.status !== 0) {
64
+ process.exitCode = result.status || 1;
65
+ return;
66
+ }
67
+ const stdoutText = String(result.stdout || '');
68
+ const wtMatch = stdoutText.match(/^\[agent-branch-start\] Worktree:\s+(.+)$/m);
69
+ const branchMatch = stdoutText.match(/^\[agent-branch-start\] (?:Created branch|Reusing existing branch):\s+(.+)$/m);
70
+ if (wtMatch) {
71
+ const wtPath = wtMatch[1].trim();
72
+ process.stdout.write('\n');
73
+ process.stdout.write(`WORKTREE_PATH=${wtPath}\n`);
74
+ if (branchMatch) process.stdout.write(`BRANCH=${branchMatch[1].trim()}\n`);
75
+ process.stdout.write(`NEXT_STEP=cd "${wtPath}"\n`);
76
+ }
77
+ process.exitCode = 0;
78
+ }
79
+
80
+ // `gx ship` — alias for the canonical "I am done" command. Defaults to
81
+ // `finish --via-pr --wait-for-merge --cleanup` so AI agents don't strand
82
+ // commits or worktrees by accident. Any explicit user-supplied flags survive.
83
+ function ship(rawArgs) {
84
+ const args = Array.isArray(rawArgs) ? rawArgs.slice() : [];
85
+ const ensureFlag = (flag) => {
86
+ if (!args.includes(flag)) args.push(flag);
87
+ };
88
+ ensureFlag('--via-pr');
89
+ ensureFlag('--wait-for-merge');
90
+ ensureFlag('--cleanup');
91
+ // `gx ship` enforces the merge gate (clean review + green CI) by default;
92
+ // an explicit --no-gate-review / --skip-review-gate opts back out.
93
+ if (!args.includes('--no-gate-review') && !args.includes('--skip-review-gate')) {
94
+ ensureFlag('--gate-review');
95
+ }
96
+ return finish(args);
97
+ }
98
+
99
+ function locks(rawArgs) {
100
+ const { target, passthrough } = extractTargetedArgs(rawArgs);
101
+ const result = runPackageAsset('lockTool', passthrough, { cwd: resolveRepoRoot(target) });
102
+ if (result.stdout) process.stdout.write(result.stdout);
103
+ if (result.stderr) process.stderr.write(result.stderr);
104
+ process.exitCode = result.status;
105
+ }
106
+
107
+ function worktree(rawArgs) {
108
+ const activeCwd = process.cwd();
109
+ const [subcommand, ...rest] = rawArgs;
110
+ if (subcommand === 'prune') {
111
+ const { target, passthrough } = extractTargetedArgs(rest);
112
+ invokePackageAsset('worktreePrune', passthrough, {
113
+ cwd: resolveRepoRoot(target),
114
+ env: { GUARDEX_PRUNE_ACTIVE_CWD: process.env.GUARDEX_PRUNE_ACTIVE_CWD || activeCwd },
115
+ });
116
+ return;
117
+ }
118
+ throw new Error(`Usage: ${SHORT_TOOL_NAME} worktree prune [cleanup-options]`);
119
+ }
120
+
121
+ module.exports = {
122
+ branch,
123
+ pivot,
124
+ ship,
125
+ locks,
126
+ worktree,
127
+ };