From f2b96f0a6ea9009720d820650fb25a4deac1b906 Mon Sep 17 00:00:00 2001 From: konojunya Date: Sun, 6 Sep 2026 02:17:12 +0900 Subject: [PATCH] Support website command prompts and canonical release freshness --- .github/workflows/ci.yaml | 4 ++ .github/workflows/release-freshness.yaml | 23 ++++++++ README.md | 16 ++++++ content/agent-workflow.md | 2 +- generated/guide/agent-workflow.md | 2 +- generated/manifest.json | 12 ++--- generated/site/guide/agent-workflow.md | 10 ++-- generated/site/ja/guide/agent-workflow.md | 10 ++-- generated/site/ko/guide/agent-workflow.md | 10 ++-- generated/site/zh/guide/agent-workflow.md | 10 ++-- generated/skills/stack-diagrams/SKILL.md | 2 +- package.json | 2 + scripts/cli-release.mjs | 64 +++++++++++++++++++++++ scripts/cli-release.test.mjs | 30 +++++++++++ scripts/generate.mjs | 2 +- scripts/generate.test.mjs | 2 +- 16 files changed, 170 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/release-freshness.yaml create mode 100644 scripts/cli-release.mjs create mode 100644 scripts/cli-release.test.mjs diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a4fa6be..3bd9d77 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,6 +24,10 @@ jobs: run: npm test - name: Verify committed generated content run: npm run check + - name: Check published CLI freshness + run: npm run release:check + env: + GH_TOKEN: ${{ github.token }} - name: Verify and exercise published CLI env: GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/release-freshness.yaml b/.github/workflows/release-freshness.yaml new file mode 100644 index 0000000..74c6abf --- /dev/null +++ b/.github/workflows/release-freshness.yaml @@ -0,0 +1,23 @@ +name: Release freshness + +on: + schedule: + - cron: '23 2 * * *' + workflow_dispatch: + +permissions: + contents: read + +jobs: + freshness: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - uses: actions/setup-node@v7 + with: + node-version: 22.14.0 + - run: npm run release:check + env: + GH_TOKEN: ${{ github.token }} diff --git a/README.md b/README.md index 0192c2f..b111386 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,22 @@ instructions does not publish a new CLI binary. Recheck capability statements against the released binary's help when updating the release lock; changing a version string alone does not prove a feature is available. +## Keep the published CLI reference current + +Run `npm run release:sync` after a stable CLI release. It resolves the published +tag to its exact commit, updates `content/cli-release.json`, and regenerates all +version declarations. Review changed capabilities and run tests and the verified +release binary smoke before opening a PR. After merging, update both consumer +Docs pins and verify the website deployment and CLI skill installation. + +`npm run release:check` and the read-only daily freshness workflow reject a newer +unrecorded stable release or a retargeted tag. They do not publish, install a CLI, +or merge changes. Scheduled runs can be delayed and GitHub notification settings +control failure notifications. Web additionally audits the release it deploys. + +Site shell examples receive a generated `$ ` prompt; the installable skill keeps +executable command lines without prompts. The canonical source remains shared. + ## Migration status Shared workflow and multilingual source generation are available here. CLI and Web diff --git a/content/agent-workflow.md b/content/agent-workflow.md index af250bc..d2aa064 100644 --- a/content/agent-workflow.md +++ b/content/agent-workflow.md @@ -4,7 +4,7 @@ Deliver editable `.stack` source and, when rendering is available, an SVG. Prese ## 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 {{cliVersion}} supports `check`, `fmt`, and `render`; it does not support their `--json` flags. A newer version may support additional options: verify them using `stack help `. +Run `stack --version` and `stack help` before selecting commands. Use the installed binary's help, not unreleased repository instructions. This workflow is tested with published CLI {{cliVersion}} using `check`, `fmt`, and `render` without `--json` for compatibility. Before using additional options such as JSON output, 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/v{{cliVersion}}/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. diff --git a/generated/guide/agent-workflow.md b/generated/guide/agent-workflow.md index 666fd28..74d83b5 100644 --- a/generated/guide/agent-workflow.md +++ b/generated/guide/agent-workflow.md @@ -6,7 +6,7 @@ Deliver editable `.stack` source and, when rendering is available, an SVG. Prese ## 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 `. +Run `stack --version` and `stack help` before selecting commands. Use the installed binary's help, not unreleased repository instructions. This workflow is tested with published CLI 0.4.0 using `check`, `fmt`, and `render` without `--json` for compatibility. Before using additional options such as JSON output, 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. diff --git a/generated/manifest.json b/generated/manifest.json index 6a212b4..6e9432c 100644 --- a/generated/manifest.json +++ b/generated/manifest.json @@ -8,11 +8,11 @@ "files": [ { "path": "skills/stack-diagrams/SKILL.md", - "sha256": "a7f39a9d3da0f7074ea348bebb0260a642f202ee5f2026742c08972f75c7f2a6" + "sha256": "cb0efd01b5ae4762af18b57e9eb4e88ebcec860dc0aa9212235a2f5f3f742182" }, { "path": "guide/agent-workflow.md", - "sha256": "66fe4c3c97afad3a740d9ab824c5aae3f43783bfa251fe0347666b38bc3afc9b" + "sha256": "f2a20b466c4355eb42f7063b781eab32ff1dd87424d26f70bef070a8b70353dc" }, { "path": "site/examples/index.md", @@ -240,19 +240,19 @@ }, { "path": "site/guide/agent-workflow.md", - "sha256": "66fe4c3c97afad3a740d9ab824c5aae3f43783bfa251fe0347666b38bc3afc9b" + "sha256": "35d435082b86b48fa4b456262d7eb219e622221ae0906dca6dbe9a6619d02ef9" }, { "path": "site/ja/guide/agent-workflow.md", - "sha256": "66fe4c3c97afad3a740d9ab824c5aae3f43783bfa251fe0347666b38bc3afc9b" + "sha256": "35d435082b86b48fa4b456262d7eb219e622221ae0906dca6dbe9a6619d02ef9" }, { "path": "site/zh/guide/agent-workflow.md", - "sha256": "66fe4c3c97afad3a740d9ab824c5aae3f43783bfa251fe0347666b38bc3afc9b" + "sha256": "35d435082b86b48fa4b456262d7eb219e622221ae0906dca6dbe9a6619d02ef9" }, { "path": "site/ko/guide/agent-workflow.md", - "sha256": "66fe4c3c97afad3a740d9ab824c5aae3f43783bfa251fe0347666b38bc3afc9b" + "sha256": "35d435082b86b48fa4b456262d7eb219e622221ae0906dca6dbe9a6619d02ef9" } ] } diff --git a/generated/site/guide/agent-workflow.md b/generated/site/guide/agent-workflow.md index 666fd28..7fe240f 100644 --- a/generated/site/guide/agent-workflow.md +++ b/generated/site/guide/agent-workflow.md @@ -6,7 +6,7 @@ Deliver editable `.stack` source and, when rendering is available, an SVG. Prese ## 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 `. +Run `stack --version` and `stack help` before selecting commands. Use the installed binary's help, not unreleased repository instructions. This workflow is tested with published CLI 0.4.0 using `check`, `fmt`, and `render` without `--json` for compatibility. Before using additional options such as JSON output, 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. @@ -29,10 +29,10 @@ For a new diagram, start with the smallest complete source that preserves the re 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 +$ 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. diff --git a/generated/site/ja/guide/agent-workflow.md b/generated/site/ja/guide/agent-workflow.md index 666fd28..7fe240f 100644 --- a/generated/site/ja/guide/agent-workflow.md +++ b/generated/site/ja/guide/agent-workflow.md @@ -6,7 +6,7 @@ Deliver editable `.stack` source and, when rendering is available, an SVG. Prese ## 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 `. +Run `stack --version` and `stack help` before selecting commands. Use the installed binary's help, not unreleased repository instructions. This workflow is tested with published CLI 0.4.0 using `check`, `fmt`, and `render` without `--json` for compatibility. Before using additional options such as JSON output, 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. @@ -29,10 +29,10 @@ For a new diagram, start with the smallest complete source that preserves the re 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 +$ 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. diff --git a/generated/site/ko/guide/agent-workflow.md b/generated/site/ko/guide/agent-workflow.md index 666fd28..7fe240f 100644 --- a/generated/site/ko/guide/agent-workflow.md +++ b/generated/site/ko/guide/agent-workflow.md @@ -6,7 +6,7 @@ Deliver editable `.stack` source and, when rendering is available, an SVG. Prese ## 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 `. +Run `stack --version` and `stack help` before selecting commands. Use the installed binary's help, not unreleased repository instructions. This workflow is tested with published CLI 0.4.0 using `check`, `fmt`, and `render` without `--json` for compatibility. Before using additional options such as JSON output, 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. @@ -29,10 +29,10 @@ For a new diagram, start with the smallest complete source that preserves the re 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 +$ 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. diff --git a/generated/site/zh/guide/agent-workflow.md b/generated/site/zh/guide/agent-workflow.md index 666fd28..7fe240f 100644 --- a/generated/site/zh/guide/agent-workflow.md +++ b/generated/site/zh/guide/agent-workflow.md @@ -6,7 +6,7 @@ Deliver editable `.stack` source and, when rendering is available, an SVG. Prese ## 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 `. +Run `stack --version` and `stack help` before selecting commands. Use the installed binary's help, not unreleased repository instructions. This workflow is tested with published CLI 0.4.0 using `check`, `fmt`, and `render` without `--json` for compatibility. Before using additional options such as JSON output, 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. @@ -29,10 +29,10 @@ For a new diagram, start with the smallest complete source that preserves the re 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 +$ 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. diff --git a/generated/skills/stack-diagrams/SKILL.md b/generated/skills/stack-diagrams/SKILL.md index e48f3ed..1acb976 100644 --- a/generated/skills/stack-diagrams/SKILL.md +++ b/generated/skills/stack-diagrams/SKILL.md @@ -12,7 +12,7 @@ Deliver editable `.stack` source and, when rendering is available, an SVG. Prese ## 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 `. +Run `stack --version` and `stack help` before selecting commands. Use the installed binary's help, not unreleased repository instructions. This workflow is tested with published CLI 0.4.0 using `check`, `fmt`, and `render` without `--json` for compatibility. Before using additional options such as JSON output, 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. diff --git a/package.json b/package.json index 735a3f8..dcdf919 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,8 @@ "type": "module", "license": "Apache-2.0", "scripts": { + "release:check": "node scripts/cli-release.mjs", + "release:sync": "node scripts/cli-release.mjs --sync", "generate": "node scripts/generate.mjs", "check": "node scripts/generate.mjs --check", "test": "node --test scripts/*.test.mjs", diff --git a/scripts/cli-release.mjs b/scripts/cli-release.mjs new file mode 100644 index 0000000..e4df065 --- /dev/null +++ b/scripts/cli-release.mjs @@ -0,0 +1,64 @@ +import { readFile, writeFile } from "node:fs/promises" +import { fileURLToPath } from "node:url" +import path from "node:path" + +export function validateRelease(lock, release, revision) { + const errors = [] + if (release.draft || release.prerelease || !/^v\d+\.\d+\.\d+$/.test(release.tag_name)) { + errors.push("Expected a published stable CLI release") + } + if (release.tag_name !== `v${lock.version}`) { + errors.push( + `CLI release drift: docs ${lock.version}, latest ${release.tag_name}; run npm run release:sync`, + ) + } + if (revision !== lock.revision) + errors.push("CLI release tag commit differs from the documentation pin") + return errors +} + +export function synchronizeVersion(source, version) { + if (!/^\d+\.\d+\.\d+$/.test(version)) throw new Error("Invalid CLI version") + if (!/Stack CLI \d+\.\d+\.\d+/.test(source)) throw new Error("Missing CLI version declaration") + return source.replace(/Stack CLI \d+\.\d+\.\d+/g, `Stack CLI ${version}`) +} + +async function github(endpoint) { + const headers = { Accept: "application/vnd.github+json" } + if (process.env.GH_TOKEN) headers.Authorization = `Bearer ${process.env.GH_TOKEN}` + const response = await fetch(`https://api.github.com/repos/stack-sh/cli/${endpoint}`, { + headers, + signal: AbortSignal.timeout(15000), + }) + if (!response.ok) throw new Error(`GitHub ${endpoint}: HTTP ${response.status}`) + return response.json() +} + +export async function latestRelease() { + const release = await github("releases/latest") + if (release.draft || release.prerelease || !/^v\d+\.\d+\.\d+$/.test(release.tag_name)) { + throw new Error("Expected a published stable CLI release") + } + let { object } = await github(`git/ref/tags/${encodeURIComponent(release.tag_name)}`) + for (let depth = 0; object.type === "tag" && depth < 4; depth += 1) { + ;({ object } = await github(`git/tags/${object.sha}`)) + } + if (object.type !== "commit" || !/^[a-f0-9]{40}$/.test(object.sha)) { + throw new Error("CLI release tag does not resolve to a commit") + } + return { release, revision: object.sha } +} +async function main() { + const lockPath = new URL("../content/cli-release.json", import.meta.url) + const lock = JSON.parse(await readFile(lockPath, "utf8")) + const { release, revision } = await latestRelease() + if (process.argv.includes("--sync")) { + await writeFile(lockPath, JSON.stringify({ repository: "stack-sh/cli", revision, version: release.tag_name.slice(1) }, null, 2) + "\n") + const { generate } = await import("./generate.mjs") + await generate() + } else { + const errors = validateRelease(lock, release, revision) + if (errors.length) throw new Error(errors.join("\n")) + } +} +if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) await main() diff --git a/scripts/cli-release.test.mjs b/scripts/cli-release.test.mjs new file mode 100644 index 0000000..8bfc523 --- /dev/null +++ b/scripts/cli-release.test.mjs @@ -0,0 +1,30 @@ +import assert from "node:assert/strict" +import test from "node:test" +import { synchronizeVersion, validateRelease } from "./cli-release.mjs" + +const lock = { version: "0.4.0", revision: "a".repeat(40) } +const release = { tag_name: "v0.4.0", draft: false, prerelease: false } + +test("matches a published release and its exact commit", () => { + assert.deepEqual(validateRelease(lock, release, lock.revision), []) +}) +test("rejects a new release omitted from docs", () => { + assert.match( + validateRelease(lock, { ...release, tag_name: "v0.5.0" }, lock.revision).join(), + /release drift/, + ) +}) +test("rejects draft, prerelease, and retargeted tags", () => { + for (const field of ["draft", "prerelease"]) { + assert.ok(validateRelease(lock, { ...release, [field]: true }, lock.revision).length) + } + assert.ok(validateRelease(lock, release, "b".repeat(40)).length) +}) +test("updates all declarations without changing unrelated prose or versions", () => { + assert.equal( + synchronizeVersion("Stack CLI 0.3.0, Engine 0.7.0, Stack CLI 0.3.0", "0.4.0"), + "Stack CLI 0.4.0, Engine 0.7.0, Stack CLI 0.4.0", + ) + assert.throws(() => synchronizeVersion("No declaration", "0.4.0")) + assert.throws(() => synchronizeVersion("Stack CLI 0.3.0", "main")) +}) diff --git a/scripts/generate.mjs b/scripts/generate.mjs index 4cc7dd6..d1ce474 100644 --- a/scripts/generate.mjs +++ b/scripts/generate.mjs @@ -57,7 +57,7 @@ export async function generate(directory = root, check = false) { outputs[`site/${file}`] = rendered; } for (const locale of ['', 'ja/', 'zh/', 'ko/']) { - outputs[`site/${locale}guide/agent-workflow.md`] = outputs['guide/agent-workflow.md']; + outputs[`site/${locale}guide/agent-workflow.md`] = outputs['guide/agent-workflow.md'].replace(/```sh\n([\s\S]*?)```/g, (_, commands) => '```sh\n' + commands.trimEnd().split('\n').map(line => '$ ' + line).join('\n') + '\n```'); } } const manifest = { diff --git a/scripts/generate.test.mjs b/scripts/generate.test.mjs index 2415af0..ee4bf6d 100644 --- a/scripts/generate.test.mjs +++ b/scripts/generate.test.mjs @@ -73,7 +73,7 @@ test('all four locales expose the same page set and shared copyable instruction' 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(outputs[`site/${locale}guide/agent-workflow.md`].replace(/^\$ /gm, ''), outputs['guide/agent-workflow.md']); } assert.equal(Object.keys(outputs).filter(file => file.startsWith('site/')).length, 60); });