@erclx/canon 5.36.0 → 5.37.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/api-design/SKILL.md +6 -0
- package/claude/skills/backlog-triage/SKILL.md +7 -7
- package/claude/skills/build-in-slices/SKILL.md +6 -0
- package/claude/skills/build-in-slices/references/adopted.md +3 -0
- package/claude/skills/canon-cli/SKILL.md +3 -0
- package/claude/skills/canon-feedback/SKILL.md +5 -0
- package/claude/skills/canon-feedback-triage/SKILL.md +3 -0
- package/claude/skills/canvas-board/SKILL.md +3 -0
- package/claude/skills/canvas-board/references/canvas.md +12 -0
- package/claude/skills/ci-workflow/SKILL.md +5 -0
- package/claude/skills/code-craft/SKILL.md +6 -0
- package/claude/skills/context-fold/references/context.md +48 -34
- package/claude/skills/create-rule/SKILL.md +11 -9
- package/claude/skills/create-rule/references/rule.md +6 -0
- package/claude/skills/create-skill/SKILL.md +11 -2
- package/claude/skills/create-skill/references/skill-disclosure.md +26 -0
- package/claude/skills/create-skill/references/skill-paths.md +3 -0
- package/claude/skills/create-skill/references/skill-reference.md +12 -0
- package/claude/skills/create-skill/references/skill.md +25 -24
- package/claude/skills/deprecation-migration/SKILL.md +6 -0
- package/claude/skills/deprecation-migration/references/adopted.md +3 -0
- package/claude/skills/design-taste/SKILL.md +6 -0
- package/claude/skills/design-taste/references/craft.md +3 -0
- package/claude/skills/design-taste/references/preflight.md +16 -0
- package/claude/skills/docs-sync/references/docs.md +6 -0
- package/claude/skills/docs-sync/references/readme.md +15 -0
- package/claude/skills/draft-and-pick/SKILL.md +12 -0
- package/claude/skills/draft-doc/references/context.md +1 -1
- package/claude/skills/draft-doc/references/readme.md +3 -0
- package/claude/skills/draft-figure/references/mermaid.md +6 -0
- package/claude/skills/draft-slides/SKILL.md +3 -0
- package/claude/skills/git-branch/references/branch.md +16 -11
- package/claude/skills/git-commit/references/commit.md +19 -11
- package/claude/skills/git-commit/references/versioning.md +9 -0
- package/claude/skills/git-issue/references/issue.md +12 -9
- package/claude/skills/git-pr/SKILL.md +5 -0
- package/claude/skills/git-pr/references/pr.md +24 -6
- package/claude/skills/git-ship/SKILL.md +3 -0
- package/claude/skills/git-split/SKILL.md +6 -0
- package/claude/skills/git-stage/SKILL.md +3 -0
- package/claude/skills/git-worktree/SKILL.md +6 -6
- package/claude/skills/markdown-craft/references/markdown.md +24 -6
- package/claude/skills/plan-feature/SKILL.md +9 -0
- package/claude/skills/plan-feature/references/plan.md +20 -8
- package/claude/skills/plan-groundwork/SKILL.md +6 -0
- package/claude/skills/plan-groundwork/references/groundwork.md +10 -7
- package/claude/skills/plan-intake/references/intake.md +6 -6
- package/claude/skills/read-frames/SKILL.md +3 -0
- package/claude/skills/review-craft/SKILL.md +3 -0
- package/claude/skills/review-ui/SKILL.md +6 -3
- package/claude/skills/role-orchestrator/SKILL.md +3 -0
- package/claude/skills/role-orchestrator/references/orchestrator-dispatch.md +7 -4
- package/claude/skills/role-orchestrator/references/orchestrator-refill.md +3 -0
- package/claude/skills/role-planner/SKILL.md +3 -0
- package/claude/skills/role-worker/SKILL.md +12 -0
- package/claude/skills/search-craft/SKILL.md +3 -0
- package/claude/skills/systematic-debugging/SKILL.md +6 -0
- package/claude/skills/target-check/references/domains.md +5 -0
- package/claude/skills/target-setup/SKILL.md +5 -0
- package/claude/skills/task-board/references/tasks.md +9 -6
- package/claude/skills/task-complete/references/archive.md +3 -0
- package/claude/skills/teach-workspace/SKILL.md +3 -0
- package/claude/skills/teach-workspace/references/glossary.md +3 -0
- package/claude/skills/teach-workspace/references/lesson-build.md +3 -0
- package/claude/skills/teach-workspace/references/lesson-craft.md +3 -0
- package/claude/skills/teach-workspace/references/teach.md +8 -8
- package/claude/skills/test-craft/SKILL.md +5 -0
- package/claude/skills/video-craft/SKILL.md +6 -0
- package/claude/skills/write-human/SKILL.md +9 -0
- package/docs/agents/capture.md +2 -0
- package/docs/agents/commands.md +54 -54
- package/docs/agents/context-audit-checks.md +6 -0
- package/docs/agents/context-audit.md +8 -8
- package/docs/agents/context-classify.md +2 -0
- package/docs/agents/drift-surfaces.md +5 -5
- package/docs/agents/gate.md +6 -7
- package/docs/agents/index.md +1 -1
- package/docs/agents/install-and-sync.md +2 -2
- package/docs/agents/markdown-audit-weight.md +11 -3
- package/docs/agents/markdown-audit.md +2 -2
- package/docs/agents/pr-frames.md +17 -3
- package/docs/agents/sessions-transfer.md +8 -6
- package/docs/agents/skills-audit.md +9 -1
- package/docs/target/scenarios.md +1 -1
- package/docs/target/standards-moved.md +20 -18
- package/docs/workflow/ai-workflow.md +3 -0
- package/docs/workflow/visual-design-workflow.md +5 -0
- package/package.json +2 -2
- package/src/cli/help.ts +1 -1
- package/src/commands/context.ts +29 -4
- package/src/commands/gate.ts +1 -8
- package/src/commands/markdown.ts +52 -0
- package/src/commands/pr.ts +17 -10
- package/src/context/audit.ts +83 -0
- package/src/context/classify/prompts.ts +6 -1
- package/src/context/gate.ts +6 -3
- package/src/gate/measures.ts +186 -1
- package/src/gate/sequencer.ts +0 -4
- package/src/gate/stages.ts +32 -27
- package/src/git/files.ts +30 -0
- package/src/gov/adapter.ts +2 -2
- package/src/gov/install.ts +2 -2
- package/src/gov/list.ts +1 -1
- package/src/gov/payload.ts +1 -1
- package/src/gov/stacks.ts +1 -1
- package/src/markdown/gate.ts +10 -0
- package/src/markdown/growth.ts +43 -0
- package/src/markdown/stacks.ts +74 -0
- package/src/markdown/structure.ts +72 -4
- package/src/migrate/rule-layout.ts +12 -12
- package/src/pr/frames.ts +66 -1
- package/src/sync/check.ts +23 -23
- package/tooling/astro/configs/tsconfig.json +1 -1
- package/tooling/astro/reference.md +2 -2
- package/tooling/base/configs/scripts/verify.json +1 -1
- package/tooling/base/configs/scripts/verify.ts +2 -8
- package/tooling/base/reference.md +10 -10
- package/tooling/base/seeds/canon/context/ci.md +4 -4
- package/tooling/base/seeds/canon/context/development.md +9 -9
- package/tooling/claude/seeds/.claude/hooks/scratch-guard.sh +8 -0
- package/tooling/vite-react/configs/tsconfig.json +1 -1
- package/tooling/vite-react/configs/vitest.config.ts +1 -1
- package/tooling/vite-react/reference.md +2 -2
- package/tooling/web/configs/src/test/setup.ts +1 -1
- package/tooling/web/manifest.toml +3 -3
- package/tooling/web/reference.md +1 -1
|
@@ -34,12 +34,12 @@ export const RENUMBERED_RULES: Readonly<Record<string, string>> = {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
* exclusion holds even for a
|
|
37
|
+
* Rule folders the walk skips by name rather than by content, so the
|
|
38
|
+
* exclusion holds even for a folder the toolkit has not shipped yet.
|
|
39
39
|
* `canon/` and `internal/` are already-migrated destinations, and
|
|
40
40
|
* `project/` is a target's own rules, which this verb never touches.
|
|
41
41
|
*/
|
|
42
|
-
const
|
|
42
|
+
const EXCLUDED_FOLDERS: readonly string[] = ['project', 'canon', 'internal']
|
|
43
43
|
|
|
44
44
|
/** One flat rule file, before classification. */
|
|
45
45
|
export interface FlatRuleFile {
|
|
@@ -57,9 +57,9 @@ export function flatRulesRoot(target: string): string {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* Every rule file sitting directly under a flat
|
|
61
|
-
* the
|
|
62
|
-
* nests a rule deeper than its
|
|
60
|
+
* Every rule file sitting directly under a flat rule folder. One level for
|
|
61
|
+
* the folder and one glob below it for `*.md`, since `governance/rules/` never
|
|
62
|
+
* nests a rule deeper than its folder, and the flat layout this verb migrates
|
|
63
63
|
* off of mirrors that depth.
|
|
64
64
|
*/
|
|
65
65
|
export async function walkFlatRules(target: string): Promise<FlatRuleFile[]> {
|
|
@@ -69,20 +69,20 @@ export async function walkFlatRules(target: string): Promise<FlatRuleFile[]> {
|
|
|
69
69
|
)
|
|
70
70
|
if (entries === undefined) return []
|
|
71
71
|
|
|
72
|
-
const
|
|
73
|
-
(entry) => entry.isDirectory() && !
|
|
72
|
+
const folders = entries.filter(
|
|
73
|
+
(entry) => entry.isDirectory() && !EXCLUDED_FOLDERS.includes(entry.name),
|
|
74
74
|
)
|
|
75
75
|
|
|
76
76
|
const files: FlatRuleFile[] = []
|
|
77
|
-
for (const
|
|
77
|
+
for (const folder of folders) {
|
|
78
78
|
const glob = new Bun.Glob('*.md')
|
|
79
79
|
for (const name of glob.scanSync({
|
|
80
|
-
cwd: join(root,
|
|
80
|
+
cwd: join(root, folder.name),
|
|
81
81
|
onlyFiles: true,
|
|
82
82
|
})) {
|
|
83
83
|
files.push({
|
|
84
|
-
rel: relPath('.claude', 'rules',
|
|
85
|
-
subdir:
|
|
84
|
+
rel: relPath('.claude', 'rules', folder.name, name),
|
|
85
|
+
subdir: folder.name,
|
|
86
86
|
name: name.slice(0, -'.md'.length),
|
|
87
87
|
})
|
|
88
88
|
}
|
package/src/pr/frames.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises'
|
|
2
2
|
|
|
3
3
|
/** The branch holding review frames. It never merges into a branch anyone checks out. */
|
|
4
|
-
export const FRAMES_BRANCH = 'canon
|
|
4
|
+
export const FRAMES_BRANCH = 'canon/frames'
|
|
5
|
+
|
|
6
|
+
/** The branch frames lived on before the rename. A drop and a prune drain it and an add never writes it. */
|
|
7
|
+
export const LEGACY_FRAMES_BRANCH = 'canon-frames'
|
|
5
8
|
|
|
6
9
|
/** The eight bytes every PNG opens with. A frame that lacks them embeds as a broken image. */
|
|
7
10
|
const PNG_SIGNATURE = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]
|
|
@@ -94,6 +97,7 @@ export type DropResult =
|
|
|
94
97
|
readonly removed: readonly number[]
|
|
95
98
|
readonly commit?: string
|
|
96
99
|
readonly deleted?: boolean
|
|
100
|
+
readonly legacy?: true
|
|
97
101
|
}
|
|
98
102
|
| { readonly kind: 'refused'; readonly reason: FramesRefusal }
|
|
99
103
|
|
|
@@ -105,6 +109,7 @@ export type PruneResult =
|
|
|
105
109
|
readonly unread: readonly number[]
|
|
106
110
|
readonly commit?: string
|
|
107
111
|
readonly deleted?: boolean
|
|
112
|
+
readonly legacy?: true
|
|
108
113
|
}
|
|
109
114
|
| { readonly kind: 'refused'; readonly reason: FramesRefusal }
|
|
110
115
|
|
|
@@ -341,3 +346,63 @@ export async function pruneFrames(
|
|
|
341
346
|
unread: unread.sort((a, b) => a - b),
|
|
342
347
|
}
|
|
343
348
|
}
|
|
349
|
+
|
|
350
|
+
function mergeNumbers(
|
|
351
|
+
first: readonly number[],
|
|
352
|
+
second: readonly number[],
|
|
353
|
+
): number[] {
|
|
354
|
+
return [...new Set([...first, ...second])].sort((a, b) => a - b)
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/** Whether a drain pass changed the legacy ref, by removing a pull request or deleting it. */
|
|
358
|
+
function touchedLegacy(result: DropResult): boolean {
|
|
359
|
+
return (
|
|
360
|
+
result.kind === 'dropped' &&
|
|
361
|
+
(result.removed.length > 0 || result.deleted === true)
|
|
362
|
+
)
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Drops on the current branch, then on the legacy one. The legacy pass only
|
|
367
|
+
* removes, and a refusal there never fails a drop the current branch already
|
|
368
|
+
* finished, since a target that never held the legacy ref reads it as missing
|
|
369
|
+
* and a token may be unable to read it at all.
|
|
370
|
+
*/
|
|
371
|
+
export async function dropFramesWithLegacy(
|
|
372
|
+
api: FramesApi,
|
|
373
|
+
legacy: FramesApi,
|
|
374
|
+
numbers: readonly number[],
|
|
375
|
+
): Promise<DropResult> {
|
|
376
|
+
const current = await dropFrames(api, numbers)
|
|
377
|
+
if (current.kind === 'refused') return current
|
|
378
|
+
const drained = await dropFrames(legacy, numbers)
|
|
379
|
+
if (drained.kind === 'refused' || !touchedLegacy(drained)) return current
|
|
380
|
+
return {
|
|
381
|
+
...current,
|
|
382
|
+
removed: mergeNumbers(current.removed, drained.removed),
|
|
383
|
+
legacy: true,
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** The prune counterpart of `dropFramesWithLegacy`, with the same legacy semantics. */
|
|
388
|
+
export async function pruneFramesWithLegacy(
|
|
389
|
+
api: FramesApi,
|
|
390
|
+
legacy: FramesApi,
|
|
391
|
+
days: number,
|
|
392
|
+
now: Date,
|
|
393
|
+
): Promise<PruneResult> {
|
|
394
|
+
const current = await pruneFrames(api, days, now)
|
|
395
|
+
if (current.kind === 'refused') return current
|
|
396
|
+
const drained = await pruneFrames(legacy, days, now)
|
|
397
|
+
if (drained.kind === 'refused') return current
|
|
398
|
+
const touched = drained.removed.length > 0 || drained.deleted === true
|
|
399
|
+
const kept = mergeNumbers(current.kept, drained.kept)
|
|
400
|
+
const unread = mergeNumbers(current.unread, drained.unread)
|
|
401
|
+
return {
|
|
402
|
+
...current,
|
|
403
|
+
removed: mergeNumbers(current.removed, drained.removed),
|
|
404
|
+
kept,
|
|
405
|
+
unread,
|
|
406
|
+
...(touched && { legacy: true as const }),
|
|
407
|
+
}
|
|
408
|
+
}
|
package/src/sync/check.ts
CHANGED
|
@@ -531,12 +531,12 @@ export function parseNewSkills(paths: string): string[] {
|
|
|
531
531
|
|
|
532
532
|
/**
|
|
533
533
|
* What the target's `.claude/rules/` proves about its entitlement. `held` is
|
|
534
|
-
* every rule name it carries and `
|
|
534
|
+
* every rule name it carries and `folders` every rule folder those names sit in.
|
|
535
535
|
*
|
|
536
536
|
* Read off the installed tree rather than off a stack name, because
|
|
537
537
|
* `gov install` records file hashes and never the stack it resolved, so the
|
|
538
538
|
* chain a target consumed survives nowhere else. `installRules` copies each
|
|
539
|
-
* rule into the subdirectory it was authored in, which is what makes the
|
|
539
|
+
* rule into the subdirectory it was authored in, which is what makes the folder
|
|
540
540
|
* folders legible as evidence.
|
|
541
541
|
*
|
|
542
542
|
* `successorOf` adds the name a held rule was renamed to, which the next sync
|
|
@@ -547,12 +547,12 @@ export function readInstalledRules(
|
|
|
547
547
|
successorOf?: (name: string) => string | undefined,
|
|
548
548
|
): {
|
|
549
549
|
held: Set<string>
|
|
550
|
-
|
|
550
|
+
folders: Set<string>
|
|
551
551
|
} {
|
|
552
552
|
const dir = join(target, ...INSTALL_MARKERS.governance)
|
|
553
553
|
const held = new Set<string>()
|
|
554
|
-
const
|
|
555
|
-
if (!isDirectory(dir)) return { held,
|
|
554
|
+
const folders = new Set<string>()
|
|
555
|
+
if (!isDirectory(dir)) return { held, folders }
|
|
556
556
|
|
|
557
557
|
for (const rel of new Bun.Glob('**/*.md').scanSync({
|
|
558
558
|
cwd: dir,
|
|
@@ -566,34 +566,34 @@ export function readInstalledRules(
|
|
|
566
566
|
held.add(name)
|
|
567
567
|
const successor = successorOf?.(name)
|
|
568
568
|
if (successor !== undefined) held.add(successor)
|
|
569
|
-
if (boundary > 0)
|
|
569
|
+
if (boundary > 0) folders.add(posix.slice(0, boundary))
|
|
570
570
|
}
|
|
571
571
|
|
|
572
|
-
return { held,
|
|
572
|
+
return { held, folders }
|
|
573
573
|
}
|
|
574
574
|
|
|
575
575
|
/**
|
|
576
576
|
* Narrows rules added upstream to the ones this target could receive and does
|
|
577
577
|
* not already hold.
|
|
578
578
|
*
|
|
579
|
-
* The
|
|
579
|
+
* The folder test is the entitlement filter, and `folders` carries two sources: the
|
|
580
580
|
* folders the target already holds, and the folders holding a rule the base
|
|
581
581
|
* stack resolves to.
|
|
582
582
|
* A rule authored under `lang/` or `ui/` is named by an individual stack, so it
|
|
583
583
|
* belongs to some targets and not others, and listing every added file would
|
|
584
584
|
* tell a base consumer about rules it was never entitled to. The test
|
|
585
|
-
* over-reports inside a
|
|
585
|
+
* over-reports inside a folder a target already carries, since one folder can be
|
|
586
586
|
* reached by more than one stack, and that costs a line where under-reporting
|
|
587
587
|
* would cost the whole point of the section.
|
|
588
588
|
*
|
|
589
|
-
* The `held` test is what keeps a rule that moved
|
|
589
|
+
* The `held` test is what keeps a rule that moved folders upstream out. A rename
|
|
590
590
|
* reaches this diff as an addition, and the target already has the file under
|
|
591
591
|
* its old folder, so matching by name is what tells the two apart.
|
|
592
592
|
*/
|
|
593
593
|
export function selectNewRules(
|
|
594
594
|
paths: string,
|
|
595
595
|
held: ReadonlySet<string>,
|
|
596
|
-
|
|
596
|
+
folders: ReadonlySet<string>,
|
|
597
597
|
): string[] {
|
|
598
598
|
const prefix = 'governance/rules/'
|
|
599
599
|
const names = new Set<string>()
|
|
@@ -604,11 +604,11 @@ export function selectNewRules(
|
|
|
604
604
|
|
|
605
605
|
const rel = trimmed.slice(prefix.length)
|
|
606
606
|
const boundary = rel.indexOf('/')
|
|
607
|
-
const
|
|
607
|
+
const folder = boundary === -1 ? '' : rel.slice(0, boundary)
|
|
608
608
|
const name = basename(rel, '.md')
|
|
609
609
|
|
|
610
610
|
if (held.has(name)) continue
|
|
611
|
-
if (
|
|
611
|
+
if (folder !== '' && !folders.has(folder)) continue
|
|
612
612
|
|
|
613
613
|
names.add(name)
|
|
614
614
|
}
|
|
@@ -617,29 +617,29 @@ export function selectNewRules(
|
|
|
617
617
|
}
|
|
618
618
|
|
|
619
619
|
/**
|
|
620
|
-
*
|
|
620
|
+
* Rule folders holding a rule the base stack resolves to. Every governance
|
|
621
621
|
* stack extends base, so a new rule authored beside one of base's rules is
|
|
622
622
|
* reported to every target the fallback below reads.
|
|
623
623
|
*
|
|
624
|
-
* This is what covers a
|
|
625
|
-
* read off folders the target already holds, and a
|
|
624
|
+
* This is what covers a folder no target can carry yet. Entitlement is otherwise
|
|
625
|
+
* read off folders the target already holds, and a folder base reaches later
|
|
626
626
|
* exists in no installed tree, so without this the rules inside it would reach
|
|
627
627
|
* nobody. Read through `resolveRules` rather than off the stack's entries,
|
|
628
628
|
* since base names its rules one by one and an entry is a slug rather than a
|
|
629
629
|
* folder.
|
|
630
630
|
*
|
|
631
631
|
* A folder only a leaf stack reaches is deliberately absent. It is entitled to
|
|
632
|
-
* some targets and not others, which is the distinction the
|
|
632
|
+
* some targets and not others, which is the distinction the folder test makes and
|
|
633
633
|
* the installed tree is the only evidence of.
|
|
634
634
|
*/
|
|
635
|
-
export function
|
|
635
|
+
export function baseFolders(root: string): Set<string> {
|
|
636
636
|
const resolution = resolveRules(root, 'base')
|
|
637
637
|
if (!resolution.ok) return new Set()
|
|
638
638
|
|
|
639
639
|
return new Set(
|
|
640
640
|
lookupRules(root, resolution.rules)
|
|
641
641
|
.found.map((source) => source.subdir.split(sep)[0] ?? '')
|
|
642
|
-
.filter((
|
|
642
|
+
.filter((folder) => folder !== ''),
|
|
643
643
|
)
|
|
644
644
|
}
|
|
645
645
|
|
|
@@ -651,7 +651,7 @@ export function baseBands(root: string): Set<string> {
|
|
|
651
651
|
* `collectMissing` reports per file through the domain scan, so a rule the
|
|
652
652
|
* chain names and the target lacks reaches both surfaces the same way.
|
|
653
653
|
*
|
|
654
|
-
* The diff-and-
|
|
654
|
+
* The diff-and-folder path stays as the fallback for a target stamped before
|
|
655
655
|
* governance recorded a chain. Rules are domain-scoped there too, so it
|
|
656
656
|
* measures from governance's own anchor rather than from the oldest anchor
|
|
657
657
|
* across domains the way `readNewSkills` does. A shared anchor would let
|
|
@@ -670,7 +670,7 @@ export function baseBands(root: string): Set<string> {
|
|
|
670
670
|
* unmeasured result from a clean one.
|
|
671
671
|
*
|
|
672
672
|
* A recorded chain naming a stack the toolkit no longer ships falls through to
|
|
673
|
-
* the
|
|
673
|
+
* the folder-based path below rather than reporting the empty list an
|
|
674
674
|
* unresolved chain would otherwise produce. That empty list reads exactly
|
|
675
675
|
* like a target holding everything, which is the same failure this function
|
|
676
676
|
* exists to close, so a retired stack name is read the same as no chain at
|
|
@@ -702,8 +702,8 @@ export async function readNewRules(
|
|
|
702
702
|
'governance/rules/',
|
|
703
703
|
])
|
|
704
704
|
|
|
705
|
-
const { held,
|
|
706
|
-
return selectNewRules(paths, held,
|
|
705
|
+
const { held, folders } = readInstalledRules(target, successorResolver(root))
|
|
706
|
+
return selectNewRules(paths, held, folders.union(baseFolders(root)))
|
|
707
707
|
}
|
|
708
708
|
|
|
709
709
|
async function readUpstream(
|
|
@@ -20,7 +20,7 @@ The astro stack covers Astro + TypeScript projects: content sites, marketing sit
|
|
|
20
20
|
- `astro.config.mjs`: `@astrojs/react` integration, `@tailwindcss/vite` in `vite.plugins`, `@/` path alias via `vite.resolve.alias`, `ASTRO_SITE` env for the `site` field. Port `4321` plus `WORKTREE_PORT_OFFSET` at `server.port`, with `strictPort` under `vite.server` and `vite.preview`. Astro merges the user's `vite` block into the config backing both its dev and its static preview server, and feeds `server.port` through as the preview port, so the port sits at the top level while the bind guarantee sits under `vite`.
|
|
21
21
|
- `vitest.config.ts`: uses `getViteConfig` from `astro/config` (not `mergeConfig`). jsdom, globals, setup file, `passWithNoTests: true`, v8 coverage, `**/*.astro` in coverage excludes.
|
|
22
22
|
- `playwright.config.ts`: all browsers, `webServer` runs `bun run build && bun run preview` on port `4321` plus `WORKTREE_PORT_OFFSET`, `reuseExistingServer: false`. Astro's dev/prod gap is wide (MDX, island hydration, asset optimization), so E2E always tests the built `dist/`. `DIST_PREBUILT` set in the environment drops the `build` half, running `bun run preview` alone against a `dist/` a prior CI job already produced.
|
|
23
|
-
- `tsconfig.json`: extends `astro/tsconfigs/strict`, adds `skipLibCheck`, `vitest/globals` and `@testing-library/jest-dom` in types, `@/` paths.
|
|
23
|
+
- `tsconfig.json`: extends `astro/tsconfigs/strict`, adds `skipLibCheck`, `vitest/globals` and `@testing-library/jest-dom/vitest` in types, `@/` paths.
|
|
24
24
|
- `card.config.mjs`, `card-src/pages/og-card.astro`, and `scripts/check-card-exclusion.sh`: the social card route, its structural build exclusion, and the check enforcing it. See `## Social card route` below.
|
|
25
25
|
- `eslint.config.js`: overrides the web layer. Adds `eslint-plugin-astro` (`.astro` parser via `astro-eslint-parser`). React-hooks scoped to `.jsx`/`.tsx` only (`.astro` is not React). The shared block's `files` selector includes `.astro`, so `check-file/filename-naming-convention` reaches `.ts`, `.tsx`, and `.astro` under `KEBAB_CASE`, overriding Astro's own PascalCase component convention deliberately, on the ground that a component's name in markup comes from the import binding rather than the filename. `.js` and `.jsx` stay out of the rule's own pattern, matching `web` and `nextjs`. `check-file/folder-naming-convention` reaches every `src/**` folder except `__tests__` and the whole `pages/` subtree, which carries its own off-block for the bracket-named dynamic routes and nested slug folders Astro's file-based routing produces. See `canon/context/tooling/stacks.md` for the measurement.
|
|
26
26
|
|
|
@@ -32,7 +32,7 @@ The astro stack covers Astro + TypeScript projects: content sites, marketing sit
|
|
|
32
32
|
|
|
33
33
|
Unit-test React island components (`.tsx`) only. Do not test `.astro` files. Page-level behavior is verified by Playwright against rendered output.
|
|
34
34
|
|
|
35
|
-
Vitest is pinned to `^
|
|
35
|
+
Vitest is pinned to `^5` in the web manifest, which supports the Vite 8 that Astro 7 bundles. The earlier `^3` pin avoided `^4` bundling rolldown-vite, which ignored the esbuild JSX config in `@vitejs/plugin-react`. Astro now bundles Vite 8 itself, so that conflict no longer applies.
|
|
36
36
|
|
|
37
37
|
## Prettier (extend)
|
|
38
38
|
|
|
@@ -46,16 +46,10 @@ const PHASES: readonly Phase[] = [
|
|
|
46
46
|
failed: 'Lint failed',
|
|
47
47
|
passed: 'Lint passed',
|
|
48
48
|
},
|
|
49
|
-
{
|
|
50
|
-
script: 'format',
|
|
51
|
-
title: 'Formatting',
|
|
52
|
-
failed: 'Format failed',
|
|
53
|
-
passed: 'Format applied',
|
|
54
|
-
},
|
|
55
49
|
{
|
|
56
50
|
script: 'check:format',
|
|
57
51
|
title: 'Format check',
|
|
58
|
-
failed:
|
|
52
|
+
failed: "Format check failed. Run 'bun run format' to fix it",
|
|
59
53
|
passed: 'Format check passed',
|
|
60
54
|
},
|
|
61
55
|
{
|
|
@@ -85,7 +79,7 @@ const PHASES: readonly Phase[] = [
|
|
|
85
79
|
// A subfolder synced with --skip base declares none of these, since the
|
|
86
80
|
// repository root owns them, so a list that does not require one runs it only
|
|
87
81
|
// where the folder declares it.
|
|
88
|
-
const BASE_PHASES = new Set(['
|
|
82
|
+
const BASE_PHASES = new Set(['check:format'])
|
|
89
83
|
|
|
90
84
|
// An add-on stack declares these, keyed to the stack that ships each, so a
|
|
91
85
|
// folder that never synced the add-on skips the phase rather than failing it.
|
|
@@ -13,8 +13,8 @@ Golden config files live in `tooling/base/configs/` and are copied into the targ
|
|
|
13
13
|
- `.prettierrc`: `semi: false`, `singleQuote: true`, plus a parser override per non-standard extension (`.mdx` to `markdown`).
|
|
14
14
|
- `commitlint.config.js`: ESM default export extending `@commitlint/config-conventional`. Rules are `header-max-length: 72`, `scope-case: lower-case`, `subject-full-stop: never`, `subject-case` disabled, and a local `no-claude-co-author` rule refusing a `Co-authored-by` trailer that names Claude or Anthropic.
|
|
15
15
|
- `.husky/`: `pre-commit`, `commit-msg`, `pre-push`, `post-merge`, `post-rewrite`.
|
|
16
|
-
- `scripts/verify.ts`: the one verify runner every stack shares, and the command behind `check`. It runs typecheck, lint, format
|
|
17
|
-
- `scripts/verify.json`: the phases a stack requires, plus any tools and preconditions it probes first. The nearest stack's copy wins. A required phase whose script `package.json` lacks fails the run. A base phase the list leaves out runs only where the folder declares its script. Base requires
|
|
16
|
+
- `scripts/verify.ts`: the one verify runner every stack shares, and the command behind `check`. It runs typecheck, lint, format check, shell, unit tests, build, markdown bans, then card exclusion, always in that order, and skips any phase the folder's `scripts/verify.json` leaves out. Node modules only, since a target's own lint and typecheck read it.
|
|
17
|
+
- `scripts/verify.json`: the phases a stack requires, plus any tools and preconditions it probes first. The nearest stack's copy wins. A required phase whose script `package.json` lacks fails the run. A base phase the list leaves out runs only where the folder declares its script. Base requires `check:format`, so a base-only target still fails on a missing one. The shell phase runs only where `package.json` declares `check:shell`, which the `shell` stack adds, and probes for `shfmt` and `shellcheck` first. These two files are base's `[sync] per_root` set, which a `--skip base` subfolder still receives.
|
|
18
18
|
|
|
19
19
|
## What ships as user-owned seeds
|
|
20
20
|
|
|
@@ -75,15 +75,15 @@ Sticky negative knowledge. Do not relearn.
|
|
|
75
75
|
|
|
76
76
|
## CLI
|
|
77
77
|
|
|
78
|
-
| Script | What it does
|
|
79
|
-
| ---------------------- |
|
|
80
|
-
| `bun run check` |
|
|
81
|
-
| `bun run check:format` | Asserts prettier formatting without writing
|
|
82
|
-
| `bun run format` | Writes prettier formatting in place
|
|
83
|
-
| `bun run prepare` | Initializes husky hooks, run automatically on `bun install`
|
|
78
|
+
| Script | What it does |
|
|
79
|
+
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
80
|
+
| `bun run check` | Gates a checkout through `scripts/verify.ts` and writes nothing. Honors `VERIFY_NESTED=true` to suppress timeline boundaries when another script calls it. |
|
|
81
|
+
| `bun run check:format` | Asserts prettier formatting without writing |
|
|
82
|
+
| `bun run format` | Writes prettier formatting in place |
|
|
83
|
+
| `bun run prepare` | Initializes husky hooks, run automatically on `bun install` |
|
|
84
84
|
|
|
85
85
|
Base writes `check` as a `[scripts.override]`, so a sync replaces whatever `check` a target declared, including one that chained further checks after the runner. Re-add a chained check as its own script after a sync.
|
|
86
86
|
|
|
87
|
-
`bun run check`
|
|
87
|
+
`bun run check` gates a checkout and writes nothing. Formatting drift fails it at `check:format`, and the failure line names `bun run format`, the one command that writes. It once ran `format` first to auto-fix drift, which rewrote files in a checkout several sessions share on every push and left a gate that could not fail. That was rejected, so the writing pass stays in `bun run format` and a push fails until it runs. The pull request workflow calls `check:format` directly as well.
|
|
88
88
|
|
|
89
|
-
`scripts/verify.ts`'s `Markdown bans` stage
|
|
89
|
+
`scripts/verify.ts`'s `Markdown bans` stage gates on banned characters. It runs `canon markdown audit` over every tracked markdown file except `CHANGELOG.md`, since a generated changelog carries commit subjects nobody wrote against the ban set, and exits `2` on a finding or `3` on a shipped-empty ban set, failing `bun run check` and the `pre-push` hook that calls it. A refusal to measure exits `1` and is logged as a skip rather than a failure, as does a corpus with no file left to check once `CHANGELOG.md` is set aside. The stage needs `canon` on PATH. `canon docs projects` names the install command. Without it, the stage is skipped and logged, and coverage falls back to the format check above.
|
|
@@ -13,12 +13,12 @@ Owns the GitHub Actions workflow that gates a merge: which events start a run, a
|
|
|
13
13
|
|
|
14
14
|
- `.github/workflows/` owns the workflow definitions a trigger below starts
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
### Triggers
|
|
17
17
|
|
|
18
18
|
- Pull requests targeting `main`
|
|
19
19
|
- `workflow_dispatch` (manual run from the Actions tab)
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
### Checks
|
|
22
22
|
|
|
23
23
|
Defined in `.github/workflows/verify.yml`. All jobs must pass before merge.
|
|
24
24
|
|
|
@@ -26,6 +26,6 @@ Defined in `.github/workflows/verify.yml`. All jobs must pass before merge.
|
|
|
26
26
|
| ------ | ---------------------- | ----------------- |
|
|
27
27
|
| Format | `bun run check:format` | prettier is clean |
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
### Running CI locally
|
|
30
30
|
|
|
31
|
-
`bun run check` runs the same assert
|
|
31
|
+
`bun run check` runs the same assert and writes nothing. If CI fails on format, run `bun run format` locally and commit the diff.
|
|
@@ -14,24 +14,24 @@ Owns how the project runs on a developer machine: installing the toolchain, the
|
|
|
14
14
|
- `scripts/` owns the shell scripts the package scripts below call
|
|
15
15
|
- `.husky/` owns the git hooks
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
### Setup
|
|
18
18
|
|
|
19
19
|
- Install [Bun](https://bun.sh): `curl -fsSL https://bun.sh/install | bash`
|
|
20
20
|
- Install dependencies: `bun install`
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
### Scripts
|
|
23
23
|
|
|
24
|
-
| Command | Purpose
|
|
25
|
-
| ---------------- |
|
|
26
|
-
| `bun run check` |
|
|
27
|
-
| `bun run format` | Auto-fix prettier formatting.
|
|
24
|
+
| Command | Purpose |
|
|
25
|
+
| ---------------- | ---------------------------------------------------------------------------------------- |
|
|
26
|
+
| `bun run check` | Gates locally and writes nothing. Fails on formatting drift until `bun run format` runs. |
|
|
27
|
+
| `bun run format` | Auto-fix prettier formatting. |
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
### Shell scripts
|
|
30
30
|
|
|
31
31
|
All `.sh` files live under `scripts/`. Do not place shell scripts outside `scripts/`.
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
### Husky hooks
|
|
34
34
|
|
|
35
35
|
- `pre-commit` runs `lint-staged` (prettier on staged files).
|
|
36
36
|
- `commit-msg` runs `commitlint` against the conventional commit format.
|
|
37
|
-
- `pre-push` runs `bun run check`. When a markdown-bans audit tool is on PATH, it also gates on banned characters across every tracked markdown file except `CHANGELOG.md`.
|
|
37
|
+
- `pre-push` runs `bun run check`. When a markdown-bans audit tool is on PATH, it also gates on banned characters across every tracked markdown file except `CHANGELOG.md`. A push fails on formatting drift until `bun run format` runs, since the hook writes nothing.
|
|
@@ -26,6 +26,14 @@ case "$file_path" in
|
|
|
26
26
|
*/.claude/.tmp/* | */.canon/tmp/*) exit 0 ;;
|
|
27
27
|
esac
|
|
28
28
|
|
|
29
|
+
# A background session's temp folder is the harness's own, told to the session
|
|
30
|
+
# and located under the home folder, outside every project. Matching its shape
|
|
31
|
+
# rather than reading CLAUDE_JOB_DIR holds whether or not this hook's
|
|
32
|
+
# environment carries the variable.
|
|
33
|
+
case "$file_path" in
|
|
34
|
+
*/.claude/jobs/*/tmp/*) exit 0 ;;
|
|
35
|
+
esac
|
|
36
|
+
|
|
29
37
|
# A project whose own root sits under a path carrying a tmp segment is not
|
|
30
38
|
# writing to system temp, and the bare pattern below would trip on every source
|
|
31
39
|
# file it holds. The project root is stripped before the match rather than
|
|
@@ -17,9 +17,9 @@ The vite-react stack covers Vite + React + TypeScript projects: web apps and Chr
|
|
|
17
17
|
## What ships as golden configs
|
|
18
18
|
|
|
19
19
|
- `vite.config.ts`: `@vitejs/plugin-react`, `@tailwindcss/vite`, `@` path alias to `./src`, `VITE_BASE_URL` env for base path. Dev port `5173` and preview port `4173`, each plus `WORKTREE_PORT_OFFSET`, both with `strictPort`.
|
|
20
|
-
- `vitest.config.ts`: merges from `vite.config.ts
|
|
20
|
+
- `vitest.config.ts`: merges from `vite.config.ts` (imported with its `.ts` extension, which Vite 8 requires), jsdom, globals, setup file, `passWithNoTests: true`, v8 coverage.
|
|
21
21
|
- `playwright.config.ts`: all browsers, `webServer` on `bun run dev` at port `5173` plus `WORKTREE_PORT_OFFSET`, `reuseExistingServer: false`, trace under `use`.
|
|
22
|
-
- `tsconfig.json`: unified, `noEmit: true`, `skipLibCheck: true`, `@/` paths, `vitest/globals` and `@testing-library/jest-dom` in types.
|
|
22
|
+
- `tsconfig.json`: unified, `noEmit: true`, `skipLibCheck: true`, `@/` paths, `vitest/globals` and `@testing-library/jest-dom/vitest` in types.
|
|
23
23
|
|
|
24
24
|
## Chrome extension variant
|
|
25
25
|
|
|
@@ -22,9 +22,9 @@ packages = [
|
|
|
22
22
|
"@types/react",
|
|
23
23
|
"@types/react-dom",
|
|
24
24
|
"@types/node",
|
|
25
|
-
"vitest@^
|
|
26
|
-
"@vitest/coverage-v8@^
|
|
27
|
-
"@vitest/ui@^
|
|
25
|
+
"vitest@^5",
|
|
26
|
+
"@vitest/coverage-v8@^5",
|
|
27
|
+
"@vitest/ui@^5",
|
|
28
28
|
"jsdom",
|
|
29
29
|
"@testing-library/react",
|
|
30
30
|
"@testing-library/jest-dom",
|
package/tooling/web/reference.md
CHANGED
|
@@ -11,7 +11,7 @@ The web layer covers web-universal tooling shared across Vite + React, Astro, an
|
|
|
11
11
|
Golden config files live in `tooling/web/configs/` and are copied into the target on `canon tooling sync web . --write`, replacing whatever sits at those paths. They are the source of truth. The reference covers rationale and tradeoffs. Configs show the concrete setup.
|
|
12
12
|
|
|
13
13
|
- `eslint.config.js`: flat config with `@eslint/js`, `typescript-eslint`, React hooks, import sort, check-file, vitest rules scoped to test files, `eslint-config-prettier` last.
|
|
14
|
-
- `src/test/setup.ts`: `@testing-library/jest-dom` import, `cleanup` after each test.
|
|
14
|
+
- `src/test/setup.ts`: `@testing-library/jest-dom/vitest` import, `cleanup` after each test.
|
|
15
15
|
- `e2e/screenshot.ts`: capture template. A single `CASES` record at the top carries one entry per output file, each naming a section, a theme, and a route, and the loop below crosses every case with the `VIEWPORTS` array and writes `screenshots/<hostname>/<section>/<width>--<theme>.png`, keyed on `SCREENSHOT_BASE_URL`'s hostname so a local and a deployed run land in different folders. `VIEWPORTS` holds four breakpoint buckets named by width, 320, 768, 1280 and 1536, with 320 as the base a page has to hold without wrapping or clipping. A case flagged `evidence: true` additionally writes `evidence/<section>/<width>--<theme>.png`, with no hostname segment, at the viewports flagged `evidence` alone, which are 320 and 1280. Committing all four multiplies the tracked frames by the width count, so the flag is what keeps the tracked set at twice the sections rather than four times. A case may name `excludeViewports` to skip a width, for a route whose long-form prose reflows at 320 instead of breaking. `SCREENSHOT_FILTER` narrows a run to the cases whose label, `<section>/<width>--<theme>`, contains any comma-separated term, exits 1 when nothing matches and lists the labels that exist, and leaves the rest of the sweep alone. `--require-base-url` skips a flagged case entirely, so a production smoke run neither writes to the committed path nor counts an evidence route in its console-clean check, and exits 1 when that leaves zero cases run, so flagging every case cannot silence the production check without saying so. Per-project cases extend the one record. A route's widths and themes sit together under its section folder, so the filename carries both. A case may also name `sections`, one `{ name, selector }` per addressable part of the route, and each writes its own frame at `screenshots/<hostname>/<section>/<name>/<width>--<theme>.png` beside the whole-page one, plus `evidence/<section>/<name>/<width>--<theme>.png` where the case is flagged and the width carries `evidence`. The field is optional, so a case that names none captures the page alone as before, and a selector matching nothing is reported and skipped rather than raised, since `CASES` is a template a project rewrites and a target that syncs this file before editing its own list would otherwise capture nothing at all. Testing that every named section resolves belongs to the project that owns the selectors, beside its own page. A case may also name `mask`, a list of selectors whose boxes are painted over in every frame the case writes, whole-page and section alike, for a value that moves between runs with no code change, so a double capture still compares everything else. A mask selector matching nothing is reported and skipped the same way. Every case settles before anything is shot: the context is created with `reducedMotion: 'reduce'`, each named section is scrolled into view so an `IntersectionObserver` fires and a frame marked `loading="lazy"` loads, the page returns to the top, and fonts, images and same-origin frames are waited out on a bounded condition rather than on a second `networkidle`, which is a lifecycle event of the navigation and does not re-arm for a load a scroll started. A section frame drops the page's floating chrome, being whatever computes to `position: sticky` or `fixed`, because a section taller than the viewport is scrolled into view to be cut and a sticky bar otherwise rides that scroll into the middle of the frame. The whole-page frame is shot first and keeps its chrome. `--check-console-clean` collects `console`-level error messages per case and exits 1 with the list if any fired, turning the capture into a smoke check. `--require-base-url` exits 1 before launching a browser when `SCREENSHOT_BASE_URL` is unset, guarding a script meant to run against a real deployment from silently capturing `localhost`.
|
|
16
16
|
- `scripts/screenshot.sh`: sources `scripts/lib/preview-server.sh`, then runs the capture against the served preview.
|
|
17
17
|
- `scripts/lib/preview-server.sh`: sourced, never executed. Builds, serves on `PREVIEW_PORT`, blocks until the port answers, and traps the whole process group on exit, including the detached grandchild `lsof` finds. Both capture scripts source it so the startup lives once.
|