From 2ee2f8f1d293b3f4c3d65701385bac8d1deae536 Mon Sep 17 00:00:00 2001 From: konojunya Date: Sun, 6 Sep 2026 02:10:06 +0900 Subject: [PATCH] Generate multilingual site content from canonical documentation sources --- README.md | 21 +- content/agent-prompt.txt | 1 + content/site/examples/index.md | 7 + content/site/guide/coding-agents.md | 27 ++ content/site/guide/getting-started.md | 86 +++++++ content/site/guide/playground.md | 42 +++ content/site/guide/provider-icons.md | 118 +++++++++ content/site/guide/what-is-stack.md | 51 ++++ content/site/index.md | 27 ++ content/site/ja/examples/index.md | 7 + content/site/ja/guide/coding-agents.md | 27 ++ content/site/ja/guide/getting-started.md | 86 +++++++ content/site/ja/guide/playground.md | 42 +++ content/site/ja/guide/provider-icons.md | 118 +++++++++ content/site/ja/guide/what-is-stack.md | 51 ++++ content/site/ja/index.md | 27 ++ content/site/ja/language/edges-and-layout.md | 78 ++++++ content/site/ja/language/formatting.md | 58 +++++ content/site/ja/language/nodes-and-groups.md | 67 +++++ content/site/ja/language/syntax.md | 95 +++++++ content/site/ja/language/themes-and-icons.md | 126 +++++++++ .../ja/reference/diagnostics-and-limits.md | 58 +++++ .../ja/reference/versioning-and-safety.md | 40 +++ content/site/ko/examples/index.md | 7 + content/site/ko/guide/coding-agents.md | 27 ++ content/site/ko/guide/getting-started.md | 86 +++++++ content/site/ko/guide/playground.md | 42 +++ content/site/ko/guide/provider-icons.md | 118 +++++++++ content/site/ko/guide/what-is-stack.md | 51 ++++ content/site/ko/index.md | 27 ++ content/site/ko/language/edges-and-layout.md | 78 ++++++ content/site/ko/language/formatting.md | 58 +++++ content/site/ko/language/nodes-and-groups.md | 67 +++++ content/site/ko/language/syntax.md | 95 +++++++ content/site/ko/language/themes-and-icons.md | 126 +++++++++ .../ko/reference/diagnostics-and-limits.md | 58 +++++ .../ko/reference/versioning-and-safety.md | 40 +++ content/site/language/edges-and-layout.md | 78 ++++++ content/site/language/formatting.md | 58 +++++ content/site/language/nodes-and-groups.md | 67 +++++ content/site/language/syntax.md | 95 +++++++ content/site/language/themes-and-icons.md | 126 +++++++++ .../site/reference/diagnostics-and-limits.md | 58 +++++ .../site/reference/versioning-and-safety.md | 40 +++ content/site/zh/examples/index.md | 7 + content/site/zh/guide/coding-agents.md | 27 ++ content/site/zh/guide/getting-started.md | 86 +++++++ content/site/zh/guide/playground.md | 42 +++ content/site/zh/guide/provider-icons.md | 118 +++++++++ content/site/zh/guide/what-is-stack.md | 51 ++++ content/site/zh/index.md | 27 ++ content/site/zh/language/edges-and-layout.md | 78 ++++++ content/site/zh/language/formatting.md | 58 +++++ content/site/zh/language/nodes-and-groups.md | 67 +++++ content/site/zh/language/syntax.md | 95 +++++++ content/site/zh/language/themes-and-icons.md | 126 +++++++++ .../zh/reference/diagnostics-and-limits.md | 58 +++++ .../zh/reference/versioning-and-safety.md | 40 +++ generated/manifest.json | 240 ++++++++++++++++++ generated/site/examples/index.md | 7 + generated/site/guide/agent-workflow.md | 42 +++ generated/site/guide/coding-agents.md | 27 ++ generated/site/guide/getting-started.md | 86 +++++++ generated/site/guide/playground.md | 42 +++ generated/site/guide/provider-icons.md | 118 +++++++++ generated/site/guide/what-is-stack.md | 51 ++++ generated/site/index.md | 27 ++ generated/site/ja/examples/index.md | 7 + generated/site/ja/guide/agent-workflow.md | 42 +++ generated/site/ja/guide/coding-agents.md | 27 ++ generated/site/ja/guide/getting-started.md | 86 +++++++ generated/site/ja/guide/playground.md | 42 +++ generated/site/ja/guide/provider-icons.md | 118 +++++++++ generated/site/ja/guide/what-is-stack.md | 51 ++++ generated/site/ja/index.md | 27 ++ .../site/ja/language/edges-and-layout.md | 78 ++++++ generated/site/ja/language/formatting.md | 58 +++++ .../site/ja/language/nodes-and-groups.md | 67 +++++ generated/site/ja/language/syntax.md | 95 +++++++ .../site/ja/language/themes-and-icons.md | 126 +++++++++ .../ja/reference/diagnostics-and-limits.md | 58 +++++ .../ja/reference/versioning-and-safety.md | 40 +++ generated/site/ko/examples/index.md | 7 + generated/site/ko/guide/agent-workflow.md | 42 +++ generated/site/ko/guide/coding-agents.md | 27 ++ generated/site/ko/guide/getting-started.md | 86 +++++++ generated/site/ko/guide/playground.md | 42 +++ generated/site/ko/guide/provider-icons.md | 118 +++++++++ generated/site/ko/guide/what-is-stack.md | 51 ++++ generated/site/ko/index.md | 27 ++ .../site/ko/language/edges-and-layout.md | 78 ++++++ generated/site/ko/language/formatting.md | 58 +++++ .../site/ko/language/nodes-and-groups.md | 67 +++++ generated/site/ko/language/syntax.md | 95 +++++++ .../site/ko/language/themes-and-icons.md | 126 +++++++++ .../ko/reference/diagnostics-and-limits.md | 58 +++++ .../ko/reference/versioning-and-safety.md | 40 +++ generated/site/language/edges-and-layout.md | 78 ++++++ generated/site/language/formatting.md | 58 +++++ generated/site/language/nodes-and-groups.md | 67 +++++ generated/site/language/syntax.md | 95 +++++++ generated/site/language/themes-and-icons.md | 126 +++++++++ .../site/reference/diagnostics-and-limits.md | 58 +++++ .../site/reference/versioning-and-safety.md | 40 +++ generated/site/zh/examples/index.md | 7 + generated/site/zh/guide/agent-workflow.md | 42 +++ generated/site/zh/guide/coding-agents.md | 27 ++ generated/site/zh/guide/getting-started.md | 86 +++++++ generated/site/zh/guide/playground.md | 42 +++ generated/site/zh/guide/provider-icons.md | 118 +++++++++ generated/site/zh/guide/what-is-stack.md | 51 ++++ generated/site/zh/index.md | 27 ++ .../site/zh/language/edges-and-layout.md | 78 ++++++ generated/site/zh/language/formatting.md | 58 +++++ .../site/zh/language/nodes-and-groups.md | 67 +++++ generated/site/zh/language/syntax.md | 95 +++++++ .../site/zh/language/themes-and-icons.md | 126 +++++++++ .../zh/reference/diagnostics-and-limits.md | 58 +++++ .../zh/reference/versioning-and-safety.md | 40 +++ scripts/generate.mjs | 15 ++ scripts/generate.test.mjs | 19 +- 121 files changed, 7498 insertions(+), 6 deletions(-) create mode 100644 content/agent-prompt.txt create mode 100644 content/site/examples/index.md create mode 100644 content/site/guide/coding-agents.md create mode 100644 content/site/guide/getting-started.md create mode 100644 content/site/guide/playground.md create mode 100644 content/site/guide/provider-icons.md create mode 100644 content/site/guide/what-is-stack.md create mode 100644 content/site/index.md create mode 100644 content/site/ja/examples/index.md create mode 100644 content/site/ja/guide/coding-agents.md create mode 100644 content/site/ja/guide/getting-started.md create mode 100644 content/site/ja/guide/playground.md create mode 100644 content/site/ja/guide/provider-icons.md create mode 100644 content/site/ja/guide/what-is-stack.md create mode 100644 content/site/ja/index.md create mode 100644 content/site/ja/language/edges-and-layout.md create mode 100644 content/site/ja/language/formatting.md create mode 100644 content/site/ja/language/nodes-and-groups.md create mode 100644 content/site/ja/language/syntax.md create mode 100644 content/site/ja/language/themes-and-icons.md create mode 100644 content/site/ja/reference/diagnostics-and-limits.md create mode 100644 content/site/ja/reference/versioning-and-safety.md create mode 100644 content/site/ko/examples/index.md create mode 100644 content/site/ko/guide/coding-agents.md create mode 100644 content/site/ko/guide/getting-started.md create mode 100644 content/site/ko/guide/playground.md create mode 100644 content/site/ko/guide/provider-icons.md create mode 100644 content/site/ko/guide/what-is-stack.md create mode 100644 content/site/ko/index.md create mode 100644 content/site/ko/language/edges-and-layout.md create mode 100644 content/site/ko/language/formatting.md create mode 100644 content/site/ko/language/nodes-and-groups.md create mode 100644 content/site/ko/language/syntax.md create mode 100644 content/site/ko/language/themes-and-icons.md create mode 100644 content/site/ko/reference/diagnostics-and-limits.md create mode 100644 content/site/ko/reference/versioning-and-safety.md create mode 100644 content/site/language/edges-and-layout.md create mode 100644 content/site/language/formatting.md create mode 100644 content/site/language/nodes-and-groups.md create mode 100644 content/site/language/syntax.md create mode 100644 content/site/language/themes-and-icons.md create mode 100644 content/site/reference/diagnostics-and-limits.md create mode 100644 content/site/reference/versioning-and-safety.md create mode 100644 content/site/zh/examples/index.md create mode 100644 content/site/zh/guide/coding-agents.md create mode 100644 content/site/zh/guide/getting-started.md create mode 100644 content/site/zh/guide/playground.md create mode 100644 content/site/zh/guide/provider-icons.md create mode 100644 content/site/zh/guide/what-is-stack.md create mode 100644 content/site/zh/index.md create mode 100644 content/site/zh/language/edges-and-layout.md create mode 100644 content/site/zh/language/formatting.md create mode 100644 content/site/zh/language/nodes-and-groups.md create mode 100644 content/site/zh/language/syntax.md create mode 100644 content/site/zh/language/themes-and-icons.md create mode 100644 content/site/zh/reference/diagnostics-and-limits.md create mode 100644 content/site/zh/reference/versioning-and-safety.md create mode 100644 generated/site/examples/index.md create mode 100644 generated/site/guide/agent-workflow.md create mode 100644 generated/site/guide/coding-agents.md create mode 100644 generated/site/guide/getting-started.md create mode 100644 generated/site/guide/playground.md create mode 100644 generated/site/guide/provider-icons.md create mode 100644 generated/site/guide/what-is-stack.md create mode 100644 generated/site/index.md create mode 100644 generated/site/ja/examples/index.md create mode 100644 generated/site/ja/guide/agent-workflow.md create mode 100644 generated/site/ja/guide/coding-agents.md create mode 100644 generated/site/ja/guide/getting-started.md create mode 100644 generated/site/ja/guide/playground.md create mode 100644 generated/site/ja/guide/provider-icons.md create mode 100644 generated/site/ja/guide/what-is-stack.md create mode 100644 generated/site/ja/index.md create mode 100644 generated/site/ja/language/edges-and-layout.md create mode 100644 generated/site/ja/language/formatting.md create mode 100644 generated/site/ja/language/nodes-and-groups.md create mode 100644 generated/site/ja/language/syntax.md create mode 100644 generated/site/ja/language/themes-and-icons.md create mode 100644 generated/site/ja/reference/diagnostics-and-limits.md create mode 100644 generated/site/ja/reference/versioning-and-safety.md create mode 100644 generated/site/ko/examples/index.md create mode 100644 generated/site/ko/guide/agent-workflow.md create mode 100644 generated/site/ko/guide/coding-agents.md create mode 100644 generated/site/ko/guide/getting-started.md create mode 100644 generated/site/ko/guide/playground.md create mode 100644 generated/site/ko/guide/provider-icons.md create mode 100644 generated/site/ko/guide/what-is-stack.md create mode 100644 generated/site/ko/index.md create mode 100644 generated/site/ko/language/edges-and-layout.md create mode 100644 generated/site/ko/language/formatting.md create mode 100644 generated/site/ko/language/nodes-and-groups.md create mode 100644 generated/site/ko/language/syntax.md create mode 100644 generated/site/ko/language/themes-and-icons.md create mode 100644 generated/site/ko/reference/diagnostics-and-limits.md create mode 100644 generated/site/ko/reference/versioning-and-safety.md create mode 100644 generated/site/language/edges-and-layout.md create mode 100644 generated/site/language/formatting.md create mode 100644 generated/site/language/nodes-and-groups.md create mode 100644 generated/site/language/syntax.md create mode 100644 generated/site/language/themes-and-icons.md create mode 100644 generated/site/reference/diagnostics-and-limits.md create mode 100644 generated/site/reference/versioning-and-safety.md create mode 100644 generated/site/zh/examples/index.md create mode 100644 generated/site/zh/guide/agent-workflow.md create mode 100644 generated/site/zh/guide/coding-agents.md create mode 100644 generated/site/zh/guide/getting-started.md create mode 100644 generated/site/zh/guide/playground.md create mode 100644 generated/site/zh/guide/provider-icons.md create mode 100644 generated/site/zh/guide/what-is-stack.md create mode 100644 generated/site/zh/index.md create mode 100644 generated/site/zh/language/edges-and-layout.md create mode 100644 generated/site/zh/language/formatting.md create mode 100644 generated/site/zh/language/nodes-and-groups.md create mode 100644 generated/site/zh/language/syntax.md create mode 100644 generated/site/zh/language/themes-and-icons.md create mode 100644 generated/site/zh/reference/diagnostics-and-limits.md create mode 100644 generated/site/zh/reference/versioning-and-safety.md diff --git a/README.md b/README.md index 6e2c033..0192c2f 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,17 @@ skill and the human-readable workflow are generated from this one source. Skill discovery metadata lives in `content/skill-metadata.json`, and published CLI identity lives in `content/cli-release.json`. +The four-locale site sources live in `content/site/`. They were imported from +`stack-sh/web` commit `c0c773fd2721a177c56406732c010808269e30bc` under Apache-2.0. +The original 56 page paths are preserved. Four generated `guide/agent-workflow.md` +pages expose the canonical English instructions used by the skill; the localized +coding-agent guides explain this and share one copyable prompt from +`content/agent-prompt.txt`. This avoids hand-maintaining the validation workflow +both in a guide and a skill. `{{cliVersion}}` comes from the release lock. + +`generated/site/` contains complete Markdown inputs for the website. Website +presentation, images, VitePress configuration, and deployment are not owned here. + Language syntax, schemas, and canonical examples remain owned by [stack-sh/specification](https://github.com/stack-sh/specification). [stack-sh/cli](https://github.com/stack-sh/cli) owns native command behavior and the @@ -39,7 +50,9 @@ version string alone does not prove a feature is available. ## Migration status -Shared workflow generation is available here. CLI and Web consumption, the full -multilingual guide migration, and automated consumer freshness checks are still -being integrated. Existing public documentation and skill installation remain -available from their current repositories until those consumer changes land. +Shared workflow and multilingual source generation are available here. CLI and Web +consumption and automated consumer freshness checks are still being integrated. +Existing public documentation and skill installation remain available from their +current repositories until those consumer changes land. The website's existing +language, example, link, and build gates must pass when switching to this source; +source generation alone does not prove rendered-site compatibility. diff --git a/content/agent-prompt.txt b/content/agent-prompt.txt new file mode 100644 index 0000000..060721e --- /dev/null +++ b/content/agent-prompt.txt @@ -0,0 +1 @@ +Use Stack to create or edit the architecture described below. Read https://stack-diagram.com/docs/guide/agent-workflow.md and follow its local validation and safety workflow. Read the relevant language reference and examples as needed. Deliver editable .stack source and report verification results. Architecture requirements: diff --git a/content/site/examples/index.md b/content/site/examples/index.md new file mode 100644 index 0000000..e0dd853 --- /dev/null +++ b/content/site/examples/index.md @@ -0,0 +1,7 @@ +# Example gallery + +Start with a small diagram, then move through groups, layout constraints, provider icons, and production-like systems. Every thumbnail below is generated from the canonical source pinned to the public Stack specification. + +Provider examples keep artwork caller-owned: install the listed icon packs when you want branded icons. Without a pack, the same source remains valid and renders with Stack's deterministic missing-icon fallback. + + diff --git a/content/site/guide/coding-agents.md b/content/site/guide/coding-agents.md new file mode 100644 index 0000000..2fe124a --- /dev/null +++ b/content/site/guide/coding-agents.md @@ -0,0 +1,27 @@ +# Coding agents + +Use Stack with a coding agent to keep architecture diagrams as reviewable source. The agent can read the language reference and run the CLI locally; a remote MCP server is not required. + +## Install the skill + +Install only the diagram skill with `npx skills add stack-sh/cli`. This installs into the current project; add `-g` only when you want a user-wide installation. Review the downloaded instructions before use. This installs instructions, not the Stack CLI. For a reproducible installation, clone the repository, check out a reviewed commit, then run `npx skills add /absolute/path/to/cli --skill stack-diagrams`. The installer does not accept a raw commit SHA as a remote branch. + +[SKILL.md](https://github.com/stack-sh/cli/blob/main/skills/stack-diagrams/SKILL.md) + +## Without installation + +Copy this instruction into your agent and add the architecture requirements. The same prompt works without a skill-aware client, provided it can read HTTPS pages and execute local commands. + +```text +{{agentPrompt}} +``` + +The full [agent workflow](./agent-workflow) is generated from the same source as the CLI skill. The canonical agent instructions are in English; copy them or let your agent read the Markdown URL above. + +## Reference and updates + +- [Examples](../examples/index) +- [Syntax](../language/syntax) +- [Diagnostics](../reference/diagnostics-and-limits) +- [Provider icons](./provider-icons) +- [Markdown index](https://stack-diagram.com/docs/llms.txt) diff --git a/content/site/guide/getting-started.md b/content/site/guide/getting-started.md new file mode 100644 index 0000000..8e06793 --- /dev/null +++ b/content/site/guide/getting-started.md @@ -0,0 +1,86 @@ +# Getting started + +The fastest way to use Stack is the browser [Playground](https://stack-diagram.com/). It runs the formatter, validator, layout engine, and SVG renderer locally in WebAssembly; you do not need to install a command or send source to a rendering API. + +## Install the native CLI + +For terminal workflows and local automation, install the owner-maintained Homebrew formula with `brew install stack-sh/tap/stack`. It uses the canonical Stack CLI {{cliVersion}} release archive and supports Apple Silicon macOS plus glibc-based Linux on arm64 and x86_64 when the host meets Homebrew's current tier-1 requirements. Homebrew owns upgrades through `brew upgrade stack-sh/tap/stack`; uninstalling the formula leaves your Stack configuration and icon store in place. See the [CLI distribution contract](https://github.com/stack-sh/cli/blob/main/docs/distribution.md#homebrew-installation) for the exact platform matrix, direct-install alternative, and recovery policy. + +## Write your first document + +Replace the editor content with this example: + +```stack +stack 1.0 + +diagram "Checkout" { + theme default + + node shopper "Shopper" { + kind actor + } + + group application "Application" { + node web "Web app" { + kind client + detail "React" + } + + node api "Checkout API" { + kind service + detail "Rust" + } + + layout { + direction right + order [web, api] + } + } + + node orders "Orders" { + kind database + detail "PostgreSQL" + } + + edge shopper -> web "HTTPS" { + kind request + } + + edge web -> api "JSON" { + kind request + } + + edge api -> orders "SQL" { + kind data + } + + layout { + direction right + order [shopper, application, orders] + } +} +``` + +## Render and inspect + +Select **Run** or press Command/Ctrl + Enter. The preview shows a standalone SVG. Select the preview to inspect it at a larger size, then use **Download SVG** when you want the file. + +The source has four parts: + +1. `stack 1.0` declares the language version. +2. `diagram` provides one title and contains the architecture. +3. `node` and `group` declare components and boundaries. +4. `edge` records relationships, while `layout` supplies constrained placement intent. + +## Check and format + +Use **Check** to run the complete validation and layout pipeline without replacing the SVG. Use **Format** to rewrite syntactically valid source into the canonical two-space form while preserving line comments and meaning. + +If Stack finds a problem, the diagnostic shows its severity, stable code, location, source frame, expected values, and corrective help when available. Selecting a diagnostic focuses its source range. + +## Choose what to learn next + +- Read [Document and syntax](../language/syntax) for lexical rules and the complete grammar. +- Read [Nodes and groups](../language/nodes-and-groups) to model components and boundaries. +- Read [Edges and layout](../language/edges-and-layout) for relationships and placement intent. +- Read [Themes and icons](../language/themes-and-icons) before selecting a visual system or explicit icon. diff --git a/content/site/guide/playground.md b/content/site/guide/playground.md new file mode 100644 index 0000000..0f83962 --- /dev/null +++ b/content/site/guide/playground.md @@ -0,0 +1,42 @@ +# Using the Playground + +The Playground is the public browser consumer at [stack-diagram.com](https://stack-diagram.com/). The editor remains a native text input while a shared TextMate grammar supplies syntax color. Validation, formatting, layout, and SVG always come from the published Stack WebAssembly engine. + +## Actions + +| Action | Result | +| ---------------- | ------------------------------------------------------------------------------------------------ | +| **Format** | Canonicalizes syntactically valid source and preserves comments. Semantic errors remain visible. | +| **Check** | Runs compiler, theme, icon, layout, and routing checks without creating a new SVG. | +| **Run** | Runs the full pipeline and updates the SVG when no error prevents rendering. | +| **Download SVG** | Saves the current standalone SVG. | + +Command/Ctrl + Enter runs the document. Source changes clear stale diagnostics so old ranges are not presented as current results. + +## Reading diagnostics + +An error result can include: + +```text +error[STK2002] at 4:22 +4 | layout { direction hoo } + | ^^^ unexpected layout direction 'hoo' + = expected: right, down + = help: use 'right' for horizontal flow or 'down' for vertical flow +``` + +Select a diagnostic or its related information to focus the corresponding source. Errors prevent a successful render. Warnings describe a fallback or readability concern and can accompany an SVG. + +## Two independent color choices + +The header color-mode control changes the Playground and editor presentation. A source statement such as `theme dark` changes the generated diagram. The two settings are intentionally independent: switching the site to dark mode must not rewrite or reinterpret the diagram theme. + +## Browser behavior and data + +The Playground loads a published WebAssembly module, then runs synchronous `format`, `check`, and `render` operations in the browser. The engine itself does not read files, contact a network service, inspect the DOM, observe a clock, or measure host fonts. + +The current Playground does not provide accounts, cloud persistence, collaboration, or paid themes. Download source or SVG that you need to keep. + +## Accessibility + +The editor retains native caret, selection, clipboard, undo, keyboard, and IME behavior. Diagnostics can navigate to source ranges. The preview has text alternatives and opens in a keyboard-accessible dialog. The interface supports 320-pixel layouts, light and dark contrast, visible focus, and reduced-motion preferences. diff --git a/content/site/guide/provider-icons.md b/content/site/guide/provider-icons.md new file mode 100644 index 0000000..272c3b6 --- /dev/null +++ b/content/site/guide/provider-icons.md @@ -0,0 +1,118 @@ +# Provider icons + +Stack includes a provider-neutral core icon catalog. AWS, Google Cloud, Azure, and common developer and collaboration artwork are available through provider packs stored in your user-managed icon store. + +## Available provider catalog + +The audited catalog contains 1,051 IDs: 305 AWS Architecture Icons, 45 Google Cloud product and category icons, 639 Azure service icons, and 62 curated tool icons. The tool catalog includes GitHub, GitHub Actions, Notion, Linear, Atlassian, Jira, Confluence, Docker, Kubernetes, Terraform, Datadog, Grafana, Sentry, and more. + +Select a provider card to see its import command, then search or filter the complete catalog. Results are shown 100 at a time for comfortable use on smaller devices. + + + +A provider pack supplies artwork. The node `kind` in Stack source continues to control semantic styling and layout. + +## Quick start + +Import each provider used by a diagram once. `--accept-terms` records your confirmation that you reviewed the linked provider and brand terms. + +```sh +$ stack icons import gcp --accept-terms +$ stack icons import simple-icons --accept-terms +$ stack render architecture.stack -o architecture.svg +``` + +The CLI downloads the audited official archives, verifies their complete SHA-256 hashes, sanitizes the selected SVGs, and writes each processed provider pack to the shared icon store. Google Cloud product and category artwork is imported together by the single `gcp` command. + +## Use provider icons in CLI + +A Stack file can use multiple providers. This example combines Cloud Run from Google Cloud with GitHub from Simple Icons: + +```stack +stack 1.0 + +diagram "Deploy from GitHub to Cloud Run" { + node repository "GitHub" { + kind external + icon "simple-icons:github" + } + + node service "Cloud Run" { + kind service + icon "gcp:cloud-run" + } + + edge repository -> service "Deploy" { + kind dependency + } +} +``` + +After both imports, the standard render command discovers both packs: + +```sh +$ stack render architecture.stack -o architecture.svg --notice architecture.NOTICE.md +``` + +## Shared icon store + +The default icon store is `$XDG_CONFIG_HOME/stack/icons`. When `XDG_CONFIG_HOME` is unset, Stack uses `$HOME/.config/stack/icons`. + +```text +icons/ + aws/ + gcp/ + azure/ + simple-icons/ +``` + +Set a different shared location in `$XDG_CONFIG_HOME/stack/config.yaml` with an absolute path: + +```yaml +default_icons_path: /absolute/path/to/stack-icons +``` + +The configured location is used by both `stack icons import` and `stack render`. + +## Use provider icons in Playground + +Open **Icons**, choose the `stack/icons` folder, and the Playground loads every recognized provider directory in that store. Search the loaded artwork and select an item to copy its ID into Stack source. + +The selected packs are processed in the current browser tab. When a rendered diagram contains provider artwork, **Notice** beside the SVG download provides the source, terms, and used-icon record. + +## Keep icons with a project + +Use `-o` to place imported packs in a project directory that can be committed with the repository: + +```sh +$ stack icons import gcp --accept-terms -o .stack-icons +$ stack icons import simple-icons --accept-terms -o .stack-icons +``` + +Pass that icon-store root with `--provider-pack` when rendering: + +```sh +$ stack render architecture.stack \ + --provider-pack .stack-icons \ + -o architecture.svg \ + --notice architecture.NOTICE.md +``` + +## Find icon IDs + +Search the catalog from the CLI or on this page: + +```sh +$ stack icons list +$ stack icons list aws s3 +$ stack icons list azure database +$ stack icons list simple-icons github +``` + +The CLI output contains `ID`, `PRODUCT`, `CATEGORY`, and recommended `KIND` columns. Namespaced IDs such as `gcp:cloud-run` and `simple-icons:github` select artwork from the corresponding pack. + +## Verification, terms, and notices + +The CLI catalog pins each official HTTPS archive URL, release, complete archive SHA-256, allowlisted entry path, terms URL, and review date. Import applies bounded archive and SVG sizes, sanitizes active and external SVG content, and writes each pack atomically. + +Each pack includes `NOTICE.md`. `stack render --notice ` writes the exact pack revisions, source releases, terms URLs, attribution, non-endorsement text, and used icon IDs for a rendered artifact. The catalog links each provider's official source and terms, plus brand sources and guidelines for curated Simple Icons marks. diff --git a/content/site/guide/what-is-stack.md b/content/site/guide/what-is-stack.md new file mode 100644 index 0000000..bf3ea0a --- /dev/null +++ b/content/site/guide/what-is-stack.md @@ -0,0 +1,51 @@ +# What is Stack? + +Stack is a small declarative language for static software architecture and technology-stack diagrams. You describe components, boundaries, and relationships in a UTF-8 `.stack` file. A renderer decides coordinates, spacing, routes, typography, and visual treatment. + +This split keeps the source concise, reviewable, and useful in version control. It also lets the same document be formatted, checked, and rendered by conforming tools without turning the file into drawing instructions. + +## The basic model + +Every document contains a language version and exactly one diagram. A diagram contains nodes, optional groups, edges, an optional theme, and optional layout intent. + +```stack +stack 1.0 + +diagram "Service architecture" { + node client "Web app" { + kind client + } + + node api "API" { + kind service + detail "Order orchestration" + } + + edge client -> api "HTTPS" { + kind request + } +} +``` + +The document says that a client calls a service. It does not say where either box sits or how an arrow bends. + +## What Stack optimizes for + +- **Concise authoring:** useful diagrams need little more than named nodes and edges. +- **Predictable generation:** each concept has one constrained representation that people and language models can produce reliably. +- **Semantic source:** a document records topology and intent, not pixels. +- **Polished output:** the renderer owns a coherent visual system. +- **Actionable errors:** diagnostics point to source ranges and can include expected values, corrective help, and related declarations. +- **Safe embedding:** source cannot execute code, fetch arbitrary assets, or inject HTML or SVG. + +## What Stack is not + +Stack 1.0 is not a general graph language, pixel-perfect canvas, infrastructure definition, or executable programming language. It has no variables, imports, macros, conditionals, CSS, coordinates, arbitrary URLs, or embedded HTML. It is not a sequence, state-machine, class, ER, or complete UML notation. + +Use several focused diagrams for a large system. A single Stack document deliberately has readability limits rather than unlimited elements. + +## Processing model + +A tool decodes and parses the document, resolves identifiers and defaults, validates semantics, resolves the theme and icons, solves layout, and finally renders. Source errors stop rendering. Missing optional theme or icon resources and unsatisfied layout hints are warnings, so the engine can still return a fallback diagram. + +The [language pages](../language/syntax) explain every author-facing construct. The [versioning and safety reference](../reference/versioning-and-safety) explains compatibility and trust boundaries. diff --git a/content/site/index.md b/content/site/index.md new file mode 100644 index 0000000..3bdf0f3 --- /dev/null +++ b/content/site/index.md @@ -0,0 +1,27 @@ +--- +layout: home + +hero: + name: Stack + text: Architecture, as source. + tagline: Write a small, semantic document. Get a consistent, accessible architecture diagram without drawing coordinates or styling every box. + image: + light: /favicon.svg + dark: /favicon.svg + alt: Stack logo + actions: + - theme: brand + text: Get started + link: /guide/getting-started + - theme: alt + text: Open Playground + link: https://stack-diagram.com/ + +features: + - title: Describe the system + details: Nodes, groups, relationships, and layout intent stay readable in a compact .stack file. + - title: Keep meaning portable + details: A versioned language and structured diagnostics separate architecture meaning from renderer choices. + - title: Render safely + details: The engine produces standalone SVG without scripts, arbitrary HTML, or network-loaded assets. +--- diff --git a/content/site/ja/examples/index.md b/content/site/ja/examples/index.md new file mode 100644 index 0000000..690ea1d --- /dev/null +++ b/content/site/ja/examples/index.md @@ -0,0 +1,7 @@ +# Example gallery + +小さなdiagramから始め、group、layout constraint、provider icon、production-likeなsystemへ段階的に進めます。下のthumbnailはすべて、公開Stack specificationへpinしたcanonical sourceから生成しています。 + +Provider exampleのartworkはcaller-ownedです。Brand iconを使う場合は表示されたicon packを導入してください。Packがなくても同じsourceはvalidで、Stackのdeterministicなmissing-icon fallbackを使ってrenderされます。 + + diff --git a/content/site/ja/guide/coding-agents.md b/content/site/ja/guide/coding-agents.md new file mode 100644 index 0000000..a0b2ab7 --- /dev/null +++ b/content/site/ja/guide/coding-agents.md @@ -0,0 +1,27 @@ +# Coding agentで使う + +Coding agentでStackを読み書きすると、構成図をレビュー可能なsourceとして管理できます。言語referenceを読み、CLIをlocal実行するため、remote MCP serverは不要です。 + +## Skillの導入 + +`npx skills add stack-sh/cli`で図作成skillだけをcurrent projectへ導入します。User全体へ導入したい場合だけ`-g`を付け、取得したinstructionを確認してください。CLI本体は別途必要です。再現可能な導入にはrepositoryをcloneして確認済みcommitをcheckoutし、`npx skills add /absolute/path/to/cli --skill stack-diagrams`で導入します。Installerはcommit SHAをremote branchとして直接指定する方法には対応していません。 + +[SKILL.md](https://github.com/stack-sh/cli/blob/main/skills/stack-diagrams/SKILL.md) + +## 導入せずに使う + +次のinstructionをagentへ渡し、作りたい構成を追記してください。HTTPSの参照とlocal command実行ができれば、skillに未対応のclientでも使えます。 + +```text +{{agentPrompt}} +``` + +詳しい[agent workflow](./agent-workflow)はCLIスキルと同じ原稿から生成します。正本のagent向け指示は英語です。上のMarkdown URLをagentに読ませるか、指示をコピーしてください。 + +## 参照と更新 + +- [Examples](../examples/index) +- [Syntax](../language/syntax) +- [Diagnostics](../reference/diagnostics-and-limits) +- [Provider icons](./provider-icons) +- [Markdown index](https://stack-diagram.com/docs/llms.txt) diff --git a/content/site/ja/guide/getting-started.md b/content/site/ja/guide/getting-started.md new file mode 100644 index 0000000..a6512fb --- /dev/null +++ b/content/site/ja/guide/getting-started.md @@ -0,0 +1,86 @@ +# はじめる + +最短の利用方法はbrowser [Playground](https://stack-diagram.com/)です。Formatter、validator、layout engine、SVG rendererがWebAssemblyとしてlocalで動作するため、commandのinstallやrendering APIへのsource送信は不要です。 + +## Native CLIをinstallする + +Terminal workflowとlocal automationでは、owner管理のHomebrew formulaを`brew install stack-sh/tap/stack`でinstallします。CanonicalなStack CLI {{cliVersion}} release archiveを使用し、Homebrewの現行Tier 1要件を満たすApple Silicon macOSと、arm64 / x86_64のglibc Linuxをsupportします。UpgradeはHomebrewが`brew upgrade stack-sh/tap/stack`で管理し、formulaをuninstallしてもStackのconfigとicon storeは保持されます。正確なplatform matrix、direct install、recovery policyは[CLI distribution contract](https://github.com/stack-sh/cli/blob/main/docs/distribution.md#homebrew-installation)を参照してください。 + +## 最初のdocumentを書く + +Editorを次のexampleへ置き換えます。 + +```stack +stack 1.0 + +diagram "Checkout" { + theme default + + node shopper "Shopper" { + kind actor + } + + group application "Application" { + node web "Web app" { + kind client + detail "React" + } + + node api "Checkout API" { + kind service + detail "Rust" + } + + layout { + direction right + order [web, api] + } + } + + node orders "Orders" { + kind database + detail "PostgreSQL" + } + + edge shopper -> web "HTTPS" { + kind request + } + + edge web -> api "JSON" { + kind request + } + + edge api -> orders "SQL" { + kind data + } + + layout { + direction right + order [shopper, application, orders] + } +} +``` + +## Renderして確認する + +**Run**を選ぶか、Command/Ctrl + Enterを押します。Previewにstandalone SVGが表示されます。Previewを選ぶと拡大でき、必要なら**Download SVG**で保存できます。 + +Sourceは4つの要素で構成されています。 + +1. `stack 1.0`がlanguage versionを宣言します。 +2. `diagram`が1つのtitleとarchitecture全体を持ちます。 +3. `node`と`group`がcomponentとboundaryを宣言します。 +4. `edge`がrelationshipを、`layout`が制約された配置intentを記録します。 + +## CheckとFormat + +**Check**はSVGを置き換えず、validationとlayout pipeline全体を実行します。**Format**はline commentと意味を保持しながら、syntaxがvalidなsourceをcanonicalな2-space形式へ書き換えます。 + +問題があると、severity、stable code、location、source frame、expected value、利用可能なcorrective helpが表示されます。Diagnosticを選ぶと該当source rangeへfocusします。 + +## 次に読むもの + +- Lexical ruleと完全なgrammarは[Documentとsyntax](../language/syntax)を参照します。 +- Componentとboundaryは[Nodeとgroup](../language/nodes-and-groups)を参照します。 +- Relationshipと配置intentは[Edgeとlayout](../language/edges-and-layout)を参照します。 +- Visual systemや明示iconを選ぶ前に[Themeとicon](../language/themes-and-icons)を参照します。 diff --git a/content/site/ja/guide/playground.md b/content/site/ja/guide/playground.md new file mode 100644 index 0000000..b3b2a6b --- /dev/null +++ b/content/site/ja/guide/playground.md @@ -0,0 +1,42 @@ +# Playgroundの使い方 + +Playgroundは[stack-diagram.com](https://stack-diagram.com/)で公開しているbrowser consumerです。Editorはnative text inputを維持し、shared TextMate grammarがsyntax colorを提供します。Validation、format、layout、SVGは常に公開Stack WebAssembly engineから生成されます。 + +## Action + +| Action | Result | +| ---------------- | -------------------------------------------------------------------------------------------- | +| **Format** | Syntaxがvalidなsourceをcanonicalizeし、commentを保持します。Semantic errorは表示に残ります。 | +| **Check** | 新しいSVGを作らず、compiler、theme、icon、layout、routingを確認します。 | +| **Run** | Pipeline全体を実行し、renderを妨げるerrorがなければSVGを更新します。 | +| **Download SVG** | 現在のstandalone SVGを保存します。 | + +Command/Ctrl + Enterでも実行できます。Source変更時には古いrangeを現在の結果として見せないよう、stale diagnosticを消去します。 + +## Diagnosticの読み方 + +Error resultには次の情報が含まれます。 + +```text +error[STK2002] at 4:22 +4 | layout { direction hoo } + | ^^^ unexpected layout direction 'hoo' + = expected: right, down + = help: use 'right' for horizontal flow or 'down' for vertical flow +``` + +Diagnosticやrelated informationを選ぶと対応sourceへfocusします。Errorはsuccessful renderを止めます。Warningはfallbackや可読性の懸念を表し、SVGと同時に返ることがあります。 + +## 独立した2つのcolor設定 + +Headerのcolor modeはPlaygroundとeditorの表示を変えます。`theme dark`のようなsource statementは生成diagramを変えます。Siteをdark modeへ切り替えてもdiagram themeを変更・解釈し直さないよう、両者は独立しています。 + +## Browser behaviorとdata + +Playgroundは公開WebAssembly moduleをloadし、browser内で同期的な`format`、`check`、`render`を実行します。Engine自体はfile読込、network接続、DOM参照、clock観測、host font計測をしません。 + +現在はaccount、cloud persistence、collaboration、paid themeを提供していません。保持したいsourceやSVGはdownloadしてください。 + +## Accessibility + +Editorはnativeのcaret、selection、clipboard、undo、keyboard、IME behaviorを保持します。Diagnosticからsource rangeへ移動でき、previewはtext alternativeを持つkeyboard-accessibleなdialogで開きます。320px layout、light/dark contrast、visible focus、reduced motionに対応します。 diff --git a/content/site/ja/guide/provider-icons.md b/content/site/ja/guide/provider-icons.md new file mode 100644 index 0000000..5659717 --- /dev/null +++ b/content/site/ja/guide/provider-icons.md @@ -0,0 +1,118 @@ +# Provider icon + +Stackにはprovider-neutralなcore icon catalogが含まれます。AWS、Google Cloud、Azure、主要な開発・collaboration toolのartworkは、user-managed icon storeに保存するprovider packとして利用できます。 + +## 利用可能なprovider catalog + +監査済みcatalogには合計1,051 IDがあります。AWS Architecture Icons 305件、Google Cloudのproduct・category icon 45件、Azure service icon 639件、主要tool icon 62件です。Tool catalogにはGitHub、GitHub Actions、Notion、Linear、Atlassian、Jira、Confluence、Docker、Kubernetes、Terraform、Datadog、Grafana、Sentryなどが含まれます。 + +Provider cardを選ぶとimport commandを確認できます。全catalogを検索・filterでき、小さいdeviceでも見やすいよう100件ずつ表示します。 + + + +Provider packが追加するのはartworkです。Semantic stylingとlayoutはStack sourceに書いたnode `kind`が引き続き決めます。 + +## Quick start + +Diagramで使うproviderを一度ずつimportします。`--accept-terms`は、link先のprovider・brand termsを確認して同意したことを記録します。 + +```sh +$ stack icons import gcp --accept-terms +$ stack icons import simple-icons --accept-terms +$ stack render architecture.stack -o architecture.svg +``` + +CLIは監査済みの公式archiveをdownloadし、archive全体のSHA-256を検証し、選択したSVGをsanitizeして、処理済みprovider packをshared icon storeへ保存します。Google Cloudのproduct・category artworkは1つの`gcp` commandで一緒にimportされます。 + +## CLIでprovider iconを使う + +1つのStack fileで複数providerを利用できます。次の例はGoogle CloudのCloud RunとSimple IconsのGitHubを組み合わせます。 + +```stack +stack 1.0 + +diagram "Deploy from GitHub to Cloud Run" { + node repository "GitHub" { + kind external + icon "simple-icons:github" + } + + node service "Cloud Run" { + kind service + icon "gcp:cloud-run" + } + + edge repository -> service "Deploy" { + kind dependency + } +} +``` + +2つをimportした後は、通常のrender commandが両方のpackを見つけます。 + +```sh +$ stack render architecture.stack -o architecture.svg --notice architecture.NOTICE.md +``` + +## Shared icon store + +Default icon storeは`$XDG_CONFIG_HOME/stack/icons`です。`XDG_CONFIG_HOME`が未設定の場合は`$HOME/.config/stack/icons`を使います。 + +```text +icons/ + aws/ + gcp/ + azure/ + simple-icons/ +``` + +`$XDG_CONFIG_HOME/stack/config.yaml`にabsolute pathを書くと、shared locationを変更できます。 + +```yaml +default_icons_path: /absolute/path/to/stack-icons +``` + +このlocationは`stack icons import`と`stack render`の両方で使われます。 + +## Playgroundでprovider iconを使う + +**Icons**を開いて`stack/icons` folderを選ぶと、Playgroundがstore内の認識可能なprovider directoryをすべてloadします。Loadしたartworkを検索し、選択するとIDをStack sourceへcopyできます。 + +選択したpackは現在のbrowser tabで処理されます。生成diagramにprovider artworkが含まれる場合は、SVG download横の**Notice**からsource、terms、使用iconの記録を取得できます。 + +## Iconをprojectと一緒に管理する + +Import済みpackをrepositoryへ含める場合は、`-o`でproject directoryを指定します。 + +```sh +$ stack icons import gcp --accept-terms -o .stack-icons +$ stack icons import simple-icons --accept-terms -o .stack-icons +``` + +Render時は`--provider-pack`へ同じicon-store rootを渡します。 + +```sh +$ stack render architecture.stack \ + --provider-pack .stack-icons \ + -o architecture.svg \ + --notice architecture.NOTICE.md +``` + +## Icon IDを探す + +CLIまたはこのpageでcatalogを検索できます。 + +```sh +$ stack icons list +$ stack icons list aws s3 +$ stack icons list azure database +$ stack icons list simple-icons github +``` + +CLI outputには`ID`、`PRODUCT`、`CATEGORY`、推奨`KIND`が含まれます。`gcp:cloud-run`や`simple-icons:github`のようなnamespaced IDが対応するpackのartworkを選択します。 + +## 検証・terms・notice + +CLI catalogは公式HTTPS archive URL、release、archive全体のSHA-256、allowlist済みentry path、terms URL、review dateをpinしています。Importではarchive・SVGのsizeを制限し、active・external SVG contentをsanitizeして、packをatomicに保存します。 + +各packには`NOTICE.md`が含まれます。`stack render --notice `は、実際のpack revision、source release、terms URL、attribution、non-endorsement text、使用icon IDを出力します。Catalogから各providerの公式sourceとterms、Simple Iconsのbrand sourceとguidelineを確認できます。 diff --git a/content/site/ja/guide/what-is-stack.md b/content/site/ja/guide/what-is-stack.md new file mode 100644 index 0000000..b6117c2 --- /dev/null +++ b/content/site/ja/guide/what-is-stack.md @@ -0,0 +1,51 @@ +# Stackとは + +Stackは、software architectureとtechnology stackの静的なdiagramを記述するための小さなdeclarative languageです。UTF-8の`.stack` fileにcomponent、boundary、relationshipを書き、座標、余白、route、typography、visual treatmentはrendererが決めます。 + +この分離により、sourceは簡潔でreviewしやすく、version controlにも適します。同じdocumentを、drawing instructionへ変えずにformat・check・renderできます。 + +## 基本モデル + +各documentにはlanguage versionとちょうど1つのdiagramがあります。Diagramにはnode、任意のgroup・edge・theme・layout intentを記述します。 + +```stack +stack 1.0 + +diagram "Service architecture" { + node client "Web app" { + kind client + } + + node api "API" { + kind service + detail "Order orchestration" + } + + edge client -> api "HTTPS" { + kind request + } +} +``` + +このsourceはclientがserviceを呼ぶことを表します。Boxの位置やarrowの曲がり方は指定しません。 + +## Stackが重視すること + +- **簡潔なauthoring:** 名前付きnodeとedgeだけで有用なdiagramを書けます。 +- **予測可能な生成:** 人とlanguage modelが同じconceptを安定して記述できます。 +- **Semantic source:** Pixelではなくtopologyとintentを記録します。 +- **整ったoutput:** 一貫したvisual systemをrendererが所有します。 +- **修正可能なerror:** Diagnosticはsource range、expected value、help、related declarationを示せます。 +- **安全な埋め込み:** Sourceはcode実行、任意asset取得、HTML/SVG注入ができません。 + +## Stackではないもの + +Stack 1.0はgeneral graph language、pixel-perfect canvas、infrastructure definition、実行可能なprogramming languageではありません。Variable、import、macro、condition、CSS、座標、任意URL、埋め込みHTMLはありません。Sequence、state machine、class、ER、完全なUML notationも対象外です。 + +大規模systemは1枚に詰めず、複数の焦点を絞ったdiagramに分けます。Stackには可読性を守るための上限があります。 + +## Processing model + +Toolはdecode / parse、identifierとdefaultの解決、semantic validation、theme / icon解決、layout、renderの順に処理します。Source errorはrenderを停止します。Optional theme / iconの欠落や満たせないlayout hintはwarningとなり、fallback diagramを返せます。 + +Author向けの全constructは[言語ページ](../language/syntax)、互換性とtrust boundaryは[Versioningと安全性](../reference/versioning-and-safety)で説明します。 diff --git a/content/site/ja/index.md b/content/site/ja/index.md new file mode 100644 index 0000000..dafd1ac --- /dev/null +++ b/content/site/ja/index.md @@ -0,0 +1,27 @@ +--- +layout: home + +hero: + name: Stack + text: Architectureをsourceとして。 + tagline: 小さなsemantic documentを書くだけで、座標やboxごとのstyleを指定せず、一貫したaccessibleなarchitecture diagramを生成できます。 + image: + light: /favicon.svg + dark: /favicon.svg + alt: Stackロゴ + actions: + - theme: brand + text: はじめる + link: /ja/guide/getting-started + - theme: alt + text: Playgroundを開く + link: https://stack-diagram.com/ + +features: + - title: Systemを記述する + details: Node、group、relationship、layout intentを、簡潔な.stack fileとして読みやすく保ちます。 + - title: 意味をportableにする + details: Version付きlanguageとstructured diagnosticが、architectureの意味をrendererの選択から分離します。 + - title: 安全にrenderする + details: Script、任意HTML、network assetを含まないstandalone SVGをengineが生成します。 +--- diff --git a/content/site/ja/language/edges-and-layout.md b/content/site/ja/language/edges-and-layout.md new file mode 100644 index 0000000..de233aa --- /dev/null +++ b/content/site/ja/language/edges-and-layout.md @@ -0,0 +1,78 @@ +# Edgeとlayout + +Edgeはnode間のrelationshipを表します。Layout blockは座標やdrawing primitiveを公開せず、少量の配置intentを表します。 + +## Edge direction + +Edgeは異なる2 nodeを接続します。Forward referenceはvalidですが、self-edgeとgroup endpointはinvalidです。 + +| Operator | Meaning | +| -------- | -------------------------------------------------- | +| `->` | 左nodeから右nodeへのdirected relationship | +| `<->` | 両方向の1つのsymmetric relationship | +| `--` | Directionがない、または意図的に未指定のassociation | + +`<->`は独立してlabel可能な2 edgeの省略形ではありません。 + +## Edge kindとlabel + +任意labelはprotocol、event、command、dataset、purposeを表す1〜40 Unicode scalarです。任意`kind`はlabelとは独立してrelationshipを分類し、defaultは`flow`です。 + +| Kind | Intended meaning | +| ------------ | --------------------------------------------------- | +| `flow` | Generic runtimeまたはconceptual flow | +| `request` | Synchronous requestまたはcall | +| `event` | Asynchronous messageまたはevent delivery | +| `data` | Data movement、replication、read、write | +| `dependency` | Build-time、deployment-time、operational dependency | + +```stack +stack 1.0 + +diagram "Relationships" { + node web "Web app" { + kind client + } + + node api "API" + node queue "Events" { + kind queue + } + + edge web -> api "HTTPS" { + kind request + } + + edge api -> queue "OrderPlaced" { + kind event + } +} +``` + +異なるrelationshipなら同じnode間に複数edgeを置けます。同じendpoint、operator、label、effective kindのexact duplicateはinvalidです。`<->`と`--`のduplicate比較ではendpoint orderを無視します。 + +## Layout scope + +Diagramまたはgroupには1つの`layout` blockを置けます。Group blockはそのdirect childだけ、diagram blockはdiagramのdirect childだけに作用します。`rank`と`order`は同じscopeの異なるdirect childを最低2つ参照します。 + +Layoutではdirect child groupを1 itemとして扱います。Descendant node同士のconnectionは所属するdirect-child item間のconnectionになるため、groupをedge endpointにしなくてもtop-level layoutでgroupを配置できます。 + +## Direction、rank、order + +```stack +layout { + direction right + rank same [web, worker] + order [web, worker, database] +} +``` + +- `direction right`は左から右、`direction down`は上から下のprogressionを優先します。Strong hintであり、全edgeの幾何方向を保証しません。Nested groupへinheritしません。 +- `rank same [a, b]`はlisted direct childを同じlayout rankに置くconstraintです。同じscopeで1 childを2つのsame-rank statementに置けません。 +- `order [a, b]`はrelative-order hintです。Right scopeでは上から下、down scopeでは左から右、automatic layoutではchosen cross-axisに沿います。他childは省略できます。 + +Rendererはcontainment、same-rank constraint、legibility、output boundを守るため`order`から外れることがあります。その場合、diagnostic-capable toolは`STK4001`を出します。 + +## Rendererが所有する判断 + +Stackには座標、dimension、port、path、color、font、line break、z-indexがありません。Rendererはoverlapを防ぎ、containmentとdirectionを保ち、labelを読みやすくし、node interiorを避けてedgeをrouteし、semantic contentをclipせずcanvasを拡張します。 diff --git a/content/site/ja/language/formatting.md b/content/site/ja/language/formatting.md new file mode 100644 index 0000000..753d123 --- /dev/null +++ b/content/site/ja/language/formatting.md @@ -0,0 +1,58 @@ +# Canonical formatting + +Stackはlexically / syntactically validな各documentに、1つのcanonical byte representationを定義します。Formattingはlanguage version、semantic meaning、line commentを変えず、diffを一定にします。 + +## Formatできるsource + +FormatterはBOMなしUTF-8を受け取ります。Lexical/syntax error時はdiagnosticだけを返し、partial formatted sourceを返しません。Syntaxがvalidならsemantic/complexity diagnosticがあってもformatできます。Format成功はdiagramのvalidityを意味しません。 + +## Canonical output + +Canonical sourceは次の規則に従います。 + +- BOMなしUTF-8を使う。 +- 全line endingをLFへ正規化する。 +- Block levelごとにASCII space 2つを使い、formatting tabを使わない。 +- Line末尾のformatting whitespaceを置かない。 +- 最後はちょうど1 LFにする。 +- Opening braceはdeclarationまたは`layout`行、closing braceは単独行に置く。 +- Versionとdiagram、bodyの隣接member間に1 empty lineを置く。 +- Propertyとlayout statement間にはempty lineを置かない。 + +```stack +stack 1.0 + +diagram "Title" { + theme dark + + node client "Client" + + node api "API" { + kind service + detail "Public API" + } + + edge client -> api "HTTPS" { + kind request + } + + layout { + direction right + order [client, api] + } +} +``` + +## Orderとlist + +Formatterはdiagram/group member、node/edge property、layout statement、list identifierのauthored orderを保持します。Group化やsortはしません。Listは1行でcomma後に1 space、bracket内側にspaceなし、trailing commaなしです。 + +## String + +Valid stringをdecodeし、Unicode normalizationせずUTF-8で直接出力します。Quoteとbackslashはescapeし、canonical outputは`\uXXXX`を使いません。たとえば`"API \u56F3 \uD83D\uDE80"`は`"API 図 🚀"`になります。 + +## Comment + +すべてのline commentと順序を保持します。Trailing commentは直前tokenの後へ1 spaceで続きます。Own-line commentはtoken gapを保ち、後続member、statement、propertyの直前に置きます。Construct内commentはcontinuation lineを強制でき、通常のone-line ruleに対する唯一の例外です。 + +Canonical sourceを再formatした結果はbyte-identicalでなければなりません。Normalized IRがある場合、format前後でsemantically equalなIRを生成します。 diff --git a/content/site/ja/language/nodes-and-groups.md b/content/site/ja/language/nodes-and-groups.md new file mode 100644 index 0000000..b00e75e --- /dev/null +++ b/content/site/ja/language/nodes-and-groups.md @@ -0,0 +1,67 @@ +# Nodeとgroup + +Nodeは参照可能なarchitectural entity、groupはlabel付きcontainment boundaryです。この2つでdiagram内のcomponentとscopeを記述します。 + +## Node + +Nodeにはglobally uniqueなidentifierとvisible labelが必要です。Identifierはedgeとlayoutから参照しますがrenderされません。Labelは1〜60 Unicode scalarです。 + +```stack +stack 1.0 + +diagram "Node example" { + node api "Public API" { + kind service + detail "Order orchestration" + } +} +``` + +別entityなら同じvisible labelを持てますが、位置に頼らず理解できるlabelを推奨します。Node blockでは`kind`、`icon`、`detail`を重複できません。 + +## Node kind + +`kind`は粗いarchitectural meaningを表し、themeが管理するshapeとfallback iconを選びます。Defaultは`service`です。 + +| Kind | Intended meaning | +| ---------- | ------------------------------------------------- | +| `actor` | Person、role、team、autonomous participant | +| `client` | Browser、mobile/desktop app、deviceなどのclient | +| `service` | Long-running app、API、gateway、general component | +| `function` | On-demandまたはserverless compute unit | +| `worker` | Background processorまたはscheduled job | +| `database` | Durableでquery可能なdatastore | +| `cache` | 内容を破棄・再生成できるdatastore | +| `queue` | Async delivery用queue、stream、bus、broker | +| `storage` | Blob、object、file、archive storage | +| `external` | Architectureのcontrol boundary外のsystem | + +Kindはvendor shapeではなくsemantic categoryです。Hosted PostgreSQLも`database`で、technology名は`detail`に書きます。 + +## Labelとdetail + +`detail`は任意のvisibleな2行目で、1〜80 Unicode scalarです。`"Next.js"`、`"PostgreSQL 17"`、`"Order orchestration"`のように1 technologyまたは短いresponsibilityを書きます。すべてのrenderで表示され、tooltipだけにはなりません。 + +Labelとdetailはplain textです。明示`icon`はnodeを装飾しますが、kind、identity、accessible labelを変えません。[Themeとicon](./themes-and-icons)も参照してください。 + +## Group + +Groupにはglobally uniqueなidentifier、1〜60 Unicode scalarのlabel、最低1つのdescendant nodeが必要です。Node、nested group、1つのlayout blockを含められます。 + +```stack +stack 1.0 + +diagram "Boundaries" { + group platform "Platform" { + group data "Data layer" { + node primary "Primary database" { + kind database + } + } + } +} +``` + +Nestingはdiagram下3 levelまでです。Nodeは最も近いgroupと全ancestor groupに属します。Declarationは再利用できないため、2つの別groupには所属できません。 + +Edgeは必ずdiagram scopeで宣言し、endpointにはnodeだけを使えます。Groupはimplicit nodeやrelationshipを作りません。Labelでsystem、domain、network、deployment area、teamなどの意味を示します。Containmentだけでruntime isolation、security、ownership、deployment semanticsを意味しません。 diff --git a/content/site/ja/language/syntax.md b/content/site/ja/language/syntax.md new file mode 100644 index 0000000..ed01ab8 --- /dev/null +++ b/content/site/ja/language/syntax.md @@ -0,0 +1,95 @@ +# Documentとsyntax + +Stack sourceは意図的に小さく設計されています。このページではdraft Stack 1.0のlexical structureとgrammarをすべて説明します。 + +## Document構造 + +DocumentはBOMなしUTF-8の`.stack` fileです。LFとCRLFは同じ意味です。最初のnon-comment tokenはversion directiveで、その後にちょうど1つのdiagramが続き、後続declarationは置けません。 + +```stack +// One file, one diagram. +stack 1.0 + +diagram "Example" { + node api "API" +} +``` + +Diagram titleは必須で1〜80 Unicode scalar、先頭・末尾にUnicode whitespaceは置けません。Diagramには最低1 nodeが必要です。 + +## Commentとwhitespace + +Space、tab、line endingはtokenを分離しますが、それ以外の意味を持ちません。Line commentは`//`からline endingまでで、whitespaceを置ける場所に記述できます。Block commentはありません。 + +Formatting自体はsemanticではありませんが、canonical formatterは[Canonical formatting](./formatting)の一定形式を生成します。 + +## Identifier + +Node、group、theme、reference identifierは次に一致します。 + +```text +[a-z][a-z0-9_-]* +``` + +1〜64 ASCII文字でcase-sensitive、画面には表示されません。Nodeとgroupは1つのglobal namespaceを共有します。Keywordはcontextualなのでidentifier位置にも置けますが、読みにくい名前は避けてください。 + +Icon identifierはquoted stringで、decode後が`[a-z0-9][a-z0-9-]*`に一致する1〜64 ASCII文字です。Effective theme内で解決されます。 + +## String + +Stringはdouble quoteで囲み、Unicodeを直接書けます。Escapeは3種類だけです。 + +| Escape | Meaning | +| -------- | ----------------- | +| `\"` | Double quote | +| `\\` | Backslash | +| `\uXXXX` | Unicode code unit | + +Decode後のstringにline break、tab、control character、unpaired surrogateは置けません。Title、label、detailの先頭・末尾にUnicode whitespaceは置けません。Stringはplain textであり、MarkdownやHTMLとして解釈されません。 + +## 完全なgrammar + +```text +document = version-directive, diagram-declaration, EOF ; +version-directive = "stack", integer, ".", integer ; +diagram-declaration + = "diagram", string, "{", { diagram-member }, "}" ; +diagram-member = node-declaration | group-declaration | edge-declaration + | theme-statement | layout-block ; +theme-statement = "theme", identifier ; +group-declaration = "group", identifier, string, "{", { group-member }, "}" ; +group-member = node-declaration | group-declaration | layout-block ; +node-declaration = "node", identifier, string, [ node-block ] ; +node-block = "{", node-property, { node-property }, "}" ; +node-property = "kind", node-kind | "icon", string | "detail", string ; +node-kind = "actor" | "client" | "service" | "function" | "worker" + | "database" | "cache" | "queue" | "storage" | "external" ; +edge-declaration = "edge", identifier, edge-operator, identifier, + [ string ], [ edge-block ] ; +edge-operator = "->" | "<->" | "--" ; +edge-block = "{", edge-property, { edge-property }, "}" ; +edge-property = "kind", edge-kind ; +edge-kind = "flow" | "request" | "event" | "data" | "dependency" ; +layout-block = "layout", "{", layout-statement, + { layout-statement }, "}" ; +layout-statement = direction-statement | rank-statement | order-statement ; +direction-statement + = "direction", ( "right" | "down" ) ; +rank-statement = "rank", "same", identifier-list ; +order-statement = "order", identifier-list ; +identifier-list = "[", identifier, ",", identifier, + { ",", identifier }, "]" ; +integer = "0" | nonzero-digit, { digit } ; +``` + +## Contextual keyword + +Stack 1.0はgrammar上の位置で次のwordを認識します。 + +```text +stack diagram group node edge theme layout kind icon detail direction +rank same order right down actor client service function worker +database cache queue storage external flow request event data dependency +``` + +Unknown declaration、property、enum value、operatorはerrorです。見た目だけ成功してauthorの意味を失わないよう、toolはunknown syntaxを黙って無視しません。 diff --git a/content/site/ja/language/themes-and-icons.md b/content/site/ja/language/themes-and-icons.md new file mode 100644 index 0000000..ace5bab --- /dev/null +++ b/content/site/ja/language/themes-and-icons.md @@ -0,0 +1,126 @@ +# Themeとicon + +Themeはdiagram-levelでrendererが管理するvisual systemへのsymbolic referenceです。Iconはそのtheme内で解決するlogical nameです。どちらもdiagramの意味を変更しません。 + +## Themeを選ぶ + +Diagram直下に最大1つの`theme` statementを置きます。 + +```stack +stack 1.0 + +diagram "Dark architecture" { + theme dark + + node api "API" +} +``` + +省略時は`default`です。Draft Stack 1.0はcore catalogに次のthemeを要求します。 + +| Theme | Intended use | +| --------- | ------------------------------------------------------------ | +| `default` | 一般的なarchitecture diagram向けのbalanced blue-gray surface | +| `light` | Light document向けのwarm neutral surface | +| `dark` | Dark canvas向けのhigh-contrast cool surface | + +Sourceはidentifierを選ぶだけで、catalog package versionを選びません。Render metadataがcatalog versionとcontent revisionを記録します。 + +生成diagramのthemeとPlayground UIのlight/darkは独立しています。Themeはpalette、typography metric、surface、icon、connector、backgroundを変えられますが、node、group、edge、label、kind、direction、layout constraintを隠したり変更したりできません。 + +## Fallback behavior + +3つのcore themeはrenderer必須resourceです。利用中catalogにないnon-core themeはwarning `STK6001`を出し、`default`でrenderします。Sourceにidentifierがあってもnetworkからthemeを取得しません。 + +Theme identifierは通常のStack identifier syntaxを使います。一度登録されたidentifierを、deprecation後も別themeへ再利用できません。 + +## Kind fallback icon + +各themeは全node kindにfallbackを持ちます。`icon`を省略するとrendererがこれを使います。 + +| Node kind | Current logical fallback icon | +| ---------- | ----------------------------- | +| `actor` | `kind-actor` | +| `client` | `kind-client` | +| `service` | `kind-service` | +| `function` | `kind-function` | +| `worker` | `kind-worker` | +| `database` | `kind-database` | +| `cache` | `kind-cache` | +| `queue` | `kind-queue` | +| `storage` | `kind-storage` | +| `external` | `kind-external` | + +現在のopen core catalogは`default`、`light`、`dark`にこの10 fallback identifierを持ちます。`postgresql`、`aws`、`github`などのvendor iconはまだありません。通常はsemanticな`kind`を選び、`icon`を省略してください。 + +## 明示icon + +明示iconはquoted logical identifierです。 + +```stack +stack 1.0 + +diagram "Explicit icon" { + node gateway "Public API" { + kind service + icon "api" + } +} +``` + +Iconはnodeを装飾するだけで、`service` kind、identity、label、accessible descriptionを変えません。Themeごとに色やartworkを調整できますが、同じidentifierは同じlogical subjectを表します。 + +## First-party icon catalog + +Free core catalogは、次のprovider-neutralな明示iconを`default`、`light`、`dark`に収録しています。 + +| ID | Stable subject | 主な用途 | +| --------------- | --------------------------------- | -------------------------------- | +| `api` | Application programming interface | Public / internal API | +| `web` | Web application | Browser向けWeb experience | +| `mobile` | Mobile application | iOS / Android client | +| `desktop` | Desktop application | Native desktop client | +| `server` | Server host | Virtual machine / physical host | +| `container` | Application container | Containerized workload | +| `cluster` | Compute cluster | Orchestrated compute group | +| `cloud` | Cloud environment | Provider-neutralなcloud boundary | +| `scheduler` | Scheduled execution | Cron job / scheduled work | +| `webhook` | Webhook endpoint | Inbound / outbound callback | +| `identity` | Identity and access | Authentication / authorization | +| `observability` | Observability system | Metrics / logs / traces | +| `gateway` | Network gateway | Public / private networkの入口 | +| `load-balancer` | Load balancer | Trafficの分散 | +| `dns` | Domain name service | Hostname / service discovery | +| `cdn` | Content delivery network | Edgeでのcontent delivery | +| `firewall` | Network firewall | Network access boundary | +| `network` | Network topology | 一般的なnetwork / subnet | +| `event` | Discrete event | 個別のdomain / system event | +| `stream` | Event stream | 継続的なevent / data flow | +| `search` | Search service | Indexing / query system | +| `analytics` | Analytics system | Reporting / data analysis | +| `repository` | Source code repository | Source code / version control | +| `pipeline` | Delivery pipeline | Build / test / deploy flow | +| `secret` | Secret or credential | Secret / key / credential | +| `document` | Document or knowledge base | Documentation / knowledge | +| `task` | Task or issue tracker | Task / ticket / issue tracking | +| `chat` | Chat or messaging tool | Team chat / messaging | +| `email` | Email delivery | Email delivery / inbox | +| `ai` | Artificial intelligence system | AI model / inference service | + +下のpreviewをlight / darkへ切り替えると、実際のoutputを比較できます。各imageは公開`@stack-sh/engine@0.7.0`がlocalでrenderし、DocumentationにTheme SVG assetを複製していません。Syntaxの行を選ぶとコピーできます。 + + + +Semanticな`kind`と明示iconは独立して選びます。たとえば`icon "web"`は`client`にも`service`にも使えますが、そのnodeの意味は変更しません。 + +## 未収録iconとvendor icon + +Core catalogは現在、`postgresql`、`aws`、`github`、`docker`などのvendor / project markを収録していません。Effective themeにauthored icon identifierがなければ、node kindのfallbackでrenderを続け、warning `STK5001`を出します。 + +上表のprovider-neutral iconを選ぶか、kind fallbackだけで役割が伝わる場合は`icon`を省略してください。Vendor markを別catalogへ収録するには、asset単位のlicense、redistribution、trademark reviewが必要です。 + +## Catalogとasset safety + +Public `stack-sh/theme` catalogがpalette、deterministic font metric、node-kind visual、connector、icon metadata、SVG byte、provenance、redistribution permissionを所有します。Catalog assetはrendererへbundleし、authored identifierをfile pathやURLとして扱いません。 + +SVG validationはscript、event handler、nested SVG、unsafe reference、data/network URL、style attribute、allowlist外のelement/attributeを拒否します。Iconだけを意味の唯一の手掛かりにせず、labelとnon-color distinctionも維持します。 diff --git a/content/site/ja/reference/diagnostics-and-limits.md b/content/site/ja/reference/diagnostics-and-limits.md new file mode 100644 index 0000000..e5a1b2c --- /dev/null +++ b/content/site/ja/reference/diagnostics-and-limits.md @@ -0,0 +1,58 @@ +# Diagnosticとlimit + +Stack diagnosticはconsole proseではなくstructured resultです。Stable code、`error`/`warning` severity、1-based end-exclusive source range、簡潔なmessage、ordered `expected` listを持ちます。必要に応じてcorrective helpとrelated source rangeも含みます。 + +## Processingとseverity + +Toolはencoding/token、grammar、identifier/default、semantic limit、theme/icon、layout、renderの順で処理します。最初の4 stageのerrorはrenderを止めます。Theme、icon、density、layout-hint warningはfallback SVGと同時に返せます。 + +Playgroundはsource編集後にstale diagnosticを消します。Resultを選ぶとprimary sourceへfocusし、related informationから以前のdeclarationへ移動できます。 + +## Complexity limit + +| Item | Draft Stack 1.0 limit | +| ------------------------ | -------------------------------: | +| Documentあたりのdiagram | 1 | +| Node | 1〜40 | +| Group | 0〜12 | +| Diagram下のgroup nesting | 3 level | +| Edge | 0〜80またはnode数の2倍の小さい方 | +| Warning前のnode degree | 12 incident edge declaration | + +Hard limit超過は`STK4003`です。推奨degreeを超えたnodeはvalidのまま`STK4002`を出します。大規模systemは1つへ圧縮せず、焦点を絞ったdiagramへ分けてください。 + +## Portable diagnostic code + +| Code | Severity | Meaning | +| --------- | -------- | -------------------------------------------------------- | +| `STK1001` | Error | Inputがvalid UTF-8ではない | +| `STK1002` | Error | Byte order markがある | +| `STK1003` | Error | String escapeまたはdecode valueがinvalid | +| `STK2001` | Error | 宣言language versionがunsupported | +| `STK2002` | Error | Unexpected token、declaration、property、value、operator | +| `STK2003` | Error | Construct完了前にinputが終了した | +| `STK3001` | Error | Identifierがinvalid | +| `STK3002` | Error | Identifierが重複宣言された | +| `STK3003` | Error | Edgeがunknown nodeを参照した | +| `STK3004` | Error | Groupをedge endpointに使った | +| `STK3005` | Error | Edgeが同じnodeを接続した | +| `STK3006` | Error | Exact duplicate edgeを宣言した | +| `STK3007` | Error | 1 block内でpropertyが重複した | +| `STK3008` | Error | Title、label、detailがtext constraint違反 | +| `STK3009` | Error | Groupにdescendant nodeがない | +| `STK3010` | Error | Group nestingがlimit超過 | +| `STK3011` | Error | Layout referenceがscope内でinvalid | +| `STK3012` | Error | Layout blockまたはsingleton statementが重複した | +| `STK3013` | Error | Icon identifierがmalformed | +| `STK3014` | Error | Diagramに複数theme statementがある | +| `STK4001` | Warning | Order hintを満たせなかった | +| `STK4002` | Warning | Nodeが推奨incident-edge degreeを超えた | +| `STK4003` | Error | Diagramがlanguage complexity limit超過 | +| `STK5001` | Warning | Effective themeにiconがなくkind fallbackを使用した | +| `STK6001` | Warning | Requested non-core themeがなく`default`を使用した | + +Code familyは`STK1000`がencoding/lexical、`STK2000`がsyntax、`STK3000`がname/semantic、`STK4000`がlayout/complexity、`STK5000`がicon、`STK6000`がthemeです。`STK9000`はsource mistakeではなくimplementation failure用です。Implementation固有diagnosticはnon-`STK` prefixだけを使えます。 + +## Recovery rule + +Parserは複数のindependent errorを報告するためrecoverできますが、partial diagramをvalidとしてrenderできません。Unknown declaration、property、enum value、operatorは無視されません。Authorの意味を失った成功風outputを防ぎます。 diff --git a/content/site/ja/reference/versioning-and-safety.md b/content/site/ja/reference/versioning-and-safety.md new file mode 100644 index 0000000..1a0b3b3 --- /dev/null +++ b/content/site/ja/reference/versioning-and-safety.md @@ -0,0 +1,40 @@ +# Versioningと安全性 + +Draft Stack 1.0はsource language、implementation、theme catalog、package versionを分離します。この境界を理解するとdocumentをportableにし、rendered outputの由来を追跡できます。 + +## Language version + +すべてのdocumentは`major.minor` directiveから始まります。 + +```stack +stack 1.0 + +diagram "Versioned source" { + node api "API" +} +``` + +これはdocumentが必要とするminimum language grammar / semanticsで、engineやtheme versionではありません。`M.N`対応rendererは同じmajorでminorが`N`以下のdocumentをacceptし、異なるmajorや未対応のhigher minorをrejectします。Unknown future syntaxを推測しません。 + +Specification releaseはsemantic versioningを使います。Majorはincompatible language change、minorはbackwards-compatible capability追加、patchはvalid sourceの意味を変えないclarification / errataです。そのためdocument directiveにpatchはありません。 + +## Rendererとcatalog identity + +通常のengine resultにはengine version、authored language version、theme catalog version、catalog content revisionが入ります。Sourceの`theme`はsymbolic identifierを選ぶだけで、package releaseをpinしたりremote dataを取得したりしません。 + +Exact pixel outputはlanguage compatibility promiseではありません。Theme metric、renderer version、font、canvas判断で位置が変わっても、node、group、relationship、label、kind、constraintは保持されます。 + +## 安全なsource boundary + +Stack stringはplain textです。Sourceに実行code、任意HTML/Markdown、CSS、SVG、import、macro、file path、network URLは置けません。Engineはauthored textをescapeし、validated catalog icon、local marker reference、accessible title/description metadataを埋め込んだstandalone SVGを生成します。 + +Rendered SVGにはscript、event handler、任意external reference、host font measurement、runtime I/Oがありません。Missing icon/theme nameはpath解決やregistry接続ではなくbundled fallbackを選びます。 + +## 現在のdelivery status + +- Browser Playgroundがsupport対象のpublic experienceです。 +- Public `@stack-sh/engine`がPlaygroundで使うtyped WebAssembly `format`、`check`、`render`を提供します。 +- Public `@stack-sh/language`がeditor highlight用のshared TextMate grammarと言語metadataを提供します。 +- Public [`stack-sh/cli`](https://github.com/stack-sh/cli)がnative `format`、`check`、`render`、provider-icon store操作を提供します。 + +Normative language contractは[`stack-sh/specification`](https://github.com/stack-sh/specification)、public theme catalogは[`stack-sh/theme`](https://github.com/stack-sh/theme)、engine behaviorは[`stack-sh/engine`](https://github.com/stack-sh/engine)が正本です。 diff --git a/content/site/ko/examples/index.md b/content/site/ko/examples/index.md new file mode 100644 index 0000000..e9908e6 --- /dev/null +++ b/content/site/ko/examples/index.md @@ -0,0 +1,7 @@ +# 예제 갤러리 + +작은 다이어그램에서 시작해 그룹, 레이아웃 제약, 클라우드 제공자 아이콘, 프로덕션 수준의 시스템으로 단계적으로 확장합니다. 아래의 모든 썸네일은 공개 Stack 명세에 고정된 canonical source에서 생성됩니다. + +Provider 예제의 아트워크는 caller-owned입니다. 브랜드 아이콘이 필요하면 표시된 아이콘 팩을 설치하세요. 팩이 없어도 같은 소스는 유효하며 Stack의 deterministic missing-icon fallback으로 렌더링됩니다. + + diff --git a/content/site/ko/guide/coding-agents.md b/content/site/ko/guide/coding-agents.md new file mode 100644 index 0000000..1c971eb --- /dev/null +++ b/content/site/ko/guide/coding-agents.md @@ -0,0 +1,27 @@ +# Coding agent 사용 + +Coding agent로 Stack을 읽고 쓰면 아키텍처 다이어그램을 검토 가능한 소스로 관리할 수 있습니다. 언어 레퍼런스를 읽고 CLI를 로컬에서 실행하므로 원격 MCP 서버가 필요하지 않습니다. + +## Skill 설치 + +`npx skills add stack-sh/cli`로 현재 프로젝트에 다이어그램 skill만 설치합니다. 사용자 전체에 설치하려는 경우에만 `-g`를 추가하고 다운로드한 지침을 검토하세요. CLI는 별도로 설치해야 합니다. 재현 가능한 설치에는 저장소를 clone하고 검토한 commit을 checkout한 다음 `npx skills add /absolute/path/to/cli --skill stack-diagrams`를 실행하세요. 설치 프로그램은 commit SHA를 원격 브랜치로 직접 지정하는 방식을 지원하지 않습니다. + +[SKILL.md](https://github.com/stack-sh/cli/blob/main/skills/stack-diagrams/SKILL.md) + +## 설치 없이 사용 + +다음 지침을 agent에게 전달하고 아키텍처 요구 사항을 추가하세요. HTTPS 문서를 읽고 로컬 명령을 실행할 수 있다면 skill 미지원 클라이언트에서도 사용할 수 있습니다. + +```text +{{agentPrompt}} +``` + +전체 [agent workflow](./agent-workflow)는 CLI skill과 같은 원본에서 생성됩니다. 정본 agent 지침은 영어입니다. 위 Markdown URL을 agent가 읽게 하거나 전체 지침을 복사하세요. + +## 레퍼런스와 업데이트 + +- [Examples](../examples/index) +- [Syntax](../language/syntax) +- [Diagnostics](../reference/diagnostics-and-limits) +- [Provider icons](./provider-icons) +- [Markdown index](https://stack-diagram.com/docs/llms.txt) diff --git a/content/site/ko/guide/getting-started.md b/content/site/ko/guide/getting-started.md new file mode 100644 index 0000000..7a4e7fa --- /dev/null +++ b/content/site/ko/guide/getting-started.md @@ -0,0 +1,86 @@ +# 시작하기 + +Stack을 가장 빠르게 사용하는 방법은 브라우저 [Playground](https://stack-diagram.com/)입니다. 포매터, 검증기, 레이아웃 엔진, SVG 렌더러가 WebAssembly로 로컬에서 실행되므로 명령 설치나 렌더링 API로의 소스 전송이 필요 없습니다. + +## 네이티브 CLI 설치 + +터미널 워크플로와 로컬 자동화에서는 `brew install stack-sh/tap/stack`으로 Stack이 관리하는 Homebrew formula를 설치합니다. 이 formula는 표준 Stack CLI {{cliVersion}} 릴리스 아카이브를 사용하며, Homebrew의 현재 Tier 1 요구 사항을 충족하는 Apple Silicon macOS와 arm64 / x86_64 glibc Linux를 지원합니다. 업그레이드는 Homebrew가 `brew upgrade stack-sh/tap/stack`으로 관리하며, formula를 제거해도 Stack 설정과 아이콘 저장소는 유지됩니다. 정확한 플랫폼 매트릭스, 직접 설치 방법 및 복구 정책은 [CLI 배포 계약](https://github.com/stack-sh/cli/blob/main/docs/distribution.md#homebrew-installation)을 참고하세요. + +## 첫 문서 작성 + +에디터 내용을 다음 예제로 바꿉니다. + +```stack +stack 1.0 + +diagram "Checkout" { + theme default + + node shopper "Shopper" { + kind actor + } + + group application "Application" { + node web "Web app" { + kind client + detail "React" + } + + node api "Checkout API" { + kind service + detail "Rust" + } + + layout { + direction right + order [web, api] + } + } + + node orders "Orders" { + kind database + detail "PostgreSQL" + } + + edge shopper -> web "HTTPS" { + kind request + } + + edge web -> api "JSON" { + kind request + } + + edge api -> orders "SQL" { + kind data + } + + layout { + direction right + order [shopper, application, orders] + } +} +``` + +## 렌더링하고 확인하기 + +**Run**을 선택하거나 Command/Ctrl + Enter를 누릅니다. 프리뷰에 독립형 SVG가 표시됩니다. 프리뷰를 선택해 크게 확인하고, 필요하면 **Download SVG**로 저장합니다. + +소스는 네 부분으로 구성됩니다. + +1. `stack 1.0`은 언어 버전을 선언합니다. +2. `diagram`은 하나의 제목과 전체 아키텍처를 포함합니다. +3. `node`와 `group`은 컴포넌트와 경계를 선언합니다. +4. `edge`는 관계를, `layout`은 제한된 배치 의도를 기록합니다. + +## 검사와 포맷 + +**Check**는 SVG를 바꾸지 않고 전체 검증과 레이아웃 파이프라인을 실행합니다. **Format**은 줄 주석과 의미를 보존하면서 문법적으로 유효한 소스를 표준 2칸 형식으로 다시 씁니다. + +문제가 있으면 진단에 심각도, 안정적인 코드, 위치, 소스 프레임, 예상 값과 가능한 수정 도움말이 표시됩니다. 진단을 선택하면 해당 소스 범위에 포커스합니다. + +## 다음으로 읽을 내용 + +- 어휘 규칙과 전체 문법은 [문서와 문법](../language/syntax)을 참고하세요. +- 컴포넌트와 경계는 [노드와 그룹](../language/nodes-and-groups)을 참고하세요. +- 관계와 배치 의도는 [엣지와 레이아웃](../language/edges-and-layout)을 참고하세요. +- 시각 시스템이나 명시적 아이콘을 고르기 전에 [테마와 아이콘](../language/themes-and-icons)을 읽으세요. diff --git a/content/site/ko/guide/playground.md b/content/site/ko/guide/playground.md new file mode 100644 index 0000000..5294da6 --- /dev/null +++ b/content/site/ko/guide/playground.md @@ -0,0 +1,42 @@ +# Playground 사용법 + +Playground는 [stack-diagram.com](https://stack-diagram.com/)의 공개 브라우저 consumer입니다. 에디터는 네이티브 텍스트 입력을 유지하고 공유 TextMate grammar가 문법 색상을 제공합니다. 검증, 포맷, 레이아웃, SVG는 항상 공개 Stack WebAssembly 엔진에서 생성됩니다. + +## 작업 + +| 작업 | 결과 | +| ---------------- | ----------------------------------------------------------------------------------- | +| **Format** | 문법적으로 유효한 소스를 표준화하고 주석을 보존합니다. 의미 오류는 계속 표시됩니다. | +| **Check** | 새 SVG를 만들지 않고 compiler, theme, icon, layout, routing을 검사합니다. | +| **Run** | 전체 파이프라인을 실행하고 렌더링을 막는 오류가 없으면 SVG를 갱신합니다. | +| **Download SVG** | 현재 독립형 SVG를 저장합니다. | + +Command/Ctrl + Enter로도 실행할 수 있습니다. 소스가 변경되면 이전 범위를 현재 결과로 보이지 않도록 오래된 진단을 지웁니다. + +## 진단 읽기 + +오류 결과에는 다음 정보가 포함될 수 있습니다. + +```text +error[STK2002] at 4:22 +4 | layout { direction hoo } + | ^^^ unexpected layout direction 'hoo' + = expected: right, down + = help: use 'right' for horizontal flow or 'down' for vertical flow +``` + +진단이나 관련 정보를 선택하면 대응하는 소스에 포커스합니다. 오류는 성공적인 렌더링을 막습니다. 경고는 fallback 또는 가독성 문제를 설명하며 SVG와 함께 반환될 수 있습니다. + +## 독립된 두 색상 설정 + +헤더의 색상 모드는 Playground와 에디터 표현만 바꿉니다. `theme dark` 같은 소스 문장은 생성된 다이어그램을 바꿉니다. 사이트를 다크 모드로 전환해도 다이어그램 테마를 다시 해석하거나 변경하지 않도록 둘은 독립적입니다. + +## 브라우저 동작과 데이터 + +Playground는 공개 WebAssembly 모듈을 불러온 뒤 브라우저에서 동기식 `format`, `check`, `render`를 실행합니다. 엔진 자체는 파일을 읽거나 네트워크 서비스에 접속하거나 DOM, 시계, 호스트 폰트 측정을 사용하지 않습니다. + +현재 Playground에는 계정, 클라우드 저장, 협업, 유료 테마가 없습니다. 보관할 소스와 SVG를 다운로드하세요. + +## 접근성 + +에디터는 네이티브 캐럿, 선택, 클립보드, 실행 취소, 키보드, IME 동작을 유지합니다. 진단에서 소스 범위로 이동할 수 있습니다. 프리뷰는 텍스트 대체를 제공하고 키보드로 접근 가능한 다이얼로그에서 열립니다. 인터페이스는 320px 레이아웃, 라이트/다크 대비, 보이는 포커스, reduced motion을 지원합니다. diff --git a/content/site/ko/guide/provider-icons.md b/content/site/ko/guide/provider-icons.md new file mode 100644 index 0000000..66defcc --- /dev/null +++ b/content/site/ko/guide/provider-icons.md @@ -0,0 +1,118 @@ +# 클라우드 제공자 아이콘 + +Stack에는 제공자 중립적인 core icon catalog가 포함됩니다. AWS, Google Cloud, Azure 및 주요 개발·협업 도구 그림은 사용자가 관리하는 icon store에 저장된 provider pack으로 사용할 수 있습니다. + +## 사용 가능한 제공자 catalog + +감사 완료 catalog에는 총 1,051개 ID가 있습니다. AWS Architecture Icons 305개, Google Cloud 제품·category icon 45개, Azure service icon 639개, 주요 tool icon 62개입니다. Tool catalog에는 GitHub, GitHub Actions, Notion, Linear, Atlassian, Jira, Confluence, Docker, Kubernetes, Terraform, Datadog, Grafana, Sentry 등이 포함됩니다. + +Provider 카드를 선택하면 import 명령을 확인할 수 있습니다. 전체 catalog를 검색·filter할 수 있으며 작은 화면에서도 안정적으로 보이도록 100개씩 표시합니다. + + + +Provider pack은 그림을 제공합니다. Stack source의 node `kind`가 계속 의미적 스타일과 레이아웃을 결정합니다. + +## 빠른 시작 + +다이어그램에서 사용하는 각 provider를 한 번씩 import합니다. `--accept-terms`는 연결된 provider 및 brand terms를 검토하고 동의했음을 기록합니다. + +```sh +$ stack icons import gcp --accept-terms +$ stack icons import simple-icons --accept-terms +$ stack render architecture.stack -o architecture.svg +``` + +CLI는 감사 완료 공식 archive를 다운로드하고 전체 SHA-256을 검증하며 선택한 SVG를 sanitize한 뒤 처리된 provider pack을 shared icon store에 기록합니다. Google Cloud 제품과 category 그림은 하나의 `gcp` 명령으로 함께 import됩니다. + +## CLI에서 provider icon 사용하기 + +하나의 Stack 파일에서 여러 provider를 사용할 수 있습니다. 다음 예제는 Google Cloud의 Cloud Run과 Simple Icons의 GitHub를 함께 사용합니다. + +```stack +stack 1.0 + +diagram "Deploy from GitHub to Cloud Run" { + node repository "GitHub" { + kind external + icon "simple-icons:github" + } + + node service "Cloud Run" { + kind service + icon "gcp:cloud-run" + } + + edge repository -> service "Deploy" { + kind dependency + } +} +``` + +두 pack을 import한 뒤 표준 render 명령이 모두 찾습니다. + +```sh +$ stack render architecture.stack -o architecture.svg --notice architecture.NOTICE.md +``` + +## Shared icon store + +기본 icon store는 `$XDG_CONFIG_HOME/stack/icons`입니다. `XDG_CONFIG_HOME`이 설정되지 않았으면 `$HOME/.config/stack/icons`를 사용합니다. + +```text +icons/ + aws/ + gcp/ + azure/ + simple-icons/ +``` + +`$XDG_CONFIG_HOME/stack/config.yaml`에서 절대 경로를 설정해 shared 위치를 변경할 수 있습니다. + +```yaml +default_icons_path: /absolute/path/to/stack-icons +``` + +이 위치는 `stack icons import`와 `stack render`에서 함께 사용됩니다. + +## Playground에서 provider icon 사용하기 + +**Icons**를 열고 `stack/icons` 폴더를 선택하면 Playground가 store 안의 인식 가능한 provider directory를 모두 불러옵니다. 불러온 그림을 검색하고 항목을 선택해 ID를 Stack source로 복사할 수 있습니다. + +선택한 pack은 현재 브라우저 탭에서 처리됩니다. 생성한 다이어그램에 provider 그림이 있으면 SVG 다운로드 옆의 **Notice**에서 source, terms 및 사용 icon 기록을 확인할 수 있습니다. + +## Icon을 프로젝트와 함께 관리하기 + +`-o`를 사용해 import한 pack을 repository와 함께 commit할 project directory에 둡니다. + +```sh +$ stack icons import gcp --accept-terms -o .stack-icons +$ stack icons import simple-icons --accept-terms -o .stack-icons +``` + +Render할 때 같은 icon-store root를 `--provider-pack`으로 전달합니다. + +```sh +$ stack render architecture.stack \ + --provider-pack .stack-icons \ + -o architecture.svg \ + --notice architecture.NOTICE.md +``` + +## Icon ID 찾기 + +CLI 또는 이 페이지에서 catalog를 검색할 수 있습니다. + +```sh +$ stack icons list +$ stack icons list aws s3 +$ stack icons list azure database +$ stack icons list simple-icons github +``` + +CLI 출력에는 `ID`, `PRODUCT`, `CATEGORY`, 권장 `KIND`가 포함됩니다. `gcp:cloud-run`, `simple-icons:github` 같은 namespaced ID가 해당 pack의 그림을 선택합니다. + +## 검증, terms 및 notice + +CLI catalog는 각 공식 HTTPS archive URL, release, 전체 SHA-256, 허용된 entry path, terms URL, review date를 pin합니다. Import는 archive와 SVG 크기를 제한하고 active 및 external SVG content를 sanitize하며 pack을 atomic하게 기록합니다. + +각 pack에는 `NOTICE.md`가 포함됩니다. `stack render --notice `는 실제 pack revision, source release, terms URL, attribution, non-endorsement text 및 사용 icon ID를 기록합니다. Catalog는 각 provider의 공식 source와 terms, Simple Icons mark의 brand source와 guideline도 연결합니다. diff --git a/content/site/ko/guide/what-is-stack.md b/content/site/ko/guide/what-is-stack.md new file mode 100644 index 0000000..a5af2c5 --- /dev/null +++ b/content/site/ko/guide/what-is-stack.md @@ -0,0 +1,51 @@ +# Stack이란? + +Stack은 정적인 소프트웨어 아키텍처와 기술 스택 다이어그램을 위한 작은 선언형 언어입니다. UTF-8 `.stack` 파일에 컴포넌트, 경계, 관계를 작성하고 좌표, 간격, 경로, 타이포그래피, 시각 표현은 렌더러가 결정합니다. + +이 분리는 소스를 간결하고 리뷰하기 쉽게 만들며 버전 관리에도 적합하게 합니다. 같은 문서를 드로잉 명령으로 바꾸지 않고 호환 도구에서 포맷, 검사, 렌더링할 수 있습니다. + +## 기본 모델 + +모든 문서는 언어 버전과 정확히 하나의 다이어그램을 포함합니다. 다이어그램에는 노드와 선택적인 그룹, 엣지, 테마, 레이아웃 의도가 들어갑니다. + +```stack +stack 1.0 + +diagram "Service architecture" { + node client "Web app" { + kind client + } + + node api "API" { + kind service + detail "Order orchestration" + } + + edge client -> api "HTTPS" { + kind request + } +} +``` + +이 소스는 클라이언트가 서비스를 호출한다는 의미를 나타냅니다. 박스 위치나 화살표 경로는 지정하지 않습니다. + +## Stack의 설계 목표 + +- **간결한 작성:** 이름이 있는 노드와 엣지만으로 유용한 다이어그램을 만듭니다. +- **예측 가능한 생성:** 사람과 언어 모델이 같은 개념을 하나의 제한된 방식으로 안정적으로 표현합니다. +- **의미 기반 소스:** 픽셀이 아니라 토폴로지와 의도를 기록합니다. +- **정돈된 출력:** 렌더러가 일관된 시각 시스템을 소유합니다. +- **실행 가능한 오류:** 진단은 소스 범위, 예상 값, 수정 도움말, 관련 선언을 제공할 수 있습니다. +- **안전한 임베딩:** 소스는 코드를 실행하거나 임의 에셋을 가져오거나 HTML/SVG를 삽입할 수 없습니다. + +## Stack이 아닌 것 + +Stack 1.0은 범용 그래프 언어, 픽셀 단위 캔버스, 인프라 정의, 실행 가능한 프로그래밍 언어가 아닙니다. 변수, import, macro, 조건문, CSS, 좌표, 임의 URL, 내장 HTML이 없으며 sequence, state-machine, class, ER, 전체 UML 표기법도 아닙니다. + +큰 시스템은 하나에 압축하지 말고 여러 개의 집중된 다이어그램으로 설명하세요. Stack에는 가독성을 위한 요소 제한이 있습니다. + +## 처리 모델 + +도구는 문서 디코딩과 파싱, 식별자와 기본값 해결, 의미 검증, 테마와 아이콘 해결, 레이아웃, 렌더링 순서로 처리합니다. 소스 오류는 렌더링을 중단합니다. 선택적 테마나 아이콘 누락, 만족할 수 없는 레이아웃 힌트는 경고가 되어 fallback 다이어그램을 반환할 수 있습니다. + +작성자를 위한 모든 구문은 [언어 페이지](../language/syntax), 호환성과 신뢰 경계는 [버전과 안전성](../reference/versioning-and-safety)에서 설명합니다. diff --git a/content/site/ko/index.md b/content/site/ko/index.md new file mode 100644 index 0000000..13a1514 --- /dev/null +++ b/content/site/ko/index.md @@ -0,0 +1,27 @@ +--- +layout: home + +hero: + name: Stack + text: 아키텍처를 소스로. + tagline: 작은 의미 기반 문서를 작성하면 좌표나 박스별 스타일을 지정하지 않아도 일관되고 접근 가능한 아키텍처 다이어그램을 만들 수 있습니다. + image: + light: /favicon.svg + dark: /favicon.svg + alt: Stack 로고 + actions: + - theme: brand + text: 시작하기 + link: /ko/guide/getting-started + - theme: alt + text: Playground 열기 + link: https://stack-diagram.com/ + +features: + - title: 시스템 설명 + details: 노드, 그룹, 관계, 레이아웃 의도를 간결하고 읽기 쉬운 .stack 파일로 유지합니다. + - title: 의미의 이식성 + details: 버전이 있는 언어와 구조화된 진단이 아키텍처 의미를 렌더러 선택과 분리합니다. + - title: 안전한 렌더링 + details: 엔진은 스크립트, 임의 HTML, 네트워크 에셋이 없는 독립형 SVG를 생성합니다. +--- diff --git a/content/site/ko/language/edges-and-layout.md b/content/site/ko/language/edges-and-layout.md new file mode 100644 index 0000000..e32e28e --- /dev/null +++ b/content/site/ko/language/edges-and-layout.md @@ -0,0 +1,78 @@ +# 엣지와 레이아웃 + +엣지는 노드 사이의 관계를 설명합니다. 레이아웃 블록은 좌표나 드로잉 원시 요소를 노출하지 않고 소량의 배치 의도를 표현합니다. + +## 엣지 방향 + +엣지는 서로 다른 두 노드를 연결합니다. 전방 참조는 유효하지만 self-edge와 그룹 endpoint는 유효하지 않습니다. + +| 연산자 | 의미 | +| ------ | ------------------------------------------- | +| `->` | 왼쪽 노드에서 오른쪽 노드로 향하는 관계 | +| `<->` | 양방향 대칭인 하나의 관계 | +| `--` | 방향이 없거나 의도적으로 지정하지 않은 연관 | + +`<->`는 독립적으로 라벨을 붙일 수 있는 두 엣지의 축약형이 아닙니다. + +## 엣지 종류와 라벨 + +선택적 라벨은 프로토콜, 이벤트, 명령, 데이터셋, 목적을 나타내며 1~40 Unicode scalar입니다. 선택적 `kind`는 라벨과 별개로 관계를 설명하고 기본값은 `flow`입니다. + +| Kind | 의도한 의미 | +| ------------ | --------------------------------- | +| `flow` | 일반 runtime 또는 conceptual flow | +| `request` | 동기 요청 또는 호출 | +| `event` | 비동기 메시지 또는 이벤트 전달 | +| `data` | 데이터 이동, 복제, 읽기, 쓰기 | +| `dependency` | 빌드, 배포, 운영 의존성 | + +```stack +stack 1.0 + +diagram "Relationships" { + node web "Web app" { + kind client + } + + node api "API" + node queue "Events" { + kind queue + } + + edge web -> api "HTTPS" { + kind request + } + + edge api -> queue "OrderPlaced" { + kind event + } +} +``` + +서로 다른 관계를 표현한다면 같은 노드 쌍에 여러 엣지를 둘 수 있습니다. endpoint, 연산자, 라벨, 유효 kind가 모두 같은 정확한 중복은 유효하지 않습니다. `<->`와 `--` 중복 비교에서는 endpoint 순서를 무시합니다. + +## 레이아웃 스코프 + +다이어그램이나 그룹에는 하나의 `layout` 블록을 둘 수 있습니다. 그룹 블록은 직접 자식만, 다이어그램 블록은 다이어그램의 직접 자식만 영향을 줍니다. `rank`와 `order` 참조는 같은 스코프의 서로 다른 직접 자식을 최소 두 개 지정해야 합니다. + +레이아웃에서 직접 자식 그룹은 하나의 항목입니다. 서로 다른 그룹의 하위 노드 연결은 직접 자식 항목 사이 연결이 되므로 그룹이 엣지 endpoint가 아니어도 상위 레이아웃으로 그룹을 배치할 수 있습니다. + +## Direction, rank, order + +```stack +layout { + direction right + rank same [web, worker] + order [web, worker, database] +} +``` + +- `direction right`는 왼쪽에서 오른쪽, `direction down`은 위에서 아래 진행을 선호합니다. 강한 힌트지만 모든 엣지의 기하 방향을 보장하지 않으며 중첩 그룹에 상속되지 않습니다. +- `rank same [a, b]`는 나열된 직접 자식을 같은 레이아웃 rank에 두는 제약입니다. 한 스코프에서 같은 자식을 두 same-rank 문장에 넣을 수 없습니다. +- `order [a, b]`는 상대 순서 힌트입니다. 오른쪽 방향에서는 위에서 아래, 아래 방향에서는 왼쪽에서 오른쪽, 자동 레이아웃에서는 선택한 cross-axis를 따릅니다. 다른 자식은 생략할 수 있습니다. + +렌더러는 포함, same-rank 제약, 가독성, 출력 경계를 지키기 위해 `order`를 벗어날 수 있습니다. 진단을 지원하는 도구는 이때 `STK4001`을 내야 합니다. + +## 렌더러가 결정하는 것 + +Stack에는 좌표, 크기, 포트, 경로, 색상, 폰트, 줄바꿈, z-index가 없습니다. 렌더러는 겹침을 막고 포함과 방향을 보존하며 라벨을 읽기 쉽게 유지하고 노드 내부를 피해 엣지를 배치하며 의미 내용을 자르지 않고 캔버스를 확장합니다. diff --git a/content/site/ko/language/formatting.md b/content/site/ko/language/formatting.md new file mode 100644 index 0000000..68e9d41 --- /dev/null +++ b/content/site/ko/language/formatting.md @@ -0,0 +1,58 @@ +# 표준 포매팅 + +Stack은 어휘와 문법이 유효한 모든 문서에 하나의 표준 바이트 표현을 정의합니다. 포매팅은 언어 버전, 의미, 모든 줄 주석을 바꾸지 않고 diff를 일관되게 만듭니다. + +## 포맷 가능한 소스 + +포매터는 BOM 없는 UTF-8을 받습니다. 어휘나 문법 오류가 있으면 진단만 반환하고 부분적으로 다시 쓴 소스를 반환하지 않습니다. 문법이 유효하면 의미나 복잡도 진단이 있어도 포맷할 수 있으며, 포맷 성공이 다이어그램 유효성을 뜻하지는 않습니다. + +## 표준 출력 + +표준 소스는 다음을 따릅니다. + +- BOM 없는 UTF-8을 사용합니다. +- 모든 줄바꿈을 LF로 정규화합니다. +- 블록 레벨마다 ASCII 공백 두 칸을 사용하고 포매팅 탭을 쓰지 않습니다. +- 줄 끝에 포매팅 공백이 없습니다. +- 정확히 하나의 LF로 끝납니다. +- 여는 중괄호는 선언 또는 `layout` 줄에, 닫는 중괄호는 별도 줄에 둡니다. +- 버전과 다이어그램, 인접한 body member 사이에 빈 줄 하나를 둡니다. +- 속성과 레이아웃 문장 사이에는 빈 줄을 두지 않습니다. + +```stack +stack 1.0 + +diagram "Title" { + theme dark + + node client "Client" + + node api "API" { + kind service + detail "Public API" + } + + edge client -> api "HTTPS" { + kind request + } + + layout { + direction right + order [client, api] + } +} +``` + +## 순서와 목록 + +포매터는 다이어그램과 그룹 member, 노드와 엣지 속성, 레이아웃 문장, 목록 식별자의 작성 순서를 보존합니다. 그룹화하거나 정렬하지 않습니다. 목록은 한 줄에 두고 쉼표 뒤 공백 하나, 대괄호 안쪽 공백 없음, 마지막 쉼표 없음으로 출력합니다. + +## 문자열 + +유효 문자열을 디코드해 Unicode normalization 없이 UTF-8로 직접 출력합니다. 따옴표와 역슬래시는 이스케이프하고 표준 출력은 `\uXXXX`를 사용하지 않습니다. 예를 들어 `"API \u56F3 \uD83D\uDE80"`는 `"API 図 🚀"`가 됩니다. + +## 주석 + +모든 줄 주석과 순서를 보존합니다. 뒤따르는 주석은 앞 token 뒤에 공백 하나를 두고 유지합니다. 독립 줄 주석은 token gap을 보존하며 뒤따르는 member, 문장, 속성 바로 앞에 둡니다. 구문 내부 주석은 이어지는 줄을 강제할 수 있고 이는 일반적인 한 줄 규칙의 유일한 예외입니다. + +표준 소스를 다시 포맷하면 바이트 단위로 같은 결과가 나와야 합니다. Normalized IR이 존재할 때 포맷 전후 소스는 의미가 같은 IR을 생성해야 합니다. diff --git a/content/site/ko/language/nodes-and-groups.md b/content/site/ko/language/nodes-and-groups.md new file mode 100644 index 0000000..a957a82 --- /dev/null +++ b/content/site/ko/language/nodes-and-groups.md @@ -0,0 +1,67 @@ +# 노드와 그룹 + +노드는 참조 가능한 아키텍처 엔티티이고 그룹은 라벨이 있는 포함 경계입니다. 둘을 사용해 다이어그램에 보이는 컴포넌트와 스코프를 설명합니다. + +## 노드 + +노드에는 전역으로 고유한 식별자와 보이는 라벨이 필요합니다. 식별자는 엣지와 레이아웃 문장에서 참조하지만 렌더링되지 않습니다. 라벨은 1~60 Unicode scalar입니다. + +```stack +stack 1.0 + +diagram "Node example" { + node api "Public API" { + kind service + detail "Order orchestration" + } +} +``` + +서로 다른 엔티티는 같은 보이는 라벨을 사용할 수 있지만 위치에 의존하지 않아도 이해되는 이름을 권장합니다. 노드 블록에서는 `kind`, `icon`, `detail`을 중복할 수 없습니다. + +## 노드 종류 + +`kind`는 큰 범주의 아키텍처 의미를 제공하고 테마가 관리하는 모양과 fallback 아이콘을 선택합니다. 기본값은 `service`입니다. + +| Kind | 의도한 의미 | +| ---------- | ---------------------------------------------------- | +| `actor` | 사람, 역할, 팀, 자율 참여자 | +| `client` | 브라우저, 모바일/데스크톱 앱, 디바이스 등 클라이언트 | +| `service` | 장기 실행 앱, API, 게이트웨이, 일반 컴포넌트 | +| `function` | 온디맨드 또는 serverless 컴퓨팅 단위 | +| `worker` | 백그라운드 프로세서나 예약 작업 | +| `database` | 지속적이고 조회 가능한 데이터 저장소 | +| `cache` | 내용을 폐기하거나 재생성할 수 있는 데이터 저장소 | +| `queue` | 비동기 전달용 큐, 스트림, 버스, broker | +| `storage` | Blob, object, file, archive storage | +| `external` | 아키텍처 제어 경계 밖의 시스템 | + +Kind는 벤더별 모양이 아닌 의미 범주입니다. 호스팅된 PostgreSQL도 `database`이며 기술 이름은 `detail`에 작성합니다. + +## 라벨과 상세 + +`detail`은 선택적인 두 번째 표시 줄이며 1~80 Unicode scalar입니다. `"Next.js"`, `"PostgreSQL 17"`, `"Order orchestration"`처럼 한 기술이나 짧은 책임을 적습니다. 모든 렌더링에서 보이며 tooltip만으로 축소할 수 없습니다. + +라벨과 상세는 일반 텍스트입니다. 명시적 `icon`은 노드를 꾸미지만 kind, identity, 접근성 라벨을 바꾸지 않습니다. [테마와 아이콘](./themes-and-icons)도 참고하세요. + +## 그룹 + +그룹에는 전역으로 고유한 식별자, 1~60 Unicode scalar 라벨, 최소 하나의 하위 노드가 필요합니다. 노드, 중첩 그룹, 하나의 레이아웃 블록을 포함할 수 있습니다. + +```stack +stack 1.0 + +diagram "Boundaries" { + group platform "Platform" { + group data "Data layer" { + node primary "Primary database" { + kind database + } + } + } +} +``` + +그룹은 다이어그램 아래 최대 세 레벨까지 중첩할 수 있습니다. 노드는 가장 가까운 그룹과 모든 상위 그룹에 속합니다. 선언을 재사용할 수 없으므로 한 노드가 두 독립 그룹에 동시에 속할 수 없습니다. + +엣지는 항상 다이어그램 스코프에서 선언하며 노드만 endpoint가 될 수 있습니다. 그룹은 암시적 노드나 관계를 만들지 않습니다. 라벨로 시스템, 도메인, 네트워크, 배포 영역, 팀 같은 경계의 의미를 설명합니다. 포함만으로 runtime isolation, security, ownership, deployment semantics를 의미하지 않습니다. diff --git a/content/site/ko/language/syntax.md b/content/site/ko/language/syntax.md new file mode 100644 index 0000000..c952a72 --- /dev/null +++ b/content/site/ko/language/syntax.md @@ -0,0 +1,95 @@ +# 문서와 문법 + +Stack 소스는 의도적으로 작게 설계되었습니다. 이 페이지는 draft Stack 1.0의 전체 어휘 구조와 문법을 설명합니다. + +## 문서 구조 + +문서는 BOM이 없는 UTF-8 `.stack` 파일 하나입니다. LF와 CRLF는 같은 의미입니다. 첫 non-comment token은 버전 지시문이어야 하며, 그 뒤에는 정확히 하나의 다이어그램만 있고 추가 선언은 올 수 없습니다. + +```stack +// One file, one diagram. +stack 1.0 + +diagram "Example" { + node api "API" +} +``` + +다이어그램 제목은 필수이며 1~80 Unicode scalar입니다. 시작과 끝에 Unicode 공백을 둘 수 없습니다. 다이어그램에는 노드가 적어도 하나 필요합니다. + +## 주석과 공백 + +공백, 탭, 줄바꿈은 token을 구분하지만 그 밖의 의미는 없습니다. 줄 주석은 `//`에서 줄 끝까지이며 공백이 허용되는 곳에 쓸 수 있습니다. 블록 주석은 지원하지 않습니다. + +포맷 자체는 의미가 없지만 표준 포매터는 [표준 포매팅](./formatting)에 정의된 일관된 표현을 생성합니다. + +## 식별자 + +노드, 그룹, 테마, 참조 식별자는 다음과 일치합니다. + +```text +[a-z][a-z0-9_-]* +``` + +1~64 ASCII 문자이며 대소문자를 구분하고 화면에 표시되지 않습니다. 노드와 그룹은 하나의 전역 namespace를 공유합니다. 키워드는 문맥적이므로 식별자 위치에도 쓸 수 있지만 읽기 어려운 이름은 피하세요. + +아이콘 식별자는 인용 문자열이며 디코드된 값이 `[a-z0-9][a-z0-9-]*`와 일치하는 1~64 ASCII 문자입니다. 유효 테마 안에서 해결됩니다. + +## 문자열 + +문자열은 큰따옴표를 사용하고 Unicode를 직접 포함할 수 있습니다. 이스케이프는 세 종류뿐입니다. + +| 이스케이프 | 의미 | +| ---------- | ----------------- | +| `\"` | 큰따옴표 | +| `\\` | 역슬래시 | +| `\uXXXX` | Unicode code unit | + +디코드된 문자열에는 줄바꿈, 탭, 제어 문자, 짝이 없는 surrogate를 넣을 수 없습니다. 제목, 라벨, 상세의 시작과 끝에는 Unicode 공백을 둘 수 없습니다. 문자열은 항상 일반 텍스트이며 Markdown이나 HTML로 해석되지 않습니다. + +## 전체 문법 + +```text +document = version-directive, diagram-declaration, EOF ; +version-directive = "stack", integer, ".", integer ; +diagram-declaration + = "diagram", string, "{", { diagram-member }, "}" ; +diagram-member = node-declaration | group-declaration | edge-declaration + | theme-statement | layout-block ; +theme-statement = "theme", identifier ; +group-declaration = "group", identifier, string, "{", { group-member }, "}" ; +group-member = node-declaration | group-declaration | layout-block ; +node-declaration = "node", identifier, string, [ node-block ] ; +node-block = "{", node-property, { node-property }, "}" ; +node-property = "kind", node-kind | "icon", string | "detail", string ; +node-kind = "actor" | "client" | "service" | "function" | "worker" + | "database" | "cache" | "queue" | "storage" | "external" ; +edge-declaration = "edge", identifier, edge-operator, identifier, + [ string ], [ edge-block ] ; +edge-operator = "->" | "<->" | "--" ; +edge-block = "{", edge-property, { edge-property }, "}" ; +edge-property = "kind", edge-kind ; +edge-kind = "flow" | "request" | "event" | "data" | "dependency" ; +layout-block = "layout", "{", layout-statement, + { layout-statement }, "}" ; +layout-statement = direction-statement | rank-statement | order-statement ; +direction-statement + = "direction", ( "right" | "down" ) ; +rank-statement = "rank", "same", identifier-list ; +order-statement = "order", identifier-list ; +identifier-list = "[", identifier, ",", identifier, + { ",", identifier }, "]" ; +integer = "0" | nonzero-digit, { digit } ; +``` + +## 문맥적 키워드 + +Stack 1.0은 문법 위치에 따라 다음 단어를 인식합니다. + +```text +stack diagram group node edge theme layout kind icon detail direction +rank same order right down actor client service function worker +database cache queue storage external flow request event data dependency +``` + +알 수 없는 선언, 속성, enum 값, 연산자는 오류입니다. 도구는 작성자의 의미를 잃은 채 그럴듯한 다이어그램을 만들 수 있는 문법을 조용히 무시하지 않습니다. diff --git a/content/site/ko/language/themes-and-icons.md b/content/site/ko/language/themes-and-icons.md new file mode 100644 index 0000000..7ec9657 --- /dev/null +++ b/content/site/ko/language/themes-and-icons.md @@ -0,0 +1,126 @@ +# 테마와 아이콘 + +테마는 다이어그램 레벨에서 렌더러가 관리하는 시각 시스템의 기호 참조입니다. 아이콘은 해당 테마 안에서 해결되는 논리 이름입니다. 둘 다 다이어그램 의미를 바꾸지 않습니다. + +## 테마 선택 + +다이어그램 바로 안에 `theme` 문장을 최대 하나 추가합니다. + +```stack +stack 1.0 + +diagram "Dark architecture" { + theme dark + + node api "API" +} +``` + +생략하면 `default`를 사용합니다. Draft Stack 1.0은 코어 catalog에 다음 테마를 요구합니다. + +| Theme | 용도 | +| --------- | ----------------------------------------------------------- | +| `default` | 일반 아키텍처 다이어그램을 위한 균형 잡힌 blue-gray surface | +| `light` | 밝은 문서를 위한 따뜻한 중립 surface | +| `dark` | 어두운 캔버스를 위한 고대비 차가운 surface | + +소스는 식별자만 선택하며 catalog package 버전을 고르지 않습니다. 렌더 metadata는 사용한 시각 데이터를 식별하도록 catalog 버전과 content revision을 기록합니다. + +생성 다이어그램 테마는 Playground의 라이트/다크 UI와 독립적입니다. 테마는 palette, typography metric, surface, icon, connector, background를 바꿀 수 있지만 노드, 그룹, 엣지, 라벨, kind, 방향, 레이아웃 제약을 숨기거나 바꿀 수 없습니다. + +## Fallback 동작 + +세 코어 테마는 렌더러 필수 리소스입니다. 설치된 catalog에 없는 non-core 테마는 `STK6001` 경고 후 `default`로 렌더링합니다. 소스에 테마 식별자가 있다고 네트워크에서 테마를 가져오지 않습니다. + +테마 식별자는 일반 Stack 식별자 문법을 사용합니다. 한 번 등록된 식별자는 폐기된 뒤에도 다른 테마에 재할당할 수 없습니다. + +## Kind fallback 아이콘 + +각 테마는 모든 노드 kind에 fallback을 제공합니다. `icon`을 생략하면 렌더러가 이를 사용합니다. + +| Node kind | 현재 논리 fallback 아이콘 | +| ---------- | ------------------------- | +| `actor` | `kind-actor` | +| `client` | `kind-client` | +| `service` | `kind-service` | +| `function` | `kind-function` | +| `worker` | `kind-worker` | +| `database` | `kind-database` | +| `cache` | `kind-cache` | +| `queue` | `kind-queue` | +| `storage` | `kind-storage` | +| `external` | `kind-external` | + +현재 공개 코어 catalog는 `default`, `light`, `dark`에 이 열 개 식별자를 포함하지만 `postgresql`, `aws`, `github` 같은 벤더 아이콘은 아직 없습니다. 대부분의 문서는 의미에 맞는 `kind`를 선택하고 `icon`을 생략하세요. + +## 명시적 아이콘 + +명시적 아이콘은 인용된 논리 식별자입니다. + +```stack +stack 1.0 + +diagram "Explicit icon" { + node gateway "Public API" { + kind service + icon "api" + } +} +``` + +아이콘은 노드를 꾸밀 뿐 `service` kind, identity, label, 접근성 설명을 바꾸지 않습니다. 테마마다 색상과 그림은 달라질 수 있지만 같은 식별자는 같은 논리 대상을 나타냅니다. + +## First-party 아이콘 catalog + +무료 코어 catalog는 `default`, `light`, `dark`에 다음 provider-neutral 명시적 아이콘을 제공합니다. + +| ID | Stable subject | 주요 용도 | +| --------------- | --------------------------------- | -------------------------------- | +| `api` | Application programming interface | 공개 또는 내부 API | +| `web` | Web application | 브라우저용 Web 경험 | +| `mobile` | Mobile application | iOS 또는 Android 클라이언트 | +| `desktop` | Desktop application | 네이티브 데스크톱 클라이언트 | +| `server` | Server host | 가상 머신 또는 물리 호스트 | +| `container` | Application container | 컨테이너화된 워크로드 | +| `cluster` | Compute cluster | 오케스트레이션된 컴퓨팅 그룹 | +| `cloud` | Cloud environment | provider-neutral 클라우드 경계 | +| `scheduler` | Scheduled execution | Cron 작업 또는 예약 실행 | +| `webhook` | Webhook endpoint | 인바운드 또는 아웃바운드 콜백 | +| `identity` | Identity and access | 인증 또는 권한 부여 | +| `observability` | Observability system | 메트릭, 로그 또는 트레이스 | +| `gateway` | Network gateway | 공용 또는 사설 네트워크 진입점 | +| `load-balancer` | Load balancer | 트래픽 분산 | +| `dns` | Domain name service | 호스트 이름 및 서비스 검색 | +| `cdn` | Content delivery network | 엣지 콘텐츠 전송 | +| `firewall` | Network firewall | 네트워크 접근 경계 | +| `network` | Network topology | 일반 네트워크 또는 서브넷 | +| `event` | Discrete event | 개별 도메인 또는 시스템 이벤트 | +| `stream` | Event stream | 지속적인 이벤트 또는 데이터 흐름 | +| `search` | Search service | 인덱싱 및 쿼리 시스템 | +| `analytics` | Analytics system | 보고 또는 데이터 분석 | +| `repository` | Source code repository | 소스 코드 및 버전 관리 | +| `pipeline` | Delivery pipeline | 빌드, 테스트 또는 배포 흐름 | +| `secret` | Secret or credential | 비밀, 키 또는 자격 증명 | +| `document` | Document or knowledge base | 문서 및 지식 기반 | +| `task` | Task or issue tracker | 작업, 티켓 또는 이슈 추적 | +| `chat` | Chat or messaging tool | 팀 채팅 또는 메시징 | +| `email` | Email delivery | 이메일 전송 또는 받은편지함 | +| `ai` | Artificial intelligence system | AI 모델 또는 추론 서비스 | + +아래 미리보기를 라이트와 다크로 전환하여 실제 출력을 비교할 수 있습니다. 각 이미지는 공개된 `@stack-sh/engine@0.7.0`이 로컬에서 렌더링하며 문서에 Theme SVG 에셋을 복제하지 않습니다. 문법 행을 선택하면 복사됩니다. + + + +의미를 나타내는 `kind`와 명시적 아이콘은 독립적으로 선택합니다. 예를 들어 `icon "web"`은 `client` 또는 `service` 노드를 꾸밀 수 있지만 노드의 의미를 바꾸지 않습니다. + +## 누락 아이콘과 벤더 아이콘 + +코어 catalog에는 현재 `postgresql`, `aws`, `github`, `docker` 같은 벤더 또는 프로젝트 마크가 없습니다. 유효 테마가 작성한 아이콘 식별자를 제공하지 않으면 노드 kind fallback으로 계속 렌더링하고 `STK5001` 경고를 냅니다. + +위 표의 provider-neutral 아이콘을 사용하거나 kind fallback만으로 역할이 명확하면 `icon`을 생략하세요. 벤더 마크는 에셋별 license, 재배포 및 trademark review를 완료해야 별도 catalog에 포함할 수 있습니다. + +## Catalog와 에셋 안전성 + +공개 `stack-sh/theme` catalog가 palette, 결정적 폰트 metric, node-kind visual, connector, icon metadata, SVG bytes, provenance, 재배포 권한을 소유합니다. Catalog 에셋은 렌더러에 번들되며 작성한 식별자는 파일 경로나 URL로 취급하지 않습니다. + +SVG 검증은 script, event handler, nested SVG, unsafe reference, data/network URL, style attribute, allowlist 밖의 요소와 속성을 거부합니다. 아이콘만 의미의 유일한 단서가 될 수 없으며 라벨과 비색상 구분을 유지해야 합니다. diff --git a/content/site/ko/reference/diagnostics-and-limits.md b/content/site/ko/reference/diagnostics-and-limits.md new file mode 100644 index 0000000..bc58def --- /dev/null +++ b/content/site/ko/reference/diagnostics-and-limits.md @@ -0,0 +1,58 @@ +# 진단과 제한 + +Stack 진단은 콘솔 문장이 아닌 구조화된 결과입니다. 안정적인 코드, `error` 또는 `warning` 심각도, 1부터 시작하는 end-exclusive 소스 범위, 간결한 메시지, 정렬된 `expected` 목록을 가집니다. 유용할 때 수정 도움말과 관련 소스 범위도 포함합니다. + +## 처리와 심각도 + +도구는 인코딩과 token, 문법, 식별자와 기본값, 의미 제한, 테마와 아이콘, 레이아웃, 렌더링 순서로 처리합니다. 앞 네 단계의 오류는 렌더링을 막습니다. 테마, 아이콘, 밀도, 레이아웃 힌트 경고는 fallback SVG와 함께 반환될 수 있습니다. + +Playground는 소스 편집 후 오래된 진단을 지웁니다. 결과를 선택하면 primary source에 포커스하고 관련 정보에서 이전 선언으로 이동할 수 있습니다. + +## 복잡도 제한 + +| 항목 | Draft Stack 1.0 제한 | +| ------------------------- | ---------------------------------: | +| 문서당 다이어그램 | 1 | +| 노드 | 1~40 | +| 그룹 | 0~12 | +| 다이어그램 아래 그룹 중첩 | 3레벨 | +| 엣지 | 0~80 또는 노드 수 두 배 중 작은 값 | +| 경고 전 노드 degree | 12개의 incident edge 선언 | + +하드 제한 초과는 `STK4003`입니다. 권장 degree를 넘은 노드는 유효하지만 `STK4002`가 발생합니다. 큰 시스템은 하나에 압축하지 말고 집중된 여러 다이어그램으로 나누세요. + +## 이식 가능한 진단 코드 + +| Code | Severity | 의미 | +| --------- | -------- | ------------------------------------------------ | +| `STK1001` | Error | 입력이 유효한 UTF-8이 아님 | +| `STK1002` | Error | Byte order mark가 있음 | +| `STK1003` | Error | 문자열 이스케이프나 디코드 값이 유효하지 않음 | +| `STK2001` | Error | 선언한 언어 버전을 지원하지 않음 | +| `STK2002` | Error | 예상하지 못한 token, 선언, 속성, 값, 연산자 | +| `STK2003` | Error | 현재 구문이 끝나기 전에 입력이 종료됨 | +| `STK3001` | Error | 식별자가 유효하지 않음 | +| `STK3002` | Error | 식별자가 중복 선언됨 | +| `STK3003` | Error | 엣지가 알 수 없는 노드를 참조함 | +| `STK3004` | Error | 그룹을 엣지 endpoint로 사용함 | +| `STK3005` | Error | 엣지가 노드 자신을 연결함 | +| `STK3006` | Error | 정확히 중복된 엣지를 선언함 | +| `STK3007` | Error | 한 block에서 속성이 중복됨 | +| `STK3008` | Error | 제목, 라벨, 상세가 텍스트 제약을 위반함 | +| `STK3009` | Error | 그룹에 하위 노드가 없음 | +| `STK3010` | Error | 그룹 중첩이 언어 제한을 넘음 | +| `STK3011` | Error | 레이아웃 참조가 스코프에서 유효하지 않음 | +| `STK3012` | Error | 레이아웃 블록 또는 singleton 문장이 중복됨 | +| `STK3013` | Error | 아이콘 식별자 형식이 잘못됨 | +| `STK3014` | Error | 다이어그램에 여러 테마 문장이 있음 | +| `STK4001` | Warning | 순서 힌트를 만족할 수 없음 | +| `STK4002` | Warning | 노드가 권장 incident-edge degree를 넘음 | +| `STK4003` | Error | 다이어그램이 언어 복잡도 제한을 넘음 | +| `STK5001` | Warning | 유효 테마에 아이콘이 없어 kind fallback을 사용함 | +| `STK6001` | Warning | 요청한 non-core 테마가 없어 `default`를 사용함 | + +코드 family에서 `STK1000`은 인코딩/어휘, `STK2000`은 문법, `STK3000`은 이름/의미, `STK4000`은 레이아웃/복잡도, `STK5000`은 아이콘, `STK6000`은 테마입니다. `STK9000`은 소스 실수가 아닌 구현 실패용입니다. 구현은 자체 non-`STK` prefix로만 진단을 추가할 수 있습니다. + +## 복구 규칙 + +파서는 여러 독립 오류를 보고하기 위해 복구할 수 있지만 부분 다이어그램을 유효한 것으로 렌더링할 수 없습니다. 알 수 없는 선언, 속성, enum 값, 연산자는 무시되지 않습니다. 의미를 잃은 채 성공처럼 보이는 출력을 막습니다. diff --git a/content/site/ko/reference/versioning-and-safety.md b/content/site/ko/reference/versioning-and-safety.md new file mode 100644 index 0000000..66e1fdb --- /dev/null +++ b/content/site/ko/reference/versioning-and-safety.md @@ -0,0 +1,40 @@ +# 버전과 안전성 + +Draft Stack 1.0은 소스 언어, 구현, 테마 catalog, package 버전을 분리합니다. 이 경계를 이해하면 문서를 이식 가능하게 하고 렌더 결과의 출처를 추적할 수 있습니다. + +## 언어 버전 + +모든 문서는 `major.minor` 지시문으로 시작합니다. + +```stack +stack 1.0 + +diagram "Versioned source" { + node api "API" +} +``` + +이 값은 문서가 요구하는 최소 언어 문법과 의미이며 엔진이나 테마 버전이 아닙니다. `M.N`을 지원하는 렌더러는 같은 major에서 minor가 `N` 이하인 문서를 받고, 다른 major나 명시적으로 지원하지 않는 더 높은 minor를 거부합니다. 미래 문법의 의미를 추측하지 않습니다. + +Specification release는 semantic versioning을 사용합니다. Major는 호환되지 않는 언어 변경, minor는 하위 호환 기능 추가, patch는 유효 소스 의미를 바꾸지 않는 설명과 오류 수정입니다. 그래서 문서 지시문은 patch를 생략합니다. + +## 렌더러와 catalog 식별 + +일반 엔진 결과에는 엔진 버전, 작성한 언어 버전, 테마 catalog 버전, catalog content revision이 포함됩니다. 소스 `theme`은 기호 식별자만 선택하며 package release를 pin하거나 원격 데이터를 가져오지 않습니다. + +정확한 픽셀 출력은 언어 호환성 약속이 아닙니다. 테마 metric, 렌더러 버전, 폰트, 캔버스 결정이 위치를 바꿀 수 있지만 노드, 그룹, 관계, 라벨, kind, 제약은 보존해야 합니다. + +## 안전한 소스 경계 + +Stack 문자열은 일반 텍스트입니다. 소스에는 실행 코드, 임의 HTML/Markdown, CSS, SVG, import, macro, 파일 경로, 네트워크 URL을 넣을 수 없습니다. 엔진은 작성한 텍스트를 escape하고 검증된 catalog 아이콘, local marker reference, 접근 가능한 title/description metadata가 포함된 독립형 SVG를 만듭니다. + +렌더된 SVG에는 script, event handler, 임의 external reference, host font measurement, runtime I/O가 없습니다. 없는 아이콘과 테마 이름은 경로나 registry를 찾는 대신 번들 fallback을 선택합니다. + +## 현재 제공 상태 + +- 브라우저 Playground가 지원되는 공개 경험입니다. +- 공개 `@stack-sh/engine`은 Playground가 사용하는 typed WebAssembly `format`, `check`, `render`를 제공합니다. +- 공개 `@stack-sh/language`는 에디터 하이라이트용 공유 TextMate grammar와 언어 metadata를 제공합니다. +- 공개 [`stack-sh/cli`](https://github.com/stack-sh/cli)는 native `format`, `check`, `render` 및 provider-icon store 작업을 제공합니다. + +표준 언어 계약은 [`stack-sh/specification`](https://github.com/stack-sh/specification), 공개 테마 catalog는 [`stack-sh/theme`](https://github.com/stack-sh/theme), 엔진 동작은 [`stack-sh/engine`](https://github.com/stack-sh/engine)이 소유합니다. diff --git a/content/site/language/edges-and-layout.md b/content/site/language/edges-and-layout.md new file mode 100644 index 0000000..32034df --- /dev/null +++ b/content/site/language/edges-and-layout.md @@ -0,0 +1,78 @@ +# Edges and layout + +Edges describe relationships between nodes. Layout blocks express a small amount of placement intent without exposing coordinates or drawing primitives. + +## Edge direction + +An edge connects two distinct nodes. Forward references are valid, while self-edges and group endpoints are invalid. + +| Operator | Meaning | +| -------- | -------------------------------------------------------------- | +| `->` | Directed relationship from the left node to the right node | +| `<->` | One symmetric relationship in both directions | +| `--` | Association with absent or intentionally unspecified direction | + +`<->` is one relationship, not shorthand for two independently labeled edges. + +## Edge kinds and labels + +An optional label names a protocol, event, command, dataset, or purpose and contains 1 to 40 Unicode scalar values. An optional `kind` describes the relationship independently of that label. The default is `flow`. + +| Kind | Intended meaning | +| ------------ | ------------------------------------------------------ | +| `flow` | Generic runtime or conceptual flow | +| `request` | Synchronous request or call | +| `event` | Asynchronous message or event delivery | +| `data` | Data movement, replication, reads, or writes | +| `dependency` | Build-time, deployment-time, or operational dependency | + +```stack +stack 1.0 + +diagram "Relationships" { + node web "Web app" { + kind client + } + + node api "API" + node queue "Events" { + kind queue + } + + edge web -> api "HTTPS" { + kind request + } + + edge api -> queue "OrderPlaced" { + kind event + } +} +``` + +Multiple edges between the same nodes are valid when they express distinct relationships. An exact duplicate with the same endpoints, operator, label, and effective kind is invalid. Endpoint order is ignored when comparing `<->` and `--` duplicates. + +## Layout scope + +A diagram or group may contain one `layout` block. A group block affects only its direct child nodes and groups. A diagram block affects only direct children of the diagram. `rank` and `order` references must name at least two distinct direct children in that scope. + +For layout, a direct child group acts as one item. Connections between descendant nodes induce connections between their containing direct-child items, so a top-level layout can arrange groups even though groups are not edge endpoints. + +## Direction, rank, and order + +```stack +layout { + direction right + rank same [web, worker] + order [web, worker, database] +} +``` + +- `direction right` prefers left-to-right progression; `direction down` prefers top-to-bottom progression. It is a strong hint, not a promise that every edge points geometrically that way. Nested groups do not inherit it. +- `rank same [a, b]` is a constraint: listed direct children must share a layout rank. A child cannot appear in two same-rank statements in one scope. +- `order [a, b]` is a relative-order hint. It is top-to-bottom for a right-directed scope, left-to-right for a down-directed scope, and follows the chosen cross-axis in automatic layout. Other children may be omitted. + +The renderer may depart from `order` to preserve containment, same-rank constraints, legibility, or output bounds. Diagnostic-capable tools should emit `STK4001` when an authored order cannot be satisfied. + +## Renderer-owned decisions + +Stack exposes no coordinates, dimensions, ports, paths, colors, fonts, line breaks, or z-index. The renderer prevents overlaps, preserves containment and direction, keeps labels legible, routes edges outside node interiors, and expands the canvas rather than clipping semantic content. diff --git a/content/site/language/formatting.md b/content/site/language/formatting.md new file mode 100644 index 0000000..73b62ff --- /dev/null +++ b/content/site/language/formatting.md @@ -0,0 +1,58 @@ +# Canonical formatting + +Stack defines one canonical byte representation for every lexically and syntactically valid document. Formatting keeps diffs consistent without changing the declared language version, semantic meaning, or line comments. + +## What formatting accepts + +The formatter accepts UTF-8 without a byte order mark. Lexical or syntax errors return diagnostics and no partial formatted source. A syntactically valid document remains formattable when it has semantic or complexity diagnostics; formatting success does not mean the diagram is valid. + +## Canonical output + +Canonical source: + +- uses UTF-8 without a byte order mark; +- normalizes every line ending to LF; +- uses two ASCII spaces for each block level and never formatting tabs; +- has no formatting whitespace at line ends; +- ends with exactly one LF; +- puts the opening brace on the declaration or `layout` line and closing braces on their own lines; +- separates the version and diagram, and adjacent body members, with one empty line; +- keeps properties and layout statements together without empty lines. + +```stack +stack 1.0 + +diagram "Title" { + theme dark + + node client "Client" + + node api "API" { + kind service + detail "Public API" + } + + edge client -> api "HTTPS" { + kind request + } + + layout { + direction right + order [client, api] + } +} +``` + +## Order and lists + +The formatter preserves the authored order of diagram and group members, node and edge properties, layout statements, and list identifiers. It never groups or sorts them. Lists stay on one line with a comma and one space, no spaces just inside brackets, and no trailing comma. + +## Strings + +Valid strings are decoded and emitted directly as UTF-8 without Unicode normalization. Quotes and backslashes remain escaped; canonical output does not use `\uXXXX`. For example, a source spelling of `"API \u56F3 \uD83D\uDE80"` becomes `"API 図 🚀"`. + +## Comments + +Every line comment and its order are preserved. A trailing comment stays after its preceding token with one space. Own-line comments keep their token gap and appear immediately before the following member, statement, or property. A comment inside a construct can force a continuation line; this is the only exception to the usual one-line rules. + +Formatting canonical source again must produce byte-identical output. When normalized IR exists, source before and after formatting must produce semantically equal IR. diff --git a/content/site/language/nodes-and-groups.md b/content/site/language/nodes-and-groups.md new file mode 100644 index 0000000..9f94e33 --- /dev/null +++ b/content/site/language/nodes-and-groups.md @@ -0,0 +1,67 @@ +# Nodes and groups + +Nodes are addressable architectural entities. Groups are labeled containment boundaries. Together they describe the components and scopes visible in a diagram. + +## Nodes + +A node requires a globally unique identifier and a visible label. The identifier is used by edges and layout statements but is never rendered. A label contains 1 to 60 Unicode scalar values. + +```stack +stack 1.0 + +diagram "Node example" { + node api "Public API" { + kind service + detail "Order orchestration" + } +} +``` + +Two nodes may share a visible label when they are distinct entities, though labels should remain understandable without relying on position. A node block cannot repeat `kind`, `icon`, or `detail`. + +## Node kinds + +`kind` provides coarse architectural meaning. It also selects a theme-controlled shape and fallback icon. The default is `service`. + +| Kind | Intended meaning | +| ---------- | ------------------------------------------------------------ | +| `actor` | Person, role, team, or autonomous participant | +| `client` | Browser, mobile app, desktop app, device, or other client | +| `service` | Long-running application, API, gateway, or general component | +| `function` | On-demand or serverless compute unit | +| `worker` | Background processor or scheduled job | +| `database` | Durable, queryable datastore | +| `cache` | Datastore whose contents are disposable or derived | +| `queue` | Queue, stream, bus, or broker for asynchronous delivery | +| `storage` | Blob, object, file, or archival storage | +| `external` | System outside the architecture's control boundary | + +Kinds are semantic categories, not vendor shapes. A hosted PostgreSQL instance is still a `database`; name the technology in `detail`. + +## Labels and details + +`detail` is an optional visible second line of 1 to 80 Unicode scalar values. Use it for one technology or a short responsibility, such as `"Next.js"`, `"PostgreSQL 17"`, or `"Order orchestration"`. It remains visible in every rendered diagram and is never reduced to tooltip-only content. + +Labels and details are plain text, not Markdown or HTML. An explicit `icon` decorates the node but does not change its kind, identity, or accessible label. See [Themes and icons](./themes-and-icons). + +## Groups + +A group has a globally unique identifier, a label of 1 to 60 Unicode scalar values, and at least one descendant node. It may contain nodes, nested groups, and one layout block. + +```stack +stack 1.0 + +diagram "Boundaries" { + group platform "Platform" { + group data "Data layer" { + node primary "Primary database" { + kind database + } + } + } +} +``` + +Group nesting can reach three levels below the diagram. A node belongs to its nearest group and all ancestor groups. Because declarations cannot be reused, a node cannot belong to two separate groups. + +Edges are always declared at diagram scope, and only nodes can be edge endpoints. A group does not create an implicit node or relationship. Its label explains whether the boundary represents a system, domain, network, deployment area, team, or another concern; containment alone does not imply runtime isolation, security, ownership, or deployment semantics. diff --git a/content/site/language/syntax.md b/content/site/language/syntax.md new file mode 100644 index 0000000..10f7d12 --- /dev/null +++ b/content/site/language/syntax.md @@ -0,0 +1,95 @@ +# Document and syntax + +Stack source is intentionally small. This page covers the complete lexical structure and grammar for draft Stack 1.0. + +## Document structure + +A document is one UTF-8 `.stack` file with no byte order mark. LF and CRLF line endings have the same meaning. The first non-comment token is a version directive, followed by exactly one diagram and no trailing declarations. + +```stack +// One file, one diagram. +stack 1.0 + +diagram "Example" { + node api "API" +} +``` + +The diagram title is required, contains 1 to 80 Unicode scalar values, and cannot begin or end with Unicode whitespace. A diagram must contain at least one node. + +## Comments and whitespace + +Spaces, tabs, and line endings separate tokens but do not otherwise affect meaning. A line comment starts with `//` and ends at the line ending. Comments are allowed wherever whitespace is allowed. Block comments are not supported. + +Formatting is not semantic, but the canonical formatter emits a consistent representation described in [Canonical formatting](./formatting). + +## Identifiers + +Node, group, theme, and reference identifiers match: + +```text +[a-z][a-z0-9_-]* +``` + +They contain 1 to 64 ASCII characters, are case-sensitive, and are not displayed. Nodes and groups share one global namespace. Keywords are contextual and may technically appear where an identifier is expected, but avoid identifiers that make declarations hard to read. + +Icon identifiers are quoted strings whose decoded value matches `[a-z0-9][a-z0-9-]*`, also with 1 to 64 ASCII characters. They are resolved inside the effective theme. + +## Strings + +Strings use double quotes and may contain Unicode directly. Only three escape forms exist: + +| Escape | Meaning | +| -------- | ----------------- | +| `\"` | Double quote | +| `\\` | Backslash | +| `\uXXXX` | Unicode code unit | + +Decoded strings cannot contain line breaks, tabs, control characters, or unpaired surrogates. Titles, labels, and details cannot begin or end with Unicode whitespace. Strings are plain text; Markdown and HTML are never interpreted. + +## Complete grammar + +```text +document = version-directive, diagram-declaration, EOF ; +version-directive = "stack", integer, ".", integer ; +diagram-declaration + = "diagram", string, "{", { diagram-member }, "}" ; +diagram-member = node-declaration | group-declaration | edge-declaration + | theme-statement | layout-block ; +theme-statement = "theme", identifier ; +group-declaration = "group", identifier, string, "{", { group-member }, "}" ; +group-member = node-declaration | group-declaration | layout-block ; +node-declaration = "node", identifier, string, [ node-block ] ; +node-block = "{", node-property, { node-property }, "}" ; +node-property = "kind", node-kind | "icon", string | "detail", string ; +node-kind = "actor" | "client" | "service" | "function" | "worker" + | "database" | "cache" | "queue" | "storage" | "external" ; +edge-declaration = "edge", identifier, edge-operator, identifier, + [ string ], [ edge-block ] ; +edge-operator = "->" | "<->" | "--" ; +edge-block = "{", edge-property, { edge-property }, "}" ; +edge-property = "kind", edge-kind ; +edge-kind = "flow" | "request" | "event" | "data" | "dependency" ; +layout-block = "layout", "{", layout-statement, + { layout-statement }, "}" ; +layout-statement = direction-statement | rank-statement | order-statement ; +direction-statement + = "direction", ( "right" | "down" ) ; +rank-statement = "rank", "same", identifier-list ; +order-statement = "order", identifier-list ; +identifier-list = "[", identifier, ",", identifier, + { ",", identifier }, "]" ; +integer = "0" | nonzero-digit, { digit } ; +``` + +## Contextual keywords + +Stack 1.0 recognizes these words in their grammatical positions: + +```text +stack diagram group node edge theme layout kind icon detail direction +rank same order right down actor client service function worker +database cache queue storage external flow request event data dependency +``` + +Unknown declarations, properties, enum values, and operators are errors. Tools do not silently ignore syntax that could create a plausible but incorrect diagram. diff --git a/content/site/language/themes-and-icons.md b/content/site/language/themes-and-icons.md new file mode 100644 index 0000000..c4bb400 --- /dev/null +++ b/content/site/language/themes-and-icons.md @@ -0,0 +1,126 @@ +# Themes and icons + +A theme is a symbolic, diagram-level reference to a renderer-managed visual system. Icons are logical names resolved inside that theme. Neither feature changes diagram meaning. + +## Select a theme + +Add at most one `theme` statement directly inside the diagram: + +```stack +stack 1.0 + +diagram "Dark architecture" { + theme dark + + node api "API" +} +``` + +If the statement is omitted, Stack uses `default`. Draft Stack 1.0 requires the core catalog to contain: + +| Theme | Intended use | +| --------- | ------------------------------------------------------------- | +| `default` | Balanced blue-gray surfaces for general architecture diagrams | +| `light` | Warm neutral surfaces for light documents | +| `dark` | High-contrast cool surfaces for dark canvases | + +The source selects an identifier, not a catalog package version. Render metadata records the catalog version and content revision so an output can identify the visual data it used. + +The generated diagram theme is independent from the Playground's light or dark interface. A theme may change palette, typography metrics, surfaces, icons, connectors, and background treatment. It cannot hide or change nodes, groups, edges, labels, kinds, direction, or layout constraints. + +## Fallback behavior + +The three core themes are required renderer resources. A requested non-core theme that is unavailable emits warning `STK6001` and renders with `default`. The engine never fetches a theme from the network just because its identifier appears in source. + +Theme identifiers use normal Stack identifier syntax. Once registered, an identifier cannot later name a different theme, even after deprecation. + +## Kind fallback icons + +Every theme provides one fallback for each node kind. If you omit `icon`, this is what the renderer uses. + +| Node kind | Current logical fallback icon | +| ---------- | ----------------------------- | +| `actor` | `kind-actor` | +| `client` | `kind-client` | +| `service` | `kind-service` | +| `function` | `kind-function` | +| `worker` | `kind-worker` | +| `database` | `kind-database` | +| `cache` | `kind-cache` | +| `queue` | `kind-queue` | +| `storage` | `kind-storage` | +| `external` | `kind-external` | + +The current open core catalog contains these ten fallback identifiers in `default`, `light`, and `dark`. It does not yet contain vendor icons such as `postgresql`, `aws`, or `github`. In most documents, choose the semantic `kind` and omit `icon`. + +## Explicit icons + +An explicit icon is a quoted logical identifier: + +```stack +stack 1.0 + +diagram "Explicit icon" { + node gateway "Public API" { + kind service + icon "api" + } +} +``` + +The icon decorates the node; it does not change the `service` kind, identity, label, or accessible description. The same identifier in different themes represents the same logical subject, although its color and artwork may adapt to the theme. + +## First-party icon catalog + +The free core catalog includes these provider-neutral explicit icons in `default`, `light`, and `dark`: + +| ID | Stable subject | Use it for | +| --------------- | --------------------------------- | ---------------------------------- | +| `api` | Application programming interface | Public or internal APIs | +| `web` | Web application | Browser-facing web experiences | +| `mobile` | Mobile application | iOS or Android clients | +| `desktop` | Desktop application | Native desktop clients | +| `server` | Server host | Virtual machines or physical hosts | +| `container` | Application container | Containerized workloads | +| `cluster` | Compute cluster | Orchestrated compute groups | +| `cloud` | Cloud environment | Provider-neutral cloud boundaries | +| `scheduler` | Scheduled execution | Cron jobs or scheduled work | +| `webhook` | Webhook endpoint | Inbound or outbound callbacks | +| `identity` | Identity and access | Authentication or authorization | +| `observability` | Observability system | Metrics, logs, or traces | +| `gateway` | Network gateway | Public or private network entry | +| `load-balancer` | Load balancer | Traffic distribution | +| `dns` | Domain name service | Hostname and service discovery | +| `cdn` | Content delivery network | Edge content delivery | +| `firewall` | Network firewall | Network access boundaries | +| `network` | Network topology | Generic networks or subnets | +| `event` | Discrete event | Individual domain or system events | +| `stream` | Event stream | Continuous event or data flows | +| `search` | Search service | Indexing and query systems | +| `analytics` | Analytics system | Reporting or data analysis | +| `repository` | Source code repository | Source code and version control | +| `pipeline` | Delivery pipeline | Build, test, or deployment flows | +| `secret` | Secret or credential | Secrets, keys, or credentials | +| `document` | Document or knowledge base | Documentation and knowledge | +| `task` | Task or issue tracker | Tasks, tickets, or issue tracking | +| `chat` | Chat or messaging tool | Team chat or messaging | +| `email` | Email delivery | Email delivery or inboxes | +| `ai` | Artificial intelligence system | AI models or inference services | + +Switch the preview below between light and dark to inspect the actual output. The published `@stack-sh/engine@0.7.0` renders every image locally; the Documentation does not copy Theme SVG assets. Select a syntax row to copy it. + + + +Use the semantic `kind` independently from the explicit icon. For example, `icon "web"` may decorate either a `client` or `service` node without changing what that node means. + +## Missing and vendor icons + +The core catalog does not currently include vendor or project marks such as `postgresql`, `aws`, `github`, or `docker`. If the effective theme does not provide an authored icon identifier, rendering continues with the node's kind fallback and warning `STK5001`. + +Prefer a provider-neutral icon above or omit `icon` when its kind fallback already communicates the role. Vendor marks require asset-specific license, redistribution, and trademark review before they can ship in a separate catalog. + +## Catalog and asset safety + +The public `stack-sh/theme` catalog owns palettes, deterministic font metrics, node-kind visuals, connectors, icon metadata, SVG bytes, provenance, and redistribution permissions. Catalog assets are bundled with the renderer; authored identifiers are never treated as file paths or URLs. + +SVG validation rejects scripts, event handlers, nested SVG documents, unsafe references, data or network URLs, style attributes, and elements or attributes outside an allowlist. Icons are not the only accessible indication of meaning: labels and non-color visual distinctions remain required. diff --git a/content/site/reference/diagnostics-and-limits.md b/content/site/reference/diagnostics-and-limits.md new file mode 100644 index 0000000..5ffddf7 --- /dev/null +++ b/content/site/reference/diagnostics-and-limits.md @@ -0,0 +1,58 @@ +# Diagnostics and limits + +Stack diagnostics are structured results, not console prose. They have a stable code, `error` or `warning` severity, a one-based end-exclusive source range, a concise message, and an ordered `expected` list. Corrective help and related source ranges are included when useful. + +## Processing and severity + +Tools process encoding and tokens, grammar, identifiers and defaults, semantic limits, theme and icon resolution, layout, then rendering. Errors in the first four stages prevent rendering. Theme, icon, density, and layout-hint warnings can accompany a fallback SVG. + +The Playground clears stale diagnostics after source edits. Selecting a result focuses its primary source; related information can point back to an earlier declaration. + +## Complexity limits + +| Item | Draft Stack 1.0 limit | +| --------------------------- | ---------------------------------------------: | +| Diagrams per document | 1 | +| Nodes | 1 to 40 | +| Groups | 0 to 12 | +| Group nesting below diagram | 3 levels | +| Edges | 0 to the smaller of 80 or twice the node count | +| Node degree before warning | 12 incident edge declarations | + +Exceeding a hard limit is `STK4003`. A node above the recommended degree remains valid but emits `STK4002`. Split large systems into focused diagrams rather than compressing an exhaustive graph. + +## Portable diagnostic codes + +| Code | Severity | Meaning | +| --------- | -------- | ------------------------------------------------------------------------- | +| `STK1001` | Error | Input is not valid UTF-8 | +| `STK1002` | Error | A byte order mark is present | +| `STK1003` | Error | A string has an invalid escape or decoded value | +| `STK2001` | Error | The declared language version is unsupported | +| `STK2002` | Error | An unexpected token, declaration, property, value, or operator was found | +| `STK2003` | Error | Input ended before the current construct was complete | +| `STK3001` | Error | An identifier is invalid | +| `STK3002` | Error | An identifier is declared more than once | +| `STK3003` | Error | An edge references an unknown node | +| `STK3004` | Error | A group is used as an edge endpoint | +| `STK3005` | Error | An edge connects a node to itself | +| `STK3006` | Error | An exact duplicate edge is declared | +| `STK3007` | Error | A property occurs more than once in one block | +| `STK3008` | Error | A title, label, or detail violates its text constraints | +| `STK3009` | Error | A group has no descendant node | +| `STK3010` | Error | Group nesting exceeds the language limit | +| `STK3011` | Error | A layout reference is invalid in its scope | +| `STK3012` | Error | A layout block or singleton layout statement is duplicated | +| `STK3013` | Error | An icon identifier is malformed | +| `STK3014` | Error | A diagram contains more than one theme statement | +| `STK4001` | Warning | An order hint could not be satisfied | +| `STK4002` | Warning | A node exceeds the recommended incident-edge degree | +| `STK4003` | Error | A diagram exceeds a language complexity limit | +| `STK5001` | Warning | An icon is unavailable in the effective theme; its kind fallback was used | +| `STK6001` | Warning | A requested non-core theme is unavailable; `default` was used | + +Code families reserve `STK1000` for encoding and lexical errors, `STK2000` for syntax, `STK3000` for names and semantics, `STK4000` for layout and complexity, `STK5000` for icons, and `STK6000` for themes. `STK9000` is for implementation failures, never a source mistake. Implementations may add diagnostics only under their own non-`STK` prefix. + +## Recovery rules + +A parser may recover to report independent errors together, but it cannot render a partial diagram as valid. Unknown declarations, properties, enum values, and operators are never ignored. This avoids successful-looking output that silently lost authored meaning. diff --git a/content/site/reference/versioning-and-safety.md b/content/site/reference/versioning-and-safety.md new file mode 100644 index 0000000..61f835a --- /dev/null +++ b/content/site/reference/versioning-and-safety.md @@ -0,0 +1,40 @@ +# Versioning and safety + +Draft Stack 1.0 separates the source language, implementation, theme catalog, and package versions. Understanding that boundary makes documents portable and rendered output reproducible. + +## Language version + +Every document starts with a `major.minor` directive: + +```stack +stack 1.0 + +diagram "Versioned source" { + node api "API" +} +``` + +This is the minimum language grammar and semantics required by the document, not an engine or theme version. A renderer supporting `M.N` accepts the same major with a minor less than or equal to `N`, rejects a different major, and rejects a higher minor unless it explicitly supports it. It never guesses unknown future syntax. + +Specification releases use semantic versioning. A major release may change the language incompatibly; a minor adds backwards-compatible capabilities; a patch clarifies wording or fixes errata without changing valid source meaning. The document omits a patch number for that reason. + +## Renderer and catalog identity + +Normal engine results include the engine version, authored language version, theme catalog version, and catalog content revision. The source `theme` statement selects a symbolic identifier only. It does not pin a package release or fetch remote data. + +Exact pixel output is not a language compatibility promise. Theme metrics, renderer versions, fonts, and canvas decisions may change positions while preserving nodes, groups, relationships, labels, kinds, and constraints. + +## Safe source boundary + +Stack strings are plain text. Source cannot contain executable code, arbitrary HTML or Markdown, CSS, SVG, imports, macros, file paths, or network URLs. The engine escapes authored text and emits standalone SVG with embedded validated catalog icons, local marker references, and accessible title and description metadata. + +Rendered SVG contains no script, event handler, arbitrary external reference, host font measurement, or runtime I/O. Missing icon and theme names select bundled fallbacks rather than resolving paths or contacting a registry. + +## Current delivery status + +- The browser Playground is the supported public experience. +- Public `@stack-sh/engine` provides the typed WebAssembly `format`, `check`, and `render` operations used by the Playground. +- Public `@stack-sh/language` provides the shared TextMate grammar and language metadata used for editor highlighting. +- Public [`stack-sh/cli`](https://github.com/stack-sh/cli) provides native `format`, `check`, `render`, and provider-icon store operations. + +The normative language contract remains in [`stack-sh/specification`](https://github.com/stack-sh/specification). The public theme catalog is in [`stack-sh/theme`](https://github.com/stack-sh/theme), and engine behavior is in [`stack-sh/engine`](https://github.com/stack-sh/engine). diff --git a/content/site/zh/examples/index.md b/content/site/zh/examples/index.md new file mode 100644 index 0000000..0dd253c --- /dev/null +++ b/content/site/zh/examples/index.md @@ -0,0 +1,7 @@ +# 示例库 + +从小型图开始,逐步学习分组、布局约束、云服务商图标和接近生产环境的系统。下面的每个缩略图都由固定到公开 Stack 规范的规范源代码生成。 + +云服务商示例中的图标资源由调用方管理。需要品牌图标时,请安装页面标出的图标包。即使没有图标包,同一份源代码仍然有效,并会使用 Stack 的确定性缺失图标回退进行渲染。 + + diff --git a/content/site/zh/guide/coding-agents.md b/content/site/zh/guide/coding-agents.md new file mode 100644 index 0000000..5e92fd0 --- /dev/null +++ b/content/site/zh/guide/coding-agents.md @@ -0,0 +1,27 @@ +# 使用 coding agent + +使用 coding agent 读写 Stack,可将架构图作为可审查的源文件管理。agent 阅读语言参考并在本地执行 CLI,不需要远程 MCP 服务器。 + +## 安装 skill + +使用 `npx skills add stack-sh/cli` 仅将图表 skill 安装到当前项目。仅在需要用户级安装时添加 `-g`,并检查下载的指令。CLI 需要单独安装。需要可复现安装时,先 clone 仓库并 checkout 已审核的 commit,再运行 `npx skills add /absolute/path/to/cli --skill stack-diagrams`。安装器不能将 commit SHA 直接作为远程分支安装。 + +[SKILL.md](https://github.com/stack-sh/cli/blob/main/skills/stack-diagrams/SKILL.md) + +## 不安装也能使用 + +将以下指令复制给 agent,并补充架构需求。只要客户端可以读取 HTTPS 页面和运行本地命令,即使不支持 skill 也能使用。 + +```text +{{agentPrompt}} +``` + +完整的 [agent workflow](./agent-workflow) 与 CLI skill 从同一份源文件生成。规范的 agent 指令使用英语;请让 agent 读取上面的 Markdown URL,或复制完整指令。 + +## 参考与更新 + +- [Examples](../examples/index) +- [Syntax](../language/syntax) +- [Diagnostics](../reference/diagnostics-and-limits) +- [Provider icons](./provider-icons) +- [Markdown index](https://stack-diagram.com/docs/llms.txt) diff --git a/content/site/zh/guide/getting-started.md b/content/site/zh/guide/getting-started.md new file mode 100644 index 0000000..9078be0 --- /dev/null +++ b/content/site/zh/guide/getting-started.md @@ -0,0 +1,86 @@ +# 快速开始 + +使用 Stack 最快的方法是浏览器 [Playground](https://stack-diagram.com/)。格式化器、验证器、布局引擎和 SVG 渲染器都通过 WebAssembly 在本地运行;无需安装命令,也不会把源文件发送到渲染 API。 + +## 安装原生 CLI + +对于终端工作流和本地自动化,请使用 `brew install stack-sh/tap/stack` 安装由 Stack 维护的 Homebrew formula。它使用规范的 Stack CLI {{cliVersion}} 发布归档,并支持符合 Homebrew 当前 Tier 1 要求的 Apple Silicon macOS,以及 arm64 / x86_64 的 glibc Linux。Homebrew 通过 `brew upgrade stack-sh/tap/stack` 管理升级;卸载 formula 不会删除 Stack 配置和图标存储。有关准确的平台矩阵、直接安装方式和恢复策略,请参阅 [CLI 分发约定](https://github.com/stack-sh/cli/blob/main/docs/distribution.md#homebrew-installation)。 + +## 编写第一份文档 + +将编辑器内容替换为下面的示例: + +```stack +stack 1.0 + +diagram "Checkout" { + theme default + + node shopper "Shopper" { + kind actor + } + + group application "Application" { + node web "Web app" { + kind client + detail "React" + } + + node api "Checkout API" { + kind service + detail "Rust" + } + + layout { + direction right + order [web, api] + } + } + + node orders "Orders" { + kind database + detail "PostgreSQL" + } + + edge shopper -> web "HTTPS" { + kind request + } + + edge web -> api "JSON" { + kind request + } + + edge api -> orders "SQL" { + kind data + } + + layout { + direction right + order [shopper, application, orders] + } +} +``` + +## 渲染并查看 + +选择 **Run**,或按 Command/Ctrl + Enter。预览区会显示独立 SVG。选择预览可放大查看,需要保存时使用 **Download SVG**。 + +源文件由四部分组成: + +1. `stack 1.0` 声明语言版本。 +2. `diagram` 提供一个标题并包含完整架构。 +3. `node` 和 `group` 声明组件与边界。 +4. `edge` 记录关系,`layout` 提供受约束的布局意图。 + +## 检查与格式化 + +**Check** 在不替换 SVG 的情况下运行完整验证与布局流程。**Format** 保留行注释和语义,将语法有效的源文件改写成规范的两空格格式。 + +发现问题时,诊断会显示严重级别、稳定代码、位置、源码片段、候选值,以及可用的修复帮助。选择诊断会聚焦对应源码范围。 + +## 接下来阅读 + +- [文档与语法](../language/syntax)介绍词法规则和完整语法。 +- [节点与分组](../language/nodes-and-groups)介绍组件和边界建模。 +- [连线与布局](../language/edges-and-layout)介绍关系和布局意图。 +- 选择视觉系统或显式图标前,请阅读[主题与图标](../language/themes-and-icons)。 diff --git a/content/site/zh/guide/playground.md b/content/site/zh/guide/playground.md new file mode 100644 index 0000000..4f94adc --- /dev/null +++ b/content/site/zh/guide/playground.md @@ -0,0 +1,42 @@ +# 使用 Playground + +Playground 是位于 [stack-diagram.com](https://stack-diagram.com/) 的公共浏览器客户端。编辑器保留原生文本输入行为,共享 TextMate grammar 提供语法着色。验证、格式化、布局和 SVG 始终来自已发布的 Stack WebAssembly 引擎。 + +## 操作 + +| 操作 | 结果 | +| ---------------- | ------------------------------------------------------ | +| **Format** | 规范化语法有效的源文件并保留注释;语义错误仍会显示。 | +| **Check** | 不生成新 SVG,运行编译器、主题、图标、布局和路由检查。 | +| **Run** | 运行完整流程;若没有阻止渲染的错误,则更新 SVG。 | +| **Download SVG** | 保存当前独立 SVG。 | + +Command/Ctrl + Enter 也可运行文档。源文件发生变化时会清除旧诊断,避免把过期范围当成当前结果。 + +## 阅读诊断 + +错误结果可以包含: + +```text +error[STK2002] at 4:22 +4 | layout { direction hoo } + | ^^^ unexpected layout direction 'hoo' + = expected: right, down + = help: use 'right' for horizontal flow or 'down' for vertical flow +``` + +选择诊断或相关信息可聚焦对应源码。错误会阻止成功渲染;警告说明回退行为或可读性风险,并可与 SVG 同时返回。 + +## 两个独立的颜色设置 + +页头的颜色模式只改变 Playground 与编辑器外观;`theme dark` 等源码语句改变生成图。两者故意相互独立,切换网站深色模式不会改写或重新解释图的主题。 + +## 浏览器行为与数据 + +Playground 加载公开 WebAssembly 模块,然后在浏览器中同步执行 `format`、`check` 和 `render`。引擎本身不读取文件、不连接网络服务、不检查 DOM、不读取时钟,也不测量宿主字体。 + +当前 Playground 不提供账号、云端持久化、协作或付费主题。请下载需要保留的源文件或 SVG。 + +## 无障碍 + +编辑器保留原生光标、选择、剪贴板、撤销、键盘和输入法行为。诊断可以导航到源码范围。预览有文本替代,并在键盘可访问的对话框中打开。界面支持 320 像素布局、明暗对比度、可见焦点和减少动态效果偏好。 diff --git a/content/site/zh/guide/provider-icons.md b/content/site/zh/guide/provider-icons.md new file mode 100644 index 0000000..1d80962 --- /dev/null +++ b/content/site/zh/guide/provider-icons.md @@ -0,0 +1,118 @@ +# 云服务商图标 + +Stack 内置与服务商无关的核心图标目录。AWS、Google Cloud、Azure 以及常用开发和协作工具图形通过 provider pack 使用,并保存在用户管理的 icon store 中。 + +## 可用的服务商目录 + +已审核目录共有 1,051 个 ID:305 个 AWS Architecture Icons、45 个 Google Cloud 产品与分类图标、639 个 Azure 服务图标,以及 62 个常用工具图标。工具目录包括 GitHub、GitHub Actions、Notion、Linear、Atlassian、Jira、Confluence、Docker、Kubernetes、Terraform、Datadog、Grafana 和 Sentry 等。 + +选择服务商卡片即可查看导入命令。完整目录支持搜索与筛选,并以每次 100 项的方式在小屏设备上稳定显示。 + + + +Provider pack 提供图形;Stack 源码中的节点 `kind` 继续决定语义样式和布局。 + +## 快速开始 + +为图中使用的每个服务商执行一次导入。`--accept-terms` 表示你已查看并接受链接中的服务商和品牌条款。 + +```sh +$ stack icons import gcp --accept-terms +$ stack icons import simple-icons --accept-terms +$ stack render architecture.stack -o architecture.svg +``` + +CLI 会下载已审核的官方压缩包,验证完整 SHA-256,清理选定 SVG,并将处理后的 provider pack 写入共享 icon store。一个 `gcp` 命令会同时导入 Google Cloud 产品和分类图形。 + +## 在 CLI 中使用服务商图标 + +一个 Stack 文件可以使用多个服务商。下面的例子组合了 Google Cloud 的 Cloud Run 与 Simple Icons 的 GitHub: + +```stack +stack 1.0 + +diagram "Deploy from GitHub to Cloud Run" { + node repository "GitHub" { + kind external + icon "simple-icons:github" + } + + node service "Cloud Run" { + kind service + icon "gcp:cloud-run" + } + + edge repository -> service "Deploy" { + kind dependency + } +} +``` + +完成两次导入后,标准渲染命令会发现两个 pack: + +```sh +$ stack render architecture.stack -o architecture.svg --notice architecture.NOTICE.md +``` + +## 共享 icon store + +默认 icon store 为 `$XDG_CONFIG_HOME/stack/icons`。未设置 `XDG_CONFIG_HOME` 时使用 `$HOME/.config/stack/icons`。 + +```text +icons/ + aws/ + gcp/ + azure/ + simple-icons/ +``` + +可在 `$XDG_CONFIG_HOME/stack/config.yaml` 中设置绝对路径来更改共享位置: + +```yaml +default_icons_path: /absolute/path/to/stack-icons +``` + +`stack icons import` 与 `stack render` 都会使用该位置。 + +## 在 Playground 中使用服务商图标 + +打开 **Icons**,选择 `stack/icons` 文件夹,Playground 会加载其中所有可识别的服务商目录。搜索已加载图形并选择一项,即可把 ID 复制到 Stack 源码中。 + +所选 pack 在当前浏览器标签页中处理。当生成图使用服务商图形时,SVG 下载旁的 **Notice** 会提供来源、条款和已使用图标记录。 + +## 将图标与项目一起管理 + +使用 `-o` 将导入的 pack 放进可随仓库提交的项目目录: + +```sh +$ stack icons import gcp --accept-terms -o .stack-icons +$ stack icons import simple-icons --accept-terms -o .stack-icons +``` + +渲染时通过 `--provider-pack` 传入同一个 icon-store 根目录: + +```sh +$ stack render architecture.stack \ + --provider-pack .stack-icons \ + -o architecture.svg \ + --notice architecture.NOTICE.md +``` + +## 查找图标 ID + +可通过 CLI 或本页搜索目录: + +```sh +$ stack icons list +$ stack icons list aws s3 +$ stack icons list azure database +$ stack icons list simple-icons github +``` + +CLI 输出包含 `ID`、`PRODUCT`、`CATEGORY` 和推荐的 `KIND`。`gcp:cloud-run`、`simple-icons:github` 等带命名空间的 ID 会选择对应 pack 中的图形。 + +## 验证、条款与 notice + +CLI 目录固定了每个官方 HTTPS 压缩包 URL、版本、完整 SHA-256、允许的条目路径、条款 URL 与审核日期。导入时会限制压缩包与 SVG 大小,清理活动及外部 SVG 内容,并以原子方式写入 pack。 + +每个 pack 都包含 `NOTICE.md`。`stack render --notice ` 会写入实际 pack 版本、来源版本、条款 URL、署名、非背书文本和已使用的图标 ID。目录还链接每个服务商的官方来源与条款,以及 Simple Icons 标志对应的品牌来源和指南。 diff --git a/content/site/zh/guide/what-is-stack.md b/content/site/zh/guide/what-is-stack.md new file mode 100644 index 0000000..c505901 --- /dev/null +++ b/content/site/zh/guide/what-is-stack.md @@ -0,0 +1,51 @@ +# 什么是 Stack? + +Stack 是一种用于静态软件架构图和技术栈图的小型声明式语言。你在 UTF-8 `.stack` 文件中描述组件、边界与关系,由渲染器决定坐标、间距、连线路径、字体和视觉表现。 + +这种分工让源文件简洁、易审查,也适合版本控制。同一份文档可以由兼容工具格式化、检查和渲染,而不会变成绘图指令集合。 + +## 基本模型 + +每份文档包含一个语言版本和且仅一个图。图中可包含节点、分组、连线、主题和布局意图。 + +```stack +stack 1.0 + +diagram "Service architecture" { + node client "Web app" { + kind client + } + + node api "API" { + kind service + detail "Order orchestration" + } + + edge client -> api "HTTPS" { + kind request + } +} +``` + +这段源代码表达客户端调用服务,但没有规定方框位置或箭头如何转弯。 + +## Stack 的设计目标 + +- **简洁编写:** 只需命名节点和连线即可得到有用的图。 +- **可预测生成:** 人和语言模型都能用一种受约束的方式稳定表达概念。 +- **语义源文件:** 记录拓扑和意图,而不是像素。 +- **一致输出:** 渲染器拥有统一的视觉系统。 +- **可操作错误:** 诊断可指向源码范围,并给出候选值、修复帮助和相关声明。 +- **安全嵌入:** 源文件不能执行代码、获取任意资源或注入 HTML/SVG。 + +## Stack 不是什么 + +Stack 1.0 不是通用图语言、像素级画布、基础设施定义或可执行编程语言。它没有变量、导入、宏、条件、CSS、坐标、任意 URL 或嵌入 HTML,也不用于顺序图、状态机、类图、ER 图或完整 UML。 + +大型系统应拆成多张聚焦的图。Stack 为可读性设置了元素上限,而不是允许无限扩张。 + +## 处理模型 + +工具依次解码和解析文档、解析标识符与默认值、验证语义、解析主题与图标、求解布局并渲染。源代码错误会阻止渲染。可选主题或图标缺失、布局提示无法满足时会产生警告,并仍可返回回退图。 + +[语言页面](../language/syntax)介绍所有编写结构;[版本与安全](../reference/versioning-and-safety)介绍兼容性和信任边界。 diff --git a/content/site/zh/index.md b/content/site/zh/index.md new file mode 100644 index 0000000..7df8d09 --- /dev/null +++ b/content/site/zh/index.md @@ -0,0 +1,27 @@ +--- +layout: home + +hero: + name: Stack + text: 将架构写成源代码。 + tagline: 编写一份简洁的语义文档,无需指定坐标或逐个设置方框样式,即可生成一致且无障碍的架构图。 + image: + light: /favicon.svg + dark: /favicon.svg + alt: Stack 标志 + actions: + - theme: brand + text: 快速开始 + link: /zh/guide/getting-started + - theme: alt + text: 打开 Playground + link: https://stack-diagram.com/ + +features: + - title: 描述系统 + details: 用简洁、可读的 .stack 文件记录节点、分组、关系和布局意图。 + - title: 保持语义可移植 + details: 带版本的语言和结构化诊断将架构语义与渲染器选择分离。 + - title: 安全渲染 + details: 引擎生成不含脚本、任意 HTML 或网络资源的独立 SVG。 +--- diff --git a/content/site/zh/language/edges-and-layout.md b/content/site/zh/language/edges-and-layout.md new file mode 100644 index 0000000..97bae99 --- /dev/null +++ b/content/site/zh/language/edges-and-layout.md @@ -0,0 +1,78 @@ +# 连线与布局 + +连线描述节点之间的关系。布局块用少量意图控制放置方式,而不暴露坐标或绘图原语。 + +## 连线方向 + +连线连接两个不同节点。允许前向引用,不允许自连线或使用分组作为端点。 + +| 操作符 | 含义 | +| ------ | -------------------------------- | +| `->` | 从左侧节点指向右侧节点的有向关系 | +| `<->` | 双向对称的一个关系 | +| `--` | 无方向或有意不指定方向的关联 | + +`<->` 是一个关系,不是两条可独立标注连线的缩写。 + +## 连线种类与标签 + +可选标签描述协议、事件、命令、数据集或用途,长度为 1 至 40 个 Unicode scalar。可选 `kind` 与标签独立描述关系,默认值是 `flow`。 + +| Kind | 预期含义 | +| ------------ | -------------------------- | +| `flow` | 通用运行时或概念流 | +| `request` | 同步请求或调用 | +| `event` | 异步消息或事件传递 | +| `data` | 数据移动、复制、读取或写入 | +| `dependency` | 构建、部署或运维依赖 | + +```stack +stack 1.0 + +diagram "Relationships" { + node web "Web app" { + kind client + } + + node api "API" + node queue "Events" { + kind queue + } + + edge web -> api "HTTPS" { + kind request + } + + edge api -> queue "OrderPlaced" { + kind event + } +} +``` + +表达不同关系时,同一对节点之间可以有多条连线。端点、操作符、标签和有效 kind 全部相同的精确重复无效。比较 `<->` 和 `--` 重复时忽略端点顺序。 + +## 布局作用域 + +一个图或分组最多包含一个 `layout` 块。分组中的布局只影响其直接子项,图中的布局只影响图的直接子项。`rank` 和 `order` 必须引用同一作用域中至少两个不同的直接子项。 + +布局把直接子分组视为一个项。不同分组后代节点之间的连线会形成直接子项之间的连接,因此即使分组不能作为连线端点,顶层布局仍可排列分组。 + +## Direction、rank 与 order + +```stack +layout { + direction right + rank same [web, worker] + order [web, worker, database] +} +``` + +- `direction right` 偏好从左到右,`direction down` 偏好从上到下。它是强提示,但不保证每条连线都朝该几何方向;嵌套分组不会继承。 +- `rank same [a, b]` 是约束,要求列出的直接子项位于同一布局 rank。同一作用域中的一个子项不能出现在两个 same-rank 语句中。 +- `order [a, b]` 是相对顺序提示。向右布局时按从上到下,向下布局时按从左到右,自动布局时沿选定 cross-axis 解释。可以省略其他子项。 + +为满足包含关系、same-rank 约束、可读性或输出边界,渲染器可以偏离 `order`。支持诊断的工具此时应发出 `STK4001`。 + +## 渲染器负责的决定 + +Stack 不提供坐标、尺寸、端口、路径、颜色、字体、换行或 z-index。渲染器负责防止重叠、保持包含与方向、确保标签可读、避开节点内部布线,并扩展画布而不裁剪语义内容。 diff --git a/content/site/zh/language/formatting.md b/content/site/zh/language/formatting.md new file mode 100644 index 0000000..dc1cca4 --- /dev/null +++ b/content/site/zh/language/formatting.md @@ -0,0 +1,58 @@ +# 规范格式化 + +Stack 为每份词法和语法有效的文档定义唯一规范字节形式。格式化保持语言版本、语义和所有行注释不变,并让 diff 保持一致。 + +## 可格式化的源文件 + +格式化器接受不含 BOM 的 UTF-8。词法或语法错误只返回诊断,不会返回部分改写结果。语法有效时,即使存在语义或复杂度诊断也可以格式化;格式化成功不代表图有效。 + +## 规范输出 + +规范源文件: + +- 使用不含 BOM 的 UTF-8; +- 将所有换行规范为 LF; +- 每层缩进使用两个 ASCII 空格,不使用格式化制表符; +- 行尾没有格式化空白; +- 结尾恰好一个 LF; +- 左花括号留在声明或 `layout` 行,右花括号独占一行; +- 版本与图、相邻 body member 之间有一个空行; +- 属性和布局语句之间没有空行。 + +```stack +stack 1.0 + +diagram "Title" { + theme dark + + node client "Client" + + node api "API" { + kind service + detail "Public API" + } + + edge client -> api "HTTPS" { + kind request + } + + layout { + direction right + order [client, api] + } +} +``` + +## 顺序与列表 + +格式化器保持图和分组成员、节点和连线属性、布局语句及列表标识符的原始顺序,绝不分组或排序。列表保持一行,逗号后一个空格,方括号内侧无空格,也没有尾随逗号。 + +## 字符串 + +有效字符串会被解码,并在不进行 Unicode normalization 的情况下直接输出为 UTF-8。引号和反斜杠保持转义;规范输出不使用 `\uXXXX`。例如 `"API \u56F3 \uD83D\uDE80"` 会变成 `"API 図 🚀"`。 + +## 注释 + +所有行注释及其顺序都会保留。尾随注释在前一个 token 后用一个空格连接。独立行注释保持 token gap,紧邻后续成员、语句或属性。结构内部的注释可以强制续行,这是通常单行规则的唯一例外。 + +再次格式化规范源文件必须得到逐字节相同结果。存在 normalized IR 时,格式化前后必须产生语义相同的 IR。 diff --git a/content/site/zh/language/nodes-and-groups.md b/content/site/zh/language/nodes-and-groups.md new file mode 100644 index 0000000..b64140c --- /dev/null +++ b/content/site/zh/language/nodes-and-groups.md @@ -0,0 +1,67 @@ +# 节点与分组 + +节点是可引用的架构实体,分组是带标签的包含边界。两者共同描述图中可见的组件与作用域。 + +## 节点 + +节点需要全局唯一标识符和可见标签。标识符供连线和布局语句引用,但不会渲染;标签长度为 1 至 60 个 Unicode scalar。 + +```stack +stack 1.0 + +diagram "Node example" { + node api "Public API" { + kind service + detail "Order orchestration" + } +} +``` + +不同实体可以使用相同可见标签,但最好让标签不依赖位置也能理解。节点块不能重复 `kind`、`icon` 或 `detail`。 + +## 节点种类 + +`kind` 表示粗粒度架构语义,并选择由主题控制的形状和回退图标。默认值是 `service`。 + +| Kind | 预期含义 | +| ---------- | --------------------------------------- | +| `actor` | 人、角色、团队或自主参与者 | +| `client` | 浏览器、移动/桌面应用、设备或其他客户端 | +| `service` | 长期运行的应用、API、网关或通用组件 | +| `function` | 按需或 serverless 计算单元 | +| `worker` | 后台处理器或定时任务 | +| `database` | 持久、可查询的数据存储 | +| `cache` | 内容可丢弃或可重新生成的数据存储 | +| `queue` | 用于异步传递的队列、流、总线或 broker | +| `storage` | Blob、对象、文件或归档存储 | +| `external` | 架构控制边界之外的系统 | + +Kind 是语义分类,不是厂商形状。托管 PostgreSQL 仍是 `database`,技术名称应写入 `detail`。 + +## 标签与详情 + +`detail` 是可选的可见第二行,长度为 1 至 80 个 Unicode scalar。可填写一种技术或简短职责,如 `"Next.js"`、`"PostgreSQL 17"` 或 `"Order orchestration"`。它必须在所有渲染图中可见,不能只放在 tooltip 中。 + +标签和详情是纯文本。显式 `icon` 只装饰节点,不改变 kind、identity 或无障碍标签。另见[主题与图标](./themes-and-icons)。 + +## 分组 + +分组需要全局唯一标识符、1 至 60 个 Unicode scalar 的标签,以及至少一个后代节点。它可包含节点、嵌套分组和一个布局块。 + +```stack +stack 1.0 + +diagram "Boundaries" { + group platform "Platform" { + group data "Data layer" { + node primary "Primary database" { + kind database + } + } + } +} +``` + +分组最多可在图下嵌套三层。节点属于最近的分组,也传递地属于所有祖先分组。声明不能复用,因此一个节点不能同时属于两个独立分组。 + +连线必须在图作用域声明,且只有节点可作为端点。分组不会产生隐式节点或连线。标签用于说明它代表系统、领域、网络、部署区域、团队或其他边界;包含关系本身不表示运行时隔离、安全性、所有权或部署语义。 diff --git a/content/site/zh/language/syntax.md b/content/site/zh/language/syntax.md new file mode 100644 index 0000000..12a0281 --- /dev/null +++ b/content/site/zh/language/syntax.md @@ -0,0 +1,95 @@ +# 文档与语法 + +Stack 源文件被刻意设计得很小。本页完整介绍 draft Stack 1.0 的词法结构与语法。 + +## 文档结构 + +文档是一个不含 BOM 的 UTF-8 `.stack` 文件。LF 与 CRLF 含义相同。第一个非注释 token 必须是版本指令,之后只能有且仅有一个图,不能再有其他声明。 + +```stack +// One file, one diagram. +stack 1.0 + +diagram "Example" { + node api "API" +} +``` + +图标题必填,长度为 1 至 80 个 Unicode scalar,开头和结尾不能是 Unicode 空白。图中至少要有一个节点。 + +## 注释与空白 + +空格、制表符和换行用于分隔 token,除此之外没有语义。行注释从 `//` 开始,到行尾结束,可出现在允许空白的位置。不支持块注释。 + +格式本身没有语义,但规范格式化器会生成[规范格式化](./formatting)定义的一致形式。 + +## 标识符 + +节点、分组、主题和引用标识符匹配: + +```text +[a-z][a-z0-9_-]* +``` + +长度为 1 至 64 个 ASCII 字符,区分大小写,且不会显示。节点和分组共享一个全局命名空间。关键字是上下文相关的,技术上也可用于标识符位置,但应避免降低可读性的名称。 + +图标标识符是带引号的字符串,解码后匹配 `[a-z0-9][a-z0-9-]*`,长度同样为 1 至 64 个 ASCII 字符,并在有效主题内解析。 + +## 字符串 + +字符串使用双引号,可直接包含 Unicode。只支持三种转义: + +| 转义 | 含义 | +| -------- | ----------------- | +| `\"` | 双引号 | +| `\\` | 反斜杠 | +| `\uXXXX` | Unicode code unit | + +解码后的字符串不能包含换行、制表符、控制字符或未配对 surrogate。标题、标签和详情不能以 Unicode 空白开头或结尾。字符串始终是纯文本,不会解释为 Markdown 或 HTML。 + +## 完整语法 + +```text +document = version-directive, diagram-declaration, EOF ; +version-directive = "stack", integer, ".", integer ; +diagram-declaration + = "diagram", string, "{", { diagram-member }, "}" ; +diagram-member = node-declaration | group-declaration | edge-declaration + | theme-statement | layout-block ; +theme-statement = "theme", identifier ; +group-declaration = "group", identifier, string, "{", { group-member }, "}" ; +group-member = node-declaration | group-declaration | layout-block ; +node-declaration = "node", identifier, string, [ node-block ] ; +node-block = "{", node-property, { node-property }, "}" ; +node-property = "kind", node-kind | "icon", string | "detail", string ; +node-kind = "actor" | "client" | "service" | "function" | "worker" + | "database" | "cache" | "queue" | "storage" | "external" ; +edge-declaration = "edge", identifier, edge-operator, identifier, + [ string ], [ edge-block ] ; +edge-operator = "->" | "<->" | "--" ; +edge-block = "{", edge-property, { edge-property }, "}" ; +edge-property = "kind", edge-kind ; +edge-kind = "flow" | "request" | "event" | "data" | "dependency" ; +layout-block = "layout", "{", layout-statement, + { layout-statement }, "}" ; +layout-statement = direction-statement | rank-statement | order-statement ; +direction-statement + = "direction", ( "right" | "down" ) ; +rank-statement = "rank", "same", identifier-list ; +order-statement = "order", identifier-list ; +identifier-list = "[", identifier, ",", identifier, + { ",", identifier }, "]" ; +integer = "0" | nonzero-digit, { digit } ; +``` + +## 上下文关键字 + +Stack 1.0 在对应语法位置识别: + +```text +stack diagram group node edge theme layout kind icon detail direction +rank same order right down actor client service function worker +database cache queue storage external flow request event data dependency +``` + +未知声明、属性、枚举值和操作符都是错误。工具不会静默忽略可能生成外观合理但语义错误图形的语法。 diff --git a/content/site/zh/language/themes-and-icons.md b/content/site/zh/language/themes-and-icons.md new file mode 100644 index 0000000..6d8fda0 --- /dev/null +++ b/content/site/zh/language/themes-and-icons.md @@ -0,0 +1,126 @@ +# 主题与图标 + +主题是图级别、由渲染器管理的视觉系统符号引用。图标是在该主题内解析的逻辑名称。两者都不会改变图的语义。 + +## 选择主题 + +在图中最多添加一条 `theme` 语句: + +```stack +stack 1.0 + +diagram "Dark architecture" { + theme dark + + node api "API" +} +``` + +省略时使用 `default`。Draft Stack 1.0 要求核心 catalog 提供: + +| Theme | 用途 | +| --------- | ---------------------------- | +| `default` | 适合通用架构图的均衡蓝灰表面 | +| `light` | 适合浅色文档的暖中性色表面 | +| `dark` | 适合深色画布的高对比冷色表面 | + +源文件选择标识符,而不是 catalog package 版本。渲染 metadata 记录 catalog 版本和内容 revision,以标识实际使用的视觉数据。 + +生成图主题与 Playground 的明暗界面相互独立。主题可改变 palette、字体 metrics、surface、icon、connector 和 background,但不能隐藏或改变节点、分组、连线、标签、kind、方向或布局约束。 + +## 回退行为 + +三个核心主题是渲染器必需资源。当前 catalog 中不存在的非核心主题会发出 `STK6001`,并使用 `default` 渲染。引擎不会因为源文件出现主题标识符就从网络下载主题。 + +主题标识符使用普通 Stack 标识符语法。一旦注册,即使废弃后也不能重新分配给另一个主题。 + +## Kind 回退图标 + +每个主题为所有节点 kind 提供回退。省略 `icon` 时渲染器使用它。 + +| Node kind | 当前逻辑回退图标 | +| ---------- | ---------------- | +| `actor` | `kind-actor` | +| `client` | `kind-client` | +| `service` | `kind-service` | +| `function` | `kind-function` | +| `worker` | `kind-worker` | +| `database` | `kind-database` | +| `cache` | `kind-cache` | +| `queue` | `kind-queue` | +| `storage` | `kind-storage` | +| `external` | `kind-external` | + +当前开放核心 catalog 在 `default`、`light` 和 `dark` 中包含这十个回退标识符,尚不包含 `postgresql`、`aws` 或 `github` 等厂商图标。多数文档应选择语义 `kind` 并省略 `icon`。 + +## 显式图标 + +显式图标使用带引号的逻辑标识符: + +```stack +stack 1.0 + +diagram "Explicit icon" { + node gateway "Public API" { + kind service + icon "api" + } +} +``` + +图标只装饰节点,不改变 `service` kind、identity、label 或无障碍说明。同一标识符在不同主题中表示同一个逻辑对象,但颜色与图形可以适配主题。 + +## 第一方图标目录 + +免费核心 catalog 在 `default`、`light` 和 `dark` 中提供以下与厂商无关的显式图标: + +| ID | Stable subject | 主要用途 | +| --------------- | --------------------------------- | --------------------- | +| `api` | Application programming interface | 公共或内部 API | +| `web` | Web application | 面向浏览器的 Web 体验 | +| `mobile` | Mobile application | iOS 或 Android 客户端 | +| `desktop` | Desktop application | 原生桌面客户端 | +| `server` | Server host | 虚拟机或物理主机 | +| `container` | Application container | 容器化工作负载 | +| `cluster` | Compute cluster | 编排后的计算集群 | +| `cloud` | Cloud environment | 与厂商无关的云边界 | +| `scheduler` | Scheduled execution | Cron 任务或定时工作 | +| `webhook` | Webhook endpoint | 入站或出站回调 | +| `identity` | Identity and access | 身份验证或授权 | +| `observability` | Observability system | 指标、日志或链路追踪 | +| `gateway` | Network gateway | 公共或私有网络入口 | +| `load-balancer` | Load balancer | 流量分发 | +| `dns` | Domain name service | 主机名与服务发现 | +| `cdn` | Content delivery network | 边缘内容分发 | +| `firewall` | Network firewall | 网络访问边界 | +| `network` | Network topology | 通用网络或子网 | +| `event` | Discrete event | 单个领域或系统事件 | +| `stream` | Event stream | 连续事件或数据流 | +| `search` | Search service | 索引与查询系统 | +| `analytics` | Analytics system | 报告或数据分析 | +| `repository` | Source code repository | 源代码与版本控制 | +| `pipeline` | Delivery pipeline | 构建、测试或部署流程 | +| `secret` | Secret or credential | 密钥或凭据 | +| `document` | Document or knowledge base | 文档与知识库 | +| `task` | Task or issue tracker | 任务、工单或问题跟踪 | +| `chat` | Chat or messaging tool | 团队聊天或消息 | +| `email` | Email delivery | 邮件投递或收件箱 | +| `ai` | Artificial intelligence system | AI 模型或推理服务 | + +切换下方预览的浅色与深色模式即可比较真实输出。每张图片都由已发布的 `@stack-sh/engine@0.7.0` 在本地渲染;文档没有复制 Theme SVG 资源。选择语法行即可复制。 + + + +语义 `kind` 与显式图标应独立选择。例如,`icon "web"` 可以装饰 `client` 或 `service` 节点,但不会改变该节点的含义。 + +## 缺失图标与厂商图标 + +核心 catalog 目前不包含 `postgresql`、`aws`、`github` 或 `docker` 等厂商或项目标志。如果有效主题没有编写的图标标识符,引擎会继续使用节点 kind 的回退图标渲染,并发出 `STK5001`。 + +请优先选择上表中与厂商无关的图标;如果 kind 回退已能表达角色,也可以省略 `icon`。厂商标志只有在逐项完成资源 license、再分发和商标审查后,才能进入独立 catalog。 + +## Catalog 与资源安全 + +公共 `stack-sh/theme` catalog 拥有 palette、确定性字体 metrics、node-kind visual、connector、icon metadata、SVG bytes、来源和再分发许可。Catalog 资源随渲染器打包,编写的标识符绝不会被当成文件路径或 URL。 + +SVG 验证会拒绝脚本、事件处理器、嵌套 SVG、不安全引用、data/network URL、style 属性和 allowlist 外元素或属性。图标不能成为表达意义的唯一方式,标签和非颜色区分也必须保留。 diff --git a/content/site/zh/reference/diagnostics-and-limits.md b/content/site/zh/reference/diagnostics-and-limits.md new file mode 100644 index 0000000..2543e93 --- /dev/null +++ b/content/site/zh/reference/diagnostics-and-limits.md @@ -0,0 +1,58 @@ +# 诊断与限制 + +Stack 诊断是结构化结果,不是控制台文本。它包含稳定代码、`error` 或 `warning` 严重级别、从 1 开始且 end-exclusive 的源码范围、简洁消息和有序 `expected` 列表;适用时还包含修复帮助与相关源码范围。 + +## 处理与严重级别 + +工具依次处理编码与 token、语法、标识符与默认值、语义限制、主题与图标、布局、渲染。前四阶段的错误会阻止渲染。主题、图标、密度和布局提示警告可与回退 SVG 同时出现。 + +编辑源码后,Playground 会清除旧诊断。选择结果可聚焦主范围,相关信息可指向较早的声明。 + +## 复杂度限制 + +| 项目 | Draft Stack 1.0 限制 | +| ----------------------- | -----------------------------: | +| 每份文档的图 | 1 | +| 节点 | 1 至 40 | +| 分组 | 0 至 12 | +| 图下分组嵌套 | 3 层 | +| 连线 | 0 至 80 与节点数两倍中的较小值 | +| 发出警告前的节点 degree | 12 条 incident edge 声明 | + +超过硬限制会产生 `STK4003`。超过建议 degree 的节点仍有效,但产生 `STK4002`。请把大型系统拆成多张聚焦的图。 + +## 可移植诊断代码 + +| Code | Severity | 含义 | +| --------- | -------- | -------------------------------------- | +| `STK1001` | Error | 输入不是有效 UTF-8 | +| `STK1002` | Error | 存在 byte order mark | +| `STK1003` | Error | 字符串转义或解码值无效 | +| `STK2001` | Error | 声明的语言版本不受支持 | +| `STK2002` | Error | 出现意外 token、声明、属性、值或操作符 | +| `STK2003` | Error | 当前结构完成前输入结束 | +| `STK3001` | Error | 标识符无效 | +| `STK3002` | Error | 标识符被重复声明 | +| `STK3003` | Error | 连线引用未知节点 | +| `STK3004` | Error | 分组被用作连线端点 | +| `STK3005` | Error | 连线连接节点自身 | +| `STK3006` | Error | 声明了精确重复连线 | +| `STK3007` | Error | 一个 block 中属性重复 | +| `STK3008` | Error | 标题、标签或详情违反文本约束 | +| `STK3009` | Error | 分组没有后代节点 | +| `STK3010` | Error | 分组嵌套超过语言限制 | +| `STK3011` | Error | 布局引用在作用域内无效 | +| `STK3012` | Error | 布局块或单例布局语句重复 | +| `STK3013` | Error | 图标标识符格式错误 | +| `STK3014` | Error | 图包含多条主题语句 | +| `STK4001` | Warning | 顺序提示无法满足 | +| `STK4002` | Warning | 节点超过建议 incident-edge degree | +| `STK4003` | Error | 图超过语言复杂度限制 | +| `STK5001` | Warning | 有效主题中没有图标,使用 kind 回退 | +| `STK6001` | Warning | 请求的非核心主题不可用,使用 `default` | + +代码族中,`STK1000` 表示编码/词法,`STK2000` 表示语法,`STK3000` 表示名称/语义,`STK4000` 表示布局/复杂度,`STK5000` 表示图标,`STK6000` 表示主题。`STK9000` 用于实现失败,而不是源码错误。实现只能使用自己的非 `STK` 前缀添加诊断。 + +## 恢复规则 + +解析器可以恢复并一次报告多个独立错误,但不能把部分图渲染成有效结果。未知声明、属性、枚举值和操作符绝不会被忽略,以避免成功外观掩盖语义丢失。 diff --git a/content/site/zh/reference/versioning-and-safety.md b/content/site/zh/reference/versioning-and-safety.md new file mode 100644 index 0000000..1d46fd1 --- /dev/null +++ b/content/site/zh/reference/versioning-and-safety.md @@ -0,0 +1,40 @@ +# 版本与安全 + +Draft Stack 1.0 将源语言、实现、主题 catalog 和 package 版本分开。理解该边界有助于文档移植和追踪渲染输出。 + +## 语言版本 + +每份文档以 `major.minor` 指令开始: + +```stack +stack 1.0 + +diagram "Versioned source" { + node api "API" +} +``` + +它表示文档要求的最低语言语法与语义,不是引擎或主题版本。支持 `M.N` 的渲染器接受相同 major 且 minor 不大于 `N` 的文档,拒绝不同 major,并在未明确支持时拒绝更高 minor;不会猜测未来语法。 + +Specification release 使用 semantic versioning。Major 可带来不兼容语言变化;minor 添加向后兼容能力;patch 只澄清文字或修正勘误,不改变有效源码含义,因此文档指令不包含 patch。 + +## 渲染器与 catalog 标识 + +普通引擎结果包含引擎版本、编写的语言版本、主题 catalog 版本和 catalog 内容 revision。源码 `theme` 只选择符号标识符,不 pin package release,也不获取远程数据。 + +逐像素一致不是语言兼容性承诺。主题 metrics、渲染器版本、字体和画布决定可以改变位置,但必须保持节点、分组、关系、标签、kind 和约束。 + +## 安全的源文件边界 + +Stack 字符串是纯文本。源文件不能包含可执行代码、任意 HTML/Markdown、CSS、SVG、导入、宏、文件路径或网络 URL。引擎会转义编写文本,并生成包含已验证 catalog 图标、本地 marker reference、无障碍 title/description metadata 的独立 SVG。 + +渲染 SVG 不含脚本、事件处理器、任意外部引用、宿主字体测量或运行时 I/O。缺失图标或主题会选择已打包回退,而不是解析路径或连接 registry。 + +## 当前交付状态 + +- 浏览器 Playground 是受支持的公共体验。 +- 公共 `@stack-sh/engine` 提供 Playground 使用的 typed WebAssembly `format`、`check` 和 `render`。 +- 公共 `@stack-sh/language` 提供编辑器高亮使用的共享 TextMate grammar 和语言 metadata。 +- 公共 [`stack-sh/cli`](https://github.com/stack-sh/cli) 提供原生 `format`、`check`、`render` 和 provider-icon store 操作。 + +规范语言合同位于 [`stack-sh/specification`](https://github.com/stack-sh/specification),公共主题 catalog 位于 [`stack-sh/theme`](https://github.com/stack-sh/theme),引擎行为位于 [`stack-sh/engine`](https://github.com/stack-sh/engine)。 diff --git a/generated/manifest.json b/generated/manifest.json index 4d5798d..6a212b4 100644 --- a/generated/manifest.json +++ b/generated/manifest.json @@ -13,6 +13,246 @@ { "path": "guide/agent-workflow.md", "sha256": "66fe4c3c97afad3a740d9ab824c5aae3f43783bfa251fe0347666b38bc3afc9b" + }, + { + "path": "site/examples/index.md", + "sha256": "458d6c20c38e7575a106674cae869aed2ec8470aaa51f0a4625afc59017cf50f" + }, + { + "path": "site/guide/coding-agents.md", + "sha256": "2226574cfe247957177a4982e4a21d603ae39e0510e3e24f7a20e3c03566fb92" + }, + { + "path": "site/guide/getting-started.md", + "sha256": "ab944f4c19c0a1783fe0c9217cb4ff84ead7b3a07d3b8d101b25246d5ef1df87" + }, + { + "path": "site/guide/playground.md", + "sha256": "5fd132342001a05200efd974517cf2ac03d89fdbb012937fad91f7b68a3a24ea" + }, + { + "path": "site/guide/provider-icons.md", + "sha256": "6532eb3d53e169eb71065cbb9bdb3f7fbdea2054fa624f7cd6e51986408cb071" + }, + { + "path": "site/guide/what-is-stack.md", + "sha256": "ab46e1a9652452dbdb9502726451ae42c926036bb3faa3639605e562d994d1e2" + }, + { + "path": "site/index.md", + "sha256": "2c7a4c60b27975c811efd7a6323d16791b16e8b713bfd2eac03d4f14dfdf4e70" + }, + { + "path": "site/ja/examples/index.md", + "sha256": "56b4ca1171feaa383b4b9af622d8a899e19d02b26aa1c6011682d81d67f7647a" + }, + { + "path": "site/ja/guide/coding-agents.md", + "sha256": "eb33ee71336e235cd71c38128c33ef5f68bf9941fe897a1a49683bfe982fc9a0" + }, + { + "path": "site/ja/guide/getting-started.md", + "sha256": "85b80a8c3a45c97de43cdc2fb73cfa608fbac48f34b1a8eff67c1676084e386c" + }, + { + "path": "site/ja/guide/playground.md", + "sha256": "aae455a12a660766102bc5f173f52516cf25e979734f36d7683a62cbcde9355c" + }, + { + "path": "site/ja/guide/provider-icons.md", + "sha256": "74cc764285ff32bef5ee3c90ac4742ecab0558f53346ddfe1286db675d61f7e9" + }, + { + "path": "site/ja/guide/what-is-stack.md", + "sha256": "1206d992d898f626d7505ae64d494513175bb53766845006a5921e7d32e44b25" + }, + { + "path": "site/ja/index.md", + "sha256": "0e24d302a65bcaa7cfcc7793c6d059449514ddedfff2e14dbc07ff993dfe147c" + }, + { + "path": "site/ja/language/edges-and-layout.md", + "sha256": "a3255e9c623e7c46add20ea2d7e42f578d00d474107c327f6198932231596887" + }, + { + "path": "site/ja/language/formatting.md", + "sha256": "75043f8afbd81c629171e6aa2b4a16c12823bbc3d150bcc6a99b147d90da8a1a" + }, + { + "path": "site/ja/language/nodes-and-groups.md", + "sha256": "e953db6f6cd06d4ee645e2a83583f2d0b2eec92ea09bc1390edcf994d52b514c" + }, + { + "path": "site/ja/language/syntax.md", + "sha256": "542935d48c245856a3852fa05c3e6c5ebe53e88d3cddf7216e89e3ea3a681a07" + }, + { + "path": "site/ja/language/themes-and-icons.md", + "sha256": "5a8db9a572b0b5231ea1620fb23107e6ac04a1f61dfcf25402d9e80944d3c23d" + }, + { + "path": "site/ja/reference/diagnostics-and-limits.md", + "sha256": "8c012f3f7f6e6b59a42e431eb7ab84004d37075f05f59b0b745551bc093d542a" + }, + { + "path": "site/ja/reference/versioning-and-safety.md", + "sha256": "f22d30a71ecd2578f46034a055c85e78cc37b979d73a2170f84fb9d66c8672c5" + }, + { + "path": "site/ko/examples/index.md", + "sha256": "fcc69e690339ab7a89c8dd2a67f9525cddae6a1c5b867068db13a5814d105de0" + }, + { + "path": "site/ko/guide/coding-agents.md", + "sha256": "a2aace3cfffa01d8a0a240c8a8bac0924f0f82b4aecedcbc5cd7cd53a275dfaa" + }, + { + "path": "site/ko/guide/getting-started.md", + "sha256": "eb2d4acc5d12b28433a6eadfcee159a8baf9615fce3a4b66aff4c36760716d16" + }, + { + "path": "site/ko/guide/playground.md", + "sha256": "003841867074cc84012801d8fec299dd0a15d48b62592140c0639dffaf86085d" + }, + { + "path": "site/ko/guide/provider-icons.md", + "sha256": "d8138ac74047ad8e07034d5b24739a2032b2042db002f9eb7c8f37aa54305724" + }, + { + "path": "site/ko/guide/what-is-stack.md", + "sha256": "cc1e807ac44f57af084a6b87bdccb3ecb5484462ebd5852be3b97692d66d3f86" + }, + { + "path": "site/ko/index.md", + "sha256": "1d625195c05e182786ecec258e4ca994429bf6f39ea3068b4429befe3cf2211d" + }, + { + "path": "site/ko/language/edges-and-layout.md", + "sha256": "8326194eaf41087a5fe8ddfc030047593137e440d2eeb6dd3791dce533ffbf41" + }, + { + "path": "site/ko/language/formatting.md", + "sha256": "4145f94b2d3dbc0963854d63660caf98725ff94d75e929f9d3eb814350b27bfd" + }, + { + "path": "site/ko/language/nodes-and-groups.md", + "sha256": "bba8f1c8f9ac9897c6cf39f8bf21ce618335824d2d3c0b2bd3179765dbfcd7b3" + }, + { + "path": "site/ko/language/syntax.md", + "sha256": "2df6f67fabcc053b4a75523773e6b30a3b7d62e14a6f270b0bd3ed485595b43c" + }, + { + "path": "site/ko/language/themes-and-icons.md", + "sha256": "fb1eade6dd1b446bdcfa9ccfacbec2d6c702288ae254de939b79938536efb34a" + }, + { + "path": "site/ko/reference/diagnostics-and-limits.md", + "sha256": "3e9163f520458530736fd966757856e34a6ea5030c52d36839a913578d5a2bb4" + }, + { + "path": "site/ko/reference/versioning-and-safety.md", + "sha256": "c228e76cdabfb07d816ffcc1576a5f3467f4deec3b809de7269d329a0f0b12be" + }, + { + "path": "site/language/edges-and-layout.md", + "sha256": "aed8e44169d201ff06dd1e02d93436122bd3aefea167c6b68ce6e7139b06923b" + }, + { + "path": "site/language/formatting.md", + "sha256": "67bc69d97950cdc2863bde05b7c62c5b71f9bf3173fac5afff0d27b66de0a1a8" + }, + { + "path": "site/language/nodes-and-groups.md", + "sha256": "be3819622ac9c561ac4a5bb947c7025607ec2d5609a4e62a9e9d35805d3d416f" + }, + { + "path": "site/language/syntax.md", + "sha256": "f7d67c31b9d50e6d78f1fc30efbd129bbc4f64c887b8a8560b1e15aca30af5ce" + }, + { + "path": "site/language/themes-and-icons.md", + "sha256": "e82a930f3cb06ed9aa1f95fa160b5f6f8a51fca86ac2e52a1e53b75d2a0e2ff5" + }, + { + "path": "site/reference/diagnostics-and-limits.md", + "sha256": "dbb1b05d6f4f51c10cddd646ad659e980621e314623403f6817b8a6ab62283b3" + }, + { + "path": "site/reference/versioning-and-safety.md", + "sha256": "96bd742eda96f9239200b1d94552b1d4aaa88b84d8cc4690b274adcca45d3206" + }, + { + "path": "site/zh/examples/index.md", + "sha256": "de0575c5ffe6d1f525023f4eea20293fd9e6332fdfeb8973ace1673b23d6a535" + }, + { + "path": "site/zh/guide/coding-agents.md", + "sha256": "da296f81e02d4ea29dffa4646df375e260d22a650367ec96c095fe90f1cb4fa5" + }, + { + "path": "site/zh/guide/getting-started.md", + "sha256": "4303edc7deb5fa61d783330d2bfafdcf4fb2a76a5cf51e7da469de2cb8170c6f" + }, + { + "path": "site/zh/guide/playground.md", + "sha256": "961a408323fb2c0d1434d5b2c5ffa74ed639c187bbb746f031fa6be86ad4d167" + }, + { + "path": "site/zh/guide/provider-icons.md", + "sha256": "56764fc99f06127f30f6dfa07319614bb48f8763b029571f94fe7614647aa7c6" + }, + { + "path": "site/zh/guide/what-is-stack.md", + "sha256": "d616fb3b5b2324c9892a3f593f0e3b2f92d0fb338300ba2ebf3488022aa9634b" + }, + { + "path": "site/zh/index.md", + "sha256": "432a5667dd51c297e2a415f3fca9438d8cfd7ed4b02d8946fc863548363f228d" + }, + { + "path": "site/zh/language/edges-and-layout.md", + "sha256": "310eed43178e98b6fb663cb02f96234a3729e0e2597cf2098b5c3f97261db8ed" + }, + { + "path": "site/zh/language/formatting.md", + "sha256": "1f782a7b5fb6101ca240c1e756006d456cc079616362dc4bb3f2e5256a879f73" + }, + { + "path": "site/zh/language/nodes-and-groups.md", + "sha256": "48a1a9186b2f817be780a01015b6bcae0e3f0b47675546dc36d4c172b40bc3b9" + }, + { + "path": "site/zh/language/syntax.md", + "sha256": "ebb113a0782bfcb3f650b216510b93bdbbd2aa90f774315071ffdb35d58d6360" + }, + { + "path": "site/zh/language/themes-and-icons.md", + "sha256": "6d7cf0be5651274e72a511665e216ac9c08b4deeffc002415e3b6eb839011273" + }, + { + "path": "site/zh/reference/diagnostics-and-limits.md", + "sha256": "445293b2efba5a7b11a935fcc732e76119a624acac4bf32ebc19834c3d9c354f" + }, + { + "path": "site/zh/reference/versioning-and-safety.md", + "sha256": "74c0dac1f836e1ab94ab380b4877a75e4ced827c604904bea3f8b906e9a68d4d" + }, + { + "path": "site/guide/agent-workflow.md", + "sha256": "66fe4c3c97afad3a740d9ab824c5aae3f43783bfa251fe0347666b38bc3afc9b" + }, + { + "path": "site/ja/guide/agent-workflow.md", + "sha256": "66fe4c3c97afad3a740d9ab824c5aae3f43783bfa251fe0347666b38bc3afc9b" + }, + { + "path": "site/zh/guide/agent-workflow.md", + "sha256": "66fe4c3c97afad3a740d9ab824c5aae3f43783bfa251fe0347666b38bc3afc9b" + }, + { + "path": "site/ko/guide/agent-workflow.md", + "sha256": "66fe4c3c97afad3a740d9ab824c5aae3f43783bfa251fe0347666b38bc3afc9b" } ] } diff --git a/generated/site/examples/index.md b/generated/site/examples/index.md new file mode 100644 index 0000000..e0dd853 --- /dev/null +++ b/generated/site/examples/index.md @@ -0,0 +1,7 @@ +# Example gallery + +Start with a small diagram, then move through groups, layout constraints, provider icons, and production-like systems. Every thumbnail below is generated from the canonical source pinned to the public Stack specification. + +Provider examples keep artwork caller-owned: install the listed icon packs when you want branded icons. Without a pack, the same source remains valid and renders with Stack's deterministic missing-icon fallback. + + diff --git a/generated/site/guide/agent-workflow.md b/generated/site/guide/agent-workflow.md new file mode 100644 index 0000000..666fd28 --- /dev/null +++ b/generated/site/guide/agent-workflow.md @@ -0,0 +1,42 @@ + + +# Stack diagrams + +Deliver editable `.stack` source and, when rendering is available, an SVG. Preserve the requested architecture and existing unrelated content. Stack describes architecture; it does not provision resources or execute application code. + +## Start with the available tools + +Run `stack --version` and `stack help` before selecting commands. Use the installed binary's help, not unreleased repository instructions. The published CLI 0.4.0 supports `check`, `fmt`, and `render`; it does not support their `--json` flags. A newer version may support additional options: verify them using `stack help `. + +If the CLI is missing, consult the [installation guide](https://stack-diagram.com/docs/guide/getting-started.md) and [release distribution contract](https://github.com/stack-sh/cli/blob/v0.4.0/docs/distribution.md). Install only when the user's authorization allows it. Otherwise provide source with an explicit validation gap; do not report it as checked. No remote source upload is required. + +## Read only the relevant reference + +Start with [syntax](https://stack-diagram.com/docs/language/syntax.md), [nodes and groups](https://stack-diagram.com/docs/language/nodes-and-groups.md), and [edges and layout](https://stack-diagram.com/docs/language/edges-and-layout.md) when the grammar is unfamiliar. Find complete examples in the [gallery](https://stack-diagram.com/docs/examples/index.md). The [documentation index](https://stack-diagram.com/docs/llms.txt) links the remaining references. If the client cannot fetch one resource, try its Markdown page or report the missing information rather than inventing syntax. + +Non-obvious constraints: + +- One `stack 1.0` declaration and one named `diagram`; node/group IDs are globally unique. +- Declare edges at diagram scope. Endpoints are node IDs, not labels or groups. +- Model technologies using labels and `detail`; choose semantic `kind` values from the reference. Do not invent properties such as coordinates, colors, or ports. +- Prefer automatic layout or `direction` initially. `order` controls relative cross-axis ordering, not execution sequence; add `rank` or `order` only when the user needs that constraint. References must be direct children of that layout scope. +- Do not guess vendor icon IDs. Consult [provider icons](https://stack-diagram.com/docs/guide/provider-icons.md), query `stack icons list`, and verify the required pack is installed. Import downloads and terms acceptance need appropriate user authorization. If no pack is available, use the semantic kind fallback and explain that branded artwork is absent. + +## Generate, validate, and render + +For a new diagram, start with the smallest complete source that preserves the requested components and relationships. For an edit, inspect the existing source first and retain unrelated nodes, edges, labels, and comments. + +Using the user's actual filenames: + +```sh +stack check architecture.stack +stack fmt architecture.stack +stack check architecture.stack +stack render architecture.stack -o architecture.svg +``` + +`fmt` changes the source in place; avoid unrelated formatting when it would obscure a narrowly requested edit. Rendering to a file may replace it, so honor existing artifact ownership. + +Read both the exit status and diagnostics. An exit code of zero can still carry warnings. Fix unknown references or invalid syntax from the diagnostic ranges; never remove requested architecture merely to make validation pass. Investigate layout warnings without treating an optional visual hint as a required semantic relationship. Missing-icon warnings mean the image rendered with a fallback, not that provider artwork was found. Bound repeated repair attempts and report a remaining blocker rather than silently weakening the task. + +After rendering, inspect the SVG visually when a suitable viewer is available. Compiler success does not prove readable layout. Confirm the requested nodes, boundaries, relationships, and labels remain present. Report the source/SVG paths, CLI version, validation result, and any unresolved warnings or unverified visual behavior. diff --git a/generated/site/guide/coding-agents.md b/generated/site/guide/coding-agents.md new file mode 100644 index 0000000..81c9e03 --- /dev/null +++ b/generated/site/guide/coding-agents.md @@ -0,0 +1,27 @@ +# Coding agents + +Use Stack with a coding agent to keep architecture diagrams as reviewable source. The agent can read the language reference and run the CLI locally; a remote MCP server is not required. + +## Install the skill + +Install only the diagram skill with `npx skills add stack-sh/cli`. This installs into the current project; add `-g` only when you want a user-wide installation. Review the downloaded instructions before use. This installs instructions, not the Stack CLI. For a reproducible installation, clone the repository, check out a reviewed commit, then run `npx skills add /absolute/path/to/cli --skill stack-diagrams`. The installer does not accept a raw commit SHA as a remote branch. + +[SKILL.md](https://github.com/stack-sh/cli/blob/main/skills/stack-diagrams/SKILL.md) + +## Without installation + +Copy this instruction into your agent and add the architecture requirements. The same prompt works without a skill-aware client, provided it can read HTTPS pages and execute local commands. + +```text +Use Stack to create or edit the architecture described below. Read https://stack-diagram.com/docs/guide/agent-workflow.md and follow its local validation and safety workflow. Read the relevant language reference and examples as needed. Deliver editable .stack source and report verification results. Architecture requirements: +``` + +The full [agent workflow](./agent-workflow) is generated from the same source as the CLI skill. The canonical agent instructions are in English; copy them or let your agent read the Markdown URL above. + +## Reference and updates + +- [Examples](../examples/index) +- [Syntax](../language/syntax) +- [Diagnostics](../reference/diagnostics-and-limits) +- [Provider icons](./provider-icons) +- [Markdown index](https://stack-diagram.com/docs/llms.txt) diff --git a/generated/site/guide/getting-started.md b/generated/site/guide/getting-started.md new file mode 100644 index 0000000..ac81f4b --- /dev/null +++ b/generated/site/guide/getting-started.md @@ -0,0 +1,86 @@ +# Getting started + +The fastest way to use Stack is the browser [Playground](https://stack-diagram.com/). It runs the formatter, validator, layout engine, and SVG renderer locally in WebAssembly; you do not need to install a command or send source to a rendering API. + +## Install the native CLI + +For terminal workflows and local automation, install the owner-maintained Homebrew formula with `brew install stack-sh/tap/stack`. It uses the canonical Stack CLI 0.4.0 release archive and supports Apple Silicon macOS plus glibc-based Linux on arm64 and x86_64 when the host meets Homebrew's current tier-1 requirements. Homebrew owns upgrades through `brew upgrade stack-sh/tap/stack`; uninstalling the formula leaves your Stack configuration and icon store in place. See the [CLI distribution contract](https://github.com/stack-sh/cli/blob/main/docs/distribution.md#homebrew-installation) for the exact platform matrix, direct-install alternative, and recovery policy. + +## Write your first document + +Replace the editor content with this example: + +```stack +stack 1.0 + +diagram "Checkout" { + theme default + + node shopper "Shopper" { + kind actor + } + + group application "Application" { + node web "Web app" { + kind client + detail "React" + } + + node api "Checkout API" { + kind service + detail "Rust" + } + + layout { + direction right + order [web, api] + } + } + + node orders "Orders" { + kind database + detail "PostgreSQL" + } + + edge shopper -> web "HTTPS" { + kind request + } + + edge web -> api "JSON" { + kind request + } + + edge api -> orders "SQL" { + kind data + } + + layout { + direction right + order [shopper, application, orders] + } +} +``` + +## Render and inspect + +Select **Run** or press Command/Ctrl + Enter. The preview shows a standalone SVG. Select the preview to inspect it at a larger size, then use **Download SVG** when you want the file. + +The source has four parts: + +1. `stack 1.0` declares the language version. +2. `diagram` provides one title and contains the architecture. +3. `node` and `group` declare components and boundaries. +4. `edge` records relationships, while `layout` supplies constrained placement intent. + +## Check and format + +Use **Check** to run the complete validation and layout pipeline without replacing the SVG. Use **Format** to rewrite syntactically valid source into the canonical two-space form while preserving line comments and meaning. + +If Stack finds a problem, the diagnostic shows its severity, stable code, location, source frame, expected values, and corrective help when available. Selecting a diagnostic focuses its source range. + +## Choose what to learn next + +- Read [Document and syntax](../language/syntax) for lexical rules and the complete grammar. +- Read [Nodes and groups](../language/nodes-and-groups) to model components and boundaries. +- Read [Edges and layout](../language/edges-and-layout) for relationships and placement intent. +- Read [Themes and icons](../language/themes-and-icons) before selecting a visual system or explicit icon. diff --git a/generated/site/guide/playground.md b/generated/site/guide/playground.md new file mode 100644 index 0000000..0f83962 --- /dev/null +++ b/generated/site/guide/playground.md @@ -0,0 +1,42 @@ +# Using the Playground + +The Playground is the public browser consumer at [stack-diagram.com](https://stack-diagram.com/). The editor remains a native text input while a shared TextMate grammar supplies syntax color. Validation, formatting, layout, and SVG always come from the published Stack WebAssembly engine. + +## Actions + +| Action | Result | +| ---------------- | ------------------------------------------------------------------------------------------------ | +| **Format** | Canonicalizes syntactically valid source and preserves comments. Semantic errors remain visible. | +| **Check** | Runs compiler, theme, icon, layout, and routing checks without creating a new SVG. | +| **Run** | Runs the full pipeline and updates the SVG when no error prevents rendering. | +| **Download SVG** | Saves the current standalone SVG. | + +Command/Ctrl + Enter runs the document. Source changes clear stale diagnostics so old ranges are not presented as current results. + +## Reading diagnostics + +An error result can include: + +```text +error[STK2002] at 4:22 +4 | layout { direction hoo } + | ^^^ unexpected layout direction 'hoo' + = expected: right, down + = help: use 'right' for horizontal flow or 'down' for vertical flow +``` + +Select a diagnostic or its related information to focus the corresponding source. Errors prevent a successful render. Warnings describe a fallback or readability concern and can accompany an SVG. + +## Two independent color choices + +The header color-mode control changes the Playground and editor presentation. A source statement such as `theme dark` changes the generated diagram. The two settings are intentionally independent: switching the site to dark mode must not rewrite or reinterpret the diagram theme. + +## Browser behavior and data + +The Playground loads a published WebAssembly module, then runs synchronous `format`, `check`, and `render` operations in the browser. The engine itself does not read files, contact a network service, inspect the DOM, observe a clock, or measure host fonts. + +The current Playground does not provide accounts, cloud persistence, collaboration, or paid themes. Download source or SVG that you need to keep. + +## Accessibility + +The editor retains native caret, selection, clipboard, undo, keyboard, and IME behavior. Diagnostics can navigate to source ranges. The preview has text alternatives and opens in a keyboard-accessible dialog. The interface supports 320-pixel layouts, light and dark contrast, visible focus, and reduced-motion preferences. diff --git a/generated/site/guide/provider-icons.md b/generated/site/guide/provider-icons.md new file mode 100644 index 0000000..272c3b6 --- /dev/null +++ b/generated/site/guide/provider-icons.md @@ -0,0 +1,118 @@ +# Provider icons + +Stack includes a provider-neutral core icon catalog. AWS, Google Cloud, Azure, and common developer and collaboration artwork are available through provider packs stored in your user-managed icon store. + +## Available provider catalog + +The audited catalog contains 1,051 IDs: 305 AWS Architecture Icons, 45 Google Cloud product and category icons, 639 Azure service icons, and 62 curated tool icons. The tool catalog includes GitHub, GitHub Actions, Notion, Linear, Atlassian, Jira, Confluence, Docker, Kubernetes, Terraform, Datadog, Grafana, Sentry, and more. + +Select a provider card to see its import command, then search or filter the complete catalog. Results are shown 100 at a time for comfortable use on smaller devices. + + + +A provider pack supplies artwork. The node `kind` in Stack source continues to control semantic styling and layout. + +## Quick start + +Import each provider used by a diagram once. `--accept-terms` records your confirmation that you reviewed the linked provider and brand terms. + +```sh +$ stack icons import gcp --accept-terms +$ stack icons import simple-icons --accept-terms +$ stack render architecture.stack -o architecture.svg +``` + +The CLI downloads the audited official archives, verifies their complete SHA-256 hashes, sanitizes the selected SVGs, and writes each processed provider pack to the shared icon store. Google Cloud product and category artwork is imported together by the single `gcp` command. + +## Use provider icons in CLI + +A Stack file can use multiple providers. This example combines Cloud Run from Google Cloud with GitHub from Simple Icons: + +```stack +stack 1.0 + +diagram "Deploy from GitHub to Cloud Run" { + node repository "GitHub" { + kind external + icon "simple-icons:github" + } + + node service "Cloud Run" { + kind service + icon "gcp:cloud-run" + } + + edge repository -> service "Deploy" { + kind dependency + } +} +``` + +After both imports, the standard render command discovers both packs: + +```sh +$ stack render architecture.stack -o architecture.svg --notice architecture.NOTICE.md +``` + +## Shared icon store + +The default icon store is `$XDG_CONFIG_HOME/stack/icons`. When `XDG_CONFIG_HOME` is unset, Stack uses `$HOME/.config/stack/icons`. + +```text +icons/ + aws/ + gcp/ + azure/ + simple-icons/ +``` + +Set a different shared location in `$XDG_CONFIG_HOME/stack/config.yaml` with an absolute path: + +```yaml +default_icons_path: /absolute/path/to/stack-icons +``` + +The configured location is used by both `stack icons import` and `stack render`. + +## Use provider icons in Playground + +Open **Icons**, choose the `stack/icons` folder, and the Playground loads every recognized provider directory in that store. Search the loaded artwork and select an item to copy its ID into Stack source. + +The selected packs are processed in the current browser tab. When a rendered diagram contains provider artwork, **Notice** beside the SVG download provides the source, terms, and used-icon record. + +## Keep icons with a project + +Use `-o` to place imported packs in a project directory that can be committed with the repository: + +```sh +$ stack icons import gcp --accept-terms -o .stack-icons +$ stack icons import simple-icons --accept-terms -o .stack-icons +``` + +Pass that icon-store root with `--provider-pack` when rendering: + +```sh +$ stack render architecture.stack \ + --provider-pack .stack-icons \ + -o architecture.svg \ + --notice architecture.NOTICE.md +``` + +## Find icon IDs + +Search the catalog from the CLI or on this page: + +```sh +$ stack icons list +$ stack icons list aws s3 +$ stack icons list azure database +$ stack icons list simple-icons github +``` + +The CLI output contains `ID`, `PRODUCT`, `CATEGORY`, and recommended `KIND` columns. Namespaced IDs such as `gcp:cloud-run` and `simple-icons:github` select artwork from the corresponding pack. + +## Verification, terms, and notices + +The CLI catalog pins each official HTTPS archive URL, release, complete archive SHA-256, allowlisted entry path, terms URL, and review date. Import applies bounded archive and SVG sizes, sanitizes active and external SVG content, and writes each pack atomically. + +Each pack includes `NOTICE.md`. `stack render --notice ` writes the exact pack revisions, source releases, terms URLs, attribution, non-endorsement text, and used icon IDs for a rendered artifact. The catalog links each provider's official source and terms, plus brand sources and guidelines for curated Simple Icons marks. diff --git a/generated/site/guide/what-is-stack.md b/generated/site/guide/what-is-stack.md new file mode 100644 index 0000000..bf3ea0a --- /dev/null +++ b/generated/site/guide/what-is-stack.md @@ -0,0 +1,51 @@ +# What is Stack? + +Stack is a small declarative language for static software architecture and technology-stack diagrams. You describe components, boundaries, and relationships in a UTF-8 `.stack` file. A renderer decides coordinates, spacing, routes, typography, and visual treatment. + +This split keeps the source concise, reviewable, and useful in version control. It also lets the same document be formatted, checked, and rendered by conforming tools without turning the file into drawing instructions. + +## The basic model + +Every document contains a language version and exactly one diagram. A diagram contains nodes, optional groups, edges, an optional theme, and optional layout intent. + +```stack +stack 1.0 + +diagram "Service architecture" { + node client "Web app" { + kind client + } + + node api "API" { + kind service + detail "Order orchestration" + } + + edge client -> api "HTTPS" { + kind request + } +} +``` + +The document says that a client calls a service. It does not say where either box sits or how an arrow bends. + +## What Stack optimizes for + +- **Concise authoring:** useful diagrams need little more than named nodes and edges. +- **Predictable generation:** each concept has one constrained representation that people and language models can produce reliably. +- **Semantic source:** a document records topology and intent, not pixels. +- **Polished output:** the renderer owns a coherent visual system. +- **Actionable errors:** diagnostics point to source ranges and can include expected values, corrective help, and related declarations. +- **Safe embedding:** source cannot execute code, fetch arbitrary assets, or inject HTML or SVG. + +## What Stack is not + +Stack 1.0 is not a general graph language, pixel-perfect canvas, infrastructure definition, or executable programming language. It has no variables, imports, macros, conditionals, CSS, coordinates, arbitrary URLs, or embedded HTML. It is not a sequence, state-machine, class, ER, or complete UML notation. + +Use several focused diagrams for a large system. A single Stack document deliberately has readability limits rather than unlimited elements. + +## Processing model + +A tool decodes and parses the document, resolves identifiers and defaults, validates semantics, resolves the theme and icons, solves layout, and finally renders. Source errors stop rendering. Missing optional theme or icon resources and unsatisfied layout hints are warnings, so the engine can still return a fallback diagram. + +The [language pages](../language/syntax) explain every author-facing construct. The [versioning and safety reference](../reference/versioning-and-safety) explains compatibility and trust boundaries. diff --git a/generated/site/index.md b/generated/site/index.md new file mode 100644 index 0000000..3bdf0f3 --- /dev/null +++ b/generated/site/index.md @@ -0,0 +1,27 @@ +--- +layout: home + +hero: + name: Stack + text: Architecture, as source. + tagline: Write a small, semantic document. Get a consistent, accessible architecture diagram without drawing coordinates or styling every box. + image: + light: /favicon.svg + dark: /favicon.svg + alt: Stack logo + actions: + - theme: brand + text: Get started + link: /guide/getting-started + - theme: alt + text: Open Playground + link: https://stack-diagram.com/ + +features: + - title: Describe the system + details: Nodes, groups, relationships, and layout intent stay readable in a compact .stack file. + - title: Keep meaning portable + details: A versioned language and structured diagnostics separate architecture meaning from renderer choices. + - title: Render safely + details: The engine produces standalone SVG without scripts, arbitrary HTML, or network-loaded assets. +--- diff --git a/generated/site/ja/examples/index.md b/generated/site/ja/examples/index.md new file mode 100644 index 0000000..690ea1d --- /dev/null +++ b/generated/site/ja/examples/index.md @@ -0,0 +1,7 @@ +# Example gallery + +小さなdiagramから始め、group、layout constraint、provider icon、production-likeなsystemへ段階的に進めます。下のthumbnailはすべて、公開Stack specificationへpinしたcanonical sourceから生成しています。 + +Provider exampleのartworkはcaller-ownedです。Brand iconを使う場合は表示されたicon packを導入してください。Packがなくても同じsourceはvalidで、Stackのdeterministicなmissing-icon fallbackを使ってrenderされます。 + + diff --git a/generated/site/ja/guide/agent-workflow.md b/generated/site/ja/guide/agent-workflow.md new file mode 100644 index 0000000..666fd28 --- /dev/null +++ b/generated/site/ja/guide/agent-workflow.md @@ -0,0 +1,42 @@ + + +# Stack diagrams + +Deliver editable `.stack` source and, when rendering is available, an SVG. Preserve the requested architecture and existing unrelated content. Stack describes architecture; it does not provision resources or execute application code. + +## Start with the available tools + +Run `stack --version` and `stack help` before selecting commands. Use the installed binary's help, not unreleased repository instructions. The published CLI 0.4.0 supports `check`, `fmt`, and `render`; it does not support their `--json` flags. A newer version may support additional options: verify them using `stack help `. + +If the CLI is missing, consult the [installation guide](https://stack-diagram.com/docs/guide/getting-started.md) and [release distribution contract](https://github.com/stack-sh/cli/blob/v0.4.0/docs/distribution.md). Install only when the user's authorization allows it. Otherwise provide source with an explicit validation gap; do not report it as checked. No remote source upload is required. + +## Read only the relevant reference + +Start with [syntax](https://stack-diagram.com/docs/language/syntax.md), [nodes and groups](https://stack-diagram.com/docs/language/nodes-and-groups.md), and [edges and layout](https://stack-diagram.com/docs/language/edges-and-layout.md) when the grammar is unfamiliar. Find complete examples in the [gallery](https://stack-diagram.com/docs/examples/index.md). The [documentation index](https://stack-diagram.com/docs/llms.txt) links the remaining references. If the client cannot fetch one resource, try its Markdown page or report the missing information rather than inventing syntax. + +Non-obvious constraints: + +- One `stack 1.0` declaration and one named `diagram`; node/group IDs are globally unique. +- Declare edges at diagram scope. Endpoints are node IDs, not labels or groups. +- Model technologies using labels and `detail`; choose semantic `kind` values from the reference. Do not invent properties such as coordinates, colors, or ports. +- Prefer automatic layout or `direction` initially. `order` controls relative cross-axis ordering, not execution sequence; add `rank` or `order` only when the user needs that constraint. References must be direct children of that layout scope. +- Do not guess vendor icon IDs. Consult [provider icons](https://stack-diagram.com/docs/guide/provider-icons.md), query `stack icons list`, and verify the required pack is installed. Import downloads and terms acceptance need appropriate user authorization. If no pack is available, use the semantic kind fallback and explain that branded artwork is absent. + +## Generate, validate, and render + +For a new diagram, start with the smallest complete source that preserves the requested components and relationships. For an edit, inspect the existing source first and retain unrelated nodes, edges, labels, and comments. + +Using the user's actual filenames: + +```sh +stack check architecture.stack +stack fmt architecture.stack +stack check architecture.stack +stack render architecture.stack -o architecture.svg +``` + +`fmt` changes the source in place; avoid unrelated formatting when it would obscure a narrowly requested edit. Rendering to a file may replace it, so honor existing artifact ownership. + +Read both the exit status and diagnostics. An exit code of zero can still carry warnings. Fix unknown references or invalid syntax from the diagnostic ranges; never remove requested architecture merely to make validation pass. Investigate layout warnings without treating an optional visual hint as a required semantic relationship. Missing-icon warnings mean the image rendered with a fallback, not that provider artwork was found. Bound repeated repair attempts and report a remaining blocker rather than silently weakening the task. + +After rendering, inspect the SVG visually when a suitable viewer is available. Compiler success does not prove readable layout. Confirm the requested nodes, boundaries, relationships, and labels remain present. Report the source/SVG paths, CLI version, validation result, and any unresolved warnings or unverified visual behavior. diff --git a/generated/site/ja/guide/coding-agents.md b/generated/site/ja/guide/coding-agents.md new file mode 100644 index 0000000..a5c6b13 --- /dev/null +++ b/generated/site/ja/guide/coding-agents.md @@ -0,0 +1,27 @@ +# Coding agentで使う + +Coding agentでStackを読み書きすると、構成図をレビュー可能なsourceとして管理できます。言語referenceを読み、CLIをlocal実行するため、remote MCP serverは不要です。 + +## Skillの導入 + +`npx skills add stack-sh/cli`で図作成skillだけをcurrent projectへ導入します。User全体へ導入したい場合だけ`-g`を付け、取得したinstructionを確認してください。CLI本体は別途必要です。再現可能な導入にはrepositoryをcloneして確認済みcommitをcheckoutし、`npx skills add /absolute/path/to/cli --skill stack-diagrams`で導入します。Installerはcommit SHAをremote branchとして直接指定する方法には対応していません。 + +[SKILL.md](https://github.com/stack-sh/cli/blob/main/skills/stack-diagrams/SKILL.md) + +## 導入せずに使う + +次のinstructionをagentへ渡し、作りたい構成を追記してください。HTTPSの参照とlocal command実行ができれば、skillに未対応のclientでも使えます。 + +```text +Use Stack to create or edit the architecture described below. Read https://stack-diagram.com/docs/guide/agent-workflow.md and follow its local validation and safety workflow. Read the relevant language reference and examples as needed. Deliver editable .stack source and report verification results. Architecture requirements: +``` + +詳しい[agent workflow](./agent-workflow)はCLIスキルと同じ原稿から生成します。正本のagent向け指示は英語です。上のMarkdown URLをagentに読ませるか、指示をコピーしてください。 + +## 参照と更新 + +- [Examples](../examples/index) +- [Syntax](../language/syntax) +- [Diagnostics](../reference/diagnostics-and-limits) +- [Provider icons](./provider-icons) +- [Markdown index](https://stack-diagram.com/docs/llms.txt) diff --git a/generated/site/ja/guide/getting-started.md b/generated/site/ja/guide/getting-started.md new file mode 100644 index 0000000..9a8d5dd --- /dev/null +++ b/generated/site/ja/guide/getting-started.md @@ -0,0 +1,86 @@ +# はじめる + +最短の利用方法はbrowser [Playground](https://stack-diagram.com/)です。Formatter、validator、layout engine、SVG rendererがWebAssemblyとしてlocalで動作するため、commandのinstallやrendering APIへのsource送信は不要です。 + +## Native CLIをinstallする + +Terminal workflowとlocal automationでは、owner管理のHomebrew formulaを`brew install stack-sh/tap/stack`でinstallします。CanonicalなStack CLI 0.4.0 release archiveを使用し、Homebrewの現行Tier 1要件を満たすApple Silicon macOSと、arm64 / x86_64のglibc Linuxをsupportします。UpgradeはHomebrewが`brew upgrade stack-sh/tap/stack`で管理し、formulaをuninstallしてもStackのconfigとicon storeは保持されます。正確なplatform matrix、direct install、recovery policyは[CLI distribution contract](https://github.com/stack-sh/cli/blob/main/docs/distribution.md#homebrew-installation)を参照してください。 + +## 最初のdocumentを書く + +Editorを次のexampleへ置き換えます。 + +```stack +stack 1.0 + +diagram "Checkout" { + theme default + + node shopper "Shopper" { + kind actor + } + + group application "Application" { + node web "Web app" { + kind client + detail "React" + } + + node api "Checkout API" { + kind service + detail "Rust" + } + + layout { + direction right + order [web, api] + } + } + + node orders "Orders" { + kind database + detail "PostgreSQL" + } + + edge shopper -> web "HTTPS" { + kind request + } + + edge web -> api "JSON" { + kind request + } + + edge api -> orders "SQL" { + kind data + } + + layout { + direction right + order [shopper, application, orders] + } +} +``` + +## Renderして確認する + +**Run**を選ぶか、Command/Ctrl + Enterを押します。Previewにstandalone SVGが表示されます。Previewを選ぶと拡大でき、必要なら**Download SVG**で保存できます。 + +Sourceは4つの要素で構成されています。 + +1. `stack 1.0`がlanguage versionを宣言します。 +2. `diagram`が1つのtitleとarchitecture全体を持ちます。 +3. `node`と`group`がcomponentとboundaryを宣言します。 +4. `edge`がrelationshipを、`layout`が制約された配置intentを記録します。 + +## CheckとFormat + +**Check**はSVGを置き換えず、validationとlayout pipeline全体を実行します。**Format**はline commentと意味を保持しながら、syntaxがvalidなsourceをcanonicalな2-space形式へ書き換えます。 + +問題があると、severity、stable code、location、source frame、expected value、利用可能なcorrective helpが表示されます。Diagnosticを選ぶと該当source rangeへfocusします。 + +## 次に読むもの + +- Lexical ruleと完全なgrammarは[Documentとsyntax](../language/syntax)を参照します。 +- Componentとboundaryは[Nodeとgroup](../language/nodes-and-groups)を参照します。 +- Relationshipと配置intentは[Edgeとlayout](../language/edges-and-layout)を参照します。 +- Visual systemや明示iconを選ぶ前に[Themeとicon](../language/themes-and-icons)を参照します。 diff --git a/generated/site/ja/guide/playground.md b/generated/site/ja/guide/playground.md new file mode 100644 index 0000000..b3b2a6b --- /dev/null +++ b/generated/site/ja/guide/playground.md @@ -0,0 +1,42 @@ +# Playgroundの使い方 + +Playgroundは[stack-diagram.com](https://stack-diagram.com/)で公開しているbrowser consumerです。Editorはnative text inputを維持し、shared TextMate grammarがsyntax colorを提供します。Validation、format、layout、SVGは常に公開Stack WebAssembly engineから生成されます。 + +## Action + +| Action | Result | +| ---------------- | -------------------------------------------------------------------------------------------- | +| **Format** | Syntaxがvalidなsourceをcanonicalizeし、commentを保持します。Semantic errorは表示に残ります。 | +| **Check** | 新しいSVGを作らず、compiler、theme、icon、layout、routingを確認します。 | +| **Run** | Pipeline全体を実行し、renderを妨げるerrorがなければSVGを更新します。 | +| **Download SVG** | 現在のstandalone SVGを保存します。 | + +Command/Ctrl + Enterでも実行できます。Source変更時には古いrangeを現在の結果として見せないよう、stale diagnosticを消去します。 + +## Diagnosticの読み方 + +Error resultには次の情報が含まれます。 + +```text +error[STK2002] at 4:22 +4 | layout { direction hoo } + | ^^^ unexpected layout direction 'hoo' + = expected: right, down + = help: use 'right' for horizontal flow or 'down' for vertical flow +``` + +Diagnosticやrelated informationを選ぶと対応sourceへfocusします。Errorはsuccessful renderを止めます。Warningはfallbackや可読性の懸念を表し、SVGと同時に返ることがあります。 + +## 独立した2つのcolor設定 + +Headerのcolor modeはPlaygroundとeditorの表示を変えます。`theme dark`のようなsource statementは生成diagramを変えます。Siteをdark modeへ切り替えてもdiagram themeを変更・解釈し直さないよう、両者は独立しています。 + +## Browser behaviorとdata + +Playgroundは公開WebAssembly moduleをloadし、browser内で同期的な`format`、`check`、`render`を実行します。Engine自体はfile読込、network接続、DOM参照、clock観測、host font計測をしません。 + +現在はaccount、cloud persistence、collaboration、paid themeを提供していません。保持したいsourceやSVGはdownloadしてください。 + +## Accessibility + +Editorはnativeのcaret、selection、clipboard、undo、keyboard、IME behaviorを保持します。Diagnosticからsource rangeへ移動でき、previewはtext alternativeを持つkeyboard-accessibleなdialogで開きます。320px layout、light/dark contrast、visible focus、reduced motionに対応します。 diff --git a/generated/site/ja/guide/provider-icons.md b/generated/site/ja/guide/provider-icons.md new file mode 100644 index 0000000..5659717 --- /dev/null +++ b/generated/site/ja/guide/provider-icons.md @@ -0,0 +1,118 @@ +# Provider icon + +Stackにはprovider-neutralなcore icon catalogが含まれます。AWS、Google Cloud、Azure、主要な開発・collaboration toolのartworkは、user-managed icon storeに保存するprovider packとして利用できます。 + +## 利用可能なprovider catalog + +監査済みcatalogには合計1,051 IDがあります。AWS Architecture Icons 305件、Google Cloudのproduct・category icon 45件、Azure service icon 639件、主要tool icon 62件です。Tool catalogにはGitHub、GitHub Actions、Notion、Linear、Atlassian、Jira、Confluence、Docker、Kubernetes、Terraform、Datadog、Grafana、Sentryなどが含まれます。 + +Provider cardを選ぶとimport commandを確認できます。全catalogを検索・filterでき、小さいdeviceでも見やすいよう100件ずつ表示します。 + + + +Provider packが追加するのはartworkです。Semantic stylingとlayoutはStack sourceに書いたnode `kind`が引き続き決めます。 + +## Quick start + +Diagramで使うproviderを一度ずつimportします。`--accept-terms`は、link先のprovider・brand termsを確認して同意したことを記録します。 + +```sh +$ stack icons import gcp --accept-terms +$ stack icons import simple-icons --accept-terms +$ stack render architecture.stack -o architecture.svg +``` + +CLIは監査済みの公式archiveをdownloadし、archive全体のSHA-256を検証し、選択したSVGをsanitizeして、処理済みprovider packをshared icon storeへ保存します。Google Cloudのproduct・category artworkは1つの`gcp` commandで一緒にimportされます。 + +## CLIでprovider iconを使う + +1つのStack fileで複数providerを利用できます。次の例はGoogle CloudのCloud RunとSimple IconsのGitHubを組み合わせます。 + +```stack +stack 1.0 + +diagram "Deploy from GitHub to Cloud Run" { + node repository "GitHub" { + kind external + icon "simple-icons:github" + } + + node service "Cloud Run" { + kind service + icon "gcp:cloud-run" + } + + edge repository -> service "Deploy" { + kind dependency + } +} +``` + +2つをimportした後は、通常のrender commandが両方のpackを見つけます。 + +```sh +$ stack render architecture.stack -o architecture.svg --notice architecture.NOTICE.md +``` + +## Shared icon store + +Default icon storeは`$XDG_CONFIG_HOME/stack/icons`です。`XDG_CONFIG_HOME`が未設定の場合は`$HOME/.config/stack/icons`を使います。 + +```text +icons/ + aws/ + gcp/ + azure/ + simple-icons/ +``` + +`$XDG_CONFIG_HOME/stack/config.yaml`にabsolute pathを書くと、shared locationを変更できます。 + +```yaml +default_icons_path: /absolute/path/to/stack-icons +``` + +このlocationは`stack icons import`と`stack render`の両方で使われます。 + +## Playgroundでprovider iconを使う + +**Icons**を開いて`stack/icons` folderを選ぶと、Playgroundがstore内の認識可能なprovider directoryをすべてloadします。Loadしたartworkを検索し、選択するとIDをStack sourceへcopyできます。 + +選択したpackは現在のbrowser tabで処理されます。生成diagramにprovider artworkが含まれる場合は、SVG download横の**Notice**からsource、terms、使用iconの記録を取得できます。 + +## Iconをprojectと一緒に管理する + +Import済みpackをrepositoryへ含める場合は、`-o`でproject directoryを指定します。 + +```sh +$ stack icons import gcp --accept-terms -o .stack-icons +$ stack icons import simple-icons --accept-terms -o .stack-icons +``` + +Render時は`--provider-pack`へ同じicon-store rootを渡します。 + +```sh +$ stack render architecture.stack \ + --provider-pack .stack-icons \ + -o architecture.svg \ + --notice architecture.NOTICE.md +``` + +## Icon IDを探す + +CLIまたはこのpageでcatalogを検索できます。 + +```sh +$ stack icons list +$ stack icons list aws s3 +$ stack icons list azure database +$ stack icons list simple-icons github +``` + +CLI outputには`ID`、`PRODUCT`、`CATEGORY`、推奨`KIND`が含まれます。`gcp:cloud-run`や`simple-icons:github`のようなnamespaced IDが対応するpackのartworkを選択します。 + +## 検証・terms・notice + +CLI catalogは公式HTTPS archive URL、release、archive全体のSHA-256、allowlist済みentry path、terms URL、review dateをpinしています。Importではarchive・SVGのsizeを制限し、active・external SVG contentをsanitizeして、packをatomicに保存します。 + +各packには`NOTICE.md`が含まれます。`stack render --notice `は、実際のpack revision、source release、terms URL、attribution、non-endorsement text、使用icon IDを出力します。Catalogから各providerの公式sourceとterms、Simple Iconsのbrand sourceとguidelineを確認できます。 diff --git a/generated/site/ja/guide/what-is-stack.md b/generated/site/ja/guide/what-is-stack.md new file mode 100644 index 0000000..b6117c2 --- /dev/null +++ b/generated/site/ja/guide/what-is-stack.md @@ -0,0 +1,51 @@ +# Stackとは + +Stackは、software architectureとtechnology stackの静的なdiagramを記述するための小さなdeclarative languageです。UTF-8の`.stack` fileにcomponent、boundary、relationshipを書き、座標、余白、route、typography、visual treatmentはrendererが決めます。 + +この分離により、sourceは簡潔でreviewしやすく、version controlにも適します。同じdocumentを、drawing instructionへ変えずにformat・check・renderできます。 + +## 基本モデル + +各documentにはlanguage versionとちょうど1つのdiagramがあります。Diagramにはnode、任意のgroup・edge・theme・layout intentを記述します。 + +```stack +stack 1.0 + +diagram "Service architecture" { + node client "Web app" { + kind client + } + + node api "API" { + kind service + detail "Order orchestration" + } + + edge client -> api "HTTPS" { + kind request + } +} +``` + +このsourceはclientがserviceを呼ぶことを表します。Boxの位置やarrowの曲がり方は指定しません。 + +## Stackが重視すること + +- **簡潔なauthoring:** 名前付きnodeとedgeだけで有用なdiagramを書けます。 +- **予測可能な生成:** 人とlanguage modelが同じconceptを安定して記述できます。 +- **Semantic source:** Pixelではなくtopologyとintentを記録します。 +- **整ったoutput:** 一貫したvisual systemをrendererが所有します。 +- **修正可能なerror:** Diagnosticはsource range、expected value、help、related declarationを示せます。 +- **安全な埋め込み:** Sourceはcode実行、任意asset取得、HTML/SVG注入ができません。 + +## Stackではないもの + +Stack 1.0はgeneral graph language、pixel-perfect canvas、infrastructure definition、実行可能なprogramming languageではありません。Variable、import、macro、condition、CSS、座標、任意URL、埋め込みHTMLはありません。Sequence、state machine、class、ER、完全なUML notationも対象外です。 + +大規模systemは1枚に詰めず、複数の焦点を絞ったdiagramに分けます。Stackには可読性を守るための上限があります。 + +## Processing model + +Toolはdecode / parse、identifierとdefaultの解決、semantic validation、theme / icon解決、layout、renderの順に処理します。Source errorはrenderを停止します。Optional theme / iconの欠落や満たせないlayout hintはwarningとなり、fallback diagramを返せます。 + +Author向けの全constructは[言語ページ](../language/syntax)、互換性とtrust boundaryは[Versioningと安全性](../reference/versioning-and-safety)で説明します。 diff --git a/generated/site/ja/index.md b/generated/site/ja/index.md new file mode 100644 index 0000000..dafd1ac --- /dev/null +++ b/generated/site/ja/index.md @@ -0,0 +1,27 @@ +--- +layout: home + +hero: + name: Stack + text: Architectureをsourceとして。 + tagline: 小さなsemantic documentを書くだけで、座標やboxごとのstyleを指定せず、一貫したaccessibleなarchitecture diagramを生成できます。 + image: + light: /favicon.svg + dark: /favicon.svg + alt: Stackロゴ + actions: + - theme: brand + text: はじめる + link: /ja/guide/getting-started + - theme: alt + text: Playgroundを開く + link: https://stack-diagram.com/ + +features: + - title: Systemを記述する + details: Node、group、relationship、layout intentを、簡潔な.stack fileとして読みやすく保ちます。 + - title: 意味をportableにする + details: Version付きlanguageとstructured diagnosticが、architectureの意味をrendererの選択から分離します。 + - title: 安全にrenderする + details: Script、任意HTML、network assetを含まないstandalone SVGをengineが生成します。 +--- diff --git a/generated/site/ja/language/edges-and-layout.md b/generated/site/ja/language/edges-and-layout.md new file mode 100644 index 0000000..de233aa --- /dev/null +++ b/generated/site/ja/language/edges-and-layout.md @@ -0,0 +1,78 @@ +# Edgeとlayout + +Edgeはnode間のrelationshipを表します。Layout blockは座標やdrawing primitiveを公開せず、少量の配置intentを表します。 + +## Edge direction + +Edgeは異なる2 nodeを接続します。Forward referenceはvalidですが、self-edgeとgroup endpointはinvalidです。 + +| Operator | Meaning | +| -------- | -------------------------------------------------- | +| `->` | 左nodeから右nodeへのdirected relationship | +| `<->` | 両方向の1つのsymmetric relationship | +| `--` | Directionがない、または意図的に未指定のassociation | + +`<->`は独立してlabel可能な2 edgeの省略形ではありません。 + +## Edge kindとlabel + +任意labelはprotocol、event、command、dataset、purposeを表す1〜40 Unicode scalarです。任意`kind`はlabelとは独立してrelationshipを分類し、defaultは`flow`です。 + +| Kind | Intended meaning | +| ------------ | --------------------------------------------------- | +| `flow` | Generic runtimeまたはconceptual flow | +| `request` | Synchronous requestまたはcall | +| `event` | Asynchronous messageまたはevent delivery | +| `data` | Data movement、replication、read、write | +| `dependency` | Build-time、deployment-time、operational dependency | + +```stack +stack 1.0 + +diagram "Relationships" { + node web "Web app" { + kind client + } + + node api "API" + node queue "Events" { + kind queue + } + + edge web -> api "HTTPS" { + kind request + } + + edge api -> queue "OrderPlaced" { + kind event + } +} +``` + +異なるrelationshipなら同じnode間に複数edgeを置けます。同じendpoint、operator、label、effective kindのexact duplicateはinvalidです。`<->`と`--`のduplicate比較ではendpoint orderを無視します。 + +## Layout scope + +Diagramまたはgroupには1つの`layout` blockを置けます。Group blockはそのdirect childだけ、diagram blockはdiagramのdirect childだけに作用します。`rank`と`order`は同じscopeの異なるdirect childを最低2つ参照します。 + +Layoutではdirect child groupを1 itemとして扱います。Descendant node同士のconnectionは所属するdirect-child item間のconnectionになるため、groupをedge endpointにしなくてもtop-level layoutでgroupを配置できます。 + +## Direction、rank、order + +```stack +layout { + direction right + rank same [web, worker] + order [web, worker, database] +} +``` + +- `direction right`は左から右、`direction down`は上から下のprogressionを優先します。Strong hintであり、全edgeの幾何方向を保証しません。Nested groupへinheritしません。 +- `rank same [a, b]`はlisted direct childを同じlayout rankに置くconstraintです。同じscopeで1 childを2つのsame-rank statementに置けません。 +- `order [a, b]`はrelative-order hintです。Right scopeでは上から下、down scopeでは左から右、automatic layoutではchosen cross-axisに沿います。他childは省略できます。 + +Rendererはcontainment、same-rank constraint、legibility、output boundを守るため`order`から外れることがあります。その場合、diagnostic-capable toolは`STK4001`を出します。 + +## Rendererが所有する判断 + +Stackには座標、dimension、port、path、color、font、line break、z-indexがありません。Rendererはoverlapを防ぎ、containmentとdirectionを保ち、labelを読みやすくし、node interiorを避けてedgeをrouteし、semantic contentをclipせずcanvasを拡張します。 diff --git a/generated/site/ja/language/formatting.md b/generated/site/ja/language/formatting.md new file mode 100644 index 0000000..753d123 --- /dev/null +++ b/generated/site/ja/language/formatting.md @@ -0,0 +1,58 @@ +# Canonical formatting + +Stackはlexically / syntactically validな各documentに、1つのcanonical byte representationを定義します。Formattingはlanguage version、semantic meaning、line commentを変えず、diffを一定にします。 + +## Formatできるsource + +FormatterはBOMなしUTF-8を受け取ります。Lexical/syntax error時はdiagnosticだけを返し、partial formatted sourceを返しません。Syntaxがvalidならsemantic/complexity diagnosticがあってもformatできます。Format成功はdiagramのvalidityを意味しません。 + +## Canonical output + +Canonical sourceは次の規則に従います。 + +- BOMなしUTF-8を使う。 +- 全line endingをLFへ正規化する。 +- Block levelごとにASCII space 2つを使い、formatting tabを使わない。 +- Line末尾のformatting whitespaceを置かない。 +- 最後はちょうど1 LFにする。 +- Opening braceはdeclarationまたは`layout`行、closing braceは単独行に置く。 +- Versionとdiagram、bodyの隣接member間に1 empty lineを置く。 +- Propertyとlayout statement間にはempty lineを置かない。 + +```stack +stack 1.0 + +diagram "Title" { + theme dark + + node client "Client" + + node api "API" { + kind service + detail "Public API" + } + + edge client -> api "HTTPS" { + kind request + } + + layout { + direction right + order [client, api] + } +} +``` + +## Orderとlist + +Formatterはdiagram/group member、node/edge property、layout statement、list identifierのauthored orderを保持します。Group化やsortはしません。Listは1行でcomma後に1 space、bracket内側にspaceなし、trailing commaなしです。 + +## String + +Valid stringをdecodeし、Unicode normalizationせずUTF-8で直接出力します。Quoteとbackslashはescapeし、canonical outputは`\uXXXX`を使いません。たとえば`"API \u56F3 \uD83D\uDE80"`は`"API 図 🚀"`になります。 + +## Comment + +すべてのline commentと順序を保持します。Trailing commentは直前tokenの後へ1 spaceで続きます。Own-line commentはtoken gapを保ち、後続member、statement、propertyの直前に置きます。Construct内commentはcontinuation lineを強制でき、通常のone-line ruleに対する唯一の例外です。 + +Canonical sourceを再formatした結果はbyte-identicalでなければなりません。Normalized IRがある場合、format前後でsemantically equalなIRを生成します。 diff --git a/generated/site/ja/language/nodes-and-groups.md b/generated/site/ja/language/nodes-and-groups.md new file mode 100644 index 0000000..b00e75e --- /dev/null +++ b/generated/site/ja/language/nodes-and-groups.md @@ -0,0 +1,67 @@ +# Nodeとgroup + +Nodeは参照可能なarchitectural entity、groupはlabel付きcontainment boundaryです。この2つでdiagram内のcomponentとscopeを記述します。 + +## Node + +Nodeにはglobally uniqueなidentifierとvisible labelが必要です。Identifierはedgeとlayoutから参照しますがrenderされません。Labelは1〜60 Unicode scalarです。 + +```stack +stack 1.0 + +diagram "Node example" { + node api "Public API" { + kind service + detail "Order orchestration" + } +} +``` + +別entityなら同じvisible labelを持てますが、位置に頼らず理解できるlabelを推奨します。Node blockでは`kind`、`icon`、`detail`を重複できません。 + +## Node kind + +`kind`は粗いarchitectural meaningを表し、themeが管理するshapeとfallback iconを選びます。Defaultは`service`です。 + +| Kind | Intended meaning | +| ---------- | ------------------------------------------------- | +| `actor` | Person、role、team、autonomous participant | +| `client` | Browser、mobile/desktop app、deviceなどのclient | +| `service` | Long-running app、API、gateway、general component | +| `function` | On-demandまたはserverless compute unit | +| `worker` | Background processorまたはscheduled job | +| `database` | Durableでquery可能なdatastore | +| `cache` | 内容を破棄・再生成できるdatastore | +| `queue` | Async delivery用queue、stream、bus、broker | +| `storage` | Blob、object、file、archive storage | +| `external` | Architectureのcontrol boundary外のsystem | + +Kindはvendor shapeではなくsemantic categoryです。Hosted PostgreSQLも`database`で、technology名は`detail`に書きます。 + +## Labelとdetail + +`detail`は任意のvisibleな2行目で、1〜80 Unicode scalarです。`"Next.js"`、`"PostgreSQL 17"`、`"Order orchestration"`のように1 technologyまたは短いresponsibilityを書きます。すべてのrenderで表示され、tooltipだけにはなりません。 + +Labelとdetailはplain textです。明示`icon`はnodeを装飾しますが、kind、identity、accessible labelを変えません。[Themeとicon](./themes-and-icons)も参照してください。 + +## Group + +Groupにはglobally uniqueなidentifier、1〜60 Unicode scalarのlabel、最低1つのdescendant nodeが必要です。Node、nested group、1つのlayout blockを含められます。 + +```stack +stack 1.0 + +diagram "Boundaries" { + group platform "Platform" { + group data "Data layer" { + node primary "Primary database" { + kind database + } + } + } +} +``` + +Nestingはdiagram下3 levelまでです。Nodeは最も近いgroupと全ancestor groupに属します。Declarationは再利用できないため、2つの別groupには所属できません。 + +Edgeは必ずdiagram scopeで宣言し、endpointにはnodeだけを使えます。Groupはimplicit nodeやrelationshipを作りません。Labelでsystem、domain、network、deployment area、teamなどの意味を示します。Containmentだけでruntime isolation、security、ownership、deployment semanticsを意味しません。 diff --git a/generated/site/ja/language/syntax.md b/generated/site/ja/language/syntax.md new file mode 100644 index 0000000..ed01ab8 --- /dev/null +++ b/generated/site/ja/language/syntax.md @@ -0,0 +1,95 @@ +# Documentとsyntax + +Stack sourceは意図的に小さく設計されています。このページではdraft Stack 1.0のlexical structureとgrammarをすべて説明します。 + +## Document構造 + +DocumentはBOMなしUTF-8の`.stack` fileです。LFとCRLFは同じ意味です。最初のnon-comment tokenはversion directiveで、その後にちょうど1つのdiagramが続き、後続declarationは置けません。 + +```stack +// One file, one diagram. +stack 1.0 + +diagram "Example" { + node api "API" +} +``` + +Diagram titleは必須で1〜80 Unicode scalar、先頭・末尾にUnicode whitespaceは置けません。Diagramには最低1 nodeが必要です。 + +## Commentとwhitespace + +Space、tab、line endingはtokenを分離しますが、それ以外の意味を持ちません。Line commentは`//`からline endingまでで、whitespaceを置ける場所に記述できます。Block commentはありません。 + +Formatting自体はsemanticではありませんが、canonical formatterは[Canonical formatting](./formatting)の一定形式を生成します。 + +## Identifier + +Node、group、theme、reference identifierは次に一致します。 + +```text +[a-z][a-z0-9_-]* +``` + +1〜64 ASCII文字でcase-sensitive、画面には表示されません。Nodeとgroupは1つのglobal namespaceを共有します。Keywordはcontextualなのでidentifier位置にも置けますが、読みにくい名前は避けてください。 + +Icon identifierはquoted stringで、decode後が`[a-z0-9][a-z0-9-]*`に一致する1〜64 ASCII文字です。Effective theme内で解決されます。 + +## String + +Stringはdouble quoteで囲み、Unicodeを直接書けます。Escapeは3種類だけです。 + +| Escape | Meaning | +| -------- | ----------------- | +| `\"` | Double quote | +| `\\` | Backslash | +| `\uXXXX` | Unicode code unit | + +Decode後のstringにline break、tab、control character、unpaired surrogateは置けません。Title、label、detailの先頭・末尾にUnicode whitespaceは置けません。Stringはplain textであり、MarkdownやHTMLとして解釈されません。 + +## 完全なgrammar + +```text +document = version-directive, diagram-declaration, EOF ; +version-directive = "stack", integer, ".", integer ; +diagram-declaration + = "diagram", string, "{", { diagram-member }, "}" ; +diagram-member = node-declaration | group-declaration | edge-declaration + | theme-statement | layout-block ; +theme-statement = "theme", identifier ; +group-declaration = "group", identifier, string, "{", { group-member }, "}" ; +group-member = node-declaration | group-declaration | layout-block ; +node-declaration = "node", identifier, string, [ node-block ] ; +node-block = "{", node-property, { node-property }, "}" ; +node-property = "kind", node-kind | "icon", string | "detail", string ; +node-kind = "actor" | "client" | "service" | "function" | "worker" + | "database" | "cache" | "queue" | "storage" | "external" ; +edge-declaration = "edge", identifier, edge-operator, identifier, + [ string ], [ edge-block ] ; +edge-operator = "->" | "<->" | "--" ; +edge-block = "{", edge-property, { edge-property }, "}" ; +edge-property = "kind", edge-kind ; +edge-kind = "flow" | "request" | "event" | "data" | "dependency" ; +layout-block = "layout", "{", layout-statement, + { layout-statement }, "}" ; +layout-statement = direction-statement | rank-statement | order-statement ; +direction-statement + = "direction", ( "right" | "down" ) ; +rank-statement = "rank", "same", identifier-list ; +order-statement = "order", identifier-list ; +identifier-list = "[", identifier, ",", identifier, + { ",", identifier }, "]" ; +integer = "0" | nonzero-digit, { digit } ; +``` + +## Contextual keyword + +Stack 1.0はgrammar上の位置で次のwordを認識します。 + +```text +stack diagram group node edge theme layout kind icon detail direction +rank same order right down actor client service function worker +database cache queue storage external flow request event data dependency +``` + +Unknown declaration、property、enum value、operatorはerrorです。見た目だけ成功してauthorの意味を失わないよう、toolはunknown syntaxを黙って無視しません。 diff --git a/generated/site/ja/language/themes-and-icons.md b/generated/site/ja/language/themes-and-icons.md new file mode 100644 index 0000000..ace5bab --- /dev/null +++ b/generated/site/ja/language/themes-and-icons.md @@ -0,0 +1,126 @@ +# Themeとicon + +Themeはdiagram-levelでrendererが管理するvisual systemへのsymbolic referenceです。Iconはそのtheme内で解決するlogical nameです。どちらもdiagramの意味を変更しません。 + +## Themeを選ぶ + +Diagram直下に最大1つの`theme` statementを置きます。 + +```stack +stack 1.0 + +diagram "Dark architecture" { + theme dark + + node api "API" +} +``` + +省略時は`default`です。Draft Stack 1.0はcore catalogに次のthemeを要求します。 + +| Theme | Intended use | +| --------- | ------------------------------------------------------------ | +| `default` | 一般的なarchitecture diagram向けのbalanced blue-gray surface | +| `light` | Light document向けのwarm neutral surface | +| `dark` | Dark canvas向けのhigh-contrast cool surface | + +Sourceはidentifierを選ぶだけで、catalog package versionを選びません。Render metadataがcatalog versionとcontent revisionを記録します。 + +生成diagramのthemeとPlayground UIのlight/darkは独立しています。Themeはpalette、typography metric、surface、icon、connector、backgroundを変えられますが、node、group、edge、label、kind、direction、layout constraintを隠したり変更したりできません。 + +## Fallback behavior + +3つのcore themeはrenderer必須resourceです。利用中catalogにないnon-core themeはwarning `STK6001`を出し、`default`でrenderします。Sourceにidentifierがあってもnetworkからthemeを取得しません。 + +Theme identifierは通常のStack identifier syntaxを使います。一度登録されたidentifierを、deprecation後も別themeへ再利用できません。 + +## Kind fallback icon + +各themeは全node kindにfallbackを持ちます。`icon`を省略するとrendererがこれを使います。 + +| Node kind | Current logical fallback icon | +| ---------- | ----------------------------- | +| `actor` | `kind-actor` | +| `client` | `kind-client` | +| `service` | `kind-service` | +| `function` | `kind-function` | +| `worker` | `kind-worker` | +| `database` | `kind-database` | +| `cache` | `kind-cache` | +| `queue` | `kind-queue` | +| `storage` | `kind-storage` | +| `external` | `kind-external` | + +現在のopen core catalogは`default`、`light`、`dark`にこの10 fallback identifierを持ちます。`postgresql`、`aws`、`github`などのvendor iconはまだありません。通常はsemanticな`kind`を選び、`icon`を省略してください。 + +## 明示icon + +明示iconはquoted logical identifierです。 + +```stack +stack 1.0 + +diagram "Explicit icon" { + node gateway "Public API" { + kind service + icon "api" + } +} +``` + +Iconはnodeを装飾するだけで、`service` kind、identity、label、accessible descriptionを変えません。Themeごとに色やartworkを調整できますが、同じidentifierは同じlogical subjectを表します。 + +## First-party icon catalog + +Free core catalogは、次のprovider-neutralな明示iconを`default`、`light`、`dark`に収録しています。 + +| ID | Stable subject | 主な用途 | +| --------------- | --------------------------------- | -------------------------------- | +| `api` | Application programming interface | Public / internal API | +| `web` | Web application | Browser向けWeb experience | +| `mobile` | Mobile application | iOS / Android client | +| `desktop` | Desktop application | Native desktop client | +| `server` | Server host | Virtual machine / physical host | +| `container` | Application container | Containerized workload | +| `cluster` | Compute cluster | Orchestrated compute group | +| `cloud` | Cloud environment | Provider-neutralなcloud boundary | +| `scheduler` | Scheduled execution | Cron job / scheduled work | +| `webhook` | Webhook endpoint | Inbound / outbound callback | +| `identity` | Identity and access | Authentication / authorization | +| `observability` | Observability system | Metrics / logs / traces | +| `gateway` | Network gateway | Public / private networkの入口 | +| `load-balancer` | Load balancer | Trafficの分散 | +| `dns` | Domain name service | Hostname / service discovery | +| `cdn` | Content delivery network | Edgeでのcontent delivery | +| `firewall` | Network firewall | Network access boundary | +| `network` | Network topology | 一般的なnetwork / subnet | +| `event` | Discrete event | 個別のdomain / system event | +| `stream` | Event stream | 継続的なevent / data flow | +| `search` | Search service | Indexing / query system | +| `analytics` | Analytics system | Reporting / data analysis | +| `repository` | Source code repository | Source code / version control | +| `pipeline` | Delivery pipeline | Build / test / deploy flow | +| `secret` | Secret or credential | Secret / key / credential | +| `document` | Document or knowledge base | Documentation / knowledge | +| `task` | Task or issue tracker | Task / ticket / issue tracking | +| `chat` | Chat or messaging tool | Team chat / messaging | +| `email` | Email delivery | Email delivery / inbox | +| `ai` | Artificial intelligence system | AI model / inference service | + +下のpreviewをlight / darkへ切り替えると、実際のoutputを比較できます。各imageは公開`@stack-sh/engine@0.7.0`がlocalでrenderし、DocumentationにTheme SVG assetを複製していません。Syntaxの行を選ぶとコピーできます。 + + + +Semanticな`kind`と明示iconは独立して選びます。たとえば`icon "web"`は`client`にも`service`にも使えますが、そのnodeの意味は変更しません。 + +## 未収録iconとvendor icon + +Core catalogは現在、`postgresql`、`aws`、`github`、`docker`などのvendor / project markを収録していません。Effective themeにauthored icon identifierがなければ、node kindのfallbackでrenderを続け、warning `STK5001`を出します。 + +上表のprovider-neutral iconを選ぶか、kind fallbackだけで役割が伝わる場合は`icon`を省略してください。Vendor markを別catalogへ収録するには、asset単位のlicense、redistribution、trademark reviewが必要です。 + +## Catalogとasset safety + +Public `stack-sh/theme` catalogがpalette、deterministic font metric、node-kind visual、connector、icon metadata、SVG byte、provenance、redistribution permissionを所有します。Catalog assetはrendererへbundleし、authored identifierをfile pathやURLとして扱いません。 + +SVG validationはscript、event handler、nested SVG、unsafe reference、data/network URL、style attribute、allowlist外のelement/attributeを拒否します。Iconだけを意味の唯一の手掛かりにせず、labelとnon-color distinctionも維持します。 diff --git a/generated/site/ja/reference/diagnostics-and-limits.md b/generated/site/ja/reference/diagnostics-and-limits.md new file mode 100644 index 0000000..e5a1b2c --- /dev/null +++ b/generated/site/ja/reference/diagnostics-and-limits.md @@ -0,0 +1,58 @@ +# Diagnosticとlimit + +Stack diagnosticはconsole proseではなくstructured resultです。Stable code、`error`/`warning` severity、1-based end-exclusive source range、簡潔なmessage、ordered `expected` listを持ちます。必要に応じてcorrective helpとrelated source rangeも含みます。 + +## Processingとseverity + +Toolはencoding/token、grammar、identifier/default、semantic limit、theme/icon、layout、renderの順で処理します。最初の4 stageのerrorはrenderを止めます。Theme、icon、density、layout-hint warningはfallback SVGと同時に返せます。 + +Playgroundはsource編集後にstale diagnosticを消します。Resultを選ぶとprimary sourceへfocusし、related informationから以前のdeclarationへ移動できます。 + +## Complexity limit + +| Item | Draft Stack 1.0 limit | +| ------------------------ | -------------------------------: | +| Documentあたりのdiagram | 1 | +| Node | 1〜40 | +| Group | 0〜12 | +| Diagram下のgroup nesting | 3 level | +| Edge | 0〜80またはnode数の2倍の小さい方 | +| Warning前のnode degree | 12 incident edge declaration | + +Hard limit超過は`STK4003`です。推奨degreeを超えたnodeはvalidのまま`STK4002`を出します。大規模systemは1つへ圧縮せず、焦点を絞ったdiagramへ分けてください。 + +## Portable diagnostic code + +| Code | Severity | Meaning | +| --------- | -------- | -------------------------------------------------------- | +| `STK1001` | Error | Inputがvalid UTF-8ではない | +| `STK1002` | Error | Byte order markがある | +| `STK1003` | Error | String escapeまたはdecode valueがinvalid | +| `STK2001` | Error | 宣言language versionがunsupported | +| `STK2002` | Error | Unexpected token、declaration、property、value、operator | +| `STK2003` | Error | Construct完了前にinputが終了した | +| `STK3001` | Error | Identifierがinvalid | +| `STK3002` | Error | Identifierが重複宣言された | +| `STK3003` | Error | Edgeがunknown nodeを参照した | +| `STK3004` | Error | Groupをedge endpointに使った | +| `STK3005` | Error | Edgeが同じnodeを接続した | +| `STK3006` | Error | Exact duplicate edgeを宣言した | +| `STK3007` | Error | 1 block内でpropertyが重複した | +| `STK3008` | Error | Title、label、detailがtext constraint違反 | +| `STK3009` | Error | Groupにdescendant nodeがない | +| `STK3010` | Error | Group nestingがlimit超過 | +| `STK3011` | Error | Layout referenceがscope内でinvalid | +| `STK3012` | Error | Layout blockまたはsingleton statementが重複した | +| `STK3013` | Error | Icon identifierがmalformed | +| `STK3014` | Error | Diagramに複数theme statementがある | +| `STK4001` | Warning | Order hintを満たせなかった | +| `STK4002` | Warning | Nodeが推奨incident-edge degreeを超えた | +| `STK4003` | Error | Diagramがlanguage complexity limit超過 | +| `STK5001` | Warning | Effective themeにiconがなくkind fallbackを使用した | +| `STK6001` | Warning | Requested non-core themeがなく`default`を使用した | + +Code familyは`STK1000`がencoding/lexical、`STK2000`がsyntax、`STK3000`がname/semantic、`STK4000`がlayout/complexity、`STK5000`がicon、`STK6000`がthemeです。`STK9000`はsource mistakeではなくimplementation failure用です。Implementation固有diagnosticはnon-`STK` prefixだけを使えます。 + +## Recovery rule + +Parserは複数のindependent errorを報告するためrecoverできますが、partial diagramをvalidとしてrenderできません。Unknown declaration、property、enum value、operatorは無視されません。Authorの意味を失った成功風outputを防ぎます。 diff --git a/generated/site/ja/reference/versioning-and-safety.md b/generated/site/ja/reference/versioning-and-safety.md new file mode 100644 index 0000000..1a0b3b3 --- /dev/null +++ b/generated/site/ja/reference/versioning-and-safety.md @@ -0,0 +1,40 @@ +# Versioningと安全性 + +Draft Stack 1.0はsource language、implementation、theme catalog、package versionを分離します。この境界を理解するとdocumentをportableにし、rendered outputの由来を追跡できます。 + +## Language version + +すべてのdocumentは`major.minor` directiveから始まります。 + +```stack +stack 1.0 + +diagram "Versioned source" { + node api "API" +} +``` + +これはdocumentが必要とするminimum language grammar / semanticsで、engineやtheme versionではありません。`M.N`対応rendererは同じmajorでminorが`N`以下のdocumentをacceptし、異なるmajorや未対応のhigher minorをrejectします。Unknown future syntaxを推測しません。 + +Specification releaseはsemantic versioningを使います。Majorはincompatible language change、minorはbackwards-compatible capability追加、patchはvalid sourceの意味を変えないclarification / errataです。そのためdocument directiveにpatchはありません。 + +## Rendererとcatalog identity + +通常のengine resultにはengine version、authored language version、theme catalog version、catalog content revisionが入ります。Sourceの`theme`はsymbolic identifierを選ぶだけで、package releaseをpinしたりremote dataを取得したりしません。 + +Exact pixel outputはlanguage compatibility promiseではありません。Theme metric、renderer version、font、canvas判断で位置が変わっても、node、group、relationship、label、kind、constraintは保持されます。 + +## 安全なsource boundary + +Stack stringはplain textです。Sourceに実行code、任意HTML/Markdown、CSS、SVG、import、macro、file path、network URLは置けません。Engineはauthored textをescapeし、validated catalog icon、local marker reference、accessible title/description metadataを埋め込んだstandalone SVGを生成します。 + +Rendered SVGにはscript、event handler、任意external reference、host font measurement、runtime I/Oがありません。Missing icon/theme nameはpath解決やregistry接続ではなくbundled fallbackを選びます。 + +## 現在のdelivery status + +- Browser Playgroundがsupport対象のpublic experienceです。 +- Public `@stack-sh/engine`がPlaygroundで使うtyped WebAssembly `format`、`check`、`render`を提供します。 +- Public `@stack-sh/language`がeditor highlight用のshared TextMate grammarと言語metadataを提供します。 +- Public [`stack-sh/cli`](https://github.com/stack-sh/cli)がnative `format`、`check`、`render`、provider-icon store操作を提供します。 + +Normative language contractは[`stack-sh/specification`](https://github.com/stack-sh/specification)、public theme catalogは[`stack-sh/theme`](https://github.com/stack-sh/theme)、engine behaviorは[`stack-sh/engine`](https://github.com/stack-sh/engine)が正本です。 diff --git a/generated/site/ko/examples/index.md b/generated/site/ko/examples/index.md new file mode 100644 index 0000000..e9908e6 --- /dev/null +++ b/generated/site/ko/examples/index.md @@ -0,0 +1,7 @@ +# 예제 갤러리 + +작은 다이어그램에서 시작해 그룹, 레이아웃 제약, 클라우드 제공자 아이콘, 프로덕션 수준의 시스템으로 단계적으로 확장합니다. 아래의 모든 썸네일은 공개 Stack 명세에 고정된 canonical source에서 생성됩니다. + +Provider 예제의 아트워크는 caller-owned입니다. 브랜드 아이콘이 필요하면 표시된 아이콘 팩을 설치하세요. 팩이 없어도 같은 소스는 유효하며 Stack의 deterministic missing-icon fallback으로 렌더링됩니다. + + diff --git a/generated/site/ko/guide/agent-workflow.md b/generated/site/ko/guide/agent-workflow.md new file mode 100644 index 0000000..666fd28 --- /dev/null +++ b/generated/site/ko/guide/agent-workflow.md @@ -0,0 +1,42 @@ + + +# Stack diagrams + +Deliver editable `.stack` source and, when rendering is available, an SVG. Preserve the requested architecture and existing unrelated content. Stack describes architecture; it does not provision resources or execute application code. + +## Start with the available tools + +Run `stack --version` and `stack help` before selecting commands. Use the installed binary's help, not unreleased repository instructions. The published CLI 0.4.0 supports `check`, `fmt`, and `render`; it does not support their `--json` flags. A newer version may support additional options: verify them using `stack help `. + +If the CLI is missing, consult the [installation guide](https://stack-diagram.com/docs/guide/getting-started.md) and [release distribution contract](https://github.com/stack-sh/cli/blob/v0.4.0/docs/distribution.md). Install only when the user's authorization allows it. Otherwise provide source with an explicit validation gap; do not report it as checked. No remote source upload is required. + +## Read only the relevant reference + +Start with [syntax](https://stack-diagram.com/docs/language/syntax.md), [nodes and groups](https://stack-diagram.com/docs/language/nodes-and-groups.md), and [edges and layout](https://stack-diagram.com/docs/language/edges-and-layout.md) when the grammar is unfamiliar. Find complete examples in the [gallery](https://stack-diagram.com/docs/examples/index.md). The [documentation index](https://stack-diagram.com/docs/llms.txt) links the remaining references. If the client cannot fetch one resource, try its Markdown page or report the missing information rather than inventing syntax. + +Non-obvious constraints: + +- One `stack 1.0` declaration and one named `diagram`; node/group IDs are globally unique. +- Declare edges at diagram scope. Endpoints are node IDs, not labels or groups. +- Model technologies using labels and `detail`; choose semantic `kind` values from the reference. Do not invent properties such as coordinates, colors, or ports. +- Prefer automatic layout or `direction` initially. `order` controls relative cross-axis ordering, not execution sequence; add `rank` or `order` only when the user needs that constraint. References must be direct children of that layout scope. +- Do not guess vendor icon IDs. Consult [provider icons](https://stack-diagram.com/docs/guide/provider-icons.md), query `stack icons list`, and verify the required pack is installed. Import downloads and terms acceptance need appropriate user authorization. If no pack is available, use the semantic kind fallback and explain that branded artwork is absent. + +## Generate, validate, and render + +For a new diagram, start with the smallest complete source that preserves the requested components and relationships. For an edit, inspect the existing source first and retain unrelated nodes, edges, labels, and comments. + +Using the user's actual filenames: + +```sh +stack check architecture.stack +stack fmt architecture.stack +stack check architecture.stack +stack render architecture.stack -o architecture.svg +``` + +`fmt` changes the source in place; avoid unrelated formatting when it would obscure a narrowly requested edit. Rendering to a file may replace it, so honor existing artifact ownership. + +Read both the exit status and diagnostics. An exit code of zero can still carry warnings. Fix unknown references or invalid syntax from the diagnostic ranges; never remove requested architecture merely to make validation pass. Investigate layout warnings without treating an optional visual hint as a required semantic relationship. Missing-icon warnings mean the image rendered with a fallback, not that provider artwork was found. Bound repeated repair attempts and report a remaining blocker rather than silently weakening the task. + +After rendering, inspect the SVG visually when a suitable viewer is available. Compiler success does not prove readable layout. Confirm the requested nodes, boundaries, relationships, and labels remain present. Report the source/SVG paths, CLI version, validation result, and any unresolved warnings or unverified visual behavior. diff --git a/generated/site/ko/guide/coding-agents.md b/generated/site/ko/guide/coding-agents.md new file mode 100644 index 0000000..122285a --- /dev/null +++ b/generated/site/ko/guide/coding-agents.md @@ -0,0 +1,27 @@ +# Coding agent 사용 + +Coding agent로 Stack을 읽고 쓰면 아키텍처 다이어그램을 검토 가능한 소스로 관리할 수 있습니다. 언어 레퍼런스를 읽고 CLI를 로컬에서 실행하므로 원격 MCP 서버가 필요하지 않습니다. + +## Skill 설치 + +`npx skills add stack-sh/cli`로 현재 프로젝트에 다이어그램 skill만 설치합니다. 사용자 전체에 설치하려는 경우에만 `-g`를 추가하고 다운로드한 지침을 검토하세요. CLI는 별도로 설치해야 합니다. 재현 가능한 설치에는 저장소를 clone하고 검토한 commit을 checkout한 다음 `npx skills add /absolute/path/to/cli --skill stack-diagrams`를 실행하세요. 설치 프로그램은 commit SHA를 원격 브랜치로 직접 지정하는 방식을 지원하지 않습니다. + +[SKILL.md](https://github.com/stack-sh/cli/blob/main/skills/stack-diagrams/SKILL.md) + +## 설치 없이 사용 + +다음 지침을 agent에게 전달하고 아키텍처 요구 사항을 추가하세요. HTTPS 문서를 읽고 로컬 명령을 실행할 수 있다면 skill 미지원 클라이언트에서도 사용할 수 있습니다. + +```text +Use Stack to create or edit the architecture described below. Read https://stack-diagram.com/docs/guide/agent-workflow.md and follow its local validation and safety workflow. Read the relevant language reference and examples as needed. Deliver editable .stack source and report verification results. Architecture requirements: +``` + +전체 [agent workflow](./agent-workflow)는 CLI skill과 같은 원본에서 생성됩니다. 정본 agent 지침은 영어입니다. 위 Markdown URL을 agent가 읽게 하거나 전체 지침을 복사하세요. + +## 레퍼런스와 업데이트 + +- [Examples](../examples/index) +- [Syntax](../language/syntax) +- [Diagnostics](../reference/diagnostics-and-limits) +- [Provider icons](./provider-icons) +- [Markdown index](https://stack-diagram.com/docs/llms.txt) diff --git a/generated/site/ko/guide/getting-started.md b/generated/site/ko/guide/getting-started.md new file mode 100644 index 0000000..210357f --- /dev/null +++ b/generated/site/ko/guide/getting-started.md @@ -0,0 +1,86 @@ +# 시작하기 + +Stack을 가장 빠르게 사용하는 방법은 브라우저 [Playground](https://stack-diagram.com/)입니다. 포매터, 검증기, 레이아웃 엔진, SVG 렌더러가 WebAssembly로 로컬에서 실행되므로 명령 설치나 렌더링 API로의 소스 전송이 필요 없습니다. + +## 네이티브 CLI 설치 + +터미널 워크플로와 로컬 자동화에서는 `brew install stack-sh/tap/stack`으로 Stack이 관리하는 Homebrew formula를 설치합니다. 이 formula는 표준 Stack CLI 0.4.0 릴리스 아카이브를 사용하며, Homebrew의 현재 Tier 1 요구 사항을 충족하는 Apple Silicon macOS와 arm64 / x86_64 glibc Linux를 지원합니다. 업그레이드는 Homebrew가 `brew upgrade stack-sh/tap/stack`으로 관리하며, formula를 제거해도 Stack 설정과 아이콘 저장소는 유지됩니다. 정확한 플랫폼 매트릭스, 직접 설치 방법 및 복구 정책은 [CLI 배포 계약](https://github.com/stack-sh/cli/blob/main/docs/distribution.md#homebrew-installation)을 참고하세요. + +## 첫 문서 작성 + +에디터 내용을 다음 예제로 바꿉니다. + +```stack +stack 1.0 + +diagram "Checkout" { + theme default + + node shopper "Shopper" { + kind actor + } + + group application "Application" { + node web "Web app" { + kind client + detail "React" + } + + node api "Checkout API" { + kind service + detail "Rust" + } + + layout { + direction right + order [web, api] + } + } + + node orders "Orders" { + kind database + detail "PostgreSQL" + } + + edge shopper -> web "HTTPS" { + kind request + } + + edge web -> api "JSON" { + kind request + } + + edge api -> orders "SQL" { + kind data + } + + layout { + direction right + order [shopper, application, orders] + } +} +``` + +## 렌더링하고 확인하기 + +**Run**을 선택하거나 Command/Ctrl + Enter를 누릅니다. 프리뷰에 독립형 SVG가 표시됩니다. 프리뷰를 선택해 크게 확인하고, 필요하면 **Download SVG**로 저장합니다. + +소스는 네 부분으로 구성됩니다. + +1. `stack 1.0`은 언어 버전을 선언합니다. +2. `diagram`은 하나의 제목과 전체 아키텍처를 포함합니다. +3. `node`와 `group`은 컴포넌트와 경계를 선언합니다. +4. `edge`는 관계를, `layout`은 제한된 배치 의도를 기록합니다. + +## 검사와 포맷 + +**Check**는 SVG를 바꾸지 않고 전체 검증과 레이아웃 파이프라인을 실행합니다. **Format**은 줄 주석과 의미를 보존하면서 문법적으로 유효한 소스를 표준 2칸 형식으로 다시 씁니다. + +문제가 있으면 진단에 심각도, 안정적인 코드, 위치, 소스 프레임, 예상 값과 가능한 수정 도움말이 표시됩니다. 진단을 선택하면 해당 소스 범위에 포커스합니다. + +## 다음으로 읽을 내용 + +- 어휘 규칙과 전체 문법은 [문서와 문법](../language/syntax)을 참고하세요. +- 컴포넌트와 경계는 [노드와 그룹](../language/nodes-and-groups)을 참고하세요. +- 관계와 배치 의도는 [엣지와 레이아웃](../language/edges-and-layout)을 참고하세요. +- 시각 시스템이나 명시적 아이콘을 고르기 전에 [테마와 아이콘](../language/themes-and-icons)을 읽으세요. diff --git a/generated/site/ko/guide/playground.md b/generated/site/ko/guide/playground.md new file mode 100644 index 0000000..5294da6 --- /dev/null +++ b/generated/site/ko/guide/playground.md @@ -0,0 +1,42 @@ +# Playground 사용법 + +Playground는 [stack-diagram.com](https://stack-diagram.com/)의 공개 브라우저 consumer입니다. 에디터는 네이티브 텍스트 입력을 유지하고 공유 TextMate grammar가 문법 색상을 제공합니다. 검증, 포맷, 레이아웃, SVG는 항상 공개 Stack WebAssembly 엔진에서 생성됩니다. + +## 작업 + +| 작업 | 결과 | +| ---------------- | ----------------------------------------------------------------------------------- | +| **Format** | 문법적으로 유효한 소스를 표준화하고 주석을 보존합니다. 의미 오류는 계속 표시됩니다. | +| **Check** | 새 SVG를 만들지 않고 compiler, theme, icon, layout, routing을 검사합니다. | +| **Run** | 전체 파이프라인을 실행하고 렌더링을 막는 오류가 없으면 SVG를 갱신합니다. | +| **Download SVG** | 현재 독립형 SVG를 저장합니다. | + +Command/Ctrl + Enter로도 실행할 수 있습니다. 소스가 변경되면 이전 범위를 현재 결과로 보이지 않도록 오래된 진단을 지웁니다. + +## 진단 읽기 + +오류 결과에는 다음 정보가 포함될 수 있습니다. + +```text +error[STK2002] at 4:22 +4 | layout { direction hoo } + | ^^^ unexpected layout direction 'hoo' + = expected: right, down + = help: use 'right' for horizontal flow or 'down' for vertical flow +``` + +진단이나 관련 정보를 선택하면 대응하는 소스에 포커스합니다. 오류는 성공적인 렌더링을 막습니다. 경고는 fallback 또는 가독성 문제를 설명하며 SVG와 함께 반환될 수 있습니다. + +## 독립된 두 색상 설정 + +헤더의 색상 모드는 Playground와 에디터 표현만 바꿉니다. `theme dark` 같은 소스 문장은 생성된 다이어그램을 바꿉니다. 사이트를 다크 모드로 전환해도 다이어그램 테마를 다시 해석하거나 변경하지 않도록 둘은 독립적입니다. + +## 브라우저 동작과 데이터 + +Playground는 공개 WebAssembly 모듈을 불러온 뒤 브라우저에서 동기식 `format`, `check`, `render`를 실행합니다. 엔진 자체는 파일을 읽거나 네트워크 서비스에 접속하거나 DOM, 시계, 호스트 폰트 측정을 사용하지 않습니다. + +현재 Playground에는 계정, 클라우드 저장, 협업, 유료 테마가 없습니다. 보관할 소스와 SVG를 다운로드하세요. + +## 접근성 + +에디터는 네이티브 캐럿, 선택, 클립보드, 실행 취소, 키보드, IME 동작을 유지합니다. 진단에서 소스 범위로 이동할 수 있습니다. 프리뷰는 텍스트 대체를 제공하고 키보드로 접근 가능한 다이얼로그에서 열립니다. 인터페이스는 320px 레이아웃, 라이트/다크 대비, 보이는 포커스, reduced motion을 지원합니다. diff --git a/generated/site/ko/guide/provider-icons.md b/generated/site/ko/guide/provider-icons.md new file mode 100644 index 0000000..66defcc --- /dev/null +++ b/generated/site/ko/guide/provider-icons.md @@ -0,0 +1,118 @@ +# 클라우드 제공자 아이콘 + +Stack에는 제공자 중립적인 core icon catalog가 포함됩니다. AWS, Google Cloud, Azure 및 주요 개발·협업 도구 그림은 사용자가 관리하는 icon store에 저장된 provider pack으로 사용할 수 있습니다. + +## 사용 가능한 제공자 catalog + +감사 완료 catalog에는 총 1,051개 ID가 있습니다. AWS Architecture Icons 305개, Google Cloud 제품·category icon 45개, Azure service icon 639개, 주요 tool icon 62개입니다. Tool catalog에는 GitHub, GitHub Actions, Notion, Linear, Atlassian, Jira, Confluence, Docker, Kubernetes, Terraform, Datadog, Grafana, Sentry 등이 포함됩니다. + +Provider 카드를 선택하면 import 명령을 확인할 수 있습니다. 전체 catalog를 검색·filter할 수 있으며 작은 화면에서도 안정적으로 보이도록 100개씩 표시합니다. + + + +Provider pack은 그림을 제공합니다. Stack source의 node `kind`가 계속 의미적 스타일과 레이아웃을 결정합니다. + +## 빠른 시작 + +다이어그램에서 사용하는 각 provider를 한 번씩 import합니다. `--accept-terms`는 연결된 provider 및 brand terms를 검토하고 동의했음을 기록합니다. + +```sh +$ stack icons import gcp --accept-terms +$ stack icons import simple-icons --accept-terms +$ stack render architecture.stack -o architecture.svg +``` + +CLI는 감사 완료 공식 archive를 다운로드하고 전체 SHA-256을 검증하며 선택한 SVG를 sanitize한 뒤 처리된 provider pack을 shared icon store에 기록합니다. Google Cloud 제품과 category 그림은 하나의 `gcp` 명령으로 함께 import됩니다. + +## CLI에서 provider icon 사용하기 + +하나의 Stack 파일에서 여러 provider를 사용할 수 있습니다. 다음 예제는 Google Cloud의 Cloud Run과 Simple Icons의 GitHub를 함께 사용합니다. + +```stack +stack 1.0 + +diagram "Deploy from GitHub to Cloud Run" { + node repository "GitHub" { + kind external + icon "simple-icons:github" + } + + node service "Cloud Run" { + kind service + icon "gcp:cloud-run" + } + + edge repository -> service "Deploy" { + kind dependency + } +} +``` + +두 pack을 import한 뒤 표준 render 명령이 모두 찾습니다. + +```sh +$ stack render architecture.stack -o architecture.svg --notice architecture.NOTICE.md +``` + +## Shared icon store + +기본 icon store는 `$XDG_CONFIG_HOME/stack/icons`입니다. `XDG_CONFIG_HOME`이 설정되지 않았으면 `$HOME/.config/stack/icons`를 사용합니다. + +```text +icons/ + aws/ + gcp/ + azure/ + simple-icons/ +``` + +`$XDG_CONFIG_HOME/stack/config.yaml`에서 절대 경로를 설정해 shared 위치를 변경할 수 있습니다. + +```yaml +default_icons_path: /absolute/path/to/stack-icons +``` + +이 위치는 `stack icons import`와 `stack render`에서 함께 사용됩니다. + +## Playground에서 provider icon 사용하기 + +**Icons**를 열고 `stack/icons` 폴더를 선택하면 Playground가 store 안의 인식 가능한 provider directory를 모두 불러옵니다. 불러온 그림을 검색하고 항목을 선택해 ID를 Stack source로 복사할 수 있습니다. + +선택한 pack은 현재 브라우저 탭에서 처리됩니다. 생성한 다이어그램에 provider 그림이 있으면 SVG 다운로드 옆의 **Notice**에서 source, terms 및 사용 icon 기록을 확인할 수 있습니다. + +## Icon을 프로젝트와 함께 관리하기 + +`-o`를 사용해 import한 pack을 repository와 함께 commit할 project directory에 둡니다. + +```sh +$ stack icons import gcp --accept-terms -o .stack-icons +$ stack icons import simple-icons --accept-terms -o .stack-icons +``` + +Render할 때 같은 icon-store root를 `--provider-pack`으로 전달합니다. + +```sh +$ stack render architecture.stack \ + --provider-pack .stack-icons \ + -o architecture.svg \ + --notice architecture.NOTICE.md +``` + +## Icon ID 찾기 + +CLI 또는 이 페이지에서 catalog를 검색할 수 있습니다. + +```sh +$ stack icons list +$ stack icons list aws s3 +$ stack icons list azure database +$ stack icons list simple-icons github +``` + +CLI 출력에는 `ID`, `PRODUCT`, `CATEGORY`, 권장 `KIND`가 포함됩니다. `gcp:cloud-run`, `simple-icons:github` 같은 namespaced ID가 해당 pack의 그림을 선택합니다. + +## 검증, terms 및 notice + +CLI catalog는 각 공식 HTTPS archive URL, release, 전체 SHA-256, 허용된 entry path, terms URL, review date를 pin합니다. Import는 archive와 SVG 크기를 제한하고 active 및 external SVG content를 sanitize하며 pack을 atomic하게 기록합니다. + +각 pack에는 `NOTICE.md`가 포함됩니다. `stack render --notice `는 실제 pack revision, source release, terms URL, attribution, non-endorsement text 및 사용 icon ID를 기록합니다. Catalog는 각 provider의 공식 source와 terms, Simple Icons mark의 brand source와 guideline도 연결합니다. diff --git a/generated/site/ko/guide/what-is-stack.md b/generated/site/ko/guide/what-is-stack.md new file mode 100644 index 0000000..a5af2c5 --- /dev/null +++ b/generated/site/ko/guide/what-is-stack.md @@ -0,0 +1,51 @@ +# Stack이란? + +Stack은 정적인 소프트웨어 아키텍처와 기술 스택 다이어그램을 위한 작은 선언형 언어입니다. UTF-8 `.stack` 파일에 컴포넌트, 경계, 관계를 작성하고 좌표, 간격, 경로, 타이포그래피, 시각 표현은 렌더러가 결정합니다. + +이 분리는 소스를 간결하고 리뷰하기 쉽게 만들며 버전 관리에도 적합하게 합니다. 같은 문서를 드로잉 명령으로 바꾸지 않고 호환 도구에서 포맷, 검사, 렌더링할 수 있습니다. + +## 기본 모델 + +모든 문서는 언어 버전과 정확히 하나의 다이어그램을 포함합니다. 다이어그램에는 노드와 선택적인 그룹, 엣지, 테마, 레이아웃 의도가 들어갑니다. + +```stack +stack 1.0 + +diagram "Service architecture" { + node client "Web app" { + kind client + } + + node api "API" { + kind service + detail "Order orchestration" + } + + edge client -> api "HTTPS" { + kind request + } +} +``` + +이 소스는 클라이언트가 서비스를 호출한다는 의미를 나타냅니다. 박스 위치나 화살표 경로는 지정하지 않습니다. + +## Stack의 설계 목표 + +- **간결한 작성:** 이름이 있는 노드와 엣지만으로 유용한 다이어그램을 만듭니다. +- **예측 가능한 생성:** 사람과 언어 모델이 같은 개념을 하나의 제한된 방식으로 안정적으로 표현합니다. +- **의미 기반 소스:** 픽셀이 아니라 토폴로지와 의도를 기록합니다. +- **정돈된 출력:** 렌더러가 일관된 시각 시스템을 소유합니다. +- **실행 가능한 오류:** 진단은 소스 범위, 예상 값, 수정 도움말, 관련 선언을 제공할 수 있습니다. +- **안전한 임베딩:** 소스는 코드를 실행하거나 임의 에셋을 가져오거나 HTML/SVG를 삽입할 수 없습니다. + +## Stack이 아닌 것 + +Stack 1.0은 범용 그래프 언어, 픽셀 단위 캔버스, 인프라 정의, 실행 가능한 프로그래밍 언어가 아닙니다. 변수, import, macro, 조건문, CSS, 좌표, 임의 URL, 내장 HTML이 없으며 sequence, state-machine, class, ER, 전체 UML 표기법도 아닙니다. + +큰 시스템은 하나에 압축하지 말고 여러 개의 집중된 다이어그램으로 설명하세요. Stack에는 가독성을 위한 요소 제한이 있습니다. + +## 처리 모델 + +도구는 문서 디코딩과 파싱, 식별자와 기본값 해결, 의미 검증, 테마와 아이콘 해결, 레이아웃, 렌더링 순서로 처리합니다. 소스 오류는 렌더링을 중단합니다. 선택적 테마나 아이콘 누락, 만족할 수 없는 레이아웃 힌트는 경고가 되어 fallback 다이어그램을 반환할 수 있습니다. + +작성자를 위한 모든 구문은 [언어 페이지](../language/syntax), 호환성과 신뢰 경계는 [버전과 안전성](../reference/versioning-and-safety)에서 설명합니다. diff --git a/generated/site/ko/index.md b/generated/site/ko/index.md new file mode 100644 index 0000000..13a1514 --- /dev/null +++ b/generated/site/ko/index.md @@ -0,0 +1,27 @@ +--- +layout: home + +hero: + name: Stack + text: 아키텍처를 소스로. + tagline: 작은 의미 기반 문서를 작성하면 좌표나 박스별 스타일을 지정하지 않아도 일관되고 접근 가능한 아키텍처 다이어그램을 만들 수 있습니다. + image: + light: /favicon.svg + dark: /favicon.svg + alt: Stack 로고 + actions: + - theme: brand + text: 시작하기 + link: /ko/guide/getting-started + - theme: alt + text: Playground 열기 + link: https://stack-diagram.com/ + +features: + - title: 시스템 설명 + details: 노드, 그룹, 관계, 레이아웃 의도를 간결하고 읽기 쉬운 .stack 파일로 유지합니다. + - title: 의미의 이식성 + details: 버전이 있는 언어와 구조화된 진단이 아키텍처 의미를 렌더러 선택과 분리합니다. + - title: 안전한 렌더링 + details: 엔진은 스크립트, 임의 HTML, 네트워크 에셋이 없는 독립형 SVG를 생성합니다. +--- diff --git a/generated/site/ko/language/edges-and-layout.md b/generated/site/ko/language/edges-and-layout.md new file mode 100644 index 0000000..e32e28e --- /dev/null +++ b/generated/site/ko/language/edges-and-layout.md @@ -0,0 +1,78 @@ +# 엣지와 레이아웃 + +엣지는 노드 사이의 관계를 설명합니다. 레이아웃 블록은 좌표나 드로잉 원시 요소를 노출하지 않고 소량의 배치 의도를 표현합니다. + +## 엣지 방향 + +엣지는 서로 다른 두 노드를 연결합니다. 전방 참조는 유효하지만 self-edge와 그룹 endpoint는 유효하지 않습니다. + +| 연산자 | 의미 | +| ------ | ------------------------------------------- | +| `->` | 왼쪽 노드에서 오른쪽 노드로 향하는 관계 | +| `<->` | 양방향 대칭인 하나의 관계 | +| `--` | 방향이 없거나 의도적으로 지정하지 않은 연관 | + +`<->`는 독립적으로 라벨을 붙일 수 있는 두 엣지의 축약형이 아닙니다. + +## 엣지 종류와 라벨 + +선택적 라벨은 프로토콜, 이벤트, 명령, 데이터셋, 목적을 나타내며 1~40 Unicode scalar입니다. 선택적 `kind`는 라벨과 별개로 관계를 설명하고 기본값은 `flow`입니다. + +| Kind | 의도한 의미 | +| ------------ | --------------------------------- | +| `flow` | 일반 runtime 또는 conceptual flow | +| `request` | 동기 요청 또는 호출 | +| `event` | 비동기 메시지 또는 이벤트 전달 | +| `data` | 데이터 이동, 복제, 읽기, 쓰기 | +| `dependency` | 빌드, 배포, 운영 의존성 | + +```stack +stack 1.0 + +diagram "Relationships" { + node web "Web app" { + kind client + } + + node api "API" + node queue "Events" { + kind queue + } + + edge web -> api "HTTPS" { + kind request + } + + edge api -> queue "OrderPlaced" { + kind event + } +} +``` + +서로 다른 관계를 표현한다면 같은 노드 쌍에 여러 엣지를 둘 수 있습니다. endpoint, 연산자, 라벨, 유효 kind가 모두 같은 정확한 중복은 유효하지 않습니다. `<->`와 `--` 중복 비교에서는 endpoint 순서를 무시합니다. + +## 레이아웃 스코프 + +다이어그램이나 그룹에는 하나의 `layout` 블록을 둘 수 있습니다. 그룹 블록은 직접 자식만, 다이어그램 블록은 다이어그램의 직접 자식만 영향을 줍니다. `rank`와 `order` 참조는 같은 스코프의 서로 다른 직접 자식을 최소 두 개 지정해야 합니다. + +레이아웃에서 직접 자식 그룹은 하나의 항목입니다. 서로 다른 그룹의 하위 노드 연결은 직접 자식 항목 사이 연결이 되므로 그룹이 엣지 endpoint가 아니어도 상위 레이아웃으로 그룹을 배치할 수 있습니다. + +## Direction, rank, order + +```stack +layout { + direction right + rank same [web, worker] + order [web, worker, database] +} +``` + +- `direction right`는 왼쪽에서 오른쪽, `direction down`은 위에서 아래 진행을 선호합니다. 강한 힌트지만 모든 엣지의 기하 방향을 보장하지 않으며 중첩 그룹에 상속되지 않습니다. +- `rank same [a, b]`는 나열된 직접 자식을 같은 레이아웃 rank에 두는 제약입니다. 한 스코프에서 같은 자식을 두 same-rank 문장에 넣을 수 없습니다. +- `order [a, b]`는 상대 순서 힌트입니다. 오른쪽 방향에서는 위에서 아래, 아래 방향에서는 왼쪽에서 오른쪽, 자동 레이아웃에서는 선택한 cross-axis를 따릅니다. 다른 자식은 생략할 수 있습니다. + +렌더러는 포함, same-rank 제약, 가독성, 출력 경계를 지키기 위해 `order`를 벗어날 수 있습니다. 진단을 지원하는 도구는 이때 `STK4001`을 내야 합니다. + +## 렌더러가 결정하는 것 + +Stack에는 좌표, 크기, 포트, 경로, 색상, 폰트, 줄바꿈, z-index가 없습니다. 렌더러는 겹침을 막고 포함과 방향을 보존하며 라벨을 읽기 쉽게 유지하고 노드 내부를 피해 엣지를 배치하며 의미 내용을 자르지 않고 캔버스를 확장합니다. diff --git a/generated/site/ko/language/formatting.md b/generated/site/ko/language/formatting.md new file mode 100644 index 0000000..68e9d41 --- /dev/null +++ b/generated/site/ko/language/formatting.md @@ -0,0 +1,58 @@ +# 표준 포매팅 + +Stack은 어휘와 문법이 유효한 모든 문서에 하나의 표준 바이트 표현을 정의합니다. 포매팅은 언어 버전, 의미, 모든 줄 주석을 바꾸지 않고 diff를 일관되게 만듭니다. + +## 포맷 가능한 소스 + +포매터는 BOM 없는 UTF-8을 받습니다. 어휘나 문법 오류가 있으면 진단만 반환하고 부분적으로 다시 쓴 소스를 반환하지 않습니다. 문법이 유효하면 의미나 복잡도 진단이 있어도 포맷할 수 있으며, 포맷 성공이 다이어그램 유효성을 뜻하지는 않습니다. + +## 표준 출력 + +표준 소스는 다음을 따릅니다. + +- BOM 없는 UTF-8을 사용합니다. +- 모든 줄바꿈을 LF로 정규화합니다. +- 블록 레벨마다 ASCII 공백 두 칸을 사용하고 포매팅 탭을 쓰지 않습니다. +- 줄 끝에 포매팅 공백이 없습니다. +- 정확히 하나의 LF로 끝납니다. +- 여는 중괄호는 선언 또는 `layout` 줄에, 닫는 중괄호는 별도 줄에 둡니다. +- 버전과 다이어그램, 인접한 body member 사이에 빈 줄 하나를 둡니다. +- 속성과 레이아웃 문장 사이에는 빈 줄을 두지 않습니다. + +```stack +stack 1.0 + +diagram "Title" { + theme dark + + node client "Client" + + node api "API" { + kind service + detail "Public API" + } + + edge client -> api "HTTPS" { + kind request + } + + layout { + direction right + order [client, api] + } +} +``` + +## 순서와 목록 + +포매터는 다이어그램과 그룹 member, 노드와 엣지 속성, 레이아웃 문장, 목록 식별자의 작성 순서를 보존합니다. 그룹화하거나 정렬하지 않습니다. 목록은 한 줄에 두고 쉼표 뒤 공백 하나, 대괄호 안쪽 공백 없음, 마지막 쉼표 없음으로 출력합니다. + +## 문자열 + +유효 문자열을 디코드해 Unicode normalization 없이 UTF-8로 직접 출력합니다. 따옴표와 역슬래시는 이스케이프하고 표준 출력은 `\uXXXX`를 사용하지 않습니다. 예를 들어 `"API \u56F3 \uD83D\uDE80"`는 `"API 図 🚀"`가 됩니다. + +## 주석 + +모든 줄 주석과 순서를 보존합니다. 뒤따르는 주석은 앞 token 뒤에 공백 하나를 두고 유지합니다. 독립 줄 주석은 token gap을 보존하며 뒤따르는 member, 문장, 속성 바로 앞에 둡니다. 구문 내부 주석은 이어지는 줄을 강제할 수 있고 이는 일반적인 한 줄 규칙의 유일한 예외입니다. + +표준 소스를 다시 포맷하면 바이트 단위로 같은 결과가 나와야 합니다. Normalized IR이 존재할 때 포맷 전후 소스는 의미가 같은 IR을 생성해야 합니다. diff --git a/generated/site/ko/language/nodes-and-groups.md b/generated/site/ko/language/nodes-and-groups.md new file mode 100644 index 0000000..a957a82 --- /dev/null +++ b/generated/site/ko/language/nodes-and-groups.md @@ -0,0 +1,67 @@ +# 노드와 그룹 + +노드는 참조 가능한 아키텍처 엔티티이고 그룹은 라벨이 있는 포함 경계입니다. 둘을 사용해 다이어그램에 보이는 컴포넌트와 스코프를 설명합니다. + +## 노드 + +노드에는 전역으로 고유한 식별자와 보이는 라벨이 필요합니다. 식별자는 엣지와 레이아웃 문장에서 참조하지만 렌더링되지 않습니다. 라벨은 1~60 Unicode scalar입니다. + +```stack +stack 1.0 + +diagram "Node example" { + node api "Public API" { + kind service + detail "Order orchestration" + } +} +``` + +서로 다른 엔티티는 같은 보이는 라벨을 사용할 수 있지만 위치에 의존하지 않아도 이해되는 이름을 권장합니다. 노드 블록에서는 `kind`, `icon`, `detail`을 중복할 수 없습니다. + +## 노드 종류 + +`kind`는 큰 범주의 아키텍처 의미를 제공하고 테마가 관리하는 모양과 fallback 아이콘을 선택합니다. 기본값은 `service`입니다. + +| Kind | 의도한 의미 | +| ---------- | ---------------------------------------------------- | +| `actor` | 사람, 역할, 팀, 자율 참여자 | +| `client` | 브라우저, 모바일/데스크톱 앱, 디바이스 등 클라이언트 | +| `service` | 장기 실행 앱, API, 게이트웨이, 일반 컴포넌트 | +| `function` | 온디맨드 또는 serverless 컴퓨팅 단위 | +| `worker` | 백그라운드 프로세서나 예약 작업 | +| `database` | 지속적이고 조회 가능한 데이터 저장소 | +| `cache` | 내용을 폐기하거나 재생성할 수 있는 데이터 저장소 | +| `queue` | 비동기 전달용 큐, 스트림, 버스, broker | +| `storage` | Blob, object, file, archive storage | +| `external` | 아키텍처 제어 경계 밖의 시스템 | + +Kind는 벤더별 모양이 아닌 의미 범주입니다. 호스팅된 PostgreSQL도 `database`이며 기술 이름은 `detail`에 작성합니다. + +## 라벨과 상세 + +`detail`은 선택적인 두 번째 표시 줄이며 1~80 Unicode scalar입니다. `"Next.js"`, `"PostgreSQL 17"`, `"Order orchestration"`처럼 한 기술이나 짧은 책임을 적습니다. 모든 렌더링에서 보이며 tooltip만으로 축소할 수 없습니다. + +라벨과 상세는 일반 텍스트입니다. 명시적 `icon`은 노드를 꾸미지만 kind, identity, 접근성 라벨을 바꾸지 않습니다. [테마와 아이콘](./themes-and-icons)도 참고하세요. + +## 그룹 + +그룹에는 전역으로 고유한 식별자, 1~60 Unicode scalar 라벨, 최소 하나의 하위 노드가 필요합니다. 노드, 중첩 그룹, 하나의 레이아웃 블록을 포함할 수 있습니다. + +```stack +stack 1.0 + +diagram "Boundaries" { + group platform "Platform" { + group data "Data layer" { + node primary "Primary database" { + kind database + } + } + } +} +``` + +그룹은 다이어그램 아래 최대 세 레벨까지 중첩할 수 있습니다. 노드는 가장 가까운 그룹과 모든 상위 그룹에 속합니다. 선언을 재사용할 수 없으므로 한 노드가 두 독립 그룹에 동시에 속할 수 없습니다. + +엣지는 항상 다이어그램 스코프에서 선언하며 노드만 endpoint가 될 수 있습니다. 그룹은 암시적 노드나 관계를 만들지 않습니다. 라벨로 시스템, 도메인, 네트워크, 배포 영역, 팀 같은 경계의 의미를 설명합니다. 포함만으로 runtime isolation, security, ownership, deployment semantics를 의미하지 않습니다. diff --git a/generated/site/ko/language/syntax.md b/generated/site/ko/language/syntax.md new file mode 100644 index 0000000..c952a72 --- /dev/null +++ b/generated/site/ko/language/syntax.md @@ -0,0 +1,95 @@ +# 문서와 문법 + +Stack 소스는 의도적으로 작게 설계되었습니다. 이 페이지는 draft Stack 1.0의 전체 어휘 구조와 문법을 설명합니다. + +## 문서 구조 + +문서는 BOM이 없는 UTF-8 `.stack` 파일 하나입니다. LF와 CRLF는 같은 의미입니다. 첫 non-comment token은 버전 지시문이어야 하며, 그 뒤에는 정확히 하나의 다이어그램만 있고 추가 선언은 올 수 없습니다. + +```stack +// One file, one diagram. +stack 1.0 + +diagram "Example" { + node api "API" +} +``` + +다이어그램 제목은 필수이며 1~80 Unicode scalar입니다. 시작과 끝에 Unicode 공백을 둘 수 없습니다. 다이어그램에는 노드가 적어도 하나 필요합니다. + +## 주석과 공백 + +공백, 탭, 줄바꿈은 token을 구분하지만 그 밖의 의미는 없습니다. 줄 주석은 `//`에서 줄 끝까지이며 공백이 허용되는 곳에 쓸 수 있습니다. 블록 주석은 지원하지 않습니다. + +포맷 자체는 의미가 없지만 표준 포매터는 [표준 포매팅](./formatting)에 정의된 일관된 표현을 생성합니다. + +## 식별자 + +노드, 그룹, 테마, 참조 식별자는 다음과 일치합니다. + +```text +[a-z][a-z0-9_-]* +``` + +1~64 ASCII 문자이며 대소문자를 구분하고 화면에 표시되지 않습니다. 노드와 그룹은 하나의 전역 namespace를 공유합니다. 키워드는 문맥적이므로 식별자 위치에도 쓸 수 있지만 읽기 어려운 이름은 피하세요. + +아이콘 식별자는 인용 문자열이며 디코드된 값이 `[a-z0-9][a-z0-9-]*`와 일치하는 1~64 ASCII 문자입니다. 유효 테마 안에서 해결됩니다. + +## 문자열 + +문자열은 큰따옴표를 사용하고 Unicode를 직접 포함할 수 있습니다. 이스케이프는 세 종류뿐입니다. + +| 이스케이프 | 의미 | +| ---------- | ----------------- | +| `\"` | 큰따옴표 | +| `\\` | 역슬래시 | +| `\uXXXX` | Unicode code unit | + +디코드된 문자열에는 줄바꿈, 탭, 제어 문자, 짝이 없는 surrogate를 넣을 수 없습니다. 제목, 라벨, 상세의 시작과 끝에는 Unicode 공백을 둘 수 없습니다. 문자열은 항상 일반 텍스트이며 Markdown이나 HTML로 해석되지 않습니다. + +## 전체 문법 + +```text +document = version-directive, diagram-declaration, EOF ; +version-directive = "stack", integer, ".", integer ; +diagram-declaration + = "diagram", string, "{", { diagram-member }, "}" ; +diagram-member = node-declaration | group-declaration | edge-declaration + | theme-statement | layout-block ; +theme-statement = "theme", identifier ; +group-declaration = "group", identifier, string, "{", { group-member }, "}" ; +group-member = node-declaration | group-declaration | layout-block ; +node-declaration = "node", identifier, string, [ node-block ] ; +node-block = "{", node-property, { node-property }, "}" ; +node-property = "kind", node-kind | "icon", string | "detail", string ; +node-kind = "actor" | "client" | "service" | "function" | "worker" + | "database" | "cache" | "queue" | "storage" | "external" ; +edge-declaration = "edge", identifier, edge-operator, identifier, + [ string ], [ edge-block ] ; +edge-operator = "->" | "<->" | "--" ; +edge-block = "{", edge-property, { edge-property }, "}" ; +edge-property = "kind", edge-kind ; +edge-kind = "flow" | "request" | "event" | "data" | "dependency" ; +layout-block = "layout", "{", layout-statement, + { layout-statement }, "}" ; +layout-statement = direction-statement | rank-statement | order-statement ; +direction-statement + = "direction", ( "right" | "down" ) ; +rank-statement = "rank", "same", identifier-list ; +order-statement = "order", identifier-list ; +identifier-list = "[", identifier, ",", identifier, + { ",", identifier }, "]" ; +integer = "0" | nonzero-digit, { digit } ; +``` + +## 문맥적 키워드 + +Stack 1.0은 문법 위치에 따라 다음 단어를 인식합니다. + +```text +stack diagram group node edge theme layout kind icon detail direction +rank same order right down actor client service function worker +database cache queue storage external flow request event data dependency +``` + +알 수 없는 선언, 속성, enum 값, 연산자는 오류입니다. 도구는 작성자의 의미를 잃은 채 그럴듯한 다이어그램을 만들 수 있는 문법을 조용히 무시하지 않습니다. diff --git a/generated/site/ko/language/themes-and-icons.md b/generated/site/ko/language/themes-and-icons.md new file mode 100644 index 0000000..7ec9657 --- /dev/null +++ b/generated/site/ko/language/themes-and-icons.md @@ -0,0 +1,126 @@ +# 테마와 아이콘 + +테마는 다이어그램 레벨에서 렌더러가 관리하는 시각 시스템의 기호 참조입니다. 아이콘은 해당 테마 안에서 해결되는 논리 이름입니다. 둘 다 다이어그램 의미를 바꾸지 않습니다. + +## 테마 선택 + +다이어그램 바로 안에 `theme` 문장을 최대 하나 추가합니다. + +```stack +stack 1.0 + +diagram "Dark architecture" { + theme dark + + node api "API" +} +``` + +생략하면 `default`를 사용합니다. Draft Stack 1.0은 코어 catalog에 다음 테마를 요구합니다. + +| Theme | 용도 | +| --------- | ----------------------------------------------------------- | +| `default` | 일반 아키텍처 다이어그램을 위한 균형 잡힌 blue-gray surface | +| `light` | 밝은 문서를 위한 따뜻한 중립 surface | +| `dark` | 어두운 캔버스를 위한 고대비 차가운 surface | + +소스는 식별자만 선택하며 catalog package 버전을 고르지 않습니다. 렌더 metadata는 사용한 시각 데이터를 식별하도록 catalog 버전과 content revision을 기록합니다. + +생성 다이어그램 테마는 Playground의 라이트/다크 UI와 독립적입니다. 테마는 palette, typography metric, surface, icon, connector, background를 바꿀 수 있지만 노드, 그룹, 엣지, 라벨, kind, 방향, 레이아웃 제약을 숨기거나 바꿀 수 없습니다. + +## Fallback 동작 + +세 코어 테마는 렌더러 필수 리소스입니다. 설치된 catalog에 없는 non-core 테마는 `STK6001` 경고 후 `default`로 렌더링합니다. 소스에 테마 식별자가 있다고 네트워크에서 테마를 가져오지 않습니다. + +테마 식별자는 일반 Stack 식별자 문법을 사용합니다. 한 번 등록된 식별자는 폐기된 뒤에도 다른 테마에 재할당할 수 없습니다. + +## Kind fallback 아이콘 + +각 테마는 모든 노드 kind에 fallback을 제공합니다. `icon`을 생략하면 렌더러가 이를 사용합니다. + +| Node kind | 현재 논리 fallback 아이콘 | +| ---------- | ------------------------- | +| `actor` | `kind-actor` | +| `client` | `kind-client` | +| `service` | `kind-service` | +| `function` | `kind-function` | +| `worker` | `kind-worker` | +| `database` | `kind-database` | +| `cache` | `kind-cache` | +| `queue` | `kind-queue` | +| `storage` | `kind-storage` | +| `external` | `kind-external` | + +현재 공개 코어 catalog는 `default`, `light`, `dark`에 이 열 개 식별자를 포함하지만 `postgresql`, `aws`, `github` 같은 벤더 아이콘은 아직 없습니다. 대부분의 문서는 의미에 맞는 `kind`를 선택하고 `icon`을 생략하세요. + +## 명시적 아이콘 + +명시적 아이콘은 인용된 논리 식별자입니다. + +```stack +stack 1.0 + +diagram "Explicit icon" { + node gateway "Public API" { + kind service + icon "api" + } +} +``` + +아이콘은 노드를 꾸밀 뿐 `service` kind, identity, label, 접근성 설명을 바꾸지 않습니다. 테마마다 색상과 그림은 달라질 수 있지만 같은 식별자는 같은 논리 대상을 나타냅니다. + +## First-party 아이콘 catalog + +무료 코어 catalog는 `default`, `light`, `dark`에 다음 provider-neutral 명시적 아이콘을 제공합니다. + +| ID | Stable subject | 주요 용도 | +| --------------- | --------------------------------- | -------------------------------- | +| `api` | Application programming interface | 공개 또는 내부 API | +| `web` | Web application | 브라우저용 Web 경험 | +| `mobile` | Mobile application | iOS 또는 Android 클라이언트 | +| `desktop` | Desktop application | 네이티브 데스크톱 클라이언트 | +| `server` | Server host | 가상 머신 또는 물리 호스트 | +| `container` | Application container | 컨테이너화된 워크로드 | +| `cluster` | Compute cluster | 오케스트레이션된 컴퓨팅 그룹 | +| `cloud` | Cloud environment | provider-neutral 클라우드 경계 | +| `scheduler` | Scheduled execution | Cron 작업 또는 예약 실행 | +| `webhook` | Webhook endpoint | 인바운드 또는 아웃바운드 콜백 | +| `identity` | Identity and access | 인증 또는 권한 부여 | +| `observability` | Observability system | 메트릭, 로그 또는 트레이스 | +| `gateway` | Network gateway | 공용 또는 사설 네트워크 진입점 | +| `load-balancer` | Load balancer | 트래픽 분산 | +| `dns` | Domain name service | 호스트 이름 및 서비스 검색 | +| `cdn` | Content delivery network | 엣지 콘텐츠 전송 | +| `firewall` | Network firewall | 네트워크 접근 경계 | +| `network` | Network topology | 일반 네트워크 또는 서브넷 | +| `event` | Discrete event | 개별 도메인 또는 시스템 이벤트 | +| `stream` | Event stream | 지속적인 이벤트 또는 데이터 흐름 | +| `search` | Search service | 인덱싱 및 쿼리 시스템 | +| `analytics` | Analytics system | 보고 또는 데이터 분석 | +| `repository` | Source code repository | 소스 코드 및 버전 관리 | +| `pipeline` | Delivery pipeline | 빌드, 테스트 또는 배포 흐름 | +| `secret` | Secret or credential | 비밀, 키 또는 자격 증명 | +| `document` | Document or knowledge base | 문서 및 지식 기반 | +| `task` | Task or issue tracker | 작업, 티켓 또는 이슈 추적 | +| `chat` | Chat or messaging tool | 팀 채팅 또는 메시징 | +| `email` | Email delivery | 이메일 전송 또는 받은편지함 | +| `ai` | Artificial intelligence system | AI 모델 또는 추론 서비스 | + +아래 미리보기를 라이트와 다크로 전환하여 실제 출력을 비교할 수 있습니다. 각 이미지는 공개된 `@stack-sh/engine@0.7.0`이 로컬에서 렌더링하며 문서에 Theme SVG 에셋을 복제하지 않습니다. 문법 행을 선택하면 복사됩니다. + + + +의미를 나타내는 `kind`와 명시적 아이콘은 독립적으로 선택합니다. 예를 들어 `icon "web"`은 `client` 또는 `service` 노드를 꾸밀 수 있지만 노드의 의미를 바꾸지 않습니다. + +## 누락 아이콘과 벤더 아이콘 + +코어 catalog에는 현재 `postgresql`, `aws`, `github`, `docker` 같은 벤더 또는 프로젝트 마크가 없습니다. 유효 테마가 작성한 아이콘 식별자를 제공하지 않으면 노드 kind fallback으로 계속 렌더링하고 `STK5001` 경고를 냅니다. + +위 표의 provider-neutral 아이콘을 사용하거나 kind fallback만으로 역할이 명확하면 `icon`을 생략하세요. 벤더 마크는 에셋별 license, 재배포 및 trademark review를 완료해야 별도 catalog에 포함할 수 있습니다. + +## Catalog와 에셋 안전성 + +공개 `stack-sh/theme` catalog가 palette, 결정적 폰트 metric, node-kind visual, connector, icon metadata, SVG bytes, provenance, 재배포 권한을 소유합니다. Catalog 에셋은 렌더러에 번들되며 작성한 식별자는 파일 경로나 URL로 취급하지 않습니다. + +SVG 검증은 script, event handler, nested SVG, unsafe reference, data/network URL, style attribute, allowlist 밖의 요소와 속성을 거부합니다. 아이콘만 의미의 유일한 단서가 될 수 없으며 라벨과 비색상 구분을 유지해야 합니다. diff --git a/generated/site/ko/reference/diagnostics-and-limits.md b/generated/site/ko/reference/diagnostics-and-limits.md new file mode 100644 index 0000000..bc58def --- /dev/null +++ b/generated/site/ko/reference/diagnostics-and-limits.md @@ -0,0 +1,58 @@ +# 진단과 제한 + +Stack 진단은 콘솔 문장이 아닌 구조화된 결과입니다. 안정적인 코드, `error` 또는 `warning` 심각도, 1부터 시작하는 end-exclusive 소스 범위, 간결한 메시지, 정렬된 `expected` 목록을 가집니다. 유용할 때 수정 도움말과 관련 소스 범위도 포함합니다. + +## 처리와 심각도 + +도구는 인코딩과 token, 문법, 식별자와 기본값, 의미 제한, 테마와 아이콘, 레이아웃, 렌더링 순서로 처리합니다. 앞 네 단계의 오류는 렌더링을 막습니다. 테마, 아이콘, 밀도, 레이아웃 힌트 경고는 fallback SVG와 함께 반환될 수 있습니다. + +Playground는 소스 편집 후 오래된 진단을 지웁니다. 결과를 선택하면 primary source에 포커스하고 관련 정보에서 이전 선언으로 이동할 수 있습니다. + +## 복잡도 제한 + +| 항목 | Draft Stack 1.0 제한 | +| ------------------------- | ---------------------------------: | +| 문서당 다이어그램 | 1 | +| 노드 | 1~40 | +| 그룹 | 0~12 | +| 다이어그램 아래 그룹 중첩 | 3레벨 | +| 엣지 | 0~80 또는 노드 수 두 배 중 작은 값 | +| 경고 전 노드 degree | 12개의 incident edge 선언 | + +하드 제한 초과는 `STK4003`입니다. 권장 degree를 넘은 노드는 유효하지만 `STK4002`가 발생합니다. 큰 시스템은 하나에 압축하지 말고 집중된 여러 다이어그램으로 나누세요. + +## 이식 가능한 진단 코드 + +| Code | Severity | 의미 | +| --------- | -------- | ------------------------------------------------ | +| `STK1001` | Error | 입력이 유효한 UTF-8이 아님 | +| `STK1002` | Error | Byte order mark가 있음 | +| `STK1003` | Error | 문자열 이스케이프나 디코드 값이 유효하지 않음 | +| `STK2001` | Error | 선언한 언어 버전을 지원하지 않음 | +| `STK2002` | Error | 예상하지 못한 token, 선언, 속성, 값, 연산자 | +| `STK2003` | Error | 현재 구문이 끝나기 전에 입력이 종료됨 | +| `STK3001` | Error | 식별자가 유효하지 않음 | +| `STK3002` | Error | 식별자가 중복 선언됨 | +| `STK3003` | Error | 엣지가 알 수 없는 노드를 참조함 | +| `STK3004` | Error | 그룹을 엣지 endpoint로 사용함 | +| `STK3005` | Error | 엣지가 노드 자신을 연결함 | +| `STK3006` | Error | 정확히 중복된 엣지를 선언함 | +| `STK3007` | Error | 한 block에서 속성이 중복됨 | +| `STK3008` | Error | 제목, 라벨, 상세가 텍스트 제약을 위반함 | +| `STK3009` | Error | 그룹에 하위 노드가 없음 | +| `STK3010` | Error | 그룹 중첩이 언어 제한을 넘음 | +| `STK3011` | Error | 레이아웃 참조가 스코프에서 유효하지 않음 | +| `STK3012` | Error | 레이아웃 블록 또는 singleton 문장이 중복됨 | +| `STK3013` | Error | 아이콘 식별자 형식이 잘못됨 | +| `STK3014` | Error | 다이어그램에 여러 테마 문장이 있음 | +| `STK4001` | Warning | 순서 힌트를 만족할 수 없음 | +| `STK4002` | Warning | 노드가 권장 incident-edge degree를 넘음 | +| `STK4003` | Error | 다이어그램이 언어 복잡도 제한을 넘음 | +| `STK5001` | Warning | 유효 테마에 아이콘이 없어 kind fallback을 사용함 | +| `STK6001` | Warning | 요청한 non-core 테마가 없어 `default`를 사용함 | + +코드 family에서 `STK1000`은 인코딩/어휘, `STK2000`은 문법, `STK3000`은 이름/의미, `STK4000`은 레이아웃/복잡도, `STK5000`은 아이콘, `STK6000`은 테마입니다. `STK9000`은 소스 실수가 아닌 구현 실패용입니다. 구현은 자체 non-`STK` prefix로만 진단을 추가할 수 있습니다. + +## 복구 규칙 + +파서는 여러 독립 오류를 보고하기 위해 복구할 수 있지만 부분 다이어그램을 유효한 것으로 렌더링할 수 없습니다. 알 수 없는 선언, 속성, enum 값, 연산자는 무시되지 않습니다. 의미를 잃은 채 성공처럼 보이는 출력을 막습니다. diff --git a/generated/site/ko/reference/versioning-and-safety.md b/generated/site/ko/reference/versioning-and-safety.md new file mode 100644 index 0000000..66e1fdb --- /dev/null +++ b/generated/site/ko/reference/versioning-and-safety.md @@ -0,0 +1,40 @@ +# 버전과 안전성 + +Draft Stack 1.0은 소스 언어, 구현, 테마 catalog, package 버전을 분리합니다. 이 경계를 이해하면 문서를 이식 가능하게 하고 렌더 결과의 출처를 추적할 수 있습니다. + +## 언어 버전 + +모든 문서는 `major.minor` 지시문으로 시작합니다. + +```stack +stack 1.0 + +diagram "Versioned source" { + node api "API" +} +``` + +이 값은 문서가 요구하는 최소 언어 문법과 의미이며 엔진이나 테마 버전이 아닙니다. `M.N`을 지원하는 렌더러는 같은 major에서 minor가 `N` 이하인 문서를 받고, 다른 major나 명시적으로 지원하지 않는 더 높은 minor를 거부합니다. 미래 문법의 의미를 추측하지 않습니다. + +Specification release는 semantic versioning을 사용합니다. Major는 호환되지 않는 언어 변경, minor는 하위 호환 기능 추가, patch는 유효 소스 의미를 바꾸지 않는 설명과 오류 수정입니다. 그래서 문서 지시문은 patch를 생략합니다. + +## 렌더러와 catalog 식별 + +일반 엔진 결과에는 엔진 버전, 작성한 언어 버전, 테마 catalog 버전, catalog content revision이 포함됩니다. 소스 `theme`은 기호 식별자만 선택하며 package release를 pin하거나 원격 데이터를 가져오지 않습니다. + +정확한 픽셀 출력은 언어 호환성 약속이 아닙니다. 테마 metric, 렌더러 버전, 폰트, 캔버스 결정이 위치를 바꿀 수 있지만 노드, 그룹, 관계, 라벨, kind, 제약은 보존해야 합니다. + +## 안전한 소스 경계 + +Stack 문자열은 일반 텍스트입니다. 소스에는 실행 코드, 임의 HTML/Markdown, CSS, SVG, import, macro, 파일 경로, 네트워크 URL을 넣을 수 없습니다. 엔진은 작성한 텍스트를 escape하고 검증된 catalog 아이콘, local marker reference, 접근 가능한 title/description metadata가 포함된 독립형 SVG를 만듭니다. + +렌더된 SVG에는 script, event handler, 임의 external reference, host font measurement, runtime I/O가 없습니다. 없는 아이콘과 테마 이름은 경로나 registry를 찾는 대신 번들 fallback을 선택합니다. + +## 현재 제공 상태 + +- 브라우저 Playground가 지원되는 공개 경험입니다. +- 공개 `@stack-sh/engine`은 Playground가 사용하는 typed WebAssembly `format`, `check`, `render`를 제공합니다. +- 공개 `@stack-sh/language`는 에디터 하이라이트용 공유 TextMate grammar와 언어 metadata를 제공합니다. +- 공개 [`stack-sh/cli`](https://github.com/stack-sh/cli)는 native `format`, `check`, `render` 및 provider-icon store 작업을 제공합니다. + +표준 언어 계약은 [`stack-sh/specification`](https://github.com/stack-sh/specification), 공개 테마 catalog는 [`stack-sh/theme`](https://github.com/stack-sh/theme), 엔진 동작은 [`stack-sh/engine`](https://github.com/stack-sh/engine)이 소유합니다. diff --git a/generated/site/language/edges-and-layout.md b/generated/site/language/edges-and-layout.md new file mode 100644 index 0000000..32034df --- /dev/null +++ b/generated/site/language/edges-and-layout.md @@ -0,0 +1,78 @@ +# Edges and layout + +Edges describe relationships between nodes. Layout blocks express a small amount of placement intent without exposing coordinates or drawing primitives. + +## Edge direction + +An edge connects two distinct nodes. Forward references are valid, while self-edges and group endpoints are invalid. + +| Operator | Meaning | +| -------- | -------------------------------------------------------------- | +| `->` | Directed relationship from the left node to the right node | +| `<->` | One symmetric relationship in both directions | +| `--` | Association with absent or intentionally unspecified direction | + +`<->` is one relationship, not shorthand for two independently labeled edges. + +## Edge kinds and labels + +An optional label names a protocol, event, command, dataset, or purpose and contains 1 to 40 Unicode scalar values. An optional `kind` describes the relationship independently of that label. The default is `flow`. + +| Kind | Intended meaning | +| ------------ | ------------------------------------------------------ | +| `flow` | Generic runtime or conceptual flow | +| `request` | Synchronous request or call | +| `event` | Asynchronous message or event delivery | +| `data` | Data movement, replication, reads, or writes | +| `dependency` | Build-time, deployment-time, or operational dependency | + +```stack +stack 1.0 + +diagram "Relationships" { + node web "Web app" { + kind client + } + + node api "API" + node queue "Events" { + kind queue + } + + edge web -> api "HTTPS" { + kind request + } + + edge api -> queue "OrderPlaced" { + kind event + } +} +``` + +Multiple edges between the same nodes are valid when they express distinct relationships. An exact duplicate with the same endpoints, operator, label, and effective kind is invalid. Endpoint order is ignored when comparing `<->` and `--` duplicates. + +## Layout scope + +A diagram or group may contain one `layout` block. A group block affects only its direct child nodes and groups. A diagram block affects only direct children of the diagram. `rank` and `order` references must name at least two distinct direct children in that scope. + +For layout, a direct child group acts as one item. Connections between descendant nodes induce connections between their containing direct-child items, so a top-level layout can arrange groups even though groups are not edge endpoints. + +## Direction, rank, and order + +```stack +layout { + direction right + rank same [web, worker] + order [web, worker, database] +} +``` + +- `direction right` prefers left-to-right progression; `direction down` prefers top-to-bottom progression. It is a strong hint, not a promise that every edge points geometrically that way. Nested groups do not inherit it. +- `rank same [a, b]` is a constraint: listed direct children must share a layout rank. A child cannot appear in two same-rank statements in one scope. +- `order [a, b]` is a relative-order hint. It is top-to-bottom for a right-directed scope, left-to-right for a down-directed scope, and follows the chosen cross-axis in automatic layout. Other children may be omitted. + +The renderer may depart from `order` to preserve containment, same-rank constraints, legibility, or output bounds. Diagnostic-capable tools should emit `STK4001` when an authored order cannot be satisfied. + +## Renderer-owned decisions + +Stack exposes no coordinates, dimensions, ports, paths, colors, fonts, line breaks, or z-index. The renderer prevents overlaps, preserves containment and direction, keeps labels legible, routes edges outside node interiors, and expands the canvas rather than clipping semantic content. diff --git a/generated/site/language/formatting.md b/generated/site/language/formatting.md new file mode 100644 index 0000000..73b62ff --- /dev/null +++ b/generated/site/language/formatting.md @@ -0,0 +1,58 @@ +# Canonical formatting + +Stack defines one canonical byte representation for every lexically and syntactically valid document. Formatting keeps diffs consistent without changing the declared language version, semantic meaning, or line comments. + +## What formatting accepts + +The formatter accepts UTF-8 without a byte order mark. Lexical or syntax errors return diagnostics and no partial formatted source. A syntactically valid document remains formattable when it has semantic or complexity diagnostics; formatting success does not mean the diagram is valid. + +## Canonical output + +Canonical source: + +- uses UTF-8 without a byte order mark; +- normalizes every line ending to LF; +- uses two ASCII spaces for each block level and never formatting tabs; +- has no formatting whitespace at line ends; +- ends with exactly one LF; +- puts the opening brace on the declaration or `layout` line and closing braces on their own lines; +- separates the version and diagram, and adjacent body members, with one empty line; +- keeps properties and layout statements together without empty lines. + +```stack +stack 1.0 + +diagram "Title" { + theme dark + + node client "Client" + + node api "API" { + kind service + detail "Public API" + } + + edge client -> api "HTTPS" { + kind request + } + + layout { + direction right + order [client, api] + } +} +``` + +## Order and lists + +The formatter preserves the authored order of diagram and group members, node and edge properties, layout statements, and list identifiers. It never groups or sorts them. Lists stay on one line with a comma and one space, no spaces just inside brackets, and no trailing comma. + +## Strings + +Valid strings are decoded and emitted directly as UTF-8 without Unicode normalization. Quotes and backslashes remain escaped; canonical output does not use `\uXXXX`. For example, a source spelling of `"API \u56F3 \uD83D\uDE80"` becomes `"API 図 🚀"`. + +## Comments + +Every line comment and its order are preserved. A trailing comment stays after its preceding token with one space. Own-line comments keep their token gap and appear immediately before the following member, statement, or property. A comment inside a construct can force a continuation line; this is the only exception to the usual one-line rules. + +Formatting canonical source again must produce byte-identical output. When normalized IR exists, source before and after formatting must produce semantically equal IR. diff --git a/generated/site/language/nodes-and-groups.md b/generated/site/language/nodes-and-groups.md new file mode 100644 index 0000000..9f94e33 --- /dev/null +++ b/generated/site/language/nodes-and-groups.md @@ -0,0 +1,67 @@ +# Nodes and groups + +Nodes are addressable architectural entities. Groups are labeled containment boundaries. Together they describe the components and scopes visible in a diagram. + +## Nodes + +A node requires a globally unique identifier and a visible label. The identifier is used by edges and layout statements but is never rendered. A label contains 1 to 60 Unicode scalar values. + +```stack +stack 1.0 + +diagram "Node example" { + node api "Public API" { + kind service + detail "Order orchestration" + } +} +``` + +Two nodes may share a visible label when they are distinct entities, though labels should remain understandable without relying on position. A node block cannot repeat `kind`, `icon`, or `detail`. + +## Node kinds + +`kind` provides coarse architectural meaning. It also selects a theme-controlled shape and fallback icon. The default is `service`. + +| Kind | Intended meaning | +| ---------- | ------------------------------------------------------------ | +| `actor` | Person, role, team, or autonomous participant | +| `client` | Browser, mobile app, desktop app, device, or other client | +| `service` | Long-running application, API, gateway, or general component | +| `function` | On-demand or serverless compute unit | +| `worker` | Background processor or scheduled job | +| `database` | Durable, queryable datastore | +| `cache` | Datastore whose contents are disposable or derived | +| `queue` | Queue, stream, bus, or broker for asynchronous delivery | +| `storage` | Blob, object, file, or archival storage | +| `external` | System outside the architecture's control boundary | + +Kinds are semantic categories, not vendor shapes. A hosted PostgreSQL instance is still a `database`; name the technology in `detail`. + +## Labels and details + +`detail` is an optional visible second line of 1 to 80 Unicode scalar values. Use it for one technology or a short responsibility, such as `"Next.js"`, `"PostgreSQL 17"`, or `"Order orchestration"`. It remains visible in every rendered diagram and is never reduced to tooltip-only content. + +Labels and details are plain text, not Markdown or HTML. An explicit `icon` decorates the node but does not change its kind, identity, or accessible label. See [Themes and icons](./themes-and-icons). + +## Groups + +A group has a globally unique identifier, a label of 1 to 60 Unicode scalar values, and at least one descendant node. It may contain nodes, nested groups, and one layout block. + +```stack +stack 1.0 + +diagram "Boundaries" { + group platform "Platform" { + group data "Data layer" { + node primary "Primary database" { + kind database + } + } + } +} +``` + +Group nesting can reach three levels below the diagram. A node belongs to its nearest group and all ancestor groups. Because declarations cannot be reused, a node cannot belong to two separate groups. + +Edges are always declared at diagram scope, and only nodes can be edge endpoints. A group does not create an implicit node or relationship. Its label explains whether the boundary represents a system, domain, network, deployment area, team, or another concern; containment alone does not imply runtime isolation, security, ownership, or deployment semantics. diff --git a/generated/site/language/syntax.md b/generated/site/language/syntax.md new file mode 100644 index 0000000..10f7d12 --- /dev/null +++ b/generated/site/language/syntax.md @@ -0,0 +1,95 @@ +# Document and syntax + +Stack source is intentionally small. This page covers the complete lexical structure and grammar for draft Stack 1.0. + +## Document structure + +A document is one UTF-8 `.stack` file with no byte order mark. LF and CRLF line endings have the same meaning. The first non-comment token is a version directive, followed by exactly one diagram and no trailing declarations. + +```stack +// One file, one diagram. +stack 1.0 + +diagram "Example" { + node api "API" +} +``` + +The diagram title is required, contains 1 to 80 Unicode scalar values, and cannot begin or end with Unicode whitespace. A diagram must contain at least one node. + +## Comments and whitespace + +Spaces, tabs, and line endings separate tokens but do not otherwise affect meaning. A line comment starts with `//` and ends at the line ending. Comments are allowed wherever whitespace is allowed. Block comments are not supported. + +Formatting is not semantic, but the canonical formatter emits a consistent representation described in [Canonical formatting](./formatting). + +## Identifiers + +Node, group, theme, and reference identifiers match: + +```text +[a-z][a-z0-9_-]* +``` + +They contain 1 to 64 ASCII characters, are case-sensitive, and are not displayed. Nodes and groups share one global namespace. Keywords are contextual and may technically appear where an identifier is expected, but avoid identifiers that make declarations hard to read. + +Icon identifiers are quoted strings whose decoded value matches `[a-z0-9][a-z0-9-]*`, also with 1 to 64 ASCII characters. They are resolved inside the effective theme. + +## Strings + +Strings use double quotes and may contain Unicode directly. Only three escape forms exist: + +| Escape | Meaning | +| -------- | ----------------- | +| `\"` | Double quote | +| `\\` | Backslash | +| `\uXXXX` | Unicode code unit | + +Decoded strings cannot contain line breaks, tabs, control characters, or unpaired surrogates. Titles, labels, and details cannot begin or end with Unicode whitespace. Strings are plain text; Markdown and HTML are never interpreted. + +## Complete grammar + +```text +document = version-directive, diagram-declaration, EOF ; +version-directive = "stack", integer, ".", integer ; +diagram-declaration + = "diagram", string, "{", { diagram-member }, "}" ; +diagram-member = node-declaration | group-declaration | edge-declaration + | theme-statement | layout-block ; +theme-statement = "theme", identifier ; +group-declaration = "group", identifier, string, "{", { group-member }, "}" ; +group-member = node-declaration | group-declaration | layout-block ; +node-declaration = "node", identifier, string, [ node-block ] ; +node-block = "{", node-property, { node-property }, "}" ; +node-property = "kind", node-kind | "icon", string | "detail", string ; +node-kind = "actor" | "client" | "service" | "function" | "worker" + | "database" | "cache" | "queue" | "storage" | "external" ; +edge-declaration = "edge", identifier, edge-operator, identifier, + [ string ], [ edge-block ] ; +edge-operator = "->" | "<->" | "--" ; +edge-block = "{", edge-property, { edge-property }, "}" ; +edge-property = "kind", edge-kind ; +edge-kind = "flow" | "request" | "event" | "data" | "dependency" ; +layout-block = "layout", "{", layout-statement, + { layout-statement }, "}" ; +layout-statement = direction-statement | rank-statement | order-statement ; +direction-statement + = "direction", ( "right" | "down" ) ; +rank-statement = "rank", "same", identifier-list ; +order-statement = "order", identifier-list ; +identifier-list = "[", identifier, ",", identifier, + { ",", identifier }, "]" ; +integer = "0" | nonzero-digit, { digit } ; +``` + +## Contextual keywords + +Stack 1.0 recognizes these words in their grammatical positions: + +```text +stack diagram group node edge theme layout kind icon detail direction +rank same order right down actor client service function worker +database cache queue storage external flow request event data dependency +``` + +Unknown declarations, properties, enum values, and operators are errors. Tools do not silently ignore syntax that could create a plausible but incorrect diagram. diff --git a/generated/site/language/themes-and-icons.md b/generated/site/language/themes-and-icons.md new file mode 100644 index 0000000..c4bb400 --- /dev/null +++ b/generated/site/language/themes-and-icons.md @@ -0,0 +1,126 @@ +# Themes and icons + +A theme is a symbolic, diagram-level reference to a renderer-managed visual system. Icons are logical names resolved inside that theme. Neither feature changes diagram meaning. + +## Select a theme + +Add at most one `theme` statement directly inside the diagram: + +```stack +stack 1.0 + +diagram "Dark architecture" { + theme dark + + node api "API" +} +``` + +If the statement is omitted, Stack uses `default`. Draft Stack 1.0 requires the core catalog to contain: + +| Theme | Intended use | +| --------- | ------------------------------------------------------------- | +| `default` | Balanced blue-gray surfaces for general architecture diagrams | +| `light` | Warm neutral surfaces for light documents | +| `dark` | High-contrast cool surfaces for dark canvases | + +The source selects an identifier, not a catalog package version. Render metadata records the catalog version and content revision so an output can identify the visual data it used. + +The generated diagram theme is independent from the Playground's light or dark interface. A theme may change palette, typography metrics, surfaces, icons, connectors, and background treatment. It cannot hide or change nodes, groups, edges, labels, kinds, direction, or layout constraints. + +## Fallback behavior + +The three core themes are required renderer resources. A requested non-core theme that is unavailable emits warning `STK6001` and renders with `default`. The engine never fetches a theme from the network just because its identifier appears in source. + +Theme identifiers use normal Stack identifier syntax. Once registered, an identifier cannot later name a different theme, even after deprecation. + +## Kind fallback icons + +Every theme provides one fallback for each node kind. If you omit `icon`, this is what the renderer uses. + +| Node kind | Current logical fallback icon | +| ---------- | ----------------------------- | +| `actor` | `kind-actor` | +| `client` | `kind-client` | +| `service` | `kind-service` | +| `function` | `kind-function` | +| `worker` | `kind-worker` | +| `database` | `kind-database` | +| `cache` | `kind-cache` | +| `queue` | `kind-queue` | +| `storage` | `kind-storage` | +| `external` | `kind-external` | + +The current open core catalog contains these ten fallback identifiers in `default`, `light`, and `dark`. It does not yet contain vendor icons such as `postgresql`, `aws`, or `github`. In most documents, choose the semantic `kind` and omit `icon`. + +## Explicit icons + +An explicit icon is a quoted logical identifier: + +```stack +stack 1.0 + +diagram "Explicit icon" { + node gateway "Public API" { + kind service + icon "api" + } +} +``` + +The icon decorates the node; it does not change the `service` kind, identity, label, or accessible description. The same identifier in different themes represents the same logical subject, although its color and artwork may adapt to the theme. + +## First-party icon catalog + +The free core catalog includes these provider-neutral explicit icons in `default`, `light`, and `dark`: + +| ID | Stable subject | Use it for | +| --------------- | --------------------------------- | ---------------------------------- | +| `api` | Application programming interface | Public or internal APIs | +| `web` | Web application | Browser-facing web experiences | +| `mobile` | Mobile application | iOS or Android clients | +| `desktop` | Desktop application | Native desktop clients | +| `server` | Server host | Virtual machines or physical hosts | +| `container` | Application container | Containerized workloads | +| `cluster` | Compute cluster | Orchestrated compute groups | +| `cloud` | Cloud environment | Provider-neutral cloud boundaries | +| `scheduler` | Scheduled execution | Cron jobs or scheduled work | +| `webhook` | Webhook endpoint | Inbound or outbound callbacks | +| `identity` | Identity and access | Authentication or authorization | +| `observability` | Observability system | Metrics, logs, or traces | +| `gateway` | Network gateway | Public or private network entry | +| `load-balancer` | Load balancer | Traffic distribution | +| `dns` | Domain name service | Hostname and service discovery | +| `cdn` | Content delivery network | Edge content delivery | +| `firewall` | Network firewall | Network access boundaries | +| `network` | Network topology | Generic networks or subnets | +| `event` | Discrete event | Individual domain or system events | +| `stream` | Event stream | Continuous event or data flows | +| `search` | Search service | Indexing and query systems | +| `analytics` | Analytics system | Reporting or data analysis | +| `repository` | Source code repository | Source code and version control | +| `pipeline` | Delivery pipeline | Build, test, or deployment flows | +| `secret` | Secret or credential | Secrets, keys, or credentials | +| `document` | Document or knowledge base | Documentation and knowledge | +| `task` | Task or issue tracker | Tasks, tickets, or issue tracking | +| `chat` | Chat or messaging tool | Team chat or messaging | +| `email` | Email delivery | Email delivery or inboxes | +| `ai` | Artificial intelligence system | AI models or inference services | + +Switch the preview below between light and dark to inspect the actual output. The published `@stack-sh/engine@0.7.0` renders every image locally; the Documentation does not copy Theme SVG assets. Select a syntax row to copy it. + + + +Use the semantic `kind` independently from the explicit icon. For example, `icon "web"` may decorate either a `client` or `service` node without changing what that node means. + +## Missing and vendor icons + +The core catalog does not currently include vendor or project marks such as `postgresql`, `aws`, `github`, or `docker`. If the effective theme does not provide an authored icon identifier, rendering continues with the node's kind fallback and warning `STK5001`. + +Prefer a provider-neutral icon above or omit `icon` when its kind fallback already communicates the role. Vendor marks require asset-specific license, redistribution, and trademark review before they can ship in a separate catalog. + +## Catalog and asset safety + +The public `stack-sh/theme` catalog owns palettes, deterministic font metrics, node-kind visuals, connectors, icon metadata, SVG bytes, provenance, and redistribution permissions. Catalog assets are bundled with the renderer; authored identifiers are never treated as file paths or URLs. + +SVG validation rejects scripts, event handlers, nested SVG documents, unsafe references, data or network URLs, style attributes, and elements or attributes outside an allowlist. Icons are not the only accessible indication of meaning: labels and non-color visual distinctions remain required. diff --git a/generated/site/reference/diagnostics-and-limits.md b/generated/site/reference/diagnostics-and-limits.md new file mode 100644 index 0000000..5ffddf7 --- /dev/null +++ b/generated/site/reference/diagnostics-and-limits.md @@ -0,0 +1,58 @@ +# Diagnostics and limits + +Stack diagnostics are structured results, not console prose. They have a stable code, `error` or `warning` severity, a one-based end-exclusive source range, a concise message, and an ordered `expected` list. Corrective help and related source ranges are included when useful. + +## Processing and severity + +Tools process encoding and tokens, grammar, identifiers and defaults, semantic limits, theme and icon resolution, layout, then rendering. Errors in the first four stages prevent rendering. Theme, icon, density, and layout-hint warnings can accompany a fallback SVG. + +The Playground clears stale diagnostics after source edits. Selecting a result focuses its primary source; related information can point back to an earlier declaration. + +## Complexity limits + +| Item | Draft Stack 1.0 limit | +| --------------------------- | ---------------------------------------------: | +| Diagrams per document | 1 | +| Nodes | 1 to 40 | +| Groups | 0 to 12 | +| Group nesting below diagram | 3 levels | +| Edges | 0 to the smaller of 80 or twice the node count | +| Node degree before warning | 12 incident edge declarations | + +Exceeding a hard limit is `STK4003`. A node above the recommended degree remains valid but emits `STK4002`. Split large systems into focused diagrams rather than compressing an exhaustive graph. + +## Portable diagnostic codes + +| Code | Severity | Meaning | +| --------- | -------- | ------------------------------------------------------------------------- | +| `STK1001` | Error | Input is not valid UTF-8 | +| `STK1002` | Error | A byte order mark is present | +| `STK1003` | Error | A string has an invalid escape or decoded value | +| `STK2001` | Error | The declared language version is unsupported | +| `STK2002` | Error | An unexpected token, declaration, property, value, or operator was found | +| `STK2003` | Error | Input ended before the current construct was complete | +| `STK3001` | Error | An identifier is invalid | +| `STK3002` | Error | An identifier is declared more than once | +| `STK3003` | Error | An edge references an unknown node | +| `STK3004` | Error | A group is used as an edge endpoint | +| `STK3005` | Error | An edge connects a node to itself | +| `STK3006` | Error | An exact duplicate edge is declared | +| `STK3007` | Error | A property occurs more than once in one block | +| `STK3008` | Error | A title, label, or detail violates its text constraints | +| `STK3009` | Error | A group has no descendant node | +| `STK3010` | Error | Group nesting exceeds the language limit | +| `STK3011` | Error | A layout reference is invalid in its scope | +| `STK3012` | Error | A layout block or singleton layout statement is duplicated | +| `STK3013` | Error | An icon identifier is malformed | +| `STK3014` | Error | A diagram contains more than one theme statement | +| `STK4001` | Warning | An order hint could not be satisfied | +| `STK4002` | Warning | A node exceeds the recommended incident-edge degree | +| `STK4003` | Error | A diagram exceeds a language complexity limit | +| `STK5001` | Warning | An icon is unavailable in the effective theme; its kind fallback was used | +| `STK6001` | Warning | A requested non-core theme is unavailable; `default` was used | + +Code families reserve `STK1000` for encoding and lexical errors, `STK2000` for syntax, `STK3000` for names and semantics, `STK4000` for layout and complexity, `STK5000` for icons, and `STK6000` for themes. `STK9000` is for implementation failures, never a source mistake. Implementations may add diagnostics only under their own non-`STK` prefix. + +## Recovery rules + +A parser may recover to report independent errors together, but it cannot render a partial diagram as valid. Unknown declarations, properties, enum values, and operators are never ignored. This avoids successful-looking output that silently lost authored meaning. diff --git a/generated/site/reference/versioning-and-safety.md b/generated/site/reference/versioning-and-safety.md new file mode 100644 index 0000000..61f835a --- /dev/null +++ b/generated/site/reference/versioning-and-safety.md @@ -0,0 +1,40 @@ +# Versioning and safety + +Draft Stack 1.0 separates the source language, implementation, theme catalog, and package versions. Understanding that boundary makes documents portable and rendered output reproducible. + +## Language version + +Every document starts with a `major.minor` directive: + +```stack +stack 1.0 + +diagram "Versioned source" { + node api "API" +} +``` + +This is the minimum language grammar and semantics required by the document, not an engine or theme version. A renderer supporting `M.N` accepts the same major with a minor less than or equal to `N`, rejects a different major, and rejects a higher minor unless it explicitly supports it. It never guesses unknown future syntax. + +Specification releases use semantic versioning. A major release may change the language incompatibly; a minor adds backwards-compatible capabilities; a patch clarifies wording or fixes errata without changing valid source meaning. The document omits a patch number for that reason. + +## Renderer and catalog identity + +Normal engine results include the engine version, authored language version, theme catalog version, and catalog content revision. The source `theme` statement selects a symbolic identifier only. It does not pin a package release or fetch remote data. + +Exact pixel output is not a language compatibility promise. Theme metrics, renderer versions, fonts, and canvas decisions may change positions while preserving nodes, groups, relationships, labels, kinds, and constraints. + +## Safe source boundary + +Stack strings are plain text. Source cannot contain executable code, arbitrary HTML or Markdown, CSS, SVG, imports, macros, file paths, or network URLs. The engine escapes authored text and emits standalone SVG with embedded validated catalog icons, local marker references, and accessible title and description metadata. + +Rendered SVG contains no script, event handler, arbitrary external reference, host font measurement, or runtime I/O. Missing icon and theme names select bundled fallbacks rather than resolving paths or contacting a registry. + +## Current delivery status + +- The browser Playground is the supported public experience. +- Public `@stack-sh/engine` provides the typed WebAssembly `format`, `check`, and `render` operations used by the Playground. +- Public `@stack-sh/language` provides the shared TextMate grammar and language metadata used for editor highlighting. +- Public [`stack-sh/cli`](https://github.com/stack-sh/cli) provides native `format`, `check`, `render`, and provider-icon store operations. + +The normative language contract remains in [`stack-sh/specification`](https://github.com/stack-sh/specification). The public theme catalog is in [`stack-sh/theme`](https://github.com/stack-sh/theme), and engine behavior is in [`stack-sh/engine`](https://github.com/stack-sh/engine). diff --git a/generated/site/zh/examples/index.md b/generated/site/zh/examples/index.md new file mode 100644 index 0000000..0dd253c --- /dev/null +++ b/generated/site/zh/examples/index.md @@ -0,0 +1,7 @@ +# 示例库 + +从小型图开始,逐步学习分组、布局约束、云服务商图标和接近生产环境的系统。下面的每个缩略图都由固定到公开 Stack 规范的规范源代码生成。 + +云服务商示例中的图标资源由调用方管理。需要品牌图标时,请安装页面标出的图标包。即使没有图标包,同一份源代码仍然有效,并会使用 Stack 的确定性缺失图标回退进行渲染。 + + diff --git a/generated/site/zh/guide/agent-workflow.md b/generated/site/zh/guide/agent-workflow.md new file mode 100644 index 0000000..666fd28 --- /dev/null +++ b/generated/site/zh/guide/agent-workflow.md @@ -0,0 +1,42 @@ + + +# Stack diagrams + +Deliver editable `.stack` source and, when rendering is available, an SVG. Preserve the requested architecture and existing unrelated content. Stack describes architecture; it does not provision resources or execute application code. + +## Start with the available tools + +Run `stack --version` and `stack help` before selecting commands. Use the installed binary's help, not unreleased repository instructions. The published CLI 0.4.0 supports `check`, `fmt`, and `render`; it does not support their `--json` flags. A newer version may support additional options: verify them using `stack help `. + +If the CLI is missing, consult the [installation guide](https://stack-diagram.com/docs/guide/getting-started.md) and [release distribution contract](https://github.com/stack-sh/cli/blob/v0.4.0/docs/distribution.md). Install only when the user's authorization allows it. Otherwise provide source with an explicit validation gap; do not report it as checked. No remote source upload is required. + +## Read only the relevant reference + +Start with [syntax](https://stack-diagram.com/docs/language/syntax.md), [nodes and groups](https://stack-diagram.com/docs/language/nodes-and-groups.md), and [edges and layout](https://stack-diagram.com/docs/language/edges-and-layout.md) when the grammar is unfamiliar. Find complete examples in the [gallery](https://stack-diagram.com/docs/examples/index.md). The [documentation index](https://stack-diagram.com/docs/llms.txt) links the remaining references. If the client cannot fetch one resource, try its Markdown page or report the missing information rather than inventing syntax. + +Non-obvious constraints: + +- One `stack 1.0` declaration and one named `diagram`; node/group IDs are globally unique. +- Declare edges at diagram scope. Endpoints are node IDs, not labels or groups. +- Model technologies using labels and `detail`; choose semantic `kind` values from the reference. Do not invent properties such as coordinates, colors, or ports. +- Prefer automatic layout or `direction` initially. `order` controls relative cross-axis ordering, not execution sequence; add `rank` or `order` only when the user needs that constraint. References must be direct children of that layout scope. +- Do not guess vendor icon IDs. Consult [provider icons](https://stack-diagram.com/docs/guide/provider-icons.md), query `stack icons list`, and verify the required pack is installed. Import downloads and terms acceptance need appropriate user authorization. If no pack is available, use the semantic kind fallback and explain that branded artwork is absent. + +## Generate, validate, and render + +For a new diagram, start with the smallest complete source that preserves the requested components and relationships. For an edit, inspect the existing source first and retain unrelated nodes, edges, labels, and comments. + +Using the user's actual filenames: + +```sh +stack check architecture.stack +stack fmt architecture.stack +stack check architecture.stack +stack render architecture.stack -o architecture.svg +``` + +`fmt` changes the source in place; avoid unrelated formatting when it would obscure a narrowly requested edit. Rendering to a file may replace it, so honor existing artifact ownership. + +Read both the exit status and diagnostics. An exit code of zero can still carry warnings. Fix unknown references or invalid syntax from the diagnostic ranges; never remove requested architecture merely to make validation pass. Investigate layout warnings without treating an optional visual hint as a required semantic relationship. Missing-icon warnings mean the image rendered with a fallback, not that provider artwork was found. Bound repeated repair attempts and report a remaining blocker rather than silently weakening the task. + +After rendering, inspect the SVG visually when a suitable viewer is available. Compiler success does not prove readable layout. Confirm the requested nodes, boundaries, relationships, and labels remain present. Report the source/SVG paths, CLI version, validation result, and any unresolved warnings or unverified visual behavior. diff --git a/generated/site/zh/guide/coding-agents.md b/generated/site/zh/guide/coding-agents.md new file mode 100644 index 0000000..3b3a264 --- /dev/null +++ b/generated/site/zh/guide/coding-agents.md @@ -0,0 +1,27 @@ +# 使用 coding agent + +使用 coding agent 读写 Stack,可将架构图作为可审查的源文件管理。agent 阅读语言参考并在本地执行 CLI,不需要远程 MCP 服务器。 + +## 安装 skill + +使用 `npx skills add stack-sh/cli` 仅将图表 skill 安装到当前项目。仅在需要用户级安装时添加 `-g`,并检查下载的指令。CLI 需要单独安装。需要可复现安装时,先 clone 仓库并 checkout 已审核的 commit,再运行 `npx skills add /absolute/path/to/cli --skill stack-diagrams`。安装器不能将 commit SHA 直接作为远程分支安装。 + +[SKILL.md](https://github.com/stack-sh/cli/blob/main/skills/stack-diagrams/SKILL.md) + +## 不安装也能使用 + +将以下指令复制给 agent,并补充架构需求。只要客户端可以读取 HTTPS 页面和运行本地命令,即使不支持 skill 也能使用。 + +```text +Use Stack to create or edit the architecture described below. Read https://stack-diagram.com/docs/guide/agent-workflow.md and follow its local validation and safety workflow. Read the relevant language reference and examples as needed. Deliver editable .stack source and report verification results. Architecture requirements: +``` + +完整的 [agent workflow](./agent-workflow) 与 CLI skill 从同一份源文件生成。规范的 agent 指令使用英语;请让 agent 读取上面的 Markdown URL,或复制完整指令。 + +## 参考与更新 + +- [Examples](../examples/index) +- [Syntax](../language/syntax) +- [Diagnostics](../reference/diagnostics-and-limits) +- [Provider icons](./provider-icons) +- [Markdown index](https://stack-diagram.com/docs/llms.txt) diff --git a/generated/site/zh/guide/getting-started.md b/generated/site/zh/guide/getting-started.md new file mode 100644 index 0000000..a072d72 --- /dev/null +++ b/generated/site/zh/guide/getting-started.md @@ -0,0 +1,86 @@ +# 快速开始 + +使用 Stack 最快的方法是浏览器 [Playground](https://stack-diagram.com/)。格式化器、验证器、布局引擎和 SVG 渲染器都通过 WebAssembly 在本地运行;无需安装命令,也不会把源文件发送到渲染 API。 + +## 安装原生 CLI + +对于终端工作流和本地自动化,请使用 `brew install stack-sh/tap/stack` 安装由 Stack 维护的 Homebrew formula。它使用规范的 Stack CLI 0.4.0 发布归档,并支持符合 Homebrew 当前 Tier 1 要求的 Apple Silicon macOS,以及 arm64 / x86_64 的 glibc Linux。Homebrew 通过 `brew upgrade stack-sh/tap/stack` 管理升级;卸载 formula 不会删除 Stack 配置和图标存储。有关准确的平台矩阵、直接安装方式和恢复策略,请参阅 [CLI 分发约定](https://github.com/stack-sh/cli/blob/main/docs/distribution.md#homebrew-installation)。 + +## 编写第一份文档 + +将编辑器内容替换为下面的示例: + +```stack +stack 1.0 + +diagram "Checkout" { + theme default + + node shopper "Shopper" { + kind actor + } + + group application "Application" { + node web "Web app" { + kind client + detail "React" + } + + node api "Checkout API" { + kind service + detail "Rust" + } + + layout { + direction right + order [web, api] + } + } + + node orders "Orders" { + kind database + detail "PostgreSQL" + } + + edge shopper -> web "HTTPS" { + kind request + } + + edge web -> api "JSON" { + kind request + } + + edge api -> orders "SQL" { + kind data + } + + layout { + direction right + order [shopper, application, orders] + } +} +``` + +## 渲染并查看 + +选择 **Run**,或按 Command/Ctrl + Enter。预览区会显示独立 SVG。选择预览可放大查看,需要保存时使用 **Download SVG**。 + +源文件由四部分组成: + +1. `stack 1.0` 声明语言版本。 +2. `diagram` 提供一个标题并包含完整架构。 +3. `node` 和 `group` 声明组件与边界。 +4. `edge` 记录关系,`layout` 提供受约束的布局意图。 + +## 检查与格式化 + +**Check** 在不替换 SVG 的情况下运行完整验证与布局流程。**Format** 保留行注释和语义,将语法有效的源文件改写成规范的两空格格式。 + +发现问题时,诊断会显示严重级别、稳定代码、位置、源码片段、候选值,以及可用的修复帮助。选择诊断会聚焦对应源码范围。 + +## 接下来阅读 + +- [文档与语法](../language/syntax)介绍词法规则和完整语法。 +- [节点与分组](../language/nodes-and-groups)介绍组件和边界建模。 +- [连线与布局](../language/edges-and-layout)介绍关系和布局意图。 +- 选择视觉系统或显式图标前,请阅读[主题与图标](../language/themes-and-icons)。 diff --git a/generated/site/zh/guide/playground.md b/generated/site/zh/guide/playground.md new file mode 100644 index 0000000..4f94adc --- /dev/null +++ b/generated/site/zh/guide/playground.md @@ -0,0 +1,42 @@ +# 使用 Playground + +Playground 是位于 [stack-diagram.com](https://stack-diagram.com/) 的公共浏览器客户端。编辑器保留原生文本输入行为,共享 TextMate grammar 提供语法着色。验证、格式化、布局和 SVG 始终来自已发布的 Stack WebAssembly 引擎。 + +## 操作 + +| 操作 | 结果 | +| ---------------- | ------------------------------------------------------ | +| **Format** | 规范化语法有效的源文件并保留注释;语义错误仍会显示。 | +| **Check** | 不生成新 SVG,运行编译器、主题、图标、布局和路由检查。 | +| **Run** | 运行完整流程;若没有阻止渲染的错误,则更新 SVG。 | +| **Download SVG** | 保存当前独立 SVG。 | + +Command/Ctrl + Enter 也可运行文档。源文件发生变化时会清除旧诊断,避免把过期范围当成当前结果。 + +## 阅读诊断 + +错误结果可以包含: + +```text +error[STK2002] at 4:22 +4 | layout { direction hoo } + | ^^^ unexpected layout direction 'hoo' + = expected: right, down + = help: use 'right' for horizontal flow or 'down' for vertical flow +``` + +选择诊断或相关信息可聚焦对应源码。错误会阻止成功渲染;警告说明回退行为或可读性风险,并可与 SVG 同时返回。 + +## 两个独立的颜色设置 + +页头的颜色模式只改变 Playground 与编辑器外观;`theme dark` 等源码语句改变生成图。两者故意相互独立,切换网站深色模式不会改写或重新解释图的主题。 + +## 浏览器行为与数据 + +Playground 加载公开 WebAssembly 模块,然后在浏览器中同步执行 `format`、`check` 和 `render`。引擎本身不读取文件、不连接网络服务、不检查 DOM、不读取时钟,也不测量宿主字体。 + +当前 Playground 不提供账号、云端持久化、协作或付费主题。请下载需要保留的源文件或 SVG。 + +## 无障碍 + +编辑器保留原生光标、选择、剪贴板、撤销、键盘和输入法行为。诊断可以导航到源码范围。预览有文本替代,并在键盘可访问的对话框中打开。界面支持 320 像素布局、明暗对比度、可见焦点和减少动态效果偏好。 diff --git a/generated/site/zh/guide/provider-icons.md b/generated/site/zh/guide/provider-icons.md new file mode 100644 index 0000000..1d80962 --- /dev/null +++ b/generated/site/zh/guide/provider-icons.md @@ -0,0 +1,118 @@ +# 云服务商图标 + +Stack 内置与服务商无关的核心图标目录。AWS、Google Cloud、Azure 以及常用开发和协作工具图形通过 provider pack 使用,并保存在用户管理的 icon store 中。 + +## 可用的服务商目录 + +已审核目录共有 1,051 个 ID:305 个 AWS Architecture Icons、45 个 Google Cloud 产品与分类图标、639 个 Azure 服务图标,以及 62 个常用工具图标。工具目录包括 GitHub、GitHub Actions、Notion、Linear、Atlassian、Jira、Confluence、Docker、Kubernetes、Terraform、Datadog、Grafana 和 Sentry 等。 + +选择服务商卡片即可查看导入命令。完整目录支持搜索与筛选,并以每次 100 项的方式在小屏设备上稳定显示。 + + + +Provider pack 提供图形;Stack 源码中的节点 `kind` 继续决定语义样式和布局。 + +## 快速开始 + +为图中使用的每个服务商执行一次导入。`--accept-terms` 表示你已查看并接受链接中的服务商和品牌条款。 + +```sh +$ stack icons import gcp --accept-terms +$ stack icons import simple-icons --accept-terms +$ stack render architecture.stack -o architecture.svg +``` + +CLI 会下载已审核的官方压缩包,验证完整 SHA-256,清理选定 SVG,并将处理后的 provider pack 写入共享 icon store。一个 `gcp` 命令会同时导入 Google Cloud 产品和分类图形。 + +## 在 CLI 中使用服务商图标 + +一个 Stack 文件可以使用多个服务商。下面的例子组合了 Google Cloud 的 Cloud Run 与 Simple Icons 的 GitHub: + +```stack +stack 1.0 + +diagram "Deploy from GitHub to Cloud Run" { + node repository "GitHub" { + kind external + icon "simple-icons:github" + } + + node service "Cloud Run" { + kind service + icon "gcp:cloud-run" + } + + edge repository -> service "Deploy" { + kind dependency + } +} +``` + +完成两次导入后,标准渲染命令会发现两个 pack: + +```sh +$ stack render architecture.stack -o architecture.svg --notice architecture.NOTICE.md +``` + +## 共享 icon store + +默认 icon store 为 `$XDG_CONFIG_HOME/stack/icons`。未设置 `XDG_CONFIG_HOME` 时使用 `$HOME/.config/stack/icons`。 + +```text +icons/ + aws/ + gcp/ + azure/ + simple-icons/ +``` + +可在 `$XDG_CONFIG_HOME/stack/config.yaml` 中设置绝对路径来更改共享位置: + +```yaml +default_icons_path: /absolute/path/to/stack-icons +``` + +`stack icons import` 与 `stack render` 都会使用该位置。 + +## 在 Playground 中使用服务商图标 + +打开 **Icons**,选择 `stack/icons` 文件夹,Playground 会加载其中所有可识别的服务商目录。搜索已加载图形并选择一项,即可把 ID 复制到 Stack 源码中。 + +所选 pack 在当前浏览器标签页中处理。当生成图使用服务商图形时,SVG 下载旁的 **Notice** 会提供来源、条款和已使用图标记录。 + +## 将图标与项目一起管理 + +使用 `-o` 将导入的 pack 放进可随仓库提交的项目目录: + +```sh +$ stack icons import gcp --accept-terms -o .stack-icons +$ stack icons import simple-icons --accept-terms -o .stack-icons +``` + +渲染时通过 `--provider-pack` 传入同一个 icon-store 根目录: + +```sh +$ stack render architecture.stack \ + --provider-pack .stack-icons \ + -o architecture.svg \ + --notice architecture.NOTICE.md +``` + +## 查找图标 ID + +可通过 CLI 或本页搜索目录: + +```sh +$ stack icons list +$ stack icons list aws s3 +$ stack icons list azure database +$ stack icons list simple-icons github +``` + +CLI 输出包含 `ID`、`PRODUCT`、`CATEGORY` 和推荐的 `KIND`。`gcp:cloud-run`、`simple-icons:github` 等带命名空间的 ID 会选择对应 pack 中的图形。 + +## 验证、条款与 notice + +CLI 目录固定了每个官方 HTTPS 压缩包 URL、版本、完整 SHA-256、允许的条目路径、条款 URL 与审核日期。导入时会限制压缩包与 SVG 大小,清理活动及外部 SVG 内容,并以原子方式写入 pack。 + +每个 pack 都包含 `NOTICE.md`。`stack render --notice ` 会写入实际 pack 版本、来源版本、条款 URL、署名、非背书文本和已使用的图标 ID。目录还链接每个服务商的官方来源与条款,以及 Simple Icons 标志对应的品牌来源和指南。 diff --git a/generated/site/zh/guide/what-is-stack.md b/generated/site/zh/guide/what-is-stack.md new file mode 100644 index 0000000..c505901 --- /dev/null +++ b/generated/site/zh/guide/what-is-stack.md @@ -0,0 +1,51 @@ +# 什么是 Stack? + +Stack 是一种用于静态软件架构图和技术栈图的小型声明式语言。你在 UTF-8 `.stack` 文件中描述组件、边界与关系,由渲染器决定坐标、间距、连线路径、字体和视觉表现。 + +这种分工让源文件简洁、易审查,也适合版本控制。同一份文档可以由兼容工具格式化、检查和渲染,而不会变成绘图指令集合。 + +## 基本模型 + +每份文档包含一个语言版本和且仅一个图。图中可包含节点、分组、连线、主题和布局意图。 + +```stack +stack 1.0 + +diagram "Service architecture" { + node client "Web app" { + kind client + } + + node api "API" { + kind service + detail "Order orchestration" + } + + edge client -> api "HTTPS" { + kind request + } +} +``` + +这段源代码表达客户端调用服务,但没有规定方框位置或箭头如何转弯。 + +## Stack 的设计目标 + +- **简洁编写:** 只需命名节点和连线即可得到有用的图。 +- **可预测生成:** 人和语言模型都能用一种受约束的方式稳定表达概念。 +- **语义源文件:** 记录拓扑和意图,而不是像素。 +- **一致输出:** 渲染器拥有统一的视觉系统。 +- **可操作错误:** 诊断可指向源码范围,并给出候选值、修复帮助和相关声明。 +- **安全嵌入:** 源文件不能执行代码、获取任意资源或注入 HTML/SVG。 + +## Stack 不是什么 + +Stack 1.0 不是通用图语言、像素级画布、基础设施定义或可执行编程语言。它没有变量、导入、宏、条件、CSS、坐标、任意 URL 或嵌入 HTML,也不用于顺序图、状态机、类图、ER 图或完整 UML。 + +大型系统应拆成多张聚焦的图。Stack 为可读性设置了元素上限,而不是允许无限扩张。 + +## 处理模型 + +工具依次解码和解析文档、解析标识符与默认值、验证语义、解析主题与图标、求解布局并渲染。源代码错误会阻止渲染。可选主题或图标缺失、布局提示无法满足时会产生警告,并仍可返回回退图。 + +[语言页面](../language/syntax)介绍所有编写结构;[版本与安全](../reference/versioning-and-safety)介绍兼容性和信任边界。 diff --git a/generated/site/zh/index.md b/generated/site/zh/index.md new file mode 100644 index 0000000..7df8d09 --- /dev/null +++ b/generated/site/zh/index.md @@ -0,0 +1,27 @@ +--- +layout: home + +hero: + name: Stack + text: 将架构写成源代码。 + tagline: 编写一份简洁的语义文档,无需指定坐标或逐个设置方框样式,即可生成一致且无障碍的架构图。 + image: + light: /favicon.svg + dark: /favicon.svg + alt: Stack 标志 + actions: + - theme: brand + text: 快速开始 + link: /zh/guide/getting-started + - theme: alt + text: 打开 Playground + link: https://stack-diagram.com/ + +features: + - title: 描述系统 + details: 用简洁、可读的 .stack 文件记录节点、分组、关系和布局意图。 + - title: 保持语义可移植 + details: 带版本的语言和结构化诊断将架构语义与渲染器选择分离。 + - title: 安全渲染 + details: 引擎生成不含脚本、任意 HTML 或网络资源的独立 SVG。 +--- diff --git a/generated/site/zh/language/edges-and-layout.md b/generated/site/zh/language/edges-and-layout.md new file mode 100644 index 0000000..97bae99 --- /dev/null +++ b/generated/site/zh/language/edges-and-layout.md @@ -0,0 +1,78 @@ +# 连线与布局 + +连线描述节点之间的关系。布局块用少量意图控制放置方式,而不暴露坐标或绘图原语。 + +## 连线方向 + +连线连接两个不同节点。允许前向引用,不允许自连线或使用分组作为端点。 + +| 操作符 | 含义 | +| ------ | -------------------------------- | +| `->` | 从左侧节点指向右侧节点的有向关系 | +| `<->` | 双向对称的一个关系 | +| `--` | 无方向或有意不指定方向的关联 | + +`<->` 是一个关系,不是两条可独立标注连线的缩写。 + +## 连线种类与标签 + +可选标签描述协议、事件、命令、数据集或用途,长度为 1 至 40 个 Unicode scalar。可选 `kind` 与标签独立描述关系,默认值是 `flow`。 + +| Kind | 预期含义 | +| ------------ | -------------------------- | +| `flow` | 通用运行时或概念流 | +| `request` | 同步请求或调用 | +| `event` | 异步消息或事件传递 | +| `data` | 数据移动、复制、读取或写入 | +| `dependency` | 构建、部署或运维依赖 | + +```stack +stack 1.0 + +diagram "Relationships" { + node web "Web app" { + kind client + } + + node api "API" + node queue "Events" { + kind queue + } + + edge web -> api "HTTPS" { + kind request + } + + edge api -> queue "OrderPlaced" { + kind event + } +} +``` + +表达不同关系时,同一对节点之间可以有多条连线。端点、操作符、标签和有效 kind 全部相同的精确重复无效。比较 `<->` 和 `--` 重复时忽略端点顺序。 + +## 布局作用域 + +一个图或分组最多包含一个 `layout` 块。分组中的布局只影响其直接子项,图中的布局只影响图的直接子项。`rank` 和 `order` 必须引用同一作用域中至少两个不同的直接子项。 + +布局把直接子分组视为一个项。不同分组后代节点之间的连线会形成直接子项之间的连接,因此即使分组不能作为连线端点,顶层布局仍可排列分组。 + +## Direction、rank 与 order + +```stack +layout { + direction right + rank same [web, worker] + order [web, worker, database] +} +``` + +- `direction right` 偏好从左到右,`direction down` 偏好从上到下。它是强提示,但不保证每条连线都朝该几何方向;嵌套分组不会继承。 +- `rank same [a, b]` 是约束,要求列出的直接子项位于同一布局 rank。同一作用域中的一个子项不能出现在两个 same-rank 语句中。 +- `order [a, b]` 是相对顺序提示。向右布局时按从上到下,向下布局时按从左到右,自动布局时沿选定 cross-axis 解释。可以省略其他子项。 + +为满足包含关系、same-rank 约束、可读性或输出边界,渲染器可以偏离 `order`。支持诊断的工具此时应发出 `STK4001`。 + +## 渲染器负责的决定 + +Stack 不提供坐标、尺寸、端口、路径、颜色、字体、换行或 z-index。渲染器负责防止重叠、保持包含与方向、确保标签可读、避开节点内部布线,并扩展画布而不裁剪语义内容。 diff --git a/generated/site/zh/language/formatting.md b/generated/site/zh/language/formatting.md new file mode 100644 index 0000000..dc1cca4 --- /dev/null +++ b/generated/site/zh/language/formatting.md @@ -0,0 +1,58 @@ +# 规范格式化 + +Stack 为每份词法和语法有效的文档定义唯一规范字节形式。格式化保持语言版本、语义和所有行注释不变,并让 diff 保持一致。 + +## 可格式化的源文件 + +格式化器接受不含 BOM 的 UTF-8。词法或语法错误只返回诊断,不会返回部分改写结果。语法有效时,即使存在语义或复杂度诊断也可以格式化;格式化成功不代表图有效。 + +## 规范输出 + +规范源文件: + +- 使用不含 BOM 的 UTF-8; +- 将所有换行规范为 LF; +- 每层缩进使用两个 ASCII 空格,不使用格式化制表符; +- 行尾没有格式化空白; +- 结尾恰好一个 LF; +- 左花括号留在声明或 `layout` 行,右花括号独占一行; +- 版本与图、相邻 body member 之间有一个空行; +- 属性和布局语句之间没有空行。 + +```stack +stack 1.0 + +diagram "Title" { + theme dark + + node client "Client" + + node api "API" { + kind service + detail "Public API" + } + + edge client -> api "HTTPS" { + kind request + } + + layout { + direction right + order [client, api] + } +} +``` + +## 顺序与列表 + +格式化器保持图和分组成员、节点和连线属性、布局语句及列表标识符的原始顺序,绝不分组或排序。列表保持一行,逗号后一个空格,方括号内侧无空格,也没有尾随逗号。 + +## 字符串 + +有效字符串会被解码,并在不进行 Unicode normalization 的情况下直接输出为 UTF-8。引号和反斜杠保持转义;规范输出不使用 `\uXXXX`。例如 `"API \u56F3 \uD83D\uDE80"` 会变成 `"API 図 🚀"`。 + +## 注释 + +所有行注释及其顺序都会保留。尾随注释在前一个 token 后用一个空格连接。独立行注释保持 token gap,紧邻后续成员、语句或属性。结构内部的注释可以强制续行,这是通常单行规则的唯一例外。 + +再次格式化规范源文件必须得到逐字节相同结果。存在 normalized IR 时,格式化前后必须产生语义相同的 IR。 diff --git a/generated/site/zh/language/nodes-and-groups.md b/generated/site/zh/language/nodes-and-groups.md new file mode 100644 index 0000000..b64140c --- /dev/null +++ b/generated/site/zh/language/nodes-and-groups.md @@ -0,0 +1,67 @@ +# 节点与分组 + +节点是可引用的架构实体,分组是带标签的包含边界。两者共同描述图中可见的组件与作用域。 + +## 节点 + +节点需要全局唯一标识符和可见标签。标识符供连线和布局语句引用,但不会渲染;标签长度为 1 至 60 个 Unicode scalar。 + +```stack +stack 1.0 + +diagram "Node example" { + node api "Public API" { + kind service + detail "Order orchestration" + } +} +``` + +不同实体可以使用相同可见标签,但最好让标签不依赖位置也能理解。节点块不能重复 `kind`、`icon` 或 `detail`。 + +## 节点种类 + +`kind` 表示粗粒度架构语义,并选择由主题控制的形状和回退图标。默认值是 `service`。 + +| Kind | 预期含义 | +| ---------- | --------------------------------------- | +| `actor` | 人、角色、团队或自主参与者 | +| `client` | 浏览器、移动/桌面应用、设备或其他客户端 | +| `service` | 长期运行的应用、API、网关或通用组件 | +| `function` | 按需或 serverless 计算单元 | +| `worker` | 后台处理器或定时任务 | +| `database` | 持久、可查询的数据存储 | +| `cache` | 内容可丢弃或可重新生成的数据存储 | +| `queue` | 用于异步传递的队列、流、总线或 broker | +| `storage` | Blob、对象、文件或归档存储 | +| `external` | 架构控制边界之外的系统 | + +Kind 是语义分类,不是厂商形状。托管 PostgreSQL 仍是 `database`,技术名称应写入 `detail`。 + +## 标签与详情 + +`detail` 是可选的可见第二行,长度为 1 至 80 个 Unicode scalar。可填写一种技术或简短职责,如 `"Next.js"`、`"PostgreSQL 17"` 或 `"Order orchestration"`。它必须在所有渲染图中可见,不能只放在 tooltip 中。 + +标签和详情是纯文本。显式 `icon` 只装饰节点,不改变 kind、identity 或无障碍标签。另见[主题与图标](./themes-and-icons)。 + +## 分组 + +分组需要全局唯一标识符、1 至 60 个 Unicode scalar 的标签,以及至少一个后代节点。它可包含节点、嵌套分组和一个布局块。 + +```stack +stack 1.0 + +diagram "Boundaries" { + group platform "Platform" { + group data "Data layer" { + node primary "Primary database" { + kind database + } + } + } +} +``` + +分组最多可在图下嵌套三层。节点属于最近的分组,也传递地属于所有祖先分组。声明不能复用,因此一个节点不能同时属于两个独立分组。 + +连线必须在图作用域声明,且只有节点可作为端点。分组不会产生隐式节点或连线。标签用于说明它代表系统、领域、网络、部署区域、团队或其他边界;包含关系本身不表示运行时隔离、安全性、所有权或部署语义。 diff --git a/generated/site/zh/language/syntax.md b/generated/site/zh/language/syntax.md new file mode 100644 index 0000000..12a0281 --- /dev/null +++ b/generated/site/zh/language/syntax.md @@ -0,0 +1,95 @@ +# 文档与语法 + +Stack 源文件被刻意设计得很小。本页完整介绍 draft Stack 1.0 的词法结构与语法。 + +## 文档结构 + +文档是一个不含 BOM 的 UTF-8 `.stack` 文件。LF 与 CRLF 含义相同。第一个非注释 token 必须是版本指令,之后只能有且仅有一个图,不能再有其他声明。 + +```stack +// One file, one diagram. +stack 1.0 + +diagram "Example" { + node api "API" +} +``` + +图标题必填,长度为 1 至 80 个 Unicode scalar,开头和结尾不能是 Unicode 空白。图中至少要有一个节点。 + +## 注释与空白 + +空格、制表符和换行用于分隔 token,除此之外没有语义。行注释从 `//` 开始,到行尾结束,可出现在允许空白的位置。不支持块注释。 + +格式本身没有语义,但规范格式化器会生成[规范格式化](./formatting)定义的一致形式。 + +## 标识符 + +节点、分组、主题和引用标识符匹配: + +```text +[a-z][a-z0-9_-]* +``` + +长度为 1 至 64 个 ASCII 字符,区分大小写,且不会显示。节点和分组共享一个全局命名空间。关键字是上下文相关的,技术上也可用于标识符位置,但应避免降低可读性的名称。 + +图标标识符是带引号的字符串,解码后匹配 `[a-z0-9][a-z0-9-]*`,长度同样为 1 至 64 个 ASCII 字符,并在有效主题内解析。 + +## 字符串 + +字符串使用双引号,可直接包含 Unicode。只支持三种转义: + +| 转义 | 含义 | +| -------- | ----------------- | +| `\"` | 双引号 | +| `\\` | 反斜杠 | +| `\uXXXX` | Unicode code unit | + +解码后的字符串不能包含换行、制表符、控制字符或未配对 surrogate。标题、标签和详情不能以 Unicode 空白开头或结尾。字符串始终是纯文本,不会解释为 Markdown 或 HTML。 + +## 完整语法 + +```text +document = version-directive, diagram-declaration, EOF ; +version-directive = "stack", integer, ".", integer ; +diagram-declaration + = "diagram", string, "{", { diagram-member }, "}" ; +diagram-member = node-declaration | group-declaration | edge-declaration + | theme-statement | layout-block ; +theme-statement = "theme", identifier ; +group-declaration = "group", identifier, string, "{", { group-member }, "}" ; +group-member = node-declaration | group-declaration | layout-block ; +node-declaration = "node", identifier, string, [ node-block ] ; +node-block = "{", node-property, { node-property }, "}" ; +node-property = "kind", node-kind | "icon", string | "detail", string ; +node-kind = "actor" | "client" | "service" | "function" | "worker" + | "database" | "cache" | "queue" | "storage" | "external" ; +edge-declaration = "edge", identifier, edge-operator, identifier, + [ string ], [ edge-block ] ; +edge-operator = "->" | "<->" | "--" ; +edge-block = "{", edge-property, { edge-property }, "}" ; +edge-property = "kind", edge-kind ; +edge-kind = "flow" | "request" | "event" | "data" | "dependency" ; +layout-block = "layout", "{", layout-statement, + { layout-statement }, "}" ; +layout-statement = direction-statement | rank-statement | order-statement ; +direction-statement + = "direction", ( "right" | "down" ) ; +rank-statement = "rank", "same", identifier-list ; +order-statement = "order", identifier-list ; +identifier-list = "[", identifier, ",", identifier, + { ",", identifier }, "]" ; +integer = "0" | nonzero-digit, { digit } ; +``` + +## 上下文关键字 + +Stack 1.0 在对应语法位置识别: + +```text +stack diagram group node edge theme layout kind icon detail direction +rank same order right down actor client service function worker +database cache queue storage external flow request event data dependency +``` + +未知声明、属性、枚举值和操作符都是错误。工具不会静默忽略可能生成外观合理但语义错误图形的语法。 diff --git a/generated/site/zh/language/themes-and-icons.md b/generated/site/zh/language/themes-and-icons.md new file mode 100644 index 0000000..6d8fda0 --- /dev/null +++ b/generated/site/zh/language/themes-and-icons.md @@ -0,0 +1,126 @@ +# 主题与图标 + +主题是图级别、由渲染器管理的视觉系统符号引用。图标是在该主题内解析的逻辑名称。两者都不会改变图的语义。 + +## 选择主题 + +在图中最多添加一条 `theme` 语句: + +```stack +stack 1.0 + +diagram "Dark architecture" { + theme dark + + node api "API" +} +``` + +省略时使用 `default`。Draft Stack 1.0 要求核心 catalog 提供: + +| Theme | 用途 | +| --------- | ---------------------------- | +| `default` | 适合通用架构图的均衡蓝灰表面 | +| `light` | 适合浅色文档的暖中性色表面 | +| `dark` | 适合深色画布的高对比冷色表面 | + +源文件选择标识符,而不是 catalog package 版本。渲染 metadata 记录 catalog 版本和内容 revision,以标识实际使用的视觉数据。 + +生成图主题与 Playground 的明暗界面相互独立。主题可改变 palette、字体 metrics、surface、icon、connector 和 background,但不能隐藏或改变节点、分组、连线、标签、kind、方向或布局约束。 + +## 回退行为 + +三个核心主题是渲染器必需资源。当前 catalog 中不存在的非核心主题会发出 `STK6001`,并使用 `default` 渲染。引擎不会因为源文件出现主题标识符就从网络下载主题。 + +主题标识符使用普通 Stack 标识符语法。一旦注册,即使废弃后也不能重新分配给另一个主题。 + +## Kind 回退图标 + +每个主题为所有节点 kind 提供回退。省略 `icon` 时渲染器使用它。 + +| Node kind | 当前逻辑回退图标 | +| ---------- | ---------------- | +| `actor` | `kind-actor` | +| `client` | `kind-client` | +| `service` | `kind-service` | +| `function` | `kind-function` | +| `worker` | `kind-worker` | +| `database` | `kind-database` | +| `cache` | `kind-cache` | +| `queue` | `kind-queue` | +| `storage` | `kind-storage` | +| `external` | `kind-external` | + +当前开放核心 catalog 在 `default`、`light` 和 `dark` 中包含这十个回退标识符,尚不包含 `postgresql`、`aws` 或 `github` 等厂商图标。多数文档应选择语义 `kind` 并省略 `icon`。 + +## 显式图标 + +显式图标使用带引号的逻辑标识符: + +```stack +stack 1.0 + +diagram "Explicit icon" { + node gateway "Public API" { + kind service + icon "api" + } +} +``` + +图标只装饰节点,不改变 `service` kind、identity、label 或无障碍说明。同一标识符在不同主题中表示同一个逻辑对象,但颜色与图形可以适配主题。 + +## 第一方图标目录 + +免费核心 catalog 在 `default`、`light` 和 `dark` 中提供以下与厂商无关的显式图标: + +| ID | Stable subject | 主要用途 | +| --------------- | --------------------------------- | --------------------- | +| `api` | Application programming interface | 公共或内部 API | +| `web` | Web application | 面向浏览器的 Web 体验 | +| `mobile` | Mobile application | iOS 或 Android 客户端 | +| `desktop` | Desktop application | 原生桌面客户端 | +| `server` | Server host | 虚拟机或物理主机 | +| `container` | Application container | 容器化工作负载 | +| `cluster` | Compute cluster | 编排后的计算集群 | +| `cloud` | Cloud environment | 与厂商无关的云边界 | +| `scheduler` | Scheduled execution | Cron 任务或定时工作 | +| `webhook` | Webhook endpoint | 入站或出站回调 | +| `identity` | Identity and access | 身份验证或授权 | +| `observability` | Observability system | 指标、日志或链路追踪 | +| `gateway` | Network gateway | 公共或私有网络入口 | +| `load-balancer` | Load balancer | 流量分发 | +| `dns` | Domain name service | 主机名与服务发现 | +| `cdn` | Content delivery network | 边缘内容分发 | +| `firewall` | Network firewall | 网络访问边界 | +| `network` | Network topology | 通用网络或子网 | +| `event` | Discrete event | 单个领域或系统事件 | +| `stream` | Event stream | 连续事件或数据流 | +| `search` | Search service | 索引与查询系统 | +| `analytics` | Analytics system | 报告或数据分析 | +| `repository` | Source code repository | 源代码与版本控制 | +| `pipeline` | Delivery pipeline | 构建、测试或部署流程 | +| `secret` | Secret or credential | 密钥或凭据 | +| `document` | Document or knowledge base | 文档与知识库 | +| `task` | Task or issue tracker | 任务、工单或问题跟踪 | +| `chat` | Chat or messaging tool | 团队聊天或消息 | +| `email` | Email delivery | 邮件投递或收件箱 | +| `ai` | Artificial intelligence system | AI 模型或推理服务 | + +切换下方预览的浅色与深色模式即可比较真实输出。每张图片都由已发布的 `@stack-sh/engine@0.7.0` 在本地渲染;文档没有复制 Theme SVG 资源。选择语法行即可复制。 + + + +语义 `kind` 与显式图标应独立选择。例如,`icon "web"` 可以装饰 `client` 或 `service` 节点,但不会改变该节点的含义。 + +## 缺失图标与厂商图标 + +核心 catalog 目前不包含 `postgresql`、`aws`、`github` 或 `docker` 等厂商或项目标志。如果有效主题没有编写的图标标识符,引擎会继续使用节点 kind 的回退图标渲染,并发出 `STK5001`。 + +请优先选择上表中与厂商无关的图标;如果 kind 回退已能表达角色,也可以省略 `icon`。厂商标志只有在逐项完成资源 license、再分发和商标审查后,才能进入独立 catalog。 + +## Catalog 与资源安全 + +公共 `stack-sh/theme` catalog 拥有 palette、确定性字体 metrics、node-kind visual、connector、icon metadata、SVG bytes、来源和再分发许可。Catalog 资源随渲染器打包,编写的标识符绝不会被当成文件路径或 URL。 + +SVG 验证会拒绝脚本、事件处理器、嵌套 SVG、不安全引用、data/network URL、style 属性和 allowlist 外元素或属性。图标不能成为表达意义的唯一方式,标签和非颜色区分也必须保留。 diff --git a/generated/site/zh/reference/diagnostics-and-limits.md b/generated/site/zh/reference/diagnostics-and-limits.md new file mode 100644 index 0000000..2543e93 --- /dev/null +++ b/generated/site/zh/reference/diagnostics-and-limits.md @@ -0,0 +1,58 @@ +# 诊断与限制 + +Stack 诊断是结构化结果,不是控制台文本。它包含稳定代码、`error` 或 `warning` 严重级别、从 1 开始且 end-exclusive 的源码范围、简洁消息和有序 `expected` 列表;适用时还包含修复帮助与相关源码范围。 + +## 处理与严重级别 + +工具依次处理编码与 token、语法、标识符与默认值、语义限制、主题与图标、布局、渲染。前四阶段的错误会阻止渲染。主题、图标、密度和布局提示警告可与回退 SVG 同时出现。 + +编辑源码后,Playground 会清除旧诊断。选择结果可聚焦主范围,相关信息可指向较早的声明。 + +## 复杂度限制 + +| 项目 | Draft Stack 1.0 限制 | +| ----------------------- | -----------------------------: | +| 每份文档的图 | 1 | +| 节点 | 1 至 40 | +| 分组 | 0 至 12 | +| 图下分组嵌套 | 3 层 | +| 连线 | 0 至 80 与节点数两倍中的较小值 | +| 发出警告前的节点 degree | 12 条 incident edge 声明 | + +超过硬限制会产生 `STK4003`。超过建议 degree 的节点仍有效,但产生 `STK4002`。请把大型系统拆成多张聚焦的图。 + +## 可移植诊断代码 + +| Code | Severity | 含义 | +| --------- | -------- | -------------------------------------- | +| `STK1001` | Error | 输入不是有效 UTF-8 | +| `STK1002` | Error | 存在 byte order mark | +| `STK1003` | Error | 字符串转义或解码值无效 | +| `STK2001` | Error | 声明的语言版本不受支持 | +| `STK2002` | Error | 出现意外 token、声明、属性、值或操作符 | +| `STK2003` | Error | 当前结构完成前输入结束 | +| `STK3001` | Error | 标识符无效 | +| `STK3002` | Error | 标识符被重复声明 | +| `STK3003` | Error | 连线引用未知节点 | +| `STK3004` | Error | 分组被用作连线端点 | +| `STK3005` | Error | 连线连接节点自身 | +| `STK3006` | Error | 声明了精确重复连线 | +| `STK3007` | Error | 一个 block 中属性重复 | +| `STK3008` | Error | 标题、标签或详情违反文本约束 | +| `STK3009` | Error | 分组没有后代节点 | +| `STK3010` | Error | 分组嵌套超过语言限制 | +| `STK3011` | Error | 布局引用在作用域内无效 | +| `STK3012` | Error | 布局块或单例布局语句重复 | +| `STK3013` | Error | 图标标识符格式错误 | +| `STK3014` | Error | 图包含多条主题语句 | +| `STK4001` | Warning | 顺序提示无法满足 | +| `STK4002` | Warning | 节点超过建议 incident-edge degree | +| `STK4003` | Error | 图超过语言复杂度限制 | +| `STK5001` | Warning | 有效主题中没有图标,使用 kind 回退 | +| `STK6001` | Warning | 请求的非核心主题不可用,使用 `default` | + +代码族中,`STK1000` 表示编码/词法,`STK2000` 表示语法,`STK3000` 表示名称/语义,`STK4000` 表示布局/复杂度,`STK5000` 表示图标,`STK6000` 表示主题。`STK9000` 用于实现失败,而不是源码错误。实现只能使用自己的非 `STK` 前缀添加诊断。 + +## 恢复规则 + +解析器可以恢复并一次报告多个独立错误,但不能把部分图渲染成有效结果。未知声明、属性、枚举值和操作符绝不会被忽略,以避免成功外观掩盖语义丢失。 diff --git a/generated/site/zh/reference/versioning-and-safety.md b/generated/site/zh/reference/versioning-and-safety.md new file mode 100644 index 0000000..1d46fd1 --- /dev/null +++ b/generated/site/zh/reference/versioning-and-safety.md @@ -0,0 +1,40 @@ +# 版本与安全 + +Draft Stack 1.0 将源语言、实现、主题 catalog 和 package 版本分开。理解该边界有助于文档移植和追踪渲染输出。 + +## 语言版本 + +每份文档以 `major.minor` 指令开始: + +```stack +stack 1.0 + +diagram "Versioned source" { + node api "API" +} +``` + +它表示文档要求的最低语言语法与语义,不是引擎或主题版本。支持 `M.N` 的渲染器接受相同 major 且 minor 不大于 `N` 的文档,拒绝不同 major,并在未明确支持时拒绝更高 minor;不会猜测未来语法。 + +Specification release 使用 semantic versioning。Major 可带来不兼容语言变化;minor 添加向后兼容能力;patch 只澄清文字或修正勘误,不改变有效源码含义,因此文档指令不包含 patch。 + +## 渲染器与 catalog 标识 + +普通引擎结果包含引擎版本、编写的语言版本、主题 catalog 版本和 catalog 内容 revision。源码 `theme` 只选择符号标识符,不 pin package release,也不获取远程数据。 + +逐像素一致不是语言兼容性承诺。主题 metrics、渲染器版本、字体和画布决定可以改变位置,但必须保持节点、分组、关系、标签、kind 和约束。 + +## 安全的源文件边界 + +Stack 字符串是纯文本。源文件不能包含可执行代码、任意 HTML/Markdown、CSS、SVG、导入、宏、文件路径或网络 URL。引擎会转义编写文本,并生成包含已验证 catalog 图标、本地 marker reference、无障碍 title/description metadata 的独立 SVG。 + +渲染 SVG 不含脚本、事件处理器、任意外部引用、宿主字体测量或运行时 I/O。缺失图标或主题会选择已打包回退,而不是解析路径或连接 registry。 + +## 当前交付状态 + +- 浏览器 Playground 是受支持的公共体验。 +- 公共 `@stack-sh/engine` 提供 Playground 使用的 typed WebAssembly `format`、`check` 和 `render`。 +- 公共 `@stack-sh/language` 提供编辑器高亮使用的共享 TextMate grammar 和语言 metadata。 +- 公共 [`stack-sh/cli`](https://github.com/stack-sh/cli) 提供原生 `format`、`check`、`render` 和 provider-icon store 操作。 + +规范语言合同位于 [`stack-sh/specification`](https://github.com/stack-sh/specification),公共主题 catalog 位于 [`stack-sh/theme`](https://github.com/stack-sh/theme),引擎行为位于 [`stack-sh/engine`](https://github.com/stack-sh/engine)。 diff --git a/scripts/generate.mjs b/scripts/generate.mjs index d6247fb..4cc7dd6 100644 --- a/scripts/generate.mjs +++ b/scripts/generate.mjs @@ -45,6 +45,21 @@ export async function generate(directory = root, check = false) { const metadata = JSON.parse(await readFile(path.join(directory, 'content/skill-metadata.json'), 'utf8')); const release = JSON.parse(await readFile(path.join(directory, 'content/cli-release.json'), 'utf8')); const outputs = renderGuidance(workflow, metadata, release); + const siteRoot = path.join(directory, 'content/site'); + const siteFiles = await filePaths(siteRoot); + if (siteFiles.length > 0) { + const prompt = (await readFile(path.join(directory, 'content/agent-prompt.txt'), 'utf8')).trimEnd(); + for (const file of siteFiles) { + assert.ok(file.endsWith('.md'), `Only Markdown source is supported: ${file}`); + const source = await readFile(path.join(siteRoot, file), 'utf8'); + const rendered = source.replaceAll('{{cliVersion}}', release.version).replaceAll('{{agentPrompt}}', prompt); + assert.ok(!/\{\{[^}]+\}\}/.test(rendered), `Unknown site template token: ${file}`); + outputs[`site/${file}`] = rendered; + } + for (const locale of ['', 'ja/', 'zh/', 'ko/']) { + outputs[`site/${locale}guide/agent-workflow.md`] = outputs['guide/agent-workflow.md']; + } + } const manifest = { schemaVersion: '1.0', cli: release, diff --git a/scripts/generate.test.mjs b/scripts/generate.test.mjs index 06f46a7..2415af0 100644 --- a/scripts/generate.test.mjs +++ b/scripts/generate.test.mjs @@ -21,7 +21,7 @@ test('one shared instruction change updates skill and guide with deterministic o const source = await readFile(sourcePath, 'utf8'); await writeFile(sourcePath, source + '\nKeep the existing diagram title.\n'); const after = await generate(directory); - for (const file of ['skills/stack-diagrams/SKILL.md', 'guide/agent-workflow.md']) { + for (const file of ['skills/stack-diagrams/SKILL.md', 'guide/agent-workflow.md', ...['', 'ja/', 'zh/', 'ko/'].map(locale => `site/${locale}guide/agent-workflow.md`)]) { assert.notEqual(before[file], after[file]); assert.ok(after[file].includes('Keep the existing diagram title.')); } @@ -36,7 +36,7 @@ test('release lock updates all rendered version references', async t => { release.version = '9.8.7'; await writeFile(releasePath, JSON.stringify(release)); const outputs = await generate(directory); - for (const file of ['skills/stack-diagrams/SKILL.md', 'guide/agent-workflow.md']) { + for (const file of ['skills/stack-diagrams/SKILL.md', 'guide/agent-workflow.md', ...['', 'ja/', 'zh/', 'ko/'].map(locale => `site/${locale}guide/getting-started.md`)]) { assert.ok(outputs[file].includes('9.8.7')); assert.ok(!outputs[file].includes('0.4.0')); } @@ -62,3 +62,18 @@ test('unknown tokens and mutable provider revisions fail closed', () => { assert.throws(() => renderGuidance('{{missing}}', metadata, release), /Unknown template token/); assert.throws(() => renderGuidance('content', metadata, { ...release, revision: 'main' })); }); + +test('all four locales expose the same page set and shared copyable instruction', async t => { + const directory = await fixture(t); + const outputs = await generate(directory); + const locales = ['', 'ja/', 'zh/', 'ko/']; + const englishPages = Object.keys(outputs).filter(file => file.startsWith('site/') && !/^site\/(ja|zh|ko)\//.test(file)).map(file => file.slice(5)).sort(); + assert.equal(englishPages.length, 15); + const prompt = (await readFile(path.join(directory, 'content/agent-prompt.txt'), 'utf8')).trimEnd(); + for (const locale of locales) { + for (const page of englishPages) assert.ok(outputs[`site/${locale}${page}`], `Missing ${locale}${page}`); + assert.ok(outputs[`site/${locale}guide/coding-agents.md`].includes(prompt)); + assert.equal(outputs[`site/${locale}guide/agent-workflow.md`], outputs['guide/agent-workflow.md']); + } + assert.equal(Object.keys(outputs).filter(file => file.startsWith('site/')).length, 60); +});