@erclx/canon 4.45.1 → 4.47.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/claude/.claude-plugin/plugin.json +1 -1
- package/claude/skills/claude-feature/SKILL.md +2 -0
- package/claude/skills/claude-ux-audit/SKILL.md +2 -2
- package/docs/agents/commands.md +1 -0
- package/docs/agents/tasks.md +22 -0
- package/package.json +1 -1
- package/src/commands/migrate.ts +34 -0
- package/src/commands/tasks.ts +85 -0
- package/src/migrate/records.ts +141 -5
- package/src/tasks/archive.ts +19 -9
- package/src/tasks/record.ts +77 -0
- package/standards/tasks.md +2 -0
- package/standards/versioning.md +5 -0
|
@@ -101,6 +101,8 @@ Run `canon records validate plans` after writing the file when the CLI is on PAT
|
|
|
101
101
|
|
|
102
102
|
Run `canon markdown audit .canon/plans/feature-<slug>.md` beside it, naming the file. `.canon/plans/` is gitignored and the audit's default path set is what git lists, so no other gate ever opens a plan, and six ban hits landed across four plans written without this call. Rewrite the sentence carrying a hit rather than swapping the token for a near-synonym.
|
|
103
103
|
|
|
104
|
+
When Step 1 resolved an existing task for this feature, run `canon tasks plan-link <task> .canon/plans/feature-<slug>.md` right after the file lands, naming the stem Step 1 read. Skip the call when Step 1 found no task, since there is nothing to link yet. Report a refusal rather than stopping on it. The plan file is already written, and `canon tasks validate` still catches an unlinked task through `plan-uncited` if this call cannot run.
|
|
105
|
+
|
|
104
106
|
Then output in chat:
|
|
105
107
|
|
|
106
108
|
```markdown
|
|
@@ -16,7 +16,7 @@ Read these in parallel from the project root, skipping any that do not exist:
|
|
|
16
16
|
|
|
17
17
|
- `CLAUDE.md`: project type and conventions
|
|
18
18
|
- `.claude/DESIGN.md`: visual intent, tokens, typography, spacing rules
|
|
19
|
-
- `.claude/wireframes/index.md` + every `.claude/wireframes/<surface>.md
|
|
19
|
+
- `.claude/wireframes/index.md` + every `.claude/wireframes/<surface>.md`, each a flat file or a grouped surface's own `.claude/wireframes/<surface>/index.md` and the siblings it lists: intended UI layout, UI copy, interaction rules. Surfaces are loaded one file at a time during Step 3. Per `${CLAUDE_SKILL_DIR}/../../standards/wireframes.md`, these carry layout and intent, not implementation detail.
|
|
20
20
|
- `.claude/REQUIREMENTS.md`: feature scope and non-goals
|
|
21
21
|
|
|
22
22
|
## Step 2: identify surfaces
|
|
@@ -32,7 +32,7 @@ For each surface, look for:
|
|
|
32
32
|
3. **Inconsistencies**: spacing, tone of voice, interaction patterns, icon use, keyboard affordances
|
|
33
33
|
4. **Roughness in daily use**: friction, redundant steps, unclear affordances, ambiguous labels
|
|
34
34
|
|
|
35
|
-
Use `.claude/DESIGN.md` and the per-surface `.claude/wireframes/<surface>.md` files as ground truth for intent. For each implementation surface, read the matching wireframe file before flagging drift. Observations only, no implementation suggestions or fixes.
|
|
35
|
+
Use `.claude/DESIGN.md` and the per-surface `.claude/wireframes/<surface>.md` files, each a flat file or a grouped surface's own `.claude/wireframes/<surface>/index.md` and the siblings it lists, as ground truth for intent. For each implementation surface, read the matching wireframe file before flagging drift. Observations only, no implementation suggestions or fixes.
|
|
36
36
|
|
|
37
37
|
## Step 4: report and persist
|
|
38
38
|
|
package/docs/agents/commands.md
CHANGED
|
@@ -32,6 +32,7 @@ Full help: `canon <command> --help`. Behavior notes for the install and sync ver
|
|
|
32
32
|
| `canon transcripts <url>` | Fetch a YouTube transcript with metadata frontmatter (needs `yt-dlp`) |
|
|
33
33
|
| `canon tasks archive` | Move a shipped task and its plan off the board, clear its ordering row, and regenerate the index |
|
|
34
34
|
| `canon tasks pull-request` | Record a pull request number on the task a branch closes, by stem or `--plan` (`--json`) |
|
|
35
|
+
| `canon tasks plan-link` | Write or correct a task's `Plan:` line to point at a plan, by stem and plan path or slug (`--json`) |
|
|
35
36
|
| `canon tasks outcome` | Mark outcomes `[x]` on a task by position, repeating `--close` (`--json`) |
|
|
36
37
|
| `canon tasks validate` | Report board rows whose shape, order, plan, task file, group, file set, or blocker does not hold (`--json`) |
|
|
37
38
|
| `canon intake list` | Report intake folder counts, or one folder's items, keeping what is unread with `--unread` (`--json`) |
|
package/docs/agents/tasks.md
CHANGED
|
@@ -104,6 +104,28 @@ The orchestrator dispatch runbook calls this before it checks the branch or the
|
|
|
104
104
|
canon tasks plan-answers dispatch-answer-gate --json | jq -r '.launchable'
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
+
## Plan link
|
|
108
|
+
|
|
109
|
+
`canon tasks plan-link <task> <plan>` writes or corrects a task's `Plan:` line, as `Plan: [<label>](<target>)` right after the H1. `claude-feature` calls it right after a plan file lands, when Step 1 resolved an existing task for the feature, so the line is a mechanical write rather than hand-edited markdown.
|
|
110
|
+
|
|
111
|
+
Name the task by its filename stem, and the plan by its path or its slug, the same two forms `canon tasks plan-answers` accepts:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
canon tasks plan-link v28.1-trigger-escalation dispatch-answer-gate # canon-allow-reference: illustrates the stem-selection form, not a citation of a real task
|
|
115
|
+
canon tasks plan-link v28.1-trigger-escalation .canon/plans/feature-dispatch-answer-gate.md --json
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
| Option | Behavior |
|
|
119
|
+
| --------------- | ------------------------------------------- |
|
|
120
|
+
| `--json` | Emit a machine-readable record on stdout |
|
|
121
|
+
| `--root <path>` | Board root, defaulting to the main worktree |
|
|
122
|
+
|
|
123
|
+
The plan resolves the same way `canon tasks plan-answers` resolves one, against the project root first and `.canon/tasks/` second, so a bare slug and a board-relative path both work. A reference resolving to no file refuses as `no-plan`, naming every base it looked under.
|
|
124
|
+
|
|
125
|
+
The write mirrors `canon tasks pull-request`'s add/correct/unchanged shape, anchored on the H1 rather than on the last origin line, since `Plan:` is the first origin line a task carries rather than the last. The `action` field reports `added`, `corrected`, or `unchanged`, which makes a rerun against the same plan safe.
|
|
126
|
+
|
|
127
|
+
Exit codes: `0` recorded, `1` refused. The `reason` field carries `no-board`, `no-match`, `no-plan`, or `bad-input`.
|
|
128
|
+
|
|
107
129
|
## Pull request
|
|
108
130
|
|
|
109
131
|
`canon tasks pull-request` records the number a branch's pull request carries onto the task that branch closes. It adds `Pull request: #NNN` under the `Plan:`, `Groundwork:`, `Intake:`, or `Issue:` lines the task already holds, and corrects the number in place when the line exists.
|
package/package.json
CHANGED
package/src/commands/migrate.ts
CHANGED
|
@@ -295,6 +295,31 @@ function reportRecords(plan: RecordsPlan, records: number): void {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
+
|
|
299
|
+
// Named individually, same reasoning as the glob report above: an ownership
|
|
300
|
+
// boundary and a tense judgment stop being visible the moment either is
|
|
301
|
+
// rewritten, so the reader gets the file and line rather than a count.
|
|
302
|
+
if (plan.crossRepoCitations.length > 0) {
|
|
303
|
+
logInfo(
|
|
304
|
+
`${plural(plan.crossRepoCitations.length, 'file')} carry a citation into another repository, left alone:`,
|
|
305
|
+
)
|
|
306
|
+
for (const entry of plan.crossRepoCitations) {
|
|
307
|
+
for (const line of entry.lines) {
|
|
308
|
+
logInfo(` ${entry.path}:${line.line} ${excerpt(line.text)}`)
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (plan.datedCitations.length > 0) {
|
|
314
|
+
logInfo(
|
|
315
|
+
`${plural(plan.datedCitations.length, 'file')} carry a dated citation, left alone:`,
|
|
316
|
+
)
|
|
317
|
+
for (const entry of plan.datedCitations) {
|
|
318
|
+
for (const line of entry.lines) {
|
|
319
|
+
logInfo(` ${entry.path}:${line.line} ${excerpt(line.text)}`)
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
298
323
|
}
|
|
299
324
|
|
|
300
325
|
function toRecordsRecord(
|
|
@@ -313,7 +338,11 @@ function toRecordsRecord(
|
|
|
313
338
|
excluded: plan.excluded.length,
|
|
314
339
|
coupled: plan.coupled,
|
|
315
340
|
frontmatterGlobs: plan.frontmatterGlobs,
|
|
341
|
+
crossRepoCitations: plan.crossRepoCitations,
|
|
342
|
+
datedCitations: plan.datedCitations,
|
|
316
343
|
globs: plan.globs,
|
|
344
|
+
crossRepo: plan.crossRepo,
|
|
345
|
+
dated: plan.dated,
|
|
317
346
|
records,
|
|
318
347
|
paths: plan.entries.map((entry) => ({
|
|
319
348
|
path: entry.path,
|
|
@@ -575,6 +604,11 @@ export function register(program: Command): void {
|
|
|
575
604
|
'alone rather than rewritten, since a rewritten glob stops matching',
|
|
576
605
|
'silently. No marker is needed; the YAML shape is enough.',
|
|
577
606
|
'',
|
|
607
|
+
'A citation shaped like a path into another repository, or one sitting',
|
|
608
|
+
'inside a dated paragraph, is reported and left alone rather than',
|
|
609
|
+
'rewritten. The first is an ownership judgment and the second a tense',
|
|
610
|
+
'one, neither of which a regular expression makes reliably.',
|
|
611
|
+
'',
|
|
578
612
|
'The records themselves are never swept. Everything under .canon/ and',
|
|
579
613
|
'every .claude/ record folder is left alone and reported as a count, so',
|
|
580
614
|
'a run after the ignore entries collapse touches the same files as one',
|
package/src/commands/tasks.ts
CHANGED
|
@@ -11,7 +11,9 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
type CloseOutcome,
|
|
13
13
|
closeOutcomes,
|
|
14
|
+
type PlanOutcome,
|
|
14
15
|
type PullRequestOutcome,
|
|
16
|
+
recordPlan,
|
|
15
17
|
type RecordRefused,
|
|
16
18
|
type RecordSelector,
|
|
17
19
|
recordPullRequest,
|
|
@@ -66,6 +68,11 @@ interface PullRequestCommandOptions {
|
|
|
66
68
|
readonly root?: string
|
|
67
69
|
}
|
|
68
70
|
|
|
71
|
+
interface PlanLinkCommandOptions {
|
|
72
|
+
readonly json?: boolean
|
|
73
|
+
readonly root?: string
|
|
74
|
+
}
|
|
75
|
+
|
|
69
76
|
interface OutcomeCommandOptions {
|
|
70
77
|
readonly close?: readonly string[]
|
|
71
78
|
readonly json?: boolean
|
|
@@ -258,6 +265,40 @@ export function register(program: Command): void {
|
|
|
258
265
|
},
|
|
259
266
|
)
|
|
260
267
|
|
|
268
|
+
tasks
|
|
269
|
+
.command('plan-link')
|
|
270
|
+
.description("Write or correct a task's Plan: line to point at a plan")
|
|
271
|
+
.argument('<task>', 'Task filename stem, as in v28.1-trigger-escalation')
|
|
272
|
+
.argument('<plan>', 'Plan path or its slug, as in dispatch-answer-gate')
|
|
273
|
+
.helpOption('-h, --help', 'Show this help message')
|
|
274
|
+
.option('--json', 'Emit a machine-readable record on stdout')
|
|
275
|
+
.option('--root <path>', 'Board root, defaulting to the main worktree')
|
|
276
|
+
.addHelpText(
|
|
277
|
+
'after',
|
|
278
|
+
[
|
|
279
|
+
'',
|
|
280
|
+
'Exit codes:',
|
|
281
|
+
' 0 the line was added, corrected, or already correct',
|
|
282
|
+
' 1 refused, with the reason on stderr or in the JSON record',
|
|
283
|
+
'',
|
|
284
|
+
'It writes Plan: [<label>](<target>) right after the H1, the same',
|
|
285
|
+
'add/correct/unchanged shape canon tasks pull-request writes with, and',
|
|
286
|
+
'resolves both a bare slug and a board-relative path the way',
|
|
287
|
+
'canon tasks plan-answers does. Safe from a linked worktree, since it',
|
|
288
|
+
'resolves the board root in-process.',
|
|
289
|
+
'',
|
|
290
|
+
'Examples:',
|
|
291
|
+
' canon tasks plan-link v28.1-trigger-escalation dispatch-answer-gate',
|
|
292
|
+
' canon tasks plan-link v28.1-trigger-escalation .canon/plans/feature-dispatch-answer-gate.md --json',
|
|
293
|
+
'',
|
|
294
|
+
].join('\n'),
|
|
295
|
+
)
|
|
296
|
+
.action(
|
|
297
|
+
async (task: string, plan: string, opts: PlanLinkCommandOptions) => {
|
|
298
|
+
process.exitCode = await runPlanLink(task, plan, opts)
|
|
299
|
+
},
|
|
300
|
+
)
|
|
301
|
+
|
|
261
302
|
tasks
|
|
262
303
|
.command('outcome')
|
|
263
304
|
.description('Mark outcomes closed on a task by their position')
|
|
@@ -366,6 +407,18 @@ async function runPullRequest(
|
|
|
366
407
|
return reportPullRequest(outcome, emitJson, root)
|
|
367
408
|
}
|
|
368
409
|
|
|
410
|
+
async function runPlanLink(
|
|
411
|
+
task: string,
|
|
412
|
+
plan: string,
|
|
413
|
+
opts: PlanLinkCommandOptions,
|
|
414
|
+
): Promise<number> {
|
|
415
|
+
const emitJson = opts.json ?? false
|
|
416
|
+
const root = opts.root ?? (await mainWorktreeRoot())
|
|
417
|
+
const outcome = await recordPlan(root, task, plan)
|
|
418
|
+
|
|
419
|
+
return reportPlanLink(outcome, emitJson, root)
|
|
420
|
+
}
|
|
421
|
+
|
|
369
422
|
async function runOutcome(
|
|
370
423
|
task: string | undefined,
|
|
371
424
|
opts: OutcomeCommandOptions,
|
|
@@ -484,6 +537,38 @@ function reportPullRequest(
|
|
|
484
537
|
return 0
|
|
485
538
|
}
|
|
486
539
|
|
|
540
|
+
function reportPlanLink(
|
|
541
|
+
outcome: PlanOutcome,
|
|
542
|
+
emitJson: boolean,
|
|
543
|
+
root: string,
|
|
544
|
+
): number {
|
|
545
|
+
if (!outcome.ok) {
|
|
546
|
+
return reportRecord('canon tasks plan-link', outcome, emitJson, root)
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
if (emitJson) {
|
|
550
|
+
process.stdout.write(
|
|
551
|
+
`${JSON.stringify({
|
|
552
|
+
ok: true,
|
|
553
|
+
root,
|
|
554
|
+
task: outcome.stem,
|
|
555
|
+
path: relative(root, outcome.path),
|
|
556
|
+
plan: outcome.plan,
|
|
557
|
+
action: outcome.action,
|
|
558
|
+
})}\n`,
|
|
559
|
+
)
|
|
560
|
+
return 0
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
intro('canon tasks plan-link')
|
|
564
|
+
logStep(outcome.action === 'unchanged' ? 'Already recorded' : 'Recorded')
|
|
565
|
+
logInfo(`${outcome.stem} names plan ${outcome.plan}`)
|
|
566
|
+
if (outcome.action !== 'unchanged') logAdd(relative(root, outcome.path))
|
|
567
|
+
outro()
|
|
568
|
+
|
|
569
|
+
return 0
|
|
570
|
+
}
|
|
571
|
+
|
|
487
572
|
function reportOutcome(
|
|
488
573
|
outcome: CloseOutcome,
|
|
489
574
|
emitJson: boolean,
|
package/src/migrate/records.ts
CHANGED
|
@@ -257,7 +257,60 @@ function isFrontmatterPathsLine(
|
|
|
257
257
|
return lines[top]?.trim().startsWith('paths:') ?? false
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
|
|
260
|
+
/**
|
|
261
|
+
* A path segment immediately before a citation match, shaped like another
|
|
262
|
+
* repository's own name: it carries a dot (a domain-shaped token, matching
|
|
263
|
+
* the measured `erclx.dev`) or it is itself preceded by a further `/` (two
|
|
264
|
+
* path segments deep, also matching the measured `public/erclx.dev/...`).
|
|
265
|
+
*
|
|
266
|
+
* Bounded by `[\w.-]`, which is what keeps a shell-glob prefix such as
|
|
267
|
+
* `*` before the slash and a variable-substitution prefix such as
|
|
268
|
+
* `$project` out: neither `*` nor `$` is in the class, so a segment built
|
|
269
|
+
* from either never reaches the dot or the second slash this looks for.
|
|
270
|
+
*/
|
|
271
|
+
const CROSS_REPO_PREFIX = /(?:[\w.-]+\.[\w.-]+|[\w.-]+\/[\w.-]+)\/$/
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Whether the line's citation sits right after a prefix `CROSS_REPO_PREFIX`
|
|
275
|
+
* reads as another repository's own path. Per-line rather than per-match,
|
|
276
|
+
* matching `isKept`'s and `isFrontmatterPathsLine`'s granularity: a line
|
|
277
|
+
* carrying more than one citation is judged by the first.
|
|
278
|
+
*/
|
|
279
|
+
function isCrossRepoPrefix(lines: readonly string[], index: number): boolean {
|
|
280
|
+
const line = lines[index] ?? ''
|
|
281
|
+
const match = [...line.matchAll(CITATION)][0]
|
|
282
|
+
if (match === undefined) return false
|
|
283
|
+
|
|
284
|
+
return CROSS_REPO_PREFIX.test(line.slice(0, match.index ?? 0))
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** An ISO date, marking a paragraph as recording what was true on that day. */
|
|
288
|
+
const ISO_DATE = /\b\d{4}-\d{2}-\d{2}\b/
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Whether the line's citation sits inside a blank-line-delimited paragraph
|
|
292
|
+
* that also carries an ISO date, read as dated prose rather than a live path.
|
|
293
|
+
*
|
|
294
|
+
* Walks both directions from `index` to the paragraph's edges, unlike
|
|
295
|
+
* `isKept`'s upward-only walk to a marker: the date can close a paragraph the
|
|
296
|
+
* citation opens, as `.claude/ARCHITECTURE.md`'s own `Measured at ... on
|
|
297
|
+
* <date>` sentences do.
|
|
298
|
+
*/
|
|
299
|
+
function isDatedParagraph(lines: readonly string[], index: number): boolean {
|
|
300
|
+
let start = index
|
|
301
|
+
while (start > 0 && lines[start - 1]?.trim() !== '') start -= 1
|
|
302
|
+
|
|
303
|
+
let end = index
|
|
304
|
+
while (end < lines.length - 1 && lines[end + 1]?.trim() !== '') end += 1
|
|
305
|
+
|
|
306
|
+
for (let cursor = start; cursor <= end; cursor += 1) {
|
|
307
|
+
if (ISO_DATE.test(lines[cursor] ?? '')) return true
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return false
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
type LineClass = 'live' | 'kept' | 'glob' | 'crossRepo' | 'dated'
|
|
261
314
|
|
|
262
315
|
function classifyLine(
|
|
263
316
|
lines: readonly string[],
|
|
@@ -266,6 +319,8 @@ function classifyLine(
|
|
|
266
319
|
): LineClass {
|
|
267
320
|
if (isFrontmatterPathsLine(lines, index, frontmatterEndIndex)) return 'glob'
|
|
268
321
|
if (isKept(lines, index)) return 'kept'
|
|
322
|
+
if (isCrossRepoPrefix(lines, index)) return 'crossRepo'
|
|
323
|
+
if (isDatedParagraph(lines, index)) return 'dated'
|
|
269
324
|
return 'live'
|
|
270
325
|
}
|
|
271
326
|
|
|
@@ -287,8 +342,9 @@ export function rewriteText(text: string): string {
|
|
|
287
342
|
|
|
288
343
|
/**
|
|
289
344
|
* How many citations `rewriteText` would rewrite, how many marked lines it
|
|
290
|
-
* left alone,
|
|
291
|
-
*
|
|
345
|
+
* left alone, how many sat inside a frontmatter `paths:` glob, how many sat
|
|
346
|
+
* behind a cross-repository-shaped prefix, and how many sat inside a dated
|
|
347
|
+
* paragraph. Every number past the first is what says its boundary fired at
|
|
292
348
|
* all, which a diff cannot show because a protected line does not appear in
|
|
293
349
|
* one.
|
|
294
350
|
*/
|
|
@@ -296,12 +352,16 @@ export function scanText(text: string): {
|
|
|
296
352
|
readonly rewritten: number
|
|
297
353
|
readonly kept: number
|
|
298
354
|
readonly globs: number
|
|
355
|
+
readonly crossRepo: number
|
|
356
|
+
readonly dated: number
|
|
299
357
|
} {
|
|
300
358
|
const lines = text.split('\n')
|
|
301
359
|
const frontmatterEndIndex = frontmatterEnd(lines)
|
|
302
360
|
let rewritten = 0
|
|
303
361
|
let kept = 0
|
|
304
362
|
let globs = 0
|
|
363
|
+
let crossRepo = 0
|
|
364
|
+
let dated = 0
|
|
305
365
|
|
|
306
366
|
for (const [index, line] of lines.entries()) {
|
|
307
367
|
const matches = [...line.matchAll(CITATION)].length
|
|
@@ -310,10 +370,12 @@ export function scanText(text: string): {
|
|
|
310
370
|
const kind = classifyLine(lines, index, frontmatterEndIndex)
|
|
311
371
|
if (kind === 'glob') globs += matches
|
|
312
372
|
else if (kind === 'kept') kept += matches
|
|
373
|
+
else if (kind === 'crossRepo') crossRepo += matches
|
|
374
|
+
else if (kind === 'dated') dated += matches
|
|
313
375
|
else rewritten += matches
|
|
314
376
|
}
|
|
315
377
|
|
|
316
|
-
return { rewritten, kept, globs }
|
|
378
|
+
return { rewritten, kept, globs, crossRepo, dated }
|
|
317
379
|
}
|
|
318
380
|
|
|
319
381
|
/** Where a citation sits, so a reader can judge it before `--write` runs. */
|
|
@@ -338,6 +400,45 @@ function frontmatterGlobLines(text: string): CitationLine[] {
|
|
|
338
400
|
return held
|
|
339
401
|
}
|
|
340
402
|
|
|
403
|
+
/**
|
|
404
|
+
* Every line in `text` whose citation `classifyLine` reads as `crossRepo`.
|
|
405
|
+
*
|
|
406
|
+
* Reads through `classifyLine` rather than `isCrossRepoPrefix` alone, so a
|
|
407
|
+
* line a glob or a keep marker already claims is not reported twice under a
|
|
408
|
+
* second boundary.
|
|
409
|
+
*/
|
|
410
|
+
function crossRepoLines(text: string): CitationLine[] {
|
|
411
|
+
const lines = text.split('\n')
|
|
412
|
+
const frontmatterEndIndex = frontmatterEnd(lines)
|
|
413
|
+
const held: CitationLine[] = []
|
|
414
|
+
|
|
415
|
+
for (const [index, line] of lines.entries()) {
|
|
416
|
+
if ([...line.matchAll(CITATION)].length === 0) continue
|
|
417
|
+
if (classifyLine(lines, index, frontmatterEndIndex) !== 'crossRepo')
|
|
418
|
+
continue
|
|
419
|
+
|
|
420
|
+
held.push({ line: index + 1, text: line.trim() })
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return held
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** Every line in `text` whose citation `classifyLine` reads as `dated`. */
|
|
427
|
+
function datedLines(text: string): CitationLine[] {
|
|
428
|
+
const lines = text.split('\n')
|
|
429
|
+
const frontmatterEndIndex = frontmatterEnd(lines)
|
|
430
|
+
const held: CitationLine[] = []
|
|
431
|
+
|
|
432
|
+
for (const [index, line] of lines.entries()) {
|
|
433
|
+
if ([...line.matchAll(CITATION)].length === 0) continue
|
|
434
|
+
if (classifyLine(lines, index, frontmatterEndIndex) !== 'dated') continue
|
|
435
|
+
|
|
436
|
+
held.push({ line: index + 1, text: line.trim() })
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
return held
|
|
440
|
+
}
|
|
441
|
+
|
|
341
442
|
export interface FolderMove {
|
|
342
443
|
readonly from: string
|
|
343
444
|
readonly to: string
|
|
@@ -402,6 +503,18 @@ export interface FrontmatterGlobEntry {
|
|
|
402
503
|
readonly lines: readonly CitationLine[]
|
|
403
504
|
}
|
|
404
505
|
|
|
506
|
+
/** One file whose citation resolves outside this project, held rather than rewritten. */
|
|
507
|
+
export interface CrossRepoCitationEntry {
|
|
508
|
+
readonly path: string
|
|
509
|
+
readonly lines: readonly CitationLine[]
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/** One file whose citation sits inside a dated paragraph, held rather than rewritten. */
|
|
513
|
+
export interface DatedCitationEntry {
|
|
514
|
+
readonly path: string
|
|
515
|
+
readonly lines: readonly CitationLine[]
|
|
516
|
+
}
|
|
517
|
+
|
|
405
518
|
export interface RecordsPlan {
|
|
406
519
|
readonly moves: readonly FolderMove[]
|
|
407
520
|
readonly collisions: readonly string[]
|
|
@@ -409,9 +522,13 @@ export interface RecordsPlan {
|
|
|
409
522
|
readonly excluded: readonly string[]
|
|
410
523
|
readonly coupled: readonly string[]
|
|
411
524
|
readonly frontmatterGlobs: readonly FrontmatterGlobEntry[]
|
|
525
|
+
readonly crossRepoCitations: readonly CrossRepoCitationEntry[]
|
|
526
|
+
readonly datedCitations: readonly DatedCitationEntry[]
|
|
412
527
|
readonly rewritten: number
|
|
413
528
|
readonly kept: number
|
|
414
529
|
readonly globs: number
|
|
530
|
+
readonly crossRepo: number
|
|
531
|
+
readonly dated: number
|
|
415
532
|
}
|
|
416
533
|
|
|
417
534
|
/**
|
|
@@ -431,8 +548,12 @@ export function planRecordsMove(
|
|
|
431
548
|
const excluded: string[] = []
|
|
432
549
|
const coupled: string[] = []
|
|
433
550
|
const frontmatterGlobs: FrontmatterGlobEntry[] = []
|
|
551
|
+
const crossRepoCitations: CrossRepoCitationEntry[] = []
|
|
552
|
+
const datedCitations: DatedCitationEntry[] = []
|
|
434
553
|
let kept = 0
|
|
435
554
|
let globs = 0
|
|
555
|
+
let crossRepo = 0
|
|
556
|
+
let dated = 0
|
|
436
557
|
|
|
437
558
|
for (const source of sources) {
|
|
438
559
|
// Silently, and ahead of the exclusion test. The command boundary filters
|
|
@@ -452,13 +573,24 @@ export function planRecordsMove(
|
|
|
452
573
|
const counts = scanText(source.text)
|
|
453
574
|
kept += counts.kept
|
|
454
575
|
globs += counts.globs
|
|
576
|
+
crossRepo += counts.crossRepo
|
|
577
|
+
dated += counts.dated
|
|
455
578
|
|
|
456
579
|
// Ahead of the rewritten === 0 continue below: a file whose only citation
|
|
457
|
-
// sits in its paths: glob
|
|
580
|
+
// sits in its paths: glob, a cross-repo prefix, or a dated paragraph still
|
|
581
|
+
// needs to be reported.
|
|
458
582
|
const held = frontmatterGlobLines(source.text)
|
|
459
583
|
if (held.length > 0)
|
|
460
584
|
frontmatterGlobs.push({ path: source.path, lines: held })
|
|
461
585
|
|
|
586
|
+
const foreign = crossRepoLines(source.text)
|
|
587
|
+
if (foreign.length > 0)
|
|
588
|
+
crossRepoCitations.push({ path: source.path, lines: foreign })
|
|
589
|
+
|
|
590
|
+
const dates = datedLines(source.text)
|
|
591
|
+
if (dates.length > 0)
|
|
592
|
+
datedCitations.push({ path: source.path, lines: dates })
|
|
593
|
+
|
|
462
594
|
if (counts.rewritten === 0) continue
|
|
463
595
|
|
|
464
596
|
if (referencesExcluded(source.text)) coupled.push(source.path)
|
|
@@ -478,8 +610,12 @@ export function planRecordsMove(
|
|
|
478
610
|
excluded,
|
|
479
611
|
coupled,
|
|
480
612
|
frontmatterGlobs,
|
|
613
|
+
crossRepoCitations,
|
|
614
|
+
datedCitations,
|
|
481
615
|
rewritten: entries.reduce((sum, entry) => sum + entry.rewritten, 0),
|
|
482
616
|
kept,
|
|
483
617
|
globs,
|
|
618
|
+
crossRepo,
|
|
619
|
+
dated,
|
|
484
620
|
}
|
|
485
621
|
}
|
package/src/tasks/archive.ts
CHANGED
|
@@ -211,10 +211,23 @@ export function readPlanTarget(text: string): string | undefined {
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
/**
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
214
|
+
* Builds a `Plan:` line as a markdown link whose text and target stay in step,
|
|
215
|
+
* the label taken from the target's filename with its extension dropped.
|
|
216
|
+
* `record.ts` reuses this so a plan-link write and an archive retarget produce
|
|
217
|
+
* one line shape rather than two.
|
|
218
|
+
*/
|
|
219
|
+
export function planLine(target: string): string {
|
|
220
|
+
const name = basename(target)
|
|
221
|
+
const label = name.endsWith('.md') ? name.slice(0, -'.md'.length) : name
|
|
222
|
+
|
|
223
|
+
return `Plan: [${label}](${target})`
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Points the task's `Plan:` line at the plan's new home. The line is matched
|
|
228
|
+
* with the pattern the read above uses, so the archive rewrites exactly the
|
|
229
|
+
* line it parsed and never a second `Plan:` a task displays inside a fenced
|
|
230
|
+
* sample.
|
|
218
231
|
*
|
|
219
232
|
* The replacement is built by a function rather than passed as a string,
|
|
220
233
|
* because `$&` and its siblings are substitution sequences inside a replacement
|
|
@@ -222,10 +235,7 @@ export function readPlanTarget(text: string): string | undefined {
|
|
|
222
235
|
* `.canon/plans/` is gitignored, so nothing recovers the pointer it replaced.
|
|
223
236
|
*/
|
|
224
237
|
export function retargetPlanLine(text: string, target: string): string {
|
|
225
|
-
|
|
226
|
-
const label = name.endsWith('.md') ? name.slice(0, -'.md'.length) : name
|
|
227
|
-
|
|
228
|
-
return text.replace(PLAN_PATTERN, () => `Plan: [${label}](${target})`)
|
|
238
|
+
return text.replace(PLAN_PATTERN, () => planLine(target))
|
|
229
239
|
}
|
|
230
240
|
|
|
231
241
|
/**
|
|
@@ -624,7 +634,7 @@ async function planToArchive(
|
|
|
624
634
|
* deeper than the live pair, so the link is measured between the two
|
|
625
635
|
* destinations rather than written as the `../plans/` the live task carried.
|
|
626
636
|
*/
|
|
627
|
-
function linkTo(taskDir: string, plan: string): string {
|
|
637
|
+
export function linkTo(taskDir: string, plan: string): string {
|
|
628
638
|
return relative(taskDir, plan).split(sep).join('/')
|
|
629
639
|
}
|
|
630
640
|
|
package/src/tasks/record.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs'
|
|
2
2
|
import { readFile, writeFile } from 'node:fs/promises'
|
|
3
3
|
import { basename, join, relative } from 'node:path'
|
|
4
|
+
import { planCandidates } from '@/tasks/answers'
|
|
4
5
|
import {
|
|
5
6
|
fenceMask,
|
|
7
|
+
linkTo,
|
|
6
8
|
listTaskStems,
|
|
7
9
|
OUTCOME_PATTERN,
|
|
10
|
+
planLine,
|
|
8
11
|
readPlanTarget,
|
|
9
12
|
tasksDir,
|
|
10
13
|
} from '@/tasks/archive'
|
|
@@ -28,6 +31,7 @@ export const RECORD_REFUSALS = [
|
|
|
28
31
|
'ambiguous',
|
|
29
32
|
'no-outcomes',
|
|
30
33
|
'out-of-range',
|
|
34
|
+
'no-plan',
|
|
31
35
|
'bad-input',
|
|
32
36
|
] as const
|
|
33
37
|
|
|
@@ -56,6 +60,16 @@ export interface PullRequestRecorded {
|
|
|
56
60
|
|
|
57
61
|
export type PullRequestOutcome = PullRequestRecorded | RecordRefused
|
|
58
62
|
|
|
63
|
+
export interface PlanRecorded {
|
|
64
|
+
readonly ok: true
|
|
65
|
+
readonly stem: string
|
|
66
|
+
readonly path: string
|
|
67
|
+
readonly plan: string
|
|
68
|
+
readonly action: LineAction
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type PlanOutcome = PlanRecorded | RecordRefused
|
|
72
|
+
|
|
59
73
|
export interface OutcomesClosed {
|
|
60
74
|
readonly ok: true
|
|
61
75
|
readonly stem: string
|
|
@@ -127,6 +141,33 @@ function lastOriginLine(lines: readonly string[]): number | undefined {
|
|
|
127
141
|
return found
|
|
128
142
|
}
|
|
129
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Places the `Plan:` line right after the H1, mirroring
|
|
146
|
+
* `writePullRequestLine`'s add/correct/unchanged shape. `Plan:` is the first
|
|
147
|
+
* origin line a task carries, so it anchors on the heading itself rather than
|
|
148
|
+
* on the last origin line above it.
|
|
149
|
+
*/
|
|
150
|
+
export function writePlanLine(
|
|
151
|
+
text: string,
|
|
152
|
+
target: string,
|
|
153
|
+
): { readonly text: string; readonly action: LineAction } {
|
|
154
|
+
const line = planLine(target)
|
|
155
|
+
const lines = text.split('\n')
|
|
156
|
+
const existing = lines.findIndex((entry) => entry.startsWith('Plan:'))
|
|
157
|
+
|
|
158
|
+
if (existing !== -1) {
|
|
159
|
+
if (lines[existing] === line) return { text, action: 'unchanged' }
|
|
160
|
+
lines[existing] = line
|
|
161
|
+
return { text: lines.join('\n'), action: 'corrected' }
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const heading = lines.findIndex((entry) => entry.startsWith('# '))
|
|
165
|
+
if (heading === -1) return { text: `${line}\n${text}`, action: 'added' }
|
|
166
|
+
|
|
167
|
+
lines.splice(heading + 1, 0, '', line)
|
|
168
|
+
return { text: lines.join('\n'), action: 'added' }
|
|
169
|
+
}
|
|
170
|
+
|
|
130
171
|
/**
|
|
131
172
|
* Marks outcomes closed by their 1-based position in the task's outcome list,
|
|
132
173
|
* which is the order the board format writes them. A caller reads the file
|
|
@@ -267,6 +308,42 @@ export async function recordPullRequest(
|
|
|
267
308
|
return { ok: true, stem, path, number, action }
|
|
268
309
|
}
|
|
269
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Records a plan's path on the task it belongs to, as the task's `Plan:` line.
|
|
313
|
+
* `claude-feature` runs this right after the plan file lands, resolving the
|
|
314
|
+
* reference the same two ways `canon tasks plan-answers` does, through
|
|
315
|
+
* `planCandidates`, so a bare slug and a board-relative path both resolve.
|
|
316
|
+
*
|
|
317
|
+
* The task is named directly rather than through `RecordSelector`'s `plan`
|
|
318
|
+
* kind: every caller already holds the stem, since resolving the task is what
|
|
319
|
+
* put it in a position to write the plan's path in the first place.
|
|
320
|
+
*/
|
|
321
|
+
export async function recordPlan(
|
|
322
|
+
root: string,
|
|
323
|
+
stem: string,
|
|
324
|
+
reference: string,
|
|
325
|
+
): Promise<PlanOutcome> {
|
|
326
|
+
const opened = await openTask(root, { kind: 'stem', stem })
|
|
327
|
+
if ('ok' in opened) return opened
|
|
328
|
+
|
|
329
|
+
const { path } = opened
|
|
330
|
+
const dir = tasksDir(root)
|
|
331
|
+
const candidates = planCandidates(root, reference)
|
|
332
|
+
const plan = candidates.find((candidate) => existsSync(candidate))
|
|
333
|
+
|
|
334
|
+
if (!plan) {
|
|
335
|
+
const looked = candidates.map((entry) => relative(root, entry)).join(' or ')
|
|
336
|
+
return refuse('no-plan', `No plan at ${looked}.`, [reference])
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const target = linkTo(dir, plan)
|
|
340
|
+
const { text, action } = writePlanLine(await readFile(path, 'utf8'), target)
|
|
341
|
+
|
|
342
|
+
if (action !== 'unchanged') await writeFile(path, text)
|
|
343
|
+
|
|
344
|
+
return { ok: true, stem: opened.stem, path, plan: target, action }
|
|
345
|
+
}
|
|
346
|
+
|
|
270
347
|
/**
|
|
271
348
|
* Marks the named outcomes `[x]` in place. `claude-docs` runs this against a
|
|
272
349
|
* board it can read and cannot edit from a linked worktree, and the positions
|
package/standards/tasks.md
CHANGED
|
@@ -219,6 +219,8 @@ A project that archived plans before the folder nested under `.canon/plans/` hol
|
|
|
219
219
|
|
|
220
220
|
One plan per task. A plan cited by two tasks is a misfile rather than a shape to design for, which is why the sweep counts citations before archiving: the count is a guard against the misfile stranding a pointer, not support for the shape.
|
|
221
221
|
|
|
222
|
+
`canon tasks plan-link <task> <plan>` writes or corrects the `Plan:` line, mirroring how `canon tasks pull-request` writes its own. `claude-feature` calls it right after the plan file lands, when an existing task names the feature, so the line is a mechanical write rather than hand-edited markdown.
|
|
223
|
+
|
|
222
224
|
`Groundwork:` points at `../groundwork/<slug>/`, the folder `claude-groundwork` fills. It names the surface it points at the way `Plan:` does. Use this key alone. `Research record` and `Decision record` are earlier spellings of the same thing and both convert to it.
|
|
223
225
|
|
|
224
226
|
`Intake:` points at `../intake/<slug>/`, the folder an intake pass fills. Use it rather than `Groundwork:`, because a groundwork track measures one question in depth while an intake dispositions many across a tree, and one key covering both loses which kind of pass produced the task. The line names the folder rather than an item inside it. A task routinely promotes several items at once, so an anchored line would name one and drop the rest, and the item numbers belong in that task's `## Findings`.
|
package/standards/versioning.md
CHANGED
|
@@ -18,6 +18,7 @@ Does not govern:
|
|
|
18
18
|
- Commit subject, branch name, and pull request title format: `commit.md`, `branch.md`, and `pr.md`
|
|
19
19
|
- Voice, rhythm, and sentence construction in any text carrying a label: the `write-human` skill
|
|
20
20
|
- Punctuation, formatting, and word choice in any text carrying a label: `markdown.md`
|
|
21
|
+
- How a quoted-alone version-shaped token or a record path is caught as a board reference, which sits outside the phase-label/semver split this file owns: `publish.md`
|
|
21
22
|
|
|
22
23
|
## Phase labels
|
|
23
24
|
|
|
@@ -59,6 +60,10 @@ External release identity used in git tags and release notes. Independent of pha
|
|
|
59
60
|
- Git tags use semver only. Phase labels never become tags.
|
|
60
61
|
- A PR that cuts a release may reference its semver tag in the title or body. Phase labels still do not appear.
|
|
61
62
|
- PR bodies, review comments, and issue text name the change itself, never the internal stream that scheduled it. Describe the work rather than the label it was planned under.
|
|
63
|
+
- A phase label written alone inside its own code span reads as shown rather than asserted. `canon labels scan` masks a code span before checking for a bare token, so a backticked label on its own does not count as an appearance for the phase-label check.
|
|
64
|
+
- That masking clears one check and not the gate. A span whose whole content is the label still resolves as a board reference under `publish.md`'s own board-identifier check, run by the same scan, so a title or body quoting a label alone in a span still fails on that check and does not clear every surface the table above marks `no`.
|
|
65
|
+
- The one shape neither check reaches is a version-shaped token folded into a longer quoted phrase, such as a fixture name or a file path. A backticked span quoting a test fixture's own version-shaped name is the corpus case that forced this carve-out, and a real phase label folded the same way inside a review comment is the counterexample where it read as clean on both checks.
|
|
66
|
+
- The operator decided to keep the carve-out rather than narrow it to fenced blocks alone or drop it outright, leaving an author responsible for writing a live reference in plain text instead of folding it into a quoted phrase.
|
|
62
67
|
- A phase label in a context entry is permitted only when its substance is restated inline beside it. A bare label carrying nothing beside it is forbidden, since a reader without the board has nothing to resolve it against.
|
|
63
68
|
- A phase label carries no exception for a surface this repository authors and ships to a target it does not control: a standard, a skill body, and a governance rule are all forbidden outright, substance restated or not. The line is ownership rather than reachability. A shipped file is read by a project that never edits it, so the label names a board that reader can never reach. A context entry stays permitted above because it is this project's own tracked surface, never shipped.
|
|
64
69
|
- The shipped-surface rule governs a reference to a real row, never a token shown to illustrate the label's own format. A phase label naming no decision, written only to show the pattern's shape, is not a citation, which is what lets a standard defining the format still show what one looks like.
|