@imdeadpool/guardex 8.4.5 → 8.4.7
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/package.json +2 -2
- package/src/agents/inspect.js +40 -7
- package/src/agents/status.js +23 -11
- package/src/cli/commands/pr.js +11 -0
- package/src/pr.js +11 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imdeadpool/guardex",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.7",
|
|
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,
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"jsonc-parser": "3.3.1",
|
|
98
98
|
"semver": "7.7.4"
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "35e5af1b87965537ad1fa8d6b1784603d0e12a53"
|
|
101
101
|
}
|
package/src/agents/inspect.js
CHANGED
|
@@ -67,11 +67,11 @@ function worktreePathForBranch(repoRoot, branch, worktrees = null) {
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
function resolveBaseBranch(repoRoot, branch) {
|
|
71
|
-
const perBranch =
|
|
70
|
+
function resolveBaseBranch(repoRoot, branch, readConfig = readGitConfig) {
|
|
71
|
+
const perBranch = readConfig(repoRoot, `branch.${branch}.guardexbase`);
|
|
72
72
|
if (perBranch) return perBranch;
|
|
73
73
|
|
|
74
|
-
const configuredBase =
|
|
74
|
+
const configuredBase = readConfig(repoRoot, 'multiagent.basebranch');
|
|
75
75
|
// Infer from history; do NOT persist (inspect is read-only display).
|
|
76
76
|
const inferred = inferBaseBranchFromHistory(repoRoot, branch, {
|
|
77
77
|
configuredBase,
|
|
@@ -131,20 +131,26 @@ function readUntrackedFiles(worktreePath) {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
function inspectAgentBranch(options) {
|
|
134
|
-
|
|
134
|
+
return inspectBranch(resolveRepoRoot(options.target || process.cwd()), options);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function inspectBranch(repoRoot, options, readConfig, compareBase = compareRefForBase) {
|
|
135
138
|
const branch = String(options.branch || '').trim();
|
|
136
139
|
if (!branch) {
|
|
137
140
|
throw new Error('--branch requires an agent branch name');
|
|
138
141
|
}
|
|
139
142
|
|
|
140
|
-
const baseBranch = resolveBaseBranch(repoRoot, branch);
|
|
141
|
-
const compareRef =
|
|
143
|
+
const baseBranch = resolveBaseBranch(repoRoot, branch, readConfig);
|
|
144
|
+
const compareRef = compareBase(repoRoot, baseBranch);
|
|
142
145
|
const { worktreePath, worktreeFound } = worktreePathForBranch(repoRoot, branch, options.worktrees);
|
|
143
146
|
return { repoRoot, branch, baseBranch, compareRef, worktreePath, worktreeFound };
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
function changedFiles(options) {
|
|
147
|
-
|
|
150
|
+
return changedFilesInContext(inspectAgentBranch(options));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function changedFilesInContext(context) {
|
|
148
154
|
const diffTarget = context.worktreeFound ? context.compareRef : `${context.compareRef}...${context.branch}`;
|
|
149
155
|
const result = git(context.worktreePath, ['diff', '--name-only', diffTarget, '--', '.', `:(exclude)${LOCK_FILE_RELATIVE}`]);
|
|
150
156
|
const files = [...splitGitLines(result.stdout), ...(context.worktreeFound ? readUntrackedFiles(context.worktreePath) : [])];
|
|
@@ -152,6 +158,32 @@ function changedFiles(options) {
|
|
|
152
158
|
return { ...context, files: uniqueFiles };
|
|
153
159
|
}
|
|
154
160
|
|
|
161
|
+
function createChangedFilesReader(target, worktrees) {
|
|
162
|
+
const repoRoot = resolveRepoRoot(target);
|
|
163
|
+
// Git's scalar config getter takes the last value. Preserve that precedence
|
|
164
|
+
// and the subsection's case; only the section and key are canonicalized.
|
|
165
|
+
const result = git(repoRoot, ['config', '--null', '--get-regexp', '^(branch\\..*\\.guardexbase|multiagent\\.basebranch)$'],
|
|
166
|
+
{ allowFailure: true });
|
|
167
|
+
const config = new Map();
|
|
168
|
+
if (result.status === 0) {
|
|
169
|
+
for (const entry of String(result.stdout || '').split('\0')) {
|
|
170
|
+
if (!entry) continue;
|
|
171
|
+
const separator = entry.indexOf('\n');
|
|
172
|
+
if (separator < 0) config.set(entry, '');
|
|
173
|
+
else config.set(entry.slice(0, separator), entry.slice(separator + 1).trim());
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const readConfig = result.status === 0 || result.status === 1
|
|
177
|
+
? (_repo, key) => config.get(key) || ''
|
|
178
|
+
: readGitConfig;
|
|
179
|
+
const compareRefs = new Map();
|
|
180
|
+
const compareBase = (repo, base) => {
|
|
181
|
+
if (!compareRefs.has(base)) compareRefs.set(base, compareRefForBase(repo, base));
|
|
182
|
+
return compareRefs.get(base);
|
|
183
|
+
};
|
|
184
|
+
return (branch) => changedFilesInContext(inspectBranch(repoRoot, { branch, worktrees }, readConfig, compareBase)).files;
|
|
185
|
+
}
|
|
186
|
+
|
|
155
187
|
function branchDiff(options) {
|
|
156
188
|
const context = inspectAgentBranch(options);
|
|
157
189
|
const diffTarget = context.worktreeFound ? context.compareRef : `${context.compareRef}...${context.branch}`;
|
|
@@ -198,6 +230,7 @@ module.exports = {
|
|
|
198
230
|
branchDiff,
|
|
199
231
|
branchLocks,
|
|
200
232
|
changedFiles,
|
|
233
|
+
createChangedFilesReader,
|
|
201
234
|
inspectAgentBranch,
|
|
202
235
|
listWorktrees,
|
|
203
236
|
parseWorktreeList,
|
package/src/agents/status.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { fs, path, LOCK_FILE_RELATIVE, TOOL_NAME } = require('../context');
|
|
2
|
-
const {
|
|
2
|
+
const { createChangedFilesReader, listWorktrees } = require('./inspect');
|
|
3
3
|
const { listAgentSessions } = require('./sessions');
|
|
4
4
|
|
|
5
5
|
function uniqueSorted(values) {
|
|
@@ -35,13 +35,21 @@ function readLockDetails(repoRoot) {
|
|
|
35
35
|
return { counts, files };
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
function statusChangedFilesReader() {
|
|
39
|
+
let readFiles;
|
|
40
|
+
const byBranch = new Map();
|
|
41
|
+
return (repoRoot, branch, worktrees) => {
|
|
42
|
+
if (!branch) return [];
|
|
43
|
+
if (!byBranch.has(branch)) {
|
|
44
|
+
try {
|
|
45
|
+
readFiles ||= createChangedFilesReader(repoRoot, worktrees);
|
|
46
|
+
byBranch.set(branch, readFiles(branch));
|
|
47
|
+
} catch (_error) {
|
|
48
|
+
byBranch.set(branch, []);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return [...byBranch.get(branch)];
|
|
52
|
+
};
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
function normalizePr(session) {
|
|
@@ -53,7 +61,7 @@ function normalizePr(session) {
|
|
|
53
61
|
};
|
|
54
62
|
}
|
|
55
63
|
|
|
56
|
-
function normalizeSessionForStatus(session, lockDetails, repoRoot, worktrees, readChanges
|
|
64
|
+
function normalizeSessionForStatus(session, lockDetails, repoRoot, worktrees, readChanges) {
|
|
57
65
|
const branch = session.branch || '';
|
|
58
66
|
const worktreePath = session.worktreePath || '';
|
|
59
67
|
const claimedFiles = uniqueSorted([
|
|
@@ -84,14 +92,17 @@ function normalizeSessionForStatus(session, lockDetails, repoRoot, worktrees, re
|
|
|
84
92
|
}
|
|
85
93
|
|
|
86
94
|
function buildAgentsStatusPayload(repoRoot) {
|
|
95
|
+
const sessions = listAgentSessions(repoRoot);
|
|
96
|
+
if (!sessions.length) return { schemaVersion: 1, repoRoot, sessions };
|
|
87
97
|
const lockDetails = readLockDetails(repoRoot);
|
|
88
98
|
// Hoist the invariant `git worktree list` out of the per-session loop: fetch it
|
|
89
99
|
// once here instead of once inside every session's changedFiles() (~6N -> ~6+N).
|
|
90
100
|
const worktrees = listWorktrees(repoRoot);
|
|
101
|
+
const readChanges = statusChangedFilesReader();
|
|
91
102
|
return {
|
|
92
103
|
schemaVersion: 1,
|
|
93
104
|
repoRoot,
|
|
94
|
-
sessions:
|
|
105
|
+
sessions: sessions.map((session) => normalizeSessionForStatus(session, lockDetails, repoRoot, worktrees, readChanges)),
|
|
95
106
|
};
|
|
96
107
|
}
|
|
97
108
|
|
|
@@ -151,8 +162,9 @@ function writeStatusCommand(repoRoot, options = {}, output = process.stdout, dep
|
|
|
151
162
|
output.write(`[${TOOL_NAME}] Agent sessions: ${sessions.length} (${repoRoot})\n`);
|
|
152
163
|
const lockDetails = readLockDetails(repoRoot);
|
|
153
164
|
const worktrees = (deps.listWorktrees || listWorktrees)(repoRoot);
|
|
165
|
+
const readChanges = deps.readChangedFiles || statusChangedFilesReader();
|
|
154
166
|
for (const session of sessions) {
|
|
155
|
-
const row = normalizeSessionForStatus(session, lockDetails, repoRoot, worktrees,
|
|
167
|
+
const row = normalizeSessionForStatus(session, lockDetails, repoRoot, worktrees, readChanges);
|
|
156
168
|
output.write(`${renderSession(row)}\n`);
|
|
157
169
|
}
|
|
158
170
|
}
|
package/src/cli/commands/pr.js
CHANGED
|
@@ -123,6 +123,8 @@ function renderChecksLine(checks) {
|
|
|
123
123
|
if (checks.pending) parts.push(`${checks.pending} pending`);
|
|
124
124
|
if (checks.failed) parts.push(`${checks.failed} failed`);
|
|
125
125
|
if (checks.cancelled) parts.push(`${checks.cancelled} cancelled`);
|
|
126
|
+
if (checks.waived) parts.push(`${checks.waived} did not start (GitHub billing)`);
|
|
127
|
+
if (checks.skipped) parts.push(`${checks.skipped} skipped`);
|
|
126
128
|
if (checks.other) parts.push(`${checks.other} other`);
|
|
127
129
|
return parts.length ? parts.join(', ') : `${checks.total} checks`;
|
|
128
130
|
}
|
|
@@ -295,6 +297,15 @@ async function cmdWatch(opts) {
|
|
|
295
297
|
logError(`CI checks failed. Investigate the PR before retrying.${buildChecksFailedDetail(result.pr)}`);
|
|
296
298
|
return;
|
|
297
299
|
}
|
|
300
|
+
if (result.status === 'billing-blocked') {
|
|
301
|
+
process.exitCode = 2;
|
|
302
|
+
logError(
|
|
303
|
+
`GitHub Actions did not start due to billing or a spending limit${buildTimeoutDetail(result.pr)}. ` +
|
|
304
|
+
'Restore Actions and rerun CI, or use the review-gated finish with a trusted base preflight. ' +
|
|
305
|
+
'GitHub merge requirements still apply.',
|
|
306
|
+
);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
298
309
|
if (result.status === 'timeout') {
|
|
299
310
|
process.exitCode = 3;
|
|
300
311
|
logWarn(`Timed out waiting for PR to merge.${buildTimeoutDetail(result.pr)}`);
|
package/src/pr.js
CHANGED
|
@@ -609,9 +609,8 @@ async function watchPullRequest(options) {
|
|
|
609
609
|
|
|
610
610
|
// eslint-disable-next-line no-constant-condition
|
|
611
611
|
while (true) {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
if (!open) {
|
|
612
|
+
const snapshot = getPullRequestStatus(repoRoot, branch);
|
|
613
|
+
if (!snapshot) {
|
|
615
614
|
const latest = findLatestPrForBranch(repoRoot, branch);
|
|
616
615
|
if (latest && latest.state === 'MERGED') {
|
|
617
616
|
onEvent({ phase: 'merged', pr: latest });
|
|
@@ -625,19 +624,21 @@ async function watchPullRequest(options) {
|
|
|
625
624
|
return { status: 'no-pr', pr: null };
|
|
626
625
|
}
|
|
627
626
|
|
|
628
|
-
const snapshot = getPullRequestStatus(repoRoot, branch);
|
|
629
627
|
onEvent({ phase: 'polling', pr: snapshot });
|
|
630
628
|
|
|
631
|
-
|
|
629
|
+
const { checks } = snapshot;
|
|
630
|
+
if (checks.failed > 0 || checks.cancelled > 0) {
|
|
632
631
|
return { status: 'checks-failed', pr: snapshot };
|
|
633
632
|
}
|
|
633
|
+
if (checks.waived > 0 && checks.pending === 0) {
|
|
634
|
+
return { status: 'billing-blocked', pr: snapshot };
|
|
635
|
+
}
|
|
634
636
|
if (
|
|
635
|
-
snapshot
|
|
636
|
-
&& !snapshot.isDraft
|
|
637
|
+
!snapshot.isDraft
|
|
637
638
|
&& snapshot.mergeable === 'MERGEABLE'
|
|
638
|
-
&& snapshot.
|
|
639
|
-
&&
|
|
640
|
-
&&
|
|
639
|
+
&& (snapshot.mergeStateStatus === 'CLEAN' || snapshot.mergeStateStatus === 'HAS_HOOKS')
|
|
640
|
+
&& checks.total > 0
|
|
641
|
+
&& checks.success + (checks.skipped || 0) === checks.total
|
|
641
642
|
) {
|
|
642
643
|
// CI is green and PR is non-draft + mergeable; the merge itself will be
|
|
643
644
|
// driven by auto-merge or a separate `gh pr merge` invocation.
|