feat: implement web-base CLI, templates, workflows, and skill#2
Merged
Conversation
Adds the monorepo root configs from docs/specs/01-monorepo-structure.md. The bin field on package.json plus the bundled cli/dist build is what makes 'bunx github:daniel-rck/web-base ...' work after install.
Implements the three CLI library modules per docs/specs/02-cli.md: - lib/manifest.ts: loadManifest, resolveTemplate (recursive meta-template expansion with dedupe), templatesDir (built/source fallback + WEB_BASE_TEMPLATES_DIR env override for tests), listTemplates - lib/copy.ts: copyTemplateFiles with skip/force/overwrite/dryRun semantics; diffTemplateFile for the update command - lib/pkg.ts: additive patchPackageJson (never removes keys, only sets when value differs)
Implements the three subcommands per docs/specs/02-cli.md: - commands/init.ts: prompts for an app name, writes the per-app package.json template from docs/specs/07-conventions.md, then applies the 'core' meta-template; aborts if package.json already exists unless --force is passed - commands/add.ts: applies a template (or expands a meta) via resolveTemplate; lists available templates when called without an arg, marking metas with [meta] - commands/update.ts: diffs local files against the template source and reports missing/identical/differs; --apply overwrites local from template (does not patch package.json) - index.ts: registers the three subcommands on a citty defineCommand
Three leaf templates per docs/specs/03-templates.md: - hygiene: LICENSE (MIT), CONTRIBUTING.md, SECURITY.md, .editorconfig - biome: per-app biome.json (slightly less strict than web-base's own: warns on noConsoleLog + noExplicitAny) plus lint/format scripts - router: createBrowserRouter scaffold + ROUTES const for typed paths
Three more leaves per docs/specs/03-templates.md:
- storage: idb factory with AppSchema interface placeholder +
BroadcastChannel-driven useLiveQuery hook returning {data, loading,
error}; mutation helpers emit on db:<store> + db:* channels
- pwa: injectManifest sw.ts skeleton (precache + skipWaiting +
clientsClaim + message handler) plus a vite.snippet.md to merge into
vite.config.ts and a separate tsconfig.sw.json for WebWorker lib
- worker: 30-line Cloudflare Worker with /healthz, /api/* stub, static-
asset fallthrough via env.ASSETS.fetch, wrangler.toml with R2/KV
binding placeholders
The shared UI structure per docs/specs/04-layout-system.md: - AppShell: top-level wrapper, sticky h-14 header, sidebar on >=md, bottom-nav on <md - AppHeader: container max-w-4xl, backdrop-blur, optional logo + actions - AppNav: sidebar and bottom variants, NavLink-based, active state via bg-accent-100 / text-accent-600 - PageHeader: section header, optional subtitle + actions - primitives.tsx: Card, EmptyState, Spinner, Badge (5 variants), Button (4 variants x 3 sizes), all forwarding refs and merging className - theme.css: OKLCH tokens derived from --accent-h (per-app: only this changes), auto dark mode via prefers-color-scheme - index.ts: barrel re-exports
- core: meta-template extending hygiene, biome, router, storage, pwa,
worker, layout in that order (layout last because it imports from
storage and router)
- sync: extra (not in core) per docs/specs/03-templates.md. Ships the
E2E-encrypted Hausverwaltung-style sync:
- client.ts: SyncClient with enable/push/pull, persists deviceSecret
+ etag in localStorage, ETag-based optimistic concurrency
- crypto.ts: HKDF-SHA256 key derivation from device secret, AES-GCM-
256 encrypt/decrypt, Crockford-base32 objectId
- types.ts: SyncEnvelope, PairingSlot, SyncClientState shapes
- worker-sync.ts: R2 GET/PUT handlers with If-Match/If-None-Match,
KV-backed rate limits (60 ops/min, 5 pair/min, 10 claim/15min)
- sync.md: architecture summary copied into docs/sync.md
Both per docs/specs/06-workflows.md. - web-app-ci.yml: reusable workflow (workflow_call) consumed by every app via uses: daniel-rck/web-base/.github/workflows/web-app-ci.yml@main. Inputs: bun-version (default 1.3.11), run-tests (default true), run-build (default true). Steps: setup-bun, install --frozen-lockfile, lint, typecheck, test, build. - tools-ci.yml: CI for this repo. Runs the same lint/typecheck/test/ build plus a CLI --help smoke, an 'add hygiene' integration test in /tmp/scratch, and a skill/template alignment check that fails if any cli/templates/<name>/ (except core) lacks a matching skill/references/<name>.md (or <name>-system.md).
Per docs/specs/05-skill.md. SKILL.md trigger fires on Hausverwaltung/Tennisturnier/ErinnerMich work and on '@daniel-rck/web-base' mentions. Body covers the apps in scope, baseline stack, CLI commands, six architecture invariants, a reference mapping table, and the anti-patterns list. References under skill/references/ are aligned 1:1 with the CLI templates (the tools-ci.yml alignment check enforces this), plus two cross-cutting references (tech-stack, ci): - biome.md, hygiene.md, layout-system.md, pwa.md, router.md, storage.md, sync.md, worker.md: one per template - tech-stack.md: dependency pins, per-app package.json/biome/tsconfig templates, vite.config.ts skeleton - ci.md: caller pattern and inputs for the reusable workflow Note: the spec's 05-skill.md original list (tech-stack, layout-system, ci, repo-hygiene) didn't cover the per-template alignment requirement in tools-ci.yml. The references now match template names so CI passes; hygiene.md absorbs what repo-hygiene.md would have held.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The repo's specs in
docs/specs/were fully written but nothing was implemented. This PR makesbunx github:daniel-rck/web-base ...actually work as the README advertises.cli/) — citty entry + three commands (init,add,update) + three lib modules (manifest,copy,pkg), bundled viabun buildintocli/dist/index.js. Apreparescript triggers the build onbun installsobunx-from-GitHub works without a separate build step.cli/templates/) — all 9:hygiene,biome,router,storage,pwa,worker,layout,core(meta),sync(extra)..github/workflows/) — reusableweb-app-ci.ymlfor apps, plustools-ci.ymlfor this repo (includes the CLI smoke test and skill/template alignment check).skill/) —SKILL.mdplus 10 references (8 per-template +tech-stack.md+ci.md).resolveTemplate,copyTemplateFiles, andpatchPackageJsonsemantics.One spec conflict resolved in this PR:
05-skill.mdoriginally listed reference filenames liketech-stack.mdandrepo-hygiene.md, but the alignment check in06-workflows.md'stools-ci.ymlrequiresskill/references/<template-name>.mdfor every template. The references now match template names 1:1 (so CI passes); the original cross-cutting referencestech-stack.mdandci.mdare kept in addition.Verified locally
bun run typecheck,bun run lint,bun run test(16 passed),bun run build— all green.node cli/dist/index.js --helpandadd(no args) list all 9 templates withcoremarked[meta].add hygienein a scratch dir produces the four expected files.add corein a scratch dir produces 24 files across the 7 leaf templates and patchespackage.json.init --name myappwrites a fresh per-apppackage.jsonand appliescore.add syncadds the four sync files plusdocs/sync.md.git clone(nocli/dist/),bun installtriggersprepare→ build → CLI runs.Test plan
bunx github:daniel-rck/web-base initin an empty directorybunx github:daniel-rck/web-base add hygienein an existing appdaniel-rck/web-base/.github/workflows/web-app-ci.yml@mainGenerated by Claude Code