@erclx/canon 5.11.0 → 5.12.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.
Files changed (34) hide show
  1. package/claude/.claude-plugin/plugin.json +1 -1
  2. package/claude/skills/auto-ship/REQUIREMENT.md +1 -0
  3. package/claude/skills/auto-ship/SKILL.md +5 -8
  4. package/claude/skills/auto-ship/references/failure-recovery.md +0 -1
  5. package/claude/skills/auto-ship/references/ui-checklist.md +21 -0
  6. package/claude/skills/git-pr/references/evidence.md +7 -7
  7. package/claude/skills/git-ship/REQUIREMENT.md +1 -1
  8. package/claude/skills/git-ship/SKILL.md +1 -1
  9. package/claude/skills/review-craft/references/ui.md +1 -2
  10. package/claude/skills/review-pr/SKILL.md +1 -1
  11. package/claude/skills/ui-checklist/SKILL.md +1 -18
  12. package/docs/agents/gate.md +1 -1
  13. package/docs/agents/hooks.md +2 -0
  14. package/docs/agents/install-and-sync.md +2 -2
  15. package/docs/agents/pr-evidence.md +26 -25
  16. package/docs/agents/tasks-validate.md +3 -3
  17. package/docs/target/migrations.md +1 -1
  18. package/docs/workflow/ai-workflow.md +2 -1
  19. package/docs/workflow/parallel-features.md +3 -3
  20. package/package.json +3 -4
  21. package/scripts/lib/sandbox-path.sh +1 -1
  22. package/src/commands/pr.ts +16 -14
  23. package/src/gate/stages.ts +10 -2
  24. package/src/tasks/validate.ts +37 -27
  25. package/standards/tasks.md +1 -1
  26. package/tooling/base/configs/.husky/post-merge +30 -77
  27. package/tooling/base/configs/.husky/post-rewrite +3 -3
  28. package/tooling/base/reference.md +1 -1
  29. package/scripts/core/clean.sh +0 -36
  30. package/scripts/core/regen-agent-fixture.sh +0 -235
  31. package/scripts/core/regen-claude-copies.sh +0 -10
  32. package/scripts/core/regen-indexes.sh +0 -10
  33. package/scripts/core/snapshot.sh +0 -134
  34. package/scripts/core/update.sh +0 -35
@@ -6,7 +6,6 @@ import {
6
6
  declinedDir,
7
7
  isReservedStem,
8
8
  readOutcomes,
9
- readPlanTarget,
10
9
  readPlanTargets,
11
10
  readPullRequest,
12
11
  resolveLivePlan,
@@ -731,11 +730,8 @@ async function planDisagreement(
731
730
  if (!existsSync(file)) return undefined
732
731
 
733
732
  const text = await readFile(file, 'utf8')
734
- const target = readPlanTarget(text)
735
- if (!target) {
736
- const several = severalPlans(text, 'Run now', subject)
737
- if (several) return several
738
-
733
+ const targets = readPlanTargets(text)
734
+ if (targets.length === 0) {
739
735
  return {
740
736
  kind: 'plan-uncited',
741
737
  group: 'Run now',
@@ -744,15 +740,22 @@ async function planDisagreement(
744
740
  }
745
741
  }
746
742
 
743
+ const twice = duplicatePlans(targets, 'Run now', subject, dir, root)
744
+ if (twice) return twice
745
+
747
746
  const rowed = planPath(row.plan, dir, root)
748
- const cited = planPath(target, dir, root)
749
- if (rowed === cited) return undefined
747
+ if (targets.some((target) => planPath(target, dir, root) === rowed)) {
748
+ return undefined
749
+ }
750
750
 
751
751
  return {
752
752
  kind: 'plan-mismatched',
753
753
  group: 'Run now',
754
754
  subject,
755
- message: `is rowed against ${row.plan} and cites ${target} in its own Plan: line. One task names one plan.`,
755
+ message:
756
+ targets.length === 1
757
+ ? `is rowed against ${row.plan} and cites ${targets[0]} in its own Plan: line. One task names one plan.`
758
+ : `is rowed against ${row.plan}, which is none of the links on its own Plan: line (${targets.join(', ')}).`,
756
759
  }
757
760
  }
758
761
 
@@ -794,14 +797,15 @@ async function groupClaimFinding(
794
797
  if (!existsSync(file)) return undefined
795
798
 
796
799
  const text = await readFile(file, 'utf8')
797
- const target = readPlanTarget(text)
798
- if (!target) {
799
- const several = severalPlans(text, row.group, row.stem)
800
- if (several) return several
801
- }
800
+ const targets = readPlanTargets(text)
801
+ const twice = duplicatePlans(targets, row.group, row.stem, dir, root)
802
+ if (twice) return twice
802
803
 
803
- const live = target ? resolveLivePlan(target, dir, root) : undefined
804
- const hasLivePlan = live !== undefined && existsSync(live)
804
+ const target = targets.find((link) => {
805
+ const live = resolveLivePlan(link, dir, root)
806
+ return live !== undefined && existsSync(live)
807
+ })
808
+ const hasLivePlan = target !== undefined
805
809
 
806
810
  if (row.group === 'Needs a plan' && hasLivePlan) {
807
811
  return {
@@ -817,9 +821,12 @@ async function groupClaimFinding(
817
821
  kind: 'plan-absent',
818
822
  group: row.group,
819
823
  subject: row.stem,
820
- message: target
821
- ? `sits under ${row.group}, which claims a written plan, and its task cites ${target}, which is not a live plan.`
822
- : `sits under ${row.group}, which claims a written plan, and its task carries no Plan: line.`,
824
+ message:
825
+ targets.length > 1
826
+ ? `sits under ${row.group}, which claims a written plan, and its task cites ${targets.join(', ')}, none of which is a live plan.`
827
+ : targets.length === 1
828
+ ? `sits under ${row.group}, which claims a written plan, and its task cites ${targets[0]}, which is not a live plan.`
829
+ : `sits under ${row.group}, which claims a written plan, and its task carries no Plan: line.`,
823
830
  }
824
831
  }
825
832
 
@@ -827,23 +834,26 @@ async function groupClaimFinding(
827
834
  }
828
835
 
829
836
  /**
830
- * Reports a `Plan:` line linking more than one plan. `readPlanTarget` reads
831
- * such a line as naming nothing, so without this a caller would report the
832
- * line as absent when it is there and breaks the one-plan rule instead.
837
+ * Reports a `Plan:` line linking one plan more than once. Links to distinct
838
+ * plans are the shape a sliced task carries, so only a repeat is a finding.
839
+ * Links compare by the file they resolve to, so `../plans/x.md` beside
840
+ * `.canon/plans/x.md` is one plan listed twice.
833
841
  */
834
- function severalPlans(
835
- text: string,
842
+ function duplicatePlans(
843
+ targets: readonly string[],
836
844
  group: Finding['group'],
837
845
  subject: string,
846
+ dir: string,
847
+ root: string,
838
848
  ): Finding | undefined {
839
- const targets = readPlanTargets(text)
840
- if (targets.length < 2) return undefined
849
+ const paths = targets.map((target) => planPath(target, dir, root))
850
+ if (new Set(paths).size === paths.length) return undefined
841
851
 
842
852
  return {
843
853
  kind: 'plan-several',
844
854
  group,
845
855
  subject,
846
- message: `cites ${targets.length} plans on its Plan: line (${targets.join(', ')}). One task names one plan, so split the task or drop the extra links.`,
856
+ message: `lists the same plan twice on its Plan: line (${targets.join(', ')}). Drop the repeat, or link a distinct plan per slice.`,
847
857
  }
848
858
  }
849
859
 
@@ -124,7 +124,7 @@ An intake folder answers that direction at folder scope rather than item scope.
124
124
 
125
125
  A project that archived plans before the folder nested under `.canon/plans/` holds closed tasks pointing at `../plans-archive/` or `../.tmp/plans-archive/`. Leave those pointers where they are, since each resolves against the files it names and a task retargeted without its plan moving leads nowhere.
126
126
 
127
- One plan per task, or one per slice on a sliced task. A plan cited by two tasks is a misfile rather than a shape to design for.
127
+ One plan per task, or one per slice, which the board check reads as distinct plans on one line. A plan cited by two tasks is a misfile.
128
128
 
129
129
  `canon tasks plan-link <task> <plan>` writes or corrects the `Plan:` line, and `--add` appends a slice's plan, so the line is never hand-edited.
130
130
 
@@ -1,92 +1,45 @@
1
1
  #!/usr/bin/env sh
2
2
 
3
- # Names archive candidates after a pull merges work in.
3
+ # Runs the post-merge steps through `canon hooks post-merge`: archive the task a
4
+ # merged pull request closed, push the records, reclaim merged worktrees,
5
+ # reinstall the CLI, and update the plugin cache. The verb owns the order and
6
+ # each line it prints.
4
7
  #
5
- # Every step before the merge fires from a chain and the archive fires when a
6
- # person remembers, so shipped tasks accumulate on a board that reads as ready
7
- # to hand a worker. This is the only event that lands after a merge.
8
+ # CANON_SKIP_RECLAIM=1 turns off the worktree reclaim.
9
+ # CANON_SKIP_UPGRADE=1 turns off the CLI reinstall.
10
+ # CANON_SKIP_PLUGIN_UPDATE=1 turns off the plugin cache update.
8
11
  #
9
- # Candidates rather than closed tasks, because an all-`[x]` board entry does not
10
- # mean the work merged. `context-fold` marks outcomes on the branch as step 1 of
11
- # the ship chain, so a task can read closed while its pull request is still open
12
- # or already abandoned. The board is gitignored and an archived task has nothing
13
- # to recover it, so `task-board` confirms the work is on `main` before moving
14
- # anything and this output says so rather than implying the check is done.
12
+ # The reclaim reads merge state through `gh`, so a machine without it on PATH
13
+ # reclaims nothing and says nothing. Install `gh` to turn it on.
15
14
  #
16
- # It announces and never moves a file. The board is gitignored, so a shell-side
17
- # archive leaves no diff to review with nobody watching, and `index.md` is
18
- # regenerated by a session-scoped hook that a `mv` from a shell never fires.
19
- #
20
- # Husky runs this as `sh -e`, so the shebang is advisory and any bare command
21
- # returning non-zero aborts the hook and prints a husky failure. Keep every
22
- # test inside an `if` condition, which errexit exempts.
15
+ # Husky runs this as `sh -e`, and `post-rewrite` sources it on a rebase, so
16
+ # every test sits inside an `if` or an `||` and nothing here exits non-zero.
23
17
 
24
18
  root=$(git worktree list --porcelain 2>/dev/null | grep -m 1 '^worktree ' | cut -d' ' -f2-) || root=''
25
19
  [ -n "$root" ] || exit 0
26
20
 
27
21
  # The board is shared scratch at the main worktree root, and `git worktree
28
- # list` puts that root first. A pull inside a linked worktree fires this same
29
- # hook, so trusting the working directory would read a board that is not there.
30
- board="$root/.canon/tasks"
31
- [ -d "$board" ] || exit 0
32
-
33
- closed=""
34
- count=0
35
-
36
- for file in "$board"/*.md; do
37
- [ -f "$file" ] || continue
22
+ # list` puts that root first. A checkout with no board runs none of the steps.
23
+ [ -d "$root/.canon/tasks" ] || exit 0
38
24
 
39
- case "$file" in
40
- */index.md | */priority.md) continue ;;
41
- esac
42
-
43
- # Gate on the same condition both archive verbs gate on: at least one closed
44
- # outcome and none open. A file carrying no outcomes at all falls out here,
45
- # which is what keeps notes on the board from being announced as tasks.
46
- if grep -q '^- \[ \]' "$file"; then
47
- continue
48
- fi
25
+ if ! command -v canon >/dev/null 2>&1; then
26
+ exit 0
27
+ fi
49
28
 
50
- if grep -q '^- \[x\]' "$file"; then
51
- closed="$closed $(basename "$file" .md)
52
- "
53
- count=$((count + 1))
29
+ # A global binary older than the verb cannot run it, and the verb carries the
30
+ # only step that would update it, so reinstall here and probe again. The probe
31
+ # reads the verb's own usage line rather than the exit, since an older binary
32
+ # answers an unknown command's `--help` with its root help and exits zero.
33
+ has_verb() {
34
+ canon hooks post-merge --help 2>/dev/null | grep -q '^Usage: canon hooks post-merge'
35
+ }
36
+
37
+ if ! has_verb; then
38
+ if [ -z "$CANON_SKIP_UPGRADE" ]; then
39
+ CANON_NON_INTERACTIVE=1 canon upgrade >/dev/null 2>&1 || true
54
40
  fi
55
- done
56
-
57
- [ "$count" -gt 0 ] || exit 0
58
-
59
- printf '\n📋 %s archive candidate(s) on the board:\n%s\n' "$count" "$closed"
60
- printf 'Outcomes are marked on the branch, so each still needs its work confirmed\n'
61
- printf 'on main. Run /task-board, which checks that and sweeps the plan first.\n\n'
62
-
63
- # The gitignored record folders live on one disk and nowhere else, and a merge
64
- # is the event that changes them most. This runs on every merge rather than
65
- # only on one that closes a task, since a review report and a memory entry
66
- # both land on runs that archive nothing.
67
- #
68
- # Sits last so a slow or unreachable remote delays no candidate announcement,
69
- # and inside an `if` so a push failing offline, or a machine that never ran
70
- # the one-time setup, still leaves this hook exiting zero. Guarded by its own
71
- # `command -v canon` check, since this file carries none above it.
72
- if command -v canon >/dev/null 2>&1; then
73
- if backup=$(canon records push --root "$root" --json 2>/dev/null); then
74
- changed=$(printf '%s' "$backup" | sed -n 's/.*"changed":\([0-9][0-9]*\).*/\1/p')
75
- if [ -n "$changed" ] && [ "$changed" != "0" ]; then
76
- printf '\n🗄️ Backed up %s record path(s).\n\n' "$changed"
77
- fi
78
- else
79
- reason=$(printf '%s' "$backup" | sed -n 's/.*"reason":"\([^"]*\)".*/\1/p')
41
+ fi
80
42
 
81
- # No records history on this machine, which is every checkout that never
82
- # ran the one-time setup. Nothing to report.
83
- if [ "$reason" != "no-repository" ]; then
84
- printf '\n🗄️ Records not backed up: %s\n' "${reason:-unknown}"
85
- if [ "$reason" = "unsafe-payload" ]; then
86
- printf 'Run canon records push to see the blocked paths.\n\n'
87
- else
88
- printf 'Run canon records push when the remote is reachable.\n\n'
89
- fi
90
- fi
91
- fi
43
+ if has_verb; then
44
+ canon hooks post-merge --root "$root" || true
92
45
  fi
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env sh
2
2
 
3
- # Runs the `post-merge` board check for anyone pulling with rebase.
3
+ # Runs the `post-merge` steps for anyone pulling with rebase.
4
4
  #
5
5
  # `git pull` under `pull.rebase=true` runs `git rebase`, which fires this event
6
6
  # and never `post-merge`. Without this the trigger is a silent no-op on that
@@ -9,8 +9,8 @@
9
9
  # target, where the pull style is not something this repository controls.
10
10
  #
11
11
  # Only the `rebase` argument delegates. `post-rewrite` also fires on
12
- # `commit --amend`, which rewrites nothing on the board and would print the
13
- # candidate list on an ordinary amend.
12
+ # `commit --amend`, which rewrites nothing on the board and would run the
13
+ # archive, reclaim, and upgrade steps on an ordinary amend.
14
14
 
15
15
  [ "$1" = "rebase" ] || exit 0
16
16
 
@@ -52,7 +52,7 @@ Seeds live in `tooling/base/seeds/`. Sync drops each once on first install and n
52
52
  - `pre-commit` runs `bunx lint-staged`.
53
53
  - `commit-msg` runs `bunx commitlint --edit "$1"`.
54
54
  - `pre-push` runs `bun run check`.
55
- - `post-merge` names `.canon/tasks/` archive candidates, staying silent otherwise and when the board is absent.
55
+ - `post-merge` runs `canon hooks post-merge`: archive the task a merged pull request closed, push the records, reclaim merged worktrees, reinstall the CLI, and update the plugin. It does nothing when the board is absent. `CANON_SKIP_RECLAIM`, `CANON_SKIP_UPGRADE`, and `CANON_SKIP_PLUGIN_UPDATE` turn off the three steps that act on the machine. Read `canon docs hooks` for the contract.
56
56
  - `post-rewrite` delegates to `post-merge` on `rebase`, so a `pull.rebase=true` machine still gets the check.
57
57
 
58
58
  ## lint-staged
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -e
3
- set -o pipefail
4
-
5
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
- PROJECT_ROOT="${PROJECT_ROOT:-$(cd "$SCRIPT_DIR/../.." && pwd)}"
7
-
8
- source "$PROJECT_ROOT/scripts/lib/ui.sh"
9
-
10
- check_dependencies() {
11
- command -v bun >/dev/null 2>&1 || log_error "bun is not installed"
12
- }
13
-
14
- main() {
15
- check_dependencies
16
-
17
- echo -e "${GREY}┌${NC}"
18
-
19
- echo -e "${GREY}├${NC} ${WHITE}Cleaning artifacts${NC}"
20
- rm -rf node_modules
21
-
22
- log_rem "node_modules/"
23
-
24
- log_step "Cleaning cache"
25
- bun pm cache rm
26
- log_info "Package manager cache cleared"
27
-
28
- log_step "Rehydrating project"
29
- bun install
30
- log_info "Dependencies installed"
31
-
32
- echo -e "${GREY}└${NC}\n"
33
- echo -e "${GREEN}✓ Clean complete${NC}"
34
- }
35
-
36
- main "$@"
@@ -1,235 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Writes web/src/fixtures/agent-view.json from a real `canon sessions list
3
- # --json` read of this repository's own sessions.
4
- #
5
- # The page it feeds re-creates an orchestrator dispatching workers, which is the
6
- # one thing this toolkit does that no other surface here shows. A re-creation
7
- # earns nothing if the rows behind it are invented, so the session half is a
8
- # live listing and never a literal.
9
- #
10
- # Every role in the roster appears, not the workers alone. The controlling
11
- # session is pinned above the bands and planners sit in them beside workers,
12
- # which is what the surface being re-created does. An earlier version of this
13
- # script filtered the listing down to sessions holding a feature branch, and
14
- # that dropped the orchestrator and every planner, since a controlling session
15
- # and a planning session both sit on the default branch. A page about a dispatch
16
- # that excludes the dispatcher is the defect that filter shipped.
17
- #
18
- # Two fields cannot come from the listing and are transcribed by hand into the
19
- # table below. The activity text is written by Claude Code into its own status
20
- # line and no verb here reports it. The pull request number sits on a task file
21
- # with nothing joining a session record to it, which the plan behind this script
22
- # took as a trade rather than building the join. Both are recorded as
23
- # transcribed in the fixture's own header, so a reader of the committed file can
24
- # tell which half was measured and which was typed.
25
- #
26
- # The honesty cost this leaves open is the one assets/captures/install.html.tmpl
27
- # already documents for the terminal frames: a hand-edit after generation
28
- # defeats the discipline silently, and nothing here detects one.
29
- #
30
- # Clone-only. It reads this repository's own sessions, and a registry install
31
- # carries no such listing.
32
- set -e
33
- set -o pipefail
34
-
35
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
36
- PROJECT_ROOT="${PROJECT_ROOT:-$(cd "$SCRIPT_DIR/../.." && pwd)}"
37
-
38
- OUT="$PROJECT_ROOT/web/src/fixtures/agent-view.json"
39
-
40
- # Transcribed half, keyed by session name. The name is the only key that reaches
41
- # every row: a controlling session and a planning session both sit on the
42
- # default branch, so a branch cannot tell them apart or from each other. A
43
- # dispatched session is named `<role>-<project>-<slug>` after the work it was
44
- # given rather than after what it turned out to be doing, which is what makes
45
- # the name stable enough to key on here.
46
- #
47
- # Each row is `name|activity|pullRequest|state|age`. The state is `pinned`,
48
- # `working`, or `completed`, and it is where the row renders. An empty pull
49
- # request field is a session that had not reached its ship step when the
50
- # snapshot was taken.
51
- #
52
- # A pinned or working row has to appear in the live listing or this refuses, and
53
- # its age comes from the listing rather than the table, so the trailing field is
54
- # empty for those. A completed row names a session that has already exited, so
55
- # no listing carries it, its age is transcribed with the rest of the row, and
56
- # leaving that field blank would print an empty column on half the list.
57
- # Re-transcribe this table against a fresh listing rather than editing the
58
- # generated file.
59
- #
60
- # A planner belongs in this table as much as a worker does. `role-planner`
61
- # forbids entering a worktree, so a planner registers on the default branch at
62
- # launch and stays there for its whole life, which is why the branch filter this
63
- # script used to carry dropped every one of them permanently rather than
64
- # occasionally.
65
- ROWS=(
66
- "orchestrator-canon-lead|dispatching the planners that need a plan||pinned|"
67
- "worker-canon-agent-view-and-deploy|PR #1510 open (landing page)|1510|working|" # canon-allow-reference: transcribed status text
68
- "planner-canon-context-wireframe-draft|drafting the context and wireframe plan||working|"
69
- "planner-canon-skill-coverage-pointers|reading the skill coverage pointers||working|"
70
- "planner-canon-screenshot-trap-guard|planning the screenshot trap guard||working|"
71
- "planner-canon-write-route-hook-bypass|plan written; tested write probe||completed|32m"
72
- "planner-canon-indexes-list-lookup|plan and task board consistent||completed|13m"
73
- "worker-canon-labels-scan-body-file|address-review pass finished|1508|completed|21m"
74
- "worker-canon-web-context-entry|PR #1507 addressed with commit|1507|completed|20m" # canon-allow-reference: transcribed status text
75
- )
76
-
77
- # The listing reports a session's repository as the main `.git` directory, which
78
- # is what this resolves whether the script runs from the main checkout or from a
79
- # linked worktree. Comparing against PROJECT_ROOT instead would match nothing
80
- # from a worktree, where the two differ.
81
- MAIN_GIT_DIR="$(cd "$PROJECT_ROOT" && git rev-parse --path-format=absolute --git-common-dir)"
82
-
83
- # `bun src/cli.ts` rather than `canon`, since a globally linked binary resolves
84
- # to the main checkout no matter which worktree is running, and this script is
85
- # run from a worktree as often as not.
86
- SESSIONS_JSON="$(cd "$PROJECT_ROOT" && CANON_NON_INTERACTIVE=1 bun src/cli.ts sessions list --json 2>/dev/null)"
87
-
88
- if [ -z "$SESSIONS_JSON" ]; then
89
- echo "regen-agent-fixture: the session listing returned nothing, refusing to write an empty fixture" >&2
90
- exit 1
91
- fi
92
-
93
- # The listing crosses into the eval as a file rather than an environment entry,
94
- # since Linux caps a single env string at 128KB and a machine running many
95
- # sessions can cross it, which fails the exec with E2BIG before any check can
96
- # report a thing.
97
- SESSIONS_FILE="$(mktemp)"
98
- trap 'rm -f "$SESSIONS_FILE"' EXIT
99
- printf '%s' "$SESSIONS_JSON" >"$SESSIONS_FILE"
100
-
101
- TRANSCRIBED_ROWS="$(printf '%s\n' "${ROWS[@]}")"
102
- READ_AT="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
103
-
104
- export SESSIONS_FILE OUT PROJECT_ROOT READ_AT TRANSCRIBED_ROWS MAIN_GIT_DIR
105
-
106
- bun --eval '
107
- const { readFileSync } = require("node:fs")
108
-
109
- const { SESSIONS_FILE, OUT, PROJECT_ROOT, READ_AT, TRANSCRIBED_ROWS, MAIN_GIT_DIR } =
110
- process.env
111
-
112
- const listing = JSON.parse(readFileSync(SESSIONS_FILE, "utf8"))
113
-
114
- const rows = TRANSCRIBED_ROWS.split("\n")
115
- .map((line) => line.replace(/\s*#\s*canon-allow-reference:.*$/, "").trim())
116
- .filter((line) => line !== "")
117
- .map((line) => {
118
- const [name, activity, pullRequest, state, age] = line.split("|")
119
- return {
120
- name,
121
- activity,
122
- pullRequest: pullRequest ? Number(pullRequest) : null,
123
- state,
124
- age: age || null,
125
- }
126
- })
127
-
128
- // Narrowed to this repository, and the reason is disclosure rather than scope.
129
- // `canon sessions list` is machine-wide, so an unfiltered read carries the
130
- // session names and worktree paths of every other project on the machine, which
131
- // here includes paths under a folder named `private` and several client names.
132
- // This fixture renders on a public page, so the filter is what keeps them off
133
- // it. The cost is a fidelity gap stated plainly: the real surface is
134
- // machine-wide and the depiction is one repository, and that is a deliberate
135
- // narrowing rather than an oversight.
136
- //
137
- // Keyed by name for the reason the shell comment gives: a session on the
138
- // default branch has no other identity, and the orchestrator and every planner
139
- // sit there.
140
- const live = new Map(
141
- listing.sessions
142
- .filter((session) => session.repository === MAIN_GIT_DIR)
143
- .map((session) => [session.name, session]),
144
- )
145
-
146
- // The real surface shows an age per row, so the fixture carries one. It is
147
- // frozen at the read rather than live, which the rendered provenance line dates
148
- // so a reader is never told a stale figure is current.
149
- const ageLabel = (startedAt) => {
150
- const minutes = Math.round(
151
- (Date.parse(READ_AT) - Date.parse(startedAt)) / 60000,
152
- )
153
- if (!Number.isFinite(minutes) || minutes < 1) return "now"
154
- if (minutes < 60) return `${minutes}m`
155
- const hours = Math.round(minutes / 60)
156
- return hours < 24 ? `${hours}h` : `${Math.round(hours / 24)}d`
157
- }
158
-
159
- // A row the page shows as running has to be running. Transcribing one that is
160
- // not is the failure the live half exists to prevent, so it refuses rather than
161
- // rendering.
162
- const absent = rows.filter(
163
- (row) => row.state !== "completed" && !live.has(row.name),
164
- )
165
- if (absent.length > 0) {
166
- console.error(
167
- "regen-agent-fixture: no live session for " +
168
- absent.map((row) => row.name).join(", ") +
169
- ". Re-transcribe the table in this script against a fresh listing rather than editing the generated fixture.",
170
- )
171
- process.exit(1)
172
- }
173
-
174
- const sessions = rows.map((row) => {
175
- const session = live.get(row.name)
176
- return {
177
- name: row.name,
178
- branch: session ? session.branch : null,
179
- state: row.state,
180
- activity: row.activity,
181
- pullRequest: row.pullRequest,
182
- age: session ? ageLabel(session.startedAt) : row.age,
183
- }
184
- })
185
-
186
- const ageless = sessions.filter((entry) => !entry.age)
187
- if (ageless.length > 0) {
188
- console.error(
189
- "regen-agent-fixture: no age for " +
190
- ageless.map((entry) => entry.name).join(", ") +
191
- ". A completed row carries its age in the table, since the session has exited and no listing reports one.",
192
- )
193
- process.exit(1)
194
- }
195
-
196
- // What the real surface prints above its own list. The remainder is every
197
- // session on the machine this page has no room to show, which is a real count.
198
- const summary = {
199
- working: sessions.filter((entry) => entry.state === "working").length,
200
- completed: sessions.filter((entry) => entry.state === "completed").length,
201
- more: Math.max(0, listing.sessions.length - live.size),
202
- }
203
-
204
- const fixture = {
205
- // Read by web/src/components/agent-view.astro. Every field below is either a
206
- // live read or a hand transcription, and this header is what says which.
207
- generatedBy: "scripts/core/regen-agent-fixture.sh",
208
- readAt: READ_AT,
209
- source: {
210
- command: "canon sessions list --json",
211
- live: [
212
- "name",
213
- "branch",
214
- "age",
215
- "that every pinned and working row is running",
216
- "the remainder count",
217
- ],
218
- transcribed: {
219
- activity:
220
- "written by Claude Code into its own status line, which no verb here reports",
221
- pullRequest:
222
- "read off a task file by hand, since nothing joins a session record to one",
223
- state:
224
- "a completed session has already exited, so no listing carries the row at all",
225
- },
226
- },
227
- summary,
228
- sessions,
229
- }
230
-
231
- await Bun.write(OUT, JSON.stringify(fixture, null, 2) + "\n")
232
- console.error(
233
- `regen-agent-fixture: wrote ${sessions.length} session rows to ${OUT.replace(PROJECT_ROOT + "/", "")}`,
234
- )
235
- '
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -e
3
- set -o pipefail
4
-
5
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
- PROJECT_ROOT="${PROJECT_ROOT:-$(cd "$SCRIPT_DIR/../.." && pwd)}"
7
-
8
- # `.claude/rules/` is a subset rather than a mirror, so it resolves through the
9
- # stack machinery. The record naming the subset is `internal/governance.toml`.
10
- bun "$PROJECT_ROOT/src/cli.ts" gov regen --root "$PROJECT_ROOT"
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -e
3
- set -o pipefail
4
-
5
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
- PROJECT_ROOT="${PROJECT_ROOT:-$(cd "$SCRIPT_DIR/../.." && pwd)}"
7
-
8
- source "$PROJECT_ROOT/scripts/lib/ui.sh"
9
-
10
- bun "$PROJECT_ROOT/src/cli.ts" indexes regen --root "$PROJECT_ROOT" --json >/dev/null