Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ jobs:
cache: npm
- run: npm ci
- run: npm run check
- run: npm run copyrules
- run: npm run build
# Internal links only (external URLs skipped to avoid flaky runs).
# favicon.svg is skipped: Starlight's default /favicon.svg is missing
# (no public/ dir) -- TODO add a favicon and drop this skip.
- run: npm run linkcheck
66 changes: 51 additions & 15 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,61 @@
# CLAUDE.md — MIST.cash Docs

Astro Starlight site for MIST.cash, restyled to the landing design
(`landing/DESIGN.md` is the source of truth). Content describes the EVM
protocol: the gnark Groth16 circuit, the Solidity contracts and
`@mistcash/sdk`. `spec/` in the root repo is the document of record: a spec
claim beats marketing copy.

## Commands

- `npm run dev` — Start local dev server with HMR
- `npm run build` — Build static site to `dist/`
- `npm run preview` — Preview the production build locally
- `npm run dev` — local dev server with HMR
- `npm run check` — `astro check`
- `npm run copyrules` — holds every page to the MIST copy rules (prose only)
- `npm run build` — static site to `dist/`
- `npm run linkcheck` — internal link check, after a build
- `npm run preview` — preview the production build

CI runs check, copyrules, build and linkcheck. All four must be green.

## Directory Layout
## Directory layout

```
├── astro.config.mjs # Astro + Starlight configuration
├── astro.config.mjs # Starlight config: sidebar, component overrides, code themes
├── scripts/copy-rules.mjs # copy-rules check for src/content/docs
├── public/ # self-hosted fonts (Josefin Sans, Sen) and favicons
├── src/
│ ├── content.config.ts # Content collection schema
│ ├── content/docs/ # Markdown/MDX documentation pages
│ │ ├── index.mdx
│ │ ├── getting-started.mdx
│ │ ├── guides/ # Deposit, withdraw, ZK proofs, Merkle trees
│ │ ├── packages/ # SDK, config, React packages
│ │ └── reference/ # API, types, contract ABI
│ ├── assets/ # wordmark used by the header
│ ├── components/ # SiteTitle, Hero, Footer overrides; RuledIndex, RecordStrip, Icon
│ │ └── diagrams/ # Figure, Cell, Chip, Reserve, NoteLife, Architecture
│ ├── content/docs/
│ │ ├── index.mdx # Introduction (splash)
│ │ ├── how-it-works.mdx
│ │ ├── architecture.mdx
│ │ ├── circuits/ # index.mdx, then detailed pages
│ │ ├── contracts/ # index.mdx, then detailed pages
│ │ └── sdk/ # index.mdx, then detailed pages
│ └── styles/
│ └── custom.css # Custom Starlight theme overrides
├── tsconfig.json
└── package.json
│ ├── tokens.css # brand tokens and the Starlight variable mapping
│ ├── theme.css # Starlight components restyled
│ ├── diagram.css # the diagram grammar
│ └── code-themes.mjs # syntax themes from the brand palette
```

## Adding a page

Drop an `.mdx` file under `src/content/docs/circuits/`, `contracts/` or `sdk/`.
The sidebar is autogenerated per directory; order with
`sidebar: { order: N }` in frontmatter (each section's `index.mdx` is order 0
and labelled "<Section> overview"). Link the new page from its section's index.

## Design rules that bind this repo

- Three colours only: midnight, azure, coral, plus tints of them. No green or
red for status: say what happened in words.
- Square corners (2px on controls), 1px rules, no shadow, no blur, no gradient.
- Coral is the one action and at most one marker per view. Never a coral word.
- Josefin Sans for headings, Sen for text, system monospace for code.
- Diagrams use the grammar in `src/styles/diagram.css` and the components in
`src/components/diagrams/`, and must read in both themes at 390px.
- Run `npm run copyrules` before pushing: no em-dashes, no `token`, no chain
names, no hype, no "test".
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Astro + Starlight documentation site.
npm ci
npm run dev # local dev server
npm run check # astro check
npm run copyrules # copy rules on every page
npm run build # static build to dist/
npm run linkcheck # internal link check (after build)
```
Expand Down
89 changes: 62 additions & 27 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,56 +1,91 @@
// @ts-check
import { defineConfig } from "astro/config";
import starlight from "@astrojs/starlight";
import { mistFog, mistMidnight } from "./src/styles/code-themes.mjs";

// https://astro.build/config
export default defineConfig({
site: "https://docs.mist.cash",
integrations: [
starlight({
title: "MIST.cash SDK",
title: "MIST.cash Docs",
description:
"Privacy-focused SDK for zero-knowledge transactions on Starknet",
"Documentation for MIST.cash, a protocol for private stablecoin payments on EVM chains with compliance set per Reserve: the circuit, the contracts and the TypeScript SDK.",
favicon: "/favicon.ico",
social: [
{
icon: "github",
label: "GitHub",
href: "https://github.com/mistcash/sdk",
href: "https://github.com/mistcash",
},
],
customCss: ["./src/styles/custom.css"],
sidebar: [
customCss: [
"./src/styles/tokens.css",
"./src/styles/theme.css",
"./src/styles/diagram.css",
],
components: {
SiteTitle: "./src/components/SiteTitle.astro",
Hero: "./src/components/Hero.astro",
Footer: "./src/components/Footer.astro",
},
expressiveCode: {
themes: [mistMidnight, mistFog],
styleOverrides: {
borderColor: "var(--mist-line-strong)",
borderRadius: "0",
codeFontSize: "0.8125rem",
codeLineHeight: "1.6",
frames: {
frameBoxShadowCssValue: "none",
},
},
},
head: [
{
label: "Start Here",
items: [
{ label: "Introduction", slug: "" },
{ label: "Getting Started", slug: "getting-started" },
],
tag: "link",
attrs: {
rel: "preload",
href: "/fonts/Sen-Variable-latin.woff2",
as: "font",
type: "font/woff2",
crossorigin: "",
},
},
{
label: "Packages",
items: [
{ label: "@mistcash/sdk", slug: "packages/core" },
{ label: "@mistcash/config", slug: "packages/config" },
{ label: "@mistcash/react", slug: "packages/react" },
],
tag: "link",
attrs: {
rel: "preload",
href: "/fonts/JosefinSans-Variable-latin.woff2",
as: "font",
type: "font/woff2",
crossorigin: "",
},
},
{
label: "Guides",
items: [
{ label: "Depositing Tokens", slug: "guides/deposit" },
{ label: "Withdrawing Tokens", slug: "guides/withdraw" },
{ label: "Zero-Knowledge Proofs", slug: "guides/zero-knowledge" },
{ label: "Merkle Trees", slug: "guides/merkle-trees" },
],
tag: "link",
attrs: { rel: "apple-touch-icon", href: "/apple-touch-icon.png" },
},
{
label: "Reference",
tag: "meta",
attrs: { name: "theme-color", content: "#010511" },
},
],
sidebar: [
{
label: "Overview",
items: [
{ label: "API Reference", slug: "reference/api" },
{ label: "Types", slug: "reference/types" },
{ label: "Contract ABI", slug: "reference/contract" },
{ label: "Introduction", slug: "" },
{ label: "How MIST works", slug: "how-it-works" },
{ label: "Architecture", slug: "architecture" },
],
},
// Each section below is autogenerated from its directory, so a page
// added under src/content/docs/<section>/ appears without touching
// this file. Order pages with `sidebar: { order: N }` in frontmatter.
{ label: "Circuits", autogenerate: { directory: "circuits" } },
{ label: "Contracts", autogenerate: { directory: "contracts" } },
{ label: "SDK", autogenerate: { directory: "sdk" } },
],
}),
],
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"preview": "astro preview",
"astro": "astro",
"check": "astro check",
"linkcheck": "linkinator dist --recurse --silent --skip \"^https?://(?!localhost|127\\.0\\.0\\.1)\" --skip \"favicon\\.svg$\""
"copyrules": "node scripts/copy-rules.mjs",
"linkcheck": "linkinator dist --recurse --silent --skip \"^https?://(?!localhost|127\\.0\\.0\\.1)\""
},
"dependencies": {
"@astrojs/starlight": "^0.34.0",
Expand Down
Binary file added public/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/favicon.ico
Binary file not shown.
Binary file added public/fonts/JosefinSans-Variable-latin.woff2
Binary file not shown.
Binary file added public/fonts/Sen-Variable-latin.woff2
Binary file not shown.
86 changes: 86 additions & 0 deletions scripts/copy-rules.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Holds every docs page to the MIST copy rules (landing/PRODUCT.md, "Copy
// rules"; the same patterns as landing/src/lib/copy-rules.ts). Prose only:
// fenced code, inline code and import lines are skipped, so a code sample may
// say `token` or `test` where the API does. Run: npm run copyrules
import { readdirSync, readFileSync, statSync } from "node:fs";
import { join } from "node:path";

export const RULES = [
{ id: "test", pattern: /\btest(s|ing)?\b/i, why: "never say test" },
{ id: "mainnet", pattern: /\b(testnets?|mainnets?)\b/i, why: "no network status words" },
{ id: "token", pattern: /\btokens?\b/i, why: "say stablecoins or assets" },
{
id: "chain-name",
pattern: /\b(ethereum|arbitrum|sepolia|starknet|optimism|polygon|solana|avalanche)\b/i,
why: "no chain or network names for our deployment",
},
{ id: "em-dash", pattern: /—/, why: "no em-dashes: use a full stop or a comma" },
{ id: "arrow-glyph", pattern: /[←-↓↗↘]/, why: "arrows are drawn icons, never glyphs" },
{
id: "privacy-hype",
pattern: /\b(mixers?|untraceable|anonymous|anonymity|shielded|quantum[- ]proof|quantum[- ]safe)\b/i,
why: "banned privacy wording",
},
{
id: "hype",
pattern:
/\b(seamless(ly)?|unlock(s|ed|ing)?|empower(s|ed|ing)?|revolutionary|next[- ]gen|supercharge[sd]?|world[- ]class)\b/i,
why: "no hype words",
},
{ id: "emoji", pattern: /\p{Extended_Pictographic}/u, why: "no emoji" },
];

/** Blank out fenced code, inline code and import lines, keeping line numbers. */
export function prose(source) {
let inFence = false;
return source
.split("\n")
.map((line) => {
if (/^\s*(```|~~~)/.test(line)) {
inFence = !inFence;
return "";
}
if (inFence || /^import\s/.test(line)) return "";
return line.replace(/`[^`]*`/g, "");
})
.join("\n");
}

export function findViolations(source) {
const found = [];
prose(source)
.split("\n")
.forEach((text, i) => {
for (const rule of RULES) {
if (rule.pattern.test(text)) found.push({ rule: rule.id, why: rule.why, line: i + 1, text: text.trim() });
}
});
return found;
}

function* walk(dir) {
for (const name of readdirSync(dir)) {
const path = join(dir, name);
if (statSync(path).isDirectory()) yield* walk(path);
else if (/\.mdx?$/.test(name)) yield path;
}
}

if (import.meta.url === `file://${process.argv[1]}`) {
const root = process.argv[2] ?? "src/content/docs";
let files = 0;
let bad = 0;
for (const file of walk(root)) {
files++;
for (const v of findViolations(readFileSync(file, "utf8"))) {
bad++;
console.error(`${file}:${v.line} [${v.rule}] ${v.why}: ${v.text}`);
}
}
if (files === 0) {
console.error(`copy rules: no pages found under ${root}`);
process.exit(1);
}
console.log(`copy rules: ${files} pages, ${bad} violations`);
process.exit(bad === 0 ? 0 : 1);
}
Loading
Loading