microsite-cli
CLI tool for initializing, updating, and validating raycool.dev microsites.
Overview
microsite-cli scaffolds and maintains microsites for the raycool.dev card-stream ecosystem, keeping the evergreen contract intact and enabling optional database syncs.
public/site and dev/site, manage cards in
index.json, sync HTML resources, validate/fix contract issues, and launch the Setup Wizard UI.
Installation
pip install -e .
Quickstart
microsite init /path/to/repo # scaffold dev/public, templates, index.json
microsite add /path/to/repo --title "Release" # add a new card + details markdown
microsite update /path/to/repo # rescan public site HTML resources
microsite update /path/to/repo --dev # rescan dev site HTML resources
microsite validate /path/to/repo # validate the contract and filesystem
microsite fix /path/to/repo # auto-fix common validation issues
microsite sync-db /path/to/repo --db-url ... # push cards to PostgreSQL
microsite maturity /path/to/repo +1 # upshift maturity tier
microsite ui --port 8000 # launch the Setup Wizard UI (Ctrl+C to stop)
microsite version # print tool version
--json for structured output.
Command Reference
Details for every CLI entry point, in the same order as the README.
microsite init
Ensures dev/site and public/site (optional) exist, writes the bundled
index.html/details.md templates, and seeds index.json.
- Registers the repository in the cards database using the slug or
--repo-id. - Flags:
--slug,--name,--repo-id,--db-url,--no-public.
microsite add
Adds a new card to index.json and creates its details markdown using the bundled template.
- Infers slug/repo name from the folder; auto-increments the sequence for matching slug/level/date.
- Flags:
--title(required),--level,--purpose,--summary,--date,--source-type,--source-label,--source-url,--source-ref,--dry-run.
microsite update
Rescans the site directory for .html files, sets micro_site_home to
index.html, and refreshes paths.resources for every card.
- Use
--devto operate on thedev/sitelayer (defaults topublic). - Warns when
index.htmlis missing, when card details files are absent, or whendetails_mddoes not match the expected filename.
microsite validate
Validates contract fields and filesystem state.
- Checks required fields/types, normalized slugs, allowed levels, ISO dates, and that
index.jsonis a list. - Enforces
micro_site_home == index.htmlwhen present and requires eitherdetails_mdordetails_html. - Verifies details files exist, match
details/<id>.md, and have no YAML frontmatter or<iframe>/<script>tags. - Ensures referenced local resources exist; exits non-zero when errors are found.
microsite fix
Auto-fixes common validation issues without creating new content.
- Ensures
pathsexists, setsmicro_site_hometoindex.html, and removes references to missingdetails_md/details_html. - Relinks standard detail paths if files already exist (e.g.,
details/<id>.md); respects--dry-runto preview.
microsite maturity
Manages the repository's maturity tier (0-5) and displays the derived Phase.
- Supports absolute tier settings (0-5) or relative shifts (
+N,-N). - Phases: Establish (0-1), Comprehend (2-3), Automate (4-5).
- Flags:
--repo-id,--db-url.
microsite sync-db
Synchronizes index.json to PostgreSQL with psycopg2; uses --db-url
or MICROSITE_DB_URL.
- Upserts a repo record (default
base_url:https://raycool.dev/microsites/<slug>) and all cards, includingpaths,source, andtypewhen set. - Fails fast on missing/invalid
index.jsonor connection info and reports the count of synced cards.
microsite ui
Launches the Setup Wizard UI via a threaded HTTP server; accepts an optional repo path and
--port.
- Inference (
/infer) requires a repo path and Git URL; returns slug, repo name, branch, detected HTML resources, and site structure signals. - Snapshot (
/snapshot) lists cards, details markdown, and HTML resources, highlighting missingindex.json, missing details, orphan details, and missing resource files. - Generate (
/generate) runsinit+updatewith provided metadata, uses Git metadata forsource, and creates placeholder HTML resources when requested. - Provides a Markdown editor for card details and a viewer for HTML resources.
microsite version
Prints the CLI version.
Evergreen Contract
- Required fields:
id,slug,title,summary,date,repo,level,purpose, andpaths. - Card IDs follow
<slug>-<level>-<yyyy-mm-dd>-<seq>(three-digit sequence); details markdown is expected atdetails/<id>.md. paths.micro_site_homemust beindex.htmlwhen it exists; other HTML underpublic/sitebelong inpaths.resources.- Details markdown must avoid duplicated metadata/frontmatter and unsafe HTML tags (
iframe,script); referenced local resources must exist.
Project Layout
microsite-cli/
microsite/
cli.py
ui_server.py
VERSION
db.py
core/
add.py
fix.py
init.py
maturity.py
schema.py
sync.py
update.py
utils.py
validate.py
templates/
index.html
details.md
AGENTS.md
DEVELOPERS.md
OPERATIONAL.md
DEV_README.md
ui_assets/
tests/
pyproject.toml
requirements.txt