@sjawhar/pi-legion 19.19.0 → 19.20.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/legion.js +64 -13
- package/dist/skills/legion-architect/references/decomposition.md +3 -2
- package/dist/skills/legion-oracle/SKILL.md +1 -1
- package/dist/skills/legion-worker/SKILL.md +2 -2
- package/dist/skills/legion-worker/references/default-branch-check.md +35 -19
- package/dist/skills/legion-worker/references/foreign-path.md +3 -1
- package/dist/skills/legion-worker/references/merge-gate.md +2 -2
- package/package.json +1 -1
package/dist/legion.js
CHANGED
|
@@ -28511,6 +28511,12 @@ var ATTRIBUTION_OVERLAY = /^omp-attribution-.*\.toml$/;
|
|
|
28511
28511
|
var ISSUE_KEY2 = /^[A-Z][A-Z0-9]{1,9}-[0-9]+$/;
|
|
28512
28512
|
var FIRST_RAW_CODE = 32;
|
|
28513
28513
|
var DEL_CODE = 127;
|
|
28514
|
+
var CONTROLLER_ROLE = "controller";
|
|
28515
|
+
var JJ_REVERT_PARTS = [
|
|
28516
|
+
`'Revert "' ++ description.first_line() ++ '"' ++ "\\n"`,
|
|
28517
|
+
`"\\n"`,
|
|
28518
|
+
`"This reverts commit " ++ commit_id ++ ".\\n"`
|
|
28519
|
+
];
|
|
28514
28520
|
function sessionIdFromTranscript(sessionFile) {
|
|
28515
28521
|
return TOP_LEVEL_TRANSCRIPT.exec(path4.basename(sessionFile))?.[1];
|
|
28516
28522
|
}
|
|
@@ -28531,6 +28537,52 @@ function tomlBasicString(workspace) {
|
|
|
28531
28537
|
}
|
|
28532
28538
|
return `"${workspace.replaceAll("\\", "\\\\").replaceAll('"', "\\\"")}"`;
|
|
28533
28539
|
}
|
|
28540
|
+
function isTrailerRole(role) {
|
|
28541
|
+
return role !== undefined && (isLegionRole(role) || role === CONTROLLER_ROLE);
|
|
28542
|
+
}
|
|
28543
|
+
function commitTrailers(trailers) {
|
|
28544
|
+
return `commit_trailers = '"${trailers.map(([key, value]) => `${key}: ${value}`).join("\\n")}"'
|
|
28545
|
+
`;
|
|
28546
|
+
}
|
|
28547
|
+
function templatesTable(pair) {
|
|
28548
|
+
const revert = [
|
|
28549
|
+
...JJ_REVERT_PARTS,
|
|
28550
|
+
`"\\n"`,
|
|
28551
|
+
...pair.map(([key, value]) => `"${key}: ${value}\\n"`)
|
|
28552
|
+
];
|
|
28553
|
+
const missing = pair.map(([key, value]) => {
|
|
28554
|
+
const held = `trailers.any(|t| t.key() == "${key}" && t.value() == "${value}")`;
|
|
28555
|
+
return ` if(!${held}, "${key}: ${value}\\n"),
|
|
28556
|
+
`;
|
|
28557
|
+
});
|
|
28558
|
+
return `[templates]
|
|
28559
|
+
` + commitTrailers(pair) + `revert_description = '''
|
|
28560
|
+
concat(
|
|
28561
|
+
${revert.map((part) => ` ${part},
|
|
28562
|
+
`).join("")})
|
|
28563
|
+
'''
|
|
28564
|
+
` + `duplicate_description = '''
|
|
28565
|
+
concat(
|
|
28566
|
+
description,
|
|
28567
|
+
if(description, concat(
|
|
28568
|
+
` + ` if(!trailers, "\\n"),
|
|
28569
|
+
${missing.join("")} )),
|
|
28570
|
+
)
|
|
28571
|
+
'''
|
|
28572
|
+
`;
|
|
28573
|
+
}
|
|
28574
|
+
function scopeTable(pair, issueKey, workspace) {
|
|
28575
|
+
if (issueKey === undefined || !ISSUE_KEY2.test(issueKey) || !workspace)
|
|
28576
|
+
return "";
|
|
28577
|
+
const scopedTo = tomlBasicString(workspace);
|
|
28578
|
+
if (scopedTo === undefined)
|
|
28579
|
+
return "";
|
|
28580
|
+
return `
|
|
28581
|
+
[[--scope]]
|
|
28582
|
+
--when.workspaces = [${scopedTo}]
|
|
28583
|
+
[--scope.templates]
|
|
28584
|
+
` + commitTrailers([...pair, ["Dispatch", issueKey]]);
|
|
28585
|
+
}
|
|
28534
28586
|
function withoutOverlays(chain) {
|
|
28535
28587
|
return chain.split(":").filter((entry) => entry && !ATTRIBUTION_OVERLAY.test(path4.basename(entry))).join(":");
|
|
28536
28588
|
}
|
|
@@ -28577,7 +28629,7 @@ async function userConfigChain(timeoutMs = JJ_CONFIG_PATH_TIMEOUT_MS, env = proc
|
|
|
28577
28629
|
}
|
|
28578
28630
|
}
|
|
28579
28631
|
async function exportJjSessionAttribution(sessionId, stateDir, options = {}) {
|
|
28580
|
-
const { issueKey, workspace, env = process.env, resolveBase = userConfigChain } = options;
|
|
28632
|
+
const { issueKey, workspace, role, env = process.env, resolveBase = userConfigChain } = options;
|
|
28581
28633
|
if (!SESSION_ID_PATH_SEGMENT.test(sessionId))
|
|
28582
28634
|
return;
|
|
28583
28635
|
const overlay = path4.join(stateDir, `omp-attribution-${sessionId}.toml`);
|
|
@@ -28587,16 +28639,10 @@ async function exportJjSessionAttribution(sessionId, stateDir, options = {}) {
|
|
|
28587
28639
|
const base = (active ? withoutOverlays(active) : "") || await resolveBase();
|
|
28588
28640
|
if (!base)
|
|
28589
28641
|
return;
|
|
28590
|
-
const
|
|
28591
|
-
|
|
28592
|
-
|
|
28593
|
-
|
|
28594
|
-
` + (scopedTo === undefined ? "" : `
|
|
28595
|
-
[[--scope]]
|
|
28596
|
-
--when.workspaces = [${scopedTo}]
|
|
28597
|
-
[--scope.templates]
|
|
28598
|
-
` + `commit_trailers = '"${sessionTrailer}\\nDispatch: ${issueKey}"'
|
|
28599
|
-
`);
|
|
28642
|
+
const pair = [["Omp-Session", sessionId]];
|
|
28643
|
+
if (isTrailerRole(role))
|
|
28644
|
+
pair.push(["Legion-Role", role]);
|
|
28645
|
+
const contents = templatesTable(pair) + scopeTable(pair, issueKey, workspace);
|
|
28600
28646
|
try {
|
|
28601
28647
|
await mkdir(stateDir, { recursive: true });
|
|
28602
28648
|
const tmp = `${overlay}.${process.pid}.tmp`;
|
|
@@ -28613,7 +28659,12 @@ commit_trailers = '"${sessionTrailer}"'
|
|
|
28613
28659
|
function paneAttributionOptions(env) {
|
|
28614
28660
|
const issueKey = env["LEGION_ISSUE_TRAILER"];
|
|
28615
28661
|
const workspace = resolvedWorkspace(env["LEGION_WORKSPACE"]);
|
|
28616
|
-
|
|
28662
|
+
const role = env["LEGION_ROLE"];
|
|
28663
|
+
return {
|
|
28664
|
+
...issueKey ? { issueKey } : {},
|
|
28665
|
+
...workspace ? { workspace } : {},
|
|
28666
|
+
...isTrailerRole(role) ? { role } : {}
|
|
28667
|
+
};
|
|
28617
28668
|
}
|
|
28618
28669
|
|
|
28619
28670
|
// ../pi-shared/src/legion-claim-core.ts
|
|
@@ -28712,7 +28763,7 @@ import { logger as logger3 } from "@oh-my-pi/pi-utils";
|
|
|
28712
28763
|
// package.json
|
|
28713
28764
|
var package_default = {
|
|
28714
28765
|
name: "@sjawhar/pi-legion",
|
|
28715
|
-
version: "19.
|
|
28766
|
+
version: "19.20.0",
|
|
28716
28767
|
license: "Apache-2.0",
|
|
28717
28768
|
type: "module",
|
|
28718
28769
|
omp: {
|
|
@@ -149,8 +149,9 @@ nothing.
|
|
|
149
149
|
When every change of the tree lands through its children, the root's branch has no commit of its
|
|
150
150
|
own, and GitHub opens no pull request for a branch with no commits ahead of its base: implementing
|
|
151
151
|
would never end. The root's implementer then pushes one empty commit
|
|
152
|
-
(`jj new -m '<KEY>: the root of its children; no code of its own'
|
|
153
|
-
pull request on it, as its role prompt says; that push starts the required checks
|
|
152
|
+
(`jj new -m '<KEY>: the root of its children; no code of its own'`), writes no trailer itself,
|
|
153
|
+
and opens the pull request on it, as its role prompt says; that push starts the required checks
|
|
154
|
+
like any other.
|
|
154
155
|
Plan no code for the root in that case, and do not create a child only to give the root a commit.
|
|
155
156
|
|
|
156
157
|
## Architecture components
|
|
@@ -38,7 +38,7 @@ answer from what came back, never from the dispatch.
|
|
|
38
38
|
| 3. Framework docs | `web_search`, then `read` the library's official docs page | [library] docs [topic] |
|
|
39
39
|
| 4. External practices | `web_search`, then `read` what the tool's or standard's maintainer publishes (docs, RFC, changelog); give its URL | current practice for [topic] |
|
|
40
40
|
|
|
41
|
-
Before you rely on a step 1 hit, `grep` `docs/solutions/` for its path. If another file lists that path under its front-matter `supersedes:` key (on that line or as a list item below it), use that file instead; if one has a line `Extends docs/solutions/<hit path>`, read both. Nothing else reconciles these links.
|
|
41
|
+
Before you rely on a step 1 hit, `grep` `docs/solutions/` for its path. If another file lists that path under its front-matter `supersedes:` key (on that line or as a list item below it), use that file instead; if one has a line `Extends docs/solutions/<hit path>`, read both. The "Documentation" section of the repository's `AGENTS.md` names the pages whose rule a later rule replaces: for a hit on one of them, follow the rule that section names. Nothing else reconciles these links.
|
|
42
42
|
|
|
43
43
|
## Output
|
|
44
44
|
|
|
@@ -39,7 +39,7 @@ Read each by its `skill://` link: a read by path stops at 300 lines.
|
|
|
39
39
|
| --- | --- |
|
|
40
40
|
| Before the turn's first `jj new` or commit, in a workspace you share | `skill://legion-worker/references/foreign-path.md` |
|
|
41
41
|
| You write or edit the PR body, record a result against a check, read another phase's results, or run the simplify pass | `skill://legion-worker/references/pr-body.md` |
|
|
42
|
-
| Before a push, to check your commits'
|
|
42
|
+
| Before a push, to check your commits' trailers | `skill://legion-worker/references/default-branch-check.md` |
|
|
43
43
|
| You reply on, list or resolve review threads, or judge a bot's finding | `skill://legion-worker/references/review-threads.md` |
|
|
44
44
|
| A conflict, a need only the base meets, a retarget, a parent's last round, comparing heads after a forward merge, a push refused after the handoff import moved the branch, or rewriting a pushed commit | `skill://legion-worker/references/conflicts-and-rewrites.md` |
|
|
45
45
|
| You review or approve, merge the pull request, or take a look of a closed issue's production check | `skill://legion-worker/references/merge-gate.md` |
|
|
@@ -51,7 +51,7 @@ Read each by its `skill://` link: a read by path stops at 300 lines.
|
|
|
51
51
|
|
|
52
52
|
## Every role pushes its own commits
|
|
53
53
|
|
|
54
|
-
- Before a push, run the
|
|
54
|
+
- Before a push, run the trailer check (`skill://legion-worker/references/default-branch-check.md`) and then, with the `$default` it set, read your branch's own commit messages: `jj -R "$LEGION_WORKSPACE" log -r "${default}@origin..@" -T 'description ++ "\n"'` — earlier phases' commits in it are expected; never `ancestors(@, 5)`, which stops at five where one measurement found branches of 12 and 28 commits, and never `description.first_line()`, which shows no trailer. Invent no trailer of your own: the pane's jj appends `Omp-Session:` and `Legion-Role:` to every commit the pane's shell makes, in any jj repository, and, for a repository the deployment names, the issue line `Dispatch: <KEY>` beside them, that one scoped to the pane's own workspace. A `git commit` gets the same two lines, and no issue line, from the git wrapper. A jj repository you clone or create under that workspace is stamped like the workspace, so a commit you make in one carries this deployment's issue key: clone a repository you will push elsewhere outside `$LEGION_WORKSPACE`, and push no commit made under it to a repository that takes no issue key. Four kinds of commit get none of these lines added: one that another process made outside the pane's shell with no overlay, one that a git command made without `git commit` (a merge, a revert, a cherry-pick, a rebase), a `git commit` where the git whose version the wrapper reads is older than 2.32 (the first git with `git commit --trailer`; cybermonklabs/legion `docs/deployment.md` says which git that is), and, on the Claude harness, a jj commit of a subagent's bash that lacks the session's environment file (anthropics/claude-code#46696, which `packages/claude-envoy/hooks/session-hook.ts` records and ships a `dispatch` fallback for, though one measurement on the pinned release found those exports present there). That subagent's `git commit` still carries the role line. A commit of yours that shows a line short is cured by describing it again, since the trailers are appended when a description is set. A re-describe appends the issue line only where the shell it runs in has the pane's jj config overlay, so it adds nothing in a shell that carries none — a subagent's bash, or a pane whose overlay the writer could not make. Where it adds nothing, write the line yourself: put `Dispatch: $LEGION_ISSUE_TRAILER` into the description as a trailer line of its own, and only when `LEGION_ISSUE_TRAILER` is set, since that variable is the deployment's own name for the key this repository takes, and an unset one means the repository takes no key and the line belongs in no commit of it. Look because a base branch can require the issue line in the commit that lands: a squash builds that message from the branch's commit messages, and it leaves a merge commit's message out, so the line belongs in an ordinary commit.
|
|
55
55
|
- Only work is pushed: code, red tests, a forward merge, a rewrite, and the empty commit that carries the pull request onto the commit you pushed (the bullet below). No commit message carries a line or bracket keyword that stops GitHub's workflows (`[skip ci]` and its kin), since every head needs its own checks and a base that requires a check will not merge a head whose checks never ran. Retro pushes nothing: it records what the work taught with `dispatch comment` on the issue.
|
|
56
56
|
- **After a push, read the pull request's head and check that it is your commit.** A branch and a pull request are two objects on GitHub: the push moves the branch, and GitHub then moves the pull request onto the new commit, which is what starts its checks, and a push GitHub does not follow leaves the newer commit with no checks while Legion reads and tests the older one. The step applies once the branch has an open pull request, whose number your task's `Pull request:` line names (`gh pr list --repo <the issue's repository> --head legion/<KEY> --state open --json number --jq '.[0].number'` when it names none): run `gh pr view <n> --repo <the issue's repository> --json headRefOid --jq .headRefOid` about ten seconds after your push, again about ten seconds later, and a last time about thirty seconds after that, with a read that gives the pushed commit ending the step there and only the last read deciding a mismatch, and compare each answer with the commit you pushed, which `jj -R "$LEGION_WORKSPACE" log -r legion/<KEY>@origin --no-graph -T commit_id` prints in the 40 characters `headRefOid` answers in. This read is of the pull request's own head and of no check, so the wait it makes is not a wait on CI (`skill://legion-worker/references/pr-body.md#never-waiting-on-ci`). When the last read still is not your commit, carry the pull request with a commit of its own, an empty one when your work is complete and an empty one just as much when `@` holds work of yours, since a push of a commit the branch already holds moves no ref; the push section of your role prompt gives the one `jj` recipe, which leaves `@` and everything in it where it is. A new head is a different commit, so record each `before_merge` check again at the new head. A check carrying `ci_check` is CI's, so skip it. When that second push does not carry the pull request either, tell your architect the commit you pushed, the head each read gave and the time of each, and end the turn with a WAITING line naming that answer rather than completing: a phase completed here hands the next role a commit the pull request does not name. The push you make to answer an update message is the exception: that message has you answer the daemon and end the turn at once, so make this read in your next turn, before your phase completes. The merger pushes nothing, so this step never falls to it; it reports a mismatch it sees to the architect.
|
|
57
57
|
- A planner whose issue moved back from implementing starts on the remote tip, `jj -R "$LEGION_WORKSPACE" new legion/<KEY>@origin`, so a commit it makes never sits on the implementer's unpushed commits.
|
|
@@ -23,7 +23,12 @@ the architect; GitHub's live default branch and the one your record carries are
|
|
|
23
23
|
guessing which is right is not yours to do. When they agree, use `$default` as-is, never re-typed:
|
|
24
24
|
|
|
25
25
|
```sh
|
|
26
|
-
jj -R "$LEGION_WORKSPACE" log -r "${default}@origin..@" -T '
|
|
26
|
+
jj -R "$LEGION_WORKSPACE" log --no-graph -r "${default}@origin..@" -T '
|
|
27
|
+
commit_id.short() ++ " "
|
|
28
|
+
++ if(!author.email(), "(no author) ") ++ if(!committer.email(), "(no committer) ")
|
|
29
|
+
++ description.first_line() ++ "\n"
|
|
30
|
+
++ trailers.filter(|t| t.key() == "Omp-Session" || t.key() == "Legion-Role")
|
|
31
|
+
.map(|t| " " ++ t.key() ++ ": " ++ t.value() ++ "\n").join("")'
|
|
27
32
|
```
|
|
28
33
|
|
|
29
34
|
Because `$default` already carries its own quote characters, jj's revset parser reads
|
|
@@ -33,21 +38,32 @@ syntax or shell code. Bash's own `"${default}@origin..@"` substitutes `$default`
|
|
|
33
38
|
literally; it never re-evaluates the substituted text, so a `$(…)` sequence inside the branch name
|
|
34
39
|
never runs.
|
|
35
40
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
`
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
For each commit, the command prints its short commit id, `(no author)` or `(no committer)` where
|
|
42
|
+
that email is empty, and its first line. Under that line it prints the commit's `Omp-Session` and
|
|
43
|
+
`Legion-Role` trailers, one indented `key: value` line each.
|
|
44
|
+
|
|
45
|
+
Every commit you made must show `Omp-Session` with your session and `Legion-Role` with your
|
|
46
|
+
`LEGION_ROLE`. Check your own commits, not the whole list: earlier phases' commits are in the list
|
|
47
|
+
too, and each carries the lines of its own role.
|
|
48
|
+
|
|
49
|
+
## What the lines must show, and what to do when they do not
|
|
50
|
+
|
|
51
|
+
- Your session is `DISPATCH_SESSION_ID` under Oh My Pi and `CLAUDE_CODE_SESSION_ID` under Claude
|
|
52
|
+
Code. A jj commit's `Omp-Session` line names the session your pane registered: the id in the
|
|
53
|
+
name of the `omp-attribution-<id>.toml` file at the end of `JJ_CONFIG`
|
|
54
|
+
(`printf '%s\n' "${JJ_CONFIG##*:}"` prints that file's path). That id differs from
|
|
55
|
+
`DISPATCH_SESSION_ID` only after a session switch or a fork.
|
|
56
|
+
- A commit of yours that shows a line short is cured as `skill://legion-worker` says, in "Every
|
|
57
|
+
role pushes its own commits".
|
|
58
|
+
- A commit of yours that shows another session or another role: send the architect this log.
|
|
59
|
+
- The git author and committer name no role, so do not compare them. The troubleshooting section
|
|
60
|
+
on which role made a commit says why (cybermonklabs/legion
|
|
61
|
+
`docs/site/src/content/docs/legion/troubleshooting.md`).
|
|
62
|
+
- A commit that shows `(no author)` or `(no committer)` is one that `jj git push` refuses: send
|
|
63
|
+
the architect this log.
|
|
64
|
+
- Never set `user.name`, `user.email`, `templates.commit_trailers`,
|
|
65
|
+
`templates.revert_description`, `templates.duplicate_description` or any `trailer.*` key in any
|
|
66
|
+
jj or Git scope (`jj config set`, `--config`, `git config`). The repository-scoped jj config is
|
|
67
|
+
one file that every workspace of the clone shares, and a `templates.commit_trailers` there
|
|
68
|
+
replaces the overlay's trailers. A `trailer.*` key in Git's config changes how git writes the
|
|
69
|
+
git wrapper's lines.
|
|
@@ -18,7 +18,9 @@ A path you did not write in the first list:
|
|
|
18
18
|
|
|
19
19
|
No `jj new` first: the push carries that path unless its parent has no description. This split is
|
|
20
20
|
the one exception to "Never `jj describe` or `jj split` the working-copy commit you found at the
|
|
21
|
-
turn's start",
|
|
21
|
+
turn's start", because its `-m` writes your trailers on the commit that holds your paths. The
|
|
22
|
+
metaedit fills the author when the found commit has none: `jj git push` refuses a commit with no
|
|
23
|
+
author. Always `-m`, or your commit has no message of yours.
|
|
22
24
|
The remainder keeps that path, and the push above moves the bookmark's commit alone, so it stays
|
|
23
25
|
out of the branch. Never put the bookmark on the remainder, described or not: measured, that
|
|
24
26
|
pushes the other role's file. Read the first list again, then tell the architect what it held.
|
|
@@ -200,8 +200,8 @@ it there until that answer comes clean.
|
|
|
200
200
|
every step below names that `headRefOid`:
|
|
201
201
|
- *The message, before the merge.* GitHub's default squash message,
|
|
202
202
|
`squash_merge_commit_message` of `COMMIT_MESSAGES`, joins every commit message of the pull
|
|
203
|
-
request, which puts the tree's `Dispatch:` keys and its `Omp-Session:`
|
|
204
|
-
default branch. So the merger writes the message itself,
|
|
203
|
+
request, which puts the tree's `Dispatch:` keys and its `Omp-Session:` and `Legion-Role:`
|
|
204
|
+
trailers on the default branch. So the merger writes the message itself,
|
|
205
205
|
`--subject '<pull request title> (#<n>)' --body ''`, on every merge, whatever the repository's
|
|
206
206
|
setting says. It reads that setting first all the same
|
|
207
207
|
(`gh api "repos/<o>/<r>" --jq '[.squash_merge_commit_title, .squash_merge_commit_message] | @tsv'`),
|