@ouro.bot/cli 0.1.0-alpha.1556 → 0.1.0-alpha.1558
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/changelog.json +12 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/desk.lock.json +3 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/vendor/desk/.claude-plugin/plugin.json +1 -1
- package/vendor/desk/.ouro-desk.json +3 -3
- package/vendor/desk/CHANGELOG.md +640 -0
- package/vendor/desk/activation/copilot-root.flattened-bundle.json +2 -2
- package/vendor/desk/activation/desk.activation.json +5 -5
- package/vendor/desk/agency.json +1 -1
- package/vendor/desk/docs/issue-drains.md +8 -6
- package/vendor/desk/docs/sessions.md +1 -1
- package/vendor/desk/hooks/lib/boot-checks.cjs +1 -1
- package/vendor/desk/hooks/lib/child-agent.cjs +2 -2
- package/vendor/desk/hooks/lib/factory-end.cjs +4 -1
- package/vendor/desk/mcp/README.md +9 -1
- package/vendor/desk/mcp/bootstrap.cjs +64 -38
- package/vendor/desk/mcp/idle-proxy.cjs +14 -6
- package/vendor/desk/mcp/scripts/crew.js +3 -3
- package/vendor/desk/mcp/scripts/drains-launcher.mjs +6 -5
- package/vendor/desk/mcp/scripts/factory.js +15 -6
- package/vendor/desk/mcp/scripts/local-recovery.js +89 -7
- package/vendor/desk/mcp/scripts/resolve-desk-root.js +1 -2
- package/vendor/desk/mcp/src/actions/desk-session.actions.mts +16 -1
- package/vendor/desk/mcp/src/actions/desk.actions.mts +2 -2
- package/vendor/desk/mcp/src/actions/generated/desk/actions.json +36 -1
- package/vendor/desk/mcp/src/actions/generated/desk/mcp.json +34 -1
- package/vendor/desk/mcp/src/activation/superpowers-context.js +9 -0
- package/vendor/desk/mcp/src/crew/workspace.js +30 -4
- package/vendor/desk/mcp/src/desk/card-commit-guard.js +3 -2
- package/vendor/desk/mcp/src/desk/content-home.js +16 -0
- package/vendor/desk/mcp/src/indexer/discover.js +8 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/ax-claims.ts +2 -1
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/ax-command.ts +20 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/mcp.ts +1 -1
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/xray.ts +40 -2
- package/vendor/desk/mcp/src/runtime/boot.js +0 -1
- package/vendor/desk/mcp/src/runtime/deliver.js +42 -5
- package/vendor/desk/mcp/src/runtime/drains-cli.js +9 -1
- package/vendor/desk/mcp/src/runtime/drains.js +479 -40
- package/vendor/desk/mcp/src/runtime/hosted.js +5 -3
- package/vendor/desk/mcp/src/runtime/pending-migrations.js +5 -1
- package/vendor/desk/mcp/src/runtime/pr-publication.js +55 -29
- package/vendor/desk/mcp/src/runtime/relays.js +10 -1
- package/vendor/desk/mcp/src/runtime/remote-identity.js +22 -0
- package/vendor/desk/mcp/src/runtime/sessions-cli.js +6 -6
- package/vendor/desk/mcp/src/runtime/sync-worker.js +10 -8
- package/vendor/desk/mcp/src/runtime/unmerged-saves.js +29 -3
- package/vendor/desk/mcp/src/server.js +3 -2
- package/vendor/desk/mcp/src/tool-names.js +0 -2
- package/vendor/desk/mcp/src/tool-schemas.js +3 -8
- package/vendor/desk/mcp/src/tools/archive-links.js +3 -0
- package/vendor/desk/mcp/src/tools/desk-save.js +8 -3
- package/vendor/desk/mcp/src/tools/move.js +32 -3
- package/vendor/desk/mcp/src/tools/sibling-desk.js +10 -4
- package/vendor/desk/mcp/src/tools/status.js +9 -6
- package/vendor/desk/mcp/src/tools/task-log.js +6 -2
- package/vendor/desk/mcp/src/tools/task.js +17 -5
- package/vendor/desk/mcp/src/util/citations.js +54 -0
- package/vendor/desk/mcp/web-auth.cjs +17 -0
- package/vendor/desk/mcp/web-sso.cjs +52 -0
- package/vendor/desk/plugin.json +2 -2
- package/vendor/desk/skills/add-workspace-mcp/SKILL.md +2 -2
- package/vendor/desk/skills/archive-workflow/SKILL.md +1 -1
- package/vendor/desk/skills/coordinating-lanes/SKILL.md +24 -0
- package/vendor/desk/skills/evidence-discipline/SKILL.md +8 -12
- package/vendor/desk/skills/git-hygiene/SKILL.md +6 -0
- package/vendor/desk/skills/interaction-style/SKILL.md +4 -2
- package/vendor/desk/skills/live-ui-iteration/SKILL.md +35 -0
- package/vendor/desk/skills/operator-voice-comments/SKILL.md +4 -0
- package/vendor/desk/skills/outside-approval/SKILL.md +10 -0
- package/vendor/desk/skills/pr-feedback-on-own-pr/SKILL.md +5 -1
- package/vendor/desk/skills/pr-reviewer-audit/SKILL.md +1 -1
- package/vendor/desk/skills/pr-reviewer-audit/helpers/audit.py +19 -1
- package/vendor/desk/skills/pr-reviewer-audit/helpers/test_audit.py +37 -1
- package/vendor/desk/skills/pr-self-review/SKILL.md +1 -1
- package/vendor/desk/skills/pr-surface-hygiene/SKILL.md +28 -4
- package/vendor/desk/skills/pr-surface-hygiene/check-visual-proof.cjs +27 -14
- package/vendor/desk/skills/prior-art/SKILL.md +14 -0
- package/vendor/desk/skills/runtime-symptom-investigation/SKILL.md +5 -1
- package/vendor/desk/skills/session-resumption/SKILL.md +3 -1
- package/vendor/desk/skills/using-desk/SKILL.md +3 -3
- package/vendor/desk/skills/using-superpowers-with-desk/SKILL.md +2 -0
- package/vendor/desk/skills/visual-proof/SKILL.md +42 -0
- package/vendor/desk/skills/work-orchestration/SKILL.md +17 -2
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": 1,
|
|
3
3
|
"id": "desk",
|
|
4
|
-
"version": "3.2.
|
|
4
|
+
"version": "3.2.552",
|
|
5
5
|
"dependencies": [
|
|
6
6
|
{
|
|
7
7
|
"id": "desk",
|
|
8
8
|
"kind": "substrate",
|
|
9
|
-
"version": "3.2.
|
|
9
|
+
"version": "3.2.552",
|
|
10
10
|
"provenance": {
|
|
11
11
|
"source": "plugins/desk/.claude-plugin/plugin.json",
|
|
12
12
|
"package": "ourostack/desk"
|
|
13
13
|
},
|
|
14
14
|
"lock": {
|
|
15
|
-
"version": "3.2.
|
|
15
|
+
"version": "3.2.552",
|
|
16
16
|
"integrity": "sha256-desk-activation-manifest-v1"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"package": "ourostack/plain-language"
|
|
39
39
|
},
|
|
40
40
|
"lock": {
|
|
41
|
-
"version": "0.2.
|
|
41
|
+
"version": "0.2.17",
|
|
42
42
|
"integrity": "sha256-plain-language-activation-manifest-v1"
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -194,7 +194,7 @@
|
|
|
194
194
|
},
|
|
195
195
|
"plain-language": {
|
|
196
196
|
"path": "../plain-language",
|
|
197
|
-
"version": "0.2.
|
|
197
|
+
"version": "0.2.17",
|
|
198
198
|
"resolution": "native"
|
|
199
199
|
}
|
|
200
200
|
},
|
package/vendor/desk/agency.json
CHANGED
|
@@ -35,28 +35,30 @@ Only `repo` and `session` are required. `session` is opaque to Desk: the runner
|
|
|
35
35
|
|
|
36
36
|
## What wakes a drain
|
|
37
37
|
|
|
38
|
-
An issue is news when something other than the drain changed it since the revision last recorded: a new issue, a title or body edit, a comment, a reopen, or a label change. These are not news:
|
|
38
|
+
An issue is news when something other than the drain changed it since the revision last recorded: a new issue, a title or body edit, a comment, a reopen, an assignment change, or a label change. These are not news:
|
|
39
39
|
|
|
40
40
|
- a new issue the drain filed or already triaged: a label in its `drain:` namespace, or the `<!-- ouro-drain-status -->` marker in its body, is there before the poll first sees it, so the issue is recorded as seen and only later changes by others count;
|
|
41
41
|
- the drain's own status comment, matched by the `<!-- ouro-drain-status -->` marker and the polling account, including its edits. The polling account is whoever the drain's token is (`GET /user` on its own `account`'s token), resolved per repository, so a drain on a work account and one on a personal account each recognise only their own comments;
|
|
42
42
|
- labels starting with `drain:`, any label in the drain's `ignoredLabels`, and any label whose name matches a regular expression in its `ignoreLabels` (case-insensitive, for example `["^waiting:", "^lane:"]`): the escape hatch for a lane's own labels;
|
|
43
|
-
- a label or
|
|
43
|
+
- a label, reopen or assignment change made by the polling account during the drain's turn, whatever the label. The turn opens when a wake is delivered (a minute earlier, for a drain that acts before the delivery is acknowledged) and lasts 90 minutes; the poller keeps each drain's recent delivery times in its state (`turns`). The same account's changes outside a turn, and anyone else's inside one, still wake the drain;
|
|
44
|
+
- a body edit that only bots made, whoever created the issue. When its body changed (its title did not) the poll reads the issue's edit history over GraphQL (`Issue.userContentEdits`, 100 a page, from the start and the end in turn once a baseline is recorded) and stays quiet only when it has at least one edit since the revision last recorded and every such edit is a bot's (`Bot` or a login ending `[bot]`), so a health table a bot refreshes every few minutes wakes nobody. A person's edit anywhere in that interval wakes the drain, whatever bots edited around it. So does anything the history cannot prove: an edit whose editor is unknown or gone, a deleted edit, an edit with no id or time, a history that cycles or stands still, a changed title, or a revision recorded before the poll kept titles. The issue's creator is no part of the decision. Comments, labels, reopens, cross-references and someone else's assigning or unassigning are checked as usual after a quiet body edit.
|
|
45
|
+
The read is kept in the poll state per issue (`scans`), so it survives quota windows and a history of any length: each poll spends pages only while the account's GraphQL quota (the last `rateLimit` answer, each page costing what GitHub charged for it) stays above the 25-call reserve, pending reads take turns a page at a time (least recently served first) so none starves, and nothing else waits for them: an issue that needs no read is judged in the first poll. A read that stops (quota, network, authentication, a history that lags the issue) leaves that issue's marker where it was and the poll reports `N issue(s) were left for it` as its last error, with the code of the failure; that alone wakes nobody, and the next poll goes on from the saved page. Edits made while a read is under way are not a reason to restart it; an edit by a person among them still wakes the drain. Limits: GitHub's GraphQL answers, an append-only history and agreeing clocks are assumed, not verified; after a wake the next bot-only body change is read from the start once.
|
|
44
46
|
- body lines that start with a key in `ignoredBodyTrailers` (`Active-at: …`), so a lane's scheduled beat does not wake the drain;
|
|
45
47
|
- comments that fit an `ignoreComments` rule: written by its `author` (case-insensitive) and, when the rule has a `match`, a body that matches the regular expression. A rule without `match` skips every comment by that author; the same bot's other comments still wake the drain;
|
|
46
48
|
- a bot's comment that repeats that bot's previous comment on the issue: the two texts are the same once run URLs and IDs, dates, times and durations (`took 14 min`) are replaced, so a daily "checks failed" report or a CI-budget note wakes the drain the first time and when its text changes, not on every repeat. A person's comment, a bot's first comment and a changed text still wake it;
|
|
47
49
|
- a reopen that is the drain claiming the issue: the polling account reopens it within a minute of its own `drain:` label change;
|
|
48
50
|
- commit references (`referenced` events) and edits to the drain's own marked comment, which the rules above already skip;
|
|
49
|
-
- closes
|
|
51
|
+
- closes, and cross-references: a cross-reference the drain made itself. When an issue's `updated_at` moved and nothing above was news, the poll reads its timeline, and a `cross-referenced` event after the last marker wakes the drain unless its source is the drain's own work: an issue or pull request the drain filed (a label in its `drain:` namespace, or the `<!-- ouro-drain-status -->` marker in its body), a pull request on a `drain-…` or `drain/…` branch, the drain's marked status comment on this issue that names the source (`#50`, `owner/name#50` or a link), or its marked comment on the source that names this issue around then. Put the marker in the body of every pull request the drain opens: it is the one deterministic link between a drain's pull request and the issue it fixes, on any branch name. Any other cross-reference is news, and its event says where it came from. A pull request's merge or close is not news: the drain learns a fix landed from its own PR. A closed issue is not polled at all. GitHub does not move an issue's `updated_at` for a cross-reference or a commit reference, so an outside cross-reference is noticed with the issue's next change, which can be hours later; the poll does not read every open issue's timeline to find it sooner.
|
|
50
52
|
|
|
51
53
|
## Spending little quota
|
|
52
54
|
|
|
53
|
-
A poll is cheap on the account's REST quota. Between full syncs it asks GitHub only for what changed: `state=all&sort=updated&since=` the newest change it knew (less two minutes), sent with the `ETag` of the last answer as `If-None-Match`, so an unchanged repository costs one call that GitHub answers with a 304 and does not count against the rate limit. A change that closed an issue is in that list and marks it gone; a reopen is news. Once an hour the whole open list is read again (a full sync), which also catches anything the `since` window missed. The timeline of an issue is read only when its `updated_at` moved with nothing else news. The account's login is asked of GitHub once a day and kept in the state.
|
|
55
|
+
A poll is cheap on the account's REST quota. Between full syncs it asks GitHub only for what changed: `state=all&sort=updated&since=` the newest change it knew (less two minutes), sent with the `ETag` of the last answer as `If-None-Match`, so an unchanged repository costs one call that GitHub answers with a 304 and does not count against the rate limit. A change that closed an issue is in that list and marks it gone; a reopen is news. Once an hour the whole open list is read again (a full sync), which also catches anything the `since` window missed. The timeline of an issue is read only when its `updated_at` moved with nothing else news. The account's login is asked of GitHub once a day and kept in the state. The edit history is read only for an issue whose body changed and whose title did not, with one GraphQL call per 100 edits, read to the end of the history however long it is (a cursor that repeats counts as incomplete). GraphQL has its own quota window: its reading is kept apart as `graphqlQuota` in the state and never replaces the REST quota that holds a drain.
|
|
54
56
|
|
|
55
57
|
Every answer's `x-ratelimit-*` headers are kept per account. When an account has 25 calls or fewer left, its drains are not polled until the window resets; when it is under 200 left (or under a tenth of its limit), they are polled at most every 15 minutes. Drains that share an account share the reading. `status` shows each account's quota first (`quota <account>: 4700/5000 calls left, resets <time> (read 2m ago); the last cycle used 3 calls, 2 of them not modified`) and `held: …` after a drain that is waiting on quota.
|
|
56
58
|
|
|
57
59
|
## Seeing a gap
|
|
58
60
|
|
|
59
|
-
`status` (and the `status` lines `poll` prints) start with the Desk in use (`desk <version> (ourostack/desk@release 1a2b3c4d, the launcher's own copy)`; the JSON also has `desk.version` and `desk.release`) and then show, per drain, the last poll that read GitHub without an error and its lag (`last ok poll … (lag 2m)`), the last attempt, and how long the oldest waiting event has waited (`2 waiting (oldest 5h)`). A poll that keeps failing shows a growing lag and its last error; a wake that is made but never delivered shows a growing wait. Each recorded event carries `seenAt`, the time the poll first saw it, and `why`, the one change that made it news (`new issue`, `title or body edited`, `comment <id> by <login>`, `labeled <name>`, `unlabeled <name>`, `reopened`), so a wake nobody expected can be traced to a signal. The wake message names the reason after each issue (`#876 Title (cross-reference from owner/name#9)`), and each drain keeps its last 200 events in its state (with the Desk version, and the release commit for the launcher's own copy, that polled them), so `drains.js why owner/name#123` prints the reasons recorded for that issue (newest first), the marker the poll keeps for it and whether a wake is still waiting.
|
|
61
|
+
`status` (and the `status` lines `poll` prints) start with the Desk in use (`desk <version> (ourostack/desk@release 1a2b3c4d, the launcher's own copy)`; the JSON also has `desk.version` and `desk.release`) and then show, per drain, the last poll that read GitHub without an error and its lag (`last ok poll … (lag 2m)`), the last attempt, and how long the oldest waiting event has waited (`2 waiting (oldest 5h)`). A poll that keeps failing shows a growing lag and its last error; a read GitHub answers with a 5xx is asked once more at once, and if that fails too the last error says GitHub's server failed (`drains_github_server_error`, it usually clears on the next poll, nothing to do), while `Check gh auth status` is kept for a refused credential (HTTP 401 only) and any other refusal (403 permissions, 404, 422, an unreadable GraphQL answer) is reported as GitHub's answer without a credential diagnosis (`drains_github_refused`, `drains_graphql_failed`); a wake that is made but never delivered shows a growing wait. Each recorded event carries `seenAt`, the time the poll first saw it, and `why`, the one change that made it news (`new issue`, `title or body edited`, `comment <id> by <login>`, `labeled <name>`, `unlabeled <name>`, `assigned <login>`, `unassigned <login>`, `reopened`), so a wake nobody expected can be traced to a signal. The wake message names the reason after each issue (`#876 Title (cross-reference from owner/name#9)`), and each drain keeps its last 200 events in its state (with the Desk version, and the release commit for the launcher's own copy, that polled them), so `drains.js why owner/name#123` prints the reasons recorded for that issue (newest first), the marker the poll keeps for it and whether a wake is still waiting.
|
|
60
62
|
|
|
61
63
|
## Delivering a wake
|
|
62
64
|
|
|
@@ -72,7 +74,7 @@ Every answer's `x-ratelimit-*` headers are kept per account. When an account has
|
|
|
72
74
|
|
|
73
75
|
If a drain's `session` is archived or gone, the `--error` text from `done` says so and the drain recovers by itself: Desk starts a successor session with `shepherd create` (its first kickoff line is `Succeeds: <old id>`), keeps the new id in the drain's state (the config is never edited), and sends later wakes there. A failed start is retried after ten minutes, and a changed `session` in the config drops the override. `gh auth token` is read up to three times, so a timeout or a busy keyring is retried; only gh's own "no oauth token" says to sign in.
|
|
74
76
|
|
|
75
|
-
One poll or ack runs at a time
|
|
77
|
+
One poll or ack runs at a time. `poll.lock` is a directory that is published whole: Desk writes `poll.lock.new-<pid>-<token>/owner-<token>` (the process id) and renames it onto `poll.lock`, which succeeds only where the lock is absent or empty, so the lock is never visible empty or half-written. A second run stops with `desk_drains_busy` while the owner's process is alive, however long it has held it, and nothing ages a live owner out. A dead owner is retired by removing its own `owner-<token>` file (a name no later owner reuses, so a run with a stale view removes nothing of a newer lock) and then `rmdir`, which refuses a lock that has an owner; a poll releases only its own owner file. On Windows, whose rename replaces a plain file (measured on a Windows runner), the directory is published with .NET's `Directory.Move` through `pwsh` or, if that cannot be launched, `powershell` (a fixed script with the paths passed as data; it ends in a move without replace-existing, so the system refuses an existing target); a shell that ran is never retried and `rename` is never the fallback, so with neither shell the lock is `desk_drains_lock_unavailable`. When the publish fails for any reason, Desk looks at what is at `poll.lock` rather than trusting the error code (Windows reports `EPERM` for an occupied target): an owner, an empty directory or a file is handled as below, and only a failure with nothing in the way is `desk_drains_lock_unavailable`. Staging directories of dead processes, which a crash can leave, are removed by exact name. Desk fails closed, without removing anything and with its own error, on a `poll.lock` that is a file (`desk_drains_lock_legacy`, the lock of an earlier Desk, whose owner cannot be told: once no earlier poll or ack is running, remove it yourself), on entries or an owner file it did not make (`desk_drains_lock_unrecognized`), and on a failure to use the directory (`desk_drains_lock_unavailable`, naming the error code). Limits: a recycled process id can make a dead owner look alive, and the run stays busy until that process ends; the behaviour is verified on POSIX file systems only (not Windows), and without fsync, so not across power loss.
|
|
76
78
|
|
|
77
79
|
## Moving an Ouroboros drain list
|
|
78
80
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sessions on this machine
|
|
2
2
|
|
|
3
|
-
Agents often need to know what another session on the same machine last said, or to message it. [`sessions.js`](../mcp/scripts/sessions.js) does both, and finds out which session you are. It covers this machine only; to reach a session on another
|
|
3
|
+
Agents often need to know what another session on the same machine last said, or to message it. [`sessions.js`](../mcp/scripts/sessions.js) does both, and finds out which session you are. It covers this machine only; to reach a session on another of the operator's machines, run the same command there over SSH on their tailnet (`ssh <host> node <desk>/plugins/desk/mcp/scripts/sessions.js tail <session>`), not through Agency Hub. The logic is in [sessions-cli.js](../mcp/src/runtime/sessions-cli.js).
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
6
|
node <desk>/plugins/desk/mcp/scripts/sessions.js whoami [--hint <text from your own command>]
|
|
@@ -630,7 +630,7 @@ function main(argv = process.argv.slice(2)) {
|
|
|
630
630
|
}))
|
|
631
631
|
: Promise.reject(new Error("usage: boot-checks.cjs --compatible <script> [args] | --fast-forward <desk> | --repair <desk> | --ack <desk> <id> <digest> <canonical-evidence> | --revoke <common-git-dir> <worktree> <branch-ref> <owner>"));
|
|
632
632
|
run.then((result) => process.stdout.write(`${JSON.stringify(result)}\n`)).catch((error) => {
|
|
633
|
-
process.stderr.write(`
|
|
633
|
+
process.stderr.write(`boot-checks: ${oneLine(error.message)}\n`);
|
|
634
634
|
process.exitCode = 1;
|
|
635
635
|
});
|
|
636
636
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
// Plain Language loads on demand, and agents do not load it unprompted (0 of 8 haiku runs did), so every start points at it.
|
|
4
|
-
const PLAIN_LANGUAGE_POINTER = "Before you write
|
|
4
|
+
const PLAIN_LANGUAGE_POINTER = "Before you write for others, load the `plain-language` skill and follow it. Skills and briefs carry no disclaimer, copyright or read-the-original line unless required.";
|
|
5
5
|
|
|
6
6
|
// What a child agent (a subagent) gets in place of the boot: its brief is its instruction, so Desk's startup does not apply to it.
|
|
7
|
-
const CHILD_AGENT_LINE = "Desk: you are a child agent, so follow your brief and skip Desk's startup. Desk's tools are named `desk-<name>`. Before you write anything a person will read, load the `plain-language` skill.";
|
|
7
|
+
const CHILD_AGENT_LINE = "Desk: you are a child agent, so follow your brief and skip Desk's startup. Desk's tools are named `desk-<name>`. Before you write anything a person or agent will read (a skill, document, prompt or brief included), load the `plain-language` skill. Skills and briefs carry no disclaimer, copyright or read-the-original line unless required.";
|
|
8
8
|
|
|
9
9
|
// Copilot's prompt hooks name the agent running the prompt: a subagent's input carries `agentId` and `parentAgentId`, a main session's carries neither.
|
|
10
10
|
function isChildAgentInput(input) {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
// The stable code printed when the background worker cannot run.
|
|
4
|
+
const WORKER_UNAVAILABLE = "hook_worker_unavailable";
|
|
5
|
+
|
|
3
6
|
const fs = require("node:fs");
|
|
4
7
|
const os = require("node:os");
|
|
5
8
|
const path = require("node:path");
|
|
@@ -292,7 +295,7 @@ async function runBoundedHook(host, input, entry, { deadlineMs = DEADLINE_MS, st
|
|
|
292
295
|
} catch { /* Accounting produces no stdout when no correction is due. */ }
|
|
293
296
|
} else {
|
|
294
297
|
const why = timedOut ? "deadline" : spawnError ? `spawn ${spawnError.code ?? "error"}` : signal ? `signal ${signal}` : `exit ${code}`;
|
|
295
|
-
stderr.write(`[desk-delivery] unverified:
|
|
298
|
+
stderr.write(`[desk-delivery] unverified: ${WORKER_UNAVAILABLE} (${why})\n`);
|
|
296
299
|
}
|
|
297
300
|
resolve();
|
|
298
301
|
};
|
|
@@ -49,10 +49,12 @@ The command writes one local JSON report and exits:
|
|
|
49
49
|
| --- | --- |
|
|
50
50
|
| `0` | The tool reported completion, no pending push is claimed (with `--publication deferred`, the push is reported `deferred` and left to the caller), and any expected Git commit was observed through a HEAD change. This is not a project's code-delivery claim. |
|
|
51
51
|
| `1` | No mutation was dispatched: input, root, admission, scope or transport preflight refused. |
|
|
52
|
-
| `2` | Partial or unknown effects: tool/parse/transport failure after dispatch, missing commit evidence, `commit_failed`, `push_pending`, or uncertain child shutdown. |
|
|
52
|
+
| `2` | Partial or unknown effects: tool/parse/transport failure after dispatch, missing commit evidence, `commit_failed`, `commit_queued`, `push_pending`, or uncertain child shutdown. |
|
|
53
53
|
|
|
54
54
|
The report retains `operation`, `requestedRoot`, `actualRoot` when available, `preflight`, `result`, `effects`, local `git.headBefore`/`headAfter`, `transport.pid`/`shutdown`, and concrete `readback` commands. Tool-result string values matching input strings are redacted, and our shared credential scrub also covers runtime error text; the original JSON remains the source for exact card/file identities. Raw parser errors and child stderr are not printed. `effects.mutation: "not_dispatched"` establishes only that this client sent no mutation; admission may still create derived runtime state or perform its already-declared state-branch checks. `reported_applied` is the tool's account, not an independent diff. `reported_complete` covers `nothing_to_commit` and `already_archived` without claiming those responses prove unchanged files. An `isError` response alone never establishes unchanged files. A changed HEAD is an observation, not attribution against a concurrent writer.
|
|
55
55
|
|
|
56
|
+
A `task_update` `log` is written before the call returns but committed later by Desk's background writer. Recovery accepts that admitted queued result without waiting: `status: "partial"`, `code: "commit_queued"`, exit `2`, `effects.mutation: "reported_applied"`, `effects.commit: "queued"` for a log-only call, and `queued: {path, state, committer}`. `state` is `pending` while the path is not at `HEAD` or its bytes differ from the `HEAD` blob and `committer` is `background_worker`, or `next_session_start` under `--publication deferred`, which schedules no worker. In a mixed call `effects.commit` keeps the card commit's own observation and `effects.log` carries the log's `queued` or `observed`. Readback is qualified: it reads the log only through a root-contained, link-free directory chain pinned by an opened descriptor, and when the log is not yet at `HEAD` it lists Git's names for the path without reading its bytes. If the path is ignored, missing, linked or relocated, or a read of a log already at `HEAD` cannot be completed or its identity changes, the log's state is `unknown`: the call stays `partial` with the same do-not-resend receipt, never `observed`. A log not yet at `HEAD` is `pending` on Git's listed names alone; its readability is not checked. Observation shows the entry's bytes at `HEAD`; it does not say who wrote them. If the writer already committed the entry when recovery looks, the ordinary `observed`/exit `0` rules apply. Never resend a queued log; it would duplicate the entry. A `logged` result without the queued marker, or any other unknown result, stays `unexpected_tool_result`.
|
|
57
|
+
|
|
56
58
|
Push runs through the existing asynchronous handler. A configured remote is conservatively reported as pending, even if its worker later finishes; the client does not poll for delivery or advertise a successful push. A commit failure can leave the real card write applied. A timeout after dispatch can also occur after application. Read the named card/files and local status, HEAD, last commit paths and upstream in the confirmed desk before considering another mutation. Do not automatically resend, retry a permission/validation refusal elsewhere, or replace this path with unvalidated card edits.
|
|
57
59
|
|
|
58
60
|
The owned bootstrap is closed on every outcome, with bounded EOF/SIGTERM shutdown; the scheduled push keeps its ordinary lifetime. At the agent's reporting boundary, use `desk-problem`'s existing `broke / means / fix / file / tell` fields, keeping private roots local and public filings generic. This JSON transport report does not replace that block or change any published MCP result schema.
|
|
@@ -244,6 +246,12 @@ The plugin's `artifacts/tombstones/tombstones.jsonl` lists documents, by path an
|
|
|
244
246
|
|
|
245
247
|
## Tests
|
|
246
248
|
|
|
249
|
+
Publishing a workspace candidate does not close other `desk/publish/*` pull requests or delete their branches. Independent Desk roots may publish unrelated changes. Recorded-save settlement closes duplicates only after verifying their content on actual upstream, and records the evidence while clearing the local waiting receipt.
|
|
250
|
+
|
|
251
|
+
Workspace PR publication reads `.desk/publication.json` from the published target and waits for its required checks, the base branch's required checks, and every other reported check on the exact candidate head. Only then does it attach the merge relay's label and request an exact-head merge. It does not call `gh pr merge --auto`: that command can merge immediately when GitHub's own checks do not enforce the published policy.
|
|
252
|
+
|
|
253
|
+
Checks that outlast the qualification timeout remain recorded and unlabelled. The background push worker retries pending-check qualification beyond its network retry budget; failed checks, unreadable policy/rules, authentication failures and changed or closed PRs still stop with the recorded diagnostic. A relay that merges the qualified PR concurrently is accepted only after rereading its exact identity and proving the candidate is on the actual upstream.
|
|
254
|
+
|
|
247
255
|
```sh
|
|
248
256
|
npm test
|
|
249
257
|
```
|
|
@@ -524,56 +524,79 @@ function serveDegraded(options) {
|
|
|
524
524
|
|
|
525
525
|
// A host installs one copy of Desk per session, as <sessions>/<session>/<root-N>/desk, and keeps a session's server for days. When the idle proxy has to start a new server it can start the newest installed copy's index.js instead of the copy it was launched from, so every idle session moves to the current Desk on its next message.
|
|
526
526
|
// A copy is chosen only when it is newer, is the same Desk (plugin name and repository), declares the same mcp/package.json `toolProtocol` (the tools the host already listed all still exist with the same inputs; bump it in the same change that removes or breaks a tool), and its engines and runtime pack accept this Node. Anything else, or any read that fails, keeps the copy the proxy was started from.
|
|
527
|
-
// options: { mcpRoot, current: { version, abi }, platform, arch, scanRoot (the folder of session folders; default: the one this copy sits in, when it sits in that layout) }
|
|
527
|
+
// options: { mcpRoot, current: { version, abi }, platform, arch, scanRoot (the folder of session folders; default: the one this copy sits in, when it sits in that layout), own (what readOwn returned when this process started) }
|
|
528
|
+
// A copy that sits in a folder named for its version (the Claude Code plugin cache: <plugin>/<version>) also looks at its sibling version folders.
|
|
529
|
+
// When this copy's own folder has been removed (a host pruned the version a live session runs from), `own` stands in for its manifests and any installed copy of the same Desk that fits this Node is chosen, newest first.
|
|
528
530
|
// Returns { indexFile, pluginRoot, version } of the copy to run, or null to keep this one.
|
|
531
|
+
function readOwn(mcpRoot, platform, arch) {
|
|
532
|
+
var plugin = readJson(path.join(path.dirname(mcpRoot), "plugin.json"));
|
|
533
|
+
var pkg = readJson(path.join(mcpRoot, "package.json"));
|
|
534
|
+
if (!plugin || !pkg) return null;
|
|
535
|
+
return { plugin: plugin, package: pkg, abis: packAbis(mcpRoot, pkg.version, platform, arch) };
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
var VERSION_FOLDER = /^\d+\.\d+\.\d+/;
|
|
539
|
+
|
|
529
540
|
function newestDesk(options) {
|
|
530
541
|
var mcpRoot = options.mcpRoot;
|
|
531
|
-
var
|
|
532
|
-
var
|
|
533
|
-
|
|
534
|
-
var
|
|
542
|
+
var live = readOwn(mcpRoot, options.platform, options.arch);
|
|
543
|
+
var own = live || options.own || null;
|
|
544
|
+
if (!own) return null;
|
|
545
|
+
var ownPlugin = own.plugin;
|
|
546
|
+
var ownPackage = own.package;
|
|
547
|
+
var ownVersion = parseVersion(ownPlugin.version);
|
|
548
|
+
var protocol = ownPackage.toolProtocol;
|
|
535
549
|
if (!ownVersion || typeof protocol !== "number") return null;
|
|
550
|
+
var ownRoot = path.resolve(mcpRoot, "..");
|
|
551
|
+
var folders = [];
|
|
536
552
|
var scanRoot = options.scanRoot;
|
|
537
553
|
if (!scanRoot) {
|
|
538
554
|
var layout = path.resolve(mcpRoot, "..", "..", "..", "..");
|
|
539
555
|
var shape = /^root-\d+$/.test(path.basename(path.resolve(mcpRoot, "..", ".."))) && path.basename(layout) === "sessions";
|
|
540
|
-
if (
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
} catch (error) {
|
|
547
|
-
return null;
|
|
556
|
+
if (shape) scanRoot = layout;
|
|
557
|
+
else if (VERSION_FOLDER.test(path.basename(ownRoot))) {
|
|
558
|
+
listDir(path.dirname(ownRoot)).forEach(function (name) {
|
|
559
|
+
if (VERSION_FOLDER.test(name)) folders.push(path.join(path.dirname(ownRoot), name));
|
|
560
|
+
});
|
|
561
|
+
} else return null;
|
|
548
562
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
var bestVersion = ownVersion;
|
|
552
|
-
sessions.forEach(function (session) {
|
|
553
|
-
var roots;
|
|
563
|
+
if (scanRoot) {
|
|
564
|
+
var sessions;
|
|
554
565
|
try {
|
|
555
|
-
|
|
566
|
+
sessions = fs.readdirSync(scanRoot);
|
|
556
567
|
} catch (error) {
|
|
557
|
-
return;
|
|
568
|
+
return null;
|
|
558
569
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
var engines = either(pkg.engines, {});
|
|
570
|
-
if (typeof engines.node === "string" && !satisfies(options.current.version, engines.node)) return;
|
|
571
|
-
var abis = packAbis(candidateMcp, pkg.version, options.platform, options.arch);
|
|
572
|
-
// A copy that ships a runtime pack must ship one for this Node's ABI when this copy does.
|
|
573
|
-
if (ownAbis.indexOf(String(options.current.abi)) !== -1 && abis.indexOf(String(options.current.abi)) === -1) return;
|
|
574
|
-
best = { indexFile: path.join(candidateMcp, "index.js"), pluginRoot: pluginRoot, version: plugin.version };
|
|
575
|
-
bestVersion = version;
|
|
570
|
+
sessions.forEach(function (session) {
|
|
571
|
+
var roots;
|
|
572
|
+
try {
|
|
573
|
+
roots = fs.readdirSync(path.join(scanRoot, session));
|
|
574
|
+
} catch (error) {
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
roots.forEach(function (root) {
|
|
578
|
+
if (/^root-\d+$/.test(root)) folders.push(path.join(scanRoot, session, root, "desk"));
|
|
579
|
+
});
|
|
576
580
|
});
|
|
581
|
+
}
|
|
582
|
+
var ownAbis = own.abis;
|
|
583
|
+
var best = null;
|
|
584
|
+
var bestVersion = live ? ownVersion : null;
|
|
585
|
+
folders.forEach(function (pluginRoot) {
|
|
586
|
+
var plugin = readJson(path.join(pluginRoot, "plugin.json"));
|
|
587
|
+
if (!plugin || plugin.name !== ownPlugin.name || plugin.repository !== ownPlugin.repository) return;
|
|
588
|
+
var version = parseVersion(plugin.version);
|
|
589
|
+
if (!version || (bestVersion !== null && compareVersions(version, bestVersion) <= 0)) return;
|
|
590
|
+
var candidateMcp = path.join(pluginRoot, "mcp");
|
|
591
|
+
var pkg = readJson(path.join(candidateMcp, "package.json"));
|
|
592
|
+
if (!pkg || pkg.toolProtocol !== protocol || !fs.existsSync(path.join(candidateMcp, "index.js"))) return;
|
|
593
|
+
var engines = either(pkg.engines, {});
|
|
594
|
+
if (typeof engines.node === "string" && !satisfies(options.current.version, engines.node)) return;
|
|
595
|
+
var abis = packAbis(candidateMcp, pkg.version, options.platform, options.arch);
|
|
596
|
+
// A copy that ships a runtime pack must ship one for this Node's ABI when this copy does.
|
|
597
|
+
if (ownAbis.indexOf(String(options.current.abi)) !== -1 && abis.indexOf(String(options.current.abi)) === -1) return;
|
|
598
|
+
best = { indexFile: path.join(candidateMcp, "index.js"), pluginRoot: pluginRoot, version: plugin.version };
|
|
599
|
+
bestVersion = version;
|
|
577
600
|
});
|
|
578
601
|
return best;
|
|
579
602
|
}
|
|
@@ -683,7 +706,9 @@ function start(o, stderr, serve) {
|
|
|
683
706
|
// A host keeps one server per session for days, so this process stays small: it starts the real server on demand and ends it when idle (idle-proxy.cjs). An injected importIndex, or DESK_MCP_IDLE_MS=0, runs index.js in this process instead.
|
|
684
707
|
var proxy = idleMs > 0 && o.importIndex === undefined;
|
|
685
708
|
if (proxy) {
|
|
686
|
-
|
|
709
|
+
// Read while this copy's folder is still there: a host may remove it later, and the copy that replaces it must be the same Desk.
|
|
710
|
+
var ownCopy = readOwn(mcpRoot, platform, either(o.arch, process.arch));
|
|
711
|
+
var proxied = idle.runIdleProxy({ node: current.path, indexFile: indexFile, chooseIndex: function () { return newestDesk({ mcpRoot: mcpRoot, current: current, platform: platform, arch: either(o.arch, process.arch), scanRoot: o.scanRoot, own: ownCopy }); }, exists: fs.existsSync, args: args, env: env, idleMs: idleMs, spawn: o.spawn, stdin: o.stdin, stdout: o.stdout, stderr: stderr, exit: o.exit, signals: o.signals, kill: o.kill, now: o.now, setTimer: o.setTimer, clearTimer: o.clearTimer });
|
|
687
712
|
if (proxied.error !== null) throw proxied.error;
|
|
688
713
|
return new Promise(function () {});
|
|
689
714
|
}
|
|
@@ -736,6 +761,7 @@ module.exports = {
|
|
|
736
761
|
candidatePaths: candidatePaths,
|
|
737
762
|
importIndex: importIndex,
|
|
738
763
|
newestDesk: newestDesk,
|
|
764
|
+
readOwn: readOwn,
|
|
739
765
|
installCommand: installCommand,
|
|
740
766
|
packedMajor: packedMajor,
|
|
741
767
|
packAbis: packAbis,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// A Desk server holds about 200 MB once it has loaded its runtime, its tools and its search index, and a host keeps one per hosted session for days. This proxy is the process the host talks to: it holds none of that. It starts the real server (index.js) as a child, passes the MCP stream through line by line, and when nothing has crossed it for DESK_MCP_IDLE_MS (3 minutes by default) and no call is waiting for an answer, it ends the child, which gives all of that memory back. The next message from the host starts a new child first: the proxy replays the `initialize` handshake the host already sent (the child's answer to that replay is dropped, so the host never sees a second handshake) and then delivers the message.
|
|
4
4
|
//
|
|
5
|
-
// A new child runs the newest compatible installed Desk, not the copy this proxy was installed with (bootstrap.cjs newestDesk), so an idle session follows Desk releases without a restart.
|
|
5
|
+
// A new child runs the newest compatible installed Desk, not the copy this proxy was installed with (bootstrap.cjs newestDesk), so an idle session follows Desk releases without a restart, and a session whose copy a host removed keeps working on the next call.
|
|
6
6
|
//
|
|
7
7
|
// DESK_MCP_IDLE_MS=0 turns the release off: bootstrap.cjs then runs index.js in this process, as before.
|
|
8
8
|
//
|
|
@@ -306,12 +306,19 @@ function createIdleProxy(options) {
|
|
|
306
306
|
// A host that is gone cannot be answered: end like a closed stdin rather than keep a server alive with no client.
|
|
307
307
|
if (options.stdout.on) options.stdout.on("error", onClientEnd);
|
|
308
308
|
if (options.watchParent) options.watchParent(onClientEnd);
|
|
309
|
+
var signalHandlers = {};
|
|
309
310
|
FORWARDED_SIGNALS.forEach(function (signal) {
|
|
310
|
-
|
|
311
|
+
signalHandlers[signal] = function () {
|
|
311
312
|
signalled = true;
|
|
312
|
-
if (child !== null) child.kill(signal);
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
if (child !== null) return child.kill(signal);
|
|
314
|
+
// Stop listening first, so the re-raised signal takes its default action and ends the proxy instead of coming
|
|
315
|
+
// back to this listener, which would raise it again forever.
|
|
316
|
+
FORWARDED_SIGNALS.forEach(function (name) {
|
|
317
|
+
options.signals.removeListener(name, signalHandlers[name]);
|
|
318
|
+
});
|
|
319
|
+
options.kill(process.pid, signal);
|
|
320
|
+
};
|
|
321
|
+
options.signals.on(signal, signalHandlers[signal]);
|
|
315
322
|
});
|
|
316
323
|
options.stdin.resume();
|
|
317
324
|
return start();
|
|
@@ -393,7 +400,8 @@ function runIdleProxy(o) {
|
|
|
393
400
|
}
|
|
394
401
|
if (newest) {
|
|
395
402
|
var ownRoot = path.dirname(path.dirname(o.indexFile));
|
|
396
|
-
|
|
403
|
+
// A root the host set that no longer exists (a pruned version) is replaced too.
|
|
404
|
+
if (!childEnv.DESK_PLUGIN_ROOT || childEnv.DESK_PLUGIN_ROOT === ownRoot || !o.exists(childEnv.DESK_PLUGIN_ROOT)) childEnv.DESK_PLUGIN_ROOT = newest.pluginRoot;
|
|
397
405
|
indexFile = newest.indexFile;
|
|
398
406
|
pick("stderr").write("[desk-mcp] idle proxy: running Desk " + newest.version + " from " + newest.pluginRoot + "\n");
|
|
399
407
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// Without --apply, no member or shared files change; join may fetch missing Git history for its preview.
|
|
7
7
|
// `--repo` defaults to the current folder.
|
|
8
8
|
// `initiative` writes the working tree only; publish the result through the shared-path protocol.
|
|
9
|
-
// Exits 1 when the result is refused, failed, has layout problems or is not a Git clone, and 2 for a usage error (one line on stderr).
|
|
9
|
+
// Exits 1 when the result is refused, failed, has layout problems or the folder is not a Git clone or not a Crew workspace, and 2 for a usage error (one line on stderr).
|
|
10
10
|
|
|
11
11
|
import process from "node:process"
|
|
12
12
|
import { realpathSync } from "node:fs"
|
|
@@ -27,14 +27,14 @@ function founderOf(text) {
|
|
|
27
27
|
return at === -1 ? { alias: text, identity: "" } : { alias: text.slice(0, at), identity: text.slice(at + 1) }
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const FAILED = new Set(["refused", "failed", "not_git", "problems"])
|
|
30
|
+
const FAILED = new Set(["refused", "failed", "not_git", "not_crew", "problems"])
|
|
31
31
|
|
|
32
32
|
function crewCli({ cwd, engine, script }) {
|
|
33
33
|
const command = (name, def, run) => defineCommand({ name, output: "one JSON value", text: (result) => JSON.stringify(result, null, 2), exit: (result) => (FAILED.has(result.state) ? "error" : "ok"), effect: "private", ...def, run })
|
|
34
34
|
const repoOf = (input) => input.repo ?? cwd
|
|
35
35
|
return defineCli({
|
|
36
36
|
name: "crew",
|
|
37
|
-
about: ["Crew workspace setup, one deterministic step at a time. Exits 1 when the result is refused, failed, has layout problems or is not a Git clone."],
|
|
37
|
+
about: ["Crew workspace setup, one deterministic step at a time. Exits 1 when the result is refused, failed, has layout problems, or the folder is not a Git clone or not a Crew workspace."],
|
|
38
38
|
groups: { initiative: "A shared initiative, written to the working tree only; publish the result through the shared-path protocol." },
|
|
39
39
|
commands: [
|
|
40
40
|
// status also says what a Desk session started in the clone binds (`session`), the check a join runs before it delivers.
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
// `releases/<commit>/`, never the checkout another runner may be updating. If GitHub cannot be reached the last published copy runs;
|
|
6
6
|
// with no copy yet, the newest `plugins/desk@release` entry in
|
|
7
7
|
// Agency's plugin cache (`~/.local/agency/plugins/cache/cache_index.json`) or the last path that worked runs. One line is logged
|
|
8
|
-
// to stderr and to resolve.log whenever the fetch or the cache resolution fails
|
|
8
|
+
// to stderr and to resolve.log whenever the fetch or the cache resolution fails, as `<time> <code>: <sentence>` with the code
|
|
9
|
+
// `fetch-failed` or `release-unresolved`; with nothing to run it then exits 1.
|
|
9
10
|
// This file must stay standalone: the installed copy has no neighbours to import.
|
|
10
11
|
import { spawnSync } from "node:child_process"
|
|
11
12
|
import { randomUUID } from "node:crypto"
|
|
@@ -288,8 +289,8 @@ function launchWithLease({ argv, env, home, spawn, git, stderr, execPath, now, d
|
|
|
288
289
|
const cache = env.AGENCY_PLUGIN_CACHE ?? path.join(home, ".local", "agency", "plugins", "cache")
|
|
289
290
|
const lastGood = path.join(dir, "last-good-script")
|
|
290
291
|
const own = path.join(dir, "desk-release")
|
|
291
|
-
const complain = (text) => {
|
|
292
|
-
const line = `${now().toISOString()} ${text}`
|
|
292
|
+
const complain = (code, text) => {
|
|
293
|
+
const line = `${now().toISOString()} ${code}: ${text}`
|
|
293
294
|
stderr.write(`${line}\n`)
|
|
294
295
|
mkdirSync(dir, { recursive: true })
|
|
295
296
|
appendFileSync(path.join(dir, "resolve.log"), `${line}\n`)
|
|
@@ -307,7 +308,7 @@ function launchWithLease({ argv, env, home, spawn, git, stderr, execPath, now, d
|
|
|
307
308
|
let script
|
|
308
309
|
if (copy && existsSync(copy.script)) {
|
|
309
310
|
script = copy.script
|
|
310
|
-
if (fetchError) complain(`could not fetch the released Desk (${fetchError}); using the copy from ${release.slice(0, 8)}`)
|
|
311
|
+
if (fetchError) complain("fetch-failed", `could not fetch the released Desk (${fetchError}); using the copy from ${release.slice(0, 8)}`)
|
|
311
312
|
} else {
|
|
312
313
|
release = null
|
|
313
314
|
try {
|
|
@@ -318,7 +319,7 @@ function launchWithLease({ argv, env, home, spawn, git, stderr, execPath, now, d
|
|
|
318
319
|
}
|
|
319
320
|
} catch (error) {
|
|
320
321
|
script = existsSync(lastGood) ? readFileSync(lastGood, "utf8").trim() : null
|
|
321
|
-
complain(`could not resolve the released Desk (${fetchError ? `${fetchError}; ` : ""}${error.message}); ${script ? `using the last good path ${script}` : "no last good path"}`)
|
|
322
|
+
complain("release-unresolved", `could not resolve the released Desk (${fetchError ? `${fetchError}; ` : ""}${error.message}); ${script ? `using the last good path ${script}` : "no last good path"}`)
|
|
322
323
|
if (!script || !existsSync(script)) return 1
|
|
323
324
|
}
|
|
324
325
|
}
|
|
@@ -461,7 +461,11 @@ export async function runJobLinkCommand({ store, "desk-remote": deskRemote, trac
|
|
|
461
461
|
slug = birth.slug
|
|
462
462
|
}
|
|
463
463
|
// A bad store fails with the usage error before any state is read.
|
|
464
|
-
|
|
464
|
+
try {
|
|
465
|
+
jobReportUrl({ store, job: "0".repeat(32) })
|
|
466
|
+
} catch (error) {
|
|
467
|
+
throw usageError("job-link", error.message, "factory job-link --store <owner/repo> ...")
|
|
468
|
+
}
|
|
465
469
|
const job = jobId({ deskRemote, personPrefix, track, slug })
|
|
466
470
|
const published = publishedJobId({ env, deskRemote, job })
|
|
467
471
|
if (thisMachine) return thisMachineLink({ env, store, job, published })
|
|
@@ -604,6 +608,11 @@ const JOB_FLAG = { type: "string", required: true, placeholder: "<job>", descrip
|
|
|
604
608
|
const ISSUE_FLAGS = { store: { type: "string", required: true, placeholder: "<directory>", description: "The checked-out store." }, repo: { type: "string", required: true, placeholder: "<owner/repo>", description: "The store's owner/repo." }, author: { type: "string", placeholder: "<login>", description: "The bot login whose comments are the build's own." } }
|
|
605
609
|
const text = (result) => JSON.stringify(result)
|
|
606
610
|
const exitFor = (ok) => (ok ? "ok" : "error")
|
|
611
|
+
// A result that did nothing because the machine has not opted in, or because another process holds the lock, is a refusal: exit 1 so a caller
|
|
612
|
+
// that checks the status can tell it from work done. A finalize result is refused when any of its jobs was.
|
|
613
|
+
const REFUSED_RESULTS = new Set(["not_opted_in", "locked", "busy"])
|
|
614
|
+
const refusedOne = (result) => Object(result).ok === false || REFUSED_RESULTS.has(Object(result).result)
|
|
615
|
+
export const outcome = (result) => exitFor(!(refusedOne(result) || Object.values(Object(Object(result).jobs)).some(refusedOne)))
|
|
607
616
|
const noFailures = (result) => exitFor(!(Object(result).failed > 0))
|
|
608
617
|
|
|
609
618
|
/** The commands defined with Ouro AX; each prints one JSON value on one line, and a refusal exits 1. */
|
|
@@ -616,19 +625,19 @@ function factoryCli({ env, cwd, git, runner }) {
|
|
|
616
625
|
commands: [
|
|
617
626
|
command("account", { summary: "Name the signed-in GitHub account that can open intake pull requests on the store.", readOnly: true, flags: { store: STORE }, exit: (r) => exitFor(r.result === "account_found") }, runAccountCommand),
|
|
618
627
|
command("consent", { summary: "Record whether this machine contributes to the store.", flags: { store: STORE, contribute: { type: "enum", values: ["yes", "no"], required: true, description: "Whether to contribute." }, account: { type: "string", placeholder: "<gh login>", description: "The GitHub account to deliver with." } } }, runConsentCommand),
|
|
619
|
-
command("derive", { summary: "Derive facts from one marker file (the detached worker).", flags: { marker: { type: "string", required: true, placeholder: "<file>", description: "The marker file." }, "wait-quiet": { type: "number", min: 0, max: 30000, placeholder: "<milliseconds>", description: "How long to wait for the session to go quiet first." } } }, runDeriveCommand),
|
|
628
|
+
command("derive", { summary: "Derive facts from one marker file (the detached worker).", flags: { marker: { type: "string", required: true, placeholder: "<file>", description: "The marker file." }, "wait-quiet": { type: "number", min: 0, max: 30000, placeholder: "<milliseconds>", description: "How long to wait for the session to go quiet first." } }, exit: outcome }, runDeriveCommand),
|
|
620
629
|
command("status", { summary: "Print the factory's local status and maintain existing state; do not enable an uninitialized factory." }, runStatusCommand),
|
|
621
|
-
command("flush", { summary: "Make one delivery attempt to the store.", flags: { store: STORE } }, runFlushCommand),
|
|
630
|
+
command("flush", { summary: "Make one delivery attempt to the store.", flags: { store: STORE }, exit: outcome }, runFlushCommand),
|
|
622
631
|
command("context-request", { summary: "Request the task context of one existing job, as the operator.", flags: { store: STORE, job: { ...JOB_FLAG, placeholder: "<public job id>" } }, exit: (r) => exitFor(r.ok !== false) }, runContextRequestCommand),
|
|
623
|
-
command("finalize", { summary: "Finalize up to eight finished jobs, then start the loop worker when its step is due.", flags: { job: { ...JOB_FLAG, repeat: true } } }, runFinalizeCommand),
|
|
632
|
+
command("finalize", { summary: "Finalize up to eight finished jobs, then start the loop worker when its step is due.", flags: { job: { ...JOB_FLAG, repeat: true } }, exit: outcome }, runFinalizeCommand),
|
|
624
633
|
command("build", { summary: "Build the store's reports.", flags: { store: { type: "string", required: true, placeholder: "<directory>", description: "The checked-out store." }, out: { type: "string", required: true, placeholder: "<directory>", description: "Where to write the build." } } }, runBuildCommand),
|
|
625
634
|
command("evaluate-accept", { summary: "Check what the evaluator wrote for a job and move accepted labels into the outbox.", flags: { job: JOB_FLAG } }, runEvaluateAcceptCommand),
|
|
626
|
-
command("evaluate", { summary: "Record a job's evaluation request and prepare its briefs; --pending prepares every retained request again.", flags: { desk: { type: "string", placeholder: "<absolute desk root>", description: "The desk." }, task: { type: "string", placeholder: "<track>/<slug>", description: "The task, as [desks/<alias>/]<track>/<slug>." }, pending: { type: "boolean", description: "Prepare every retained request again." } } }, runEvaluateCommand),
|
|
635
|
+
command("evaluate", { summary: "Record a job's evaluation request and prepare its briefs; --pending prepares every retained request again.", flags: { desk: { type: "string", placeholder: "<absolute desk root>", description: "The desk." }, task: { type: "string", placeholder: "<track>/<slug>", description: "The task, as [desks/<alias>/]<track>/<slug>." }, pending: { type: "boolean", description: "Prepare every retained request again." } }, exit: outcome }, runEvaluateCommand),
|
|
627
636
|
command("job-link", { summary: "Print the keyed link of a job in the store (private).", readOnly: true, flags: { store: STORE, "desk-remote": { type: "string", required: true, placeholder: "<url>", description: "The desk's remote." }, track: { type: "string", required: true, placeholder: "<track>", description: "The track." }, slug: { type: "string", required: true, placeholder: "<slug>", description: "The task slug." }, "person-prefix": { type: "string", placeholder: "<prefix>", description: "The person prefix, desks/<alias>." }, desk: { type: "string", placeholder: "<desk root>", description: "The desk, to follow a renamed task." }, "this-machine": { type: "boolean", description: "Print only this machine's own link." } } }, runJobLinkCommand),
|
|
628
637
|
command("kaizen-check", { summary: "Run the kaizen check on every open card of the store.", flags: ISSUE_FLAGS, exit: noFailures }, runKaizenCheckCommand),
|
|
629
638
|
command("andon", { summary: "Open, update, reopen and close the store's andon issues.", flags: ISSUE_FLAGS, exit: noFailures }, runAndonCommand),
|
|
630
639
|
command("reconcile", { summary: "Reconcile a desk's sessions against the store for a time window.", readOnly: true, flags: { desk: { type: "string", required: true, placeholder: "<absolute desk root>", description: "The desk." }, since: { type: "string", required: true, placeholder: "<iso>", description: "Window start, a UTC timestamp." }, until: { type: "string", required: true, placeholder: "<iso>", description: "Window end, a UTC timestamp." }, store: { type: "string", placeholder: "<directory>", description: "The store checkout." }, "person-prefix": { type: "string", placeholder: "desks/<alias>", description: "The person prefix." } }, exit: (r) => exitFor(r.ok !== false) }, runReconcileCommand),
|
|
631
|
-
command("loop", { summary: "Run the improvement steps once for the desk and person given.", flags: { desk: { type: "string", placeholder: "<absolute desk root>", description: "The desk." }, "person-prefix": { type: "string", placeholder: "desks/<alias>", description: "The person prefix." } } }, runLoopCommand),
|
|
640
|
+
command("loop", { summary: "Run the improvement steps once for the desk and person given.", flags: { desk: { type: "string", placeholder: "<absolute desk root>", description: "The desk." }, "person-prefix": { type: "string", placeholder: "desks/<alias>", description: "The person prefix." } }, exit: outcome }, runLoopCommand),
|
|
632
641
|
command("validate-pr", { summary: "Validate a store pull request against the facts its merge would leave.", readOnly: true, flags: { base: { type: "string", required: true, placeholder: "<base sha>", description: "The base commit." }, head: { type: "string", required: true, placeholder: "<head sha>", description: "The pull request head commit." }, "author-association": { type: "string", required: true, placeholder: "<value>", description: "The author's association, such as NONE or OWNER." }, repo: { type: "string", placeholder: "<owner/repo>", description: "The store, to read the triage actor." }, pr: { type: "string", placeholder: "<number>", description: "The pull request number." } }, exit: (r) => exitFor(r.ok !== false) }, runValidatePrCommand),
|
|
633
642
|
command("proof", { summary: "Mark an existing local session as a controlled proof.", args: [{ name: "session", required: true, description: "The session id." }], flags: { desk: { type: "string", placeholder: "<absolute desk root>", description: "The desk the session belongs to." } }, exit: (r) => exitFor(["marked", "already_proof"].includes(r.result)) }, runProofCommand),
|
|
634
643
|
],
|