diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e81f78e..cb43da2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,3 +61,27 @@ jobs: - name: Validate formatter fixtures run: python scripts/validate-formatter-fixtures.py + + language-package: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v7 + + - name: Set up Node.js + uses: actions/setup-node@v7 + with: + node-version: 24.18.0 + package-manager-cache: false + + - name: Install dependencies + run: npm ci + + - name: Test language assets + run: npm run test:language + + - name: Check package types + run: npm run typecheck:language + + - name: Verify package contents + run: npm run pack:check diff --git a/.github/workflows/release-language.yaml b/.github/workflows/release-language.yaml new file mode 100644 index 0000000..c1a275f --- /dev/null +++ b/.github/workflows/release-language.yaml @@ -0,0 +1,76 @@ +name: Release language package + +on: + release: + types: + - published + workflow_dispatch: + inputs: + release_tag: + description: Existing language package release tag to verify or resume + required: true + type: string + +env: + RELEASE_TAG: ${{ github.event.release.tag_name || inputs.release_tag }} + +permissions: + contents: read + id-token: write + +jobs: + npm: + name: npm + if: startsWith(github.event.release.tag_name || inputs.release_tag, 'language-v') + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v7 + with: + fetch-depth: 0 + ref: ${{ env.RELEASE_TAG }} + + - name: Set up Node.js + uses: actions/setup-node@v7 + with: + node-version: 24.18.0 + registry-url: https://registry.npmjs.org + package-manager-cache: false + + - name: Install trusted publishing npm CLI + run: npm install --global npm@11.5.1 + + - name: Install dependencies + run: npm ci + + - name: Verify release version + run: | + package_version=$(node --print "require('./packages/language/package.json').version") + test "$RELEASE_TAG" = "language-v$package_version" + release_commit=$(git rev-list --max-count=1 "$RELEASE_TAG") + test -n "$release_commit" + test "$(git rev-parse HEAD)" = "$release_commit" + git merge-base --is-ancestor "$release_commit" origin/main + + - name: Test language assets + run: npm run test:language + + - name: Check package types + run: npm run typecheck:language + + - name: Verify package contents + run: npm run pack:check + + - name: Check whether version is already published + id: package + run: | + package_version=$(node --print "require('./packages/language/package.json').version") + if npm view "@stack-sh/language@$package_version" version >/dev/null 2>&1; then + echo "published=true" >> "$GITHUB_OUTPUT" + else + echo "published=false" >> "$GITHUB_OUTPUT" + fi + + - name: Publish package + if: steps.package.outputs.published != 'true' + run: npm publish --workspace @stack-sh/language --access public diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2d98f97 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +*.tgz diff --git a/README.md b/README.md index c1e20af..f84897c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Stack is an opinionated DSL for describing software architecture and technology-stack diagrams. It is designed to be concise enough for humans and language models to write, while remaining constrained enough for renderers to produce consistently polished diagrams. -This repository is the canonical source for the Stack language. It defines the language contract; it does not contain a renderer, server, editor, or CLI. +This repository is the canonical source for the Stack language. It defines the language contract and distributes shared editor language assets; it does not contain a renderer, interactive editor, server, or CLI. ## Status @@ -16,8 +16,10 @@ The language is currently a proposal for Stack 1.0. No compatibility guarantee a - [ADR-0001: Adopt a constrained declarative topology language](./docs/decisions/0001-constrained-declarative-language.md) - [ADR-0002: Make the canonical theme catalog own icons](./docs/decisions/0002-theme-owned-icons.md) - [ADR-0003: Standardize compiler interchange and conformance fixtures](./docs/decisions/0003-standardize-compiler-interchange-and-conformance.md) +- [ADR-0004: Distribute shared editor language assets from the specification](./docs/decisions/0004-distribute-editor-language-assets.md) - [Examples](./examples) - [Conformance suite](./conformance) +- [`@stack-sh/language`](./packages/language) ## Example @@ -64,6 +66,9 @@ check-jsonschema --schemafile schemas/normalized-ir.schema.json conformance/vali find conformance -name expected.diagnostics.json -print0 | xargs -0 check-jsonschema --schemafile schemas/diagnostic-expectations.schema.json python scripts/validate-compiler-diagnostics.py python scripts/validate-formatter-fixtures.py +npm ci +npm run test:language +npm run pack:check ``` ## Design Principles diff --git a/docs/decisions/0004-distribute-editor-language-assets.md b/docs/decisions/0004-distribute-editor-language-assets.md new file mode 100644 index 0000000..d06d644 --- /dev/null +++ b/docs/decisions/0004-distribute-editor-language-assets.md @@ -0,0 +1,67 @@ +# ADR-0004: Distribute Shared Editor Language Assets from the Specification + +## Status + +Accepted + +## Date + +2026-09-03 + +## Context + +Stack source is edited in the browser playground today and may later appear in documentation code blocks, desktop editors, and IDE extensions. These consumers need consistent lexical classification for comments, strings, declarations, properties, enum values, operators, numbers, punctuation, and identifiers. + +A TextMate grammar is a presentation-oriented description of the language's lexical surface. It is useful to many editor integrations, but it cannot enforce Stack semantics and must not become a second language definition. Stack 1.0 also has contextual keywords, so lexical highlighting cannot always reproduce parser context. + +Placing the grammar in a future language-server repository would make editor presentation depend on a protocol server and encourage that server to own syntax. Placing separate copies in the Web and editor repositories would allow the copies to drift. + +## Decision + +The specification repository owns and tests shared editor language assets under `packages/language` and distributes them as the public `@stack-sh/language` npm package. + +The package contains: + +- a TextMate grammar with the stable root scope `source.stack`; +- a portable editor language configuration for comments, brackets, surrounding pairs, and identifier words; +- dependency-free JavaScript and TypeScript entry points for consuming those assets. + +The normative prose grammar in `SPECIFICATION.md` remains authoritative. The TextMate grammar follows that contract and only classifies source for presentation. Highlighting never establishes that a token or document is valid. + +The package does not depend on Shiki, an editor runtime, a theme, the Stack compiler, or an LSP implementation. Consumers select those integrations themselves and pin a released package version. + +The reference compiler continues to own parsing, semantic validation, structured diagnostics, source ranges, and normalized IR. A future language server will own LSP document lifecycle and protocol features such as completion, hover, navigation, and diagnostic publication. It will consume compiler capabilities and this package rather than defining a separate Stack grammar. + +## Alternatives Considered + +### Put the grammar in the Web repository + +- Pros: The first consumer can evolve quickly. +- Cons: Documentation and editor integrations must copy or depend on a product-specific repository. +- Rejected: The grammar represents shared language tooling, not Web UI behavior. + +### Put the grammar in a future LSP repository + +- Pros: Most editor-facing assets would be colocated. +- Cons: Syntax highlighting would depend organizationally on a protocol integration that does not yet exist, and non-LSP consumers would inherit that coupling. +- Rejected: The language server consumes the language contract; it does not own it. + +### Generate the grammar from the EBNF + +- Pros: Reduces duplicated keyword lists in principle. +- Cons: TextMate scopes, string recovery, and contextual-keyword approximation require presentation decisions that the normative EBNF does not express. +- Rejected for Stack 1.0: Tests and review provide a smaller and clearer synchronization mechanism. Generation can be reconsidered if the grammar grows substantially. + +### Publish a Shiki-specific package + +- Pros: Gives the Web consumer a ready-made highlighter. +- Cons: Couples shared language data to one runtime, theme strategy, and release cadence. +- Rejected: The package should remain usable by Shiki, VS Code-compatible tooling, and other TextMate consumers. + +## Consequences + +- Web, documentation, and editor integrations can share one versioned grammar. +- Grammar changes are reviewed beside language changes and can be tested with specification examples. +- Consumers must provide their own highlighter and visual theme. +- Contextual keywords may be highlighted as keywords even where the parser accepts them as identifiers; this is presentation behavior, not a semantic restriction. +- Compiler and language-server implementations must not use TextMate scopes as parser input. diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..f0d4cc2 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,947 @@ +{ + "name": "stack-language-specification", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "stack-language-specification", + "version": "0.0.0", + "workspaces": [ + "packages/*" + ], + "devDependencies": { + "@shikijs/core": "4.4.3", + "@shikijs/engine-javascript": "4.4.3", + "typescript": "7.0.2" + } + }, + "node_modules/@shikijs/core": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-4.4.3.tgz", + "integrity": "sha512-QCR4q2ZO/ILJEuwiBMel4wdcTDb1JGwfjKTxPDF6x8ixOaluPrVqIn06C99AcRPhmYlBR56d/Fb+GN58GzExpg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/primitive": "4.4.3", + "@shikijs/types": "4.4.3", + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.5", + "hast-util-to-html": "^9.0.5" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/engine-javascript": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-4.4.3.tgz", + "integrity": "sha512-FbOjFJp9VLdo1Wevs10BBtVxiTWwNLqZh5Gkhjgda/ioL15YOgeSl9n+6XMa3qRlPQzfhFNe641SrynFHYG0nQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.4.3", + "@shikijs/vscode-textmate": "^10.0.2", + "oniguruma-to-es": "^4.3.6" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/primitive": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/@shikijs/primitive/-/primitive-4.4.3.tgz", + "integrity": "sha512-m0wBeLDQDeIxRdUmrCPdQqfuUamDwRL5isCfYbguKD6NiaKpVbsv+3J81DyIKgNW5h4WAIIr8T4EkgQrBBxvaQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.4.3", + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.5" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/types": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-4.4.3.tgz", + "integrity": "sha512-UEJxmRR++MAGR6hugn0vgVS2W/6lWAts84FFSrnlH9sP0LNol7E5+NQ792pH8liWUhyMyjhTgSUH3k7iD7tc5g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.5" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/vscode-textmate": { + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.0.2.tgz", + "integrity": "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@stack-sh/language": { + "resolved": "packages/language", + "link": true + }, + "node_modules/@types/hast": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.5.tgz", + "integrity": "sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/@types/mdast": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", + "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/@typescript/typescript-aix-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz", + "integrity": "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-arm64/-/typescript-darwin-arm64-7.0.2.tgz", + "integrity": "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-x64/-/typescript-darwin-x64-7.0.2.tgz", + "integrity": "sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-arm64/-/typescript-freebsd-arm64-7.0.2.tgz", + "integrity": "sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-x64/-/typescript-freebsd-x64-7.0.2.tgz", + "integrity": "sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm/-/typescript-linux-arm-7.0.2.tgz", + "integrity": "sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm64/-/typescript-linux-arm64-7.0.2.tgz", + "integrity": "sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-loong64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-loong64/-/typescript-linux-loong64-7.0.2.tgz", + "integrity": "sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-mips64el": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-mips64el/-/typescript-linux-mips64el-7.0.2.tgz", + "integrity": "sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-ppc64/-/typescript-linux-ppc64-7.0.2.tgz", + "integrity": "sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-riscv64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-riscv64/-/typescript-linux-riscv64-7.0.2.tgz", + "integrity": "sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-s390x": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-s390x/-/typescript-linux-s390x-7.0.2.tgz", + "integrity": "sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-x64/-/typescript-linux-x64-7.0.2.tgz", + "integrity": "sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-arm64/-/typescript-netbsd-arm64-7.0.2.tgz", + "integrity": "sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-x64/-/typescript-netbsd-x64-7.0.2.tgz", + "integrity": "sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-arm64/-/typescript-openbsd-arm64-7.0.2.tgz", + "integrity": "sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-x64/-/typescript-openbsd-x64-7.0.2.tgz", + "integrity": "sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-sunos-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-sunos-x64/-/typescript-sunos-x64-7.0.2.tgz", + "integrity": "sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-arm64/-/typescript-win32-arm64-7.0.2.tgz", + "integrity": "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-x64/-/typescript-win32-x64-7.0.2.tgz", + "integrity": "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@ungap/structured-clone": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.4.0.tgz", + "integrity": "sha512-1mEZtMKPM09vDmQt5y7YvmN2+DFTP7Tg0EWXdic8/C6VRnpb33e4ghisCIE3WZjsE2N8mf+QV1Zqh7ZFYLWInQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/ccount": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz", + "integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-entities-html4": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz", + "integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-entities-legacy": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz", + "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/comma-separated-tokens": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz", + "integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/devlop": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz", + "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==", + "dev": true, + "license": "MIT", + "dependencies": { + "dequal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/hast-util-to-html": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.5.tgz", + "integrity": "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "ccount": "^2.0.0", + "comma-separated-tokens": "^2.0.0", + "hast-util-whitespace": "^3.0.0", + "html-void-elements": "^3.0.0", + "mdast-util-to-hast": "^13.0.0", + "property-information": "^7.0.0", + "space-separated-tokens": "^2.0.0", + "stringify-entities": "^4.0.0", + "zwitch": "^2.0.4" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-whitespace": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-3.0.0.tgz", + "integrity": "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/html-void-elements": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz", + "integrity": "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/mdast-util-to-hast": { + "version": "13.2.1", + "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.1.tgz", + "integrity": "sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "@ungap/structured-clone": "^1.0.0", + "devlop": "^1.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "trim-lines": "^3.0.0", + "unist-util-position": "^5.0.0", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-encode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", + "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-sanitize-uri": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", + "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/oniguruma-parser": { + "version": "0.12.2", + "resolved": "https://registry.npmjs.org/oniguruma-parser/-/oniguruma-parser-0.12.2.tgz", + "integrity": "sha512-6HVa5oIrgMC6aA6WF6XyyqbhRPJrKR02L20+2+zpDtO5QAzGHAUGw5TKQvwi5vctNnRHkJYmjAhRVQF2EKdTQw==", + "dev": true, + "license": "MIT" + }, + "node_modules/oniguruma-to-es": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/oniguruma-to-es/-/oniguruma-to-es-4.3.6.tgz", + "integrity": "sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA==", + "dev": true, + "license": "MIT", + "dependencies": { + "oniguruma-parser": "^0.12.2", + "regex": "^6.1.0", + "regex-recursion": "^6.0.2" + } + }, + "node_modules/property-information": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/property-information/-/property-information-7.2.0.tgz", + "integrity": "sha512-IAtzIB6sUiWaJYrX9smp3V46pBGbBeLFRGdh25kg1334VcBlD8HzhPeNIWQH9zhGmo2itIe25EHt9dQP7G5hmg==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/regex/-/regex-6.1.0.tgz", + "integrity": "sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==", + "dev": true, + "license": "MIT", + "dependencies": { + "regex-utilities": "^2.3.0" + } + }, + "node_modules/regex-recursion": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/regex-recursion/-/regex-recursion-6.0.2.tgz", + "integrity": "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==", + "dev": true, + "license": "MIT", + "dependencies": { + "regex-utilities": "^2.3.0" + } + }, + "node_modules/regex-utilities": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/regex-utilities/-/regex-utilities-2.3.0.tgz", + "integrity": "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==", + "dev": true, + "license": "MIT" + }, + "node_modules/space-separated-tokens": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz", + "integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/stringify-entities": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz", + "integrity": "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==", + "dev": true, + "license": "MIT", + "dependencies": { + "character-entities-html4": "^2.0.0", + "character-entities-legacy": "^3.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/trim-lines": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz", + "integrity": "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/typescript": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-7.0.2.tgz", + "integrity": "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc" + }, + "engines": { + "node": ">=16.20.0" + }, + "optionalDependencies": { + "@typescript/typescript-aix-ppc64": "7.0.2", + "@typescript/typescript-darwin-arm64": "7.0.2", + "@typescript/typescript-darwin-x64": "7.0.2", + "@typescript/typescript-freebsd-arm64": "7.0.2", + "@typescript/typescript-freebsd-x64": "7.0.2", + "@typescript/typescript-linux-arm": "7.0.2", + "@typescript/typescript-linux-arm64": "7.0.2", + "@typescript/typescript-linux-loong64": "7.0.2", + "@typescript/typescript-linux-mips64el": "7.0.2", + "@typescript/typescript-linux-ppc64": "7.0.2", + "@typescript/typescript-linux-riscv64": "7.0.2", + "@typescript/typescript-linux-s390x": "7.0.2", + "@typescript/typescript-linux-x64": "7.0.2", + "@typescript/typescript-netbsd-arm64": "7.0.2", + "@typescript/typescript-netbsd-x64": "7.0.2", + "@typescript/typescript-openbsd-arm64": "7.0.2", + "@typescript/typescript-openbsd-x64": "7.0.2", + "@typescript/typescript-sunos-x64": "7.0.2", + "@typescript/typescript-win32-arm64": "7.0.2", + "@typescript/typescript-win32-x64": "7.0.2" + } + }, + "node_modules/unist-util-is": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.1.tgz", + "integrity": "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-position": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz", + "integrity": "sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-stringify-position": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", + "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-visit": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.1.0.tgz", + "integrity": "sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0", + "unist-util-visit-parents": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-visit-parents": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.2.tgz", + "integrity": "sha512-goh1s1TBrqSqukSc8wrjwWhL0hiJxgA8m4kFxGlQ+8FYQ3C/m11FcTs4YYem7V664AhHVvgoQLk890Ssdsr2IQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/vfile": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz", + "integrity": "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "vfile-message": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/vfile-message": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.3.tgz", + "integrity": "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-stringify-position": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/zwitch": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz", + "integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "packages/language": { + "name": "@stack-sh/language", + "version": "0.1.0", + "license": "Apache-2.0" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..895d9c2 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "stack-language-specification", + "version": "0.0.0", + "private": true, + "workspaces": [ + "packages/*" + ], + "type": "module", + "scripts": { + "test:language": "npm test --workspace @stack-sh/language", + "typecheck:language": "npm run typecheck --workspace @stack-sh/language", + "pack:check": "npm run pack:check --workspace @stack-sh/language" + }, + "devDependencies": { + "@shikijs/core": "4.4.3", + "@shikijs/engine-javascript": "4.4.3", + "typescript": "7.0.2" + } +} diff --git a/packages/language/LICENSE b/packages/language/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/packages/language/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/language/README.md b/packages/language/README.md new file mode 100644 index 0000000..53a5404 --- /dev/null +++ b/packages/language/README.md @@ -0,0 +1,33 @@ +# `@stack-sh/language` + +Editor language assets for the [Stack diagram language](https://github.com/stack-sh/specification). + +The package contains the shared TextMate grammar and editor language configuration. It deliberately has no runtime dependency on a syntax highlighter, editor, theme, compiler, or language server. + +## Usage with Shiki + +```js +import { createHighlighterCore } from "shiki/core"; +import { createJavaScriptRegexEngine } from "shiki/engine/javascript"; +import githubLight from "@shikijs/themes/github-light"; +import { stackLanguage } from "@stack-sh/language"; + +const highlighter = await createHighlighterCore({ + themes: [githubLight], + langs: [stackLanguage], + engine: createJavaScriptRegexEngine(), +}); + +const html = highlighter.codeToHtml(source, { + lang: "stack", + theme: "github-light", +}); +``` + +Raw JSON assets are also exported as `@stack-sh/language/grammar` and `@stack-sh/language/language-configuration`. + +## Boundaries + +TextMate scopes classify source for presentation. They do not determine whether a document is valid. Use the Stack compiler or engine for parsing and diagnostics. + +Stack 1.0 keywords are contextual, so a keyword remains legal where an identifier is expected. The lexical grammar highlights keyword-shaped tokens consistently without attempting to reproduce parser context. diff --git a/packages/language/grammar.d.ts b/packages/language/grammar.d.ts new file mode 100644 index 0000000..970dcbe --- /dev/null +++ b/packages/language/grammar.d.ts @@ -0,0 +1,5 @@ +import type { StackLanguageGrammar } from "./index.js"; + +declare const grammar: StackLanguageGrammar; + +export default grammar; diff --git a/packages/language/grammars/stack.tmLanguage.json b/packages/language/grammars/stack.tmLanguage.json new file mode 100644 index 0000000..dcf5ee9 --- /dev/null +++ b/packages/language/grammars/stack.tmLanguage.json @@ -0,0 +1,108 @@ +{ + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "name": "stack", + "scopeName": "source.stack", + "fileTypes": ["stack"], + "patterns": [ + { "include": "#comments" }, + { "include": "#strings" }, + { "include": "#declarations" }, + { "include": "#properties" }, + { "include": "#values" }, + { "include": "#operators" }, + { "include": "#numbers" }, + { "include": "#punctuation" }, + { "include": "#identifiers" } + ], + "repository": { + "comments": { + "patterns": [ + { + "name": "comment.line.double-slash.stack", + "match": "//.*$" + } + ] + }, + "strings": { + "patterns": [ + { + "name": "string.quoted.double.stack", + "begin": "\"", + "beginCaptures": { + "0": { "name": "punctuation.definition.string.begin.stack" } + }, + "end": "\"|$", + "endCaptures": { + "0": { "name": "punctuation.definition.string.end.stack" } + }, + "patterns": [ + { + "name": "constant.character.escape.stack", + "match": "\\\\(?:[\"\\\\]|u[0-9A-Fa-f]{4})" + }, + { + "name": "invalid.illegal.escape.stack", + "match": "\\\\." + } + ] + } + ] + }, + "declarations": { + "patterns": [ + { + "name": "keyword.control.declaration.stack", + "match": "(?|->|--" + } + ] + }, + "numbers": { + "patterns": [ + { + "name": "constant.numeric.integer.stack", + "match": "(?>; + readonly endCaptures?: Readonly>; + readonly patterns?: readonly TextMateRule[]; +} + +export interface StackLanguageGrammar { + readonly $schema?: string; + readonly name: "stack"; + readonly scopeName: "source.stack"; + readonly fileTypes: readonly ["stack"]; + readonly patterns: readonly TextMateRule[]; + readonly repository: Readonly>; +} + +export interface LanguagePair { + readonly open: string; + readonly close: string; + readonly notIn?: readonly string[]; +} + +export interface StackLanguageConfiguration { + readonly comments: { + readonly lineComment: "//"; + }; + readonly brackets: readonly (readonly [string, string])[]; + readonly autoClosingPairs: readonly LanguagePair[]; + readonly surroundingPairs: readonly (readonly [string, string])[]; + readonly wordPattern: string; +} + +export declare const stackLanguage: StackLanguageGrammar; +export declare const languageConfiguration: StackLanguageConfiguration; + +export default stackLanguage; diff --git a/packages/language/index.js b/packages/language/index.js new file mode 100644 index 0000000..9d25c09 --- /dev/null +++ b/packages/language/index.js @@ -0,0 +1,7 @@ +import grammar from "./grammars/stack.tmLanguage.json" with { type: "json" }; +import configuration from "./language-configuration.json" with { type: "json" }; + +export const stackLanguage = grammar; +export const languageConfiguration = configuration; + +export default stackLanguage; diff --git a/packages/language/language-configuration.d.ts b/packages/language/language-configuration.d.ts new file mode 100644 index 0000000..a035889 --- /dev/null +++ b/packages/language/language-configuration.d.ts @@ -0,0 +1,5 @@ +import type { StackLanguageConfiguration } from "./index.js"; + +declare const languageConfiguration: StackLanguageConfiguration; + +export default languageConfiguration; diff --git a/packages/language/language-configuration.json b/packages/language/language-configuration.json new file mode 100644 index 0000000..d8838fe --- /dev/null +++ b/packages/language/language-configuration.json @@ -0,0 +1,20 @@ +{ + "comments": { + "lineComment": "//" + }, + "brackets": [ + ["{", "}"], + ["[", "]"] + ], + "autoClosingPairs": [ + { "open": "{", "close": "}" }, + { "open": "[", "close": "]" }, + { "open": "\"", "close": "\"", "notIn": ["string", "comment"] } + ], + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["\"", "\""] + ], + "wordPattern": "[a-z][a-z0-9_-]*" +} diff --git a/packages/language/package.json b/packages/language/package.json new file mode 100644 index 0000000..c611989 --- /dev/null +++ b/packages/language/package.json @@ -0,0 +1,47 @@ +{ + "name": "@stack-sh/language", + "version": "0.1.0", + "description": "Editor language assets for the Stack diagram language", + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "git+https://github.com/stack-sh/specification.git", + "directory": "packages/language" + }, + "files": [ + "grammar.d.ts", + "grammars", + "index.d.ts", + "index.js", + "language-configuration.d.ts", + "language-configuration.json", + "README.md" + ], + "type": "module", + "sideEffects": false, + "types": "./index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./index.js", + "default": "./index.js" + }, + "./grammar": { + "types": "./grammar.d.ts", + "default": "./grammars/stack.tmLanguage.json" + }, + "./language-configuration": { + "types": "./language-configuration.d.ts", + "default": "./language-configuration.json" + }, + "./package.json": "./package.json" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "node --test test/*.test.js", + "typecheck": "tsc --project tsconfig.json", + "pack:check": "node scripts/check-package.mjs" + } +} diff --git a/packages/language/scripts/check-package.mjs b/packages/language/scripts/check-package.mjs new file mode 100644 index 0000000..b0cde51 --- /dev/null +++ b/packages/language/scripts/check-package.mjs @@ -0,0 +1,27 @@ +import assert from "node:assert/strict"; +import { execFile } from "node:child_process"; +import { promisify } from "node:util"; + +const execFileAsync = promisify(execFile); + +const { stdout } = await execFileAsync("npm", ["pack", "--json", "--dry-run"], { + cwd: new URL("..", import.meta.url), +}); +const result = JSON.parse(stdout); +const pack = Array.isArray(result) ? result[0] : result; +const actual = pack.files.map(({ path }) => path).sort(); +const expected = [ + "LICENSE", + "README.md", + "grammar.d.ts", + "grammars/stack.tmLanguage.json", + "index.d.ts", + "index.js", + "language-configuration.d.ts", + "language-configuration.json", + "package.json", +].sort(); + +assert.deepEqual(actual, expected); +assert.equal(pack.name, "@stack-sh/language"); +assert.equal(pack.version, "0.1.0"); diff --git a/packages/language/test/grammar.test.js b/packages/language/test/grammar.test.js new file mode 100644 index 0000000..f199aaf --- /dev/null +++ b/packages/language/test/grammar.test.js @@ -0,0 +1,197 @@ +import assert from "node:assert/strict"; +import { readFile } from "node:fs/promises"; +import test from "node:test"; + +import { createHighlighterCore } from "@shikijs/core"; +import { createJavaScriptRegexEngine } from "@shikijs/engine-javascript"; + +import { languageConfiguration, stackLanguage } from "@stack-sh/language"; +import rawGrammar from "@stack-sh/language/grammar" with { type: "json" }; +import rawLanguageConfiguration from "@stack-sh/language/language-configuration" with { type: "json" }; + +const colors = { + comment: "#110001", + declaration: "#220002", + property: "#330003", + value: "#440004", + string: "#550005", + escape: "#660006", + invalid: "#770007", + number: "#880008", + operator: "#990009", + punctuation: "#AA000A", + identifier: "#BB000B", +}; + +const testTheme = { + name: "stack-test", + type: "light", + colors: { + "editor.background": "#ffffff", + "editor.foreground": "#000000", + }, + tokenColors: [ + { + scope: "comment.line.double-slash.stack", + settings: { foreground: colors.comment }, + }, + { + scope: "keyword.control.declaration.stack", + settings: { foreground: colors.declaration }, + }, + { + scope: "keyword.other.property.stack", + settings: { foreground: colors.property }, + }, + { + scope: "constant.language.stack", + settings: { foreground: colors.value }, + }, + { + scope: "string.quoted.double.stack", + settings: { foreground: colors.string }, + }, + { + scope: "constant.character.escape.stack", + settings: { foreground: colors.escape }, + }, + { + scope: "invalid.illegal.escape.stack", + settings: { foreground: colors.invalid }, + }, + { + scope: "constant.numeric.integer.stack", + settings: { foreground: colors.number }, + }, + { + scope: "keyword.operator.edge.stack", + settings: { foreground: colors.operator }, + }, + { + scope: "punctuation.stack", + settings: { foreground: colors.punctuation }, + }, + { + scope: "variable.other.identifier.stack", + settings: { foreground: colors.identifier }, + }, + ], +}; + +function findToken(lines, lineIndex, content) { + const token = lines[lineIndex].find((candidate) => candidate.content === content); + assert.ok(token, `expected token ${JSON.stringify(content)} on line ${lineIndex + 1}`); + return token; +} + +function createTestHighlighter() { + return createHighlighterCore({ + themes: [testTheme], + langs: [stackLanguage], + engine: createJavaScriptRegexEngine(), + }); +} + +test("exports portable editor metadata", () => { + assert.equal(stackLanguage.name, "stack"); + assert.deepEqual(rawGrammar, stackLanguage); + assert.equal(stackLanguage.scopeName, "source.stack"); + assert.deepEqual(stackLanguage.fileTypes, ["stack"]); + assert.equal(languageConfiguration.comments.lineComment, "//"); + assert.deepEqual(rawLanguageConfiguration, languageConfiguration); + assert.deepEqual(languageConfiguration.brackets, [ + ["{", "}"], + ["[", "]"], + ]); +}); + +test("tokenizes Stack syntax with the pure JavaScript regex engine", async () => { + const highlighter = await createTestHighlighter(); + + const source = `stack 1.0 +diagram "Checkout" { + // contextual keywords remain legal identifiers + node api-service "Checkout API" { + kind service + detail "handles \\u2713 and invalid \\q" + } + edge client -> api-service "HTTPS" + layout { direction right } +}`; + const lines = highlighter.codeToTokensBase(source, { + lang: "stack", + theme: "stack-test", + }); + + assert.equal(findToken(lines, 0, "stack").color, colors.declaration); + assert.equal(findToken(lines, 0, "1").color, colors.number); + assert.equal(findToken(lines, 0, ".").color, colors.punctuation); + assert.equal(findToken(lines, 1, "diagram").color, colors.declaration); + assert.equal(findToken(lines, 1, '"Checkout"').color, colors.string); + assert.equal( + findToken(lines, 2, "// contextual keywords remain legal identifiers").color, + colors.comment, + ); + assert.equal(findToken(lines, 3, "api-service").color, colors.identifier); + assert.equal(findToken(lines, 4, "kind").color, colors.property); + assert.equal(findToken(lines, 4, "service").color, colors.value); + assert.equal(findToken(lines, 5, "\\u2713").color, colors.escape); + assert.equal(findToken(lines, 5, "\\q").color, colors.invalid); + assert.equal(findToken(lines, 7, "->").color, colors.operator); + assert.equal(findToken(lines, 8, "direction").color, colors.property); + assert.equal(findToken(lines, 8, "right").color, colors.value); + + highlighter.dispose(); +}); + +test("classifies every contextual keyword declared by Stack 1.0", async () => { + const expected = new Map([ + ...["stack", "diagram", "group", "node", "edge", "theme", "layout"].map((word) => [ + word, + colors.declaration, + ]), + ...["kind", "icon", "detail", "direction", "rank", "same", "order"].map((word) => [ + word, + colors.property, + ]), + ...[ + "right", + "down", + "actor", + "client", + "service", + "function", + "worker", + "database", + "cache", + "queue", + "storage", + "external", + "flow", + "request", + "event", + "data", + "dependency", + ].map((word) => [word, colors.value]), + ]); + const specification = await readFile( + new URL("../../../SPECIFICATION.md", import.meta.url), + "utf8", + ); + const keywordSection = specification.match( + /### 5\.1 Contextual Keywords[\s\S]*?```text\n([^`]+)```/, + ); + assert.ok(keywordSection, "expected the Stack 1.0 contextual keyword list"); + const normativeKeywords = keywordSection[1].trim().split(/\s+/).sort(); + assert.deepEqual([...expected.keys()].sort(), normativeKeywords); + + const highlighter = await createTestHighlighter(); + for (const [word, color] of expected) { + const lines = highlighter.codeToTokensBase(word, { + lang: "stack", + theme: "stack-test", + }); + assert.equal(findToken(lines, 0, word).color, color, word); + } + highlighter.dispose(); +}); diff --git a/packages/language/test/types.ts b/packages/language/test/types.ts new file mode 100644 index 0000000..fde11da --- /dev/null +++ b/packages/language/test/types.ts @@ -0,0 +1,17 @@ +import stackLanguage, { + languageConfiguration, + type StackLanguageConfiguration, + type StackLanguageGrammar, +} from "@stack-sh/language"; +import rawGrammar from "@stack-sh/language/grammar"; +import rawLanguageConfiguration from "@stack-sh/language/language-configuration"; + +const grammar: StackLanguageGrammar = stackLanguage; +const configuration: StackLanguageConfiguration = languageConfiguration; +const scopeName: "source.stack" = rawGrammar.scopeName; +const lineComment: "//" = rawLanguageConfiguration.comments.lineComment; + +void grammar; +void configuration; +void scopeName; +void lineComment; diff --git a/packages/language/tsconfig.json b/packages/language/tsconfig.json new file mode 100644 index 0000000..e21bab0 --- /dev/null +++ b/packages/language/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "module": "ESNext", + "moduleResolution": "Bundler", + "noEmit": true, + "strict": true, + "target": "ES2022" + }, + "include": ["test/types.ts"] +}