@imdeadpool/guardex 7.1.0 → 8.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.
- package/README.md +122 -322
- package/package.json +25 -5
- package/scripts/prepublish-bump-version.js +191 -0
- package/skills/gitguardex/SKILL.md +83 -3
- package/src/agents/activity.js +279 -0
- package/src/agents/finish.js +15 -0
- package/src/ci-init/index.js +0 -1
- package/src/cli/args.js +203 -6
- package/src/cli/commands/agents.js +17 -0
- package/src/cli/commands/branch.js +267 -14
- package/src/cli/commands/claude.js +15 -0
- package/src/cli/commands/doctor.js +26 -0
- package/src/cli/commands/onboard.js +293 -0
- package/src/cli/commands/prompt.js +15 -3
- package/src/cli/commands/review.js +18 -0
- package/src/cli/commands/setup.js +8 -6
- package/src/cli/commands/status.js +12 -0
- package/src/cli/main.js +2 -0
- package/src/cli/shared-locks.js +304 -0
- package/src/context.js +21 -3
- package/src/core/runtime.js +33 -1
- package/src/doctor/index.js +58 -5
- package/src/finish/heartbeat.js +169 -0
- package/src/finish/index.js +106 -4
- package/src/finish/progress.js +262 -0
- package/src/finish/review-gate.js +453 -32
- package/src/github-api.js +59 -0
- package/src/mcp/collect.js +111 -12
- package/src/mcp/server.js +10 -4
- package/src/output/index.js +210 -0
- package/src/pr-checks.js +121 -0
- package/src/pr-review.js +581 -51
- package/src/pr.js +143 -21
- package/src/provider-binary.js +101 -0
- package/src/review-diff.js +116 -0
- package/src/review-fix.js +229 -0
- package/src/sandbox/index.js +11 -5
- package/src/scaffold/agent-worktree-prep.js +9 -2
- package/src/scaffold/index.js +4 -16
- package/src/scaffold/provision-config.js +314 -0
- package/src/shared-git-state.js +566 -0
- package/src/terminal/kitty.js +20 -0
- package/src/terminal/tmux.js +9 -0
- package/templates/AGENTS.multiagent-safety.md +73 -11
- package/templates/AGENTS.multiagent-safety.min.md +1 -0
- package/templates/codex/skills/gitguardex/SKILL.md +83 -3
- package/templates/githooks/post-checkout +4 -9
- package/templates/githooks/pre-commit +17 -1
- package/templates/github/workflows/README.md +30 -23
- package/templates/scripts/agent-autofinish-watch.sh +280 -0
- package/templates/scripts/agent-branch-finish.sh +363 -26
- package/templates/scripts/agent-branch-start.sh +76 -25
- package/templates/scripts/agent-claude-stop-finish.sh +194 -0
- package/templates/scripts/agent-file-locks.py +390 -52
- package/templates/scripts/agent-preflight.sh +14 -2
- package/templates/scripts/agent-stalled-report.sh +40 -0
- package/templates/scripts/codex-agent.sh +10 -63
- package/templates/github/workflows/cr.yml +0 -46
|
@@ -16,6 +16,7 @@ const {
|
|
|
16
16
|
colorizeDoctorOutput,
|
|
17
17
|
formatElapsedDuration,
|
|
18
18
|
printAutoFinishSummary,
|
|
19
|
+
describeCompressor,
|
|
19
20
|
} = require('../../output');
|
|
20
21
|
const {
|
|
21
22
|
ensureOmxScaffold,
|
|
@@ -40,6 +41,29 @@ const {
|
|
|
40
41
|
} = require('../shared/sandbox');
|
|
41
42
|
const { printRequiredSystemToolStatus } = require('./setup');
|
|
42
43
|
|
|
44
|
+
// Advisory only — the GUARDEX_COMPRESS_CMD token-compression hook fails open, so
|
|
45
|
+
// a misconfigured compressor silently wastes tokens rather than breaking the
|
|
46
|
+
// repo. Doctor surfaces it as a warning but never changes the safe/unsafe exit
|
|
47
|
+
// code (compression is an optimization, not a safety guarantee). Silent when
|
|
48
|
+
// unset so the common case stays quiet.
|
|
49
|
+
function printCompressorHealth() {
|
|
50
|
+
const compressor = describeCompressor();
|
|
51
|
+
if (!compressor.configured) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (compressor.available === false) {
|
|
55
|
+
console.log(
|
|
56
|
+
colorizeDoctorOutput(
|
|
57
|
+
`[${TOOL_NAME}] ⚠️ Token compression: '${compressor.command}' not found on PATH — ` +
|
|
58
|
+
'GUARDEX_COMPRESS_CMD is set but gx output is not being compressed.',
|
|
59
|
+
'warn',
|
|
60
|
+
),
|
|
61
|
+
);
|
|
62
|
+
} else {
|
|
63
|
+
console.log(`[${TOOL_NAME}] Token compression: '${compressor.command}' configured.`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
43
67
|
function doctor(rawArgs) {
|
|
44
68
|
const options = parseDoctorArgs(rawArgs);
|
|
45
69
|
const topRepoRoot = resolveRepoRoot(options.target);
|
|
@@ -160,6 +184,7 @@ function doctor(rawArgs) {
|
|
|
160
184
|
|
|
161
185
|
if (!singleRepoOptions.json) {
|
|
162
186
|
printRequiredSystemToolStatus();
|
|
187
|
+
printCompressorHealth();
|
|
163
188
|
}
|
|
164
189
|
|
|
165
190
|
const blocked = protectedBaseWriteBlock(singleRepoOptions, { requireBootstrap: false });
|
|
@@ -229,6 +254,7 @@ function doctor(rawArgs) {
|
|
|
229
254
|
},
|
|
230
255
|
autoFinish: autoFinishSummary,
|
|
231
256
|
worktreePrune: prunePayload,
|
|
257
|
+
compression: describeCompressor(),
|
|
232
258
|
},
|
|
233
259
|
null,
|
|
234
260
|
2,
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
// `gx onboard` — guided first-run experience for a new GitGuardex user.
|
|
2
|
+
//
|
|
3
|
+
// It does three things and nothing destructive:
|
|
4
|
+
// 1. reflects what is already wired in the current repo (guardrails,
|
|
5
|
+
// companions, origin) so a newcomer knows their real starting point,
|
|
6
|
+
// 2. teaches the load-bearing model (isolated lanes / file locks / PR-only)
|
|
7
|
+
// and the exact first-task command sequence,
|
|
8
|
+
// 3. drops a tiny first-run marker so `gx setup` only nudges toward the tour
|
|
9
|
+
// once.
|
|
10
|
+
//
|
|
11
|
+
// The marker lives under the repo's runtime state dir (gitignored), so it is
|
|
12
|
+
// per-repo and never committed.
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
fs,
|
|
16
|
+
path,
|
|
17
|
+
TOOL_NAME,
|
|
18
|
+
SHORT_TOOL_NAME,
|
|
19
|
+
packageJson,
|
|
20
|
+
} = require('../../context');
|
|
21
|
+
const {
|
|
22
|
+
resolveRepoRoot,
|
|
23
|
+
isGitRepo,
|
|
24
|
+
currentBranchName,
|
|
25
|
+
repoHasHeadCommit,
|
|
26
|
+
hasOriginRemote,
|
|
27
|
+
} = require('../../git');
|
|
28
|
+
const { colorize, statusDot, supportsAnsiColors } = require('../../output');
|
|
29
|
+
const { collectServicesSnapshot } = require('./status');
|
|
30
|
+
|
|
31
|
+
const ONBOARD_MARKER_RELATIVE = path.join('.omx', 'state', 'onboarded.json');
|
|
32
|
+
const MANAGED_BLOCK_MARKER = 'multiagent-safety:START';
|
|
33
|
+
|
|
34
|
+
function onboardMarkerPath(repoRoot) {
|
|
35
|
+
return path.join(repoRoot, ONBOARD_MARKER_RELATIVE);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// hasCompletedOnboarding is intentionally cheap and forgiving: any unreadable
|
|
39
|
+
// state simply means "not onboarded yet" so a newcomer still gets the nudge.
|
|
40
|
+
function hasCompletedOnboarding(repoRoot) {
|
|
41
|
+
try {
|
|
42
|
+
return fs.existsSync(onboardMarkerPath(repoRoot));
|
|
43
|
+
} catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function markOnboardingComplete(repoRoot) {
|
|
49
|
+
try {
|
|
50
|
+
const markerPath = onboardMarkerPath(repoRoot);
|
|
51
|
+
fs.mkdirSync(path.dirname(markerPath), { recursive: true });
|
|
52
|
+
fs.writeFileSync(
|
|
53
|
+
markerPath,
|
|
54
|
+
`${JSON.stringify({ version: packageJson.version, at: new Date().toISOString() }, null, 2)}\n`,
|
|
55
|
+
'utf8',
|
|
56
|
+
);
|
|
57
|
+
return true;
|
|
58
|
+
} catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function resetOnboarding(repoRoot) {
|
|
64
|
+
try {
|
|
65
|
+
fs.rmSync(onboardMarkerPath(repoRoot), { force: true });
|
|
66
|
+
return true;
|
|
67
|
+
} catch {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// guardrailsInstalled treats the managed AGENTS.md/CLAUDE.md block as the
|
|
73
|
+
// canonical "setup has run here" signal — it is what `gx setup`/`gx doctor`
|
|
74
|
+
// write and is stable across worktrees.
|
|
75
|
+
function guardrailsInstalled(repoRoot) {
|
|
76
|
+
for (const name of ['AGENTS.md', 'CLAUDE.md']) {
|
|
77
|
+
try {
|
|
78
|
+
const contents = fs.readFileSync(path.join(repoRoot, name), 'utf8');
|
|
79
|
+
if (contents.includes(MANAGED_BLOCK_MARKER)) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
} catch {
|
|
83
|
+
// missing/unreadable file — keep checking the next candidate.
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function bold(text) {
|
|
90
|
+
return supportsAnsiColors() ? colorize(text, '1') : text;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function dim(text) {
|
|
94
|
+
return supportsAnsiColors() ? colorize(text, '2') : text;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function heading(text) {
|
|
98
|
+
return supportsAnsiColors() ? colorize(text, '1;36') : text;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function printOnboardHelp() {
|
|
102
|
+
console.log(
|
|
103
|
+
`${SHORT_TOOL_NAME} onboard — guided first-run tour.\n` +
|
|
104
|
+
` ${SHORT_TOOL_NAME} onboard Show where you are + how to start\n` +
|
|
105
|
+
` ${SHORT_TOOL_NAME} onboard --target <path> Inspect another repo path\n` +
|
|
106
|
+
` ${SHORT_TOOL_NAME} onboard --reset Clear the first-run marker (re-arms the setup nudge)`,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function parseOnboardArgs(rawArgs) {
|
|
111
|
+
const args = Array.isArray(rawArgs) ? rawArgs : [];
|
|
112
|
+
const options = { target: process.cwd(), reset: false, help: false };
|
|
113
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
114
|
+
const arg = args[index];
|
|
115
|
+
if (arg === '-h' || arg === '--help') {
|
|
116
|
+
options.help = true;
|
|
117
|
+
} else if (arg === '--reset') {
|
|
118
|
+
options.reset = true;
|
|
119
|
+
} else if (arg === '--target' || arg === '--current') {
|
|
120
|
+
if (arg === '--current') {
|
|
121
|
+
options.target = process.cwd();
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const value = args[index + 1];
|
|
125
|
+
if (!value || value.startsWith('--')) {
|
|
126
|
+
throw new Error('--target requires a path value');
|
|
127
|
+
}
|
|
128
|
+
options.target = value;
|
|
129
|
+
index += 1;
|
|
130
|
+
} else if (arg.startsWith('--target=')) {
|
|
131
|
+
options.target = arg.slice('--target='.length);
|
|
132
|
+
} else {
|
|
133
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return options;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function statusLine(label, status, detail) {
|
|
140
|
+
const dot = statusDot(status);
|
|
141
|
+
const tail = detail ? ` ${dim(detail)}` : '';
|
|
142
|
+
return ` ${dot} ${label.padEnd(12)}${tail}`;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function printWhereYouAre(repoRoot, inRepo) {
|
|
146
|
+
console.log(heading('WHERE YOU ARE'));
|
|
147
|
+
if (!inRepo) {
|
|
148
|
+
console.log(statusLine('repo', 'inactive', 'not a git repo — run from a repo root or pass --target <path>'));
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const branch = currentBranchName(repoRoot) || '(detached)';
|
|
152
|
+
const installed = guardrailsInstalled(repoRoot);
|
|
153
|
+
const hasOrigin = hasOriginRemote(repoRoot);
|
|
154
|
+
const hasCommit = repoHasHeadCommit(repoRoot);
|
|
155
|
+
|
|
156
|
+
console.log(statusLine('repo', 'active', repoRoot));
|
|
157
|
+
console.log(statusLine('branch', 'active', branch));
|
|
158
|
+
console.log(
|
|
159
|
+
installed
|
|
160
|
+
? statusLine('guardrails', 'active', 'installed')
|
|
161
|
+
: statusLine('guardrails', 'inactive', `not yet — run \`${SHORT_TOOL_NAME} setup\``),
|
|
162
|
+
);
|
|
163
|
+
console.log(
|
|
164
|
+
hasOrigin
|
|
165
|
+
? statusLine('origin', 'active', 'remote present')
|
|
166
|
+
: statusLine('origin', 'warning', 'none — finish/merge stay local until you add one'),
|
|
167
|
+
);
|
|
168
|
+
if (!hasCommit) {
|
|
169
|
+
console.log(statusLine('commits', 'warning', 'fresh repo — make a first commit before finishing a lane'));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function companionNote(service) {
|
|
174
|
+
if (service.status === 'active') {
|
|
175
|
+
return '';
|
|
176
|
+
}
|
|
177
|
+
if (service.status === 'unknown') {
|
|
178
|
+
return 'status unknown (is npm on PATH?)';
|
|
179
|
+
}
|
|
180
|
+
if (service.required) {
|
|
181
|
+
return 'required · not on PATH';
|
|
182
|
+
}
|
|
183
|
+
return 'optional · not installed';
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function printCompanions() {
|
|
187
|
+
let snapshot;
|
|
188
|
+
try {
|
|
189
|
+
snapshot = collectServicesSnapshot();
|
|
190
|
+
} catch {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
// requiredSystemTools (gh/rtk) gate PR + finish automation, so flag them as
|
|
194
|
+
// required rather than letting them read as "optional companions".
|
|
195
|
+
const requiredNames = new Set(
|
|
196
|
+
(snapshot.requiredSystemTools || []).map((tool) => tool.displayName || tool.name),
|
|
197
|
+
);
|
|
198
|
+
const services = (snapshot.services || [])
|
|
199
|
+
.filter((service) => service && service.displayName)
|
|
200
|
+
.map((service) => ({ ...service, required: requiredNames.has(service.displayName) }));
|
|
201
|
+
if (services.length === 0) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
console.log('');
|
|
205
|
+
console.log(heading('COMPANIONS') + dim(' (all optional except gh/rtk)'));
|
|
206
|
+
const maxName = services.reduce((max, service) => Math.max(max, service.displayName.length), 0);
|
|
207
|
+
for (const service of services) {
|
|
208
|
+
const note = companionNote(service);
|
|
209
|
+
console.log(` ${statusDot(service.status)} ${service.displayName.padEnd(maxName + 2)}${note ? dim(note) : ''}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function printHowItWorks() {
|
|
214
|
+
console.log('');
|
|
215
|
+
console.log(heading('HOW IT WORKS') + dim(' (30 seconds)'));
|
|
216
|
+
console.log(` 1. ${bold('Isolated lane')} — each task gets its own ${bold('agent/*')} branch + worktree`);
|
|
217
|
+
console.log(` 2. ${bold('File locks')} — claim files before editing; nobody clobbers them`);
|
|
218
|
+
console.log(` 3. ${bold('Protected base')} — main/dev are never edited directly; you merge via PR`);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function printFirstTask(installed) {
|
|
222
|
+
console.log('');
|
|
223
|
+
console.log(heading('YOUR FIRST TASK'));
|
|
224
|
+
const setupMark = installed ? dim('# done ✓') : dim('# one-time: wire hooks + companions');
|
|
225
|
+
console.log(` 1. ${SHORT_TOOL_NAME} setup ${setupMark}`);
|
|
226
|
+
console.log(` 2. ${SHORT_TOOL_NAME} branch start "<task>" "<agent>" ${dim('# isolated lane + worktree')}`);
|
|
227
|
+
console.log(` 3. ${SHORT_TOOL_NAME} locks claim --branch <branch> <file...> ${dim('# declare what you touch')}`);
|
|
228
|
+
console.log(` 4. ${dim('<implement + run your tests inside the worktree>')}`);
|
|
229
|
+
console.log(` 5. ${SHORT_TOOL_NAME} branch finish --via-pr --wait-for-merge --cleanup`);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function printNext(installed) {
|
|
233
|
+
console.log('');
|
|
234
|
+
console.log(heading('NEXT'));
|
|
235
|
+
if (!installed) {
|
|
236
|
+
console.log(` › ${SHORT_TOOL_NAME} setup ${dim('install + verify guardrails in this repo')}`);
|
|
237
|
+
}
|
|
238
|
+
console.log(` › ${SHORT_TOOL_NAME} prompt ${dim('copy the AI setup checklist for your agent')}`);
|
|
239
|
+
console.log(` › ${SHORT_TOOL_NAME} status ${dim('health check anytime (never modifies files)')}`);
|
|
240
|
+
console.log(` › ${SHORT_TOOL_NAME} help ${dim('full command list')}`);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function onboard(rawArgs) {
|
|
244
|
+
const options = parseOnboardArgs(rawArgs);
|
|
245
|
+
if (options.help) {
|
|
246
|
+
printOnboardHelp();
|
|
247
|
+
process.exitCode = 0;
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const inRepo = isGitRepo(options.target);
|
|
252
|
+
const repoRoot = inRepo ? resolveRepoRoot(options.target) : path.resolve(options.target);
|
|
253
|
+
|
|
254
|
+
if (options.reset) {
|
|
255
|
+
const cleared = resetOnboarding(repoRoot);
|
|
256
|
+
console.log(
|
|
257
|
+
cleared
|
|
258
|
+
? `[${TOOL_NAME}] First-run marker cleared. \`${SHORT_TOOL_NAME} setup\` will nudge the tour again.`
|
|
259
|
+
: `[${TOOL_NAME}] No first-run marker to clear.`,
|
|
260
|
+
);
|
|
261
|
+
process.exitCode = 0;
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const installed = inRepo && guardrailsInstalled(repoRoot);
|
|
266
|
+
|
|
267
|
+
console.log('');
|
|
268
|
+
console.log(`👋 ${bold(`Welcome to GitGuardex v${packageJson.version}`)}`);
|
|
269
|
+
console.log(` ${dim('Guardian t-rex for multi-agent repos — many agents, one clean repo.')}`);
|
|
270
|
+
console.log('');
|
|
271
|
+
|
|
272
|
+
printWhereYouAre(repoRoot, inRepo);
|
|
273
|
+
printCompanions();
|
|
274
|
+
printHowItWorks();
|
|
275
|
+
printFirstTask(installed);
|
|
276
|
+
printNext(installed);
|
|
277
|
+
console.log('');
|
|
278
|
+
|
|
279
|
+
if (inRepo) {
|
|
280
|
+
markOnboardingComplete(repoRoot);
|
|
281
|
+
}
|
|
282
|
+
process.exitCode = 0;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
module.exports = {
|
|
286
|
+
onboard,
|
|
287
|
+
hasCompletedOnboarding,
|
|
288
|
+
markOnboardingComplete,
|
|
289
|
+
resetOnboarding,
|
|
290
|
+
guardrailsInstalled,
|
|
291
|
+
onboardMarkerPath,
|
|
292
|
+
ONBOARD_MARKER_RELATIVE,
|
|
293
|
+
};
|
|
@@ -10,18 +10,26 @@ const {
|
|
|
10
10
|
AI_SETUP_PROMPT,
|
|
11
11
|
AI_SETUP_COMMANDS,
|
|
12
12
|
} = require('../../context');
|
|
13
|
+
const { compressBlock } = require('../../output');
|
|
13
14
|
|
|
14
15
|
function printAgentsSnippet() {
|
|
15
16
|
const snippetPath = path.join(TEMPLATE_ROOT, 'AGENTS.multiagent-safety.md');
|
|
16
|
-
|
|
17
|
+
// Route the large AGENTS narrative through the optional compressor
|
|
18
|
+
// (GUARDEX_COMPRESS_CMD). No compressor configured -> unchanged passthrough.
|
|
19
|
+
process.stdout.write(compressBlock(fs.readFileSync(snippetPath, 'utf8')));
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
function copyPrompt() {
|
|
20
|
-
|
|
23
|
+
// AI_SETUP_PROMPT is the large narrative checklist an agent reads each
|
|
24
|
+
// session, so route it through the optional compressor (GUARDEX_COMPRESS_CMD)
|
|
25
|
+
// exactly like the main `gx prompt` path and `printAgentsSnippet`.
|
|
26
|
+
process.stdout.write(compressBlock(AI_SETUP_PROMPT));
|
|
21
27
|
process.exitCode = 0;
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
function copyCommands() {
|
|
31
|
+
// AI_SETUP_COMMANDS is shell-ready output (runnable commands), so it is never
|
|
32
|
+
// compressed — a compressor would corrupt the commands an agent pastes.
|
|
25
33
|
process.stdout.write(AI_SETUP_COMMANDS);
|
|
26
34
|
process.exitCode = 0;
|
|
27
35
|
}
|
|
@@ -80,7 +88,11 @@ function prompt(rawArgs) {
|
|
|
80
88
|
process.exitCode = 0;
|
|
81
89
|
return;
|
|
82
90
|
}
|
|
83
|
-
|
|
91
|
+
const rendered = renderAiSetupPrompt({ exec: variant === 'exec', parts: selectedParts });
|
|
92
|
+
// The default/prompt variant is the large narrative checklist; route it
|
|
93
|
+
// through the optional compressor. The --exec variant is shell-ready output
|
|
94
|
+
// (runnable commands) and must never be compressed.
|
|
95
|
+
process.stdout.write(variant === 'exec' ? rendered : compressBlock(rendered));
|
|
84
96
|
process.exitCode = 0;
|
|
85
97
|
}
|
|
86
98
|
|
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
const { resolveRepoRoot } = require('../../git');
|
|
4
4
|
const { runReviewBotCommand } = require('../../core/runtime');
|
|
5
5
|
const prReviewModule = require('../../pr-review');
|
|
6
|
+
const reviewFixModule = require('../../review-fix');
|
|
6
7
|
const { parseReviewArgs, parsePrReviewArgs } = require('../args');
|
|
7
8
|
const { isSpawnFailure } = require('../shared/sandbox');
|
|
8
9
|
|
|
10
|
+
const TOOL_PREFIX = '[gitguardex]';
|
|
11
|
+
|
|
9
12
|
function review(rawArgs) {
|
|
10
13
|
const options = parseReviewArgs(rawArgs);
|
|
11
14
|
const repoRoot = resolveRepoRoot(options.target);
|
|
@@ -23,6 +26,21 @@ function prReview(rawArgs) {
|
|
|
23
26
|
const options = parsePrReviewArgs(rawArgs);
|
|
24
27
|
const result = prReviewModule.runPrReview(options);
|
|
25
28
|
prReviewModule.printPrReviewResult(result);
|
|
29
|
+
|
|
30
|
+
if (options.fix && result.findings.length > 0) {
|
|
31
|
+
const fix = reviewFixModule.runReviewFix({
|
|
32
|
+
repoRoot: resolveRepoRoot(options.target),
|
|
33
|
+
provider: options.provider,
|
|
34
|
+
findings: result.findings,
|
|
35
|
+
});
|
|
36
|
+
if (fix.status === 'fixed') {
|
|
37
|
+
console.log(`${TOOL_PREFIX} Auto-fix committed ${fix.changedFiles.length} file(s): ${fix.changedFiles.join(', ')}`);
|
|
38
|
+
console.log(`${TOOL_PREFIX} Re-run the review to confirm the findings are gone before merging.`);
|
|
39
|
+
} else {
|
|
40
|
+
console.log(`${TOOL_PREFIX} Auto-fix skipped: ${fix.reason || fix.status}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
26
44
|
process.exitCode = 0;
|
|
27
45
|
}
|
|
28
46
|
|
|
@@ -17,8 +17,9 @@ const {
|
|
|
17
17
|
const toolchainModule = require('../../toolchain');
|
|
18
18
|
const doctorModule = require('../../doctor');
|
|
19
19
|
const speckitModule = require('../../speckit');
|
|
20
|
-
const { printAutoFinishSummary } = require('../../output');
|
|
20
|
+
const { printAutoFinishSummary, colorize, supportsAnsiColors } = require('../../output');
|
|
21
21
|
const { printOperations } = require('../../scaffold');
|
|
22
|
+
const { hasCompletedOnboarding } = require('./onboard');
|
|
22
23
|
const { parseSetupArgs } = require('../args');
|
|
23
24
|
const {
|
|
24
25
|
runScanInternal,
|
|
@@ -217,14 +218,15 @@ function setup(rawArgs) {
|
|
|
217
218
|
const repoCount = discoveredRepos.length;
|
|
218
219
|
const suffix = repoCount > 1 ? ` (${repoCount} repos)` : '';
|
|
219
220
|
console.log(`[${TOOL_NAME}] ✅ Setup complete.${suffix}`);
|
|
221
|
+
// First run in this repo: point newcomers at the guided tour exactly once.
|
|
222
|
+
if (!hasCompletedOnboarding(topRepoRoot)) {
|
|
223
|
+
const nudge = `👋 New to GitGuardex? Run \`${SHORT_TOOL_NAME} onboard\` for a 2-minute guided tour.`;
|
|
224
|
+
console.log(`[${TOOL_NAME}] ${supportsAnsiColors() ? colorize(nudge, '1;36') : nudge}`);
|
|
225
|
+
}
|
|
220
226
|
console.log(`[${TOOL_NAME}] Copy AI setup prompt with: ${SHORT_TOOL_NAME} prompt`);
|
|
221
227
|
console.log(
|
|
222
|
-
`[${TOOL_NAME}] OpenSpec
|
|
223
|
-
);
|
|
224
|
-
console.log(
|
|
225
|
-
`[${TOOL_NAME}] Optional expanded OpenSpec profile: openspec config profile <profile-name> && openspec update`,
|
|
228
|
+
`[${TOOL_NAME}] Optional OpenSpec: /opsx:propose -> /opsx:apply -> /opsx:archive; guide: docs/openspec-getting-started.md`,
|
|
226
229
|
);
|
|
227
|
-
console.log(`[${TOOL_NAME}] OpenSpec guide: docs/openspec-getting-started.md`);
|
|
228
230
|
}
|
|
229
231
|
|
|
230
232
|
if (lastScanResult) {
|
|
@@ -13,6 +13,7 @@ const toolchainModule = require('../../toolchain');
|
|
|
13
13
|
const {
|
|
14
14
|
runtimeVersion,
|
|
15
15
|
statusDot,
|
|
16
|
+
describeCompressor,
|
|
16
17
|
printToolLogsSummary,
|
|
17
18
|
getInvokedCliName,
|
|
18
19
|
} = require('../../output');
|
|
@@ -180,6 +181,7 @@ function status(rawArgs) {
|
|
|
180
181
|
: null,
|
|
181
182
|
},
|
|
182
183
|
detectionError: toolchain.ok ? null : toolchain.error,
|
|
184
|
+
compression: describeCompressor(),
|
|
183
185
|
};
|
|
184
186
|
|
|
185
187
|
if (options.json) {
|
|
@@ -214,6 +216,16 @@ function status(rawArgs) {
|
|
|
214
216
|
console.log(` - ${statusDot(service.status)} ${serviceLabel}: ${service.status}`);
|
|
215
217
|
}
|
|
216
218
|
}
|
|
219
|
+
if (payload.compression.configured) {
|
|
220
|
+
const { command, available } = payload.compression;
|
|
221
|
+
if (available === false) {
|
|
222
|
+
console.log(
|
|
223
|
+
`[${TOOL_NAME}] Token compression: ${statusDot('degraded')} ${command} — not found on PATH (gx output is not compressed)`,
|
|
224
|
+
);
|
|
225
|
+
} else {
|
|
226
|
+
console.log(`[${TOOL_NAME}] Token compression: ${statusDot('active')} ${command}`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
217
229
|
const inactiveOptionalCompanions = [...npmServices, ...localCompanionServices]
|
|
218
230
|
.filter((service) => service.status !== 'active')
|
|
219
231
|
.map((service) => service.displayName || service.name);
|
package/src/cli/main.js
CHANGED
|
@@ -32,6 +32,7 @@ const { resolveRepoRoot } = require('../git');
|
|
|
32
32
|
// Subcommand modules (each owns one or a small cluster of verbs).
|
|
33
33
|
const { status } = require('./commands/status');
|
|
34
34
|
const { setup } = require('./commands/setup');
|
|
35
|
+
const { onboard } = require('./commands/onboard');
|
|
35
36
|
const { install, fix, scan } = require('./commands/bootstrap');
|
|
36
37
|
const { doctor } = require('./commands/doctor');
|
|
37
38
|
const { review, prReview } = require('./commands/review');
|
|
@@ -208,6 +209,7 @@ async function main() {
|
|
|
208
209
|
return setup(repairOnly.remaining);
|
|
209
210
|
}
|
|
210
211
|
|
|
212
|
+
if (command === 'onboard' || command === 'welcome') return onboard(rest);
|
|
211
213
|
if (command === 'prompt') return prompt(rest);
|
|
212
214
|
if (command === 'pr-review') return prReview(rest);
|
|
213
215
|
if (command === 'pr') return prCommand(rest);
|