@imdeadpool/guardex 7.1.1 → 8.2.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 +123 -322
- package/package.json +23 -5
- package/skills/gitguardex/SKILL.md +83 -3
- package/src/agents/finish.js +15 -0
- package/src/ci-init/index.js +0 -1
- package/src/cli/args.js +142 -3
- package/src/cli/commands/branch.js +294 -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 -6
- package/src/finish/heartbeat.js +169 -0
- package/src/finish/index.js +165 -18
- package/src/finish/progress.js +316 -0
- package/src/finish/review-gate.js +453 -32
- package/src/github-api.js +59 -0
- package/src/mcp/collect.js +155 -19
- package/src/mcp/server.js +35 -19
- 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/index.js +4 -16
- package/src/shared-git-state.js +566 -0
- package/templates/AGENTS.multiagent-safety.md +63 -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 +354 -23
- package/templates/scripts/agent-branch-start.sh +49 -22
- package/templates/scripts/agent-claude-stop-finish.sh +194 -0
- package/templates/scripts/agent-file-locks.py +198 -29
- 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
package/src/pr-checks.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// Normalize GitHub's PR check rollup across workflow reruns.
|
|
2
|
+
//
|
|
3
|
+
// `statusCheckRollup` can retain an older cancelled run beside its newer
|
|
4
|
+
// replacement. Counting both makes a successful rerun look red forever. Keep
|
|
5
|
+
// only the newest observation for the same provider/workflow/check identity.
|
|
6
|
+
|
|
7
|
+
const FAILING_CONCLUSIONS = new Set([
|
|
8
|
+
'FAILURE',
|
|
9
|
+
'ERROR',
|
|
10
|
+
'TIMED_OUT',
|
|
11
|
+
'CANCELLED',
|
|
12
|
+
'ACTION_REQUIRED',
|
|
13
|
+
'STARTUP_FAILURE',
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
function checkName(check) {
|
|
17
|
+
return String(check?.name || check?.context || '').trim();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function stableDetailsUrl(value) {
|
|
21
|
+
try {
|
|
22
|
+
const url = new URL(String(value || ''));
|
|
23
|
+
const volatileSegment = /^(?:\d+|[0-9a-f]{7,64}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i;
|
|
24
|
+
const volatileCollections = new Set([
|
|
25
|
+
'run', 'runs', 'job', 'jobs', 'build', 'builds',
|
|
26
|
+
'execution', 'executions', 'attempt', 'attempts',
|
|
27
|
+
]);
|
|
28
|
+
const segments = url.pathname.split('/');
|
|
29
|
+
for (let index = 1; index < segments.length; index += 1) {
|
|
30
|
+
if (volatileCollections.has(segments[index - 1].toLowerCase()) && volatileSegment.test(segments[index])) {
|
|
31
|
+
segments[index] = ':id';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return `${url.origin}${segments.join('/')}${url.search}`;
|
|
35
|
+
} catch (_error) {
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function checkIdentity(check, index) {
|
|
41
|
+
const name = String(check?.name || check?.context || '').trim();
|
|
42
|
+
if (!name) return `anonymous:${index}`;
|
|
43
|
+
|
|
44
|
+
const type = String(check?.__typename || (check?.context ? 'StatusContext' : 'CheckRun'));
|
|
45
|
+
const workflow = String(check?.workflowName || '').trim();
|
|
46
|
+
if (type === 'StatusContext') return `${type}\u0000${name}`;
|
|
47
|
+
if (workflow) return `${type}\u0000${workflow}\u0000${name}`;
|
|
48
|
+
|
|
49
|
+
const details = stableDetailsUrl(check?.detailsUrl);
|
|
50
|
+
return details ? `${type}\u0000${details}\u0000${name}` : `anonymous:${index}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function timestamp(value) {
|
|
54
|
+
const parsed = Date.parse(String(value || ''));
|
|
55
|
+
return Number.isFinite(parsed) ? parsed : Number.NEGATIVE_INFINITY;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function recency(check, index) {
|
|
59
|
+
return [
|
|
60
|
+
timestamp(check?.createdAt),
|
|
61
|
+
timestamp(check?.startedAt),
|
|
62
|
+
timestamp(check?.completedAt),
|
|
63
|
+
index,
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function isNewer(candidate, current) {
|
|
68
|
+
for (let index = 0; index < candidate.length; index += 1) {
|
|
69
|
+
if (candidate[index] !== current[index]) return candidate[index] > current[index];
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function latestStatusChecks(value) {
|
|
75
|
+
const input = Array.isArray(value) ? value : [];
|
|
76
|
+
const latest = new Map();
|
|
77
|
+
|
|
78
|
+
input.forEach((check, index) => {
|
|
79
|
+
const identity = checkIdentity(check, index);
|
|
80
|
+
const previous = latest.get(identity);
|
|
81
|
+
const candidate = { check, index, firstIndex: previous?.firstIndex ?? index, recency: recency(check, index) };
|
|
82
|
+
if (!previous || isNewer(candidate.recency, previous.recency)) latest.set(identity, candidate);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const selected = [...latest.values()].sort((left, right) => left.firstIndex - right.firstIndex);
|
|
86
|
+
const selectedIndexes = new Set(selected.map((entry) => entry.index));
|
|
87
|
+
return {
|
|
88
|
+
checks: selected.map((entry) => entry.check),
|
|
89
|
+
superseded: input.filter((_check, index) => !selectedIndexes.has(index)),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function summarizeStatusCheckRollup(value) {
|
|
94
|
+
const { checks, superseded } = latestStatusChecks(value);
|
|
95
|
+
const failedNames = [];
|
|
96
|
+
const summary = checks.reduce(
|
|
97
|
+
(acc, check) => {
|
|
98
|
+
const state = String(check?.conclusion || check?.state || check?.status || '').toUpperCase();
|
|
99
|
+
if (state === 'SUCCESS') acc.success += 1;
|
|
100
|
+
else if (state === 'CANCELLED') acc.cancelled += 1;
|
|
101
|
+
else if (FAILING_CONCLUSIONS.has(state)) acc.failed += 1;
|
|
102
|
+
else if (state === 'PENDING' || state === 'IN_PROGRESS' || state === 'QUEUED') acc.pending += 1;
|
|
103
|
+
else acc.other += 1;
|
|
104
|
+
|
|
105
|
+
if (FAILING_CONCLUSIONS.has(state)) {
|
|
106
|
+
const name = checkName(check);
|
|
107
|
+
if (name) failedNames.push(name);
|
|
108
|
+
}
|
|
109
|
+
return acc;
|
|
110
|
+
},
|
|
111
|
+
{ success: 0, failed: 0, pending: 0, cancelled: 0, other: 0, total: checks.length },
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
return { summary, failedNames, supersededCount: superseded.length };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
module.exports = {
|
|
118
|
+
FAILING_CONCLUSIONS,
|
|
119
|
+
latestStatusChecks,
|
|
120
|
+
summarizeStatusCheckRollup,
|
|
121
|
+
};
|