This repository contains the standalone HagiCode documentation site built with Astro and Starlight.
The docs site is where users learn the platform: product overviews, installation guides, tutorials, blog posts, and downloadable configuration presets all live here.
Hagilight Starlight generates localized feeds from documentation content using its default configuration. Starlight Blog generates its standard /blog/rss.xml feed; the site does not define custom RSS item selection or language-specific blog feed routes.
- Product introductions and onboarding guides for new users
- Step-by-step installation and configuration documentation
- Blog content and updates for the HagiCode ecosystem
- Preset files and static assets referenced by public docs pages
src/content/docs/- baseline Chinese docs and shared docs assetssrc/content/translations/docs/<locale>/- non-baseline localized authoring files using canonical source locale codessrc/content/.generated/docs/- build-time assembled Starlight input tree generated bynpm run prepare:docs-contentsrc/data/articles.snapshot/<locale>/- structured*-vs-hagicodearticle snapshot files mirrored from the publishedrepos/indexarticle manifestssrc/components/andsrc/layouts/- site UI building blockspublic/- static assets, downloadable presets, and shared mediascripts/andtests/- verification helpers for docs quality and routing behavior
npm install
npm run dev
npm run build
npm run previewThe local docs server runs on http://localhost:31265 by default.
npm run sync:articles-snapshot refreshes the locale-folder structured article snapshot consumed by the *-vs-hagicode FAQ routes.
By default it fetches the published dataset from https://index.hagicode.com so repos/docs does not depend on a sibling repos/index checkout.
The preferred verification path is:
cd repos/docs && npm run sync:articles-snapshotUse DOCS_ARTICLES_PUBLISHED_ROOT=/absolute/or/relative/path/to/dist or npm run sync:articles-snapshot -- --published-root <path> only when you intentionally want to test against a specific local published build.
npm run sync:articles-snapshot -- --no-remote still reuses the committed snapshot when you explicitly need offline or pinned local verification.
npm run prepare:docs-runtime now syncs the article snapshot before npm run prepare:docs-content, and prepare:docs-content synthesizes the faq/*-vs-hagicode.mdx pages directly into src/content/.generated/docs/ instead of keeping those shell pages under source authoring trees.
.github/workflows/docs-ci.ymlvalidates pushes and pull requests targetingmain..github/workflows/docs-deploy-gh-pages.ymlpublishes a validatedgh-pagespayload for pushes tomainandworkflow_dispatch.- The
gh-pagespayload contract is branch-rootesa.jsonc,wrangler.jsonc, anddist/containing the validated Astro snapshot assembled afternpm run build:cisucceeds. - The build job stays read-only and uploads the validated payload artifact;
gh-pagesremains authoritative and only the deploy job receivescontents: write. - Manual
workflow_dispatchruns rebuild from the selected ref, validate withnpm run build:ci, and republish the resulting payload togh-pages. - Direct Cloudflare publication is handled outside this workflow; keep
gh-pages/wrangler.jsoncas the versioned Wrangler contract used by direct publish operations. - Existing workflows remain in place:
.github/workflows/docs-ci.yml,.github/workflows/azure-static-web-apps-agreeable-stone-04924c800.yml,.github/workflows/compress-images.yml, and.github/workflows/indexnow.ymlare additive peers, not replaced by the new workflow. - Treat host cutover as a separate operational step: adding the workflow does not prove
docs.hagicode.comalready readsgh-pages/esa.jsonc, the Wrangler contract ingh-pages/wrangler.jsonc, andgh-pages/dist/. - Follow-up checks before treating
docs.hagicode.comas agh-pagesconsumer: confirm the workflow publishedesa.jsonc,wrangler.jsonc, anddist/, verify the hosting target still points atgh-pages, and then loadhttps://docs.hagicode.comfrom the deployed branch snapshot. - This change migrates only
repos/docs;repos/awesome-design-md-site,repos/cost,repos/index,repos/soul,repos/trait, andrepos/docker-compose-builder-webremain unchanged follow-up migration candidates. .github/workflows/compress-images.ymland.github/workflows/indexnow.ymlhandle repository maintenance automation.
Docs UI strings are maintained with @hagicode/hagi18n from this repository. The source of truth is the YAML tree under src/i18n/locales/<locale>/; generated runtime resources are committed under src/i18n/generated/ because astro.config.mjs imports them during config evaluation.
Use these commands from repos/docs:
npm run i18n:audit
npm run i18n:doctor
npm run i18n:generate
npm run i18n:checknpm install installs the project-local hagi18n CLI. To verify CLI availability directly, run npx hagi18n info or any script above.
Edit YAML files in src/i18n/locales/en-US/ and src/i18n/locales/zh-CN/. Keep namespace files, scalar key paths, and {{placeholder}} tokens aligned between locales. Run npm run i18n:audit or npm run i18n:doctor, then run npm run i18n:generate to refresh src/i18n/generated/docs-locale-resources.mjs.
npm run i18n:check combines hagi18n validation with a stale generated-resource check. npm run dev, npm run build, and npm run typecheck run prepare:docs-runtime first so both generated locale resources and the assembled docs content tree exist before Astro or TypeScript consumes them.
Sync and prune default to dry-run previews:
npm run i18n:sync
npm run i18n:pruneOnly the explicit write variants mutate locale source files:
npm run i18n:sync:write
npm run i18n:prune:writehagi18n manages docs UI strings, blog plugin UI labels, Starlight locale metadata, and common selector labels. MDX documentation pages and blog posts now use a split authoring contract:
- Baseline Chinese content lives under
src/content/docs/. - Non-baseline localized authoring files live under
src/content/translations/docs/<source-locale>/. - Astro/Starlight reads the generated build input under
src/content/.generated/docs/, produced bynpm run prepare:docs-content.
When adding or updating localized docs, keep the canonical doc key identical to the baseline file path and use canonical locale directory names such as en-US, ja-JP, or zh-Hant.
Hagilight 0.4.0 owns the Starlight header, footer, language chooser, reading-width control, AI disclosures, article promotion, and 404 recovery. Docs maps its generated locale routes and labels onto Hagilight's locale catalog by lang, preserving the root Chinese route and /en-US/ path. Docs also keeps the localized promotion fallback and PageFrame composition, site metadata and analytics, AI frontmatter defaults, and blog-specific metadata, ads, CTA, and image lightbox.
Documentation pages show Hagilight's article promotion by default. Set hagicodePromotion: false in frontmatter to opt out. Blog posts opt out by default to avoid competing with blog promotions; set hagicodePromotion: true to enable the article promotion on an individual post. Existing isAITranslation, isAIAuthor, hideAd, and hideCta frontmatter controls remain supported.
After building, npm run verify:hagilight-build checks localized navigation, preference migration, shared shell composition, blog and release-note content, 404 recovery, and standalone redirects.
Use these commands to see which docs pages, blog posts, or locales are still untranslated:
npm run report:translation
npm run report:docs-translation
npm run report:blog-translationnpm run report:translation writes a combined summary to .tmp/translation-report.json and refreshes the per-surface JSON reports in .tmp/docs-translation-report.json and .tmp/blog-translation-report.json. The combined output shows per-locale coverage for baseline Chinese docs pages and blog slugs, plus missing, duplicate, and high-similarity findings.
To fill missing translations directly from the zh-CN source content with the local Pi CLI, run:
npm run translate:missing:piDefault behavior only creates files for entries that are still missing in the translation reports. To also rewrite files that are flagged as exact duplicates of the zh-CN baseline, run:
npm run translate:missing:pi -- --include-duplicatesUseful filters:
npm run translate:missing:pi -- --surface blog --locales en-US,ja-JP --limit 5 --dry-runThis workflow calls local pi CLI and asks it to translate Markdown/MDX directly from repository source files. It does not use separate machine-translation API. Default model is gh/gpt-codex-5.3 (override with --model or PI_MODEL). Script writes docs translations to src/content/translations/docs/<locale>/...; blog translations currently follow blog report layout under src/content/docs/<locale>/blog/....
The managed screenshot sync flow reads repos/docs/.env before it launches ImgBin.
The repository default for image analysis is:
IMGBIN_ANALYSIS_PROVIDER=codexIMGBIN_CODEX_MODEL=lemon/gpt-5.4IMGBIN_CODEX_BASE_URL=http://localhost:36129/v1
Copy ./.env.example to .env when you need a local config file for npm run screenshots:sync.
Desktop download data is fetched at runtime from the canonical index endpoint published by repos/index.
When runtime loading reaches terminal failure, docs falls back to the Index Desktop history page at https://index.hagicode.com/desktop/history/.
repos/index remains a referenced dependency only; the stable fallback surface is https://index.hagicode.com/desktop/history/ plus https://index.hagicode.com/desktop/index.json.
This repository still serves public/version-index.json as a local snapshot for offline fallback, but maintainers should investigate the runtime fetch chain and the index deployment before changing docs UI behavior.
Repository-scoped update detail pages are no longer hosted in this docs site. A future change will introduce the replacement version update information surface.
The replacement release-notes surface now lives in this repository under src/content/docs/release-notes/, src/content/translations/docs/en-US/release-notes/, and the managed src/data/release-notes/ directory.
Managed outputs are generated from the authoritative repos/release-notes workspace data.
For monorepo automation, the preferred path is direct repository-to-repository transfer. GitHub Release assets remain only as an optional fallback source for standalone sync jobs. hagirepocron is expected to reach this repo only after release-notes has produced a complete bilingual published dataset for each tag.
npm run release-notes:fetch
npm run release-notes:materialize
npm run release-notes:sync
npm run verify:release-notes:input
npm run verify:release-notes:output
npm run test:release-notes
# Monorepo / cron path: read release-notes directly from a sibling checkout
DOCS_RELEASE_NOTES_SOURCE=local \
DOCS_RELEASE_NOTES_LOCAL_REPO_ROOT=../release-notes \
npm run release-notes:syncDOCS_RELEASE_NOTES_SOURCE=local- Reads
artifacts/tags/<tag>/<tag>.jsonandpublished/<tag>.<locale>.mddirectly fromDOCS_RELEASE_NOTES_LOCAL_REPO_ROOT. - This is the intended mode for
hagirepocronand other same-machine orchestration.
- Reads
DOCS_RELEASE_NOTES_SOURCE=github- Fetches GitHub Releases plus
release-notes-<tag>-history.zipassets fromDOCS_RELEASE_NOTES_REPOSITORY. - Use this only when docs runs without access to a sibling
release-notescheckout.
- Fetches GitHub Releases plus
DOCS_RELEASE_NOTES_SOURCE=auto- Default mode.
- Uses local mode when
DOCS_RELEASE_NOTES_LOCAL_REPO_ROOTis set; otherwise falls back to GitHub mode.
- Each synchronized tag must provide
artifacts/tags/<tag>/<tag>.json. - Each synchronized tag must also provide
published/<tag>.zh-CN.mdandpublished/<tag>.en.md. - In the monorepo cron path, these published bilingual files are expected to come from the upstream
release-notesAI preparation step before docs sync begins. - Tags with missing JSON, malformed JSON, tag mismatches, or incomplete locale bodies are skipped with deterministic reasons and do not publish partial pages.
- The GitHub fallback workflow only accepts assets named
release-notes-<tag>-history.zip. - Each accepted archive must contain
artifacts/tags/<tag>/<tag>.json. - Each accepted archive must also contain
published/<tag>.zh-CN.mdandpublished/<tag>.en.md.
.github/workflows/release-notes-sync.ymlruns daily and viaworkflow_dispatch.- In the monorepo cron path,
hagirepocronsetsDOCS_RELEASE_NOTES_SOURCE=localand passes the siblingrelease-notescheckout root, so docs no longer depends on published release assets to materialize pages. - Docs-managed output now uses
src/data/release-notes/index.jsonplussrc/data/release-notes/<tag>.json, together withsrc/content/docs/release-notes/index.mdxandsrc/content/translations/docs/en-US/release-notes/index.mdx. - The lightweight index keeps browse metadata only; detailed rendered bodies live in the per-tag JSON files generated inside this repository.
- Incomplete upstream tags must not create partial detail files or extra docs routes.
npm run buildruns release-notes input verification before Astro and output verification after Astro. Empty release-notes pages are valid only whensrc/data/release-notes/index.jsonhas zero entries; if entries exist, missing detail JSON, missing localized body HTML, missing anchors, or empty-state output must fail the build.- The workflow uses
DOCS_RELEASE_NOTES_TOKENfor upstream GitHub API access and falls back to the repositoryGITHUB_TOKENonly when that token already has cross-repository visibility. - In CI,
DOCS_RELEASE_NOTES_ALLOW_STALE_ON_SOURCE_ERROR=truekeeps the job green when the upstream repository is temporarily inaccessible and existing managed outputs are already present. - The sync scripts depend on the standard
zipandunziputilities in addition to Node.js. - If the sync job reports skipped tags in local mode, inspect the source files in
release-notesfirst; in GitHub mode, inspect the published asset contents. - If release discovery returns
404, treat it as an authentication or repository-access problem first and verify thatDOCS_RELEASE_NOTES_TOKENcan readHagiCode-org/release-notes. - For monorepo-local development, prefer
DOCS_RELEASE_NOTES_SOURCE=localplusDOCS_RELEASE_NOTES_LOCAL_REPO_ROOT.
Use this repository when the goal is end-user education and public documentation. Product storytelling lives in repos/site, while application behavior lives in repos/web, repos/hagicode-desktop, and repos/hagicode-core.