@codyswann/lisa 8.1.1 → 8.2.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.
- package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/upstream-evidence-manifest.json +146 -11
- package/package.json +4 -4
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/scripts/queue-contract-resolution.mjs +583 -0
- package/plugins/lisa/.codex-plugin/scripts/ready-queue-order.mjs +99 -25
- package/plugins/lisa/.codex-plugin/scripts/stale-blocker-comment.mjs +185 -0
- package/plugins/lisa/.codex-plugin/scripts/stale-blocker-confirm.mjs +130 -0
- package/plugins/lisa/.codex-plugin/scripts/stale-blocker-edges.mjs +466 -0
- package/plugins/lisa/.codex-plugin/scripts/stale-blocker-pending.mjs +257 -0
- package/plugins/lisa/.codex-plugin/scripts/stale-blocker-restore.mjs +180 -0
- package/plugins/lisa/.codex-plugin/scripts/stale-blocker-summary.mjs +239 -0
- package/plugins/lisa/.codex-plugin/scripts/stale-blocker-sweep.mjs +397 -0
- package/plugins/lisa/.codex-plugin/scripts/stale-blocker-verify.mjs +194 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-atlassian-access/SKILL.md +1 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-github-build-intake/SKILL.md +2 -7
- package/plugins/lisa/.codex-plugin/skills/lisa-jira-build-intake/SKILL.md +2 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-linear-access/SKILL.md +44 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-linear-build-intake/SKILL.md +2 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +127 -2
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
- package/plugins/lisa/scripts/ready-queue-order.mjs +99 -25
- package/plugins/lisa/scripts/stale-blocker-comment.mjs +185 -0
- package/plugins/lisa/scripts/stale-blocker-confirm.mjs +130 -0
- package/plugins/lisa/scripts/stale-blocker-edges.mjs +466 -0
- package/plugins/lisa/scripts/stale-blocker-pending.mjs +257 -0
- package/plugins/lisa/scripts/stale-blocker-restore.mjs +180 -0
- package/plugins/lisa/scripts/stale-blocker-summary.mjs +239 -0
- package/plugins/lisa/scripts/stale-blocker-sweep.mjs +397 -0
- package/plugins/lisa/scripts/stale-blocker-verify.mjs +194 -0
- package/plugins/lisa/skills/lisa-atlassian-access/SKILL.md +1 -0
- package/plugins/lisa/skills/lisa-github-build-intake/SKILL.md +2 -7
- package/plugins/lisa/skills/lisa-jira-build-intake/SKILL.md +2 -0
- package/plugins/lisa/skills/lisa-linear-access/SKILL.md +44 -0
- package/plugins/lisa/skills/lisa-linear-build-intake/SKILL.md +2 -0
- package/plugins/lisa/skills/lisa-session-manager/SKILL.md +127 -2
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
- package/plugins/lisa/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/scripts/ready-queue-order.mjs +99 -25
- package/plugins/lisa-agy/scripts/stale-blocker-comment.mjs +185 -0
- package/plugins/lisa-agy/scripts/stale-blocker-confirm.mjs +130 -0
- package/plugins/lisa-agy/scripts/stale-blocker-edges.mjs +466 -0
- package/plugins/lisa-agy/scripts/stale-blocker-pending.mjs +257 -0
- package/plugins/lisa-agy/scripts/stale-blocker-restore.mjs +180 -0
- package/plugins/lisa-agy/scripts/stale-blocker-summary.mjs +239 -0
- package/plugins/lisa-agy/scripts/stale-blocker-sweep.mjs +397 -0
- package/plugins/lisa-agy/scripts/stale-blocker-verify.mjs +194 -0
- package/plugins/lisa-agy/skills/lisa-atlassian-access/SKILL.md +1 -0
- package/plugins/lisa-agy/skills/lisa-github-build-intake/SKILL.md +2 -7
- package/plugins/lisa-agy/skills/lisa-jira-build-intake/SKILL.md +2 -0
- package/plugins/lisa-agy/skills/lisa-linear-access/SKILL.md +44 -0
- package/plugins/lisa-agy/skills/lisa-linear-build-intake/SKILL.md +2 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +127 -2
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/scripts/ready-queue-order.mjs +99 -25
- package/plugins/lisa-copilot/scripts/stale-blocker-comment.mjs +185 -0
- package/plugins/lisa-copilot/scripts/stale-blocker-confirm.mjs +130 -0
- package/plugins/lisa-copilot/scripts/stale-blocker-edges.mjs +466 -0
- package/plugins/lisa-copilot/scripts/stale-blocker-pending.mjs +257 -0
- package/plugins/lisa-copilot/scripts/stale-blocker-restore.mjs +180 -0
- package/plugins/lisa-copilot/scripts/stale-blocker-summary.mjs +239 -0
- package/plugins/lisa-copilot/scripts/stale-blocker-sweep.mjs +397 -0
- package/plugins/lisa-copilot/scripts/stale-blocker-verify.mjs +194 -0
- package/plugins/lisa-copilot/skills/lisa-atlassian-access/SKILL.md +1 -0
- package/plugins/lisa-copilot/skills/lisa-github-build-intake/SKILL.md +2 -7
- package/plugins/lisa-copilot/skills/lisa-jira-build-intake/SKILL.md +2 -0
- package/plugins/lisa-copilot/skills/lisa-linear-access/SKILL.md +44 -0
- package/plugins/lisa-copilot/skills/lisa-linear-build-intake/SKILL.md +2 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +127 -2
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/scripts/ready-queue-order.mjs +99 -25
- package/plugins/lisa-cursor/scripts/stale-blocker-comment.mjs +185 -0
- package/plugins/lisa-cursor/scripts/stale-blocker-confirm.mjs +130 -0
- package/plugins/lisa-cursor/scripts/stale-blocker-edges.mjs +466 -0
- package/plugins/lisa-cursor/scripts/stale-blocker-pending.mjs +257 -0
- package/plugins/lisa-cursor/scripts/stale-blocker-restore.mjs +180 -0
- package/plugins/lisa-cursor/scripts/stale-blocker-summary.mjs +239 -0
- package/plugins/lisa-cursor/scripts/stale-blocker-sweep.mjs +397 -0
- package/plugins/lisa-cursor/scripts/stale-blocker-verify.mjs +194 -0
- package/plugins/lisa-cursor/skills/lisa-atlassian-access/SKILL.md +1 -0
- package/plugins/lisa-cursor/skills/lisa-github-build-intake/SKILL.md +2 -7
- package/plugins/lisa-cursor/skills/lisa-jira-build-intake/SKILL.md +2 -0
- package/plugins/lisa-cursor/skills/lisa-linear-access/SKILL.md +44 -0
- package/plugins/lisa-cursor/skills/lisa-linear-build-intake/SKILL.md +2 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +127 -2
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/scripts/ready-queue-order.mjs +99 -25
- package/plugins/lisa-devin/scripts/stale-blocker-comment.mjs +185 -0
- package/plugins/lisa-devin/scripts/stale-blocker-confirm.mjs +130 -0
- package/plugins/lisa-devin/scripts/stale-blocker-edges.mjs +466 -0
- package/plugins/lisa-devin/scripts/stale-blocker-pending.mjs +257 -0
- package/plugins/lisa-devin/scripts/stale-blocker-restore.mjs +180 -0
- package/plugins/lisa-devin/scripts/stale-blocker-summary.mjs +239 -0
- package/plugins/lisa-devin/scripts/stale-blocker-sweep.mjs +397 -0
- package/plugins/lisa-devin/scripts/stale-blocker-verify.mjs +194 -0
- package/plugins/lisa-devin/skills/lisa-atlassian-access/SKILL.md +1 -0
- package/plugins/lisa-devin/skills/lisa-github-build-intake/SKILL.md +2 -7
- package/plugins/lisa-devin/skills/lisa-jira-build-intake/SKILL.md +2 -0
- package/plugins/lisa-devin/skills/lisa-linear-access/SKILL.md +44 -0
- package/plugins/lisa-devin/skills/lisa-linear-build-intake/SKILL.md +2 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +127 -2
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/src/base/scripts/ready-queue-order.mjs +99 -25
- package/plugins/src/base/scripts/stale-blocker-comment.mjs +185 -0
- package/plugins/src/base/scripts/stale-blocker-confirm.mjs +130 -0
- package/plugins/src/base/scripts/stale-blocker-edges.mjs +466 -0
- package/plugins/src/base/scripts/stale-blocker-pending.mjs +257 -0
- package/plugins/src/base/scripts/stale-blocker-restore.mjs +180 -0
- package/plugins/src/base/scripts/stale-blocker-summary.mjs +239 -0
- package/plugins/src/base/scripts/stale-blocker-sweep.mjs +397 -0
- package/plugins/src/base/scripts/stale-blocker-verify.mjs +194 -0
- package/plugins/src/base/skills/lisa-atlassian-access/SKILL.md +1 -0
- package/plugins/src/base/skills/lisa-github-build-intake/SKILL.md +2 -7
- package/plugins/src/base/skills/lisa-jira-build-intake/SKILL.md +2 -0
- package/plugins/src/base/skills/lisa-linear-access/SKILL.md +44 -0
- package/plugins/src/base/skills/lisa-linear-build-intake/SKILL.md +2 -0
- package/plugins/src/base/skills/lisa-session-manager/SKILL.md +127 -2
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
- package/plugins/src/base/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* After the writes of a stale-link clean-up (CodySwannGT/lisa#5065):
|
|
3
|
+
*
|
|
4
|
+
* - `stale-links-verify` reads the item back and says which planned
|
|
5
|
+
* removals are confirmed. Its comment covers ONLY those, and it records
|
|
6
|
+
* that comment as pending, so a comment that then fails to post is retried
|
|
7
|
+
* on its own instead of being lost with its already-removed link.
|
|
8
|
+
* - `stale-links-pending` lists the comments still owed; `stale-links-posted`
|
|
9
|
+
* settles one after it posts (or, with `--failed`, counts a failed try).
|
|
10
|
+
* - `stale-links-report` builds the cycle's summary from the verified
|
|
11
|
+
* results, never from the plan.
|
|
12
|
+
*
|
|
13
|
+
* `stale-links-verify` also records each item whose planned removals did not
|
|
14
|
+
* happen, so the next plan puts it after every other candidate. It settles
|
|
15
|
+
* the in-flight entry `stale-links-confirm` wrote before the deletes, and
|
|
16
|
+
* only on success: a failed read-back leaves it for `stale-links-pending` to
|
|
17
|
+
* list as unverified, so the next cycle verifies it again. Links it put back
|
|
18
|
+
* (their blocker reopened) are recorded as owed restores until
|
|
19
|
+
* `stale-links-restored` reads them back present; the queue holds those
|
|
20
|
+
* items from dispatch meanwhile. Every record lives in the manager's state
|
|
21
|
+
* directory (`stale-links-state.mjs`).
|
|
22
|
+
* @module session-manager/cli-stale-links-results
|
|
23
|
+
*/
|
|
24
|
+
import {
|
|
25
|
+
addPending,
|
|
26
|
+
failedInFlight,
|
|
27
|
+
failedPending,
|
|
28
|
+
recordRemovalResult,
|
|
29
|
+
recordRestores,
|
|
30
|
+
settleInFlight,
|
|
31
|
+
settlePending,
|
|
32
|
+
settleRestores,
|
|
33
|
+
} from "../../../scripts/stale-blocker-pending.mjs";
|
|
34
|
+
import { restoreActions } from "../../../scripts/stale-blocker-restore.mjs";
|
|
35
|
+
import { summarizeVerifiedSweep } from "../../../scripts/stale-blocker-summary.mjs";
|
|
36
|
+
import { normalizeStaleLinkItem } from "../../../scripts/stale-blocker-sweep.mjs";
|
|
37
|
+
import { verifyStaleLinkRemoval } from "../../../scripts/stale-blocker-verify.mjs";
|
|
38
|
+
import { CliError, asSetupError, loadProject } from "./cli-runtime.mjs";
|
|
39
|
+
import { freshItem, judgingContext, trackerOf } from "./cli-stale-links.mjs";
|
|
40
|
+
import { readJsonFile } from "./json-input.mjs";
|
|
41
|
+
import { blockerReader } from "./stale-links-github.mjs";
|
|
42
|
+
import {
|
|
43
|
+
readFailures,
|
|
44
|
+
readInFlight,
|
|
45
|
+
readPending,
|
|
46
|
+
readRestores,
|
|
47
|
+
withStateLock,
|
|
48
|
+
writeFailures,
|
|
49
|
+
writeInFlight,
|
|
50
|
+
writePending,
|
|
51
|
+
writeRestores,
|
|
52
|
+
} from "./stale-links-state.mjs";
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Each planned blocker as read NOW, after the delete. GitHub reads them
|
|
56
|
+
* itself; Jira and Linear take `--blockers <file>`, a `{ref: rawIssue}` map
|
|
57
|
+
* (a ref with no entry, or null, reads as unreadable and its link is put
|
|
58
|
+
* back).
|
|
59
|
+
* @param {object} ctx - CLI context
|
|
60
|
+
* @param {string} tracker
|
|
61
|
+
* @param {{ removed?: string[] }} plan
|
|
62
|
+
* @returns {Record<string, object | null>}
|
|
63
|
+
*/
|
|
64
|
+
function removedBlockersNow(ctx, tracker, plan) {
|
|
65
|
+
if (ctx.values.blockers) {
|
|
66
|
+
const map = readJsonFile(ctx.values.blockers);
|
|
67
|
+
if (!map || typeof map !== "object" || Array.isArray(map)) {
|
|
68
|
+
throw new CliError(
|
|
69
|
+
`${ctx.values.blockers}: expected {"<ref>": {...}}.`,
|
|
70
|
+
2
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
return map;
|
|
74
|
+
}
|
|
75
|
+
if (tracker !== "github") {
|
|
76
|
+
throw new CliError(
|
|
77
|
+
`stale-links-verify --tracker ${tracker} needs --blockers <file> with each removed blocker as read now.`,
|
|
78
|
+
2
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
const read = blockerReader(ctx);
|
|
82
|
+
return Object.fromEntries((plan.removed ?? []).map(ref => [ref, read(ref)]));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* `stale-links-verify --tracker <t> --plan <file> [--input <file>]`.
|
|
87
|
+
* @param {object} ctx - CLI context
|
|
88
|
+
* @returns {{ json: object }} The verified result, plus `pending`
|
|
89
|
+
*/
|
|
90
|
+
export async function staleLinksVerify(ctx) {
|
|
91
|
+
const project = loadProject(ctx.root);
|
|
92
|
+
const tracker = trackerOf(ctx, project);
|
|
93
|
+
if (!ctx.values.plan) {
|
|
94
|
+
throw new CliError("stale-links-verify needs --plan <file>.", 2);
|
|
95
|
+
}
|
|
96
|
+
const plan = readJsonFile(ctx.values.plan);
|
|
97
|
+
const result = await verifiedOrCounted(ctx, plan, () => {
|
|
98
|
+
const after = freshItem(ctx, tracker, plan);
|
|
99
|
+
const blockersNow = removedBlockersNow(ctx, tracker, plan);
|
|
100
|
+
const context = judgingContext(project, tracker);
|
|
101
|
+
return asSetupError(() =>
|
|
102
|
+
verifyStaleLinkRemoval({ tracker, plan, after, blockersNow, ...context })
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
const now = new Date().toISOString();
|
|
106
|
+
await withStateLock(ctx.root, () => {
|
|
107
|
+
writeFailures(
|
|
108
|
+
ctx.root,
|
|
109
|
+
recordRemovalResult(readFailures(ctx.root), result, now)
|
|
110
|
+
);
|
|
111
|
+
writeRestores(
|
|
112
|
+
ctx.root,
|
|
113
|
+
recordRestores(readRestores(ctx.root), result, plan.links ?? [], now)
|
|
114
|
+
);
|
|
115
|
+
if (result.comment !== null) {
|
|
116
|
+
writePending(ctx.root, addPending(readPending(ctx.root), result, now));
|
|
117
|
+
}
|
|
118
|
+
// Last, and only once every record above is written: until then the
|
|
119
|
+
// in-flight plan is the removed links' only recovery record.
|
|
120
|
+
writeInFlight(ctx.root, settleInFlight(readInFlight(ctx.root), plan.ref));
|
|
121
|
+
});
|
|
122
|
+
return { json: { ...result, pending: result.comment !== null } };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Run the read-back and verdict; when either throws (after the deletes may
|
|
127
|
+
* have run), count the failed try on the item's in-flight entry and
|
|
128
|
+
* rethrow, so the entry stays listed as unverified for the next cycle.
|
|
129
|
+
* @template T
|
|
130
|
+
* @param {object} ctx - CLI context
|
|
131
|
+
* @param {{ ref: string }} plan - The confirmed plan entry
|
|
132
|
+
* @param {() => T} verify
|
|
133
|
+
* @returns {Promise<T>}
|
|
134
|
+
*/
|
|
135
|
+
async function verifiedOrCounted(ctx, plan, verify) {
|
|
136
|
+
try {
|
|
137
|
+
return verify();
|
|
138
|
+
} catch (error) {
|
|
139
|
+
await withStateLock(ctx.root, () =>
|
|
140
|
+
writeInFlight(ctx.root, failedInFlight(readInFlight(ctx.root), plan.ref))
|
|
141
|
+
);
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* `stale-links-pending`: what earlier writes still owe — comments not yet
|
|
148
|
+
* posted, confirmed plans whose read-back has not succeeded (`unverified`,
|
|
149
|
+
* each with the plan entry to verify again), and links owed back
|
|
150
|
+
* (`restores`, by item ref).
|
|
151
|
+
* @param {object} ctx - CLI context
|
|
152
|
+
* @returns {{ json: object }} `{pending,unverified,restores}`
|
|
153
|
+
*/
|
|
154
|
+
export function staleLinksPending(ctx) {
|
|
155
|
+
return {
|
|
156
|
+
json: {
|
|
157
|
+
pending: readPending(ctx.root),
|
|
158
|
+
unverified: Object.values(readInFlight(ctx.root)),
|
|
159
|
+
restores: readRestores(ctx.root),
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* `stale-links-restored --ref <ref> [--tracker <t>] [--input <file>]`: read
|
|
166
|
+
* the item back after its restores and settle each owed link now present.
|
|
167
|
+
* GitHub reads the item itself; Jira and Linear take it in `--input`. The
|
|
168
|
+
* links still missing come back with fresh `restore` actions built from
|
|
169
|
+
* this read, to perform before the item can dispatch.
|
|
170
|
+
* @param {object} ctx - CLI context
|
|
171
|
+
* @returns {Promise<{ json: object }>} `{ref,owed,restore}`
|
|
172
|
+
*/
|
|
173
|
+
export async function staleLinksRestored(ctx) {
|
|
174
|
+
const ref = ctx.values.ref;
|
|
175
|
+
if (!ref) {
|
|
176
|
+
throw new CliError("stale-links-restored needs --ref <ref>.", 2);
|
|
177
|
+
}
|
|
178
|
+
const tracker = trackerOf(ctx, loadProject(ctx.root));
|
|
179
|
+
const item = normalizeStaleLinkItem(
|
|
180
|
+
tracker,
|
|
181
|
+
freshItem(ctx, tracker, { ref })
|
|
182
|
+
);
|
|
183
|
+
if (item.ref !== ref || !item.relationsRead) {
|
|
184
|
+
// probe-direction: fail-closed — a read of another item, or one without
|
|
185
|
+
// its relation list, cannot show a link is back, so nothing is settled.
|
|
186
|
+
throw new CliError(
|
|
187
|
+
`stale-links-restored: the read of ${ref} must be that item with its blocker links.`,
|
|
188
|
+
1
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
const present = new Set(item.edges.map(edge => edge.blockerRef));
|
|
192
|
+
const left = await withStateLock(ctx.root, () => {
|
|
193
|
+
const updated = settleRestores(readRestores(ctx.root), ref, present);
|
|
194
|
+
writeRestores(ctx.root, updated);
|
|
195
|
+
return updated[ref]?.links ?? [];
|
|
196
|
+
});
|
|
197
|
+
return {
|
|
198
|
+
json: { ref, owed: left, restore: restoreActions(tracker, item, left) },
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* `stale-links-posted --ref <ref> [--failed]`.
|
|
204
|
+
* @param {object} ctx - CLI context
|
|
205
|
+
* @returns {{ json: object }} `{ref,pending}` after the update
|
|
206
|
+
*/
|
|
207
|
+
export async function staleLinksPosted(ctx) {
|
|
208
|
+
const ref = ctx.values.ref;
|
|
209
|
+
const removed = String(ctx.values.removed ?? "")
|
|
210
|
+
.split(",")
|
|
211
|
+
.map(one => one.trim())
|
|
212
|
+
.filter(Boolean);
|
|
213
|
+
if (!ref || removed.length === 0) {
|
|
214
|
+
throw new CliError(
|
|
215
|
+
"stale-links-posted needs --ref <ref> --removed <blocker,...> (the entry's `removed`).",
|
|
216
|
+
2
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
const next = await withStateLock(ctx.root, () => {
|
|
220
|
+
const current = readPending(ctx.root);
|
|
221
|
+
const updated = ctx.values.failed
|
|
222
|
+
? failedPending(current, ref, removed)
|
|
223
|
+
: settlePending(current, ref, removed);
|
|
224
|
+
writePending(ctx.root, updated);
|
|
225
|
+
return updated;
|
|
226
|
+
});
|
|
227
|
+
return { json: { ref, removed, pending: next } };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* `stale-links-report --input <file>`: `{report, results, planned?}`, where
|
|
232
|
+
* `report` is the plan's and `results` are the verify outputs.
|
|
233
|
+
* @param {object} ctx - CLI context
|
|
234
|
+
* @returns {{ json: object }} `{summary}`
|
|
235
|
+
*/
|
|
236
|
+
export function staleLinksReport(ctx) {
|
|
237
|
+
if (!ctx.values.input) {
|
|
238
|
+
throw new CliError("stale-links-report needs --input <file>.", 2);
|
|
239
|
+
}
|
|
240
|
+
const input = readJsonFile(ctx.values.input);
|
|
241
|
+
if (!input?.report || !Array.isArray(input.results)) {
|
|
242
|
+
throw new CliError(
|
|
243
|
+
`${ctx.values.input}: expected {"report":{...},"results":[...]}.`,
|
|
244
|
+
2
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
json: {
|
|
249
|
+
summary: summarizeVerifiedSweep(input.report, input.results, {
|
|
250
|
+
planned: input.planned,
|
|
251
|
+
}),
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `stale-links-plan`: the session manager's per-cycle sweep for "blocked by"
|
|
3
|
+
* links whose blocker is already finished (CodySwannGT/lisa#5065). The plan
|
|
4
|
+
* writes nothing; the manager performs each action through the tracker's
|
|
5
|
+
* access layer, reads it back, then posts the plan's comment.
|
|
6
|
+
*
|
|
7
|
+
* The judging lives in the shared `stale-blocker-sweep.mjs`, so any agent's
|
|
8
|
+
* intake can run the same rule without this Claude Code-only manager.
|
|
9
|
+
* @module session-manager/cli-stale-links
|
|
10
|
+
*/
|
|
11
|
+
import { resolveRole } from "../../../scripts/resolve-lifecycle-role.mjs";
|
|
12
|
+
import { confirmStaleLinkPlan } from "../../../scripts/stale-blocker-confirm.mjs";
|
|
13
|
+
import {
|
|
14
|
+
landedDoneRoles,
|
|
15
|
+
terminalDoneRoles,
|
|
16
|
+
} from "../../../scripts/stale-blocker-edges.mjs";
|
|
17
|
+
import {
|
|
18
|
+
planStaleLinkSweep,
|
|
19
|
+
summarizeStaleLinkSweep,
|
|
20
|
+
} from "../../../scripts/stale-blocker-sweep.mjs";
|
|
21
|
+
import {
|
|
22
|
+
CliError,
|
|
23
|
+
asSetupError,
|
|
24
|
+
intFlag,
|
|
25
|
+
loadProject,
|
|
26
|
+
} from "./cli-runtime.mjs";
|
|
27
|
+
import { readJsonFile } from "./json-input.mjs";
|
|
28
|
+
import { recordInFlight } from "../../../scripts/stale-blocker-pending.mjs";
|
|
29
|
+
import {
|
|
30
|
+
readFailures,
|
|
31
|
+
readInFlight,
|
|
32
|
+
withStateLock,
|
|
33
|
+
writeInFlight,
|
|
34
|
+
} from "./stale-links-state.mjs";
|
|
35
|
+
import {
|
|
36
|
+
collectGithubStaleLinkInput,
|
|
37
|
+
readGithubStaleLinkItem,
|
|
38
|
+
} from "./stale-links-github.mjs";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param {unknown} value
|
|
42
|
+
* @returns {string}
|
|
43
|
+
*/
|
|
44
|
+
const text = value => (typeof value === "string" ? value : "");
|
|
45
|
+
|
|
46
|
+
const TRACKERS = new Set(["github", "jira", "linear"]);
|
|
47
|
+
const OWNER_REPO = /^[\w.-]+\/[\w.-]+$/;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The configured name of one lifecycle role, or "" when unset.
|
|
51
|
+
* @param {ReturnType<typeof loadProject>} project
|
|
52
|
+
* @param {string} tracker
|
|
53
|
+
* @param {string} role
|
|
54
|
+
* @returns {string}
|
|
55
|
+
*/
|
|
56
|
+
function roleValue(project, tracker, role) {
|
|
57
|
+
return resolveRole({
|
|
58
|
+
role,
|
|
59
|
+
vendor: tracker,
|
|
60
|
+
intent: "read",
|
|
61
|
+
local: project.local,
|
|
62
|
+
global: project.global,
|
|
63
|
+
}).value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The GitHub repo to sweep: `--github-repo`, else github.org/github.repo.
|
|
68
|
+
* @param {object} ctx - CLI context
|
|
69
|
+
* @param {ReturnType<typeof loadProject>} project
|
|
70
|
+
* @returns {string}
|
|
71
|
+
*/
|
|
72
|
+
function githubRepo(ctx, project) {
|
|
73
|
+
const merged = { ...project.global?.github, ...project.local?.github };
|
|
74
|
+
const repo =
|
|
75
|
+
ctx.values["github-repo"] ??
|
|
76
|
+
(merged.org && merged.repo ? `${merged.org}/${merged.repo}` : "");
|
|
77
|
+
if (!OWNER_REPO.test(repo)) {
|
|
78
|
+
throw new CliError(
|
|
79
|
+
"No GitHub repo: set github.org and github.repo, or pass --github-repo <owner/repo>.",
|
|
80
|
+
2
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return repo;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The raw items to judge: read from GitHub, or from the vendor skill's
|
|
88
|
+
* envelope for Jira and Linear (paged to completion, like `queue`).
|
|
89
|
+
* @param {object} ctx - CLI context
|
|
90
|
+
* @param {string} tracker
|
|
91
|
+
* @param {ReturnType<typeof loadProject>} project
|
|
92
|
+
* @returns {object[]}
|
|
93
|
+
*/
|
|
94
|
+
function rawItems(ctx, tracker, project) {
|
|
95
|
+
if (!ctx.values.input) {
|
|
96
|
+
if (tracker === "github") {
|
|
97
|
+
return collectGithubStaleLinkInput(ctx, githubRepo(ctx, project)).items;
|
|
98
|
+
}
|
|
99
|
+
throw new CliError(
|
|
100
|
+
`stale-links-plan --tracker ${tracker} needs --input <file>.`,
|
|
101
|
+
2
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
const envelope = readJsonFile(ctx.values.input);
|
|
105
|
+
if (envelope?.complete !== true || !Array.isArray(envelope.items)) {
|
|
106
|
+
throw new CliError(
|
|
107
|
+
`${ctx.values.input}: expected {"complete":true,"items":[...]} read to the last page.`,
|
|
108
|
+
2
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
return envelope.items;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The tracker to sweep: `--tracker`, else the project's configured tracker.
|
|
116
|
+
* @param {object} ctx - CLI context
|
|
117
|
+
* @param {ReturnType<typeof loadProject>} project
|
|
118
|
+
* @returns {"github" | "jira" | "linear"}
|
|
119
|
+
*/
|
|
120
|
+
export function trackerOf(ctx, project) {
|
|
121
|
+
const tracker =
|
|
122
|
+
ctx.values.tracker ?? project.local?.tracker ?? project.global?.tracker;
|
|
123
|
+
if (!TRACKERS.has(tracker ?? "")) {
|
|
124
|
+
throw new CliError("--tracker must be github, jira or linear.", 2);
|
|
125
|
+
}
|
|
126
|
+
return tracker;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The configured roles and done names every sweep judges against.
|
|
131
|
+
* @param {ReturnType<typeof loadProject>} project
|
|
132
|
+
* @param {string} tracker
|
|
133
|
+
* @returns {{ doneRoles: string[], landedRoles: string[], roles: { ready: string, blocked: string }, posterName: string }}
|
|
134
|
+
*/
|
|
135
|
+
export function judgingContext(project, tracker) {
|
|
136
|
+
const config = { tracker, global: project.global, local: project.local };
|
|
137
|
+
return {
|
|
138
|
+
doneRoles: terminalDoneRoles(config),
|
|
139
|
+
// Intermediate done rungs hold nothing, but their links are never removed.
|
|
140
|
+
landedRoles: landedDoneRoles(config),
|
|
141
|
+
roles: {
|
|
142
|
+
ready: roleValue(project, tracker, "ready"),
|
|
143
|
+
blocked: roleValue(project, tracker, "blocked"),
|
|
144
|
+
},
|
|
145
|
+
// The comment names the configured manager; the prefix stays the marker.
|
|
146
|
+
posterName: text(project.config?.name),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* `stale-links-plan --tracker <t> [--input <file>] [--max <n>]`.
|
|
152
|
+
* @param {object} ctx - CLI context
|
|
153
|
+
* @returns {{ json: object }} `{tracker,doneRoles,plans,deferred,report,summary}`
|
|
154
|
+
*/
|
|
155
|
+
export function staleLinksPlan(ctx) {
|
|
156
|
+
const project = loadProject(ctx.root);
|
|
157
|
+
const tracker = trackerOf(ctx, project);
|
|
158
|
+
const max = intFlag(ctx.values.max, "--max");
|
|
159
|
+
const items = rawItems(ctx, tracker, project);
|
|
160
|
+
const failures = readFailures(ctx.root);
|
|
161
|
+
return {
|
|
162
|
+
json: asSetupError(() => {
|
|
163
|
+
const context = judgingContext(project, tracker);
|
|
164
|
+
const plan = planStaleLinkSweep({
|
|
165
|
+
tracker,
|
|
166
|
+
items,
|
|
167
|
+
...context,
|
|
168
|
+
failures,
|
|
169
|
+
...(max === undefined ? {} : { max }),
|
|
170
|
+
});
|
|
171
|
+
return {
|
|
172
|
+
tracker,
|
|
173
|
+
doneRoles: context.doneRoles,
|
|
174
|
+
...plan,
|
|
175
|
+
summary: summarizeStaleLinkSweep(plan.report),
|
|
176
|
+
};
|
|
177
|
+
}),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* The item as it stands now: `--input`, or a fresh GitHub read. Used before
|
|
183
|
+
* the writes (`stale-links-confirm`) and after them (`stale-links-verify`).
|
|
184
|
+
* @param {object} ctx - CLI context
|
|
185
|
+
* @param {string} tracker
|
|
186
|
+
* @param {{ ref?: string }} plan - The plan entry being confirmed
|
|
187
|
+
* @returns {Record<string, any>}
|
|
188
|
+
*/
|
|
189
|
+
export function freshItem(ctx, tracker, plan) {
|
|
190
|
+
if (ctx.values.input) return readJsonFile(ctx.values.input);
|
|
191
|
+
if (tracker !== "github") {
|
|
192
|
+
throw new CliError(
|
|
193
|
+
`--tracker ${tracker} needs --input <file> with the item as read now.`,
|
|
194
|
+
2
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
const [repo, number] = String(plan?.ref ?? "").split("#");
|
|
198
|
+
return readGithubStaleLinkItem(ctx, repo, Number(number));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* `stale-links-confirm --tracker <t> --plan <file> [--input <file>]`: rebuild
|
|
203
|
+
* one plan entry from a fresh read of the item and its blockers, right before
|
|
204
|
+
* the writes. GitHub re-reads itself; Jira and Linear take the fresh raw item
|
|
205
|
+
* (with each blocker's current status, and the comments) in `--input`.
|
|
206
|
+
* @param {object} ctx - CLI context
|
|
207
|
+
* @returns {Promise<{ json: object }>} `{tracker,plan,skipped}`; plan is null when
|
|
208
|
+
* nothing is still safe to remove
|
|
209
|
+
*/
|
|
210
|
+
export async function staleLinksConfirm(ctx) {
|
|
211
|
+
const project = loadProject(ctx.root);
|
|
212
|
+
const tracker = trackerOf(ctx, project);
|
|
213
|
+
if (!ctx.values.plan) {
|
|
214
|
+
throw new CliError("stale-links-confirm needs --plan <file>.", 2);
|
|
215
|
+
}
|
|
216
|
+
const plan = readJsonFile(ctx.values.plan);
|
|
217
|
+
const fresh = freshItem(ctx, tracker, plan);
|
|
218
|
+
const confirmed = asSetupError(() => ({
|
|
219
|
+
tracker,
|
|
220
|
+
...confirmStaleLinkPlan({
|
|
221
|
+
tracker,
|
|
222
|
+
plan,
|
|
223
|
+
fresh,
|
|
224
|
+
...judgingContext(project, tracker),
|
|
225
|
+
}),
|
|
226
|
+
}));
|
|
227
|
+
// Recorded BEFORE any delete runs: until a verify reads the item back,
|
|
228
|
+
// the entry stays in flight, so a read-back that fails after the deletes
|
|
229
|
+
// is retried rather than leaving removed links with no comment and no
|
|
230
|
+
// restore check.
|
|
231
|
+
if (confirmed.plan !== null) {
|
|
232
|
+
const now = new Date().toISOString();
|
|
233
|
+
await withStateLock(ctx.root, () =>
|
|
234
|
+
writeInFlight(
|
|
235
|
+
ctx.root,
|
|
236
|
+
asSetupError(() =>
|
|
237
|
+
recordInFlight(readInFlight(ctx.root), confirmed.plan, now)
|
|
238
|
+
)
|
|
239
|
+
)
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
return { json: confirmed };
|
|
243
|
+
}
|
|
@@ -319,6 +319,66 @@ Per cycle
|
|
|
319
319
|
wrongly-escalated, hold and release evidence, a draft
|
|
320
320
|
Planning (filing) rule); comment is the marker to post afterwards.
|
|
321
321
|
--max caps captures per cycle (default 3); the rest are deferred.
|
|
322
|
+
stale-links-plan [--tracker <t>] [--input <file>] [--max <n>]
|
|
323
|
+
[--github-repo <owner/repo>]
|
|
324
|
+
Plans this cycle's clean-up of "blocked by" links whose blocker is
|
|
325
|
+
finished (closed in the tracker, or in the configured terminal done
|
|
326
|
+
role) or cancelled; writes nothing. GitHub reads open issues, native
|
|
327
|
+
blocked_by dependencies and "Blocked by" body lines itself; Jira and
|
|
328
|
+
Linear take --input {complete:true,items:[raw issues with comments]}.
|
|
329
|
+
Open, cross-project and unreadable blockers are kept (unreadable ones
|
|
330
|
+
reported); items in the blocked role are left to the Blocked sweep.
|
|
331
|
+
stdout {tracker,doneRoles,plans:[{ref,actions,body,removed,comment,
|
|
332
|
+
commentAdf,remainingBlockers,becomesClaimable,render}],deferred,report,
|
|
333
|
+
summary}; summary describes the plan ("planned", "would become
|
|
334
|
+
ready"), never a result. A
|
|
335
|
+
comment carries one [lisa-stale-blocker-link] blocker=<ref> marker per
|
|
336
|
+
removed link, so a re-run never comments twice. --max caps items per
|
|
337
|
+
cycle (default 10); the rest are deferred.
|
|
338
|
+
stale-links-confirm [--tracker <t>] --plan <file> [--input <file>]
|
|
339
|
+
Rebuilds one stale-links-plan entry from a fresh read, right before the
|
|
340
|
+
writes; writes nothing. GitHub re-reads the issue, each blocker and the
|
|
341
|
+
comments itself; Jira and Linear take the fresh raw item in --input.
|
|
342
|
+
Only links the plan removes that are still stale are kept; the body is
|
|
343
|
+
rebuilt from the fresh body, so a concurrent edit survives. stdout
|
|
344
|
+
{tracker,plan,skipped:[{blocker,reason}]}; reason is
|
|
345
|
+
blocker-not-resolved, link-already-gone or blocked-role; plan is null
|
|
346
|
+
when nothing is still safe to remove. A non-null plan is recorded in
|
|
347
|
+
.lisa/session-manager/stale-links-inflight.json BEFORE the writes, and
|
|
348
|
+
stays there until stale-links-verify reads the item back (queue holds
|
|
349
|
+
the item meanwhile: removal-unverified). An item that still has an
|
|
350
|
+
unverified entry is refused, never overwritten.
|
|
351
|
+
stale-links-verify [--tracker <t>] --plan <file> [--input <file>]
|
|
352
|
+
[--blockers <file>]
|
|
353
|
+
Reads one item back after its stale-link writes, and each removed
|
|
354
|
+
blocker again (GitHub itself; Jira/Linear from --blockers, a
|
|
355
|
+
{ref: rawIssue} map). stdout {ref,confirmed,stillPresent,restored,
|
|
356
|
+
restore,comment,commentAdf,becameReady,pending}: a removed link whose
|
|
357
|
+
blocker reopened is in restored, with restore the actions that put it
|
|
358
|
+
back; comment covers ONLY the confirmed removals (null when none) and
|
|
359
|
+
is recorded as pending in .lisa/session-manager/stale-links-pending.json
|
|
360
|
+
until posted (never when its marker is already live). Links in
|
|
361
|
+
restored are owed in stale-links-restores.json until
|
|
362
|
+
stale-links-restored reads them back; queue holds those items with
|
|
363
|
+
reason restore-owed. The in-flight entry is settled last, after every
|
|
364
|
+
other record; a failed read-back or write leaves it.
|
|
365
|
+
stale-links-pending
|
|
366
|
+
Lists what earlier stale-link writes still owe. stdout {pending:[...],
|
|
367
|
+
unverified:[{plan,since,attempts}],restores:{ref:{links,...}}}:
|
|
368
|
+
comments not yet posted, confirmed plans to verify again, and links
|
|
369
|
+
owed back.
|
|
370
|
+
stale-links-restored --ref <ref> [--tracker <t>] [--input <file>]
|
|
371
|
+
Reads the item back after its restores (GitHub itself; Jira/Linear from
|
|
372
|
+
--input) and settles each owed link now present. stdout {ref,owed,
|
|
373
|
+
restore}: restore is the fresh actions for the links still missing.
|
|
374
|
+
stale-links-posted --ref <ref> --removed <blocker,...> [--failed]
|
|
375
|
+
Settles the ONE pending comment with that ref and removed set after it
|
|
376
|
+
posts (an item can owe more than one); --failed instead counts one more
|
|
377
|
+
failed try for that comment.
|
|
378
|
+
stale-links-report --input <file>
|
|
379
|
+
{report,results[,planned]} -> {summary}: the cycle's stale-link line,
|
|
380
|
+
built from verified results; planned-but-not-done and deferred items
|
|
381
|
+
are counted separately, never as cleared.
|
|
322
382
|
orphan-plan [--input <file>] [--max <n>] [--stale-hours <n>]
|
|
323
383
|
STDIN (without --input): JSON
|
|
324
384
|
{complete:true,items:[{ref,role,labels,body,comments,assignees,
|
|
@@ -6,10 +6,22 @@
|
|
|
6
6
|
* command fails, and both run gh with the scrubbed worker env.
|
|
7
7
|
* @module session-manager/queue-github
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
labelNames,
|
|
11
|
+
normalizeGithubIssue,
|
|
12
|
+
} from "../../../scripts/ready-queue-order.mjs";
|
|
10
13
|
import { resolveRole } from "../../../scripts/resolve-lifecycle-role.mjs";
|
|
14
|
+
import {
|
|
15
|
+
landedDoneRoles,
|
|
16
|
+
terminalDoneRoles,
|
|
17
|
+
} from "../../../scripts/stale-blocker-edges.mjs";
|
|
11
18
|
import { CliError, mustRun } from "./cli-runtime.mjs";
|
|
12
19
|
import { parseJson } from "./json-input.mjs";
|
|
20
|
+
import {
|
|
21
|
+
blockerReader,
|
|
22
|
+
hasBlockers,
|
|
23
|
+
withBlockers,
|
|
24
|
+
} from "./stale-links-github.mjs";
|
|
13
25
|
import { scrubWorkerEnv } from "./workers.mjs";
|
|
14
26
|
|
|
15
27
|
const OWNER_REPO = /^[\w.-]+\/[\w.-]+$/;
|
|
@@ -34,6 +46,55 @@ function githubRepo(ctx, project) {
|
|
|
34
46
|
return repo;
|
|
35
47
|
}
|
|
36
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Normalize REST rows with their blockers attached, so the queue judges a
|
|
51
|
+
* blocker by the same rule as intake and the stale-link sweep (#5065).
|
|
52
|
+
* Only rows that name a blocker, and that `keep` retains, cost any extra
|
|
53
|
+
* read: a row the caller will drop anyway is dropped before enrichment.
|
|
54
|
+
* @param {object} ctx - CLI context
|
|
55
|
+
* @param {{global?: object, local?: object}} project - Loaded project
|
|
56
|
+
* @param {string} repo - `owner/repo`
|
|
57
|
+
* @param {object[]} rows - REST issues
|
|
58
|
+
* @param {(row: object) => boolean} [keep] - Raw-row filter, applied first
|
|
59
|
+
* @returns {object[]} Normalized items
|
|
60
|
+
*/
|
|
61
|
+
function normalizeRows(ctx, project, repo, rows, keep = () => true) {
|
|
62
|
+
const config = {
|
|
63
|
+
tracker: "github",
|
|
64
|
+
global: project.global,
|
|
65
|
+
local: project.local,
|
|
66
|
+
};
|
|
67
|
+
const doneRoles = terminalDoneRoles(config);
|
|
68
|
+
const landedRoles = landedDoneRoles(config);
|
|
69
|
+
const blocker = blockerReader(ctx);
|
|
70
|
+
return rows
|
|
71
|
+
.filter(row => !row.pull_request && keep(row))
|
|
72
|
+
.map(row =>
|
|
73
|
+
hasBlockers(row, repo) ? enrichOrHold(ctx, repo, row, blocker) : row
|
|
74
|
+
)
|
|
75
|
+
.map(row => normalizeGithubIssue(row, { repo, doneRoles, landedRoles }))
|
|
76
|
+
.filter(Boolean);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Attach one row's blockers. A failed blocker read holds THAT row only: the
|
|
81
|
+
* rest of the queue is still offered.
|
|
82
|
+
* @param {object} ctx - CLI context
|
|
83
|
+
* @param {string} repo - `owner/repo`
|
|
84
|
+
* @param {Record<string, any>} row - REST issue
|
|
85
|
+
* @param {(ref: string) => object | null} blocker - Body-ref reader
|
|
86
|
+
* @returns {Record<string, any>} The enriched row, or the row marked unreadable
|
|
87
|
+
*/
|
|
88
|
+
function enrichOrHold(ctx, repo, row, blocker) {
|
|
89
|
+
try {
|
|
90
|
+
return withBlockers(ctx, repo, row, blocker);
|
|
91
|
+
} catch {
|
|
92
|
+
// probe-direction: fail-closed — an item whose blockers could not be read
|
|
93
|
+
// is held (`blockersUnreadable`), never released as unblocked.
|
|
94
|
+
return { ...row, blockersUnreadable: true };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
37
98
|
/**
|
|
38
99
|
* Every string leaf of an object (label names, including env-keyed `done`).
|
|
39
100
|
* @param {unknown} value - Config subtree
|
|
@@ -87,13 +148,12 @@ export function fetchGithubBacklog(ctx, project) {
|
|
|
87
148
|
);
|
|
88
149
|
const pages = parseJson(stdout, "gh api output");
|
|
89
150
|
const rows = Array.isArray(pages) ? pages.flat() : [];
|
|
151
|
+
// The lifecycle test reads labels exactly as `normalizeGithubIssue` does,
|
|
152
|
+
// and runs on the raw rows so an excluded issue costs no blocker read.
|
|
153
|
+
const unlabelled = row =>
|
|
154
|
+
!labelNames(row.labels).some(label => lifecycle.has(label.toLowerCase()));
|
|
90
155
|
return {
|
|
91
|
-
items: rows
|
|
92
|
-
.map(row => normalizeGithubIssue(row, { repo }))
|
|
93
|
-
.filter(Boolean)
|
|
94
|
-
.filter(
|
|
95
|
-
item => !item.labels.some(label => lifecycle.has(label.toLowerCase()))
|
|
96
|
-
),
|
|
156
|
+
items: normalizeRows(ctx, project, repo, rows, unlabelled),
|
|
97
157
|
pages: Array.isArray(pages) ? pages.length : 0,
|
|
98
158
|
};
|
|
99
159
|
}
|
|
@@ -124,7 +184,7 @@ export function fetchGithubQueue(ctx, project) {
|
|
|
124
184
|
const pages = parseJson(stdout, "gh api output");
|
|
125
185
|
const rows = Array.isArray(pages) ? pages.flat() : [];
|
|
126
186
|
return {
|
|
127
|
-
items:
|
|
187
|
+
items: normalizeRows(ctx, project, repo, rows),
|
|
128
188
|
pages: Array.isArray(pages) ? pages.length : 0,
|
|
129
189
|
};
|
|
130
190
|
}
|