@erclx/canon 5.14.1 → 5.15.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 (54) hide show
  1. package/README.md +3 -2
  2. package/claude/.claude-plugin/plugin.json +1 -1
  3. package/claude/skills/draft-screencast/REQUIREMENT.md +2 -1
  4. package/claude/skills/draft-screencast/SKILL.md +14 -9
  5. package/claude/skills/read-frames/SKILL.md +3 -2
  6. package/claude/skills/record-screencast/REQUIREMENT.md +3 -0
  7. package/claude/skills/record-screencast/SKILL.md +28 -5
  8. package/docs/agents/commands.md +3 -0
  9. package/docs/agents/demo.md +34 -7
  10. package/docs/agents/migrate.md +1 -1
  11. package/docs/agents/sandbox.md +25 -0
  12. package/docs/target/migrations.md +1 -1
  13. package/docs/workflow/ai-workflow.md +2 -3
  14. package/docs/workflow/skill-map.md +1 -1
  15. package/governance/renames.toml +7 -5
  16. package/governance/rules/canon/630-requirements.md +1 -1
  17. package/package.json +5 -2
  18. package/src/canvas/client/app.tsx +85 -0
  19. package/src/canvas/client/main.tsx +62 -0
  20. package/src/canvas/client/pages-panel.tsx +123 -0
  21. package/src/canvas/client/shell.css +319 -0
  22. package/src/canvas/client/state.ts +186 -0
  23. package/src/canvas/client/surface.tsx +213 -0
  24. package/src/canvas/content.ts +326 -0
  25. package/src/canvas/index.html +14 -0
  26. package/src/canvas/server.ts +302 -0
  27. package/src/canvas/tokens.ts +71 -0
  28. package/src/claude/seeds.ts +0 -1
  29. package/src/cli.ts +2 -0
  30. package/src/commands/canvas.ts +325 -0
  31. package/src/commands/claude.ts +9 -14
  32. package/src/commands/demo.ts +6 -6
  33. package/src/commands/sandbox.ts +108 -0
  34. package/src/context/classify/prompts.ts +1 -1
  35. package/src/context/folders.ts +0 -1
  36. package/src/demo/compile.ts +8 -4
  37. package/src/demo/container.ts +1 -1
  38. package/src/gov/renames.ts +3 -2
  39. package/src/help.ts +1 -0
  40. package/src/record-root.ts +1 -0
  41. package/src/sandbox/equivalence.ts +847 -0
  42. package/src/serve/static.ts +25 -11
  43. package/src/surface-root.ts +0 -1
  44. package/standards/architecture.md +1 -1
  45. package/standards/context.md +1 -1
  46. package/standards/design.md +1 -1
  47. package/standards/index.md +0 -1
  48. package/standards/requirements.md +4 -6
  49. package/standards/wireframes.md +2 -2
  50. package/tooling/claude/reference.md +0 -1
  51. package/tooling/claude/seeds/canon/REQUIREMENTS.md +0 -2
  52. package/governance/rules/canon/645-decisions.md +0 -12
  53. package/standards/decisions.md +0 -105
  54. package/tooling/claude/seeds/canon/decisions/index.md +0 -8
@@ -13,7 +13,7 @@ export const SERVE_HOST = '127.0.0.1'
13
13
  export const DEFAULT_PORT = 8787
14
14
 
15
15
  /** How far past the requested port to look before refusing. */
16
- const PORT_ATTEMPTS = 20
16
+ export const PORT_ATTEMPTS = 20
17
17
 
18
18
  const DEFAULT_ENTRY = 'index.html'
19
19
 
@@ -216,23 +216,23 @@ export function shouldWalkPast(error: unknown): boolean {
216
216
  return (error as NodeJS.ErrnoException | null)?.code === 'EADDRINUSE'
217
217
  }
218
218
 
219
+ type BoundServer = ReturnType<typeof Bun.serve>
220
+
219
221
  /**
220
222
  * Picks a listening port, starting at the requested one and walking forward.
221
223
  * A busy port is the ordinary case rather than a failure, since a preview of
222
224
  * one workspace is routinely open while another is started.
225
+ *
226
+ * Takes the bind as a parameter so every surface that serves walks ports the
227
+ * same way, whatever routes it binds.
223
228
  */
224
- function listen(
225
- root: string,
229
+ export function bindFirstFree(
226
230
  first: number,
227
- index: boolean,
228
- ): { server: ReturnType<typeof Bun.serve>; port: number } | undefined {
231
+ bind: (port: number) => BoundServer,
232
+ ): { server: BoundServer; port: number } | undefined {
229
233
  for (let port = first; port < first + PORT_ATTEMPTS; port++) {
230
234
  try {
231
- const server = Bun.serve({
232
- hostname: SERVE_HOST,
233
- port,
234
- fetch: (request) => respond(root, request, index),
235
- })
235
+ const server = bind(port)
236
236
  /**
237
237
  * The bound port rather than the requested one. Port 0 asks the OS to
238
238
  * choose, so reporting the request builds a URL pointing at nothing.
@@ -245,7 +245,7 @@ function listen(
245
245
  * Contention is the one cause worth walking past. A permission failure
246
246
  * or an unavailable interface swallowed here would be retried twenty
247
247
  * times and then reported as a port range being full, which names a
248
- * cause nothing checked. `startServer` turns the rethrow into a refusal.
248
+ * cause nothing checked. The caller turns the rethrow into a refusal.
249
249
  */
250
250
  if (!shouldWalkPast(error)) throw error
251
251
  }
@@ -253,6 +253,20 @@ function listen(
253
253
  return undefined
254
254
  }
255
255
 
256
+ function listen(
257
+ root: string,
258
+ first: number,
259
+ index: boolean,
260
+ ): { server: BoundServer; port: number } | undefined {
261
+ return bindFirstFree(first, (port) =>
262
+ Bun.serve({
263
+ hostname: SERVE_HOST,
264
+ port,
265
+ fetch: (request) => respond(root, request, index),
266
+ }),
267
+ )
268
+ }
269
+
256
270
  export async function respond(
257
271
  root: string,
258
272
  request: Request,
@@ -43,7 +43,6 @@ export const SURFACE_ENTRIES: readonly string[] = [
43
43
  'DESIGN.md',
44
44
  'context',
45
45
  'wireframes',
46
- 'decisions',
47
46
  'canon',
48
47
  ]
49
48
 
@@ -40,7 +40,7 @@ The slots come from a scale test. Ask whether the decision would still be in thi
40
40
  - A decision that fills no slot. It lives in the domain context entry it constrains, and this file carries at most one line pointing at it.
41
41
  - A measurement paragraph specific to one domain's own mechanism, even behind a slot decision. Route it to that domain's context entry and keep the choice, the alternative that lost, and one reason here.
42
42
  - The instances of a build principle. The principle takes one sentence here, and each instance lives in the domain entry where it applies.
43
- - The history of how a decision was reached or revised: rounds of candidates, a figure followed by its correction, a branch or change that moved a number. That trail goes to the decision log or the change that introduced it.
43
+ - The history of how a decision was reached or revised: rounds of candidates, a figure followed by its correction, a branch or change that moved a number. Cut it. Git and the change that introduced it keep the trail.
44
44
 
45
45
  ## Sections
46
46
 
@@ -100,7 +100,7 @@ Only the `development` entry carries this section. It is not a general-purpose h
100
100
  - Anything already in `canon/REQUIREMENTS.md` or `canon/ARCHITECTURE.md`.
101
101
  - The history of how the domain reached its current shape. An entry describes the repository as it stands, so a change number, release label, or date attached to a change goes wherever the project tracks work.
102
102
  - A rejected alternative's provenance, which is the same rule at the one place the section above admits history. Keep what was tried and why it lost. Cut who tried it and when.
103
- - The route to a decision: the rounds of candidates, the tuning steps a threshold passed through, the review pass that caught a miss. State the decision, what lost, and why, once and in the present tense. The route goes to the decision log or the change that introduced it.
103
+ - The route to a decision: the rounds of candidates, the tuning steps a threshold passed through, the review pass that caught a miss. State the decision, what lost, and why, once and in the present tense. Cut the route. Git and the change that introduced it keep it.
104
104
  - Measured results a generated file already carries. Point at the file instead of copying the figure, so a re-run cannot leave the entry behind.
105
105
 
106
106
  ## Length
@@ -27,7 +27,7 @@ Does not govern:
27
27
 
28
28
  - CSS classes and prop names. Those live in code.
29
29
  - Anything that needs updating every time the code is refactored
30
- - The history of how a value or a mark was chosen: the candidates, the rounds, the date of a pick. State the rule and the current value. The trail goes to the decision log.
30
+ - The history of how a value or a mark was chosen: the candidates, the rounds, the date of a pick. State the rule and the current value, and cut the trail. Git keeps it.
31
31
 
32
32
  ## Format
33
33
 
@@ -12,7 +12,6 @@ Reference docs for consistent authoring across the toolkit and target projects.
12
12
  - [Branch reference](branch.md): Branch naming format and type conventions
13
13
  - [Commit reference](commit.md): Commit message format and type conventions
14
14
  - [Context entry reference](context.md): Shape and content rules for canon/context/<domain>.md entries
15
- - [Decisions reference](decisions.md): Folder layout, ordinal filename, frontmatter, record sections, and the append-only lifecycle for canon/decisions/
16
15
  - [Design reference](design.md): Shape and content rules for canon/DESIGN.md
17
16
  - [Diagram reference](diagrams.md): Shape and content rules for .canon/diagrams/<kind>.md files
18
17
  - [Docs reference](docs.md): Reader and jurisdiction, frontmatter, page structure, what a page links out to, the diagram permission, and when a category earns a subfolder
@@ -9,7 +9,7 @@ Applies to `canon/REQUIREMENTS.md`. Describes what the product does and why, not
9
9
 
10
10
  ## Scope
11
11
 
12
- Governs the product-scope document at `canon/REQUIREMENTS.md`: problem, goals, non-goals, MVP features, distribution, stack, and constraints.
12
+ Governs the product-scope document at `canon/REQUIREMENTS.md`: problem, goals, non-goals, MVP features, distribution, and constraints.
13
13
 
14
14
  Does not govern:
15
15
 
@@ -23,7 +23,6 @@ Does not govern:
23
23
  - User-facing goals stated as outcomes, not implementation
24
24
  - Explicit non-goals that prevent feature creep. Mark deferred items "(deferred)" so they read as paused, not excluded. A non-goal resting on how an outside tool, an installer, or the model behaves may close with one `Revisit when <finding>.` sentence, and a non-goal resting on scope alone takes none.
25
25
  - MVP features as a numbered list: feature name and one-line description
26
- - Tech stack as a plain list of tools
27
26
  - Hard constraints that shape every decision
28
27
 
29
28
  ## What does not go in
@@ -31,14 +30,15 @@ Does not govern:
31
30
  - Implementation details, API names, or internal component references
32
31
  - Anything that describes how a feature is built rather than what it does
33
32
  - Measured results, such as scores, benchmark figures, or token counts. They move on every run and this file changes least. Name where the results live instead.
33
+ - Content another canonical doc owns, such as the stack list, which the stack-and-runtime slot of `canon/ARCHITECTURE.md` holds, or the rules of this standard itself
34
34
 
35
35
  ## Sections
36
36
 
37
- Use `## Problem`, `## Goals`, `## Non-goals`, `## MVP features`, `## Tech stack`, and `## Constraints`. Add `## Distribution` when the rule below applies. Add `## Premise` when the project exists to answer a question, stated as the question and what would count as an answer, never as the answer measured so far. Drop a section rather than pad it with filler.
37
+ Use `## Problem`, `## Goals`, `## Non-goals`, `## MVP features`, and `## Constraints`. Add `## Distribution` when the rule below applies. Add `## Worldview` when the project holds beliefs that shape every decision, and keep a belief there only when it changes a decision, since a padded worldview turns into a second goals list. Add `## Premise` when the project exists to answer a question, stated as the question and what would count as an answer, never as the answer measured so far. Drop a section rather than pad it with filler.
38
38
 
39
39
  ## Lifecycle
40
40
 
41
- The MVP list is a historical record of the original scope. Once those features ship it stays as written. Do not renumber it, do not append to it, and do not annotate entries with status. A reader telling the original scope apart from what followed depends on the first one staying legible.
41
+ Once every entry in the MVP list, or in a later scope section, has shipped, delete the section. Git keeps the old text, and the document states the project as it stands. Do not annotate an entry as shipped and leave it in place. While any entry is unshipped, do not renumber the list or append to it.
42
42
 
43
43
  Later scope arrives as a new section rather than as an extension of the MVP list. Name the section for what it delivers and state its entries as outcomes, the same way the goals are stated. Nothing sequences either list into versions. Work reaches the board as discrete tasks under `tasks.md`, and `board.md` orders them by readiness, so a section here states what is wanted and never when it lands.
44
44
 
@@ -65,7 +65,5 @@ State each entry as an outcome the consumer reaches, never as the mechanism that
65
65
 
66
66
  <!-- ## Distribution: include only when shipping outside the repository -->
67
67
 
68
- ## Tech stack
69
-
70
68
  ## Constraints
71
69
  ```
@@ -76,11 +76,11 @@ Both fields feed `canon/wireframes/index.md` when regenerated.
76
76
  ## Not on this surface
77
77
 
78
78
  - State what was deliberately left off, one bullet per exclusion, as a present-tense rule: `- No navigation rail`. This is the section that stops a draft from proposing what was already ruled out.
79
- - Keep the reason to a clause where one is needed. The rounds that ruled it out go to the decision log.
79
+ - Keep the reason to a clause where one is needed. Cut the rounds that ruled it out.
80
80
 
81
81
  ## What moves out
82
82
 
83
- - Which candidate beat which, and when: the decision log
83
+ - Which candidate beat which, and when: nowhere. Cut it, since git keeps the old text
84
84
  - Measurements such as contrast ratios and timings: `canon/DESIGN.md` for tokens and floors, the surface's context entry for the rest
85
85
 
86
86
  ## What moves to canon/context/
@@ -14,7 +14,6 @@ canon/
14
14
  ├── ARCHITECTURE.md ← seeded. Technical design decisions and open questions
15
15
  ├── DESIGN.md ← seeded. Visual intent and the decisions behind it
16
16
  ├── context/ ← seeded. Per-domain narrative. `index.md` is the discovery anchor.
17
- ├── decisions/ ← seeded. Decision history a canonical doc points at, never loaded eagerly. `<nn>-<slug>.md` records.
18
17
  └── wireframes/ ← seeded. Per-surface regions and states. `index.md` is the discovery anchor; `<surface>.md` files hold the regions list, the states table, and the behavior bullets.
19
18
 
20
19
  .claude/
@@ -13,6 +13,4 @@ Authoring guidance: the requirements standard.
13
13
  1. Feature: description
14
14
  2. Feature: description
15
15
 
16
- ## Tech stack
17
-
18
16
  ## Constraints
@@ -1,12 +0,0 @@
1
- ---
2
- description: Route canon/decisions/ edits to the decisions standard for record shape and lifecycle
3
- paths:
4
- - 'canon/decisions/**'
5
- - '.claude/decisions/**'
6
- ---
7
-
8
- # Decisions standards
9
-
10
- ## Authority
11
-
12
- - Follow the decisions standard for folder layout, the ordinal filename, frontmatter, record sections, and the append-only lifecycle. It is the single source. Read it with `canon standards decisions`.
@@ -1,105 +0,0 @@
1
- ---
2
- title: Decisions reference
3
- description: Folder layout, ordinal filename, frontmatter, record sections, and the append-only lifecycle for canon/decisions/
4
- ---
5
-
6
- # Decisions reference
7
-
8
- Applies to `canon/decisions/`. Holds the history a canonical doc used to carry itself: pick rounds, superseded figures, and a decision's rejected alternatives, in a tracked folder nothing loads eagerly. A canonical doc points at a record from its own history section rather than restating it.
9
-
10
- ## Scope
11
-
12
- Governs `canon/decisions/`: folder layout, the ordinal filename, frontmatter, record sections, and the append-only lifecycle.
13
-
14
- Does not govern:
15
-
16
- - Which canonical doc points here and when, and what stays behind in that doc's own body: `architecture.md`, `context.md`, `wireframes.md`, `design.md`, `requirements.md`, once each states its own retirement rule
17
- - Voice, rhythm, and sentence construction: the `write-human` skill
18
- - Headings, punctuation, word choice, and file references: `markdown.md`
19
-
20
- ## What a working record looks like
21
-
22
- A record works when a reader who has never opened the project can follow it from the file alone:
23
-
24
- - What was decided, stated once, without needing the canonical doc that points here
25
- - What else was considered, and why each alternative lost
26
- - Which claim rests on a measurement, and what commit that measurement was read against
27
-
28
- A record failing these is non-conforming even when it satisfies every shape rule below.
29
-
30
- ## Folder name
31
-
32
- - `canon/decisions/`, resolved the way every tracked surface is: at `canon/decisions/` in a project that has moved, at `.claude/decisions/` in one that has not.
33
- - Never add `canon/decisions/index.md` to a `CLAUDE.md` `@` import. A log that loads eagerly rebuilds the bloat it exists to absorb. A canonical doc's own pointer is how a reader reaches a record, one file at a time.
34
-
35
- ## Record filename
36
-
37
- - Name each record `<nn>-<slug>.md`, a two-digit zero-padded ordinal followed by a kebab-case slug, the same shape a groundwork track's folder takes.
38
- - The ordinal is the order the record was written in, which is what lets a listing sort by when a decision landed rather than alphabetically by subject.
39
- - Never renumber an existing record. A later reader cites it by that name, and a record whose number moved is a record a stale citation can no longer find.
40
-
41
- ## Frontmatter
42
-
43
- - `title` (required): the decision in sentence case
44
- - `description` (required): one line naming what was decided
45
-
46
- ## Sections
47
-
48
- Use `## Context`, `## Decision`, `## Alternatives`, `## Revisit when`, and `## Measurements`.
49
-
50
- - `## Context`: the problem as it stood, stated so a reader needs nothing else open. Restate a fact rather than pointing at where it was found.
51
- - `## Decision`: what was chosen, and why, in enough detail that a reader can tell it apart from an alternative that sounds similar.
52
- - `## Alternatives`: each one considered and dropped, with the reason it lost. An alternative with no stated reason reads as a claim nobody checked.
53
- - `## Revisit when`: one bullet per finding that would reopen the decision. Required when the record came from a groundwork track whose deciding leans carried "Overturned by" lines, which carry over as written. It is optional otherwise, for a decision resting on how an outside tool, an installer, or the model behaves. Skip it for a decision resting on the project's own code.
54
- - `## Measurements`: skip when the decision cites no number. When it does, state the number and close with the commit it was read against, per Verification anchors below.
55
-
56
- ## Verification anchors
57
-
58
- A record's reasoning stays correct while the numbers it cites move. The anchor records what a measured claim was read against, so a reader can tell a number that was checked and held from one nobody has looked at since.
59
-
60
- - Close a `## Measurements` section with a trailing sentence naming the short commit SHA and the ISO date that number was read: `Measured at <short-sha> on <YYYY-MM-DD>.`
61
- - Anchor on the number alone. A record citing none carries no `## Measurements` section at all.
62
- - Read an absent section as unchecked rather than as current. A record with no measurements has nothing due a re-read.
63
-
64
- ## Lifecycle
65
-
66
- - Append-only. A written record is never edited to reflect a later reversal.
67
- - Write a new record when a later decision supersedes an earlier one, naming the record it supersedes. The old record stays as it was written, since it is history rather than a live statement of the current shape.
68
- - Never auto-loaded. A canonical doc's own history section links to a record by relative path, and a reader reaches it by following that link, not by the folder loading with the session.
69
-
70
- ## Citation
71
-
72
- - Never cite `.canon/`. A record restates what it needs, since a clone without the gitignored records folder resolves nothing there.
73
- - Cite a same-repository pull request or commit the way `publish.md` fixes for any tracked document.
74
-
75
- ## Template
76
-
77
- ```markdown
78
- ---
79
- title: <Decision, in sentence case>
80
- description: <one line naming what was decided>
81
- ---
82
-
83
- # <Decision title>
84
-
85
- ## Context
86
-
87
- <The problem as it stood, self-contained.>
88
-
89
- ## Decision
90
-
91
- <What was chosen, and why.>
92
-
93
- ## Alternatives
94
-
95
- - **<Alternative>.** <Why it lost.>
96
- - **<Alternative>.** <Why it lost.>
97
-
98
- ## Revisit when
99
-
100
- - <The finding that would reopen the decision.>
101
-
102
- ## Measurements
103
-
104
- <The number the decision rests on.> Measured at <short-sha> on <YYYY-MM-DD>.
105
- ```
@@ -1,8 +0,0 @@
1
- ---
2
- title: Decisions
3
- subtitle: Decision history a project doc points at, never loaded eagerly
4
- ---
5
-
6
- # Decisions
7
-
8
- Decision history a project doc points at, never loaded eagerly