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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/release-freshness.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion content/agent-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <command>`.
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 <command>`.

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.

Expand Down
2 changes: 1 addition & 1 deletion generated/guide/agent-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <command>`.
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 <command>`.

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.

Expand Down
12 changes: 6 additions & 6 deletions generated/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
]
}
10 changes: 5 additions & 5 deletions generated/site/guide/agent-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <command>`.
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 <command>`.

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.

Expand All @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions generated/site/ja/guide/agent-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <command>`.
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 <command>`.

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.

Expand All @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions generated/site/ko/guide/agent-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <command>`.
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 <command>`.

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.

Expand All @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions generated/site/zh/guide/agent-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <command>`.
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 <command>`.

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.

Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion generated/skills/stack-diagrams/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <command>`.
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 <command>`.

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.

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
64 changes: 64 additions & 0 deletions scripts/cli-release.mjs
Original file line number Diff line number Diff line change
@@ -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()
30 changes: 30 additions & 0 deletions scripts/cli-release.test.mjs
Original file line number Diff line number Diff line change
@@ -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"))
})
2 changes: 1 addition & 1 deletion scripts/generate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Loading