@imdeadpool/guardex 7.0.43 → 7.1.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.
Files changed (63) hide show
  1. package/README.md +26 -0
  2. package/package.json +2 -1
  3. package/skills/gx-act/SKILL.md +82 -0
  4. package/src/agents/inspect.js +17 -4
  5. package/src/agents/launch.js +10 -1
  6. package/src/agents/status.js +9 -6
  7. package/src/budget/index.js +2 -1
  8. package/src/cli/args.js +52 -2
  9. package/src/cli/commands/agents.js +364 -0
  10. package/src/cli/commands/bootstrap.js +92 -0
  11. package/src/cli/commands/branch.js +127 -0
  12. package/src/cli/commands/claude.js +674 -0
  13. package/src/cli/commands/doctor.js +268 -0
  14. package/src/cli/commands/finish.js +26 -0
  15. package/src/cli/commands/mcp.js +122 -0
  16. package/src/cli/commands/misc.js +304 -0
  17. package/src/cli/commands/pr.js +439 -0
  18. package/src/cli/commands/prompt.js +92 -0
  19. package/src/cli/commands/release.js +305 -0
  20. package/src/cli/commands/report.js +244 -0
  21. package/src/cli/commands/review.js +32 -0
  22. package/src/cli/commands/setup.js +242 -0
  23. package/src/cli/commands/status.js +338 -0
  24. package/src/cli/commands/watch.js +234 -0
  25. package/src/cli/main.js +68 -3726
  26. package/src/cli/shared/repo-env.js +161 -0
  27. package/src/cli/shared/sandbox.js +417 -0
  28. package/src/cli/shared/scaffolding.js +535 -0
  29. package/src/cli/shared/toolchain-shims.js +420 -0
  30. package/src/context.js +229 -11
  31. package/src/core/runtime.js +6 -1
  32. package/src/doctor/index.js +42 -13
  33. package/src/finish/index.js +147 -5
  34. package/src/finish/preflight.js +177 -0
  35. package/src/finish/review-gate.js +182 -0
  36. package/src/git/index.js +446 -4
  37. package/src/hooks/index.js +0 -64
  38. package/src/mcp/collect.js +370 -0
  39. package/src/mcp/server.js +157 -0
  40. package/src/output/index.js +67 -1
  41. package/src/pr-review.js +23 -0
  42. package/src/pr.js +381 -0
  43. package/src/sandbox/index.js +13 -2
  44. package/src/scaffold/agent-worktree-prep.js +213 -0
  45. package/src/scaffold/index.js +108 -10
  46. package/src/speckit/index.js +226 -0
  47. package/src/terminal/index.js +1 -76
  48. package/src/terminal/tmux.js +0 -1
  49. package/src/toolchain/index.js +20 -0
  50. package/templates/AGENTS.monorepo-apps.md +26 -0
  51. package/templates/AGENTS.multiagent-safety.md +61 -347
  52. package/templates/AGENTS.multiagent-safety.min.md +11 -0
  53. package/templates/codex/skills/gx-act/SKILL.md +82 -0
  54. package/templates/githooks/pre-commit +22 -19
  55. package/templates/scripts/agent-branch-finish.sh +8 -30
  56. package/templates/scripts/agent-branch-merge.sh +4 -1
  57. package/templates/scripts/agent-branch-start.sh +88 -3
  58. package/templates/scripts/agent-preflight.sh +31 -5
  59. package/templates/scripts/agent-worktree-prune.sh +1 -1
  60. package/templates/scripts/codex-agent.sh +0 -91
  61. package/src/agents/detect.js +0 -160
  62. package/src/cockpit/keybindings.js +0 -224
  63. package/src/cockpit/layout.js +0 -224
@@ -0,0 +1,304 @@
1
+ // Small surface commands that don't justify their own files individually:
2
+ // `gx hook`, `gx internal`, `gx install-agent-skills`, `gx migrate`,
3
+ // `gx submodule`, `gx cockpit`, `gx protect`. Pure code-motion from
4
+ // src/cli/main.js.
5
+ const {
6
+ TOOL_NAME,
7
+ SHORT_TOOL_NAME,
8
+ GUARDEX_HOME_DIR,
9
+ HOOK_NAMES,
10
+ TEMPLATE_ROOT,
11
+ LEGACY_MANAGED_REPO_FILES,
12
+ REQUIRED_MANAGED_REPO_FILES,
13
+ USER_LEVEL_SKILL_ASSETS,
14
+ DEFAULT_PROTECTED_BRANCHES,
15
+ } = require('../../context');
16
+ const {
17
+ uniquePreserveOrder,
18
+ resolveRepoRoot,
19
+ readProtectedBranches,
20
+ writeProtectedBranches,
21
+ } = require('../../git');
22
+ const {
23
+ run,
24
+ extractTargetedArgs,
25
+ packageAssetEnv,
26
+ runPackageAsset,
27
+ runReviewBotCommand,
28
+ } = require('../../core/runtime');
29
+ const hooksModule = require('../../hooks');
30
+ const submoduleModule = require('../../submodule');
31
+ const {
32
+ removeLegacyPackageScripts,
33
+ installUserLevelAsset,
34
+ removeLegacyManagedRepoFile,
35
+ printOperations,
36
+ printStandaloneOperations,
37
+ configureHooks,
38
+ } = require('../../scaffold');
39
+ const { parseTargetFlag } = require('../args');
40
+ const {
41
+ runFixInternal,
42
+ } = require('../shared/scaffolding');
43
+
44
+ function hook(rawArgs) {
45
+ return hooksModule.hook(rawArgs, {
46
+ extractTargetedArgs,
47
+ run,
48
+ resolveRepoRoot,
49
+ packageAssetEnv,
50
+ configureHooks,
51
+ TEMPLATE_ROOT,
52
+ HOOK_NAMES,
53
+ TOOL_NAME,
54
+ SHORT_TOOL_NAME,
55
+ });
56
+ }
57
+
58
+ function internal(rawArgs) {
59
+ return hooksModule.internal(rawArgs, {
60
+ extractTargetedArgs,
61
+ resolveRepoRoot,
62
+ runReviewBotCommand,
63
+ runPackageAsset,
64
+ });
65
+ }
66
+
67
+ function installAgentSkills(rawArgs) {
68
+ let dryRun = false;
69
+ let force = false;
70
+ for (const arg of rawArgs) {
71
+ if (arg === '--dry-run') {
72
+ dryRun = true;
73
+ continue;
74
+ }
75
+ if (arg === '--force') {
76
+ force = true;
77
+ continue;
78
+ }
79
+ throw new Error(`Unknown option: ${arg}`);
80
+ }
81
+
82
+ const operations = USER_LEVEL_SKILL_ASSETS.map((asset) => installUserLevelAsset(asset, { dryRun, force }));
83
+ printStandaloneOperations('User-level Guardex skills', GUARDEX_HOME_DIR, operations, dryRun);
84
+ process.exitCode = 0;
85
+ }
86
+
87
+ function migrate(rawArgs) {
88
+ const { target, passthrough } = extractTargetedArgs(rawArgs);
89
+ let dryRun = false;
90
+ let force = false;
91
+ let installSkills = false;
92
+ for (const arg of passthrough) {
93
+ if (arg === '--dry-run') {
94
+ dryRun = true;
95
+ continue;
96
+ }
97
+ if (arg === '--force') {
98
+ force = true;
99
+ continue;
100
+ }
101
+ if (arg === '--install-agent-skills') {
102
+ installSkills = true;
103
+ continue;
104
+ }
105
+ throw new Error(`Unknown option: ${arg}`);
106
+ }
107
+
108
+ const repoRoot = resolveRepoRoot(target);
109
+ const fixPayload = runFixInternal({
110
+ target: repoRoot,
111
+ dryRun,
112
+ force,
113
+ skipAgents: false,
114
+ skipPackageJson: true,
115
+ skipGitignore: false,
116
+ dropStaleLocks: true,
117
+ });
118
+ printOperations('Migrate/fix', fixPayload, dryRun);
119
+
120
+ if (installSkills) {
121
+ const skillOps = USER_LEVEL_SKILL_ASSETS.map((asset) => installUserLevelAsset(asset, { dryRun, force }));
122
+ printStandaloneOperations('Migrate/install-agent-skills', GUARDEX_HOME_DIR, skillOps, dryRun);
123
+ }
124
+
125
+ const removableLegacyFiles = LEGACY_MANAGED_REPO_FILES.filter(
126
+ (relativePath) => !REQUIRED_MANAGED_REPO_FILES.includes(relativePath),
127
+ );
128
+ const removalOps = removableLegacyFiles.map((relativePath) => removeLegacyManagedRepoFile(repoRoot, relativePath, { dryRun, force }));
129
+ removalOps.push(removeLegacyPackageScripts(repoRoot, dryRun));
130
+ printStandaloneOperations('Migrate/cleanup', repoRoot, removalOps, dryRun);
131
+ process.exitCode = 0;
132
+ }
133
+
134
+ function submodule(rawArgs) {
135
+ const parsed = parseTargetFlag(rawArgs || [], process.cwd());
136
+ const [subcommand, ...rest] = parsed.args;
137
+
138
+ if (!subcommand || subcommand === 'help' || subcommand === '--help' || subcommand === '-h') {
139
+ console.log(
140
+ `${TOOL_NAME} submodule commands:\n` +
141
+ ` ${TOOL_NAME} submodule advance [<path>] [--push] [--dry-run] [--branch <ref>] [--no-commit] [--target <path>]\n\n` +
142
+ ` advance — for each submodule listed in .gitmodules, fetch the tracked branch's\n` +
143
+ ` remote tip, advance the parent pointer, and (when on a non-protected\n` +
144
+ ` branch) commit the bump. Use --push to publish in one step.`,
145
+ );
146
+ return;
147
+ }
148
+
149
+ if (subcommand !== 'advance') {
150
+ throw new Error(`Unknown submodule subcommand: ${subcommand}. Try '${SHORT_TOOL_NAME} submodule help'.`);
151
+ }
152
+
153
+ let push = false;
154
+ let dryRun = false;
155
+ let commit = true;
156
+ let branchOverride = '';
157
+ let pathArg = '';
158
+ for (let i = 0; i < rest.length; i += 1) {
159
+ const arg = rest[i];
160
+ if (arg === '--push') {
161
+ push = true;
162
+ continue;
163
+ }
164
+ if (arg === '--dry-run' || arg === '-n') {
165
+ dryRun = true;
166
+ continue;
167
+ }
168
+ if (arg === '--no-commit') {
169
+ commit = false;
170
+ continue;
171
+ }
172
+ if (arg === '--branch' || arg === '-b') {
173
+ branchOverride = rest[i + 1] || '';
174
+ i += 1;
175
+ continue;
176
+ }
177
+ if (arg.startsWith('--branch=')) {
178
+ branchOverride = arg.slice('--branch='.length);
179
+ continue;
180
+ }
181
+ if (arg.startsWith('--')) {
182
+ throw new Error(`Unknown option for '${SHORT_TOOL_NAME} submodule advance': ${arg}`);
183
+ }
184
+ if (pathArg) {
185
+ throw new Error(`'${SHORT_TOOL_NAME} submodule advance' accepts at most one submodule path (got '${pathArg}' and '${arg}')`);
186
+ }
187
+ pathArg = arg;
188
+ }
189
+
190
+ const result = submoduleModule.advance({
191
+ target: parsed.target,
192
+ path: pathArg,
193
+ push,
194
+ dryRun,
195
+ commit,
196
+ branch: branchOverride,
197
+ });
198
+ submoduleModule.printAdvanceResult(result);
199
+ }
200
+
201
+ function cockpit(rawArgs) {
202
+ // Lazy-require: cockpit pulls ~32 modules; load only for `gx cockpit`.
203
+ const cockpitModule = require('../../cockpit');
204
+ cockpitModule.openCockpit(rawArgs, {
205
+ resolveRepoRoot,
206
+ toolName: TOOL_NAME,
207
+ });
208
+ process.exitCode = 0;
209
+ }
210
+
211
+ function parseBranchList(rawValue) {
212
+ return String(rawValue || '')
213
+ .split(/[\s,]+/)
214
+ .map((item) => item.trim())
215
+ .filter(Boolean);
216
+ }
217
+
218
+ function protect(rawArgs) {
219
+ const parsed = parseTargetFlag(rawArgs, process.cwd());
220
+ const [subcommand, ...rest] = parsed.args;
221
+ const repoRoot = resolveRepoRoot(parsed.target);
222
+
223
+ if (!subcommand || subcommand === 'help' || subcommand === '--help' || subcommand === '-h') {
224
+ console.log(
225
+ `${TOOL_NAME} protect commands:\n` +
226
+ ` ${TOOL_NAME} protect list [--target <path>]\n` +
227
+ ` ${TOOL_NAME} protect add <branch...> [--target <path>]\n` +
228
+ ` ${TOOL_NAME} protect remove <branch...> [--target <path>]\n` +
229
+ ` ${TOOL_NAME} protect set <branch...> [--target <path>]\n` +
230
+ ` ${TOOL_NAME} protect reset [--target <path>]`,
231
+ );
232
+ process.exitCode = 0;
233
+ return;
234
+ }
235
+
236
+ const requestedBranches = uniquePreserveOrder(parseBranchList(rest.join(' ')));
237
+
238
+ if (subcommand === 'list') {
239
+ const branches = readProtectedBranches(repoRoot);
240
+ console.log(`[${TOOL_NAME}] Protected branches (${branches.length}): ${branches.join(', ')}`);
241
+ process.exitCode = 0;
242
+ return;
243
+ }
244
+
245
+ if (subcommand === 'add') {
246
+ if (requestedBranches.length === 0) {
247
+ throw new Error('protect add requires one or more branch names');
248
+ }
249
+ const current = readProtectedBranches(repoRoot);
250
+ const next = uniquePreserveOrder([...current, ...requestedBranches]);
251
+ writeProtectedBranches(repoRoot, next);
252
+ console.log(`[${TOOL_NAME}] Protected branches updated: ${next.join(', ')}`);
253
+ process.exitCode = 0;
254
+ return;
255
+ }
256
+
257
+ if (subcommand === 'remove') {
258
+ if (requestedBranches.length === 0) {
259
+ throw new Error('protect remove requires one or more branch names');
260
+ }
261
+ const current = readProtectedBranches(repoRoot);
262
+ const removals = new Set(requestedBranches);
263
+ const next = current.filter((branch) => !removals.has(branch));
264
+ writeProtectedBranches(repoRoot, next);
265
+ console.log(
266
+ `[${TOOL_NAME}] Protected branches updated: ` +
267
+ `${(next.length > 0 ? next : DEFAULT_PROTECTED_BRANCHES).join(', ')}`,
268
+ );
269
+ if (next.length === 0) {
270
+ console.log(`[${TOOL_NAME}] Reset to defaults (${DEFAULT_PROTECTED_BRANCHES.join(', ')}) because list was empty.`);
271
+ }
272
+ process.exitCode = 0;
273
+ return;
274
+ }
275
+
276
+ if (subcommand === 'set') {
277
+ if (requestedBranches.length === 0) {
278
+ throw new Error('protect set requires one or more branch names');
279
+ }
280
+ writeProtectedBranches(repoRoot, requestedBranches);
281
+ console.log(`[${TOOL_NAME}] Protected branches set: ${requestedBranches.join(', ')}`);
282
+ process.exitCode = 0;
283
+ return;
284
+ }
285
+
286
+ if (subcommand === 'reset') {
287
+ writeProtectedBranches(repoRoot, []);
288
+ console.log(`[${TOOL_NAME}] Protected branches reset to defaults: ${DEFAULT_PROTECTED_BRANCHES.join(', ')}`);
289
+ process.exitCode = 0;
290
+ return;
291
+ }
292
+
293
+ throw new Error(`Unknown protect subcommand: ${subcommand}`);
294
+ }
295
+
296
+ module.exports = {
297
+ hook,
298
+ internal,
299
+ installAgentSkills,
300
+ migrate,
301
+ submodule,
302
+ cockpit,
303
+ protect,
304
+ };