@erclx/canon 4.77.0 → 4.79.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 (145) hide show
  1. package/README.md +9 -9
  2. package/claude/.claude-plugin/plugin.json +1 -1
  3. package/claude/skills/canon-operator/SKILL.md +1 -1
  4. package/claude/skills/create-standard/SKILL.md +1 -1
  5. package/claude/skills/design-extract/REQUIREMENT.md +4 -4
  6. package/claude/skills/design-extract/SKILL.md +11 -11
  7. package/claude/skills/docs-fold/SKILL.md +14 -14
  8. package/claude/skills/docs-fold/references/anchor-sweep.md +1 -1
  9. package/claude/skills/docs-fold/references/wireframe-sweep.md +4 -4
  10. package/claude/skills/draft-context/REQUIREMENT.md +6 -6
  11. package/claude/skills/draft-context/SKILL.md +8 -6
  12. package/claude/skills/draft-diagram/SKILL.md +5 -5
  13. package/claude/skills/draft-identity/SKILL.md +3 -3
  14. package/claude/skills/draft-readme/REQUIREMENT.md +1 -1
  15. package/claude/skills/draft-screencast/SKILL.md +1 -1
  16. package/claude/skills/draft-wireframes/REQUIREMENT.md +7 -7
  17. package/claude/skills/draft-wireframes/SKILL.md +7 -5
  18. package/claude/skills/memory-capture/REQUIREMENT.md +1 -1
  19. package/claude/skills/memory-capture/SKILL.md +6 -6
  20. package/claude/skills/memory-review/SKILL.md +1 -1
  21. package/claude/skills/migration-claude-md/REQUIREMENT.md +3 -3
  22. package/claude/skills/migration-claude-md/SKILL.md +7 -5
  23. package/claude/skills/migration-context/REQUIREMENT.md +3 -3
  24. package/claude/skills/migration-context/SKILL.md +11 -9
  25. package/claude/skills/plan-feature/SKILL.md +4 -4
  26. package/claude/skills/plan-groundwork/SKILL.md +2 -2
  27. package/claude/skills/plan-intake/SKILL.md +2 -2
  28. package/claude/skills/project-commands/SKILL.md +2 -2
  29. package/claude/skills/review-branch/SKILL.md +3 -3
  30. package/claude/skills/review-pr/SKILL.md +2 -2
  31. package/claude/skills/role-orchestrator/SKILL.md +1 -1
  32. package/claude/skills/role-planner/SKILL.md +1 -1
  33. package/claude/skills/session-relay/REQUIREMENT.md +1 -1
  34. package/claude/skills/session-resume/SKILL.md +1 -1
  35. package/claude/skills/setup-gov/SKILL.md +1 -1
  36. package/claude/skills/setup-init/SKILL.md +1 -1
  37. package/claude/skills/teach-workspace/references/promotion.md +5 -7
  38. package/claude/skills/ux-audit/SKILL.md +5 -5
  39. package/claude/skills/ux-measure/SKILL.md +1 -1
  40. package/docs/agents/capture.md +6 -5
  41. package/docs/agents/commands.md +8 -3
  42. package/docs/agents/context-audit-checks.md +3 -3
  43. package/docs/agents/context-audit.md +2 -2
  44. package/docs/agents/counts.md +3 -3
  45. package/docs/agents/design-board.md +3 -3
  46. package/docs/agents/docs.md +3 -3
  47. package/docs/agents/driver.md +1 -1
  48. package/docs/agents/indexes.md +1 -1
  49. package/docs/agents/install-and-sync.md +1 -1
  50. package/docs/agents/review-classification.md +1 -1
  51. package/docs/agents/routing.md +2 -2
  52. package/docs/agents/rule-citations.md +1 -1
  53. package/docs/agents/sandbox.md +1 -1
  54. package/docs/agents/scripting.md +1 -1
  55. package/docs/agents/skills-audit.md +1 -1
  56. package/docs/agents/skills-reach.md +4 -4
  57. package/docs/target-projects.md +10 -10
  58. package/docs/workflow/ai-workflow.md +16 -14
  59. package/docs/workflow/operating-model.md +2 -2
  60. package/docs/workflow/visual-design-workflow.md +20 -21
  61. package/governance/rules/claude/510-context.md +3 -2
  62. package/governance/rules/claude/520-wireframes.md +3 -2
  63. package/governance/rules/claude/530-requirements.md +2 -1
  64. package/governance/rules/claude/540-architecture.md +2 -1
  65. package/governance/rules/claude/550-design.md +2 -1
  66. package/governance/rules/core/025-indexes.md +1 -1
  67. package/governance/rules/core/045-memory.md +1 -1
  68. package/package.json +1 -1
  69. package/scripts/core/check-ignore-parity.sh +1 -1
  70. package/scripts/core/check-seed-independence.sh +5 -2
  71. package/scripts/core/install-check.sh +1 -1
  72. package/scripts/core/list-seed-roots.sh +3 -3
  73. package/scripts/core/regen-hero.sh +1 -1
  74. package/scripts/docs/list.sh +3 -3
  75. package/scripts/lib/sandbox-git.sh +1 -1
  76. package/scripts/lib/tooling.sh +6 -4
  77. package/snippets/claude/figma-steps.md +1 -1
  78. package/src/audits/catalog.ts +2 -2
  79. package/src/autoship/paths.ts +1 -1
  80. package/src/capture/render.ts +26 -9
  81. package/src/capture/sources.ts +29 -3
  82. package/src/claude/cases/authoring.ts +2 -2
  83. package/src/claude/cases/setup.ts +1 -1
  84. package/src/claude/routing.ts +1 -1
  85. package/src/claude/seeds-list.ts +1 -1
  86. package/src/claude/seeds.ts +62 -28
  87. package/src/claude/skills-reach.ts +3 -3
  88. package/src/commands/capture.ts +17 -6
  89. package/src/commands/claude.ts +1 -1
  90. package/src/commands/context.ts +8 -8
  91. package/src/commands/design.ts +1 -1
  92. package/src/commands/gov.ts +1 -1
  93. package/src/commands/migrate.ts +182 -1
  94. package/src/context/audit.ts +1 -1
  95. package/src/context/citations.ts +7 -5
  96. package/src/context/folders.ts +2 -2
  97. package/src/counts/scan.ts +4 -4
  98. package/src/design/board.ts +5 -5
  99. package/src/design/components.ts +2 -2
  100. package/src/design/css.ts +1 -1
  101. package/src/design/document.ts +1 -1
  102. package/src/design/regen.ts +1 -1
  103. package/src/design/render.ts +1 -1
  104. package/src/design/tokens.ts +2 -2
  105. package/src/docs/read.ts +9 -3
  106. package/src/gate/measures.ts +10 -7
  107. package/src/gate/stages.ts +4 -4
  108. package/src/markdown/scan.ts +1 -1
  109. package/src/migrate/surface-roots.ts +458 -0
  110. package/src/record-root.ts +6 -4
  111. package/src/sandbox/census.ts +1 -1
  112. package/src/shipped/references.ts +3 -3
  113. package/src/surface-root.ts +39 -7
  114. package/src/sync/layout.ts +10 -6
  115. package/src/sync/reverse.ts +1 -1
  116. package/src/tooling/inject.ts +5 -3
  117. package/src/tooling/scan.ts +4 -1
  118. package/standards/architecture.md +4 -4
  119. package/standards/context.md +7 -7
  120. package/standards/design.md +3 -3
  121. package/standards/diagrams.md +6 -6
  122. package/standards/index.md +5 -5
  123. package/standards/markdown.md +2 -2
  124. package/standards/publish.md +3 -3
  125. package/standards/readme.md +1 -1
  126. package/standards/requirements.md +4 -4
  127. package/standards/skill.md +2 -2
  128. package/standards/tasks.md +1 -1
  129. package/standards/wiki.md +3 -5
  130. package/standards/wireframes.md +8 -8
  131. package/tooling/astro/reference.md +3 -3
  132. package/tooling/base/reference.md +3 -3
  133. package/tooling/claude/reference.md +7 -3
  134. package/tooling/claude/seeds/CLAUDE.md +9 -9
  135. package/tooling/nextjs/reference.md +2 -2
  136. package/tooling/python/reference.md +1 -1
  137. package/tooling/vite-react/reference.md +2 -2
  138. package/tooling/web/reference.md +2 -2
  139. /package/tooling/base/seeds/{.claude → canon}/context/ci.md +0 -0
  140. /package/tooling/base/seeds/{.claude → canon}/context/development.md +0 -0
  141. /package/tooling/base/seeds/{.claude → canon}/context/index.md +0 -0
  142. /package/tooling/claude/seeds/{.claude → canon}/ARCHITECTURE.md +0 -0
  143. /package/tooling/claude/seeds/{.claude → canon}/DESIGN.md +0 -0
  144. /package/tooling/claude/seeds/{.claude → canon}/REQUIREMENTS.md +0 -0
  145. /package/tooling/claude/seeds/{.claude → canon}/wireframes/index.md +0 -0
@@ -0,0 +1,458 @@
1
+ /**
2
+ * The move of the tracked toolkit surfaces from `.claude/` to `canon/`.
3
+ *
4
+ * Unlike the records move, every entry here is tracked, so a folder relocating
5
+ * is itself a citation-shaped event: the file's own path is a string every
6
+ * other file may quote. One planner therefore judges both halves per source
7
+ * file rather than moving folders and rewriting citations as two passes, so a
8
+ * file that both moves and cites another moved entry is decided once.
9
+ */
10
+
11
+ import { join } from 'node:path'
12
+ import { SURFACE_ENTRIES, spell, type SurfaceRoot } from '@/surface-root'
13
+
14
+ /** The root the entries below leave. */
15
+ export const FROM_ROOT: SurfaceRoot = '.claude'
16
+
17
+ /** The root they arrive at. */
18
+ const TO_ROOT: SurfaceRoot = 'canon'
19
+
20
+ /**
21
+ * Every entry this move relocates, at the name `.claude/` gives it.
22
+ *
23
+ * Read from `SURFACE_ENTRIES` rather than restated, less the one entry that
24
+ * stays: `canon` names the install stamp folder, which batch 3 owns and which
25
+ * `.claude/canon/` continues to hold until that batch lands.
26
+ */
27
+ export const MOVED_ENTRIES: readonly string[] = SURFACE_ENTRIES.filter(
28
+ (entry) => entry !== 'canon',
29
+ )
30
+
31
+ function sourcePrefix(entry: string): string {
32
+ return join(FROM_ROOT, spell(FROM_ROOT, entry))
33
+ }
34
+
35
+ function destinationPrefix(entry: string): string {
36
+ return join(TO_ROOT, spell(TO_ROOT, entry))
37
+ }
38
+
39
+ /**
40
+ * Where a moved entry's own path lands, or `undefined` when `path` sits
41
+ * outside every moved entry.
42
+ *
43
+ * Tested against the file's own path rather than its content, so a context
44
+ * entry moves regardless of what it cites.
45
+ */
46
+ export function movedPath(path: string): string | undefined {
47
+ for (const entry of MOVED_ENTRIES) {
48
+ const prefix = sourcePrefix(entry)
49
+ if (path === prefix) return destinationPrefix(entry)
50
+ if (path.startsWith(`${prefix}/`)) {
51
+ return destinationPrefix(entry) + path.slice(prefix.length)
52
+ }
53
+ }
54
+
55
+ return undefined
56
+ }
57
+
58
+ /**
59
+ * A citation into a moved entry.
60
+ *
61
+ * The tail rejects a following name character rather than asking for a word
62
+ * boundary, which is what keeps `.claude/context` bare and `.claude/context/`
63
+ * both matching while `.claude/contexts/` does not. The alternation is ordered
64
+ * longest first so `ARCHITECTURE.md` is decided before any shorter entry could
65
+ * claim its prefix, and each entry is escaped because two of them carry a dot.
66
+ */
67
+ const CITATION = new RegExp(
68
+ `${escape(FROM_ROOT)}/(${[...MOVED_ENTRIES]
69
+ .sort((left, right) => right.length - left.length)
70
+ .map(escape)
71
+ .join('|')})(?![A-Za-z0-9._-])`,
72
+ 'g',
73
+ )
74
+
75
+ function escape(value: string): string {
76
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
77
+ }
78
+
79
+ /**
80
+ * Files whose content is left alone entirely.
81
+ *
82
+ * The changelog is release history, and an eval result is a transcript of
83
+ * paths a session actually opened; rewriting either makes it testify to
84
+ * something that never happened. `src/surface-root.ts` and
85
+ * `src/record-root.ts` are the two sources that spell the old root as data on
86
+ * purpose, so sweeping either would turn the very literals this verb reads
87
+ * into their own replacement. A hook is the third such source, guarding on a
88
+ * `case` carrying an arm per root, so `.claude/hooks/` and the seed's copy of
89
+ * it are excluded for the same reason `records.ts` excludes them.
90
+ *
91
+ * No suffix-wide test exclusion. Most of the `src/` test files naming these
92
+ * paths use them as fixture data proving the fallback still resolves, not to
93
+ * pin one particular assertion, so a wholesale ban would leave the majority
94
+ * silently unswept. The two files that do pin a fallback carry `KEEP_MARKER`
95
+ * on the line that needs it instead.
96
+ */
97
+ const EXCLUDED_PREFIXES: readonly string[] = [
98
+ 'src/migrate/',
99
+ 'scripts/eval/result-',
100
+ '.claude/hooks/',
101
+ 'tooling/claude/seeds/.claude/hooks/',
102
+ ]
103
+
104
+ const EXCLUDED_PATHS: readonly string[] = [
105
+ 'CHANGELOG.md',
106
+ 'src/surface-root.ts',
107
+ 'src/record-root.ts',
108
+ ]
109
+
110
+ export function isExcludedPath(path: string): boolean {
111
+ if (EXCLUDED_PATHS.includes(path)) return true
112
+ return EXCLUDED_PREFIXES.some((prefix) => path.startsWith(prefix))
113
+ }
114
+
115
+ /**
116
+ * Whether `text` names an `EXCLUDED_PREFIXES` or `EXCLUDED_PATHS` entry as
117
+ * literal substring text, which is how a rewritten file can couple to one
118
+ * this module leaves alone.
119
+ */
120
+ export function referencesExcluded(text: string): boolean {
121
+ return (
122
+ EXCLUDED_PATHS.some((path) => text.includes(path)) ||
123
+ EXCLUDED_PREFIXES.some((prefix) => text.includes(prefix))
124
+ )
125
+ }
126
+
127
+ /**
128
+ * Marks a line naming the old root on purpose.
129
+ *
130
+ * The marker sits on the line itself or on the nearest non-blank line above
131
+ * it, walking past a run of blank markdown lines to reach a marker written on
132
+ * its own line above the paragraph it protects.
133
+ */
134
+ const KEEP_MARKER = 'canon-keep-surface-root'
135
+
136
+ function isKept(lines: readonly string[], index: number): boolean {
137
+ if (lines[index]?.includes(KEEP_MARKER)) return true
138
+
139
+ let above = index - 1
140
+ while (above >= 0 && lines[above]?.trim() === '') above -= 1
141
+
142
+ return above >= 0 && (lines[above]?.includes(KEEP_MARKER) ?? false)
143
+ }
144
+
145
+ /**
146
+ * The line index where a leading YAML frontmatter block closes, or
147
+ * `undefined` when the file does not open with a bare `---` on line one.
148
+ */
149
+ function frontmatterEnd(lines: readonly string[]): number | undefined {
150
+ if (lines[0] !== '---') return undefined
151
+ const end = lines.indexOf('---', 1)
152
+ return end === -1 ? undefined : end
153
+ }
154
+
155
+ /**
156
+ * Marks a line inside a rule's frontmatter `paths:` key: the key line itself,
157
+ * or an indented `- 'glob'` list item under it.
158
+ */
159
+ function isFrontmatterPathsLine(
160
+ lines: readonly string[],
161
+ index: number,
162
+ frontmatterEndIndex: number | undefined,
163
+ ): boolean {
164
+ if (frontmatterEndIndex === undefined) return false
165
+ if (index <= 0 || index >= frontmatterEndIndex) return false
166
+
167
+ let top = index
168
+ while (top > 0 && /^\s/.test(lines[top] ?? '')) top -= 1
169
+
170
+ return lines[top]?.trim().startsWith('paths:') ?? false
171
+ }
172
+
173
+ /**
174
+ * A path segment immediately before a citation match, shaped like another
175
+ * repository's own name: it carries a dot or it is itself preceded by a
176
+ * further `/`.
177
+ */
178
+ const CROSS_REPO_PREFIX = /(?:[\w.-]+\.[\w.-]+|[\w.-]+\/[\w.-]+)\/$/
179
+
180
+ function isCrossRepoPrefix(lines: readonly string[], index: number): boolean {
181
+ const line = lines[index] ?? ''
182
+ const match = [...line.matchAll(CITATION)][0]
183
+ if (match === undefined) return false
184
+
185
+ return CROSS_REPO_PREFIX.test(line.slice(0, match.index ?? 0))
186
+ }
187
+
188
+ /** An ISO date, marking a paragraph as recording what was true on that day. */
189
+ const ISO_DATE = /\b\d{4}-\d{2}-\d{2}\b/
190
+
191
+ /**
192
+ * Whether the line's citation sits inside a blank-line-delimited paragraph
193
+ * that also carries an ISO date, read as dated prose rather than a live path.
194
+ *
195
+ * `.claude/ARCHITECTURE.md` is itself a moved entry and carries dozens of
196
+ * `Measured at <sha> on <date>` paragraphs naming the old root as what was
197
+ * true that day. Those stay as written rather than being rewritten into a
198
+ * root that did not exist yet on the date being recorded.
199
+ */
200
+ function isDatedParagraph(lines: readonly string[], index: number): boolean {
201
+ let start = index
202
+ while (start > 0 && lines[start - 1]?.trim() !== '') start -= 1
203
+
204
+ let end = index
205
+ while (end < lines.length - 1 && lines[end + 1]?.trim() !== '') end += 1
206
+
207
+ for (let cursor = start; cursor <= end; cursor += 1) {
208
+ if (ISO_DATE.test(lines[cursor] ?? '')) return true
209
+ }
210
+
211
+ return false
212
+ }
213
+
214
+ type LineClass = 'live' | 'kept' | 'glob' | 'crossRepo' | 'dated'
215
+
216
+ function classifyLine(
217
+ lines: readonly string[],
218
+ index: number,
219
+ frontmatterEndIndex: number | undefined,
220
+ ): LineClass {
221
+ if (isFrontmatterPathsLine(lines, index, frontmatterEndIndex)) return 'glob'
222
+ if (isKept(lines, index)) return 'kept'
223
+ if (isCrossRepoPrefix(lines, index)) return 'crossRepo'
224
+ if (isDatedParagraph(lines, index)) return 'dated'
225
+ return 'live'
226
+ }
227
+
228
+ /** Rewrites every unmarked, non-glob citation into a moved entry. */
229
+ export function rewriteText(text: string): string {
230
+ const lines = text.split('\n')
231
+ const frontmatterEndIndex = frontmatterEnd(lines)
232
+
233
+ return lines
234
+ .map((line, index) =>
235
+ classifyLine(lines, index, frontmatterEndIndex) === 'live'
236
+ ? line.replace(CITATION, (_match, entry: string) =>
237
+ destinationPrefix(entry),
238
+ )
239
+ : line,
240
+ )
241
+ .join('\n')
242
+ }
243
+
244
+ /**
245
+ * How many citations `rewriteText` would rewrite, how many marked lines it
246
+ * left alone, how many sat inside a frontmatter `paths:` glob, how many sat
247
+ * behind a cross-repository-shaped prefix, and how many sat inside a dated
248
+ * paragraph.
249
+ */
250
+ export function scanText(text: string): {
251
+ readonly rewritten: number
252
+ readonly kept: number
253
+ readonly globs: number
254
+ readonly crossRepo: number
255
+ readonly dated: number
256
+ } {
257
+ const lines = text.split('\n')
258
+ const frontmatterEndIndex = frontmatterEnd(lines)
259
+ let rewritten = 0
260
+ let kept = 0
261
+ let globs = 0
262
+ let crossRepo = 0
263
+ let dated = 0
264
+
265
+ for (const [index, line] of lines.entries()) {
266
+ const matches = [...line.matchAll(CITATION)].length
267
+ if (matches === 0) continue
268
+
269
+ const kind = classifyLine(lines, index, frontmatterEndIndex)
270
+ if (kind === 'glob') globs += matches
271
+ else if (kind === 'kept') kept += matches
272
+ else if (kind === 'crossRepo') crossRepo += matches
273
+ else if (kind === 'dated') dated += matches
274
+ else rewritten += matches
275
+ }
276
+
277
+ return { rewritten, kept, globs, crossRepo, dated }
278
+ }
279
+
280
+ /** Where a citation sits, so a reader can judge it before `--write` runs. */
281
+ export interface CitationLine {
282
+ readonly line: number
283
+ readonly text: string
284
+ }
285
+
286
+ function frontmatterGlobLines(text: string): CitationLine[] {
287
+ const lines = text.split('\n')
288
+ const frontmatterEndIndex = frontmatterEnd(lines)
289
+ const held: CitationLine[] = []
290
+
291
+ for (const [index, line] of lines.entries()) {
292
+ if (!isFrontmatterPathsLine(lines, index, frontmatterEndIndex)) continue
293
+ if ([...line.matchAll(CITATION)].length === 0) continue
294
+
295
+ held.push({ line: index + 1, text: line.trim() })
296
+ }
297
+
298
+ return held
299
+ }
300
+
301
+ function crossRepoLines(text: string): CitationLine[] {
302
+ const lines = text.split('\n')
303
+ const frontmatterEndIndex = frontmatterEnd(lines)
304
+ const held: CitationLine[] = []
305
+
306
+ for (const [index, line] of lines.entries()) {
307
+ if ([...line.matchAll(CITATION)].length === 0) continue
308
+ if (classifyLine(lines, index, frontmatterEndIndex) !== 'crossRepo')
309
+ continue
310
+
311
+ held.push({ line: index + 1, text: line.trim() })
312
+ }
313
+
314
+ return held
315
+ }
316
+
317
+ function datedLines(text: string): CitationLine[] {
318
+ const lines = text.split('\n')
319
+ const frontmatterEndIndex = frontmatterEnd(lines)
320
+ const held: CitationLine[] = []
321
+
322
+ for (const [index, line] of lines.entries()) {
323
+ if ([...line.matchAll(CITATION)].length === 0) continue
324
+ if (classifyLine(lines, index, frontmatterEndIndex) !== 'dated') continue
325
+
326
+ held.push({ line: index + 1, text: line.trim() })
327
+ }
328
+
329
+ return held
330
+ }
331
+
332
+ /** One tracked file, as the planner reads it. */
333
+ export interface SurfaceRootsSource {
334
+ readonly path: string
335
+ readonly text: string
336
+ }
337
+
338
+ /** One file the sweep touches, whether by moving, rewriting, or both. */
339
+ export interface SurfaceRootsEntry {
340
+ readonly path: string
341
+ readonly movesTo?: string
342
+ readonly text?: string
343
+ readonly rewritten: number
344
+ readonly kept: number
345
+ }
346
+
347
+ export interface FrontmatterGlobEntry {
348
+ readonly path: string
349
+ readonly lines: readonly CitationLine[]
350
+ }
351
+
352
+ export interface CrossRepoCitationEntry {
353
+ readonly path: string
354
+ readonly lines: readonly CitationLine[]
355
+ }
356
+
357
+ export interface DatedCitationEntry {
358
+ readonly path: string
359
+ readonly lines: readonly CitationLine[]
360
+ }
361
+
362
+ export interface SurfaceRootsPlan {
363
+ readonly entries: readonly SurfaceRootsEntry[]
364
+ readonly excluded: readonly string[]
365
+ readonly coupled: readonly string[]
366
+ readonly frontmatterGlobs: readonly FrontmatterGlobEntry[]
367
+ readonly crossRepoCitations: readonly CrossRepoCitationEntry[]
368
+ readonly datedCitations: readonly DatedCitationEntry[]
369
+ readonly rewritten: number
370
+ readonly kept: number
371
+ readonly globs: number
372
+ readonly crossRepo: number
373
+ readonly dated: number
374
+ readonly moves: number
375
+ }
376
+
377
+ /**
378
+ * What the move would do, without doing it.
379
+ *
380
+ * A file is judged once for both halves: whether its own path sits under a
381
+ * moved entry, and whether its content cites one. Either alone is enough to
382
+ * produce an entry, and a file excluded from the citation rewrite still moves
383
+ * when its path itself is inside a moved entry, since the two entries excluded
384
+ * today, `src/surface-root.ts` and `src/record-root.ts`, both sit outside
385
+ * every moved entry and never take that branch in practice.
386
+ */
387
+ export function planSurfaceRootsMove(
388
+ sources: readonly SurfaceRootsSource[],
389
+ ): SurfaceRootsPlan {
390
+ const entries: SurfaceRootsEntry[] = []
391
+ const excluded: string[] = []
392
+ const coupled: string[] = []
393
+ const frontmatterGlobs: FrontmatterGlobEntry[] = []
394
+ const crossRepoCitations: CrossRepoCitationEntry[] = []
395
+ const datedCitations: DatedCitationEntry[] = []
396
+ let kept = 0
397
+ let globs = 0
398
+ let crossRepo = 0
399
+ let dated = 0
400
+
401
+ for (const source of sources) {
402
+ const movesTo = movedPath(source.path)
403
+
404
+ if (isExcludedPath(source.path)) {
405
+ if (scanText(source.text).rewritten > 0) excluded.push(source.path)
406
+ if (movesTo !== undefined) {
407
+ entries.push({ path: source.path, movesTo, rewritten: 0, kept: 0 })
408
+ }
409
+ continue
410
+ }
411
+
412
+ const counts = scanText(source.text)
413
+ kept += counts.kept
414
+ globs += counts.globs
415
+ crossRepo += counts.crossRepo
416
+ dated += counts.dated
417
+
418
+ const held = frontmatterGlobLines(source.text)
419
+ if (held.length > 0)
420
+ frontmatterGlobs.push({ path: source.path, lines: held })
421
+
422
+ const foreign = crossRepoLines(source.text)
423
+ if (foreign.length > 0)
424
+ crossRepoCitations.push({ path: source.path, lines: foreign })
425
+
426
+ const dates = datedLines(source.text)
427
+ if (dates.length > 0)
428
+ datedCitations.push({ path: source.path, lines: dates })
429
+
430
+ const changed = counts.rewritten > 0
431
+ if (!changed && movesTo === undefined) continue
432
+
433
+ if (changed && referencesExcluded(source.text)) coupled.push(source.path)
434
+
435
+ entries.push({
436
+ path: source.path,
437
+ ...(movesTo !== undefined ? { movesTo } : {}),
438
+ ...(changed ? { text: rewriteText(source.text) } : {}),
439
+ rewritten: counts.rewritten,
440
+ kept: counts.kept,
441
+ })
442
+ }
443
+
444
+ return {
445
+ entries,
446
+ excluded,
447
+ coupled,
448
+ frontmatterGlobs,
449
+ crossRepoCitations,
450
+ datedCitations,
451
+ rewritten: entries.reduce((sum, entry) => sum + entry.rewritten, 0),
452
+ kept,
453
+ globs,
454
+ crossRepo,
455
+ dated,
456
+ moves: entries.filter((entry) => entry.movesTo !== undefined).length,
457
+ }
458
+ }
@@ -52,10 +52,12 @@ const CANON_SCRATCH = 'tmp'
52
52
  * writes back. `worktrees` is absent because the harness creates a worktree
53
53
  * under `.claude/` and requires its target to sit there.
54
54
  *
55
- * Everything absent from this list is committed and stays where it is, which is
56
- * the rule the move ran on. `context`, `rules`, `skills`, `hooks`, `wireframes`,
57
- * and the loose documents at the root are all in that set, which is why a seed
58
- * and a superseded-layout report each ask this rather than assuming a root.
55
+ * Everything absent from this list is committed and never lands under the
56
+ * record root, which is the rule the move ran on. `rules`, `skills`, and
57
+ * `hooks` stay under `.claude/` because the vendor reads them there, while
58
+ * `context`, `wireframes`, and the loose documents are tracked surfaces that
59
+ * `surface-root.ts` resolves under `canon/` instead. A seed and a
60
+ * superseded-layout report each ask this rather than assuming a root.
59
61
  */
60
62
  export const RECORD_ENTRIES: readonly string[] = [
61
63
  '.records.git',
@@ -69,7 +69,7 @@ export function listSkills(root: string): string[] {
69
69
  /**
70
70
  * Maps a scenario to the skill it drives, trying two spellings in order.
71
71
  *
72
- * `<category>-<command>` is the rule `.claude/context/sandbox/coverage.md` states, and it
72
+ * `<category>-<command>` is the rule `canon/context/sandbox/coverage.md` states, and it
73
73
  * alone pairs 29 of 54 skills. The bare `<command>` fallback is what reaches the
74
74
  * rest: `claude/setup-init.sh` drives the `setup-init` skill, not a
75
75
  * `claude-setup-init` that does not exist. Stating one spelling and shipping two
@@ -139,10 +139,10 @@ const SAME_REPOSITORY =
139
139
  * named a target's own tree, measured on 2026-09-03. Resolving against `root`
140
140
  * is what turns that 124-hit pattern into the four-hit gate.
141
141
  *
142
- * `.claude/context/` carries no equivalent pattern. The same resolution test
142
+ * `canon/context/` carries no equivalent pattern. The same resolution test
143
143
  * cannot separate a path every scaffolded project holds, such as
144
- * `.claude/context/index.md`, from this repository's own domain entry, such
145
- * as `.claude/context/indexes.md`, since both resolve here and only the
144
+ * `canon/context/index.md`, from this repository's own domain entry, such
145
+ * as `canon/context/indexes.md`, since both resolve here and only the
146
146
  * second is a defect. That is a semantic read no pattern makes, so it stays
147
147
  * with the rule and the review checklist rather than joining this reader.
148
148
  */
@@ -23,13 +23,13 @@ export type SurfaceRoot = (typeof SURFACE_ROOTS)[number]
23
23
  /**
24
24
  * The root a surface is created at when neither root carries it yet.
25
25
  *
26
- * Disagreeing with the head of the read order for exactly one release: read
27
- * precedence is new-first so a tree that has moved is never answered from the
28
- * copy left behind, while creation stays at the old root so nothing writes a
29
- * fresh tracked file under a root a target's installed binary may not resolve
30
- * yet. A later batch flips this once a release carries the read side.
26
+ * It agrees with the head of the read precedence. While the two disagreed,
27
+ * creation stayed at `.claude/` so nothing wrote a fresh tracked file under a
28
+ * root a target's installed binary could not resolve. A release carries the
29
+ * read side now, so a fresh project scaffolds one root and an unmoved one keeps
30
+ * resolving its own surfaces through the fallback above.
31
31
  */
32
- export const CREATION_ROOT: SurfaceRoot = '.claude'
32
+ export const CREATION_ROOT: SurfaceRoot = 'canon'
33
33
 
34
34
  /**
35
35
  * Every tracked surface this module resolves, at the name `.claude/` gives it.
@@ -55,6 +55,18 @@ export function spell(root: SurfaceRoot, entry: string): string {
55
55
  return root === 'canon' && entry === 'canon' ? 'config' : entry
56
56
  }
57
57
 
58
+ /**
59
+ * The creation default for one entry.
60
+ *
61
+ * The stamp folder keeps creating under `.claude/` until its own move lands,
62
+ * since the install stamp and the audits baseline still write there by a
63
+ * fixed path. A read resolving to `canon/config/` in a fresh project would
64
+ * answer from a folder nothing writes.
65
+ */
66
+ function creationRootFor(entry: string): SurfaceRoot {
67
+ return entry === 'canon' ? '.claude' : CREATION_ROOT
68
+ }
69
+
58
70
  /**
59
71
  * The root a surface resolves at: the first that carries it, and the creation
60
72
  * default when neither does.
@@ -63,7 +75,7 @@ function rootOf(root: string, entry: string): SurfaceRoot {
63
75
  return (
64
76
  SURFACE_ROOTS.find((candidate) =>
65
77
  existsSync(join(root, candidate, spell(candidate, entry))),
66
- ) ?? CREATION_ROOT
78
+ ) ?? creationRootFor(entry)
67
79
  )
68
80
  }
69
81
 
@@ -82,6 +94,26 @@ export function surfaceDir(
82
94
  return join(root, at, spell(at, entry), ...rest)
83
95
  }
84
96
 
97
+ /**
98
+ * Where a path authored at the `canon/` spelling lands under `root`.
99
+ *
100
+ * A seed tree authors every surface once, at the new root, while a target may
101
+ * still hold that surface under `.claude/`. Writing the literal path there
102
+ * would open a `canon/` copy that wins read precedence and hides every entry
103
+ * the target already wrote, so the entry resolves the way a read does. A path
104
+ * naming no surface entry is joined as written.
105
+ */
106
+ export function resolveSurfacePath(root: string, rel: string): string {
107
+ const [head, entry, ...rest] = rel.split(/[\\/]/)
108
+
109
+ if (head !== 'canon' || entry === undefined || entry === 'canon') {
110
+ return join(root, rel)
111
+ }
112
+ if (!SURFACE_ENTRIES.includes(entry)) return join(root, rel)
113
+
114
+ return surfaceDir(root, entry, ...rest)
115
+ }
116
+
85
117
  /**
86
118
  * Every root a surface would be read at, in precedence order, whether or not
87
119
  * it is on disk.
@@ -1,7 +1,8 @@
1
1
  import { existsSync, statSync } from 'node:fs'
2
- import { basename, join } from 'node:path'
2
+ import { basename, join, relative } from 'node:path'
3
3
  import { SUBDIRS } from '@/claude/seeds'
4
4
  import { creationRel, isRecordEntry } from '@/record-root'
5
+ import { SURFACE_ENTRIES, surfaceDir } from '@/surface-root'
5
6
  import type { StampDomain } from '@/sync/stamp'
6
7
 
7
8
  const CLAUDE_DIR = '.claude'
@@ -70,13 +71,16 @@ export function collectSuperseded(target: string): SupersededEntry[] {
70
71
  const rel = join(CLAUDE_DIR, `${subdir.toUpperCase()}.md`)
71
72
  if (!isFile(join(target, rel))) continue
72
73
 
73
- // A record subdir now lives under the record root, so the replacement this
74
- // names is resolved against the target rather than fixed at `.claude/`.
75
- // Naming a folder the target does not have sends a person to migrate their
76
- // legacy file into a path nothing reads.
74
+ // A record subdir lives under the record root and a tracked surface under
75
+ // the surface root, so the replacement this names is resolved against the
76
+ // target rather than fixed at `.claude/`. Naming a folder the target does
77
+ // not have sends a person to migrate their legacy file into a path nothing
78
+ // reads.
77
79
  const replacedBy = isRecordEntry(subdir)
78
80
  ? creationRel(target, subdir)
79
- : join(CLAUDE_DIR, subdir)
81
+ : SURFACE_ENTRIES.includes(subdir)
82
+ ? relative(target, surfaceDir(target, subdir))
83
+ : join(CLAUDE_DIR, subdir)
80
84
 
81
85
  entries.push({ rel, replacedBy })
82
86
  }
@@ -234,7 +234,7 @@ export function detectMigrations(target: string): MigrationCandidate[] {
234
234
  if (docs > 0 && context === 0) {
235
235
  found.push({
236
236
  skill: 'migration-context',
237
- reason: `${docs} markdown files under docs/ with no .claude/context/ tier`,
237
+ reason: `${docs} markdown files under docs/ with no canon/context/ tier`,
238
238
  })
239
239
  }
240
240
 
@@ -1,9 +1,10 @@
1
1
  import { existsSync } from 'node:fs'
2
2
  import { copyFile, mkdir, readFile, writeFile } from 'node:fs/promises'
3
- import { dirname, join } from 'node:path'
3
+ import { dirname, join, relative } from 'node:path'
4
4
  import { $ } from 'bun'
5
5
  import { copyPreservingMode } from '@/copy'
6
6
  import { rewritesOnInstall, stripSeedMarker } from '@/seed-marker'
7
+ import { resolveSurfacePath } from '@/surface-root'
7
8
  import { mergeSections, pruneSections } from '@/tooling/gitignore'
8
9
  import { ancestorsFirst, listFiles, type Manifest } from '@/tooling/manifest'
9
10
  import {
@@ -92,8 +93,9 @@ export async function injectSeeds(
92
93
 
93
94
  logStep(`Applying ${manifest.name} seeds`)
94
95
  for (const rel of files) {
95
- await mergeSeedFile(join(manifest.seedsDir, rel), join(target, rel))
96
- logAdd(rel)
96
+ const dest = resolveSurfacePath(target, rel)
97
+ await mergeSeedFile(join(manifest.seedsDir, rel), dest)
98
+ logAdd(relative(target, dest))
97
99
  applied.push(rel)
98
100
  }
99
101
  }
@@ -1,5 +1,6 @@
1
1
  import { existsSync, readFileSync } from 'node:fs'
2
2
  import { join } from 'node:path'
3
+ import { resolveSurfacePath } from '@/surface-root'
3
4
  import { mergeSections } from '@/tooling/gitignore'
4
5
  import { ancestorsFirst, listFiles, type Manifest } from '@/tooling/manifest'
5
6
  import {
@@ -79,7 +80,9 @@ export function scan(chain: readonly Manifest[], target: string): ScanResult {
79
80
 
80
81
  seeds.push({
81
82
  rel,
82
- state: existsSync(join(target, rel)) ? 'present' : 'missing',
83
+ state: existsSync(resolveSurfacePath(target, rel))
84
+ ? 'present'
85
+ : 'missing',
83
86
  })
84
87
  }
85
88
  }