@archme/cli 0.25.3 → 0.27.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/dist/cli.js +65 -20
- package/package.json +1 -1
- package/sandbox-image.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -18982,14 +18982,15 @@ function observeGithubPull(p) {
|
|
|
18982
18982
|
// Before the merge it is GitHub's throwaway test merge.
|
|
18983
18983
|
mergeCommitSha: p.merged_at ? p.merge_commit_sha ?? null : null,
|
|
18984
18984
|
headRepo: p.head.repo?.full_name ?? null,
|
|
18985
|
-
baseRepo: p.base.repo?.full_name ?? null
|
|
18985
|
+
baseRepo: p.base.repo?.full_name ?? null,
|
|
18986
|
+
draft: p.draft === true
|
|
18986
18987
|
};
|
|
18987
18988
|
}
|
|
18988
18989
|
function metaKey(o2) {
|
|
18989
18990
|
return createHash3("sha256").update(JSON.stringify([o2.title, o2.body])).digest("hex").slice(0, 16);
|
|
18990
18991
|
}
|
|
18991
18992
|
function record(o2, prev, action) {
|
|
18992
|
-
const r = { head: o2.headSha, state: o2.state, meta: metaKey(o2), html: true };
|
|
18993
|
+
const r = { head: o2.headSha, state: o2.state, meta: metaKey(o2), html: true, draft: o2.draft };
|
|
18993
18994
|
const seq = action === "synchronize" ? (prev?.seq ?? 0) + 1 : prev?.seq;
|
|
18994
18995
|
if (seq !== void 0) r.seq = seq;
|
|
18995
18996
|
return r;
|
|
@@ -19001,9 +19002,12 @@ function decideAction(prev, o2) {
|
|
|
19001
19002
|
if (wasOpen && !isOpen) return "closed";
|
|
19002
19003
|
if (!wasOpen && isOpen) return "reopened";
|
|
19003
19004
|
if (isOpen && prev.head !== o2.headSha) return "synchronize";
|
|
19005
|
+
if (isOpen && prev.draft !== void 0 && prev.draft !== o2.draft) {
|
|
19006
|
+
return o2.draft ? "converted_to_draft" : "ready_for_review";
|
|
19007
|
+
}
|
|
19004
19008
|
if (!isOpen && prev.state !== o2.state) return "edited";
|
|
19005
19009
|
if (prev.meta !== void 0 && prev.meta !== metaKey(o2)) return "edited";
|
|
19006
|
-
if (isOpen && !prev.html) return "edited";
|
|
19010
|
+
if (isOpen && (!prev.html || prev.draft === void 0)) return "edited";
|
|
19007
19011
|
return null;
|
|
19008
19012
|
}
|
|
19009
19013
|
function toItem(o2, action, sent) {
|
|
@@ -19023,6 +19027,7 @@ function toItem(o2, action, sent) {
|
|
|
19023
19027
|
body_html: o2.bodyHtml,
|
|
19024
19028
|
head_repo: o2.headRepo,
|
|
19025
19029
|
...o2.baseRepo ? { base_repo: o2.baseRepo } : {},
|
|
19030
|
+
draft: o2.draft,
|
|
19026
19031
|
...action === "synchronize" && sent.seq !== void 0 ? { seq: sent.seq } : {}
|
|
19027
19032
|
};
|
|
19028
19033
|
}
|
|
@@ -19072,6 +19077,7 @@ function parsePrPollState(raw) {
|
|
|
19072
19077
|
if (typeof r.meta === "string") entry.meta = r.meta;
|
|
19073
19078
|
if (Number.isInteger(r.seq) && r.seq > 0) entry.seq = r.seq;
|
|
19074
19079
|
if (r.html === true) entry.html = true;
|
|
19080
|
+
if (typeof r.draft === "boolean") entry.draft = r.draft;
|
|
19075
19081
|
prs[k] = entry;
|
|
19076
19082
|
}
|
|
19077
19083
|
}
|
|
@@ -19123,6 +19129,7 @@ function parseLocalRepos(raw) {
|
|
|
19123
19129
|
if (typeof raw2.haltedAt === "string" && raw2.haltedAt) entry.haltedAt = raw2.haltedAt;
|
|
19124
19130
|
if (typeof raw2.haltReason === "string" && raw2.haltReason) entry.haltReason = raw2.haltReason;
|
|
19125
19131
|
if (typeof raw2.haltCode === "string" && raw2.haltCode) entry.haltCode = raw2.haltCode;
|
|
19132
|
+
if (typeof raw2.haltSha === "string" && raw2.haltSha) entry.haltSha = raw2.haltSha;
|
|
19126
19133
|
const prPoll = parsePrPollState(raw2.prPoll);
|
|
19127
19134
|
if (prPoll) entry.prPoll = prPoll;
|
|
19128
19135
|
if (typeof raw2.prPausedAt === "string" && raw2.prPausedAt) entry.prPausedAt = raw2.prPausedAt;
|
|
@@ -19152,9 +19159,9 @@ function removeLocalReposBySlug(repos, slug) {
|
|
|
19152
19159
|
const want = slug.toLowerCase();
|
|
19153
19160
|
return repos.filter((r) => slugOf(r).toLowerCase() !== want);
|
|
19154
19161
|
}
|
|
19155
|
-
function markHalted(repos, watchedRepoId, reason, at, code) {
|
|
19162
|
+
function markHalted(repos, watchedRepoId, reason, at, code, sha2) {
|
|
19156
19163
|
return repos.map(
|
|
19157
|
-
(r) => r.watchedRepoId === watchedRepoId ? { ...r, haltedAt: at, haltReason: reason, haltCode: code } : r
|
|
19164
|
+
(r) => r.watchedRepoId === watchedRepoId ? { ...r, haltedAt: at, haltReason: reason, haltCode: code, haltSha: sha2 } : r
|
|
19158
19165
|
);
|
|
19159
19166
|
}
|
|
19160
19167
|
function setPrPollState(repos, watchedRepoId, prPoll) {
|
|
@@ -19170,7 +19177,7 @@ function markPrPaused(repos, watchedRepoId, at) {
|
|
|
19170
19177
|
function clearHalt(repos, watchedRepoId) {
|
|
19171
19178
|
return repos.map((r) => {
|
|
19172
19179
|
if (r.watchedRepoId !== watchedRepoId) return r;
|
|
19173
|
-
const { haltedAt: _at, haltReason: _reason, haltCode: _code, ...rest } = r;
|
|
19180
|
+
const { haltedAt: _at, haltReason: _reason, haltCode: _code, haltSha: _sha, ...rest } = r;
|
|
19174
19181
|
return rest;
|
|
19175
19182
|
});
|
|
19176
19183
|
}
|
|
@@ -19379,7 +19386,8 @@ function planPollTick(input) {
|
|
|
19379
19386
|
return {
|
|
19380
19387
|
kind: "halt",
|
|
19381
19388
|
code: decision.code,
|
|
19382
|
-
reason: localHaltReason(decision, input.jobForTarget, target)
|
|
19389
|
+
reason: localHaltReason(decision, input.jobForTarget, target),
|
|
19390
|
+
...decision.code === "job-terminal" && input.jobForTarget.status === "failed" ? { sha: target } : {}
|
|
19383
19391
|
};
|
|
19384
19392
|
case "advance":
|
|
19385
19393
|
return { kind: "idle", reason: decision.reason };
|
|
@@ -19387,10 +19395,14 @@ function planPollTick(input) {
|
|
|
19387
19395
|
return { kind: "idle", reason: `${short3(target)}: ${decision.reason}` };
|
|
19388
19396
|
}
|
|
19389
19397
|
}
|
|
19398
|
+
function haltHasCleared(halt, job, rolledUpThrough) {
|
|
19399
|
+
if (halt.haltCode !== "job-terminal" || !halt.haltSha) return false;
|
|
19400
|
+
return job?.status === "completed" || rolledUpThrough === halt.haltSha;
|
|
19401
|
+
}
|
|
19390
19402
|
function localHaltReason(decision, job, targetSha) {
|
|
19391
19403
|
if (decision.code !== "job-terminal" || !job) return decision.reason;
|
|
19392
19404
|
return `commit ${short3(targetSha)} could not be processed (job ${job.status} after ${job.attemptCount} attempt(s)). Local watch has stopped here rather than skipping it, because skipping would fold its changes into the next update.
|
|
19393
|
-
This one needs us \u2014 the failure is recorded against your account and visible to the ArchMe team. Get in touch if it is blocking you
|
|
19405
|
+
` + (job.status === "failed" ? `Press Retry on it in the board's History tab, and local watch carries on by itself once it completes. If it keeps failing, get in touch: the ArchMe team can see the failure.` : `This one needs us \u2014 the failure is recorded against your account and visible to the ArchMe team. Get in touch if it is blocking you.`);
|
|
19394
19406
|
}
|
|
19395
19407
|
function short3(sha2) {
|
|
19396
19408
|
return sha2.slice(0, 7);
|
|
@@ -19791,6 +19803,10 @@ async function pollPrsOnce(entry, deps) {
|
|
|
19791
19803
|
deps.log(
|
|
19792
19804
|
fork ? ` ${repo}: PR #${item.number} ${item.action} \u2192 held: it comes from a fork, and a locally watched repo does not review fork pull requests (there is no way to approve one without the GitHub App).` : ` ${repo}: PR #${item.number} ${item.action} \u2192 held: the server did not approve it for review (its head repo could not be confirmed as this repo, e.g. GitHub did not report it).`
|
|
19793
19805
|
);
|
|
19806
|
+
} else if (kind === "draft_held") {
|
|
19807
|
+
deps.log(
|
|
19808
|
+
` ${repo}: PR #${item.number} ${item.action} \u2192 draft: not reviewed until it is marked ready for review, or Scan is pressed in ArchMe.`
|
|
19809
|
+
);
|
|
19794
19810
|
} else if (kind !== void 0) {
|
|
19795
19811
|
deps.log(` ${repo}: PR #${item.number} ${item.action} \u2192 ${kind}`);
|
|
19796
19812
|
}
|
|
@@ -19948,6 +19964,9 @@ var init_pushSubject = __esm({
|
|
|
19948
19964
|
});
|
|
19949
19965
|
|
|
19950
19966
|
// src/daemon/localPoller.ts
|
|
19967
|
+
function jobRepoOf(entry, row) {
|
|
19968
|
+
return row.repoOwner && row.repoName ? `${row.repoOwner}/${row.repoName}` : `${entry.repoOwner}/${entry.repoName}`;
|
|
19969
|
+
}
|
|
19951
19970
|
async function pollRepoOnce(entry, deps) {
|
|
19952
19971
|
const repo = `${entry.repoOwner}/${entry.repoName}`;
|
|
19953
19972
|
const gateTimeoutMs = deps.gateTimeoutMs ?? DEFAULT_GATE_TIMEOUT_MS;
|
|
@@ -19980,7 +19999,7 @@ async function pollRepoOnce(entry, deps) {
|
|
|
19980
19999
|
return { kind: "idle", reason: `${repo}: watching is disabled on the server` };
|
|
19981
20000
|
}
|
|
19982
20001
|
await deps.git.fetchOrigin(entry.mirrorPath, row.repoBranch);
|
|
19983
|
-
const jobRepo =
|
|
20002
|
+
const jobRepo = jobRepoOf(entry, row);
|
|
19984
20003
|
const read = await deps.readMarker(row.projectId, row.archmeBranch, jobRepo);
|
|
19985
20004
|
const marker = { ...read, sha: read.rolledUpThrough ?? read.sha };
|
|
19986
20005
|
const upstreamTip = await deps.git.revParse(entry.mirrorPath, `origin/${row.repoBranch}`);
|
|
@@ -20028,14 +20047,35 @@ async function pollRepoOnce(entry, deps) {
|
|
|
20028
20047
|
}
|
|
20029
20048
|
return decision;
|
|
20030
20049
|
}
|
|
20050
|
+
async function clearHaltIfRetried(entry, key, deps) {
|
|
20051
|
+
if (!entry.haltSha) return false;
|
|
20052
|
+
try {
|
|
20053
|
+
const row = await deps.readWatchedRepo(entry.watchedRepoId);
|
|
20054
|
+
if (!row) return false;
|
|
20055
|
+
const repo = jobRepoOf(entry, row);
|
|
20056
|
+
const [job, marker] = await Promise.all([
|
|
20057
|
+
deps.readJobForSha(row.projectId, row.archmeBranch, repo, entry.haltSha),
|
|
20058
|
+
deps.readMarker(row.projectId, row.archmeBranch, repo)
|
|
20059
|
+
]);
|
|
20060
|
+
if (!haltHasCleared(entry, job, marker.rolledUpThrough)) return false;
|
|
20061
|
+
await deps.clearHalt(entry);
|
|
20062
|
+
return true;
|
|
20063
|
+
} catch (err4) {
|
|
20064
|
+
deps.log(` local poll ${key}: could not check its halt (checked again next tick): ${err4.message}`);
|
|
20065
|
+
return false;
|
|
20066
|
+
}
|
|
20067
|
+
}
|
|
20031
20068
|
async function pollAllRepos(repos, deps) {
|
|
20032
20069
|
const outcomes = [];
|
|
20033
20070
|
for (const entry of repos) {
|
|
20034
20071
|
const key = `${entry.repoOwner}/${entry.repoName} (${entry.watchedRepoId.slice(0, 8)})`;
|
|
20035
20072
|
const { watchedRepoId } = entry;
|
|
20036
20073
|
if (entry.haltedAt) {
|
|
20037
|
-
|
|
20038
|
-
|
|
20074
|
+
if (!await clearHaltIfRetried(entry, key, deps)) {
|
|
20075
|
+
outcomes.push({ watchedRepoId, outcome: "halted", haltCode: entry.haltCode, haltReason: entry.haltReason, haltedAt: entry.haltedAt });
|
|
20076
|
+
continue;
|
|
20077
|
+
}
|
|
20078
|
+
deps.log(` local poll resumed for ${key}: commit ${short4(entry.haltSha)} no longer blocks it`);
|
|
20039
20079
|
}
|
|
20040
20080
|
try {
|
|
20041
20081
|
const action = await pollRepoOnce(entry, deps);
|
|
@@ -20049,7 +20089,7 @@ async function pollAllRepos(repos, deps) {
|
|
|
20049
20089
|
haltReason: action.reason,
|
|
20050
20090
|
haltedAt: new Date(deps.now()).toISOString()
|
|
20051
20091
|
});
|
|
20052
|
-
await deps.persistHalt(entry, action.reason, action.code).catch((err4) => {
|
|
20092
|
+
await deps.persistHalt(entry, action.reason, action.code, action.sha).catch((err4) => {
|
|
20053
20093
|
deps.log(` local poll ${key}: could not save the halt (checked again next tick): ${err4.message}`);
|
|
20054
20094
|
});
|
|
20055
20095
|
deps.log(
|
|
@@ -20060,8 +20100,9 @@ async function pollAllRepos(repos, deps) {
|
|
|
20060
20100
|
No further commits will be processed for this repo.
|
|
20061
20101
|
Advancing past a failed commit would fold it into the next diff and break the
|
|
20062
20102
|
one-ArchMe-commit-per-git-commit guarantee, so this stops instead.
|
|
20063
|
-
|
|
20064
|
-
`
|
|
20103
|
+
` + (action.sha ? ` Retry it on the board's History tab; local watch carries on by itself once it completes.
|
|
20104
|
+
` : ` When the cause is fixed: archme local-watch --resume ${entry.repoOwner}/${entry.repoName}
|
|
20105
|
+
`)
|
|
20065
20106
|
);
|
|
20066
20107
|
continue;
|
|
20067
20108
|
}
|
|
@@ -20111,12 +20152,15 @@ function makePollerDeps(client, log, gateTimeoutMs) {
|
|
|
20111
20152
|
firstSeen.set(key, nowMs);
|
|
20112
20153
|
return nowMs;
|
|
20113
20154
|
},
|
|
20114
|
-
async persistHalt(entry, reason, code) {
|
|
20155
|
+
async persistHalt(entry, reason, code, sha2) {
|
|
20115
20156
|
const repos = await loadLocalRepos();
|
|
20116
20157
|
await saveLocalRepos(
|
|
20117
|
-
markHalted(repos, entry.watchedRepoId, reason, (/* @__PURE__ */ new Date()).toISOString(), code)
|
|
20158
|
+
markHalted(repos, entry.watchedRepoId, reason, (/* @__PURE__ */ new Date()).toISOString(), code, sha2)
|
|
20118
20159
|
);
|
|
20119
20160
|
},
|
|
20161
|
+
async clearHalt(entry) {
|
|
20162
|
+
await saveLocalRepos(clearHalt(await loadLocalRepos(), entry.watchedRepoId));
|
|
20163
|
+
},
|
|
20120
20164
|
async readWatchedRepo(watchedRepoId) {
|
|
20121
20165
|
const { data, error } = await client.from("watched_repos").select("project_id, branch, commit_update_archme_branch, source_kind, enabled, pr_update_mode, repo_owner, repo_name, deleted_at").eq("id", watchedRepoId).maybeSingle();
|
|
20122
20166
|
if (error) throw new Error(`could not read the watched repo: ${error.message}`);
|
|
@@ -27654,7 +27698,7 @@ async function runLocalWatchResume(slug, deps = {}) {
|
|
|
27654
27698
|
const stillTerminal = halted.some((m) => m.haltCode === "job-terminal");
|
|
27655
27699
|
if (stillTerminal) {
|
|
27656
27700
|
console.log(
|
|
27657
|
-
"\nNote: at least one of these stopped because a job failed outright. Resuming\ndoes not re-run a failed job \u2014 local watch will stop again on the next tick.\
|
|
27701
|
+
"\nNote: at least one of these stopped because a job failed outright. Resuming\ndoes not re-run a failed job \u2014 local watch will stop again on the next tick.\nPress Retry on that commit in the board's History tab; local watch carries on\nby itself once it completes (if it doesn't, run this command again)."
|
|
27658
27702
|
);
|
|
27659
27703
|
} else {
|
|
27660
27704
|
console.log("\nLocal watch resumes from the recorded commit on the next tick.");
|
|
@@ -30150,7 +30194,7 @@ ${project}
|
|
|
30150
30194
|
|
|
30151
30195
|
${access}
|
|
30152
30196
|
|
|
30153
|
-
4. **Ask whether to review pull requests** too (\`--prs\` or \`--no-prs\`): each
|
|
30197
|
+
4. **Ask whether to review pull requests** too (\`--prs\` or \`--no-prs\`): each PR's first review is one Claude run on their subscription, and later pushes run only when someone presses Update on the PR.${opts.githubAppAllowed ? " With local watch, a private repo's PRs need `gh auth login`, and PRs from forks are never reviewed." : " A private repo's PRs need `gh auth login`, and PRs from forks are never reviewed."}
|
|
30154
30198
|
|
|
30155
30199
|
## 5. Hand off
|
|
30156
30200
|
|
|
@@ -32649,8 +32693,9 @@ Options:
|
|
|
32649
32693
|
--project <org/slug> Project to write to (default: derived from the repo name)
|
|
32650
32694
|
--branch <name> Branch to track (default: the repo's default branch)
|
|
32651
32695
|
--yes Don't ask for confirmation (needs an explicit repo-path)
|
|
32652
|
-
--prs / --no-prs Also review pull requests (
|
|
32653
|
-
|
|
32696
|
+
--prs / --no-prs Also review pull requests (a PR's first review is one Claude
|
|
32697
|
+
run, later pushes wait for Update in the app; a private
|
|
32698
|
+
repo needs gh auth login)
|
|
32654
32699
|
|
|
32655
32700
|
Watching queues work; a local daemon does it. After registering: archme daemon start`);
|
|
32656
32701
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@archme/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Map your codebase into a living architecture diagram: run `archme init` in a repo to scan it, `archme daemon start` to keep it current on every commit.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
package/sandbox-image.json
CHANGED