@erclx/canon 4.108.0 → 4.110.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/README.md +15 -30
- package/claude/.claude-plugin/plugin.json +1 -1
- package/claude/skills/{canon-feedback-file → canon-feedback}/REQUIREMENT.md +7 -6
- package/claude/skills/{canon-feedback-file → canon-feedback}/SKILL.md +9 -19
- package/claude/skills/canon-feedback-triage/REQUIREMENT.md +1 -1
- package/claude/skills/canon-feedback-triage/SKILL.md +1 -1
- package/claude/skills/draft-wiki/REQUIREMENT.md +42 -0
- package/claude/skills/draft-wiki/SKILL.md +83 -0
- package/claude/skills/git-issue/REQUIREMENT.md +1 -1
- package/claude/skills/git-issue/SKILL.md +1 -1
- package/claude/skills/git-ship/SKILL.md +1 -1
- package/claude/skills/review-address/SKILL.md +4 -3
- package/claude/skills/task-board/REQUIREMENT.md +1 -1
- package/claude/skills/task-board/SKILL.md +2 -2
- package/docs/agents/capture.md +3 -3
- package/docs/agents/commands.md +2 -2
- package/docs/agents/pr-reads.md +2 -0
- package/docs/agents/tasks.md +10 -8
- package/docs/agents/teach.md +4 -2
- package/docs/workflow/ai-workflow.md +2 -1
- package/package.json +1 -1
- package/scripts/core/regen-hero.sh +2 -34
- package/src/claude/cases/authoring.ts +5 -0
- package/src/claude/cases/setup.ts +1 -1
- package/src/cli.ts +2 -161
- package/src/commands/pr.ts +29 -4
- package/src/commands/tasks.ts +22 -7
- package/src/design/components.ts +382 -90
- package/src/help.ts +196 -0
- package/src/pr/checks.ts +29 -0
- package/src/tasks/label.ts +136 -29
- package/src/teach/nav.ts +406 -56
- package/standards/readme.md +1 -0
|
@@ -96,11 +96,8 @@ GOV_JSON="$(catalog gov list)"
|
|
|
96
96
|
STANDARDS_JSON="$(catalog standards list)"
|
|
97
97
|
SNIPPETS_JSON="$(catalog snippets list)"
|
|
98
98
|
TOOLING_JSON="$(catalog tooling list)"
|
|
99
|
-
# The catalog ledger names three commands, and the registered set is only
|
|
100
|
-
# readable from the root help, which lists one per line under `Commands:`.
|
|
101
|
-
COMMANDS_HELP="$(cd "$PROJECT_ROOT" && CANON_NON_INTERACTIVE=1 bun src/cli.ts --help 2>/dev/null)"
|
|
102
99
|
|
|
103
|
-
for payload in "$COUNTS_JSON" "$SKILLS_JSON" "$GOV_JSON" "$STANDARDS_JSON" "$SNIPPETS_JSON" "$TOOLING_JSON"
|
|
100
|
+
for payload in "$COUNTS_JSON" "$SKILLS_JSON" "$GOV_JSON" "$STANDARDS_JSON" "$SNIPPETS_JSON" "$TOOLING_JSON"; do
|
|
104
101
|
if [ -z "$payload" ]; then
|
|
105
102
|
echo "regen-hero: a catalog returned nothing, refusing to write a zeroed hero" >&2
|
|
106
103
|
exit 1
|
|
@@ -120,7 +117,6 @@ printf '%s' "$GOV_JSON" >"$PAYLOAD_DIR/gov.json"
|
|
|
120
117
|
printf '%s' "$STANDARDS_JSON" >"$PAYLOAD_DIR/standards.json"
|
|
121
118
|
printf '%s' "$SNIPPETS_JSON" >"$PAYLOAD_DIR/snippets.json"
|
|
122
119
|
printf '%s' "$TOOLING_JSON" >"$PAYLOAD_DIR/tooling.json"
|
|
123
|
-
printf '%s' "$COMMANDS_HELP" >"$PAYLOAD_DIR/commands-help.txt"
|
|
124
120
|
printf '%s' "$TOKEN_CSS" >"$PAYLOAD_DIR/tokens.css"
|
|
125
121
|
|
|
126
122
|
export PAYLOAD_DIR
|
|
@@ -349,36 +345,8 @@ for (const [label, rows] of [
|
|
|
349
345
|
}
|
|
350
346
|
}
|
|
351
347
|
|
|
352
|
-
// The ledger names a few real entries per domain. Chosen by hand for the same
|
|
353
|
-
// reason FEATURED_SKILLS is, and asserted against the catalog so a rename fails
|
|
354
|
-
// the run rather than leaving a name the repository no longer ships.
|
|
355
|
-
const commandNames = readFileSync(PAYLOAD_DIR + "/commands-help.txt", "utf8")
|
|
356
|
-
.split("\n")
|
|
357
|
-
.map((line) => line.match(/^[│\s]{2,}(?<name>[a-z][a-z-]*)\s/)?.groups?.name)
|
|
358
|
-
.filter(Boolean)
|
|
359
|
-
const LEDGER = [
|
|
360
|
-
["skills", skills.length, ["plan-feature", "role-orchestrator", "review-pr"], skills],
|
|
361
|
-
["rules", rules.length, ["behavior", "memory", "testing"], rules],
|
|
362
|
-
["standards", standards.length, ["markdown", "plan", "teach"], standards],
|
|
363
|
-
["commands", commandCount, ["gov", "tasks", "design"], commandNames],
|
|
364
|
-
["stacks", toolingStacks.length, ["astro", "python", "web"], toolingStacks.map((stack) => stack.name)],
|
|
365
|
-
]
|
|
366
|
-
for (const [domain, , chosen, names] of LEDGER) {
|
|
367
|
-
const known = new Set(names)
|
|
368
|
-
const missing = chosen.filter((name) => !known.has(name))
|
|
369
|
-
if (missing.length > 0) {
|
|
370
|
-
console.error(`regen-hero: ledger ${domain} names missing from the catalog: ${missing.join(", ")}`)
|
|
371
|
-
process.exit(1)
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
const ledgerRows = LEDGER.map(
|
|
375
|
-
([domain, count, chosen]) =>
|
|
376
|
-
` <div class="row"><span class="count">${count}</span><span class="domain">${domain}</span><span class="names">${escape(chosen.join(", "))}</span></div>`,
|
|
377
|
-
).join("\n")
|
|
378
|
-
|
|
379
348
|
const values = {
|
|
380
349
|
TOKENS: tokenCss,
|
|
381
|
-
LEDGER_ROWS: ledgerRows,
|
|
382
350
|
GOV_STACK_ROWS: govStackRows,
|
|
383
351
|
GOV_RULE_ROWS: govRuleRows,
|
|
384
352
|
STANDARD_ROWS: standardRows,
|
|
@@ -417,7 +385,7 @@ if (templates.length === 0) {
|
|
|
417
385
|
// same template with the plain roles pointed at the light ones rather than a
|
|
418
386
|
// second copy of any hex value. The hero is a landing-page frame no README
|
|
419
387
|
// shows, so it stays dark.
|
|
420
|
-
const LIGHT_TEMPLATES = new Set(["
|
|
388
|
+
const LIGHT_TEMPLATES = new Set(["install.html.tmpl"])
|
|
421
389
|
|
|
422
390
|
const lightRoles = [...tokenCss.matchAll(/--color-light-([a-z-]+):/g)].map((match) => match[1])
|
|
423
391
|
if (lightRoles.length === 0) {
|
|
@@ -61,6 +61,11 @@ export const AUTHORING_CASES: readonly SkillCase[] = [
|
|
|
61
61
|
'Draft a wireframe for the settings panel, nothing under canon/wireframes covers that surface yet.',
|
|
62
62
|
expect: 'draft-wireframes',
|
|
63
63
|
},
|
|
64
|
+
{
|
|
65
|
+
prompt:
|
|
66
|
+
'Write a wiki reference page for Claude Code output styles, no page covers that subject yet.',
|
|
67
|
+
expect: 'draft-wiki',
|
|
68
|
+
},
|
|
64
69
|
{
|
|
65
70
|
prompt: 'Say what that dense answer actually means in plain terms.',
|
|
66
71
|
expect: 'restate-plainly',
|
package/src/cli.ts
CHANGED
|
@@ -43,169 +43,10 @@ import { register as census } from '@/commands/census'
|
|
|
43
43
|
import { register as targets } from '@/commands/targets'
|
|
44
44
|
import { register as upgrade } from '@/commands/upgrade'
|
|
45
45
|
import { readInstalled, UNKNOWN_LABEL } from '@/version/installed'
|
|
46
|
-
import {
|
|
47
|
-
|
|
48
|
-
const HELP_WIDTH = 80
|
|
49
|
-
const SIGNATURE_WIDTH = 19
|
|
50
|
-
const ROW_INDENT = '│ '.length
|
|
51
|
-
|
|
52
|
-
type CommandRow = [signature: string, description: string]
|
|
53
|
-
|
|
54
|
-
// The grouping mirrors the README's domain table and has no other source, so a
|
|
55
|
-
// command added to the program needs a row here or help-option.test.ts fails.
|
|
56
|
-
const COMMAND_GROUPS: { title: string; rows: CommandRow[] }[] = [
|
|
57
|
-
{
|
|
58
|
-
title: 'Project',
|
|
59
|
-
rows: [
|
|
60
|
-
['init [path]', 'Bootstrap a project with toolkit domains'],
|
|
61
|
-
['sync [path]', 'Sync all installed domains in a project'],
|
|
62
|
-
['upgrade', 'Reinstall the CLI with the manager that installed it'],
|
|
63
|
-
['migrate [cmd]', 'Move a project off a retired name or layout'],
|
|
64
|
-
['targets [cmd]', 'Projects this toolkit installed into (list, pulls)'],
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
title: 'Domains',
|
|
69
|
-
rows: [
|
|
70
|
-
['gov [cmd]', 'Governance rules (install, sync, list)'],
|
|
71
|
-
['standards [cmd]', 'Standards (install, sync, list, <name>)'],
|
|
72
|
-
['snippets [cmd]', 'Prompt snippets (create, list)'],
|
|
73
|
-
['tooling [cmd]', 'Tooling stacks (sync, ref, create)'],
|
|
74
|
-
['claude [cmd]', 'Claude workflow (init, sync, setup)'],
|
|
75
|
-
['wiki [cmd]', 'Wiki pages (init)'],
|
|
76
|
-
['indexes [cmd]', 'Regenerate index.md files (regen)'],
|
|
77
|
-
['docs [cmd|topic]', 'Emit toolkit reference docs (list, <topic>)'],
|
|
78
|
-
],
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
title: 'Author and render',
|
|
82
|
-
rows: [
|
|
83
|
-
['design [cmd]', 'Design system (render, board)'],
|
|
84
|
-
['slides [cmd]', 'Slide decks (render, list)'],
|
|
85
|
-
['capture [source]', 'Render HTML capture sources to PNG'],
|
|
86
|
-
['serve [dir]', 'Serve a directory on localhost, print the link'],
|
|
87
|
-
['demo [cmd]', 'Record a running app (compile, run)'],
|
|
88
|
-
['inventory [subj]', 'Report one computed property across every route'],
|
|
89
|
-
['drive <url> <run>', 'Walk a page through interactions, measure each'],
|
|
90
|
-
['transcripts <url>', 'Fetch a YouTube transcript with frontmatter'],
|
|
91
|
-
['teach [cmd]', 'Learning workspaces (list, open, resource, glossary)'],
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
title: 'Session and ship',
|
|
96
|
-
rows: [
|
|
97
|
-
['sandbox [cat:cmd]', 'Provision and run sandbox scenarios'],
|
|
98
|
-
['tasks [cmd]', 'Task board (validate, archive)'],
|
|
99
|
-
['intake [cmd]', 'Intake folders under .canon/intake/ (list, answer)'],
|
|
100
|
-
['records [cmd]', 'Session records (validate, size, push, pull)'],
|
|
101
|
-
['sessions [cmd]', 'Resolve live sessions to worktree and branch'],
|
|
102
|
-
['worktrees [cmd]', 'Reclaim worktrees whose branches merged'],
|
|
103
|
-
['autoship [cmd]', 'Decide whether a changed set needs review'],
|
|
104
|
-
['pr [cmd]', 'Read a pull request (key-changes, head, checks)'],
|
|
105
|
-
['feedback', 'Write toolkit feedback from stdin'],
|
|
106
|
-
],
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
title: 'Repo reports',
|
|
110
|
-
rows: [
|
|
111
|
-
['audits [cmd]', 'Run every health check as one set (run, list)'],
|
|
112
|
-
['gate [cmd]', 'Run the merge gate stage by stage (run)'],
|
|
113
|
-
['secrets [cmd]', 'Scan the shipped tree for credentials (scan)'],
|
|
114
|
-
['deps [cmd]', 'Read the dependency set for advisories (audit)'],
|
|
115
|
-
['labels [cmd]', 'Read a changed set against the label map (audit)'],
|
|
116
|
-
['comments [cmd]', 'Measure comment density and trend (scan)'],
|
|
117
|
-
['context [cmd]', 'Report context folder health (audit)'],
|
|
118
|
-
['markdown [cmd]', 'Report markdown against the standards (audit)'],
|
|
119
|
-
['repo [cmd]', 'Remote metadata (metadata propose, apply)'],
|
|
120
|
-
['census [path]', 'Report file count, extensions, and line totals'],
|
|
121
|
-
],
|
|
122
|
-
},
|
|
123
|
-
]
|
|
124
|
-
|
|
125
|
-
// A row past the width is cut rather than wrapped, since a wrapped row breaks
|
|
126
|
-
// the alignment the grouping exists to buy.
|
|
127
|
-
function commandRow(signature: string, description: string): string {
|
|
128
|
-
const { GREY, NC } = palette(process.stdout)
|
|
129
|
-
const room = HELP_WIDTH - ROW_INDENT - SIGNATURE_WIDTH - '# '.length
|
|
130
|
-
const text =
|
|
131
|
-
description.length > room
|
|
132
|
-
? `${description.slice(0, room - 1)}…`
|
|
133
|
-
: description
|
|
134
|
-
return `${GREY}│${NC} ${signature.padEnd(SIGNATURE_WIDTH)}${GREY}# ${text}${NC}`
|
|
135
|
-
}
|
|
46
|
+
import { renderHelp } from '@/help'
|
|
136
47
|
|
|
137
48
|
function showHelp(): void {
|
|
138
|
-
|
|
139
|
-
// about that stream rather than the stderr every other writer here uses.
|
|
140
|
-
const { GREY, NC, WHITE } = palette(process.stdout)
|
|
141
|
-
const lines = [
|
|
142
|
-
`${GREY}┌${NC}`,
|
|
143
|
-
`${GREY}├${NC} ${WHITE}Usage:${NC} canon [command]`,
|
|
144
|
-
`${GREY}│${NC}`,
|
|
145
|
-
`${GREY}│${NC} ${WHITE}Commands:${NC}`,
|
|
146
|
-
...COMMAND_GROUPS.flatMap((group) => [
|
|
147
|
-
`${GREY}│${NC}`,
|
|
148
|
-
`${GREY}│${NC} ${WHITE}${group.title}${NC}`,
|
|
149
|
-
...group.rows.map(([signature, description]) =>
|
|
150
|
-
commandRow(signature, description),
|
|
151
|
-
),
|
|
152
|
-
]),
|
|
153
|
-
`${GREY}│${NC}`,
|
|
154
|
-
`${GREY}│${NC} ${WHITE}Sandbox:${NC}`,
|
|
155
|
-
`${GREY}│${NC} canon sandbox ${GREY}# Interactive scenario picker${NC}`,
|
|
156
|
-
`${GREY}│${NC} canon sandbox git:commit ${GREY}# Run specific scenario${NC}`,
|
|
157
|
-
`${GREY}│${NC} canon sandbox reset ${GREY}# Reset sandbox to baseline${NC}`,
|
|
158
|
-
`${GREY}│${NC} canon sandbox clean ${GREY}# Wipe the sandbox${NC}`,
|
|
159
|
-
`${GREY}│${NC}`,
|
|
160
|
-
`${GREY}│${NC} ${WHITE}Examples:${NC}`,
|
|
161
|
-
`${GREY}│${NC} canon sync ../my-app`,
|
|
162
|
-
`${GREY}│${NC} canon sandbox git:commit`,
|
|
163
|
-
`${GREY}│${NC} canon gov install react`,
|
|
164
|
-
`${GREY}│${NC} canon gov sync ../my-app`,
|
|
165
|
-
`${GREY}│${NC} canon gov restated --json`,
|
|
166
|
-
`${GREY}│${NC} canon standards markdown`,
|
|
167
|
-
`${GREY}│${NC} canon snippets list`,
|
|
168
|
-
`${GREY}│${NC} canon init ../my-app`,
|
|
169
|
-
`${GREY}│${NC} canon tooling sync base`,
|
|
170
|
-
`${GREY}│${NC} canon tooling create`,
|
|
171
|
-
`${GREY}│${NC} canon claude init`,
|
|
172
|
-
`${GREY}│${NC} canon indexes regen`,
|
|
173
|
-
`${GREY}│${NC} canon indexes regen --dry-run --json`,
|
|
174
|
-
`${GREY}│${NC} canon docs list --json`,
|
|
175
|
-
`${GREY}│${NC} canon docs agents`,
|
|
176
|
-
`${GREY}│${NC} canon design render`,
|
|
177
|
-
`${GREY}│${NC} canon design board`,
|
|
178
|
-
`${GREY}│${NC} canon slides render`,
|
|
179
|
-
`${GREY}│${NC} canon slides list --json`,
|
|
180
|
-
`${GREY}│${NC} canon capture assets/captures/install.html --selector .window --out assets/evidence`,
|
|
181
|
-
`${GREY}│${NC} canon serve .canon/teach`,
|
|
182
|
-
`${GREY}│${NC} canon inventory focus --json`,
|
|
183
|
-
`${GREY}│${NC} canon drive http://localhost:4173 run.json --json`,
|
|
184
|
-
`${GREY}│${NC} pbpaste | canon feedback`,
|
|
185
|
-
`${GREY}│${NC} canon transcripts https://youtu.be/VIDEO_ID`,
|
|
186
|
-
`${GREY}│${NC} canon tasks archive --pull-request 673 --json`,
|
|
187
|
-
`${GREY}│${NC} canon intake list toolkit-overview --unread --json`,
|
|
188
|
-
`${GREY}│${NC} canon teach list --json`,
|
|
189
|
-
`${GREY}│${NC} canon comments scan src --json`,
|
|
190
|
-
`${GREY}│${NC} canon context audit --json`,
|
|
191
|
-
`${GREY}│${NC} canon markdown audit .claude/rules --json`,
|
|
192
|
-
`${GREY}│${NC} canon records validate plans`,
|
|
193
|
-
`${GREY}│${NC} canon records size --json`,
|
|
194
|
-
`${GREY}│${NC} canon records push --json`,
|
|
195
|
-
`${GREY}│${NC} canon sessions list --json`,
|
|
196
|
-
`${GREY}│${NC} canon worktrees list --json`,
|
|
197
|
-
`${GREY}│${NC} canon worktrees reclaim --dry-run`,
|
|
198
|
-
`${GREY}│${NC} canon secrets scan --json`,
|
|
199
|
-
`${GREY}│${NC} canon deps audit --json`,
|
|
200
|
-
`${GREY}│${NC} canon labels audit --json`,
|
|
201
|
-
`${GREY}│${NC} canon repo metadata propose --json`,
|
|
202
|
-
`${GREY}│${NC} canon census --json`,
|
|
203
|
-
`${GREY}│${NC} canon audits run --json`,
|
|
204
|
-
`${GREY}│${NC} canon gate run --all --no-write`,
|
|
205
|
-
`${GREY}│${NC} canon upgrade --json`,
|
|
206
|
-
`${GREY}└${NC}`,
|
|
207
|
-
]
|
|
208
|
-
console.log(lines.join('\n'))
|
|
49
|
+
console.log(renderHelp(process.stdout))
|
|
209
50
|
}
|
|
210
51
|
|
|
211
52
|
const program = new Command()
|
package/src/commands/pr.ts
CHANGED
|
@@ -20,7 +20,11 @@ import {
|
|
|
20
20
|
compareKeyChanges,
|
|
21
21
|
treeRoots,
|
|
22
22
|
} from '@/pr/bijection'
|
|
23
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
type CheckRunListing,
|
|
25
|
+
collapseChecks,
|
|
26
|
+
withMergeState,
|
|
27
|
+
} from '@/pr/checks'
|
|
24
28
|
import {
|
|
25
29
|
findEvidenceChecklist,
|
|
26
30
|
findEvidenceCommentId,
|
|
@@ -307,6 +311,11 @@ export function register(program: Command): void {
|
|
|
307
311
|
'an empty row list, and reading that as passing is the false green the',
|
|
308
312
|
'sha key alone does not close.',
|
|
309
313
|
'',
|
|
314
|
+
'A branch conflicting with its base gets no merge ref, so no run ever',
|
|
315
|
+
'starts for it and the state stays pending. The record carries',
|
|
316
|
+
'`conflicted: true` beside it when `mergeStateStatus` reads DIRTY and no',
|
|
317
|
+
'run belongs to the tip, and a caller stops waiting and rebases.',
|
|
318
|
+
'',
|
|
310
319
|
'Exit codes:',
|
|
311
320
|
' 0 the runs for the tip were read, whatever they say',
|
|
312
321
|
' 1 refused, with the reason on stderr or in the JSON record',
|
|
@@ -865,6 +874,7 @@ interface PullIdentity {
|
|
|
865
874
|
readonly number: number | undefined
|
|
866
875
|
readonly branch: string
|
|
867
876
|
readonly head?: string
|
|
877
|
+
readonly mergeState?: string
|
|
868
878
|
}
|
|
869
879
|
|
|
870
880
|
type IdentityRead =
|
|
@@ -911,12 +921,17 @@ async function readIdentity(
|
|
|
911
921
|
|
|
912
922
|
const args = ['pr', 'view']
|
|
913
923
|
if (number !== undefined) args.push(number)
|
|
914
|
-
args.push('--json', 'number,headRefName,headRefOid')
|
|
924
|
+
args.push('--json', 'number,headRefName,headRefOid,mergeStateStatus')
|
|
915
925
|
|
|
916
926
|
const stdout = await gh(cwd, args)
|
|
917
927
|
if (stdout === null) return { kind: 'refused', reason: 'gh-failed' }
|
|
918
928
|
|
|
919
|
-
let row: {
|
|
929
|
+
let row: {
|
|
930
|
+
number?: number
|
|
931
|
+
headRefName?: string
|
|
932
|
+
headRefOid?: string
|
|
933
|
+
mergeStateStatus?: string
|
|
934
|
+
}
|
|
920
935
|
try {
|
|
921
936
|
row = JSON.parse(stdout)
|
|
922
937
|
} catch {
|
|
@@ -933,6 +948,9 @@ async function readIdentity(
|
|
|
933
948
|
number: row.number,
|
|
934
949
|
branch: row.headRefName,
|
|
935
950
|
...(row.headRefOid !== undefined && { head: row.headRefOid }),
|
|
951
|
+
...(row.mergeStateStatus !== undefined && {
|
|
952
|
+
mergeState: row.mergeStateStatus,
|
|
953
|
+
}),
|
|
936
954
|
},
|
|
937
955
|
}
|
|
938
956
|
}
|
|
@@ -1071,7 +1089,10 @@ async function runChecks(
|
|
|
1071
1089
|
)
|
|
1072
1090
|
}
|
|
1073
1091
|
|
|
1074
|
-
const reading =
|
|
1092
|
+
const reading = withMergeState(
|
|
1093
|
+
identity.mergeState,
|
|
1094
|
+
collapseChecks(resolved.tip, listing),
|
|
1095
|
+
)
|
|
1075
1096
|
|
|
1076
1097
|
logStep('Scope')
|
|
1077
1098
|
logInfo(
|
|
@@ -1101,6 +1122,10 @@ async function runChecks(
|
|
|
1101
1122
|
logInfo('every run on the tip completed and none failed')
|
|
1102
1123
|
} else if (reading.state === 'failing') {
|
|
1103
1124
|
logWarn('a run on the tip failed, which no run still going can clear')
|
|
1125
|
+
} else if (reading.conflicted) {
|
|
1126
|
+
logWarn(
|
|
1127
|
+
'the branch conflicts with its base, so no run will start for the tip. Rebase onto the base rather than waiting.',
|
|
1128
|
+
)
|
|
1104
1129
|
} else if (reading.matched === 0) {
|
|
1105
1130
|
logInfo(
|
|
1106
1131
|
`no run belongs to the tip yet${reading.reported > 0 ? `, against a reported count of ${reading.reported}` : ''}. That is unread rather than clean.`,
|
package/src/commands/tasks.ts
CHANGED
|
@@ -13,7 +13,12 @@ import {
|
|
|
13
13
|
type PlanCitations,
|
|
14
14
|
planCitations,
|
|
15
15
|
} from '@/tasks/archive'
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
type LabelOutcome,
|
|
18
|
+
type LabelRefused,
|
|
19
|
+
claimLabel,
|
|
20
|
+
nextLabel,
|
|
21
|
+
} from '@/tasks/label'
|
|
17
22
|
import { listTasks } from '@/tasks/list'
|
|
18
23
|
import {
|
|
19
24
|
type Claim,
|
|
@@ -122,6 +127,7 @@ interface ListCommandOptions {
|
|
|
122
127
|
|
|
123
128
|
interface NextLabelCommandOptions {
|
|
124
129
|
readonly json?: boolean
|
|
130
|
+
readonly claim?: boolean
|
|
125
131
|
readonly root?: string
|
|
126
132
|
}
|
|
127
133
|
|
|
@@ -503,6 +509,7 @@ export function register(program: Command): void {
|
|
|
503
509
|
)
|
|
504
510
|
.helpOption('-h, --help', 'Show this help message')
|
|
505
511
|
.option('--json', 'Emit a machine-readable record on stdout')
|
|
512
|
+
.option('--claim', 'Reserve the label so a second claim gets another')
|
|
506
513
|
.option('--root <path>', 'Board root, defaulting to the main worktree')
|
|
507
514
|
.addHelpText(
|
|
508
515
|
'after',
|
|
@@ -515,14 +522,18 @@ export function register(program: Command): void {
|
|
|
515
522
|
'Exit codes:',
|
|
516
523
|
' 0 the label is derived',
|
|
517
524
|
' 1 refused with no-board',
|
|
525
|
+
' 2 refused with label-contended, on --claim only',
|
|
518
526
|
'',
|
|
519
|
-
'
|
|
520
|
-
'second can
|
|
521
|
-
'
|
|
527
|
+
'Bare, it reports and never writes, so two sessions calling it in the',
|
|
528
|
+
'same second can take the same answer. --claim reserves the label',
|
|
529
|
+
'under .canon/ordinal-locks/ and counts every reservation in the',
|
|
530
|
+
'scan, so two claims return different labels. A dead claim leaves a',
|
|
531
|
+
'gap, which standards/versioning.md permits.',
|
|
522
532
|
'',
|
|
523
533
|
'Examples:',
|
|
524
534
|
' canon tasks next-label',
|
|
525
535
|
' canon tasks next-label --json',
|
|
536
|
+
' canon tasks next-label --claim --json',
|
|
526
537
|
'',
|
|
527
538
|
].join('\n'),
|
|
528
539
|
)
|
|
@@ -864,11 +875,15 @@ async function runList(opts: ListCommandOptions): Promise<number> {
|
|
|
864
875
|
|
|
865
876
|
async function runNextLabel(opts: NextLabelCommandOptions): Promise<number> {
|
|
866
877
|
const root = opts.root ?? (await mainWorktreeRoot())
|
|
867
|
-
const outcome = await nextLabel(root)
|
|
878
|
+
const outcome = opts.claim ? await claimLabel(root) : await nextLabel(root)
|
|
868
879
|
|
|
869
880
|
return reportNextLabel(outcome, opts.json ?? false, root)
|
|
870
881
|
}
|
|
871
882
|
|
|
883
|
+
function refusalExit(outcome: LabelRefused): number {
|
|
884
|
+
return outcome.reason === 'label-contended' ? 2 : 1
|
|
885
|
+
}
|
|
886
|
+
|
|
872
887
|
function reportNextLabel(
|
|
873
888
|
outcome: LabelOutcome,
|
|
874
889
|
emitJson: boolean,
|
|
@@ -879,14 +894,14 @@ function reportNextLabel(
|
|
|
879
894
|
process.stdout.write(
|
|
880
895
|
`${JSON.stringify({ ok: false, reason: outcome.reason, message: outcome.message })}\n`,
|
|
881
896
|
)
|
|
882
|
-
return
|
|
897
|
+
return refusalExit(outcome)
|
|
883
898
|
}
|
|
884
899
|
|
|
885
900
|
intro('canon tasks next-label')
|
|
886
901
|
logStep('Refused')
|
|
887
902
|
logError(outcome.message)
|
|
888
903
|
outro()
|
|
889
|
-
return
|
|
904
|
+
return refusalExit(outcome)
|
|
890
905
|
}
|
|
891
906
|
|
|
892
907
|
if (emitJson) {
|