Skip to content

patterns: vendor session-explainer for offline init - #13

Merged
utsengar merged 2 commits into
mainfrom
session-explainer-pattern
Aug 23, 2026
Merged

patterns: vendor session-explainer for offline init#13
utsengar merged 2 commits into
mainfrom
session-explainer-pattern

Conversation

@utsengar

Copy link
Copy Markdown
Owner

Companion to utsengar/htmlbin#41, which adds a fourth official pattern — session-explainer, for publishing an agent session as a narrative (problem, approach, dead ends, what shipped) rather than dumping a transcript.

What changed

  • patterns/session-explainer.md — vendored so htmlbin patterns init works offline. src/patterns/bundled-data.ts is generated from patterns/*.md by scripts/build-bundled-patterns.mjs on prebuild/pretypecheck/pretest and is gitignored, so vendoring the markdown is the whole change — no generated file in the diff.
  • skills/htmlbin-publish/SKILL.md — this skill names the bundled set explicitly (summary-roundup, pr-explainer, plan-spec-explainer) and would have gone stale. Now lists all four.

Verification

  • Byte-identical to the Worker repo's copy — SHA-256 ad4b0636…
  • npm test162 passed, 6 skipped, including the 14 patterns e2e checks
  • patterns init verified end-to-end on both paths, each producing the same hash as source:
    • live catalog (--catalog pointed at a local Worker) → installs all 4
    • offline bundled fallback (unreachable catalog) → installs all 4

Note (pre-existing, not from this PR)

npm run typecheck reports 4 errors in test/e2e/helpers.ts (execa option types). Confirmed identical on main — left alone.

🤖 Generated with Claude Code

Mirrors the new official pattern from the Worker repo so `htmlbin patterns
init` installs it when the catalog is unreachable. src/patterns/bundled-data.ts
is generated from patterns/*.md by scripts/build-bundled-patterns.mjs on
prebuild/pretypecheck/pretest and is gitignored, so vendoring the markdown
is the whole change.

Also updates the htmlbin-publish skill, which names the bundled set
explicitly and would otherwise go stale.

Verified: file is byte-identical to the Worker repo's copy (SHA-256
ad4b0636…), and `patterns init` installs it correctly from both the live
catalog and the offline bundled fallback, producing the same hash in all
three places. Full suite green (162 passed, 6 skipped).

Companion Worker PR: utsengar/htmlbin#41

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
session-explainer is prescriptive: it mandates one structure and ships a
reference skeleton rather than describing a layout in prose. The bundle
globbed patterns/*.md only, so an offline `patterns init` installed the
pattern without the structure it points at.

The skeleton now travels with the pattern on every path.

- scripts/build-bundled-patterns.mjs picks up a <name>.template.html
  sibling and emits it as `template: { filename, body }`.
- init writes it from the bundle offline, and fetches it from the catalog
  online. The pattern's own front matter decides whether to look, so the
  three patterns without a skeleton cost no extra request.
- `patterns add <name>` gets it too, but only for catalog sources — a
  file/gist/github source has nowhere well-defined to look, and guessing
  would mean a speculative fetch.
- schema.ts learns two optional keys: `brand_scope` ("all" |
  "colors-only") and `template`.

Two things worth calling out.

The skeleton is nested on its pattern's InstallResult rather than pushed
into `installed` as a sibling. First pass pushed it, which broke an
existing assertion (`installed` had an entry whose name already carried
an extension) and, worse, made installed.length stop meaning "patterns
installed". Nesting keeps that invariant and matches what `add` returns.

The destination filename is derived from the validated pattern name, never
from the catalog. A catalog entry is remote input, and `template:
../../../etc/passwd` would otherwise be a write outside the patterns dir.
schema.ts pins the value to `<name>.template.html` and there are tests for
the traversal cases.

Verified: 171 tests pass (was 162). init installs the skeleton from both
the live catalog and the bundled fallback, byte-identical to the worker's
copy by SHA-256, idempotent on a second run, and `patterns list` still
reports 4 patterns rather than counting the skeleton as a fifth.

Companion worker PR: utsengar/htmlbin#41

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@utsengar
utsengar merged commit 2c5f2e7 into main Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant