From cdea43948734fca1222ad42157583269df5b60a3 Mon Sep 17 00:00:00 2001 From: Klaus Kneupner Date: Sun, 22 Nov 2026 14:48:57 +0100 Subject: [PATCH 1/2] refactor: move the MCP servers to their own repository The Swift servers, the npm host, the Dockerfile and their scripts now live in Vithanco/vgraph-mcp, cloned to vgraph-mcp/ and built against this checkout like the plugins. `just mcp ` runs its justfile; release and publish-all drive it. Why: ADR 0040. Co-Authored-By: Claude Opus 5.5 --- .coderabbit.yaml | 21 +- .dockerignore | 57 - .gcloudignore | 16 - .github/CODEOWNERS | 5 +- .github/dependabot.yml | 1 - .github/workflows/ci.yml | 15 +- .gitignore | 4 + AGENTS.md | 9 +- CONTRIBUTING.md | 4 +- Dockerfile | 76 - Package.resolved | 65 +- Package.swift | 92 +- README.md | 4 +- SECURITY.md | 3 +- Sources/VGraphMCP/VGraphMCPServer.swift | 61 - .../VGraphMCPHTTP/VGraphMCPHTTPServer.swift | 21 - Sources/VGraphMCPHTTPKit/HostedServer.swift | 63 - Sources/VGraphMCPHTTPKit/MCPHTTPApp.swift | 320 --- Sources/VGraphMCPTools/CLDTool.swift | 131 - Sources/VGraphMCPTools/ConceptMapTool.swift | 206 -- Sources/VGraphMCPTools/DecomposeTool.swift | 74 - .../VGraphMCPTools/DescribeNotationTool.swift | 81 - Sources/VGraphMCPTools/IBISTool.swift | 123 - .../VGraphMCPTools/MCPInfrastructure.swift | 48 - Sources/VGraphMCPTools/MCPLimits.swift | 42 - Sources/VGraphMCPTools/PNGConverter.swift | 243 -- Sources/VGraphMCPTools/TimelineTool.swift | 182 -- Sources/VGraphMCPTools/VGraphTool.swift | 175 -- Tests/AppTests/ArchitectureTest.swift | 6 +- .../DockerIntegrationTests.swift | 112 - .../IntegrationTests/LogPolicyDocsTests.swift | 10 - Tests/VGraph-Package.xctestplan | 7 - .../VGraphMCPHTTPTests/HTTPLimitsTests.swift | 227 -- .../VGraphMCPHTTPTests/InitializeTests.swift | 44 - Tests/VGraphMCPHTTPTests/RequestIDTests.swift | 142 - .../VGraphMCPTests/DecomposeLimitTests.swift | 109 - Tests/VGraphMCPTests/DecomposeToolTests.swift | 56 - .../DescribeNotationToolTests.swift | 110 - Tests/VGraphMCPTests/LimitsTests.swift | 300 -- Tests/VGraphMCPTests/LoggingTests.swift | 214 -- Tests/VGraphMCPTests/ViewsRenderTests.swift | 69 - VGraphWasm/Package.resolved | 18 - ...eleases-stay-on-the-maintainers-machine.md | 7 +- ...cp-servers-live-in-their-own-repository.md | 55 + docs/hexagonal-architecture.md | 2 +- docs/mcp-hardening.md | 79 - docs/releasing.md | 42 +- docs/where-things-live.md | 9 +- fonts/README.md | 4 +- justfile | 318 +-- plugins.json | 5 +- scripts/check-generated.sh | 34 - scripts/check-generated.test.sh | 44 - scripts/check-plugin-api.sh | 4 +- scripts/codeowners.test.sh | 5 - scripts/dump-mcp-tools.sh | 60 - scripts/justfile-hygiene.test.sh | 5 +- scripts/mcp-registry.sh | 66 - scripts/mcp-registry.test.sh | 93 - scripts/plugins-release.test.sh | 24 +- scripts/publish-plugins.test.sh | 20 +- scripts/release-stamp.sh | 6 +- scripts/release-stamp.test.sh | 13 +- vgraph-mcp-node/.gitignore | 8 - vgraph-mcp-node/LICENSE | 201 -- vgraph-mcp-node/NOTICE | 59 - vgraph-mcp-node/README.md | 80 - vgraph-mcp-node/package-lock.json | 2466 ----------------- vgraph-mcp-node/package.json | 55 - vgraph-mcp-node/release.sh | 110 - vgraph-mcp-node/server.json | 27 - vgraph-mcp-node/src/png.mjs | 62 - vgraph-mcp-node/src/render.mjs | 66 - vgraph-mcp-node/src/server.mjs | 70 - vgraph-mcp-node/src/wasm-host.mjs | 32 - vgraph-mcp-node/test/png.test.mjs | 62 - vgraph-mcp-node/test/render.test.mjs | 50 - vgraph-mcp-node/tools.json | 127 - 78 files changed, 194 insertions(+), 7742 deletions(-) delete mode 100644 .dockerignore delete mode 100644 .gcloudignore delete mode 100644 Dockerfile delete mode 100644 Sources/VGraphMCP/VGraphMCPServer.swift delete mode 100644 Sources/VGraphMCPHTTP/VGraphMCPHTTPServer.swift delete mode 100644 Sources/VGraphMCPHTTPKit/HostedServer.swift delete mode 100644 Sources/VGraphMCPHTTPKit/MCPHTTPApp.swift delete mode 100644 Sources/VGraphMCPTools/CLDTool.swift delete mode 100644 Sources/VGraphMCPTools/ConceptMapTool.swift delete mode 100644 Sources/VGraphMCPTools/DecomposeTool.swift delete mode 100644 Sources/VGraphMCPTools/DescribeNotationTool.swift delete mode 100644 Sources/VGraphMCPTools/IBISTool.swift delete mode 100644 Sources/VGraphMCPTools/MCPInfrastructure.swift delete mode 100644 Sources/VGraphMCPTools/MCPLimits.swift delete mode 100644 Sources/VGraphMCPTools/PNGConverter.swift delete mode 100644 Sources/VGraphMCPTools/TimelineTool.swift delete mode 100644 Sources/VGraphMCPTools/VGraphTool.swift delete mode 100644 Tests/IntegrationTests/DockerIntegrationTests.swift delete mode 100644 Tests/VGraphMCPHTTPTests/HTTPLimitsTests.swift delete mode 100644 Tests/VGraphMCPHTTPTests/InitializeTests.swift delete mode 100644 Tests/VGraphMCPHTTPTests/RequestIDTests.swift delete mode 100644 Tests/VGraphMCPTests/DecomposeLimitTests.swift delete mode 100644 Tests/VGraphMCPTests/DecomposeToolTests.swift delete mode 100644 Tests/VGraphMCPTests/DescribeNotationToolTests.swift delete mode 100644 Tests/VGraphMCPTests/LimitsTests.swift delete mode 100644 Tests/VGraphMCPTests/LoggingTests.swift delete mode 100644 Tests/VGraphMCPTests/ViewsRenderTests.swift create mode 100644 docs/adr/0040-the-mcp-servers-live-in-their-own-repository.md delete mode 100644 docs/mcp-hardening.md delete mode 100755 scripts/check-generated.sh delete mode 100755 scripts/check-generated.test.sh delete mode 100755 scripts/dump-mcp-tools.sh delete mode 100755 scripts/mcp-registry.sh delete mode 100755 scripts/mcp-registry.test.sh delete mode 100644 vgraph-mcp-node/.gitignore delete mode 100644 vgraph-mcp-node/LICENSE delete mode 100644 vgraph-mcp-node/NOTICE delete mode 100644 vgraph-mcp-node/README.md delete mode 100644 vgraph-mcp-node/package-lock.json delete mode 100644 vgraph-mcp-node/package.json delete mode 100755 vgraph-mcp-node/release.sh delete mode 100644 vgraph-mcp-node/server.json delete mode 100644 vgraph-mcp-node/src/png.mjs delete mode 100644 vgraph-mcp-node/src/render.mjs delete mode 100644 vgraph-mcp-node/src/server.mjs delete mode 100644 vgraph-mcp-node/src/wasm-host.mjs delete mode 100644 vgraph-mcp-node/test/png.test.mjs delete mode 100644 vgraph-mcp-node/test/render.test.mjs delete mode 100644 vgraph-mcp-node/tools.json diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 84984cc..21c5737 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -46,17 +46,10 @@ reviews: `gvFreeLayout`/`agclose`, reading layout data when `gvLayout` failed, and C strings that die before Graphviz copies them. Graphviz uses 72 points per inch and returns node sizes in inches; flag mixed-up units. - - path: "{Sources/VGraphMCP,Sources/VGraphMCPHTTP,Sources/VGraphMCPHTTPKit,Sources/VGraphMCPTools}/**/*.swift" - instructions: | - The hosted MCP endpoint is open to anyone (SECURITY.md, docs/mcp-hardening.md). - Layout cannot be cancelled, so every input must be bounded before layout through - `MCPLimits`. Flag a new tool or parameter that reaches layout or PNG conversion - without a limit, unbounded subprocess output or runtime, and error messages that - leak paths or internals. Foundation and key paths are fine here. - path: "VGraphWasm/**/*.swift" instructions: | Embedded Swift rules apply. `@JS public func` in VGraphWasm/Sources/Main.swift is - the API the Obsidian and VS Code plugins and vgraph-mcp-node call; a removed or + the API the Obsidian and VS Code plugins and the vgraph-mcp npm host call; a removed or renamed export breaks them silently (scripts/check-plugin-api.sh). DOM code stays in VGraphEditor; decisions belong in EditorCore so they can be tested natively. - path: "Tests/**/*.swift" @@ -64,11 +57,10 @@ reviews: Tests come before the fix or feature, so a bug-fix PR should add a test that fails without it. Prefer asserting on real output (SVG, layout values) over "does not crash". A changed snapshot under __Snapshots__ needs a reason in the PR. - - path: "{VGraphWasm/Tests-JS,VGraphWasm/Tests-Browser,vgraph-mcp-node}/**/*.{js,mjs}" + - path: "{VGraphWasm/Tests-JS,VGraphWasm/Tests-Browser}/**/*.{js,mjs}" instructions: | Browser tests run in Chromium and WebKit (the iPad project); flag waits on fixed - timeouts instead of conditions. vgraph-mcp-node hosts the wasm engine and must - call only exports that Main.swift still declares. + timeouts instead of conditions. - path: "{**/*.sh,justfile}" instructions: | Shell is written for the maintainer's macOS (bash 3.2, BSD tools) and must also @@ -83,11 +75,6 @@ reviews: minimal, every download is verified by checksum, and `pull_request_target` is never used. Nothing is published from CI; releases stay on the maintainer's machine, so no publish secret may appear here. - - path: "{Dockerfile,deploy.sh,.dockerignore,.gcloudignore}" - instructions: | - The image serves the public MCP endpoint on Cloud Run. It runs as a non-root - user; flag anything that adds secrets to the image, widens what gets copied in, - or unpins a base image or download. - path: "{GLOSSARY.md,docs/adr/**}" instructions: | GLOSSARY.md is the glossary; a new term should not duplicate one listed under @@ -118,7 +105,7 @@ reviews: Fail if a `@JS public func` in VGraphWasm/Sources/Main.swift is removed or renamed, or its parameters or return type change, and the PR description does not name the affected consumers (obsidian-vithanco, vscode-vithanco, - vgraph-mcp-node) and say how they are updated. Additions do not count. + vgraph-mcp) and say how they are updated. Additions do not count. - name: "ADR conflicts are explicit" mode: warning instructions: | diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 1803c3a..0000000 --- a/.dockerignore +++ /dev/null @@ -1,57 +0,0 @@ -# Build artifacts -.build/ -/WASM/.build/ -/Packages -xcuserdata/ -DerivedData/ -.swiftpm/configuration/registries.json -.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata - -# macOS files -.DS_Store - -# Git -.git/ -.gitignore - -# Documentation and planning -*.md -ADDING_SF_SYMBOLS.md -.plan.md -INTEGRATION_COMPLETE.md -PLAN.md - -# Directories not needed for Docker build -docs/ -website/ -graphics/ -VGraphWasm/ - -# Generated files -test_output.swift -/*.vgl -/*.dot -/*.svg -/*.xdot -*.tar -*.tar.gz - -# Configuration -.netrc -.claude/ -settings.local.json - -# Scripts not needed in build context -deploy-to-website.sh -docker.sh - -# Website build artifacts -/website/Package -contents.xcworkspacedata - -# IDE files -.vscode/ -.idea/ -*.swp -*.swo -*~ diff --git a/.gcloudignore b/.gcloudignore deleted file mode 100644 index 7adb49b..0000000 --- a/.gcloudignore +++ /dev/null @@ -1,16 +0,0 @@ -# Cloud Build: only upload what the Dockerfile needs -.build/ -.claude/ -.git/ -.gitignore -.swiftpm/ -VGraphWasm/ -website/ -docs/ -mapping-skills/ -*.tar.gz -*.wasm -node_modules/ -package.json -package-lock.json -yarn.lock diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 2776e94..ffa9b0b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -17,13 +17,10 @@ /.github/ @Vithanco /.githooks/ @Vithanco -# The task runner, scripts and the build context of the images. +# The task runner and scripts. /justfile @Vithanco /scripts/ @Vithanco *.sh @Vithanco -/Dockerfile @Vithanco -/.dockerignore @Vithanco -/.gcloudignore @Vithanco # Manifests run code when a package is resolved or built, and pin what it fetches. Package.swift @Vithanco diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 974acd6..e3bd846 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,7 +9,6 @@ updates: - package-ecosystem: "npm" directories: - "/" - - "/vgraph-mcp-node" - "/VGraphWasm/Tests-JS" - "/VGraphWasm/Tests-Browser" schedule: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f141f91..4a5702a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,18 +43,7 @@ jobs: tar -xzf "$JUST" -C /usr/local/bin just - run: just lint - run: swift build --build-tests - # A stale generated file fails the pull request that made it stale, not - # the next release. Root in the container does not own the checkout. - - name: Generated files are up to date - run: | - apt-get install -y --no-install-recommends python3 - git config --global --add safe.directory "$GITHUB_WORKSPACE" - ./scripts/check-generated.sh - # The PNG tests convert with rsvg-convert, as the server image does. - - run: apt-get install -y --no-install-recommends librsvg2-bin fontconfig fonts-liberation - # These two assume Linux means "inside the server image", and describe an - # image that does not exist: it has no dot and runs as root. - - run: swift test --skip-build --skip 'DockerIntegrationTests/test(DockerBuildSucceeds|NonRootUserExecution)' + - run: swift test --skip-build wasm: # Builds and tests the wasm; it publishes nothing. Releases stay on the @@ -136,7 +125,7 @@ jobs: - name: Shell tests run: | failed=0 - for t in check-wasm-optimized justfile-hygiene doctor-kegs doctor-sdk codeowners licence audit-public record-engine-build publish-plugins mcp-registry release-stamp ci-status check-generated; do + for t in check-wasm-optimized justfile-hygiene doctor-kegs doctor-sdk codeowners licence audit-public record-engine-build publish-plugins release-stamp ci-status; do echo "::group::$t" ./scripts/$t.test.sh || failed=1 echo "::endgroup::" diff --git a/.gitignore b/.gitignore index 7ca8dab..2638037 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,10 @@ SmokeWasm/ obsidian-vithanco/ vscode-vithanco/ +# The MCP servers (Swift stdio + HTTP, and the npm host) — an engine consumer +# like the plugins, built against this checkout as `..`. See ADR 0040. +vgraph-mcp/ + # Mapping skills — like the editor plugins above, its own git repo with its # own release cycle, just checked out here for convenience. mapping-skills/ diff --git a/AGENTS.md b/AGENTS.md index 1f9617c..45eeabe 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,8 +12,8 @@ already says. Anything worth keeping goes in `/docs` and stays updated. - `docs/adr/` — why things are the way they are. Read the ADR before reversing a design. - `docs/where-things-live.md` — the layer chain a feature crosses (domain, port, - app, editor, MCP, wasm, node), and which test target, entry point and owning - test a test belongs to. Read it before tracing by hand or adding a test. + app, editor, wasm, then the MCP servers in `vgraph-mcp/`), and which test + target, entry point and owning test a test belongs to. Read it before tracing by hand or adding a test. - `docs/design/` — the normative visual reference for the default theme (light and dark). Read its `README.md` before adding or changing a notation, colour, token or dark-mode behaviour; renderer output that disagrees with the guide @@ -97,8 +97,9 @@ Without it, every `String == String`, `hasPrefix` and `contains` leaves an undefined symbol. When the build can't find the archive, read `docs/wasm-unicode-tables.md` before searching the disk. -`vgraph-cli`, `vgraph-mcp`, `vgraph-mcp-http` and `VGraphMCPTools` sit outside -that graph and may use Foundation and key paths freely. +`vgraph-cli` sits outside that graph and may use Foundation and key paths +freely, as do the MCP servers, which live in their own repository +(`vgraph-mcp/`, cloned by `just plugins-setup`; ADR 0040). `VGraphvizLib` is *not* one of them — Graphviz compiles into the wasm module. Graphviz layout runs in-process on every platform, so `#if WASM` appears only in diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8020215..54ee852 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,8 +37,8 @@ everything compiled into the wasm module (no key paths, no reflection, no generi calls on `any` values). `ArchitectureTest` fails on the ones it can check. **Some files get a closer look.** Anything that runs commands or steers a coding -agent (`AGENTS.md`, `.claude/`, `.agents/`, `.github/`, `justfile`, `scripts/`, -`Dockerfile` and the release scripts) needs the maintainer's approval, listed in +agent (`AGENTS.md`, `.claude/`, `.agents/`, `.github/`, `justfile`, `scripts/` +and the release scripts) needs the maintainer's approval, listed in `.github/CODEOWNERS`. A pull request should not be able to plant instructions for someone else's tools, so changes there are read line by line. diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index f1ba464..0000000 --- a/Dockerfile +++ /dev/null @@ -1,76 +0,0 @@ -# syntax=docker/dockerfile:1 - -# Stage 1: Build vgraph-mcp-http -FROM swift:6.3 AS swift-builder - -# Static stdlib link needs libc++ archives, which aren't in the base image. -RUN apt-get update \ - && apt-get install -y --no-install-recommends libc++-dev libc++abi-dev \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /app -COPY Package.swift Package.resolved ./ -COPY Sources/ Sources/ -COPY Tests/ Tests/ - -# No `--mount=type=cache` here, deliberately. It needs BuildKit, and neither -# builder that matters has it: Cloud Build's default step is the legacy builder, -# and a plain colima + docker CLI setup has no buildx either. It also bought -# nothing on Cloud Build — a fresh worker each run means the cache is always -# cold. What it saved locally was the dependency *fetch* (~30s), not the compile; -# Docker's own layer cache still covers the common case where Sources/ is -# unchanged. Keeping the Dockerfile buildable by the classic builder is worth -# more than that. -RUN swift build -c release --product vgraph-mcp-http --static-swift-stdlib \ - && strip .build/release/vgraph-mcp-http \ - && cp .build/release/vgraph-mcp-http /app/vgraph-mcp-http-bin - -# Runtime — ubuntu:24.04 matches swift:6.3's glibc (2.38). -# Only install the libs Swift Foundation dlopen's at runtime. -FROM ubuntu:24.04 - -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - libcurl4t64 \ - librsvg2-bin \ - libc++1 \ - libc++abi1 \ - fontconfig \ - fonts-liberation \ - && rm -rf /var/lib/apt/lists/* - -# Our SVGs name three font families and this image had none of them. Verified -# by rendering a concept map in `ubuntu:24.04` + librsvg2-bin: `fc-match -# "DM Sans"` answered `DejaVuSans.ttf`, and the resulting PNG was pixel-identical -# to what mcp.vithanco.com returns. Text rendered, so nothing looked broken — -# but DejaVu is wider than what the engine measured, and a diagram's title -# overran into the logo watermark. -# -# Two families, two fixes: -# -# - Node and relation labels ask for DM Sans, which is ours to ship. Same faces -# the other renderers bundle; see fonts/README.md. -# - The graph title asks for bare `Helvetica` and the watermark for bare -# `Arial` (Attributes.Group.fontname defaults to .helvetica, not to -# FontFamily.default). Neither exists here, and no amount of DM Sans helps. -# fonts-liberation supplies metric-compatible substitutes, which is what -# fixes the title/logo collision. -# -# `fontconfig` is for `fc-cache`: librsvg2-bin pulls in libfontconfig1, the -# library, not the binary. Fontconfig would scan /usr/share/fonts at first use -# anyway; building the cache at image-build time keeps that cost off a Cloud Run -# cold start. -COPY fonts/*.ttf /usr/share/fonts/truetype/dmsans/ -COPY fonts/OFL.txt /usr/share/fonts/truetype/dmsans/ -RUN fc-cache -f - -COPY --from=swift-builder /app/vgraph-mcp-http-bin /app/vgraph-mcp-http - -EXPOSE 8080 - -# The binary defaults to warn as well; this makes the intent visible. At debug the -# Graphviz source of every render, titles and labels included, reaches Cloud Logging. -ENV VGRAPH_LOG_LEVEL=warn - -# Cloud Run sets $PORT (defaults to 8080); the server reads it from the environment -ENTRYPOINT ["/app/vgraph-mcp-http"] diff --git a/Package.resolved b/Package.resolved index ae6d1a0..09ec20f 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,15 +1,6 @@ { - "originHash" : "43f2b636321e83df296791b3f453cba4b062f83f8110efe6dd546ce84cb72ee0", + "originHash" : "c3f996c8cfac07bc897dc792e48abfda3898a545091eed9e9ad2a17162e67c65", "pins" : [ - { - "identity" : "eventsource", - "kind" : "remoteSourceControl", - "location" : "https://github.com/mattt/eventsource.git", - "state" : { - "revision" : "a3a85a85214caf642abaa96ae664e4c772a59f6e", - "version" : "1.4.1" - } - }, { "identity" : "swift-argument-parser", "kind" : "remoteSourceControl", @@ -19,60 +10,6 @@ "version" : "1.8.2" } }, - { - "identity" : "swift-atomics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-atomics.git", - "state" : { - "revision" : "0442cb5a3f98ab802acb777929fdb446bda11a34", - "version" : "1.3.1" - } - }, - { - "identity" : "swift-collections", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-collections.git", - "state" : { - "revision" : "a0cb0954ecb21e4e31b0070e6ed5674e8556685a", - "version" : "1.6.0" - } - }, - { - "identity" : "swift-log", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-log.git", - "state" : { - "revision" : "a878e7f8f46cfc0e1125e565b5c08e7d5272dc9a", - "version" : "1.14.0" - } - }, - { - "identity" : "swift-nio", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio.git", - "state" : { - "revision" : "2f58d8ef84438d6517fc78bcea2f8527e3c72936", - "version" : "2.105.0" - } - }, - { - "identity" : "swift-sdk", - "kind" : "remoteSourceControl", - "location" : "https://github.com/modelcontextprotocol/swift-sdk", - "state" : { - "revision" : "a0ae212ebf6eab5f754c3129608bc5557637e605", - "version" : "0.12.1" - } - }, - { - "identity" : "swift-system", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-system.git", - "state" : { - "revision" : "b5544ba79a70a0cb3563e75bf26dc198d6b40ed3", - "version" : "1.7.4" - } - }, { "identity" : "swiftgraphviz", "kind" : "remoteSourceControl", diff --git a/Package.swift b/Package.swift index d8bfd02..c4b9e56 100644 --- a/Package.swift +++ b/Package.swift @@ -42,24 +42,16 @@ let package = Package( name: "vgraph-cli", targets: ["vgraph-cli"] ), - .executable( - name: "vgraph-mcp", - targets: ["vgraph-mcp"] - ), - .executable( - name: "vgraph-mcp-http", - targets: ["vgraph-mcp-http"] - ), + // The native composition root under test, for the engine consumers' + // own test suites (vgraph-mcp). .library( - name: "VGraphMCPTools", - targets: ["VGraphMCPTools"] + name: "VGraphTestSupport", + targets: ["TestSupport"] ), ], dependencies: [ .package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0"), - .package(url: "https://github.com/modelcontextprotocol/swift-sdk", from: "0.10.0"), .package(url: "https://github.com/Vithanco/swiftGraphviz.git", .upToNextMinor(from: "0.9.0")), - .package(url: "https://github.com/apple/swift-nio.git", from: "2.65.0"), ], targets: [ // Core: VGraph domain @@ -186,63 +178,6 @@ let package = Package( ] ), - // Shared MCP tool definitions (used by both stdio and HTTP servers) - .target( - name: "VGraphMCPTools", - dependencies: [ - "App", - "VGraph", // RenderResult, alongside the ports that return it - .product(name: "MCP", package: "swift-sdk"), - ], - path: "Sources/VGraphMCPTools", - swiftSettings: [ - .enableExperimentalFeature("Extern") - ] - ), - - // MCP server executable (stdio transport — local CLI & Docker) - .executableTarget( - name: "vgraph-mcp", - dependencies: [ - "VGraphMCPTools", - .product(name: "MCP", package: "swift-sdk"), - ], - path: "Sources/VGraphMCP", - swiftSettings: [ - .enableExperimentalFeature("Extern") - ] - ), - - // The HTTP layer of the hosted server, a library so it can be tested. - .target( - name: "VGraphMCPHTTPKit", - dependencies: [ - "VGraphMCPTools", - .product(name: "MCP", package: "swift-sdk"), - .product(name: "NIOCore", package: "swift-nio"), - .product(name: "NIOPosix", package: "swift-nio"), - .product(name: "NIOHTTP1", package: "swift-nio"), - ], - path: "Sources/VGraphMCPHTTPKit", - swiftSettings: [ - .enableExperimentalFeature("Extern") - ] - ), - - // MCP server executable (HTTP transport — Cloud Run) - .executableTarget( - name: "vgraph-mcp-http", - dependencies: [ - "VGraphMCPTools", - "VGraphMCPHTTPKit", - .product(name: "MCP", package: "swift-sdk"), - ], - path: "Sources/VGraphMCPHTTP", - swiftSettings: [ - .enableExperimentalFeature("Extern") - ] - ), - // Tests - organized by module .testTarget( name: "VGraphTests", @@ -286,25 +221,6 @@ let package = Package( .enableExperimentalFeature("Extern") ] ), - .testTarget( - name: "VGraphMCPTests", - dependencies: ["VGraph", "VGraphSVG", "vgraph-mcp", "VGraphMCPTools", "TestSupport"], - swiftSettings: [ - .enableExperimentalFeature("Extern") - ] - ), - .testTarget( - name: "VGraphMCPHTTPTests", - dependencies: [ - "VGraphMCPHTTPKit", "VGraphMCPTools", "TestSupport", - .product(name: "NIOCore", package: "swift-nio"), - .product(name: "NIOEmbedded", package: "swift-nio"), - .product(name: "NIOHTTP1", package: "swift-nio"), - ], - swiftSettings: [ - .enableExperimentalFeature("Extern") - ] - ), .testTarget( name: "VGraphCLITests", dependencies: ["VGraph", "vgraph-cli", "TestSupport"], diff --git a/README.md b/README.md index 9165c4e..9d116db 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ document can also declare notations of its own. The | **Web editor** | [vithanco.com/editor](https://vithanco.com/editor/): write VGL, see the diagram, edit it on the canvas | | **Obsidian** | [obsidian-vithanco](https://github.com/Vithanco/obsidian-vithanco): a `vgl` code block becomes a diagram | | **VS Code** | [vscode-vithanco](https://github.com/Vithanco/vscode-vithanco) | -| **MCP server** | `npx @vithanco/vgraph-mcp` runs it locally; `https://mcp.vithanco.com/mcp` is hosted. [Details](vgraph-mcp-node/README.md) | +| **MCP server** | `npx @vithanco/vgraph-mcp` runs it locally; `https://mcp.vithanco.com/mcp` is hosted. [vgraph-mcp](https://github.com/Vithanco/vgraph-mcp) | | **Command line** | `vgraph-cli`, built from this repository | | **Swift package** | the `VGraph`, `VGLanguage` and `VGraphSVG` libraries | @@ -74,7 +74,7 @@ swift sdk install "https://download.swift.org/swift-$V-release/wasm-sdk/swift-$V it. ```bash -just build # compile everything: wasm, command line, MCP server +just build # compile the engine: wasm, command line just test # build, then the full suite: Swift, wasm smoke tests, editor browser tests just # everything else ``` diff --git a/SECURITY.md b/SECURITY.md index 3576d49..b077db4 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -42,7 +42,8 @@ logged, titles and labels included, so only developers set it. Logs are kept for Origin is not validated. The server is public and keeps no state or credentials, so a browser request can reach nothing a direct request could not. There is no -per-client rate limit; the per-request bounds in `docs/mcp-hardening.md` cap what +per-client rate limit; the per-request bounds in +[`docs/mcp-hardening.md`](https://github.com/Vithanco/vgraph-mcp/blob/main/docs/mcp-hardening.md) cap what one request costs. Both are revisited if the endpoint is abused. ## What is not diff --git a/Sources/VGraphMCP/VGraphMCPServer.swift b/Sources/VGraphMCP/VGraphMCPServer.swift deleted file mode 100644 index 86f6cd6..0000000 --- a/Sources/VGraphMCP/VGraphMCPServer.swift +++ /dev/null @@ -1,61 +0,0 @@ -// MCP server for VGraph — exposes notation-specific tools for creating diagrams. -// Communicates via stdin/stdout using the MCP (Model Context Protocol). - -import Foundation -import Logging -import MCP -import VGraphMCPTools - -@main -struct VGraphMCPServer { - /// Write a debug message to stderr (safe — does not corrupt the JSON-RPC stream on stdout) - private static func debug(_ message: String) { - FileHandle.standardError.write(Data("[vgraph-mcp DEBUG] \(message)\n".utf8)) - } - - static func main() async throws { - debug("main() entered") - - // Log to stderr to avoid corrupting the JSON-RPC stream on stdout - LoggingSystem.bootstrap(StreamLogHandler.standardError) - let logger = Logger(label: "vgraph-mcp") - debug("logging configured") - - let server = Server( - name: "vgraph", - version: "1.0.0", - capabilities: .init( - tools: .init(listChanged: false) - ) - ) - debug("server created") - - await server.withMethodHandler(ListTools.self) { _ in - debug("ListTools handler called") - return .init(tools: VGraphTools.all.map(\.definition)) - } - debug("ListTools handler registered") - - await server.withMethodHandler(CallTool.self) { params in - debug("CallTool handler called for: \(params.name)") - guard let tool = VGraphTools.all.first(where: { $0.definition.name == params.name }) - else { - return .init( - content: [.text(text: "Unknown tool: \(params.name)", annotations: nil, _meta: nil)], - isError: true - ) - } - return await tool.handle(params) - } - debug("CallTool handler registered") - - let transport = StdioTransport(logger: logger) - debug("transport created, starting server...") - try await server.start(transport: transport) - debug("server started, waiting for completion...") - - // Keep the process alive until the transport disconnects - await server.waitUntilCompleted() - debug("server completed, exiting") - } -} diff --git a/Sources/VGraphMCPHTTP/VGraphMCPHTTPServer.swift b/Sources/VGraphMCPHTTP/VGraphMCPHTTPServer.swift deleted file mode 100644 index 9b706b2..0000000 --- a/Sources/VGraphMCPHTTP/VGraphMCPHTTPServer.swift +++ /dev/null @@ -1,21 +0,0 @@ -// MCP server for VGraph over HTTP (Streamable HTTP, stateless). -// Designed for Cloud Run and similar container platforms. - -import Foundation -import Logging -import VGraphMCPHTTPKit - -@main -struct VGraphMCPHTTPServer { - static func main() async throws { - LoggingSystem.bootstrap(StreamLogHandler.standardError) - let logger = Logger(label: "vgraph-mcp-http") - - let port = ProcessInfo.processInfo.environment["PORT"].flatMap(Int.init) ?? 8080 - let host = "0.0.0.0" - let app = try await MCPHTTPApp.hosted(host: host, port: port, logger: logger) - - logger.info("Starting VGraph MCP HTTP server on \(host):\(port)") - try await app.start() - } -} diff --git a/Sources/VGraphMCPHTTPKit/HostedServer.swift b/Sources/VGraphMCPHTTPKit/HostedServer.swift deleted file mode 100644 index a204642..0000000 --- a/Sources/VGraphMCPHTTPKit/HostedServer.swift +++ /dev/null @@ -1,63 +0,0 @@ -import Logging -import MCP -import VGraphMCPTools - -extension MCPHTTPApp { - /// The endpoint Cloud Run serves: every VGraph tool behind the stateless transport. - public static func hosted(host: String, port: Int, logger: Logger) async throws -> MCPHTTPApp { - let server = Server( - name: "vgraph", - version: "1.0.0", - capabilities: .init(tools: .init(listChanged: false)) - ) - - await server.withMethodHandler(ListTools.self) { _ in - .init(tools: VGraphTools.all.map(\.definition)) - } - - await server.withMethodHandler(CallTool.self) { params in - guard let tool = VGraphTools.all.first(where: { $0.definition.name == params.name }) else { - return .init( - content: [.text(text: "Unknown tool: \(params.name)", annotations: nil, _meta: nil)], - isError: true - ) - } - return await tool.handle(params) - } - - let transport = StatelessHTTPServerTransport( - validationPipeline: StandardValidationPipeline(validators: [ - OriginValidator.disabled, - AcceptHeaderValidator(mode: .jsonOnly), - ContentTypeValidator(), - ProtocolVersionValidator(), - ]), - logger: logger - ) - try await server.start(transport: transport) - // After start, which installs the SDK's own handler. - await server.answerEveryInitialize() - return MCPHTTPApp(transport: transport, host: host, port: port, logger: logger) - } -} - -extension Server { - /// The SDK's own handler answers `initialize` once per Server, but over a - /// stateless transport every request may come from a different client, and a - /// client stops at a refused `initialize`. Nothing here keeps per-client state, - /// so each one is answered afresh. - func answerEveryInitialize() async { - let info = Server.Info(name: name, version: version, title: title) - let instructions = instructions - let capabilities = capabilities - withMethodHandler(Initialize.self) { params in - Initialize.Result( - protocolVersion: Version.supported.contains(params.protocolVersion) - ? params.protocolVersion : Version.latest, - capabilities: capabilities, - serverInfo: info, - instructions: instructions - ) - } - } -} diff --git a/Sources/VGraphMCPHTTPKit/MCPHTTPApp.swift b/Sources/VGraphMCPHTTPKit/MCPHTTPApp.swift deleted file mode 100644 index 46891fc..0000000 --- a/Sources/VGraphMCPHTTPKit/MCPHTTPApp.swift +++ /dev/null @@ -1,320 +0,0 @@ -// MCP server for VGraph over HTTP (Streamable HTTP, stateless). -// Designed for Cloud Run and similar container platforms. - -import Foundation -import Logging -import MCP -@preconcurrency import NIOCore -@preconcurrency import NIOHTTP1 -@preconcurrency import NIOPosix -import VGraphMCPTools - -// MARK: - NIO HTTP Application - -/// Minimal NIO HTTP server that routes requests to the MCP transport. -public actor MCPHTTPApp { - private let transport: StatelessHTTPServerTransport - private let host: String - private let port: Int - private let logger: Logger - private let limits: MCPLimits - - public init( - transport: StatelessHTTPServerTransport, host: String, port: Int, logger: Logger, - limits: MCPLimits = .standard - ) { - self.limits = limits - self.transport = transport - self.host = host - self.port = port - self.logger = logger - } - - public func start() async throws { - let group = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount) - - let bootstrap = ServerBootstrap(group: group) - .serverChannelOption(ChannelOptions.backlog, value: 256) - .serverChannelOption(ChannelOptions.socketOption(.so_reuseaddr), value: 1) - .childChannelInitializer { channel in - channel.pipeline.configureHTTPServerPipeline().flatMap { - channel.pipeline.addHandler(self.makeHandler()) - } - } - .childChannelOption(ChannelOptions.socketOption(.so_reuseaddr), value: 1) - .childChannelOption(ChannelOptions.maxMessagesPerRead, value: 1) - - let channel = try await bootstrap.bind(host: host, port: port).get() - logger.info("VGraph MCP HTTP server listening on \(host):\(port)") - try await channel.closeFuture.get() - } - - // Called from NIO's channel initializer, on an event loop outside the actor. - // It only reads the immutable limits; requests re-enter the actor through - // the awaited handler. - nonisolated func makeHandler() -> HTTPHandler { - HTTPHandler(limits: limits, handle: { await self.handleHTTPRequest($0) }) - } - - // MARK: - Request Routing - - private static let mcpEndpoint = "/mcp" - private static let healthEndpoint = "/health" - - func handleHTTPRequest(_ request: NIOHTTPRequest) async -> NIOHTTPResponse { - let path = String(request.uri.split(separator: "?").first ?? Substring(request.uri)) - - switch path { - case Self.healthEndpoint: - return NIOHTTPResponse(statusCode: 200, headers: ["Content-Type": "text/plain"], body: Data("ok".utf8)) - - case Self.mcpEndpoint: - let mcpRequest = HTTPRequest( - method: request.method, - headers: request.headers, - body: request.body, - path: path - ) - let mcpResponse = await transport.handleRequest(mcpRequest) - return NIOHTTPResponse( - statusCode: mcpResponse.statusCode, - headers: mcpResponse.headers, - body: mcpResponse.bodyData - ) - - default: - return NIOHTTPResponse(statusCode: 404, headers: ["Content-Type": "text/plain"], body: Data("Not Found".utf8)) - } - } -} - -// MARK: - Framework-agnostic request/response for NIO layer - -struct NIOHTTPRequest: Sendable { - let method: String - let uri: String - let headers: [String: String] - let body: Data? -} - -struct NIOHTTPResponse: Sendable { - let statusCode: Int - let headers: [String: String] - let body: Data? -} - -// MARK: - NIO HTTP Handler - -/// Bounds what one connection may cost before the MCP transport sees it: the body -/// is capped as it arrives (not after it has been buffered), a silent or stalled -/// connection is closed, and a request that runs past its deadline is answered -/// with 504. The work behind a missed deadline is abandoned, not cancelled: -/// Graphviz layout runs in-process and cannot be stopped, which is why the graph -/// limits bound the input as well. -final class HTTPHandler: ChannelInboundHandler, @unchecked Sendable { - typealias InboundIn = HTTPServerRequestPart - typealias OutboundOut = HTTPServerResponsePart - - private let limits: MCPLimits - private let handle: @Sendable (NIOHTTPRequest) async -> NIOHTTPResponse - - private struct RequestState { - var head: HTTPRequestHead - var bodyBuffer: ByteBuffer - var refused = false - } - - private var requestState: RequestState? - private var idleTimer: Scheduled? - private var readTimer: Scheduled? - - init(limits: MCPLimits, handle: @escaping @Sendable (NIOHTTPRequest) async -> NIOHTTPResponse) { - self.limits = limits - self.handle = handle - } - - func channelActive(context: ChannelHandlerContext) { - startIdleTimer(context) - context.fireChannelActive() - } - - func channelInactive(context: ChannelHandlerContext) { - idleTimer?.cancel() - readTimer?.cancel() - context.fireChannelInactive() - } - - private func timeAmount(_ seconds: Double) -> TimeAmount { .milliseconds(Int64(seconds * 1000)) } - - private func startIdleTimer(_ context: ChannelHandlerContext) { - idleTimer?.cancel() - nonisolated(unsafe) let ctx = context - idleTimer = context.eventLoop.scheduleTask(in: timeAmount(limits.idleTimeoutSeconds)) { ctx.close(promise: nil) } - } - - private func restartReadTimer(_ context: ChannelHandlerContext) { - readTimer?.cancel() - nonisolated(unsafe) let ctx = context - readTimer = context.eventLoop.scheduleTask(in: timeAmount(limits.readTimeoutSeconds)) { ctx.close(promise: nil) } - } - - func channelRead(context: ChannelHandlerContext, data: NIOAny) { - let part = unwrapInboundIn(data) - - switch part { - case .head(let head): - idleTimer?.cancel() - restartReadTimer(context) - requestState = RequestState( - head: head, - bodyBuffer: context.channel.allocator.buffer(capacity: 0) - ) - if let announced = head.headers.first(name: "Content-Length").flatMap(Int.init), - announced > limits.maxBodyBytes - { - refuse(context: context) - } - case .body(var buffer): - guard requestState?.refused == false else { return } - restartReadTimer(context) - requestState?.bodyBuffer.writeBuffer(&buffer) - if (requestState?.bodyBuffer.readableBytes ?? 0) > limits.maxBodyBytes { - refuse(context: context) - } - case .end: - readTimer?.cancel() - guard let state = requestState, !state.refused else { return } - requestState = nil - - nonisolated(unsafe) let ctx = context - Task { - await self.handleRequest(state: state, context: ctx) - } - } - } - - /// 413, then close: a client that sent too much has no claim on the connection, - /// and what it still sends is dropped unread. - private func refuse(context: ChannelHandlerContext) { - guard let version = requestState?.head.version else { return } - requestState?.refused = true - requestState?.bodyBuffer.clear() - readTimer?.cancel() - let body = Data("Request body is larger than the limit of \(describe(limits.maxBodyBytes)).".utf8) - let response = NIOHTTPResponse( - statusCode: 413, headers: ["Content-Type": "text/plain", "Connection": "close"], body: body) - write(response, version: version, context: context, thenClose: true) - } - - private func describe(_ bytes: Int) -> String { - bytes >= 1 << 20 && bytes % (1 << 20) == 0 ? "\(bytes >> 20) MiB" : "\(bytes) bytes" - } - - private func handleRequest(state: RequestState, context: ChannelHandlerContext) async { - var headers: [String: String] = [:] - for (name, value) in state.head.headers { - if let existing = headers[name] { - headers[name] = existing + ", " + value - } else { - headers[name] = value - } - } - - let body: Data? - if state.bodyBuffer.readableBytes > 0, - let bytes = state.bodyBuffer.getBytes(at: 0, length: state.bodyBuffer.readableBytes) - { - body = Data(bytes) - } else { - body = nil - } - - let request = NIOHTTPRequest( - method: state.head.method.rawValue, - uri: state.head.uri, - headers: headers, - body: body - ) - - let response = await Deadline.race(seconds: limits.requestDeadlineSeconds) { await self.handle(request) } - await writeResponse(response, version: state.head.version, context: context) - } - - private func writeResponse( - _ response: NIOHTTPResponse, - version: HTTPVersion, - context: ChannelHandlerContext - ) async { - write(response, version: version, context: context, thenClose: false) - } - - private func write( - _ response: NIOHTTPResponse, - version: HTTPVersion, - context: ChannelHandlerContext, - thenClose: Bool - ) { - nonisolated(unsafe) let ctx = context - let eventLoop = ctx.eventLoop - - let send: @Sendable () -> Void = { - var head = HTTPResponseHead( - version: version, - status: HTTPResponseStatus(statusCode: response.statusCode) - ) - for (name, value) in response.headers { - head.headers.add(name: name, value: value) - } - - ctx.write(self.wrapOutboundOut(.head(head)), promise: nil) - - if let bodyData = response.body { - var buffer = ctx.channel.allocator.buffer(capacity: bodyData.count) - buffer.writeBytes(bodyData) - ctx.write(self.wrapOutboundOut(.body(.byteBuffer(buffer))), promise: nil) - } - - ctx.writeAndFlush(self.wrapOutboundOut(.end(nil)), promise: nil) - if thenClose { ctx.close(promise: nil) } - } - if eventLoop.inEventLoop { send() } else { eventLoop.execute(send) } - } -} - -// MARK: - Request deadline - -enum Deadline { - static let exceeded = NIOHTTPResponse( - statusCode: 504, headers: ["Content-Type": "text/plain"], - body: Data("The request took too long and was abandoned. Send a smaller diagram.".utf8)) - - /// The operation's answer, or 504 if it has not answered in time. The operation - /// is left running when it loses. - static func race( - seconds: Double, operation: @escaping @Sendable () async -> NIOHTTPResponse - ) async -> NIOHTTPResponse { - await withCheckedContinuation { continuation in - let once = Once(continuation) - Task { once.resume(await operation()) } - Task { - try? await Task.sleep(for: .seconds(seconds)) - once.resume(exceeded) - } - } - } - - private final class Once: @unchecked Sendable { - private let lock = NSLock() - private var continuation: CheckedContinuation? - - init(_ continuation: CheckedContinuation) { self.continuation = continuation } - - func resume(_ response: NIOHTTPResponse) { - lock.lock() - let pending = continuation - continuation = nil - lock.unlock() - pending?.resume(returning: response) - } - } -} diff --git a/Sources/VGraphMCPTools/CLDTool.swift b/Sources/VGraphMCPTools/CLDTool.swift deleted file mode 100644 index 412658e..0000000 --- a/Sources/VGraphMCPTools/CLDTool.swift +++ /dev/null @@ -1,131 +0,0 @@ -// MCP tool for creating Causal Loop Diagrams (CLD) from VGL. - -import Foundation -import MCP -import VGraph - -public enum CLDTool: VGraphTool { - public static let name = "create_cld" - public static let errorNoun = "causal loop diagram" - public static let notationName = "CLD" - - public static let purposeSentence = """ - A Causal Loop Diagram (CLD) is a Systems Thinking tool that maps feedback loops \ - between variables, showing how a change in one variable causes changes in others. \ - It reveals reinforcing dynamics (exponential growth or decline) and balancing dynamics \ - (stabilisation toward equilibrium). - """ - - public static let vglParameterDescription = """ - Valid VGL code using the CLD notation. \ - Must start with: vgraph : CLD "" { ... } - """ - - private static let entry = Notations.CausalLoopDiagram.entry - - public static var descriptionBody: String { - """ - ## Core Concepts - - A CLD consists of **variables** (called Stocks) connected by **causal links** with polarity: - - - **same** (`s`): when A increases, B increases; when A decreases, B decreases. Drawn as a solid arrow. - - **opposite** (`o`): when A increases, B decreases; when A decreases, B increases. Drawn as a dashed arrow. - - A **feedback loop** is a closed chain of causal links returning to the starting variable: - - - **Reinforcing loop (R)**: even number of `opposite` edges (including zero). Drives exponential \ - growth or decline — a snowball effect. - - **Balancing loop (B)**: odd number of `opposite` edges. Drives the system toward equilibrium — \ - a thermostat effect. - - ## How to Build a CLD - - 1. Identify the key variables (stocks) in the system — things whose value can increase or decrease. - 2. For each pair of causally related variables, determine the polarity: does an increase in A cause \ - B to increase (same) or decrease (opposite)? - 3. Trace closed loops and classify them as reinforcing or balancing using the counting rule. - 4. Give the diagram a title that frames the system boundary. - - ## VGL Syntax - - ``` - vgraph <id>: CLD "<title>" { - <nodes and edges> - } - ``` - - ### Node Types - - \(NotationMarkdown.nodeTypeBullets(entry.nodeTypeDefinitions)) - - ``` - node <id>: Stock "<label>" - ``` - - ### Edges - - \(NotationMarkdown.edgeTypeBullets(entry.edgeTypeDefinitions)) - - CRITICAL: You MUST specify the edge type (`: same` or `: opposite`) on every edge. \ - Both edge types connect Stock to Stock, so the type CANNOT be inferred — omitting it will cause an error. - - ``` - edge <from_id> -> <to_id>: same - edge <from_id> -> <to_id>: opposite - ``` - - ## Identifying Feedback Loops - - To classify a loop, trace a closed path back to the starting variable and count the `opposite` edges: - - - **0 opposite edges** → Reinforcing (R): Population → Birth Rate → Population \ - (more people → more births → even more people) - - **1 opposite edge** → Balancing (B): Population → Death Rate → Population \ - (more people → more deaths → fewer people) - - Rule: even count = reinforcing, odd count = balancing. - - ## Complete Example - - ``` - vgraph populationCLD: CLD "Population Dynamics" { - node population: Stock "Population" - node births: Stock "Birth Rate" - node deaths: Stock "Death Rate" - node resources: Stock "Available Resources" - - edge population -> births: same - edge births -> population: same - edge population -> deaths: same - edge deaths -> population: opposite - edge population -> resources: opposite - edge resources -> births: same - } - ``` - - **Loop analysis:** - - **R1 (Reinforcing):** Population → Birth Rate → Population — \ - 0 opposite edges. More people produce more births, which increases population. Growth spiral. - - **B1 (Balancing):** Population → Death Rate → Population — \ - 1 opposite edge. More people means more deaths, which reduces population. Death regulation. - - **B2 (Balancing):** Population → Available Resources → Birth Rate → Population — \ - 1 opposite edge (population → resources). More people deplete resources, reducing birth rate. \ - Resource constraint. - - ## Rules - - 1. ALWAYS specify the edge type (`: same` or `: opposite`) — it cannot be inferred - 2. Stock labels should be nouns or noun phrases representing measurable quantities that can \ - increase or decrease (e.g. "Population", "Revenue", "Stress Level" — not "People are born" \ - or "Increasing") - 3. Every Stock MUST connect to at least one other Stock — no isolated variables - 4. Think in terms of "if A increases, what happens to B?" to determine same vs opposite polarity - 5. Use meaningful IDs (population, revenue, stress — not n1, n2, n3) - 6. Keep the diagram focused on one system — the title should frame the boundary - 7. Aim for closed loops — a CLD without any feedback loop is just a causal chain and misses \ - the point of systems thinking - 8. Prefer 3–6 variables per loop for clarity — larger loops are hard to trace and verify - """ - } -} diff --git a/Sources/VGraphMCPTools/ConceptMapTool.swift b/Sources/VGraphMCPTools/ConceptMapTool.swift deleted file mode 100644 index 3d8b439..0000000 --- a/Sources/VGraphMCPTools/ConceptMapTool.swift +++ /dev/null @@ -1,206 +0,0 @@ -// MCP tool for creating Concept Map diagrams from VGL. - -import Foundation -import MCP -import VGraph - -public enum ConceptMapTool: VGraphTool { - public static let name = "create_concept_map" - public static let errorNoun = "concept map" - public static let notationName = "ConceptMap" - - public static let purposeSentence = """ - A Concept Map defines the vocabulary of a domain \ - through falsifiable propositions. It helps people align on exact wordings and shared \ - understanding by stating facts as simple, readable sentences. - """ - - public static let vglParameterDescription = """ - Valid VGL code using the ConceptMap notation. \ - Must start with: vgraph <id>: ConceptMap "<title>" { ... } - """ - - private static let entry = Notations.ConceptMap.entry - - public static var descriptionBody: String { - """ - ## How to Build a Concept Map - - 1. Start with a Guiding Question (used as the graph title) — it determines what belongs on the map. - 2. List all relevant concepts. - 3. Connect every concept through relations. ALWAYS form readable propositions. - 4. NEVER leave a concept unconnected. Every concept MUST connect to at least one relation. - 5. Reuse relations when multiple concepts share the same relationship. - - ## VGL Syntax - - ``` - vgraph <id>: ConceptMap "<Guiding Question>" { - <nodes and edges> - } - ``` - - ### Node Types - - \(NotationMarkdown.nodeTypeBullets(entry.nodeTypeDefinitions)) - - ``` - node <id>: Concept "<label>" - node <id>: EmphasizedConcept "<label>" - node <id>: Relation "<label>" - ``` - - ### Edges - - Valid connections: - \(NotationMarkdown.edgeConnectionBullets(entry.edgeTypeDefinitions)) - - ``` - edge <from_id> -> <to_id> - ``` - - ALWAYS form the pattern: Concept -> Relation -> Concept. This creates a readable proposition. - - ## Reusing Relations - - When multiple concepts share the same relationship, reuse a single Relation node. \ - No duplicate edges when reusing — create edges only where needed: - - **Multiple sources, one target:** - ``` - vgraph animals: ConceptMap "What are common pets?" { - node dog: Concept "Dog" - node cat: Concept "Cat" - node isa: Relation "is a" - node mammal: Concept "Mammal" - - edge dog -> isa - edge cat -> isa - edge isa -> mammal // Only ONE edge from relation to target - } - ``` - - Both "Dog is a Mammal" and "Cat is a Mammal" share one Relation node — only 4 nodes total. - - **One source, multiple targets:** - ``` - vgraph typography: ConceptMap "What defines a font?" { - node font: Concept "Font" - node has: Relation "has" - node weight: Concept "Weight" - node style: Concept "Style" - - edge font -> has // Only ONE edge from source to relation - edge has -> weight - edge has -> style - } - ``` - - Both "Font has Weight" and "Font has Style" share one Relation node — only 4 nodes total. - - **CRITICAL — Multiple inbound AND multiple outbound edges:** - - When a relation has BOTH multiple inbound edges (concepts pointing TO the relation) AND \ - multiple outbound edges (relation pointing TO concepts), ALL inbound concepts must make sense \ - as propositions with ALL outbound concepts. With n inbound and m outbound edges, you get n × m \ - propositions — all must be valid. - - **Invalid example:** - ``` - vgraph learning: ConceptMap "What enables growth?" { - node learning: Concept "Learning" - node accountability: Concept "Accountability" - node enables: Relation "enables" - - edge learning -> enables - edge accountability -> enables - edge enables -> learning - edge enables -> accountability - } - ``` - - This creates 4 propositions (2 × 2): - - Learning enables Learning ❌ (circular) - - Learning enables Accountability ✓ - - Accountability enables Learning ✓ - - Accountability enables Accountability ❌ (circular) - - **Fix — Use specific relations:** - ``` - vgraph learning: ConceptMap "What enables growth?" { - node learning: Concept "Learning" - node accountability: Concept "Accountability" - node facilitates: Relation "facilitates" - node requires: Relation "requires" - - edge accountability -> facilitates - edge facilitates -> learning - - edge learning -> requires - edge requires -> accountability - } - ``` - - Now: "Accountability facilitates Learning" ✓ and "Learning requires Accountability" ✓ - - **Fix — Restructure:** - ``` - vgraph learning: ConceptMap "What enables growth?" { - node learning: Concept "Learning" - node accountability: Concept "Accountability" - node environment: Concept "Environment" - node creates: Relation "creates" - - edge learning -> creates - edge accountability -> creates - edge creates -> environment - } - ``` - - Now: "Learning creates Environment" ✓ and "Accountability creates Environment" ✓ - - ## Complete Example - - ``` - vgraph learningCM: ConceptMap "What is Learning?" { - node student: Concept "Student" - node subject: Concept "Subject" - node practice: EmphasizedConcept "Practice" - node understanding: Concept "Understanding" - node resources: Concept "Resources" - - node learns: Relation "learns" - node requires: Relation "requires" - node leads_to: Relation "leads to" - node uses: Relation "uses" - - edge student -> learns - edge learns -> subject - edge subject -> requires - edge requires -> practice - edge practice -> leads_to - edge leads_to -> understanding - edge subject -> uses - edge uses -> resources - } - ``` - - Propositions: Student learns Subject, Subject requires Practice, \ - Practice leads to Understanding, Subject uses Resources. - - ## Rules - - 1. ALWAYS form readable propositions — every Concept -> Relation -> Concept chain MUST read as a natural, falsifiable sentence - 2. NEVER leave a concept unconnected - 3. **Concept labels are nouns** — concept labels should be nouns or noun phrases (things, ideas, entities), not actions, sentences, or verb phrases. Use "Understanding" not "How we understand things" - 4. **Verb agreement** — Relation labels must match the subject's number: singular concepts (e.g., "Student", "Dog") use singular verbs ("requires", "is", "has"); plural concepts (e.g., "LLMs", "Dogs") use plural verbs ("require", "are", "have"). For mixed cases, use infinitive form without "(s)": "enable" not "enables", "prevent" not "prevents". The notation "Dog(s)" in concept labels can indicate the concept works in both forms, then use infinitive verb forms. - 5. **Guiding question as filter** — the guiding question determines what belongs on the map. Every concept MUST help answer it. If a concept does not contribute to answering the guiding question, it does not belong. - 6. **Relationship diversity** — use diverse relation types (not all "is a" or "has"). Avoid simple opposite pairs (e.g. "is parent of" / "is child of" are the same relationship stated twice in different directions). Use different verbs that reveal distinct aspects of how concepts relate. - 7. **Rich connectivity** — every concept should connect to at least 2 others via different relations. Aim for a network structure where multiple paths exist between concepts — not a chain (linear A→B→C) or a spoke (one central concept with everything hanging off it). - 8. Use meaningful IDs (student, practice — not n1, n2) - 9. Keep relation labels short (verbs or short phrases) - 10. Use EmphasizedConcept sparingly - 11. **Introduce abbreviations** — if a concept label uses an abbreviation, spell out the full term first: e.g. "Gross National Product (GNP)", not just "GNP" - """ - } -} diff --git a/Sources/VGraphMCPTools/DecomposeTool.swift b/Sources/VGraphMCPTools/DecomposeTool.swift deleted file mode 100644 index 0fbd505..0000000 --- a/Sources/VGraphMCPTools/DecomposeTool.swift +++ /dev/null @@ -1,74 +0,0 @@ -// Text in, text out: the assistant keeps the document, as an editor user does. -// It goes through the session so it decomposes exactly as the editor's menu. - -import App -import MCP -import VGraph - -public enum DecomposeTool { - - public static let name = "decompose" - - public static var definition: Tool { - Tool( - name: name, - description: """ - Decompose a node into a detailed node and return the updated VGL document. \ - Only a node whose type has a detailing can be decomposed; `describe_notation` \ - lists them. The node keeps its id, type, label and attributes and becomes a \ - group holding new details, one per edge, so every edge keeps its id and label \ - and now ends at a detail. Rename and retype the new details afterwards. - """, - inputSchema: .object([ - "type": .string("object"), - "properties": .object([ - "vgl": .object([ - "type": .string("string"), - "description": .string("The VGL document holding the node"), - ]), - "node": .object([ - "type": .string("string"), - "description": .string("Id of the node to decompose"), - ]), - ]), - "required": .array([.string("vgl"), .string("node")]), - "additionalProperties": .bool(false), - ]) - ) - } - - public static func handle(_ params: CallTool.Parameters) async -> CallTool.Result { - await handle(params, logger: StderrLogger()) - } - - public static func handle( - _ params: CallTool.Parameters, logger: StderrLogger, limits: MCPLimits = .standard - ) async -> CallTool.Result { - guard let vgl = params.arguments?["vgl"]?.stringValue, - let node = params.arguments?["node"]?.stringValue - else { - return failure("Error: 'vgl' and 'node' parameters are required.") - } - if let refusal = limits.refusal(vglBytes: vgl.utf8.count) { - return failure("Error: \(refusal)") - } - do { - let app = VGraphMCPApp(logger: logger) - // The session does not expose the parsed graph, and a parse is cheap - // beside the layout the render tools refuse to start. - let graph = try app.parseGraph(vgl) - if let refusal = limits.refusal(nodes: graph.nodes.count, edges: graph.edges.count, views: graph.views.count) { - return failure("Error: \(refusal)") - } - let session = try app.makeSession(vgl: vgl) - try session.decompose(node) - return .init(content: [.text(text: try session.exportVGL(), annotations: nil, _meta: nil)], isError: false) - } catch { - return failure("Error decomposing '\(node)': \(error)") - } - } - - private static func failure(_ text: String) -> CallTool.Result { - .init(content: [.text(text: text, annotations: nil, _meta: nil)], isError: true) - } -} diff --git a/Sources/VGraphMCPTools/DescribeNotationTool.swift b/Sources/VGraphMCPTools/DescribeNotationTool.swift deleted file mode 100644 index bcd2716..0000000 --- a/Sources/VGraphMCPTools/DescribeNotationTool.swift +++ /dev/null @@ -1,81 +0,0 @@ -// MCP tool that returns the self-describing Markdown document for a built-in notation. -// Unlike the rendering tools this does not take VGL input or produce an image — it takes -// a notation name and returns Markdown text (purpose, when-to-use, node/edge/group types, -// detailings, history, references). - -import App -import Foundation -import MCP -import VGraph - -public enum DescribeNotationTool { - - public static let name = "describe_notation" - - /// Every registered notation, in registry order. `metadescription` resolves - /// against the same registry, so an allowlist here could only ever go stale — - /// as it did, offering IBIS alone while fifteen others answered perfectly well. - public static var validNotations: [String] { NotationRegistry.entries.map(\.id) } - - public static var definition: Tool { - Tool( - name: name, - description: """ - Return the self-describing Markdown document for a built-in VGraph notation. \ - The document includes the notation's purpose, when to use it, node types, \ - edge types, group types, detailings (which node types can be decomposed and \ - what goes inside them), history, and references. - """, - inputSchema: .object([ - "type": .string("object"), - "properties": .object([ - "notation": .object([ - "type": .string("string"), - "description": .string("Name of the built-in notation"), - "enum": .array(validNotations.map { .string($0) }), - ]) - ]), - "required": .array([.string("notation")]), - "additionalProperties": .bool(false), - ]) - ) - } - - public static func handle(_ params: CallTool.Parameters) async -> CallTool.Result { - guard let notation = params.arguments?["notation"]?.stringValue else { - return .init( - content: [.text(text: "Error: 'notation' parameter is required.", annotations: nil, _meta: nil)], - isError: true - ) - } - - // Validate against known names before hitting the parser — gives a better error. - guard validNotations.contains(notation) else { - return .init( - content: [ - .text( - text: "Error: unknown notation '\(notation)'. Valid notations: \(validNotations.joined(separator: ", "))", - annotations: nil, _meta: nil - ) - ], - isError: true - ) - } - - guard let markdown = VGraphMCPApp().describeNotation(notation) else { - return .init( - content: [ - .text( - text: "Error: notation '\(notation)' has no self-description content yet.", - annotations: nil, _meta: nil - ) - ], - isError: true - ) - } - return .init( - content: [.text(text: markdown, annotations: nil, _meta: nil)], - isError: false - ) - } -} diff --git a/Sources/VGraphMCPTools/IBISTool.swift b/Sources/VGraphMCPTools/IBISTool.swift deleted file mode 100644 index f781c98..0000000 --- a/Sources/VGraphMCPTools/IBISTool.swift +++ /dev/null @@ -1,123 +0,0 @@ -// MCP tool for creating IBIS (Issue-Based Information System) diagrams from VGL. - -import Foundation -import MCP -import VGraph - -public enum IBISTool: VGraphTool { - public static let name = "create_ibis" - public static let errorNoun = "IBIS diagram" - public static let notationName = "IBIS" - - public static let purposeSentence = """ - IBIS (Issue-Based Information System) maps out any decision, discussion, or thought \ - process using just four node types: Questions, Answers (Ideas), Pros, and Cons. \ - Attaching Questions to any node lets you drill into any aspect at any depth. - """ - - public static let vglParameterDescription = """ - Valid VGL code using the IBIS notation. \ - Must start with: vgraph <id>: IBIS "<title>" { ... } - """ - - private static let entry = Notations.Ibis.entry - - public static var descriptionBody: String { - """ - ## How to Build an IBIS Diagram - - 1. Start with a root Question (used as the graph title). - 2. Add Answers (Ideas) that respond to the question. - 3. Add Pro and Con arguments for each answer. - 4. Attach further Questions to any node to drill deeper. - 5. Keep going until the topic is explored to the depth you need. - - ## VGL Syntax - - ``` - vgraph <id>: IBIS "<title>" { - <nodes and edges> - } - ``` - - ### Node Types - - \(NotationMarkdown.nodeTypeBullets(entry.nodeTypeDefinitions)) - - ``` - node <id>: Question "<label>" - node <id>: Answer "<label>" - node <id>: Pro "<label>" - node <id>: Con "<label>" - ``` - - ### Edges - - Edge types are inferred from node types — just write `edge <from> -> <to>`. - - Valid connections: - \(NotationMarkdown.edgeConnectionBullets(entry.edgeTypeDefinitions)) - - ``` - edge <from_id> -> <to_id> - ``` - - ## The Drill-Down Mechanism - - The power of IBIS is that you can attach a Question to **any** node type: - - Question a Question: "Shouldn't we rather discuss X?" - - Question an Answer: "What would we need to implement this?" - - Question a Pro: "Is this advantage really significant?" - - Question a Con: "Can we mitigate this disadvantage?" - - Each sub-question starts its own Answer/Pro/Con branch, allowing unlimited depth. - - ## Complete Example - - ``` - vgraph techChoice: IBIS "Which database should we use?" { - node q1: Question "Which database should we use?" - - node a1: Answer "PostgreSQL" - node a2: Answer "MongoDB" - - edge q1 -> a1 - edge q1 -> a2 - - node pro1: Pro "ACID compliance" - node pro2: Pro "Mature ecosystem" - node con1: Con "Schema migrations can be complex" - - edge a1 -> pro1 - edge a1 -> pro2 - edge a1 -> con1 - - node pro3: Pro "Flexible schema" - node con2: Con "Weaker transaction support" - - edge a2 -> pro3 - edge a2 -> con2 - - node q2: Question "How to handle schema migrations?" - edge con1 -> q2 - - node a3: Answer "Use Flyway or Liquibase" - edge q2 -> a3 - - node pro4: Pro "Industry-standard tooling" - edge a3 -> pro4 - } - ``` - - ## Rules - - 1. ALWAYS start with a root Question — it frames the entire diagram - 2. Follow the structure: Question -> Answer -> Pro/Con - 3. Use Questions to drill down — attach them to any node that needs exploration - 4. Keep labels concise — Questions as questions, Answers as noun phrases, Pros/Cons as short statements - 5. Use meaningful IDs (q1, mainIdea, costCon — not n1, n2, n3) - 6. Each Answer should have at least one Pro or Con to be useful - 7. Avoid orphan nodes — every node must connect to the tree - """ - } -} diff --git a/Sources/VGraphMCPTools/MCPInfrastructure.swift b/Sources/VGraphMCPTools/MCPInfrastructure.swift deleted file mode 100644 index 2196c27..0000000 --- a/Sources/VGraphMCPTools/MCPInfrastructure.swift +++ /dev/null @@ -1,48 +0,0 @@ -// Shared infrastructure for MCP tools: logging and application setup. - -import App -import Foundation -import VGraph - -/// Logger that writes to stderr (stdout is reserved for MCP JSON-RPC) -public struct StderrLogger: ForLogMessages { - public let level: LogLevel - private let sink: LogSink - - public init( - environment: [String: String] = ProcessInfo.processInfo.environment, - sink: @escaping LogSink = { FileHandle.standardError.write(Data(($0 + "\n").utf8)) } - ) { - self.level = LogLevel(environment: environment) - self.sink = sink - } - - public func log(_ message: String) { emit(.info, message) } - public func warn(_ message: String) { emit(.warn, "WARN: " + message) } - public func debug(_ message: String) { emit(.debug, "DEBUG: " + message) } - public func error(_ message: String) { emit(.error, "ERROR: " + message) } - - private func emit(_ messageLevel: LogLevel, _ line: String) { - guard messageLevel >= level else { return } - sink("[vgraph-mcp] " + line) - } -} - -/// VGraphApplication configured for MCP (logs to stderr, not stdout). -/// -/// Only the logger is MCP-specific (stderr, because stdout carries JSON-RPC); -/// the wiring is `NativePorts`, shared with the CLI, the WASM editor and the -/// tests. This root previously assembled its own pipeline and had drifted — it -/// applied folding but *not* the notation phase, so MCP rendered -/// notations (and `vnotation` blocks) differently from everything else. -public typealias VGraphMCPApp = VGraphApplication<NativePorts<StderrLogger>> - -extension VGraphMCPApp { - public init(forMCP: Void = ()) { - self.init(logger: StderrLogger()) - } - - public init(logger: StderrLogger) { - self.init(ports: NativePorts(logger: logger)) - } -} diff --git a/Sources/VGraphMCPTools/MCPLimits.swift b/Sources/VGraphMCPTools/MCPLimits.swift deleted file mode 100644 index e6274a0..0000000 --- a/Sources/VGraphMCPTools/MCPLimits.swift +++ /dev/null @@ -1,42 +0,0 @@ -import Foundation - -/// Every bound on what one request may cost, in one place. -/// -/// The hosted server is open to anyone, and in-process Graphviz layout cannot be -/// cancelled, so the worst case is bounded by bounding the input; a deadline can -/// only abandon work, not stop it. -public struct MCPLimits: Sendable { - public var maxBodyBytes = 1 << 20 - public var maxVGLBytes = 256 << 10 - public var maxNodes = 500 - public var maxEdges = 1000 - public var maxViews = 8 - - public var maxPixels = 25_000_000 - public var maxPNGBytes = 32 << 20 - public var pngTimeoutSeconds = 20.0 - public var pngConcurrency = 4 - - public var idleTimeoutSeconds = 60.0 - public var readTimeoutSeconds = 15.0 - /// Shorter than the Cloud Run `--timeout`, so the client gets an answer. - public var requestDeadlineSeconds = 120.0 - - public init() {} - - public static let standard = MCPLimits() - - /// The first limit a document breaks, checked cheapest first: its length - /// before it is parsed, its size once it is. - func refusal(vglBytes: Int) -> String? { - vglBytes > maxVGLBytes - ? "VGL length limit exceeded: \(vglBytes) bytes, the limit is \(maxVGLBytes)." : nil - } - - func refusal(nodes: Int, edges: Int, views: Int) -> String? { - if nodes > maxNodes { return "node limit exceeded: \(nodes) nodes, the limit is \(maxNodes)." } - if edges > maxEdges { return "edge limit exceeded: \(edges) edges, the limit is \(maxEdges)." } - if views > maxViews { return "view limit exceeded: \(views) views, the limit is \(maxViews)." } - return nil - } -} diff --git a/Sources/VGraphMCPTools/PNGConverter.swift b/Sources/VGraphMCPTools/PNGConverter.swift deleted file mode 100644 index a5ed329..0000000 --- a/Sources/VGraphMCPTools/PNGConverter.swift +++ /dev/null @@ -1,243 +0,0 @@ -import Foundation - -public enum PNGResult: Sendable, Equatable { - case png(Data) - case unavailable - case timedOut - case outputTooLarge - case failed -} - -/// At most `limit` conversions at once. Each one holds an rsvg-convert process and -/// its whole bitmap in memory, and the instance has 1 GiB. -public actor ConcurrencyGate { - private let limit: Int - private var running = 0 - private var waiters: [CheckedContinuation<Void, Never>] = [] - - public init(limit: Int) { - self.limit = max(1, limit) - } - - deinit { - for waiter in waiters { waiter.resume() } - } - - public func acquire() async { - if running < limit { - running += 1 - return - } - await withCheckedContinuation { waiters.append($0) } - } - - /// Hands the place straight to the longest waiter, so it cannot be overtaken. - public func release() { - if waiters.isEmpty { - running -= 1 - } else { - waiters.removeFirst().resume() - } - } -} - -/// Converts SVG to PNG with rsvg-convert, within `MCPLimits`. -public final class PNGConverter: Sendable { - private let executable: String? - private let limits: MCPLimits - private let gate: ConcurrencyGate - - public init(executable: String? = nil, limits: MCPLimits = .standard) { - self.executable = executable ?? Self.findRsvgConvert() - self.limits = limits - self.gate = ConcurrencyGate(limit: limits.pngConcurrency) - _ = Self.ignoreBrokenPipes - } - - public static let shared = PNGConverter() - - /// A child that exits before reading its input must not kill the server. - private static let ignoreBrokenPipes: Void = { signal(SIGPIPE, SIG_IGN) }() - - /// rsvg-convert refuses a bitmap longer than this on either side, whatever its area. - private static let maxSidePixels = 32767.0 - - /// Our SVG is sized in plain pixels, which rsvg takes as they are (`--dpi` has no - /// effect), so the bitmap is the SVG's own size. Past `maxPixels` in area, or - /// rsvg's limit on one side, `--zoom` shrinks it by whichever rule is stricter. - static func arguments(forSVG svg: String, limits: MCPLimits) -> [String] { - guard let (width, height) = size(of: svg), width > 0, height > 0 else { return ["--format=png"] } - let byArea = (Double(limits.maxPixels) / (width * height)).squareRoot() - let bySide = maxSidePixels / max(width, height) - let zoom = (min(1, byArea, bySide) * 10_000).rounded(.down) / 10_000 - return zoom < 1 ? ["--format=png", "--zoom=\(max(zoom, 0.0001))"] : ["--format=png"] - } - - private static func size(of svg: String) -> (Double, Double)? { - guard let open = svg.range(of: "<svg"), let close = svg[open.upperBound...].firstIndex(of: ">") else { - return nil - } - let tag = String(svg[open.upperBound..<close]) - func number(_ attribute: String, in text: String) -> Double? { - guard let match = text.range(of: #"\b\#(attribute)="\s*([0-9.]+)"#, options: .regularExpression) else { - return nil - } - return Double(text[match].filter { $0.isNumber || $0 == "." }) - } - if let width = number("width", in: tag), let height = number("height", in: tag) { - return (width, height) - } - guard let box = tag.range(of: #"viewBox="[^"]*""#, options: .regularExpression) else { return nil } - let parts = tag[box].dropFirst(9).dropLast().split(whereSeparator: { $0 == " " || $0 == "," }).compactMap { - Double($0) - } - return parts.count == 4 ? (parts[2], parts[3]) : nil - } - - public func convert(_ svg: String, logger: StderrLogger) async -> PNGResult { - guard let path = executable else { return .unavailable } - await gate.acquire() - let result = await run(svg, executable: path, logger: logger) - await gate.release() - return result - } - - private func run(_ svg: String, executable: String, logger: StderrLogger) async -> PNGResult { - let process = Process() - process.executableURL = URL(fileURLWithPath: executable) - process.arguments = Self.arguments(forSVG: svg, limits: limits) - let input = Pipe() - let output = Pipe() - let errors = Pipe() - process.standardInput = input - process.standardOutput = output - process.standardError = errors - - // Not `waitUntilExit`: it waits on a run loop, and on a dispatch worker thread - // it can miss the exit and block forever, which a conversion that had long - // finished then reports as timed out. - let exited = DispatchSemaphore(value: 0) - process.terminationHandler = { _ in exited.signal() } - - do { - try process.run() - } catch { - logRSVGFailure(.launch, logger: logger) - return .failed - } - - let maxBytes = limits.maxPNGBytes - let timeout = limits.pngTimeoutSeconds - return await withCheckedContinuation { continuation in - let outcome = Outcome(continuation) - let pid = process.processIdentifier - let kill: @Sendable () -> Void = { _ = Foundation.kill(pid, SIGKILL) } - - // Threads of their own, not the shared dispatch pool: on Linux that pool - // does not grow while its workers block, so the reads below could hold - // up the timeout until the converter exited by itself. - Thread.detachNewThread { - if !outcome.waitForDecision(seconds: timeout), outcome.finish(.timedOut) { kill() } - } - Thread.detachNewThread { - try? input.fileHandleForWriting.write(contentsOf: Data(svg.utf8)) - try? input.fileHandleForWriting.close() - } - - // Not `readDataToEndOfFile`: a killed child's own children can hold - // the pipe open, and the answer must not wait for them. - let errorText = Collected(limit: 64 << 10) - let errorsDone = DispatchSemaphore(value: 0) - Thread.detachNewThread { - while true { - let chunk = errors.fileHandleForReading.availableData - if chunk.isEmpty { break } - _ = errorText.append(chunk) - } - errorsDone.signal() - } - Thread.detachNewThread { - let png = Collected(limit: maxBytes) - while true { - let chunk = output.fileHandleForReading.availableData - if chunk.isEmpty { break } - if !png.append(chunk) { - if outcome.finish(.outputTooLarge) { kill() } - return - } - } - exited.wait() - _ = errorsDone.wait(timeout: .now() + 1) - if process.terminationStatus != 0 { - if outcome.finish(.failed) { - logRSVGFailure( - .exited(status: process.terminationStatus, stderr: errorText.string), logger: logger) - } - } else { - _ = outcome.finish(png.data.isEmpty ? .failed : .png(png.data)) - } - } - } - } - - private static func findRsvgConvert() -> String? { - [ - "/usr/bin/rsvg-convert", - "/usr/local/bin/rsvg-convert", - "/opt/homebrew/bin/rsvg-convert", - ].first { FileManager.default.isExecutableFile(atPath: $0) } - } -} - -/// Resumes its continuation once; later results are dropped. -private final class Outcome: @unchecked Sendable { - private let lock = NSLock() - private var continuation: CheckedContinuation<PNGResult, Never>? - private let decided = DispatchSemaphore(value: 0) - - init(_ continuation: CheckedContinuation<PNGResult, Never>) { - self.continuation = continuation - } - - /// False if nothing decided the result within `seconds`. - func waitForDecision(seconds: Double) -> Bool { - decided.wait(timeout: .now() + seconds) == .success - } - - /// True for the first call, which is the one that decided the result. - func finish(_ result: PNGResult) -> Bool { - lock.lock() - let pending = continuation - continuation = nil - lock.unlock() - guard let pending else { return false } - decided.signal() - pending.resume(returning: result) - return true - } -} - -private final class Collected: @unchecked Sendable { - private let lock = NSLock() - private let limit: Int - private var bytes = Data() - - init(limit: Int) { self.limit = limit } - - /// False once more than `limit` bytes have been offered. - func append(_ chunk: Data) -> Bool { - lock.lock() - defer { lock.unlock() } - guard bytes.count + chunk.count <= limit else { return false } - bytes.append(chunk) - return true - } - - var data: Data { - lock.lock() - defer { lock.unlock() } - return bytes - } - - var string: String { String(data: data, encoding: .utf8) ?? "<unreadable>" } -} diff --git a/Sources/VGraphMCPTools/TimelineTool.swift b/Sources/VGraphMCPTools/TimelineTool.swift deleted file mode 100644 index 1eb30b4..0000000 --- a/Sources/VGraphMCPTools/TimelineTool.swift +++ /dev/null @@ -1,182 +0,0 @@ -// MCP tool for creating Timeline diagrams from VGL. - -import Foundation -import MCP -import VGraph - -public enum TimelineTool: VGraphTool { - public static let name = "create_timeline" - public static let errorNoun = "timeline" - public static let notationName = "Timeline" - - public static let purposeSentence = """ - A Timeline visualises events over time, \ - optionally across multiple parallel tracks (groups). The default layout is left-to-right \ - but can be changed to any direction. The base notation provides generic TimePoint and Event \ - types — use `vnotation extends Timeline` to define domain-specific event types (e.g. Battle, \ - Treaty, Release, Incident) with custom colours and categories. - """ - - public static let vglParameterDescription = """ - Valid VGL code using the Timeline notation. Either \ - `vgraph <id>: Timeline "<title>" { ... }` directly, or a \ - `vnotation <Name> extends Timeline { ... }` block followed by \ - `vgraph <id>: <Name> "<title>" { ... }`. - """ - - private static let entry = Notations.Timeline.entry - - public static var descriptionBody: String { - """ - ## Core Concept: alignGroup - - The key mechanism is the `alignGroup` attribute. Nodes sharing the same `alignGroup` value \ - are placed at the same position in the layout — pinned to the same column (left-to-right) \ - or the same row (top-to-bottom). This is what creates time alignment. - - ``` - node t1800: TimePoint "1800" [alignGroup: "1800"] - node e1: Event "Something happened" [alignGroup: "1800"] - ``` - - These two nodes will appear at the same horizontal position because they share alignGroup "1800". - - ## How to Build a Timeline - - 1. Choose a title that describes the scope of the timeline. - 2. Decide whether you need TimePoints (axis markers) or whether alignGroup alone suffices. - 3. Add Events for things that happened, each with an `alignGroup` matching its time. - 4. Use `sequence` edges between TimePoints to form the visible time axis. - 5. Use `influence` edges between Events to show causal or contextual links. - 6. Optionally use groups to create named parallel tracks (countries, teams, systems). - - ## VGL Syntax - - ``` - vgraph <id>: Timeline "<title>" { - <nodes, edges, and groups> - } - ``` - - ### Node Types - - \(NotationMarkdown.nodeTypeBullets(entry.nodeTypeDefinitions)) - - ``` - node <id>: TimePoint "<label>" [alignGroup: "<time_value>"] - node <id>: Event "<label>" [alignGroup: "<time_value>"] - ``` - - ALWAYS include `alignGroup` on every node to ensure correct time alignment. - - ### Edges - - \(NotationMarkdown.edgeTypeBullets(entry.edgeTypeDefinitions)) - - `influence` can optionally carry a label. - - ``` - edge <from_id> -> <to_id>: sequence - edge <from_id> -> <to_id>: influence - edge <from_id> -> <to_id>: influence "<label>" - ``` - - ### Groups (Tracks) - - Groups create named parallel tracks rendered as labelled cluster boxes. Groups are optional. - - ``` - group <id> "<label>" { - node <id>: Event "<label>" [alignGroup: "<value>"] - } - ``` - - ## Changing Layout Direction - - The default is left-to-right. Use `vnotation extends Timeline` to change direction. \ - All four directions are supported: `topToBottom`, `bottomToTop`, `leftToRight`, `rightToLeft`. - - ``` - vnotation VerticalTimeline extends Timeline { - layout: topToBottom - } - - vgraph myTimeline: VerticalTimeline "My Timeline" { - ... - } - ``` - - ## Custom Event Types with vnotation - - For domain-specific timelines, use `vnotation extends Timeline` to add custom node types, \ - edge types, and change the layout — all in one block. The base TimePoint and Event types \ - plus sequence and influence edges remain available. - - ``` - vnotation WarTimeline extends Timeline { - layout: topToBottom - node type: Battle [nodeStyle: withCategory, color: "#883333", category: "Battle"] - node type: Treaty [nodeStyle: withCategory, color: "#339933", category: "Treaty"] - edge type: resolved_by from: Battle to: Treaty - edge type: influenced from: Battle to: Battle - } - - vgraph napoleonicWars: WarTimeline "Napoleonic Wars" { - node t1805: TimePoint "1805" [alignGroup: "1805"] - node t1812: TimePoint "1812" [alignGroup: "1812"] - node t1815: TimePoint "1815" [alignGroup: "1815"] - edge t1805 -> t1812: sequence - edge t1812 -> t1815: sequence - node f1: Battle "Battle of Austerlitz" [alignGroup: "1805"] - node f2: Battle "Invasion of Russia" [alignGroup: "1812"] - node f3: Battle "Battle of Waterloo" [alignGroup: "1815"] - node e1: Treaty "Treaty of Pressburg" [alignGroup: "1805"] - node e2: Treaty "Congress of Vienna" [alignGroup: "1815"] - edge f1 -> e1: resolved_by - edge f3 -> e2: resolved_by - edge f1 -> f2: influenced "overconfidence" - edge f2 -> f3: influenced "weakened army" - } - ``` - - ## Basic Example (without vnotation) - - ``` - vgraph europe: Timeline "19th Century Europe" { - node t1800: TimePoint "1800" [alignGroup: "1800"] - node t1850: TimePoint "1850" [alignGroup: "1850"] - node t1871: TimePoint "1871" [alignGroup: "1871"] - edge t1800 -> t1850: sequence - edge t1850 -> t1871: sequence - - group germany "Germany" { - node g1: Event "Napoleon defeats Prussia" [alignGroup: "1800"] - node g2: Event "German Unification" [alignGroup: "1871"] - } - - group england "England" { - node e1: Event "Industrial Revolution peaks" [alignGroup: "1850"] - node e2: Event "Franco-Prussian War impact" [alignGroup: "1871"] - } - - edge g1 -> g2: influence "led to" - edge e1 -> e2: influence - edge e1 -> g2: influence "industrialization enabled" - } - ``` - - ## Rules - - 1. ALWAYS use `alignGroup` on every node to ensure correct time alignment. - 2. TimePoints are optional — alignGroup alone suffices for alignment. - 3. Keep TimePoint labels short (dates, phase names). - 4. Use influence edges sparingly — only for meaningful causal or contextual links. - 5. Use meaningful IDs (t1800, battleOfWaterloo — not n1, n2). - 6. Groups are optional — use them when you have distinct parallel tracks. - 7. When you need domain-specific event types, use `vnotation extends Timeline` — \ - don't overload the generic Event type. - 8. When changing layout direction, always use `vnotation extends Timeline` with a \ - `layout:` directive — the base Timeline is always left-to-right. - """ - } -} diff --git a/Sources/VGraphMCPTools/VGraphTool.swift b/Sources/VGraphMCPTools/VGraphTool.swift deleted file mode 100644 index ec90792..0000000 --- a/Sources/VGraphMCPTools/VGraphTool.swift +++ /dev/null @@ -1,175 +0,0 @@ -// Protocol and default implementations for VGraph MCP tools. -// Change shared phrasing (e.g. output format) here — all tools pick it up. - -import App -import Foundation -import MCP -import VGraph - -// MARK: - Protocol - -/// Each notation tool provides these five properties; everything else is derived. -public protocol VGraphTool { - /// MCP tool name, e.g. "create_concept_map" - static var name: String { get } - /// Noun for error messages, e.g. "concept map" - static var errorNoun: String { get } - /// Notation name used in VGL, e.g. "ConceptMap" - static var notationName: String { get } - /// One-sentence purpose (appears right after "Create a … diagram as SVG image.") - static var purposeSentence: String { get } - /// Description of the `vgl` parameter for the JSON schema - static var vglParameterDescription: String { get } - /// Notation-specific markdown (node types, edges, examples, rules) - static var descriptionBody: String { get } -} - -// MARK: - Shared defaults - -/// Change this to update all tool descriptions at once. -private let sharedOutputFormat = "PNG image" - -extension VGraphTool { - - public static var description: String { - """ - Create a \(notationName) diagram as \(sharedOutputFormat). \(purposeSentence) - - You provide VGL (Vithanco Graph Language) code using the \(notationName) notation and the \ - tool renders it to an \(sharedOutputFormat). - - \(descriptionBody) - """ - } - - public static var definition: Tool { - Tool( - name: name, - description: description, - inputSchema: .object([ - "type": .string("object"), - "properties": .object([ - "vgl": .object([ - "type": .string("string"), - "description": .string(vglParameterDescription), - ]) - ]), - "required": .array([.string("vgl")]), - "additionalProperties": .bool(false), - ]) - ) - } - - private static func pngFailure(_ result: PNGResult, noun: String) -> String { - switch result { - case .timedOut: "converting the \(noun) to PNG timed out; reduce the diagram's size." - case .outputTooLarge: "the PNG of the \(noun) would be too large; reduce the diagram's size." - default: "failed to render \(noun) to PNG (rsvg-convert unavailable or conversion failed)." - } - } - - public static func handle(_ params: CallTool.Parameters) async -> CallTool.Result { - await handle(params, logger: StderrLogger()) - } - - public static func handle( - _ params: CallTool.Parameters, - logger: StderrLogger, - limits: MCPLimits = .standard, - png: PNGConverter = .shared - ) async -> CallTool.Result { - guard let vgl = params.arguments?["vgl"]?.stringValue else { - return .init( - content: [.text(text: "Error: 'vgl' parameter is required.", annotations: nil, _meta: nil)], - isError: true - ) - } - - if let refusal = limits.refusal(vglBytes: vgl.utf8.count) { - return .init(content: [.text(text: "Error: \(refusal)", annotations: nil, _meta: nil)], isError: true) - } - - let renderStart = Date() - let app = VGraphMCPApp(logger: logger) - let graph: VGraph - let renderings: [(caption: String?, result: RenderResult<VGraphMCPApp.Drawing>)] - do { - graph = try app.parseGraph(vgl) - if let refusal = limits.refusal(nodes: graph.nodes.count, edges: graph.edges.count, views: graph.views.count) { - return .init(content: [.text(text: "Error: \(refusal)", annotations: nil, _meta: nil)], isError: true) - } - // The default view first, then each declared view; captions only when views exist. - let shown: [(caption: String?, view: String?)] = - graph.views.isEmpty - ? [(nil, nil)] - : [("default", nil)] + graph.views.map { ("\($0.name)\($0.label.map { ": \($0)" } ?? "")", $0.name) } - renderings = try shown.map { (caption: $0.caption, result: try app.renderGraph(graph: graph, sourceVGL: vgl, view: $0.view)) } - } catch { - return .init( - content: [.text(text: "Error rendering \(errorNoun): \(error)", annotations: nil, _meta: nil)], - isError: true - ) - } - - let renderElapsed = Date().timeIntervalSince(renderStart) - let graphvizTimeoutSeconds = 30 - var content: [Tool.Content] = [] - // Findings are the model's, so every view carries the same report. - if let qualityText = renderings[0].result.qualityReport.formatted() { - content.append(.text(text: qualityText, annotations: nil, _meta: nil)) - } - if renderElapsed > 5.0 { - let secs = Int(renderElapsed.rounded()) - content.append( - .text( - text: "⚠️ Render took \(secs)s of \(graphvizTimeoutSeconds)s limit — reduce diagram complexity to avoid timeouts.", - annotations: nil, _meta: nil) - ) - } - for (caption, result) in renderings { - let converted = await png.convert(result.svg, logger: logger) - guard case .png(let pngData) = converted else { - return .init( - content: [.text(text: "Error: \(Self.pngFailure(converted, noun: errorNoun))", annotations: nil, _meta: nil)], - isError: true - ) - } - if let caption { content.append(.text(text: caption, annotations: nil, _meta: nil)) } - content.append(.image(data: pngData.base64EncodedString(), mimeType: "image/png", annotations: nil, _meta: nil)) - } - return .init(content: content, isError: false) - } -} - -// MARK: - Tool Registry - -/// All available VGraph tools. Add new tools here — no server changes needed. -public enum VGraphTools { - public static let all: [(definition: Tool, handle: @Sendable (CallTool.Parameters) async -> CallTool.Result)] = [ - (CLDTool.definition, CLDTool.handle), - (ConceptMapTool.definition, ConceptMapTool.handle), - (DecomposeTool.definition, DecomposeTool.handle), - (DescribeNotationTool.definition, DescribeNotationTool.handle), - (IBISTool.definition, IBISTool.handle), - (TimelineTool.definition, TimelineTool.handle), - ] -} - -// MARK: - rsvg-convert failures - -enum RSVGFailure { - case launch - case exited(status: Int32, stderr: String) -} - -/// rsvg-convert's own stderr quotes the SVG it choked on, labels included, so the -/// text is debug-only; the default level keeps the status. -func logRSVGFailure(_ failure: RSVGFailure, logger: StderrLogger) { - switch failure { - case .launch: - logger.warn("rsvg-convert failed to launch") - case .exited(let status, let stderr): - logger.warn("rsvg-convert exited \(status)") - logger.debug("rsvg-convert stderr: \(stderr)") - } -} diff --git a/Tests/AppTests/ArchitectureTest.swift b/Tests/AppTests/ArchitectureTest.swift index 597543d..c921583 100644 --- a/Tests/AppTests/ArchitectureTest.swift +++ b/Tests/AppTests/ArchitectureTest.swift @@ -108,10 +108,8 @@ struct ArchitectureTest { let adapters: Set<String> = ["VGraphSVG", "VGLanguage", "VGraphvizLib"] var violations: [String] = [] - for driver in [ - "Sources/VGraphCLI", "Sources/VGraphMCP", "Sources/VGraphMCPHTTP", - "Sources/VGraphMCPHTTPKit", "Sources/VGraphMCPTools", "Tests/TestSupport", - ] { + // vgraph-mcp holds its own servers to the same rule. + for driver in ["Sources/VGraphCLI", "Tests/TestSupport"] { for file in try requiredSwiftFiles(under: driver) { let source = try String(contentsOf: file, encoding: .utf8) for module in importedModules(in: source) where adapters.contains(module) { diff --git a/Tests/IntegrationTests/DockerIntegrationTests.swift b/Tests/IntegrationTests/DockerIntegrationTests.swift deleted file mode 100644 index c2cfdc4..0000000 --- a/Tests/IntegrationTests/DockerIntegrationTests.swift +++ /dev/null @@ -1,112 +0,0 @@ -// Integration tests for Docker/Linux functionality - -import Foundation -import Testing - -@Suite(.tags(.integration)) -struct DockerIntegrationTests { - - // MARK: - Host-side Docker infrastructure tests - - private func findProjectRoot() -> String? { - var currentPath = FileManager.default.currentDirectoryPath - while currentPath != "/" { - if FileManager.default.fileExists(atPath: currentPath + "/Package.swift") { - return currentPath - } - currentPath = (currentPath as NSString).deletingLastPathComponent - } - return nil - } - - // The cloud-image build moved from dockerBuild.sh into the justfile - // (`just build-cloud-image`); these assert that recipe is present and correct. - @Test - func testCloudImageRecipeExists() throws { - guard let root = findProjectRoot() else { - throw TestError.projectRootNotFound - } - let justfile = try String(contentsOfFile: root + "/justfile", encoding: .utf8) - - #expect(justfile.contains("build-cloud-image:"), "justfile should define a build-cloud-image recipe") - #expect(justfile.contains("docker build"), "build-cloud-image should run docker build") - } - - @Test - func testCloudImageRecipeTargetsLinuxAmd64() throws { - guard let root = findProjectRoot() else { - throw TestError.projectRootNotFound - } - let justfile = try String(contentsOfFile: root + "/justfile", encoding: .utf8) - - #expect(justfile.contains("--platform linux/amd64"), "Cloud Run image must be built for linux/amd64") - } - - @Test - func testDockerfileExists() throws { - guard let root = findProjectRoot() else { - throw TestError.projectRootNotFound - } - let fileManager = FileManager.default - let dockerfile = root + "/Dockerfile" - - #expect(fileManager.fileExists(atPath: dockerfile), "Dockerfile should exist") - } - - @Test - func testDockerfileContainsRequiredDirectives() throws { - guard let root = findProjectRoot() else { - throw TestError.projectRootNotFound - } - let dockerfile = root + "/Dockerfile" - let content = try String(contentsOfFile: dockerfile, encoding: .utf8) - - #expect(content.contains("FROM swift:"), "Dockerfile should specify a Swift base image") - #expect(content.contains("ENTRYPOINT"), "Dockerfile should define an entrypoint") - #expect(content.contains("vgraph-mcp"), "Dockerfile should reference vgraph-mcp") - } - - // MARK: - Container-side tests (Linux only) - - @Test - func testDockerBuildSucceeds() throws { - #if os(Linux) - // This test runs inside Docker on Linux - // Verify Graphviz is available at expected location - let dotPath = "/usr/bin/dot" - let fileManager = FileManager.default - - #expect(fileManager.fileExists(atPath: dotPath), "Graphviz dot should be installed at \(dotPath)") - #expect(fileManager.isExecutableFile(atPath: dotPath), "Graphviz dot should be executable") - #endif - } - - @Test - func testNonRootUserExecution() throws { - #if os(Linux) - // Verify we're running as non-root user in Docker - let process = Process() - process.executableURL = URL(fileURLWithPath: "/usr/bin/whoami") - - let pipe = Pipe() - process.standardOutput = pipe - - try process.run() - process.waitUntilExit() - - let data = pipe.fileHandleForReading.readDataToEndOfFile() - let username = String(data: data, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines) - - #expect(username != "root", "Container should not run as root user") - #expect(username == "vgraph", "Container should run as vgraph user") - #endif - } -} - -extension Tag { - @Tag static var integration: Self -} - -enum TestError: Error { - case projectRootNotFound -} diff --git a/Tests/IntegrationTests/LogPolicyDocsTests.swift b/Tests/IntegrationTests/LogPolicyDocsTests.swift index a0c586c..f958cb2 100644 --- a/Tests/IntegrationTests/LogPolicyDocsTests.swift +++ b/Tests/IntegrationTests/LogPolicyDocsTests.swift @@ -11,11 +11,6 @@ struct LogPolicyDocsTests { return try String(contentsOf: url.appendingPathComponent(path), encoding: .utf8) } - @Test("The Dockerfile sets VGRAPH_LOG_LEVEL to warn") - func dockerfileSetsLevel() throws { - #expect(try read("Dockerfile").contains("ENV VGRAPH_LOG_LEVEL=warn")) - } - @Test("The hosted-server privacy note says diagrams are not stored, logs hold request metadata and warnings, and names VGRAPH_LOG_LEVEL") func privacyNote() throws { let note = try read("SECURITY.md") @@ -23,9 +18,4 @@ struct LogPolicyDocsTests { #expect(note.contains("request metadata and warnings")) #expect(note.contains("VGRAPH_LOG_LEVEL")) } - - @Test("The README of the Node server points to the same note") - func nodeReadmePoints() throws { - #expect(try read("vgraph-mcp-node/README.md").contains("SECURITY.md")) - } } diff --git a/Tests/VGraph-Package.xctestplan b/Tests/VGraph-Package.xctestplan index d8bc3c3..c09ee1d 100644 --- a/Tests/VGraph-Package.xctestplan +++ b/Tests/VGraph-Package.xctestplan @@ -64,13 +64,6 @@ "identifier" : "IntegrationTests", "name" : "IntegrationTests" } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "VGraphMCPTests", - "name" : "VGraphMCPTests" - } } ], "version" : 1 diff --git a/Tests/VGraphMCPHTTPTests/HTTPLimitsTests.swift b/Tests/VGraphMCPHTTPTests/HTTPLimitsTests.swift deleted file mode 100644 index d332532..0000000 --- a/Tests/VGraphMCPHTTPTests/HTTPLimitsTests.swift +++ /dev/null @@ -1,227 +0,0 @@ -import Foundation -import Logging -import MCP -import NIOCore -import NIOEmbedded -import NIOHTTP1 -import Testing -import VGraphMCPTools - -@testable import VGraphMCPHTTPKit - -private actor Calls { - private(set) var bodies: [Int] = [] - func record(_ n: Int) { bodies.append(n) } -} - -private func ok(_ request: NIOHTTPRequest) -> NIOHTTPResponse { - NIOHTTPResponse(statusCode: 200, headers: [:], body: Data("answered".utf8)) -} - -private func channel( - limits: MCPLimits = .standard, - handle: @escaping @Sendable (NIOHTTPRequest) async -> NIOHTTPResponse = { ok($0) } -) async throws -> NIOAsyncTestingChannel { - let channel = NIOAsyncTestingChannel() - try await channel.pipeline.addHandler(HTTPHandler(limits: limits, handle: handle)) - try await channel.connect(to: SocketAddress(ipAddress: "127.0.0.1", port: 1)) - return channel -} - -private func post(length: Int?, chunked: Bool = false) -> HTTPServerRequestPart { - var headers = HTTPHeaders() - if let length { headers.add(name: "Content-Length", value: String(length)) } - if chunked { headers.add(name: "Transfer-Encoding", value: "chunked") } - return .head(HTTPRequestHead(version: .http1_1, method: .POST, uri: "/mcp", headers: headers)) -} - -private func chunk(_ size: Int) -> HTTPServerRequestPart { - .body(ByteBuffer(repeating: UInt8(ascii: "x"), count: size)) -} - -/// The next response part, or nil if none arrives in time. Polls: waiting on the -/// channel cannot be cancelled, so a missing response would hang the suite. -private func nextResponse(_ channel: NIOAsyncTestingChannel, seconds: Double = 2) async -> HTTPServerResponsePart? { - let deadline = Date().addingTimeInterval(seconds) - while Date() < deadline { - if let part = try? await channel.readOutbound(as: HTTPServerResponsePart.self) { return part } - try? await Task.sleep(for: .milliseconds(20)) - } - return nil -} - -private func status(_ channel: NIOAsyncTestingChannel) async -> Int? { - if case .head(let head)? = await nextResponse(channel) { return Int(head.status.code) } - return nil -} - -private let oneMiB = 1 << 20 - -@Suite("Body cap — HTTP layer") -struct BodyCapTests { - @Test("Given a POST announcing 2 MiB, when its head arrives, then 413 is sent before any body is read") - func announcedTooLarge() async throws { - let channel = try await channel() - try await channel.writeInbound(post(length: 2 * oneMiB)) - #expect(await status(channel) == 413) - } - - @Test("Given a chunked POST with no length, when it passes 1 MiB, then 413 is sent and the rest is not buffered") - func chunkedTooLarge() async throws { - let calls = Calls() - let channel = try await channel(handle: { request in - await calls.record(request.body?.count ?? 0) - return ok(request) - }) - try await channel.writeInbound(post(length: nil, chunked: true)) - for _ in 0..<5 { try await channel.writeInbound(chunk(256 << 10)) } - #expect(await status(channel) == 413) - try await channel.writeInbound(chunk(256 << 10)) - try await channel.writeInbound(HTTPServerRequestPart.end(nil)) - try await Task.sleep(for: .milliseconds(100)) - #expect(await calls.bodies.isEmpty) - } - - @Test("Given a POST of exactly 1 MiB, when received, then it reaches the MCP transport") - func exactlyAtLimit() async throws { - let calls = Calls() - let channel = try await channel(handle: { request in - await calls.record(request.body?.count ?? 0) - return ok(request) - }) - try await channel.writeInbound(post(length: oneMiB)) - for _ in 0..<4 { try await channel.writeInbound(chunk(256 << 10)) } - try await channel.writeInbound(HTTPServerRequestPart.end(nil)) - #expect(await status(channel) == 200) - #expect(await calls.bodies == [oneMiB]) - } - - @Test("Given a 413, when read, then its text names the 1 MiB limit") - func messageNamesLimit() async throws { - let channel = try await channel() - try await channel.writeInbound(post(length: 2 * oneMiB)) - _ = await nextResponse(channel) - var text = "" - if case .body(.byteBuffer(let buffer))? = await nextResponse(channel) { - text = String(buffer: buffer) - } - #expect(text.contains("1 MiB")) - } - - @Test("Given a small POST, when received, then it is handled as today") - func smallPost() async throws { - let channel = try await channel() - try await channel.writeInbound(post(length: 5)) - try await channel.writeInbound(chunk(5)) - try await channel.writeInbound(HTTPServerRequestPart.end(nil)) - #expect(await status(channel) == 200) - } -} - -@Suite("Timeouts — HTTP layer") -struct TimeoutTests { - @Test("Given a connection that sends nothing for the idle limit, when the limit passes, then it is closed") - func idleClosed() async throws { - let channel = try await channel() - await channel.testingEventLoop.advanceTime(by: .seconds(Int64(MCPLimits.standard.idleTimeoutSeconds) + 1)) - #expect(!channel.isActive) - } - - @Test("Given a head sent and a body that stalls, when the read limit passes, then it is closed") - func readStallClosed() async throws { - let channel = try await channel() - try await channel.writeInbound(post(length: 100)) - await channel.testingEventLoop.advanceTime(by: .seconds(Int64(MCPLimits.standard.readTimeoutSeconds) + 1)) - #expect(!channel.isActive) - } - - @Test("Given a request still running at the deadline, when it passes, then 504 is sent") - func deadline() async throws { - var limits = MCPLimits.standard - limits.requestDeadlineSeconds = 0.2 - let channel = try await channel( - limits: limits, - handle: { request in - try? await Task.sleep(for: .seconds(30)) - return ok(request) - }) - try await channel.writeInbound(post(length: 0)) - try await channel.writeInbound(HTTPServerRequestPart.end(nil)) - #expect(await status(channel) == 504) - } - - @Test("Given a request that finishes before the deadline, when answered, then the answer is unchanged") - func beforeDeadline() async throws { - let channel = try await channel() - try await channel.writeInbound(post(length: 0)) - try await channel.writeInbound(HTTPServerRequestPart.end(nil)) - #expect(await status(channel) == 200) - } - - @Test("Given an over-limit request, when /health is asked next, then it answers ok") - func healthAfterRefusal() async throws { - let transport = StatelessHTTPServerTransport( - validationPipeline: StandardValidationPipeline(validators: []), - logger: Logger(label: "test")) - let app = MCPHTTPApp(transport: transport, host: "127.0.0.1", port: 0, logger: Logger(label: "test")) - - let refused = NIOAsyncTestingChannel() - try await refused.pipeline.addHandler(app.makeHandler()) - try await refused.connect(to: SocketAddress(ipAddress: "127.0.0.1", port: 1)) - try await refused.writeInbound(post(length: 2 * oneMiB)) - #expect(await status(refused) == 413) - - let next = NIOAsyncTestingChannel() - try await next.pipeline.addHandler(app.makeHandler()) - try await next.connect(to: SocketAddress(ipAddress: "127.0.0.1", port: 1)) - let head = HTTPRequestHead(version: .http1_1, method: .GET, uri: "/health") - try await next.writeInbound(HTTPServerRequestPart.head(head)) - try await next.writeInbound(HTTPServerRequestPart.end(nil)) - #expect(await status(next) == 200) - } -} - -@Suite("Cloud Run settings") -struct CloudRunSettingsTests { - private func publishRecipe() throws -> String { - var url = URL(fileURLWithPath: #filePath) - while !FileManager.default.fileExists(atPath: url.appendingPathComponent("Package.swift").path) { - url.deleteLastPathComponent() - } - let justfile = try String(contentsOf: url.appendingPathComponent("justfile"), encoding: .utf8) - let start = try #require(justfile.range(of: "publish-cloud-run:")) - let rest = justfile[start.lowerBound...] - let end = rest.range(of: "\n\n# ")?.lowerBound ?? rest.endIndex - return String(rest[..<end]) - } - - @Test("publish-cloud-run sets --max-instances") - func maxInstances() throws { #expect(try publishRecipe().contains("--max-instances")) } - - @Test("publish-cloud-run sets --concurrency") - func concurrency() throws { #expect(try publishRecipe().contains("--concurrency")) } - - @Test("publish-cloud-run sets --timeout") - func timeout() throws { #expect(try publishRecipe().contains("--timeout")) } - - @Test("publish-cloud-run sets --cpu-throttling") - func cpuThrottling() throws { #expect(try publishRecipe().contains("--cpu-throttling")) } - - @Test("Each of those flags has a comment line saying why") - func flagsAreExplained() throws { - let lines = try publishRecipe().split(separator: "\n", omittingEmptySubsequences: false).map(String.init) - for flag in ["--max-instances", "--concurrency", "--timeout", "--cpu-throttling"] { - let index = try #require(lines.firstIndex { $0.contains(flag) && !$0.trimmingCharacters(in: .whitespaces).hasPrefix("#") }) - let above = lines[..<index].reversed().prefix { $0.trimmingCharacters(in: .whitespaces).hasPrefix("#") } - #expect(above.joined().contains(flag), "\(flag) needs a comment above it naming it") - } - } - - @Test("The request deadline in the server is shorter than the Cloud Run timeout") - func deadlineBelowTimeout() throws { - let recipe = try publishRecipe() - let value = try #require(recipe.range(of: #"--timeout[= ](\d+)"#, options: .regularExpression)) - let seconds = try #require(Double(recipe[value].filter(\.isNumber))) - #expect(MCPLimits.standard.requestDeadlineSeconds < seconds) - } -} diff --git a/Tests/VGraphMCPHTTPTests/InitializeTests.swift b/Tests/VGraphMCPHTTPTests/InitializeTests.swift deleted file mode 100644 index 1890666..0000000 --- a/Tests/VGraphMCPHTTPTests/InitializeTests.swift +++ /dev/null @@ -1,44 +0,0 @@ -import Foundation -import Logging -import MCP -import Testing - -@testable import VGraphMCPHTTPKit - -private struct InitializeReply: Decodable { - struct Result: Decodable { let protocolVersion: String } - struct Failure: Decodable { let message: String } - let result: Result? - let error: Failure? -} - -private func initialize(_ app: MCPHTTPApp, protocolVersion: String = "2025-06-18") async throws -> InitializeReply { - let body = - #"{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"\#(protocolVersion)","# - + #""capabilities":{},"clientInfo":{"name":"test","version":"1"}}}"# - let response = await app.handleHTTPRequest( - NIOHTTPRequest( - method: "POST", uri: "/mcp", - headers: ["Content-Type": "application/json", "Accept": "application/json"], - body: Data(body.utf8))) - return try JSONDecoder().decode(InitializeReply.self, from: try #require(response.body)) -} - -@Suite("Hosted MCP endpoint — initialize") -struct InitializeTests { - @Test("Given a client has initialized, when a second client initializes, then it is accepted") - func secondClient() async throws { - let app = try await MCPHTTPApp.hosted(host: "127.0.0.1", port: 0, logger: Logger(label: "test")) - _ = try await initialize(app) - let second = try await initialize(app) - #expect(second.error?.message == nil) - #expect(second.result?.protocolVersion == "2025-06-18") - } - - @Test("Given a client asks for a protocol version the server lacks, when it initializes, then it is offered the latest") - func unknownVersion() async throws { - let app = try await MCPHTTPApp.hosted(host: "127.0.0.1", port: 0, logger: Logger(label: "test")) - let reply = try await initialize(app, protocolVersion: "1999-01-01") - #expect(reply.result?.protocolVersion == Version.latest) - } -} diff --git a/Tests/VGraphMCPHTTPTests/RequestIDTests.swift b/Tests/VGraphMCPHTTPTests/RequestIDTests.swift deleted file mode 100644 index 170fd00..0000000 --- a/Tests/VGraphMCPHTTPTests/RequestIDTests.swift +++ /dev/null @@ -1,142 +0,0 @@ -import Foundation -import Logging -import MCP -import Testing - -@testable import VGraphMCPHTTPKit - -// Drop `withKnownIssue` once an SDK release containing swift-sdk#298 is pinned. - -private actor Arrivals { - private(set) var count = 0 - func arrive() { count += 1 } -} - -private actor Replies { - private(set) var all: [Reply] = [] - func add(_ reply: Reply) { all.append(reply) } -} - -private struct Reply: Decodable, Sendable { - let id: Value - let result: CallTool.Result? - - var marker: String? { - guard case .text(let text, _, _)? = result?.content.first else { return nil } - return text - } -} - -/// A hosted endpoint whose only tool echoes its `marker` argument once -/// `inFlight` calls have arrived, so the calls are guaranteed to overlap. -private func endpoint(inFlight: Int) async throws -> MCPHTTPApp { - let arrivals = Arrivals() - let server = Server(name: "test", version: "1", capabilities: .init(tools: .init(listChanged: false))) - await server.withMethodHandler(CallTool.self) { params in - await arrivals.arrive() - let deadline = Date().addingTimeInterval(2) - while await arrivals.count < inFlight, Date() < deadline { - try? await Task.sleep(for: .milliseconds(10)) - } - let marker = params.arguments?["marker"]?.stringValue ?? "" - return .init(content: [.text(text: marker, annotations: nil, _meta: nil)]) - } - let transport = StatelessHTTPServerTransport( - validationPipeline: StandardValidationPipeline(validators: []), - logger: Logger(label: "test")) - try await server.start(transport: transport) - return MCPHTTPApp(transport: transport, host: "127.0.0.1", port: 0, logger: Logger(label: "test")) -} - -private func call(id: String, marker: String) -> NIOHTTPRequest { - let body = - #"{"jsonrpc":"2.0","id":\#(id),"method":"tools/call","# - + #""params":{"name":"echo","arguments":{"marker":"\#(marker)"}}}"# - return NIOHTTPRequest( - method: "POST", uri: "/mcp", - headers: ["Content-Type": "application/json", "Accept": "application/json"], - body: Data(body.utf8)) -} - -/// The replies that arrive within a few seconds. A colliding call never -/// returns, so the calls run as unstructured tasks the test does not wait on. -private func send(_ requests: [NIOHTTPRequest], to app: MCPHTTPApp) async -> [Reply] { - let replies = Replies() - for request in requests { - Task { - let response = await app.handleHTTPRequest(request) - if let body = response.body, let reply = try? JSONDecoder().decode(Reply.self, from: body) { - await replies.add(reply) - } - } - } - let deadline = Date().addingTimeInterval(4) - while await replies.all.count < requests.count, Date() < deadline { - try? await Task.sleep(for: .milliseconds(20)) - } - return await replies.all -} - -private let markers = ["m1", "m2", "m3", "m4"] -private let callsWithID1 = markers.map { call(id: "1", marker: $0) } - -@Suite("Hosted MCP endpoint — overlapping tool calls") -struct OverlappingCallsTests { - @Test("Given four overlapping calls with distinct ids, when the server answers, then every call gets a response") - func distinctIDs() async throws { - let app = try await endpoint(inFlight: 4) - let replies = await send(zip(1..., markers).map { call(id: "\($0)", marker: $1) }, to: app) - #expect(replies.count == 4) - } - - @Test("Given four overlapping calls that all use id 1, when the server answers, then every call gets a response") - func sameIDAllAnswered() async throws { - let app = try await endpoint(inFlight: 4) - let replies = await send(callsWithID1, to: app) - withKnownIssue("swift-sdk#254: a second waiter with the same id replaces the first") { - #expect(replies.count == 4) - } - } - - @Test( - "Given four overlapping calls that all use id 1 with different markers, when the server answers, then each response carries its own call's marker" - ) - func sameIDOwnMarker() async throws { - let app = try await endpoint(inFlight: 4) - let replies = await send(callsWithID1, to: app) - withKnownIssue("swift-sdk#265: a response can reach the other call with the same id") { - #expect(replies.compactMap { $0.marker }.sorted() == markers) - } - } - - @Test("Given four overlapping calls that all use id 1, when the server answers, then every response carries id 1") - func sameIDKeepsID() async throws { - let app = try await endpoint(inFlight: 4) - let replies = await send(callsWithID1, to: app) - #expect(!replies.isEmpty) - #expect(replies.allSatisfy { $0.id == .int(1) }) - } - - @Test("Given two overlapping calls with id 1 and id \"1\", when the server answers, then both get a response") - func numberAndStringID() async throws { - let app = try await endpoint(inFlight: 2) - let replies = await send([call(id: "1", marker: "m1"), call(id: #""1""#, marker: "m2")], to: app) - withKnownIssue("swift-sdk#254: ids are compared as strings, so 1 and \"1\" collide") { - #expect(replies.count == 2) - } - } -} - -@Suite("Hosted MCP endpoint — one client reusing an id") -struct ReusedIDTests { - @Test( - "Given a call with id 1 that has been answered, when the client sends another call with id 1, then it gets a response" - ) - func sequentialSameID() async throws { - let app = try await endpoint(inFlight: 1) - let first = await send([call(id: "1", marker: "m1")], to: app) - let second = await send([call(id: "1", marker: "m2")], to: app) - #expect(first.count == 1) - #expect(second.map { $0.marker } == ["m2"]) - } -} diff --git a/Tests/VGraphMCPTests/DecomposeLimitTests.swift b/Tests/VGraphMCPTests/DecomposeLimitTests.swift deleted file mode 100644 index 14141b1..0000000 --- a/Tests/VGraphMCPTests/DecomposeLimitTests.swift +++ /dev/null @@ -1,109 +0,0 @@ -import MCP -import Testing - -@testable import VGraphMCPTools - -@Suite("Decompose limits") -struct DecomposeLimitTests { - private let standard = MCPLimits.standard - private let logger = StderrLogger(environment: [:], sink: { _ in }) - - private let notation = """ - vnotation Arch { - node type: Person [nodeStyle: roundedBox] - node type: System [nodeStyle: roundedBox, detailedBy: (Container)] - node type: Container [nodeStyle: roundedBox] - edge type: uses from: Person to: System - } - """ - - /// `bank` plus `people` more nodes, `edges` edges into `bank`, and `views` views. - private func document(people: Int = 1, edges: Int = 1, views: Int = 0) -> String { - var vgl = notation + "\n\nvgraph g: Arch \"G\" {\n node bank: System \"Bank\";\n" - for i in 0..<people { vgl += " node p\(i): Person \"P\(i)\";\n" } - for i in 0..<edges { vgl += " edge p\(i % max(1, people)) -> bank;\n" } - vgl += "}\n" - for v in 0..<views { vgl += "\nvview v\(v) \"View \(v)\" {\n node bank [fontsize: 1\(v)];\n}\n" } - return vgl - } - - private func padded(_ vgl: String, to bytes: Int) -> String { - vgl + String(repeating: " ", count: max(0, bytes - vgl.utf8.count)) - } - - private func decompose(_ vgl: String, limits: MCPLimits? = nil) async -> CallTool.Result { - await DecomposeTool.handle( - .init(name: "decompose", arguments: ["vgl": .string(vgl), "node": .string("bank")]), - logger: logger, limits: limits ?? standard) - } - - private func text(_ result: CallTool.Result) -> String { - result.content.compactMap { if case .text(let text, _, _) = $0 { text } else { nil } }.joined(separator: "\n") - } - - @Test("Given VGL one byte over the length limit, when a node is decomposed, then it is refused with an error naming the VGL length limit") - func tooLong() async { - let result = await decompose(padded(document(), to: standard.maxVGLBytes + 1)) - #expect(result.isError == true) - #expect(text(result).contains("VGL length limit")) - } - - @Test("Given unparseable VGL one byte over the length limit, when decomposed, then the answer is the limit error and not a parse error") - func tooLongAndUnparseable() async { - let result = await decompose(padded("this is not VGL", to: standard.maxVGLBytes + 1)) - #expect(text(result).contains("VGL length limit")) - } - - @Test("Given a decomposable document padded to exactly the length limit, when its node is decomposed, then it decomposes") - func atLengthLimit() async { - let result = await decompose(padded(document(), to: standard.maxVGLBytes)) - #expect(result.isError != true) - #expect(text(result).contains("group bank: System")) - } - - @Test("Given 501 nodes, when a node is decomposed, then it is refused with an error naming the node limit, the count and the limit") - func tooManyNodes() async { - let result = await decompose(document(people: standard.maxNodes)) - #expect(result.isError == true) - #expect(text(result).contains("node limit")) - #expect(text(result).contains("501")) - #expect(text(result).contains("500")) - } - - @Test("Given 1001 edges, when a node is decomposed, then it is refused with an error naming the edge limit") - func tooManyEdges() async { - let result = await decompose(document(people: 400, edges: standard.maxEdges + 1)) - #expect(result.isError == true) - #expect(text(result).contains("edge limit")) - } - - @Test("Given 9 views, when a node is decomposed, then it is refused with an error naming the view limit") - func tooManyViews() async { - let result = await decompose(document(views: standard.maxViews + 1)) - #expect(result.isError == true) - #expect(text(result).contains("view limit")) - } - - @Test("Given a decomposable document at every limit at once, when its node is decomposed, then it decomposes") - func atEveryLimit() async { - var small = MCPLimits.standard - small.maxNodes = 4 - small.maxEdges = 3 - small.maxViews = 2 - let vgl = document(people: 3, edges: 3, views: 2) - small.maxVGLBytes = vgl.utf8.count - let result = await decompose(vgl, limits: small) - #expect(result.isError != true) - #expect(text(result).contains("group bank: System")) - } - - @Test("Given the same over-limit document, when sent to a render tool and to decompose, then both give the same error text") - func sameWordingAsRenderTools() async { - let nodes = (0...standard.maxNodes).map { " node n\($0): Concept \"C\($0)\"" }.joined(separator: "\n") - let render = await ConceptMapTool.handle( - .init(name: ConceptMapTool.name, arguments: ["vgl": .string("vgraph t: ConceptMap \"T\" {\n\(nodes)\n}\n")]), - logger: logger) - let decomposed = await decompose(document(people: standard.maxNodes)) - #expect(text(render) == text(decomposed)) - } -} diff --git a/Tests/VGraphMCPTests/DecomposeToolTests.swift b/Tests/VGraphMCPTests/DecomposeToolTests.swift deleted file mode 100644 index fd2e9e9..0000000 --- a/Tests/VGraphMCPTests/DecomposeToolTests.swift +++ /dev/null @@ -1,56 +0,0 @@ -import MCP -import Testing -import VGraphMCPTools - -/// An assistant decomposes a node the way an editor user does. -struct DecomposeToolTests { - private let document = """ - vnotation Arch { - node type: Person [nodeStyle: roundedBox] - node type: System [nodeStyle: roundedBox, detailedBy: (Container)] - node type: Container [nodeStyle: roundedBox] - edge type: uses from: Person to: System - } - - vgraph g: Arch "G" { - node alice: Person "Alice"; - node bank: System "Bank"; - edge alice -> bank "logs in"; - } - """ - - @Test("The tool is offered to assistants") - func registered() { - #expect(VGraphTools.all.map { $0.definition.name }.contains("decompose")) - } - - @Test("Given a node whose type has a detailing, when decomposed, then the updated document holds it as a detailed node") - func decomposesTheNode() async { - let result = await DecomposeTool.handle(params(vgl: document, node: "bank")) - - #expect(result.isError != true) - let vgl = text(result) - #expect(vgl.contains("group bank: System \"Bank\""), "\(vgl)") - #expect(vgl.contains(": Container \"Change Me\""), "\(vgl)") - #expect(vgl.contains("\"logs in\""), "\(vgl)") - } - - @Test("Given a node whose type has no detailing, when decomposed, then the tool reports an error") - func refusesATypeWithoutDetailing() async { - let result = await DecomposeTool.handle(params(vgl: document, node: "alice")) - - #expect(result.isError == true) - #expect(text(result).contains("'decompose' is not available on 'alice'"), "\(text(result))") - } - - private func params(vgl: String, node: String) -> CallTool.Parameters { - CallTool.Parameters(name: "decompose", arguments: ["vgl": .string(vgl), "node": .string(node)]) - } - - private func text(_ result: CallTool.Result) -> String { - result.content.compactMap { item in - if case .text(let text, _, _) = item { return text } - return nil - }.joined(separator: "\n") - } -} diff --git a/Tests/VGraphMCPTests/DescribeNotationToolTests.swift b/Tests/VGraphMCPTests/DescribeNotationToolTests.swift deleted file mode 100644 index 6f30569..0000000 --- a/Tests/VGraphMCPTests/DescribeNotationToolTests.swift +++ /dev/null @@ -1,110 +0,0 @@ -import App -import Foundation -import MCP -import Testing -import VGraph -import VGraphMCPTools - -@Suite("DescribeNotationTool Tests") -struct DescribeNotationToolTests { - - // MARK: - Tool definition - - @Test("Tool definition has correct name") - func toolName() { - #expect(DescribeNotationTool.definition.name == "describe_notation") - } - - @Test("Tool is registered in VGraphTools.all") - func registeredInAll() { - let names = VGraphTools.all.map(\.definition.name) - #expect(names.contains("describe_notation")) - } - - // MARK: - Happy path - - @Test("IBIS returns populated Markdown") - func ibisReturnsMarkdown() async { - let result = await DescribeNotationTool.handle( - makeParams(notation: "IBIS") - ) - #expect(result.isError != true) - let text = extractText(result) - #expect(text.contains("# IBIS")) - #expect(text.contains("## Purpose")) - #expect(text.contains("## When to use")) - #expect(text.contains("## Node types")) - #expect(text.contains("## Edge types")) - #expect(text.contains("## History")) - #expect(text.contains("## References")) - } - - @Test("Every built-in notation returns without error") - func allNotationsSucceed() async { - for name in DescribeNotationTool.validNotations { - let result = await DescribeNotationTool.handle( - makeParams(notation: name) - ) - #expect(result.isError != true, "describe_notation failed for \(name)") - let text = extractText(result) - // Every notation should at least have node types and edge types tables. - #expect(text.contains("## Node types"), "\(name) missing Node types section") - #expect(text.contains("## Edge types"), "\(name) missing Edge types section") - } - } - - @Test("The tool tells an assistant it will learn the detailings") - func definitionMentionsDetailings() { - #expect(DescribeNotationTool.definition.description?.contains("detailings") == true) - } - - /// Bites once a built-in notation declares detailings (C4). - @Test("Every detailing a built-in notation declares is in its description") - func descriptionsListDetailings() async throws { - for entry in NotationRegistry.entries.map({ $0.entry }) { - let text = extractText(await DescribeNotationTool.handle(makeParams(notation: entry.id.id))) - for detailing in entry.content.detailings { - let detailTypes = detailing.detailTypes.map { $0.id }.joined(separator: ", ") - #expect(text.contains("| \(detailing.nodeType.id) | \(detailTypes) |"), "\(entry.id.id)") - } - } - } - - // MARK: - Error cases - - @Test("Unknown notation returns error with valid names") - func unknownNotation() async { - let result = await DescribeNotationTool.handle( - makeParams(notation: "NonExistent") - ) - #expect(result.isError == true) - let text = extractText(result) - #expect(text.contains("unknown notation")) - #expect(text.contains("IBIS")) // lists valid names - } - - @Test("Missing parameter returns error") - func missingParameter() async { - let params = CallTool.Parameters(name: "describe_notation", arguments: nil) - let result = await DescribeNotationTool.handle(params) - #expect(result.isError == true) - let text = extractText(result) - #expect(text.contains("'notation' parameter is required")) - } - - // MARK: - Helpers - - private func makeParams(notation: String) -> CallTool.Parameters { - CallTool.Parameters( - name: "describe_notation", - arguments: ["notation": .string(notation)] - ) - } - - private func extractText(_ result: CallTool.Result) -> String { - result.content.compactMap { item in - if case .text(let text, _, _) = item { return text } - return nil - }.joined(separator: "\n") - } -} diff --git a/Tests/VGraphMCPTests/LimitsTests.swift b/Tests/VGraphMCPTests/LimitsTests.swift deleted file mode 100644 index 7589e03..0000000 --- a/Tests/VGraphMCPTests/LimitsTests.swift +++ /dev/null @@ -1,300 +0,0 @@ -import Foundation -import MCP -import TestSupport -import Testing - -@testable import VGraphMCPTools - -private func texts(_ result: CallTool.Result) -> String { - result.content.compactMap { if case .text(let text, _, _) = $0 { text } else { nil } }.joined(separator: "\n") -} - -private func images(_ result: CallTool.Result) -> Int { - result.content.filter { if case .image = $0 { true } else { false } }.count -} - -private func nodes(_ count: Int) -> String { - (0..<count).map { " node n\($0): Concept \"C\($0)\"" }.joined(separator: "\n") -} - -/// Edges i->i+1, i->i+2, i->i+3 over `nodeCount` nodes, cut at `count`. -private func edges(_ count: Int, over nodeCount: Int) -> String { - var lines: [String] = [] - outer: for step in 1...3 { - for i in 0..<(nodeCount - step) { - if lines.count == count { break outer } - lines.append(" edge n\(i) -> n\(i + step)") - } - } - return lines.joined(separator: "\n") -} - -private func document(nodes nodeCount: Int, edges edgeCount: Int = 0, views: Int = 0) -> String { - var vgl = "vgraph test: ConceptMap \"Test\" {\n\(nodes(nodeCount))\n\(edges(edgeCount, over: nodeCount))\n}\n" - for v in 0..<views { vgl += "\nvview v\(v) \"View \(v)\" {\n node n0 [fontsize: 1\(v)];\n}\n" } - return vgl -} - -private func padded(_ vgl: String, to bytes: Int) -> String { - vgl + String(repeating: " ", count: max(0, bytes - vgl.utf8.count)) -} - -private struct Run { - let result: CallTool.Result - let log: String - var text: String { texts(result) } - var refusedByLimit: Bool { result.isError == true && text.contains("limit") } - var laidOut: Bool { log.contains("DOT Output") } -} - -private func run( - _ vgl: String, limits: MCPLimits = .standard, tool: any ToolUnderTest = ConceptMapUnderTest() -) async -> Run { - let capture = LogCapture() - let logger = StderrLogger(environment: ["VGRAPH_LOG_LEVEL": "debug"], sink: capture.write) - let result = await tool.call(vgl, logger: logger, limits: limits) - return Run(result: result, log: capture.text) -} - -private protocol ToolUnderTest: Sendable { - func call(_ vgl: String, logger: StderrLogger, limits: MCPLimits) async -> CallTool.Result -} - -private struct ConceptMapUnderTest: ToolUnderTest { - func call(_ vgl: String, logger: StderrLogger, limits: MCPLimits) async -> CallTool.Result { - await ConceptMapTool.handle( - .init(name: ConceptMapTool.name, arguments: ["vgl": .string(vgl)]), logger: logger, limits: limits) - } -} - -private struct GenericTool<T: VGraphTool>: ToolUnderTest { - func call(_ vgl: String, logger: StderrLogger, limits: MCPLimits) async -> CallTool.Result { - await T.handle(.init(name: T.name, arguments: ["vgl": .string(vgl)]), logger: logger, limits: limits) - } -} - -@Suite("Graph limits — an MCP render tool") -struct GraphLimitTests { - private let standard = MCPLimits.standard - - @Test("Given VGL one byte over the length limit, when rendered, then it is refused with an error naming the VGL length limit, and no layout runs") - func vglTooLong() async { - let r = await run(padded(document(nodes: 2), to: standard.maxVGLBytes + 1)) - #expect(r.refusedByLimit) - #expect(r.text.contains("VGL length limit")) - #expect(!r.laidOut) - } - - @Test("Given VGL exactly at the length limit, when rendered, then it renders") - func vglAtLimit() async { - let r = await run(padded(document(nodes: 2), to: standard.maxVGLBytes)) - #expect(!r.refusedByLimit) - #expect(r.laidOut) - } - - @Test("Given 501 nodes, when rendered, then it is refused with an error naming the node limit, the count and the limit") - func tooManyNodes() async { - let r = await run(document(nodes: standard.maxNodes + 1)) - #expect(r.refusedByLimit) - #expect(r.text.contains("node limit")) - #expect(r.text.contains("501")) - #expect(r.text.contains("500")) - } - - @Test("Given 1001 edges, when rendered, then it is refused with an error naming the edge limit") - func tooManyEdges() async { - let r = await run(document(nodes: 400, edges: standard.maxEdges + 1)) - #expect(r.refusedByLimit) - #expect(r.text.contains("edge limit")) - } - - @Test("Given 9 views, when rendered, then it is refused before any view is laid out") - func tooManyViews() async { - let r = await run(document(nodes: 3, views: standard.maxViews + 1)) - #expect(r.refusedByLimit) - #expect(r.text.contains("view limit")) - #expect(!r.laidOut) - } - - @Test("Given a document at every limit at once, when rendered, then it renders") - func atEveryLimit() async { - var small = MCPLimits.standard - small.maxNodes = 12 - small.maxEdges = 20 - small.maxViews = 2 - let vgl = document(nodes: 12, edges: 20, views: 2) - small.maxVGLBytes = vgl.utf8.count - let r = await run(vgl, limits: small) - #expect(!r.refusedByLimit) - #expect(r.laidOut) - } - - @Test("Given an over-limit document, when sent to each notation tool, then each refuses it") - func everyToolRefuses() async { - let tooBig = document(nodes: standard.maxNodes + 1) - let tools: [any ToolUnderTest] = [ - GenericTool<CLDTool>(), GenericTool<ConceptMapTool>(), - GenericTool<IBISTool>(), GenericTool<TimelineTool>(), - ] - for tool in tools { - #expect(await run(tooBig, tool: tool).refusedByLimit) - } - } - - @Test("Given a small document, when rendered, then the answer is what it is today") - func smallDocument() async { - let r = await run(document(nodes: 3, edges: 2)) - #expect(!r.refusedByLimit) - #expect(images(r.result) == 1) - } -} - -@Suite("PNG conversion") -struct PNGConversionTests { - private let logger = StderrLogger(environment: [:], sink: { _ in }) - - /// A stand-in for rsvg-convert: it drains stdin, then runs `body`. - private func script(_ body: String) throws -> String { - let dir = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true) - let url = dir.appendingPathComponent("fake-rsvg") - try "#!/bin/sh\ncat > /dev/null\n\(body)\n".write(to: url, atomically: true, encoding: .utf8) - try FileManager.default.setAttributes([.posixPermissions: 0o755], ofItemAtPath: url.path) - return url.path - } - - private func converter(_ body: String, adjust: (inout MCPLimits) -> Void = { _ in }) throws -> PNGConverter { - var limits = MCPLimits.standard - adjust(&limits) - return PNGConverter(executable: try script(body), limits: limits) - } - - private func seconds(_ work: () async -> Void) async -> Double { - let start = Date() - await work() - return Date().timeIntervalSince(start) - } - - @Test("Given a converter that never exits, when the timeout passes, then it is killed and conversion fails") - func neverExits() async throws { - let png = try converter("sleep 3") { $0.pngTimeoutSeconds = 0.3 } - var result: PNGResult? - let elapsed = await seconds { result = await png.convert("<svg/>", logger: logger) } - #expect(result == .timedOut) - #expect(elapsed < 2) - } - - @Test("Given a timeout, when the tool answers, then the error says the conversion timed out") - func toolReportsTimeout() async throws { - let png = try converter("sleep 3") { $0.pngTimeoutSeconds = 0.3 } - let r = await ConceptMapTool.handle( - .init(name: ConceptMapTool.name, arguments: ["vgl": .string(document(nodes: 2))]), - logger: logger, png: png) - #expect(r.isError == true) - #expect(texts(r).contains("timed out")) - } - - @Test("Given an SVG larger than 25 megapixels, when converted, then it is scaled down to fit") - func scaledDown() { - let svg = #"<svg xmlns="http://www.w3.org/2000/svg" width="10000" height="10000"></svg>"# - let args = PNGConverter.arguments(forSVG: svg, limits: .standard) - #expect(args == ["--format=png", "--zoom=0.5"]) - } - - @Test("Given an SVG within the cap, when converted, then it renders at its own size") - func withinCap() { - let svg = #"<svg xmlns="http://www.w3.org/2000/svg" width="800" height="600"></svg>"# - #expect( - PNGConverter.arguments(forSVG: svg, limits: .standard) - == ["--format=png"]) - } - - @Test( - "Given an SVG under 25 megapixels but longer than 32767 pixels on one side, when converted, then it is scaled down so the longest side fits") - func longSideScaledDown() { - let svg = #"<svg xmlns="http://www.w3.org/2000/svg" width="40000" height="400"></svg>"# - let args = PNGConverter.arguments(forSVG: svg, limits: .standard) - #expect(args == ["--format=png", "--zoom=0.8191"]) - } - - @Test("Given an SVG over both the area cap and the side limit, when converted, then the stricter scale applies") - func stricterScaleWins() { - let svg = #"<svg xmlns="http://www.w3.org/2000/svg" width="30000" height="30000"></svg>"# - let args = PNGConverter.arguments(forSVG: svg, limits: .standard) - #expect(args == ["--format=png", "--zoom=0.1666"]) - } - - @Test("Given an SVG whose longest side is just within the limit, when converted, then it renders at its own size") - func sideJustWithinLimit() { - let svg = #"<svg xmlns="http://www.w3.org/2000/svg" width="21844" height="500"></svg>"# - #expect( - PNGConverter.arguments(forSVG: svg, limits: .standard) - == ["--format=png"]) - } - - @Test("Given a chain of 500 nodes and 1000 edges, when rendered, then a PNG comes back") - func chainAtTheLimitsRenders() async { - let standard = MCPLimits.standard - let r = await run(document(nodes: standard.maxNodes, edges: standard.maxEdges)) - #expect(r.result.isError != true, "\(r.text)") - #expect(images(r.result) == 1) - } - - @Test("Given a converter writing more than the output cap, when it passes, then reading stops and conversion fails") - func outputCap() async throws { - let png = try converter("head -c 5000000 /dev/zero") { $0.maxPNGBytes = 1_000_000 } - #expect(await png.convert("<svg/>", logger: logger) == .outputTooLarge) - } - - @Test("Given the concurrency limit reached, when another conversion arrives, then it waits") - func waits() async { - let gate = ConcurrencyGate(limit: 2) - await gate.acquire() - await gate.acquire() - let started = Flag() - let waiter = Task { - await gate.acquire() - await started.set() - } - try? await Task.sleep(for: .milliseconds(200)) - #expect(await !started.value) - waiter.cancel() - } - - @Test("Given a waiting conversion, when a running one finishes, then it starts") - func startsAfterRelease() async { - let gate = ConcurrencyGate(limit: 1) - await gate.acquire() - let started = Flag() - Task { - await gate.acquire() - await started.set() - } - try? await Task.sleep(for: .milliseconds(100)) - await gate.release() - try? await Task.sleep(for: .milliseconds(300)) - #expect(await started.value) - } - - @Test("Given a converter that fails or is killed, when it ends, then its place is freed") - func slotFreed() async throws { - let failing = try converter("exit 3") { $0.pngConcurrency = 1 } - let hanging = try converter("sleep 3") { - $0.pngConcurrency = 1 - $0.pngTimeoutSeconds = 0.3 - } - var results: [PNGResult] = [] - let elapsed = await seconds { - for png in [failing, failing, hanging, hanging, failing] { - results.append(await png.convert("<svg/>", logger: logger)) - } - } - #expect(results == [.failed, .failed, .timedOut, .timedOut, .failed]) - #expect(elapsed < 4) - } -} - -private actor Flag { - private(set) var value = false - func set() { value = true } -} diff --git a/Tests/VGraphMCPTests/LoggingTests.swift b/Tests/VGraphMCPTests/LoggingTests.swift deleted file mode 100644 index 3703853..0000000 --- a/Tests/VGraphMCPTests/LoggingTests.swift +++ /dev/null @@ -1,214 +0,0 @@ -import MCP -import TestSupport -import Testing -import VGraph -import VGraphSVG - -@testable import VGraphMCPTools - -private let secret = "SECRET-LABEL-7731" - -private func logger(_ level: String?, into capture: LogCapture) -> StderrLogger { - StderrLogger(environment: level.map { [LogLevel.environmentKey: $0] } ?? [:], sink: capture.write) -} - -@Suite("Log level — what a logger lets through") -struct LogLevelFilterTests { - @Test("Given a logger at level warn, when debug is logged, then nothing is written") - func warnDropsDebug() { - let capture = LogCapture() - logger("warn", into: capture).debug("hello") - #expect(capture.lines.isEmpty) - } - - @Test("Given a logger at level warn, when info (log) is logged, then nothing is written") - func warnDropsInfo() { - let capture = LogCapture() - logger("warn", into: capture).log("hello") - #expect(capture.lines.isEmpty) - } - - @Test("Given a logger at level warn, when warn is logged, then the line is written with a WARN prefix") - func warnWritesWarn() { - let capture = LogCapture() - logger("warn", into: capture).warn("hello") - #expect(capture.lines == ["[vgraph-mcp] WARN: hello"]) - } - - @Test("Given a logger at level warn, when error is logged, then the line is written with an ERROR prefix") - func warnWritesError() { - let capture = LogCapture() - logger("warn", into: capture).error("hello") - #expect(capture.lines == ["[vgraph-mcp] ERROR: hello"]) - } - - @Test("Given a logger at level debug, when debug is logged, then the line is written with a DEBUG prefix") - func debugWritesDebug() { - let capture = LogCapture() - logger("debug", into: capture).debug("hello") - #expect(capture.lines == ["[vgraph-mcp] DEBUG: hello"]) - } - - @Test("Given a logger at level error, when warn is logged, then nothing is written") - func errorDropsWarn() { - let capture = LogCapture() - logger("error", into: capture).warn("hello") - #expect(capture.lines.isEmpty) - } -} - -@Suite("Level setting — VGRAPH_LOG_LEVEL") -struct LogLevelSettingTests { - @Test("Given no setting, when the level is read, then it is warn") - func absent() { - #expect(LogLevel(setting: nil) == .warn) - } - - @Test("Given debug, info, warn, error in any letter case, when read, then each gives its level") - func known() { - #expect(LogLevel(setting: "debug") == .debug) - #expect(LogLevel(setting: "INFO") == .info) - #expect(LogLevel(setting: "Warn") == .warn) - #expect(LogLevel(setting: "error") == .error) - } - - @Test("Given an unrecognised value, when read, then it is warn") - func unknown() { - #expect(LogLevel(setting: "verbose") == .warn) - } - - @Test("Given an empty value, when read, then it is warn") - func empty() { - #expect(LogLevel(setting: "") == .warn) - } -} - -@Suite("Default in the binary") -struct LogDefaultTests { - @Test("Given no VGRAPH_LOG_LEVEL, when the MCP app is built, then its logger is at warn") - func mcpDefaultIsWarn() { - #expect(StderrLogger(environment: [:]).level == .warn) - } -} - -@Suite("Rendering — a document with the label SECRET-LABEL-7731") -struct LogLeakTests { - private func render(_ vgl: String, level: String?) async -> String { - let capture = LogCapture() - _ = await ConceptMapTool.handle( - .init(name: ConceptMapTool.name, arguments: ["vgl": .string(vgl)]), - logger: logger(level, into: capture)) - return capture.text - } - - // The title and group/edge labels reach the Graphviz source; node labels do not. - private let labelled = """ - vgraph test: ConceptMap "\(secret)" { - node a: Concept "\(secret)" - node b: Concept "Cat" - node r1: Relation "is a" - edge a -> r1 - edge r1 -> b - } - """ - - @Test("Given the default level, when it is rendered, then nothing logged contains the label") - func defaultLevelIsSilent() async { - #expect(!(await render(labelled, level: nil)).contains(secret)) - } - - @Test("Given debug, when it is rendered, then the logged Graphviz source contains the label") - func debugShowsDot() async { - #expect((await render(labelled, level: "debug")).contains(secret)) - } - - @Test("Given a two-view document, at the default level, when rendered, then nothing logged contains the label") - func viewsAreSilent() async { - let vgl = - labelled + """ - - - vview first "First View" { - node b [fontsize: 16]; - } - - vview second "Second View" { - node b [fontsize: 20]; - } - """ - #expect(!(await render(vgl, level: nil)).contains(secret)) - } - - @Test("Given a node, a group and an edge each labelled SECRET-LABEL-7731, when rendered at the default level, then no log line contains it") - func everyKindIsSilent() async { - let vgl = """ - vgraph test: ConceptMap "Test?" { - group g1 "\(secret)" { - node a: Concept "\(secret)" - } - node b: Concept "Cat" - edge a -> b "\(secret)" - } - """ - #expect(!(await render(vgl, level: nil)).contains(secret)) - } -} - -@Suite("Warnings — identifiers, never labels") -struct LogWarningTests { - private func parseWarnings(_ vgl: String) throws -> String { - let capture = LogCapture() - _ = try VGraphMCPApp(logger: logger(nil, into: capture)).parseGraph(vgl) - return capture.text - } - - private let unknownType = """ - vgraph test: ConceptMap "Test?" { - node n7: NoSuchType "\(secret)" - } - """ - - @Test( - "Given a node of an unknown type with the label SECRET-LABEL-7731, when parsed at the default level, then a warning names the node id and the type name" - ) - func warningNamesIdentifiers() throws { - let text = try parseWarnings(unknownType) - #expect(text.contains("n7")) - #expect(text.contains("NoSuchType")) - } - - @Test( - "Given a node of an unknown type with the label SECRET-LABEL-7731, when parsed at the default level, then the warning does not contain the label" - ) - func warningOmitsLabel() throws { - #expect(!(try parseWarnings(unknownType)).contains(secret)) - } -} - -@Suite("PNG conversion failure") -struct RSVGFailureLogTests { - @Test( - "Given rsvg-convert exits with status 1 and an error text quoting a label, when it is logged at the default level, then the line has the status and not the text" - ) - func exitLogsStatusOnly() { - let capture = LogCapture() - logRSVGFailure(.exited(status: 1, stderr: "bad text \(secret)"), logger: logger(nil, into: capture)) - #expect(capture.text.contains("1")) - #expect(!capture.text.contains(secret)) - } - - @Test("Given the same failure, when logged at debug, then the line includes the text") - func exitLogsTextAtDebug() { - let capture = LogCapture() - logRSVGFailure(.exited(status: 1, stderr: "bad text \(secret)"), logger: logger("debug", into: capture)) - #expect(capture.text.contains(secret)) - } - - @Test("Given rsvg-convert cannot be launched, when it is logged at the default level, then a warning says so") - func launchFailureWarns() { - let capture = LogCapture() - logRSVGFailure(.launch, logger: logger(nil, into: capture)) - #expect(capture.text.contains("WARN")) - #expect(capture.text.contains("rsvg-convert")) - } -} diff --git a/Tests/VGraphMCPTests/ViewsRenderTests.swift b/Tests/VGraphMCPTests/ViewsRenderTests.swift deleted file mode 100644 index c50ae47..0000000 --- a/Tests/VGraphMCPTests/ViewsRenderTests.swift +++ /dev/null @@ -1,69 +0,0 @@ -import MCP -import Testing -import VGraphMCPTools - -@Suite("MCP render tools show every view") -struct ViewsRenderTests { - private func call(_ vgl: String) async -> CallTool.Result { - await ConceptMapTool.handle(.init(name: ConceptMapTool.name, arguments: ["vgl": .string(vgl)])) - } - - private func texts(_ result: CallTool.Result) -> [String] { - result.content.compactMap { if case .text(let text, _, _) = $0 { text } else { nil } } - } - - private func imageCount(_ result: CallTool.Result) -> Int { - result.content.filter { if case .image = $0 { true } else { false } }.count - } - - // Four words in a concept label draw a quality warning. - private let body = """ - vgraph test: ConceptMap "Test?" { - node a: Concept "A Very Long Concept Name" - node b: Concept "Cat" - node r1: Relation "is a" - edge a -> r1 - edge r1 -> b - } - """ - - private var twoViews: String { - body + """ - - - vview first "First View" { - node b [fontsize: 16]; - } - - vview second "Second View" { - node b [fontsize: 20]; - } - """ - } - - @Test("Given two views, when rendered, then default and both views are captioned pictures after one report") - func threePicturesOneReport() async { - let result = await call(twoViews) - #expect(result.isError != true) - #expect(imageCount(result) == 3) - - let kinds = result.content.map { item -> String in - switch item { - case .image: "image" - case .text(let text, _, _): text - default: "other" - } - } - #expect(kinds.count == 7) - #expect(kinds[0].contains("Concepts:")) - #expect(Array(kinds[1...]) == ["default", "image", "first: First View", "image", "second: Second View", "image"]) - } - - @Test("Given no views, when rendered, then it is the report and one uncaptioned picture") - func noViewsUnchanged() async { - let result = await call(body) - #expect(imageCount(result) == 1) - #expect(texts(result).count == 1) - #expect(!texts(result).contains("default")) - } -} diff --git a/VGraphWasm/Package.resolved b/VGraphWasm/Package.resolved index fc96859..7633a0e 100644 --- a/VGraphWasm/Package.resolved +++ b/VGraphWasm/Package.resolved @@ -28,15 +28,6 @@ "version" : "0.9.1" } }, - { - "identity" : "eventsource", - "kind" : "remoteSourceControl", - "location" : "https://github.com/mattt/eventsource.git", - "state" : { - "revision" : "a3a85a85214caf642abaa96ae664e4c772a59f6e", - "version" : "1.4.1" - } - }, { "identity" : "javascriptkit", "kind" : "remoteSourceControl", @@ -91,15 +82,6 @@ "version" : "2.101.3" } }, - { - "identity" : "swift-sdk", - "kind" : "remoteSourceControl", - "location" : "https://github.com/modelcontextprotocol/swift-sdk", - "state" : { - "revision" : "a0ae212ebf6eab5f754c3129608bc5557637e605", - "version" : "0.12.1" - } - }, { "identity" : "swift-syntax", "kind" : "remoteSourceControl", diff --git a/docs/adr/0036-releases-stay-on-the-maintainers-machine.md b/docs/adr/0036-releases-stay-on-the-maintainers-machine.md index 28b98a2..f69ab85 100644 --- a/docs/adr/0036-releases-stay-on-the-maintainers-machine.md +++ b/docs/adr/0036-releases-stay-on-the-maintainers-machine.md @@ -1,11 +1,12 @@ # 36. Releases stay on the maintainer's machine -Date: 2026-11-08 (revised 2026-11-13, 2026-11-15 and 2026-11-21) +Date: 2026-11-08 (revised 2026-11-13, 2026-11-15, 2026-11-21 and 2026-11-22) ## Status Accepted. Absorbs 0035, which had a VGraph tag start each plugin's build on -GitHub and was replaced before any release used it. +GitHub and was replaced before any release used it. Amended by 0040: the MCP +servers, the npm host among them, are an engine consumer in their own repository. ## Context @@ -61,7 +62,7 @@ depend on the Node version that builds it. ## Consequences -The version bump in VGraph (`plugins.json`, `vgraph-mcp-node`) reaches `main` +The version bump in VGraph (`plugins.json`) reaches `main` through a PR like any other change, because `main` takes no direct pushes. `plugins-release` commits it on `release/<version>` and opens that PR. Each plugin's bump stays uncommitted until `publish-plugins` commits it with the diff --git a/docs/adr/0040-the-mcp-servers-live-in-their-own-repository.md b/docs/adr/0040-the-mcp-servers-live-in-their-own-repository.md new file mode 100644 index 0000000..0b1c9c8 --- /dev/null +++ b/docs/adr/0040-the-mcp-servers-live-in-their-own-repository.md @@ -0,0 +1,55 @@ +# 40. The MCP servers live in their own repository + +Date: 2026-11-22 + +## Status + +Accepted. Amends [0036](./0036-releases-stay-on-the-maintainers-machine.md). + +## Context + +The MCP servers (stdio, the HTTP server behind `mcp.vithanco.com`, and the npm +host) mostly changed on their own, and they brought swift-nio and the MCP SDK into +VGraph's `Package.swift`, which every package depending on VGraph resolves. The +npm host was already an engine consumer like the plugins, but the only one +living inside VGraph. + +## Decision + +They move to `Vithanco/vgraph-mcp`, which `just plugins-setup` clones into +`vgraph-mcp/`, as it does the plugins. The Swift servers and the npm host move +together, because the host's `tools.json` is generated from the Swift server. + +Its `Package.swift` depends on VGraph as `.package(path: "..")`, not by URL. A +release ships every consumer from one engine build, and VGraph is tagged only +when it publishes, after that build; a URL dependency could not name the engine +being released. VGraph exports its `TestSupport` target as `VGraphTestSupport`, +so the servers' tests use the same wiring as VGraph's. + +## Consequences + +`vgraph-mcp` does not build on its own, and the folder around it must be called +`VGraph`, because SwiftPM names a path dependency after its folder. Its CI checks +out VGraph and puts the repository inside it. + +VGraph's justfile stays the one front door. `just mcp <recipe>` runs a recipe of +`vgraph-mcp/justfile`. `just release` builds the servers and the npm host, and +`just publish-all` runs `just mcp publish`, which commits and tags its version +bump as `publish-plugins` does the plugins'. Its recipes that ship the engine run +VGraph's `_require-vgraph-main` first. + +VGraph's CI no longer sees a change that breaks the servers. `just test` runs +their tests when the checkout is there, and their own CI builds against VGraph's +`main`, as the plugins' does. + +The Cloud Run image is built from a staged context that holds the tracked +sources of both repositories, laid out as in a checkout. + +Dependabot cannot update `vgraph-mcp`'s Swift pins: it has no VGraph around it. + +## Alternatives considered + +- **A URL dependency pinned to a VGraph tag.** The repository would build alone, + but `publish-all` would have to tag VGraph before building what it releases. +- **Moving only the npm host.** `tools.json` would then be generated across + repositories. diff --git a/docs/hexagonal-architecture.md b/docs/hexagonal-architecture.md index 65f3e18..82d1571 100644 --- a/docs/hexagonal-architecture.md +++ b/docs/hexagonal-architecture.md @@ -175,7 +175,7 @@ Every driver therefore differs only in its logger: ```swift public typealias VGraphCLIApp = VGraphApplication<NativePorts<PrintLogger>> -public typealias VGraphMCPApp = VGraphApplication<NativePorts<StderrLogger>> +public typealias VGraphMCPApp = VGraphApplication<NativePorts<StderrLogger>> // in vgraph-mcp public typealias VGraphWasmApp = VGraphApplication<NativePorts<ConsoleLogger>> public typealias VGraphTestApp = VGraphApplication<NativePorts<NoOpLogger>> ``` diff --git a/docs/mcp-hardening.md b/docs/mcp-hardening.md deleted file mode 100644 index 710ebc6..0000000 --- a/docs/mcp-hardening.md +++ /dev/null @@ -1,79 +0,0 @@ -# Hardening the hosted MCP endpoint - -`mcp.vithanco.com` is open to anyone on purpose (see `SECURITY.md`), so what a -request may cost is bounded in code, in one place: `MCPLimits`. - -## Why the input is bounded and not the render - -Graphviz layout runs in-process and cannot be cancelled. A deadline can only -abandon the work, which keeps burning CPU, so the worst case is kept short by -refusing big input before layout: body size at the HTTP layer, then length, -nodes, edges and views once parsed. The 120 s request deadline is the backstop -and sits below Cloud Run's `--timeout` so the client gets our 504. - -## Measurements behind the concurrency numbers - -Release build of `vgraph-mcp-http` on a 10-core Mac (arm64), not the 1 GiB / 1 CPU -Linux container, so treat them as relative. Peak resident memory of the server -plus its `rsvg-convert` children, one ConceptMap tool call, N at once with -distinct JSON-RPC ids: - -| Document | 1 at once | 4 at once | 8 at once | Wall, 8 at once | -|---|---|---|---|---| -| 20 nodes, 25 edges | 43 MB | 105 MB | 133 MB | 0.3 s | -| 150 nodes, 300 edges | 74 MB | 236 MB | 265 MB | 1.0 s | -| 250 nodes, 450 edges | 136 MB | 336 MB | 362 MB | 1.4 s | -| 350 nodes, 700 edges | 191 MB | 439 MB | 488 MB | 2.0 s | -| 100 nodes, 8 views | 212 MB | 361 MB | 456 MB | 5.5 s | - -- One `rsvg-convert` peaks at about 119 MB at the 25 megapixel cap, whatever the - shape (5000 x 5000, 25000 x 1000 and 32000 x 780 px all gave 119 MB), so four - at once cost about 480 MB. The gate held the children to four with eight - requests in flight. -- Layout is CPU-bound, so requests in flight share one CPU: eight views-heavy - requests took 5.5 s, a few seconds each alone. Four in flight stay far inside - the 120 s deadline. -- **Not explained:** the server's resident memory between runs grew from 9 MB to - 247 MB over about 45 renders and did not come back. That may be allocator - retention, not a leak, and Linux's allocator behaves differently. Watch the - instance memory metric after the first deploy; at four in flight and a 1 GiB - instance the headroom is roughly 700 MB after the children, but a growing base - eats it. - -So `--concurrency=4` and four PNG conversions at a time stand. Raise them only -with a Linux measurement in the real image. - -## Found while measuring - -- **Identical JSON-RPC ids hang.** The SDK's stateless transport keys a waiting - response by the request `id`. Two overlapping requests with the same id (two - clients that both start counting at 1) overwrite each other, and the first is - never answered. The request deadline now ends it with a 504 after 120 s, but - the cost is a held connection. Known upstream as - modelcontextprotocol/swift-sdk#254 and swift-sdk#265, fixed by swift-sdk#298. We wait - for that release rather than rewrite ids ourselves: a rewrite has to change - only the top-level `id`, since re-encoding the body alters numbers in tool - arguments and results. `RequestIDTests` marks the hang as a known issue and - starts failing once a fixed SDK is pinned. -- **A diagram at the node and edge limits cannot become a PNG.** 500 nodes and - 1000 edges in a chain make an SVG whose bitmap is wider than the - 32767 pixels `rsvg-convert` allows, so the tool reported a PNG failure. The pixel - cap bounded the area, not the longest side. Fixed: the zoom now also respects - that side limit. -- **`--dpi-x/-y` does not scale our SVG.** VGraph's SVG sizes are plain pixels - (`width="276.74"`), and rsvg-convert ignores dpi for pixel sizes: 144 dpi gives - the SVG's own size, same as 72. Scaling down needs `--zoom` (or `--width`). The - first version of the pixel cap scaled through dpi and so never took effect; - it now passes `--zoom`, and the dpi flags are gone (OLD-253: a Linux rsvg and - resvg-wasm agree to within about 1% of pixels, so rsvg-convert stays). - -## Maintainer notes - -Kill switch, stops public access at once and is reversible: - -``` -gcloud run services remove-iam-policy-binding vgraph-mcp --member=allUsers --role=roles/run.invoker --region europe-west1 -``` - -Still to confirm in the console: a budget alert, and the Cloud Logging -retention for the service. diff --git a/docs/releasing.md b/docs/releasing.md index d53c627..80346ac 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -2,7 +2,8 @@ An **engine consumer** bundles the VGraph engine and carries the shared version number: everything listed in `plugins.json`, today the Obsidian plugin, the VS -Code extension and the npm MCP host (`vgraph-mcp-node`). A **release** ships +Code extension and the MCP servers (`vgraph-mcp`: the npm host, and the hosted +server on Cloud Run). A **release** ships every engine consumer at one version, so a version number names one engine build wherever it is quoted. The website and Cloud Run run the engine too but have no version; updating only them is a deploy, not a release. @@ -13,7 +14,8 @@ GitHub only checks. Why: [ADR 0036](./adr/0036-releases-stay-on-the-maintainers- ## Before the first release - `export VITHANCO_MAINTAINER=1` in the shell that publishes. -- `just plugins-setup`, and both plugin checkouts on `main`. +- `just plugins-setup`, and the `obsidian-vithanco`, `vscode-vithanco` and + `vgraph-mcp` checkouts on `main`. - Logged in: `gh`, `npm` (2FA), `gcloud` (`gcloud auth login && gcloud auth configure-docker`). - `mcp-publisher` with the signing key in `~/.config/mcp-publisher/` for the MCP Registry. - The Publish CLI on `PATH` and the website checkout at `$VITHANCO_WEBSITE_DIR` @@ -29,9 +31,9 @@ just plugins-release patch # or minor, major, or an explicit version ``` This bumps every engine consumer and builds nothing. VGraph's half of the bump -(`plugins.json`, `vgraph-mcp-node`) is committed on `release/<version>` and -opened as a PR, because `main` takes no direct pushes. Each plugin's half stays -uncommitted in its checkout until it is published. +(`plugins.json`) is committed on `release/<version>` and opened as a PR, because +`main` takes no direct pushes. Each consumer's half stays uncommitted in its +checkout until it is published. Merge the PR once CI is green, then: @@ -41,10 +43,10 @@ just publish-all ``` `publish-all` runs `just release` (the optimized engine, both plugins, the -`.vsix`), asks you to type `publish`, then -tags VGraph and ships the plugins (tag, push and GitHub release each), npm and -the MCP Registry, the website, Cloud Run, and the Marketplace when a token is -found. +`.vsix`, the MCP servers and the npm host), asks you to type `publish`, then +tags VGraph and ships the plugins (tag, push and GitHub release each), then +`just mcp publish` (tag and push `vgraph-mcp`, npm, the MCP Registry, Cloud Run), +the website, and the Marketplace when a token is found. `just release` runs the tests itself only when CI has not passed on the commit (`just release full` runs them anyway); why: ADR 0036. @@ -52,23 +54,23 @@ found. VGraph's tag goes on the commit that built the engine, not on `main`'s tip, so a Swift package that depends on a version gets the engine the plugins ship. -The plugins' bump commits go straight to their `main`, not through a PR: they -hold only version fields and the engine just tested, and each plugin's CI checks -`main` after the push. +The consumers' bump commits go straight to their `main`, not through a PR: they +hold only version fields and the engine just tested, and each consumer's CI +checks `main` after the push. ## When a release stops halfway Run `just publish-all` again. It skips `just release` while nothing that ships -has changed since it passed, the plugins when they carry the version, and npm and -the MCP Registry when both do. It redeploys the website and Cloud Run, which is -harmless. The registry publish retries on its own, because the registry stalls +has changed since it passed, the plugins when they carry the version, and +`vgraph-mcp`'s tag, npm and the MCP Registry when each does. It redeploys the +website and Cloud Run, which is harmless. The registry publish retries on its own, because the registry stalls now and then. To finish one place by hand, run its recipe: `publish-plugins`, -`publish-mcp-node`, `publish-website`, `publish-cloud-run`, -`publish-vscode-marketplace`. +`publish-website`, `publish-vscode-marketplace`, or in `vgraph-mcp` +`just mcp publish-node` and `just mcp publish-cloud-run`. Every recipe that ships the engine refuses a VGraph checkout with uncommitted changes or a commit not on `origin/main`, so what ships is always on `main`. -Generated files such as `vgraph-mcp-node/tools.json` cannot be what makes it -uncommitted: CI fails a pull request that leaves one stale, and `just regen` -refreshes them. +`vgraph-mcp`'s generated `tools.json` cannot be what makes a release stop: +its CI fails a pull request that leaves it stale, and `just mcp regen` +refreshes it. diff --git a/docs/where-things-live.md b/docs/where-things-live.md index 8f02e2b..b952aeb 100644 --- a/docs/where-things-live.md +++ b/docs/where-things-live.md @@ -12,10 +12,9 @@ touches these, in order. Each step is its own commit in practice. 2. **Port** — `Sources/VGraph/VStdPorts/For*.swift`. A new member on a driving port must also be added to the expected table in `Tests/AppTests/ArchitectureTest.swift`, which fails until you do. 3. **Use case** — `Sources/App/Domain/` (`VGraphApplication` for stateless calls, `GraphSession` for the editor's stateful ones). Ports are re-exported under the plain name in `Sources/App/Ports/Inbound/`. 4. **Editor decisions** — `Sources/EditorCore/` (`Menu`, `Conversation`, `Gesture`, `Views`…). The editor in `VGraphWasm/VGraphEditor/` only hit-tests, measures and paints. Wasm-graph code: see the Embedded rules in AGENTS.md. -5. **Swift MCP** — `Sources/VGraphMCPTools/VGraphTool.swift`; test in `Tests/VGraphMCPTests/`. -6. **Wasm** — `VGraphWasm/Sources/Main.swift` (BridgeJS regenerates `Sources/Generated/` on `./build-wasm.sh`); editor UI in `VGraphWasm/VGraphEditor/`; JS smoke tests in `VGraphWasm/Tests-JS/` (`fixtures.js`, `smoke.test.js`); editor browser tests (Playwright) in `VGraphWasm/Tests-Browser/`. -7. **Node MCP** — `vgraph-mcp-node/src/` (`server.mjs`, `render.mjs`), tests in `vgraph-mcp-node/test/`. -8. **Docs** — `docs/VGL_GUIDE.md` for language changes, `GLOSSARY.md` for new terms, `docs/adr/` for decisions. +5. **Wasm** — `VGraphWasm/Sources/Main.swift` (BridgeJS regenerates `Sources/Generated/` on `./build-wasm.sh`); editor UI in `VGraphWasm/VGraphEditor/`; JS smoke tests in `VGraphWasm/Tests-JS/` (`fixtures.js`, `smoke.test.js`); editor browser tests (Playwright) in `VGraphWasm/Tests-Browser/`. +6. **MCP servers** — another repository, cloned to `vgraph-mcp/` (ADR 0040). Swift: `Sources/VGraphMCPTools/VGraphTool.swift`, tests in `Tests/VGraphMCPTests/`. npm host: `src/` (`server.mjs`, `render.mjs`), tests in `test/`. `just mcp test` runs them against this checkout. +7. **Docs** — `docs/VGL_GUIDE.md` for language changes, `GLOSSARY.md` for new terms, `docs/adr/` for decisions. ## Adding a port @@ -42,7 +41,7 @@ SwiftPM lets a target import its transitive graph, but a *test* target compiles | a rendered SVG | `VGraphSVGTests` | `VGraphTestApp()` (`import TestSupport`) | | Graphviz layout | `VGraphvizLibTests` | `VGraphTestApp()` | | domain types only | `VGraphTests` | none | -| MCP tool results | `VGraphMCPTests` | `VGraphTool.handle` | +| MCP tool results | `VGraphMCPTests`, in `vgraph-mcp/` | `VGraphTool.handle` | `AppTests` does not depend on `VGraphSVG` or `VGraphvizLib`, so a render test written there fails to build; put it in `VGraphSVGTests`. `VGraphTestApp` is the native wiring with a silent logger (`Tests/TestSupport/VGraphTestApp.swift`). diff --git a/fonts/README.md b/fonts/README.md index 8d12b84..c92ef15 100644 --- a/fonts/README.md +++ b/fonts/README.md @@ -15,8 +15,8 @@ A browser opening one of our SVGs gets DM Sans from the `@import` that render byte-identically, text missing. Inlining is not a way out. So every non-browser consumer needs the faces as files: the Docker image -(`fontconfig` + `rsvg-convert`) and the local MCP server in `vgraph-mcp-node` -(resvg). +(`fontconfig` + `rsvg-convert`) and the local MCP server, the npm host in +`vgraph-mcp` (resvg). Both copy them from here. ## Why TTF, and why one file per weight diff --git a/justfile b/justfile index 8d2fd68..7e689be 100644 --- a/justfile +++ b/justfile @@ -1,12 +1,13 @@ # VGraph task runner — the single front door to this repo. # # The command ladder (each rung includes the one below): -# build → compile the engine (WASM, cli, mcp), NO tests, NO plugins +# build → compile the engine (WASM, cli), NO tests, NO plugins # test → build + swift test + wasm smoke + editor browser tests + plugin lint # release → test + optimized WASM + plugins + release binaries + .vsix (nothing pushed) # # The plugins bundle only the optimized WASM, which `build` does not make, so -# `plugins-build` and `release` build them. +# `plugins-build` and `release` build them. The MCP servers live in vgraph-mcp/, +# another engine consumer with its own justfile; `just mcp <recipe>` runs one. # publish-*→ actually ship one target (outward-facing / irreversible) # # `release` is the safety line: reproducible and reversible. Everything below @@ -31,10 +32,6 @@ converter_dir := env_var_or_default("VITHANCO_CONVERTER_DIR", justfile_directory # No defaults: they name a developer account, so the maintainer sets them. signing_id := env_var_or_default("VITHANCO_SIGNING_ID", "") notary_profile := env_var_or_default("VITHANCO_NOTARY_PROFILE", "") -# Cloud Run image / region / service (used by the cloud recipes). -cloud_image := env_var_or_default("VGRAPH_CLOUD_IMAGE", "europe-west1-docker.pkg.dev/vgraph-mcp/cloud-run-source-deploy/vgraph-mcp-http") -cloud_region := env_var_or_default("VGRAPH_CLOUD_REGION", "europe-west1") -cloud_service := env_var_or_default("VGRAPH_CLOUD_SERVICE", "vgraph-mcp") # Default: show the menu. default: @@ -44,9 +41,9 @@ default: # Build / test / release (decomposed from the old build.sh monolith) # ═══════════════════════════════════════════════════════════════════════════ -# Compile the engine (WASM + cli + mcp) in {{config}} config. No tests, no plugins (see plugins-build). +# Compile the engine (WASM + cli) in {{config}} config. No tests, no plugins (see plugins-build). [group('build')] -build: _wasm-build cli mcp +build: _wasm-build cli @echo "✓ build complete ({{config}}, no tests)" # Build the plugins that are cloned (they need the optimized WASM: `just config=release plugins-build`). A clone without them skips. @@ -93,135 +90,6 @@ fonts: # from Google Fonts, so it needs network, and it rewrites committed binaries. ./scripts/build-fonts.sh -# Build the native MCP server. FLAGS: --release. -[group('build')] -mcp *flags: - swift build --product vgraph-mcp -c {{ if flags == "" { config } else if flags == "--release" { "release" } else { error("unknown flag: " + flags + " (only --release)") } }} - -# Assemble the Node MCP host: vendor the engine + fonts, refresh tools.json. -[group('build')] -mcp-node: mcp - #!/usr/bin/env bash - set -euo pipefail - # Always release, regardless of `config`. This vendors what npm publishes, - # and the debug module is 78MB against 4.1MB — `just mcp-node` with the - # default config would otherwise quietly build a package nobody should ship. - ./build-wasm.sh --release --skip-smoke - # Vendored rather than committed: the wasm is 4.1MB, and a copy in git is a - # copy that can disagree with the engine it was built from. Same reason the - # plugins re-copy it from website/Package on every build. - rm -rf vgraph-mcp-node/vendor - mkdir -p vgraph-mcp-node/vendor - cp -R website/Package vgraph-mcp-node/vendor/Package - cp -R fonts vgraph-mcp-node/vendor/fonts - # Belt and braces: the line above asks for release, this catches the day - # someone changes it back. - WASM_BYTES=$(wc -c < vgraph-mcp-node/vendor/Package/VGraphWasm.wasm) - if [ "$WASM_BYTES" -gt 20000000 ]; then - echo "Error: vendored wasm is $WASM_BYTES bytes — that is a debug build." >&2 - exit 1 - fi - ./scripts/dump-mcp-tools.sh - echo "✓ vgraph-mcp-node vendored ($(du -sh vgraph-mcp-node/vendor | cut -f1))" - -# Regenerate every tracked file the build generates (today vgraph-mcp-node/tools.json). CI fails while one is stale. -[group('build')] -regen: mcp - ./scripts/check-generated.sh --write - -# Run the Node MCP host against the current engine build (stdio; Ctrl-C to stop). -[group('run')] -mcp-node-run: mcp-node - cd vgraph-mcp-node && [ -d node_modules ] || npm install --silent; node src/server.mjs - -# Publish the Node MCP host to npm, then list it in the MCP Registry. -[group('publish')] -publish-mcp-node otp='': _require-maintainer _require-vgraph-main mcp-node - #!/usr/bin/env bash - set -euo pipefail - cd vgraph-mcp-node - PKG=$(node -p "require('./package.json').name") - VER=$(node -p "require('./package.json').version") - - # Preflight: everything that can fail, before anything is published. An npm - # version cannot be re-published once taken, so discovering a problem - # halfway through leaves a burnt version number behind. - FAIL=0 - - if ! npm whoami >/dev/null 2>&1; then - echo "Preflight: not logged in to npm — run 'npm login'." >&2 - FAIL=1 - fi - - # Not a failure: npm and the registry are two publishes, and the first run - # got npm out and then died on an expired registry token. Aborting here - # would have made the recipe unable to finish its own half-done work. - NPM_DONE=0 - if npm view "$PKG@$VER" version >/dev/null 2>&1; then - NPM_DONE=1 - fi - - # The registry verifies a server by matching `mcpName` in the *published* - # package against the name in server.json. Getting this wrong is only - # discoverable after npm has taken the version. - MCP_NAME=$(node -p "require('./package.json').mcpName || ''") - SRV_NAME=$(node -p "require('./server.json').name") - SRV_VER=$(node -p "require('./server.json').version") - SRV_PKG_VER=$(node -p "require('./server.json').packages[0].version") - if [ "$MCP_NAME" != "$SRV_NAME" ]; then - echo "Preflight: package.json mcpName ($MCP_NAME) != server.json name ($SRV_NAME)." >&2 - FAIL=1 - fi - if [ "$SRV_VER" != "$VER" ] || [ "$SRV_PKG_VER" != "$VER" ]; then - echo "Preflight: server.json versions ($SRV_VER / $SRV_PKG_VER) != package.json ($VER)." >&2 - FAIL=1 - fi - - # `just mcp-node` ran above, so these should hold — they catch someone - # publishing from a tree where it half-failed. - WASM="vendor/Package/VGraphWasm.wasm" - if [ ! -f "$WASM" ]; then - echo "Preflight: $WASM missing — 'just mcp-node' did not complete." >&2 - FAIL=1 - elif [ "$(wc -c < "$WASM")" -gt 20000000 ]; then - echo "Preflight: $WASM is a debug build." >&2 - FAIL=1 - fi - if [ ! -s tools.json ] || [ "$(node -p "require('./tools.json').length")" -eq 0 ]; then - echo "Preflight: tools.json is empty — scripts/dump-mcp-tools.sh did not run." >&2 - FAIL=1 - fi - # OFL 1.1 requires the licence ship with the fonts. - if [ ! -f vendor/fonts/OFL.txt ]; then - echo "Preflight: vendor/fonts/OFL.txt missing — the fonts must not ship without it." >&2 - FAIL=1 - fi - - if [ "$FAIL" -ne 0 ]; then - echo "" >&2 - echo "Nothing was published." >&2 - exit 1 - fi - - if [ "$NPM_DONE" -eq 1 ]; then - echo "· $PKG@$VER already on npm — skipping, going straight to the registry" - else - echo "Publishing $PKG@$VER to npm..." - # npm requires 2FA or a granular token with 2FA bypass to publish, - # whatever the account's own tfa setting says. With a granular token no - # OTP is needed; with account 2FA one is, and it must be supplied at the - # moment of use because it expires in seconds. - if [ -n "{{otp}}" ]; then - npm publish --access public --otp="{{otp}}" - else - npm publish --access public - fi - fi - - echo "" - cd .. - ./scripts/mcp-registry.sh - # build + run the full test suite (format + swift + wasm smoke + editor browser + plugin lint). FILTER scopes swift test. [group('test')] test filter='': build @@ -241,13 +109,11 @@ test filter='': build ./scripts/audit-public.test.sh ./scripts/publish-plugins.test.sh ./scripts/plugins-release.test.sh - ./scripts/mcp-registry.test.sh ./scripts/release-stamp.test.sh ./scripts/ci-status.test.sh - ./scripts/check-generated.test.sh - ./scripts/check-generated.sh just _if-cloned obsidian-vithanco obsidian-lint just _if-cloned vscode-vithanco vscode-preview + just _if-cloned vgraph-mcp "mcp test" # Node WASM smoke tests (vitest) against the deployed website/Package. [group('test')] @@ -329,7 +195,6 @@ release full='': _release-preflight if [ -z "{{full}}" ] && ./scripts/ci-status.sh; then just config=release build just test-wasm - ./scripts/check-generated.sh just plugin-api just _if-cloned obsidian-vithanco obsidian-lint just _if-cloned vscode-vithanco vscode-preview @@ -339,6 +204,7 @@ release full='': _release-preflight fi just config=release plugins-build ( cd vscode-vithanco && npm run package --silent ) + just mcp release ./scripts/release-stamp.sh record echo "" echo "✓ release artifacts ready (nothing pushed)." @@ -353,7 +219,7 @@ release full='': _release-preflight else echo " just publish-plugins # tag + push + GitHub releases at v$V" fi - echo " just publish-cloud-run / just stage-website" + echo " just mcp publish / just stage-website" # Bump the JS library version: set it in website/dist/package.json and sync all filenames/refs. [group('build')] @@ -400,11 +266,6 @@ clean: run-cli *args: VGRAPH_LOG_LEVEL=debug swift run vgraph-cli {{args}} -# Run the native MCP server. -[group('run')] -run-mcp: - VGRAPH_LOG_LEVEL=debug swift run vgraph-mcp - # Serve website/ locally for manual preview (ES modules need a real server). [group('run')] serve port='8000': @@ -415,26 +276,15 @@ serve port='8000': dev: _wasm-build cd obsidian-vithanco && npm run dev -# Build the LOCAL release MCP binary for Claude Desktop (distinct from the cloud image). -[group('run')] -local-server: - #!/usr/bin/env bash - set -euo pipefail - echo "Formatting VGraphMCP..." - swift-format -r -i --configuration .swift-format Sources/VGraphMCP - echo "Running MCP server tests..." - swift test --filter VGraphMCPTests - echo "Building vgraph-mcp (release)..." - swift build --product vgraph-mcp -c release - echo "" - echo "✓ Binary: .build/release/vgraph-mcp" - ls -lh .build/release/vgraph-mcp | awk '{print " " $5 " - " $9}' - echo " Quit & relaunch Claude Desktop to reload the server." - # ═══════════════════════════════════════════════════════════════════════════ # Plugins (separate git repos, driven by plugins.json) # ═══════════════════════════════════════════════════════════════════════════ +# Run a recipe of vgraph-mcp's own justfile (the MCP servers): `just mcp`, `just mcp test`, `just mcp publish`. +[group('plugins')] +mcp *args: (_require-plugin "vgraph-mcp") + just --justfile vgraph-mcp/justfile "$@" + # Clone any missing plugin repos listed in plugins.json. [group('plugins')] plugins-setup: @@ -460,13 +310,14 @@ plugins-release bump='patch' plugin='': _require-maintainer _release-preflight esac ./release-plugins.sh "$ARG" {{plugin}} V=$(node -p "const r = require('./plugins.json').plugins; (r.find(p => p.path === process.argv[1]) || r[0]).version" "{{plugin}}") - # main takes no direct pushes, so VGraph's half of the bump (plugins.json, - # vgraph-mcp-node) reaches it through a PR. _release-preflight left the - # checkout clean, so this commit holds the bump and nothing else. Each - # plugin's half is committed by publish-plugins, with the engine it ships. + # main takes no direct pushes, so VGraph's half of the bump (plugins.json) + # reaches it through a PR. _release-preflight left the checkout clean, so + # this commit holds the bump and nothing else. Each consumer's half is + # committed when it is published: by publish-plugins with the engine it + # ships, and by `just mcp publish`. BRANCH="release/$V" git switch -q -c "$BRANCH" - git add plugins.json vgraph-mcp-node + git add plugins.json git commit -q -m "chore: release $V" git push -q -u origin "$BRANCH" gh pr create --base main --head "$BRANCH" --title "chore: release $V" \ @@ -762,77 +613,15 @@ publish-website: _require-maintainer _require-vgraph-main (cli "--release") stag deploy target *flags: ./deploy.sh {{target}} {{flags}} -# Build the linux/amd64 image on Cloud Build + push it (no local Docker needed). -[group('publish')] -build-cloud-image: _require-maintainer _require-gcloud - #!/usr/bin/env bash - set -euo pipefail - # Built remotely because Cloud Run is x86_64-only and this is an ARM Mac: a - # local build must emulate amd64, and the Swift compiler dies under QEMU with - # SIGILL partway through. Cloud Build is native amd64 — no emulation, no - # Rosetta, no Docker. Use build-cloud-image-local if you want a local image. - echo "=== Building {{cloud_service}} on Cloud Build (native linux/amd64) ===" - # --tag builds AND pushes, so publish-cloud-run needs no separate docker push. - # Upload honours .gcloudignore. - gcloud builds submit --tag "{{cloud_image}}" . - echo "" - echo "✓ built and pushed {{cloud_image}}" - -# Fallback: build the image locally with Docker instead of on Cloud Build. -[group('publish')] -build-cloud-image-local: - #!/usr/bin/env bash - set -euo pipefail - # Needs an amd64-capable builder. On Apple Silicon that means Rosetta — under - # QEMU user-mode emulation the Swift compiler crashes partway through: - # softwareupdate --install-rosetta --agree-to-license - # colima stop && colima start --vm-type=vz --vz-rosetta --cpu 6 --memory 12 - # Checked up front: without it the failure is a bare 'docker: command not - # found' from inside the recipe, which says nothing about what to install. - if ! command -v docker >/dev/null 2>&1; then - echo "ERROR: docker is not installed, and this recipe builds a linux/amd64 image." >&2 - echo "" >&2 - echo " Any Docker-compatible runtime will do, e.g." >&2 - echo " brew install --cask docker # Docker Desktop" >&2 - echo " brew install colima docker # lighter CLI-only alternative" >&2 - echo "" >&2 - echo " Cloud Run is the only thing that needs this — the plugins, the" >&2 - echo " website and the local MCP binary all build without it." >&2 - exit 1 - fi - if ! docker info >/dev/null 2>&1; then - echo "ERROR: docker is installed but the daemon is not running." >&2 - echo " Start Docker Desktop (or 'colima start'), then re-run." >&2 - exit 1 - fi - echo "=== Building {{cloud_service}} image for linux/amd64 ===" - docker build --platform linux/amd64 -t "{{cloud_image}}" . - SIZE=$(docker image inspect "{{cloud_image}}" --format='{{ "{{" }}.Size{{ "}}" }}') - awk "BEGIN { printf \" Image: {{cloud_image}}\n Size: %.0f MB\n\", $SIZE/1024/1024 }" - -# Checked before build-cloud-image runs, so a missing gcloud costs a second -# rather than surfacing after a multi-minute image build. -_require-gcloud: - #!/usr/bin/env bash - if ! command -v gcloud >/dev/null 2>&1; then - echo "ERROR: gcloud is not installed, and both remaining steps need it —" >&2 - echo " 'docker push' to Artifact Registry needs its credential helper," >&2 - echo " and the deploy is 'gcloud run deploy'." >&2 - echo "" >&2 - echo " brew install --cask google-cloud-sdk" >&2 - echo " gcloud auth login && gcloud auth configure-docker" >&2 - exit 1 - fi - # First dependency of every recipe that publishes under the maintainer's accounts. # What must already hold before a release is built or published, checked in # seconds: `just release` runs this first, so a version bump that is not yet # merged stops it here, not after its tests and builds. -_release-preflight: _require-vgraph-main (_require-plugin "obsidian-vithanco") (_require-plugin "vscode-vithanco") +_release-preflight: _require-vgraph-main (_require-plugin "obsidian-vithanco") (_require-plugin "vscode-vithanco") (_require-plugin "vgraph-mcp") #!/usr/bin/env bash set -uo pipefail FAIL=0 - for DIR in obsidian-vithanco vscode-vithanco; do + for DIR in obsidian-vithanco vscode-vithanco vgraph-mcp; do BRANCH=$(git -C "$DIR" branch --show-current) if [ "$BRANCH" != main ]; then echo "Preflight: $DIR is on '$BRANCH', not main — the release would tag and push that branch." >&2 @@ -873,40 +662,6 @@ _require-maintainer: exit 1 fi -# Build + push the image + roll out a new Cloud Run revision + health check. -[group('publish')] -publish-cloud-run: _require-maintainer _require-vgraph-main _require-gcloud build-cloud-image - #!/usr/bin/env bash - set -euo pipefail - # No push step: `gcloud builds submit --tag` already pushed to Artifact - # Registry. Building locally instead? Run build-cloud-image-local, then - # `docker push {{cloud_image}}` yourself before deploying. - echo "=== Deploying to Cloud Run ===" - # The service is open to anyone (see SECURITY.md), so these bound what it can cost. - # They used to be set by hand with `gcloud run services update`; a fresh deploy - # would have lost them. - limits=( - # --max-instances: one instance caps the bill. The exposure left is - # availability, which the per-request limits in MCPLimits are for. - --max-instances=1 - # --concurrency: each render holds a Graphviz layout and, for the PNG, an - # rsvg-convert process and its bitmap in the instance's 1 GiB. Four in flight - # peaked at about 440 MB; docs/mcp-hardening.md has the measurements. - --concurrency=4 - # --timeout: longer than the 120 s request deadline in MCPLimits, so the - # client gets our 504 and not Cloud Run's. - --timeout=150 - # --cpu-throttling: CPU only while a request is in flight. Layout is the - # only work, and idle time then costs nothing. - --cpu-throttling - ) - gcloud run deploy "{{cloud_service}}" --image "{{cloud_image}}" --port 8080 --region "{{cloud_region}}" --memory 1Gi "${limits[@]}" - echo "" - echo "=== Verifying health check ===" - curl -s https://mcp.vithanco.com/health - echo "" - echo "✓ Cloud Run deploy complete." - # Coordinated release across all surfaces. Builds, then confirms before anything ships. [group('publish')] publish-all: _require-maintainer @@ -934,10 +689,9 @@ publish-all: _require-maintainer fi VER=$(echo "$VERSIONS" | head -1 | awk '{print $2}') - # npm auth is checked here rather than inside publish-mcp-node's own - # preflight because by then two plugins and a Cloud Run revision are - # already out — the same reason publish-plugins preflights before it - # mutates anything. + # npm auth is checked here rather than inside vgraph-mcp's own publish + # because by then two plugins are already out — the same reason + # publish-plugins preflights before it mutates anything. if ! npm whoami >/dev/null 2>&1; then echo "Preflight: not logged in to npm — run 'npm login'." >&2 echo " (aborting now rather than after the plugins are already released)" >&2 @@ -957,7 +711,7 @@ publish-all: _require-maintainer echo " • VGraph+plugins → push + tag + GitHub release" echo " • npm + registry → @vithanco/vgraph-mcp and com.vithanco/vgraph-mcp" echo " • Website → generate + deploy to vithanco.github.io, commit + push" - echo " • Cloud Run → new revision of '{{cloud_service}}' in {{cloud_region}}" + echo " • Cloud Run → new revision of the hosted MCP server" if [ "$VSCE_AUTO" -eq 1 ]; then echo " • VS Code Mktpl → vsce publish" else @@ -978,17 +732,9 @@ publish-all: _require-maintainer just publish-plugins defer fi - # Both, not npm alone: npm and the registry are two publishes, and skipping - # on npm kept a failed registry publish from ever being retried. - if [ "$(npm view "@vithanco/vgraph-mcp" version 2>/dev/null)" = "$VER" ] \ - && ./scripts/mcp-registry.sh --has; then - echo "· npm and the MCP Registry already at $VER — skipping" - else - just publish-mcp-node - fi - + # Tag and push, npm, the MCP Registry and Cloud Run; each skips once done. + just mcp publish just publish-website - just publish-cloud-run ./scripts/vscode-marketplace.sh echo "" @@ -1004,7 +750,7 @@ publish-all: _require-maintainer echo " npm → @vithanco/vgraph-mcp" echo " registry → com.vithanco/vgraph-mcp" echo " website → vithanco.github.io" - echo " Cloud Run → {{cloud_service}} in {{cloud_region}}" + echo " Cloud Run → mcp.vithanco.com" # ═══════════════════════════════════════════════════════════════════════════ # Misc @@ -1019,7 +765,7 @@ setup: plugins-setup #!/usr/bin/env bash set -euo pipefail git config core.hooksPath .githooks - for d in obsidian-vithanco vscode-vithanco VGraphWasm/Tests-JS VGraphWasm/Tests-Browser .; do + for d in obsidian-vithanco vscode-vithanco vgraph-mcp VGraphWasm/Tests-JS VGraphWasm/Tests-Browser .; do if [ -f "$d/package.json" ]; then echo "npm install in $d" ( cd "$d" && npm install --silent ) @@ -1046,13 +792,7 @@ doctor: have jq "brew install jq" have wasm-opt "brew install binaryen" have wasm-strip "brew install wabt" - want gcloud "only for the maintainer's Cloud Run deploy (brew install --cask google-cloud-sdk)" want gitleaks "only for the maintainer's public export (brew install gitleaks)" - # Docker is optional now: build-cloud-image runs on Cloud Build. Only the - # build-cloud-image-local fallback needs it — and buildx with it, since the - # Dockerfile's `RUN --mount=type=cache` will not run on the legacy builder. - want docker "only for build-cloud-image-local (brew install colima docker)" - want docker-buildx "with docker; the classic builder works too since the Dockerfile needs no BuildKit" have python3 "brew install python (just serve)" # Optional: only the wasm build, its smoke tests and the editor's browser # tests need the SDK; native `swift build` and `swift test` do not. diff --git a/plugins.json b/plugins.json index 69915c6..75e8963 100644 --- a/plugins.json +++ b/plugins.json @@ -12,8 +12,9 @@ "repo": "https://github.com/Vithanco/vscode-vithanco.git" }, { - "path": "vgraph-mcp-node", - "version": "1.0.15" + "path": "vgraph-mcp", + "version": "1.0.15", + "repo": "https://github.com/Vithanco/vgraph-mcp.git" } ] } diff --git a/scripts/check-generated.sh b/scripts/check-generated.sh deleted file mode 100755 index 15e61ba..0000000 --- a/scripts/check-generated.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# Regenerate every tracked file the build generates, and fail if that changed one. -# -# scripts/check-generated.sh # in CI and `just test`: stale means fail -# scripts/check-generated.sh --write # `just regen`: just regenerate -# -# Generated files used to be refreshed only by the release, which then found -# them uncommitted and stopped. Checked on every change, the pull request that -# makes one stale fails instead. Expects the binaries the generators ask to be -# built already. -set -euo pipefail - -regenerate() { - ./scripts/dump-mcp-tools.sh >/dev/null -} - -if [ "${1:-}" = --write ]; then - regenerate - exit -fi - -# Compare the working tree before and after, so unrelated uncommitted work and -# a file already regenerated but not yet committed both pass. -state() { git status --porcelain=v1 --untracked-files=all | while read -r _ f; do - printf '%s %s\n' "$f" "$(git hash-object "$f" 2>/dev/null || echo gone)"; done; } -BEFORE=$(state) -regenerate -CHANGED=$( (diff <(echo "$BEFORE") <(state) || :) | sed -n 's/^> \([^ ]*\) .*/\1/p' | sort -u) -if [ -n "$CHANGED" ]; then - echo "Generated files are out of date:" >&2 - echo "$CHANGED" | sed 's/^/ /' >&2 - echo "Run 'just regen' and commit them." >&2 - exit 1 -fi diff --git a/scripts/check-generated.test.sh b/scripts/check-generated.test.sh deleted file mode 100755 index 7059a3d..0000000 --- a/scripts/check-generated.test.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash -# A generated file regenerated only at release time left a stale copy on main, -# and the release stopped on the uncommitted change it made. Checked on every -# change, the pull request that makes it stale fails instead. -set -uo pipefail - -REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd) -ROOT=$(mktemp -d) || exit 1 -trap 'rm -rf "$ROOT"' EXIT -FAILED=0 -fail() { echo "FAIL: $*" >&2; FAILED=1; } -export GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@example.invalid GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@example.invalid - -given_generated() { # committed tools.json holding $1; the generator now writes $2 - WORK=$(mktemp -d "$ROOT/work.XXXXXX") || exit 1 - mkdir -p "$WORK/scripts" "$WORK/vgraph-mcp-node" - printf '#!/bin/sh\necho %s > vgraph-mcp-node/tools.json\n' "$2" > "$WORK/scripts/dump-mcp-tools.sh" - chmod +x "$WORK/scripts/dump-mcp-tools.sh" - echo "$1" > "$WORK/vgraph-mcp-node/tools.json" - git -C "$WORK" init -q -b main && git -C "$WORK" add . && git -C "$WORK" commit -qm init -} -check() { ( cd "$WORK" && "$REPO_ROOT/scripts/check-generated.sh" "$@" ) >"$WORK/out" 2>&1; } - -# Given the committed file is what the generator writes, then the check passes. -given_generated '[decompose]' '[decompose]' -check || fail "up-to-date file failed: $(cat "$WORK/out")" - -# Given a tool added without regenerating, then the check fails and says how to fix it. -given_generated '[]' '[decompose]' -check && fail "stale file passed" -grep -q 'vgraph-mcp-node/tools.json' "$WORK/out" || fail "does not name the stale file: $(cat "$WORK/out")" -grep -q 'just regen' "$WORK/out" || fail "does not say how to fix it: $(cat "$WORK/out")" - -# Given unrelated uncommitted work, then the check still passes. -given_generated '[decompose]' '[decompose]' -echo wip > "$WORK/notes.md" -check || fail "unrelated uncommitted work failed: $(cat "$WORK/out")" - -# Given --write, then the file is regenerated and nothing fails. -given_generated '[]' '[decompose]' -check --write || fail "--write failed: $(cat "$WORK/out")" -grep -q decompose "$WORK/vgraph-mcp-node/tools.json" || fail "--write did not regenerate" - -exit "$FAILED" diff --git a/scripts/check-plugin-api.sh b/scripts/check-plugin-api.sh index 06f3c68..18d8df3 100755 --- a/scripts/check-plugin-api.sh +++ b/scripts/check-plugin-api.sh @@ -14,13 +14,13 @@ set -uo pipefail MAIN=VGraphWasm/Sources/Main.swift # name : source dir : the identifier that holds the engine's exports in that -# consumer. The plugins destructure them onto `exports`; the Node MCP host +# consumer. The plugins destructure them onto `exports`; the npm MCP host # names the object `api`. Grepping for the wrong one finds nothing and reports # success, which is the failure mode this script exists to prevent. CONSUMERS=( "obsidian-vithanco:obsidian-vithanco/src:exports" "vscode-vithanco:vscode-vithanco/src:exports" - "vgraph-mcp-node:vgraph-mcp-node/src:api" + "vgraph-mcp:vgraph-mcp/src:api" ) if [ ! -f "$MAIN" ]; then diff --git a/scripts/codeowners.test.sh b/scripts/codeowners.test.sh index 51a3786..5307510 100755 --- a/scripts/codeowners.test.sh +++ b/scripts/codeowners.test.sh @@ -21,9 +21,6 @@ AGENTS.md CLAUDE.md .coderabbit.yaml justfile -Dockerfile -.dockerignore -.gcloudignore plugins.json Package.swift Package.resolved @@ -31,8 +28,6 @@ package.json package-lock.json VGraphWasm/Package.swift VGraphWasm/Package.resolved -vgraph-mcp-node/package.json -vgraph-mcp-node/release.sh website/dist/package.json build-wasm.sh deploy.sh diff --git a/scripts/dump-mcp-tools.sh b/scripts/dump-mcp-tools.sh deleted file mode 100755 index 7c043a1..0000000 --- a/scripts/dump-mcp-tools.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env bash -# Regenerate vgraph-mcp-node/tools.json from the native MCP server. -# -# The Node host serves the same tools as `vgraph-mcp`, and their descriptions -# are ~20KB of VGL documentation that the model actually reads — the difference -# between a diagram that follows a notation and one that doesn't. Re-typing -# them in JavaScript would guarantee they drift, so the Swift stays the single -# source of truth and this asks the built server what it offers. -# -# Speaking MCP to it rather than parsing Swift: what a client sees is the thing -# worth copying, and a tool added to VGraphTools.all shows up here with no -# change to this script. -set -euo pipefail - -cd "$(dirname "${BASH_SOURCE[0]}")/.." -OUT="vgraph-mcp-node/tools.json" - -# Whichever was built most recently, not a fixed preference: a stale release -# binary sitting next to a fresh debug one would silently dump old descriptions. -BIN="" -for candidate in .build/release/vgraph-mcp .build/debug/vgraph-mcp; do - [ -x "$candidate" ] || continue - if [ -z "$BIN" ] || [ "$candidate" -nt "$BIN" ]; then - BIN="$candidate" - fi -done -if [ -z "$BIN" ]; then - echo "Error: no vgraph-mcp binary — run 'just mcp' first." >&2 - exit 1 -fi - -echo "Asking $BIN for its tool list..." - -# stdin must stay open until the server has answered; a closed pipe races the -# reply. Three seconds is slack, not a measurement. -RESPONSE=$( ( - printf '%s\n' \ - '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"dump-tools","version":"1"}}}' \ - '{"jsonrpc":"2.0","method":"notifications/initialized"}' \ - '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' - sleep 3 -) | "$BIN" 2>/dev/null | grep '"id":2' ) - -if [ -z "$RESPONSE" ]; then - echo "Error: no tools/list response from $BIN." >&2 - exit 1 -fi - -printf '%s' "$RESPONSE" | python3 -c " -import json, sys -tools = json.load(sys.stdin)['result']['tools'] -if not tools: - sys.exit('Error: server returned an empty tool list.') -with open(sys.argv[1], 'w') as fh: - json.dump(tools, fh, indent=2, sort_keys=True) - fh.write(chr(10)) -print(' %d tools -> %s' % (len(tools), sys.argv[1])) -for t in tools: - print(' ' + t['name']) -" "$OUT" diff --git a/scripts/justfile-hygiene.test.sh b/scripts/justfile-hygiene.test.sh index 92df2fa..f11ccec 100755 --- a/scripts/justfile-hygiene.test.sh +++ b/scripts/justfile-hygiene.test.sh @@ -12,7 +12,7 @@ fail() { echo "FAIL: $*" >&2; FAILED=1; } # Recipes in the publish group that need no guard: they build or stage locally # and push nothing under anyone's account. -EXEMPT="stage-website deploy build-cloud-image-local" +EXEMPT="stage-website deploy" unguarded=$(just --dump --dump-format json | EXEMPT="$EXEMPT" python3 -c ' import json, os, sys @@ -78,6 +78,9 @@ if "just obsidian-lint" in test: print("test lints the obsidian plugin unconditi if "just vscode-preview" in test: print("test runs the vscode preview unconditionally") if "_if-cloned obsidian-vithanco obsidian-lint" not in test: print("test does not lint the plugins that are present") if "_if-cloned vscode-vithanco vscode-preview" not in test: print("test does not run the vscode preview when it is present") +if "_if-cloned vgraph-mcp" not in test: print("test does not test vgraph-mcp when it is present") +if "mcp release" not in json.dumps(r["release"]["body"]): print("release does not build vgraph-mcp") +if "vgraph-mcp/justfile" not in json.dumps(r["mcp"]["body"]): print("mcp does not hand over to the vgraph-mcp justfile") ') [ -z "$out" ] || fail "$out" diff --git a/scripts/mcp-registry.sh b/scripts/mcp-registry.sh deleted file mode 100755 index 8f5f935..0000000 --- a/scripts/mcp-registry.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env bash -# List vgraph-mcp-node in the MCP Registry at the version its server.json names. -# -# scripts/mcp-registry.sh # log in and publish, retrying; nothing to do when listed -# scripts/mcp-registry.sh --has # exit 0 when the registry lists that version -# -# The registry stalls a TLS handshake now and then (one connection in six, on -# 2026-11-21), so every step is retried. A publish that timed out may still have -# landed, and the registry refuses a version twice, so each attempt asks first. -set -euo pipefail - -cd vgraph-mcp-node -NAME=$(node -p "require('./server.json').name") -VER=$(node -p "require('./server.json').version") -REGISTRY=https://registry.modelcontextprotocol.io - -listed() { - [ "$(curl -s -o /dev/null -w '%{http_code}' --max-time 20 \ - "$REGISTRY/v0/servers/${NAME/\//%2F}/versions/$VER")" = 200 ] -} - -if [ "${1:-}" = --has ]; then - listed - exit -fi - -if ! command -v mcp-publisher >/dev/null 2>&1; then - echo "· mcp-publisher not installed, so the registry entry was skipped —" - echo " 'brew install mcp-publisher', then 'just publish-mcp-node'." - exit 0 -fi - -# DNS auth, not GitHub: it is what earns the com.vithanco namespace rather than -# io.github.vithanco. The token is short-lived, so log in right before publishing. -KEY="${MCP_SIGNING_KEY:-$HOME/.config/mcp-publisher/vithanco-ed25519.pem}" -login() { - [ -f "$KEY" ] || return 0 - mcp-publisher login dns --domain vithanco.com \ - --private-key "$(openssl pkey -in "$KEY" -outform DER | tail -c 32 | xxd -p -c 64)" -} -if [ ! -f "$KEY" ]; then - echo "· no signing key at $KEY — using whatever session mcp-publisher holds." - echo " (set MCP_SIGNING_KEY if it lives elsewhere)" -fi - -TRIES=${MCP_RETRIES:-4} -DELAY=${MCP_RETRY_DELAY:-15} -for attempt in $(seq 1 "$TRIES"); do - if listed; then - echo "✓ $NAME $VER is listed in the MCP Registry" - exit 0 - fi - echo "Publishing $NAME $VER to the MCP Registry (attempt $attempt of $TRIES)..." - if login && mcp-publisher publish; then - echo "✓ $NAME $VER is listed in the MCP Registry" - exit 0 - fi - [ "$attempt" -lt "$TRIES" ] && sleep $((DELAY * attempt)) -done -if listed; then - echo "✓ $NAME $VER is listed in the MCP Registry" - exit 0 -fi -echo "The MCP Registry did not take $NAME $VER after $TRIES attempts." >&2 -echo "npm has it; finish with 'just publish-mcp-node', which goes straight to the registry." >&2 -exit 1 diff --git a/scripts/mcp-registry.test.sh b/scripts/mcp-registry.test.sh deleted file mode 100755 index 9333090..0000000 --- a/scripts/mcp-registry.test.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env bash -# The registry stalls a TLS handshake now and then. One stall used to end the -# release, and a rerun of publish-all never came back to the registry, so it -# fell several versions behind npm. -set -uo pipefail - -REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd) -ROOT=$(mktemp -d) || exit 1 -trap 'rm -rf "$ROOT"' EXIT -FAILED=0 -fail() { echo "FAIL: $*" >&2; FAILED=1; } - -# Counters in REG: a file `login-fails` holding 2 makes the next two logins fail. -mkdir "$ROOT/bin" -cat > "$ROOT/bin/curl" <<'EOF' -#!/usr/bin/env bash -echo "$*" >> "$REG/curl.log" -if [ -s "$REG/curl-fails" ] && [ "$(cat "$REG/curl-fails")" -gt 0 ]; then - echo $(( $(cat "$REG/curl-fails") - 1 )) > "$REG/curl-fails" - printf 000; exit 28 -fi -case "$*" in - *"/v0/servers/com.example%2Fdemo/versions/1.2.3"*) [ -f "$REG/listed" ] && printf 200 || printf 404 ;; - *) printf 404 ;; -esac -EOF -cat > "$ROOT/bin/mcp-publisher" <<'EOF' -#!/usr/bin/env bash -echo "$1" >> "$REG/calls" -fails() { [ -s "$REG/$1" ] && [ "$(cat "$REG/$1")" -gt 0 ] && echo $(( $(cat "$REG/$1") - 1 )) > "$REG/$1"; } -case "$1" in - login) if fails login-fails; then echo "TLS handshake timeout" >&2; exit 1; fi ;; - publish) - if fails publish-fails; then echo "TLS handshake timeout" >&2; exit 1; fi - touch "$REG/listed" - [ -f "$REG/lands-then-fails" ] && { rm "$REG/lands-then-fails"; exit 1; } - ;; -esac -exit 0 -EOF -printf '#!/bin/sh\nhead -c 32 /dev/zero\n' > "$ROOT/bin/openssl" -chmod +x "$ROOT/bin/"* -export PATH="$ROOT/bin:$PATH" MCP_RETRY_DELAY=0 MCP_RETRIES=3 - -given_registry() { # in a fresh WORK with server.json at 1.2.3 and a signing key - WORK=$(mktemp -d "$ROOT/work.XXXXXX") || exit 1 - export REG="$WORK/reg" MCP_SIGNING_KEY="$WORK/key.pem" - mkdir -p "$REG" "$WORK/vgraph-mcp-node" - : > "$REG/calls"; : > "$REG/curl.log"; echo key > "$MCP_SIGNING_KEY" - echo '{"name":"com.example/demo","version":"1.2.3"}' > "$WORK/vgraph-mcp-node/server.json" -} -registry() { ( cd "$WORK" && "$REPO_ROOT/scripts/mcp-registry.sh" "$@" ) >"$WORK/out" 2>&1; } -count() { grep -cx "$1" "$REG/calls"; } - -# Given logins that time out twice, when publishing, then the third attempt lists it. -given_registry -echo 2 > "$REG/login-fails" -registry || fail "gave up on two timeouts: $(cat "$WORK/out")" -[ -f "$REG/listed" ] || fail "not listed after the timeouts" -[ "$(count login)" = 3 ] || fail "wanted three logins: $(cat "$REG/calls")" -[ "$(count publish)" = 1 ] || fail "wanted one publish: $(cat "$REG/calls")" - -# Given the version already listed, when publishing, then mcp-publisher is not run. -given_registry -touch "$REG/listed" -registry || fail "failed on a version already listed: $(cat "$WORK/out")" -[ -s "$REG/calls" ] && fail "ran mcp-publisher for a listed version: $(cat "$REG/calls")" - -# Given a publish that lands but reports a timeout, when retrying, then it is not published twice. -given_registry -touch "$REG/lands-then-fails" -registry || fail "failed although the publish landed: $(cat "$WORK/out")" -[ "$(count publish)" = 1 ] || fail "published a listed version again: $(cat "$REG/calls")" - -# Given a registry that never answers, when publishing, then it stops after -# MCP_RETRIES attempts and says how to finish. -given_registry -echo 99 > "$REG/login-fails" -registry && fail "succeeded without listing" -[ "$(count login)" = 3 ] || fail "wanted three attempts: $(cat "$REG/calls")" -grep -q 'just publish-mcp-node' "$WORK/out" || fail "does not say how to finish: $(cat "$WORK/out")" - -# Given the version listed, not listed, or a registry that times out, when -# asking, then only a listed version answers yes. -given_registry -registry --has && fail "--has said yes before publishing" -touch "$REG/listed" -registry --has || fail "--has said no for a listed version" -echo 1 > "$REG/curl-fails" -registry --has && fail "--has said yes when the registry timed out" -grep -q -- '--max-time' "$REG/curl.log" || fail "asks the registry without a timeout: $(cat "$REG/curl.log")" - -exit "$FAILED" diff --git a/scripts/plugins-release.test.sh b/scripts/plugins-release.test.sh index db3219f..2719539 100755 --- a/scripts/plugins-release.test.sh +++ b/scripts/plugins-release.test.sh @@ -1,8 +1,9 @@ #!/usr/bin/env bash # `just plugins-release` only decides the next version: `just release` builds -# what ships, so a build here was thrown away. Its VGraph half reaches main -# through a PR, so it commits that half and opens the PR rather than leaving -# changes that `just release` then refuses. +# what ships, so a build here was thrown away. Its VGraph half (plugins.json) +# reaches main through a PR, so it commits that half and opens the PR rather than +# leaving changes that `just release` then refuses. Each consumer's own half, +# vgraph-mcp's included, stays uncommitted in its checkout until it is published. set -uo pipefail REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd) @@ -44,7 +45,7 @@ given_everything_at() { # version, in a fresh WORK standing in for a merged VGra cp "$REPO_ROOT/release-plugins.sh" "$WORK/" printf '#!/bin/sh\necho built >> "%s/built.log"\n' "$WORK" > "$WORK/build-wasm.sh" chmod +x "$WORK/build-wasm.sh" - for p in obsidian-vithanco vscode-vithanco; do + for p in obsidian-vithanco vscode-vithanco vgraph-mcp; do git init -q --bare -b main "$WORK/$p.git" git init -q -b main "$WORK/$p" git -C "$WORK/$p" remote add origin "$WORK/$p.git" @@ -54,12 +55,9 @@ given_everything_at() { # version, in a fresh WORK standing in for a merged VGra done cp "$WORK/obsidian-vithanco/package.json" "$WORK/obsidian-vithanco/manifest.json" git -C "$WORK/obsidian-vithanco" add . && git -C "$WORK/obsidian-vithanco" commit -qm manifest - mkdir "$WORK/vgraph-mcp-node" - printf '{"version":"%s"}\n' "$1" > "$WORK/vgraph-mcp-node/package.json" - stub_release_sh "$WORK/vgraph-mcp-node" - printf '{"plugins":[{"path":"obsidian-vithanco","version":"%s"},{"path":"vscode-vithanco","version":"%s"},{"path":"vgraph-mcp-node","version":"%s"}]}\n' \ + printf '{"plugins":[{"path":"obsidian-vithanco","version":"%s"},{"path":"vscode-vithanco","version":"%s"},{"path":"vgraph-mcp","version":"%s"}]}\n' \ "$1" "$1" "$1" > "$WORK/plugins.json" - printf '%s\n' '*.git/' obsidian-vithanco/ vscode-vithanco/ out gh.log release.log built.log > "$WORK/.gitignore" + printf '%s\n' '*.git/' obsidian-vithanco/ vscode-vithanco/ vgraph-mcp/ out gh.log release.log built.log > "$WORK/.gitignore" git init -q --bare -b main "$WORK/vgraph.git" git -C "$WORK" init -q -b main git -C "$WORK" remote add origin "$WORK/vgraph.git" @@ -82,8 +80,10 @@ bump patch || fail "plugins-release patch failed: $(cat "$WORK/out")" [ -f "$WORK/built.log" ] && fail "plugins-release built the engine" git -C "$WORK/vgraph.git" show release/1.2.4:plugins.json 2>/dev/null | grep -q '1.2.4' \ || fail "release/1.2.4 on origin does not carry the bumped plugins.json" -git -C "$WORK/vgraph.git" show release/1.2.4:vgraph-mcp-node/package.json 2>/dev/null | grep -q '1.2.4' \ - || fail "release/1.2.4 on origin does not carry the bumped vgraph-mcp-node" +[ "$(git -C "$WORK/vgraph.git" diff --name-only main release/1.2.4)" = plugins.json ] \ + || fail "release/1.2.4 carries more than plugins.json: $(git -C "$WORK/vgraph.git" diff --name-only main release/1.2.4)" +git -C "$WORK/vgraph-mcp" diff --quiet -- package.json \ + && fail "vgraph-mcp's bump is not waiting uncommitted in its checkout" grep -q '^pr create.*release/1.2.4' "$GH_LOG" || fail "no PR opened for release/1.2.4: $(cat "$GH_LOG")" [ "$(git -C "$WORK" branch --show-current)" = main ] || fail "left VGraph on $(git -C "$WORK" branch --show-current)" [ -z "$(git -C "$WORK" status --porcelain)" ] || fail "left VGraph dirty: $(git -C "$WORK" status --porcelain)" @@ -125,7 +125,7 @@ printf '\0asm' > "$REAL/website/Package/VGraphWasm.wasm" cp "$REPO_ROOT/LICENSE" "$REPO_ROOT/NOTICE" "$REAL/" for spec in "obsidian-vithanco:manifest.json package.json versions.json scripts/set-version.mjs" \ "vscode-vithanco:package.json" \ - "vgraph-mcp-node:package.json server.json"; do + "vgraph-mcp:package.json server.json"; do p=${spec%%:*} [ -f "$REPO_ROOT/$p/release.sh" ] || { echo "· skipping $p: not cloned"; continue; } mkdir -p "$REAL/$p/scripts" diff --git a/scripts/publish-plugins.test.sh b/scripts/publish-plugins.test.sh index 5ccb999..8d47d5b 100755 --- a/scripts/publish-plugins.test.sh +++ b/scripts/publish-plugins.test.sh @@ -69,10 +69,12 @@ given_plugins_at() { # version, in a fresh directory WORK with pushed plugin rep git -C "$WORK/$p" add . && git -C "$WORK/$p" commit -qm "bump merged" git -C "$WORK/$p" push -q origin main done + git init -q -b main "$WORK/vgraph-mcp" + git -C "$WORK/vgraph-mcp" commit -q --allow-empty -m init # WORK stands in for VGraph itself: committed, and pushed to its main. mkdir -p "$WORK/Sources" && echo 'engine' > "$WORK/Sources/engine.swift" echo '{}' > "$WORK/plugins.json" - printf '%s\n' '*.git/' obsidian-vithanco/ vscode-vithanco/ website/Package/ out gh.log npx.log > "$WORK/.gitignore" + printf '%s\n' '*.git/' obsidian-vithanco/ vscode-vithanco/ vgraph-mcp/ website/Package/ out gh.log npx.log > "$WORK/.gitignore" git init -q --bare -b main "$WORK/vgraph.git" git -C "$WORK" init -q -b main git -C "$WORK" remote add origin "$WORK/vgraph.git" @@ -284,15 +286,15 @@ just --justfile "$REPO_ROOT/justfile" --working-directory "$WORK" _release-prefl && fail "the release preflight accepted a VGraph whose status could not be read" grep -q 'status' "$WORK/out" || fail "does not say the status could not be read: $(cat "$WORK/out")" -# Given VGraph with uncommitted changes, when the npm host, the website or Cloud -# Run is published on its own (finishing a half-done release), then it refuses: -# each ships the engine from this checkout. +# Given VGraph with uncommitted changes, when the website is published on its own +# (finishing a half-done release), then it refuses: it ships the engine from this +# checkout. vgraph-mcp's own justfile holds its publish recipes to the same check. given_plugins_at 1.2.3 echo 'change' > "$WORK/engine.swift" just --justfile "$REPO_ROOT/justfile" --working-directory "$WORK" _require-vgraph-main >"$WORK/out" 2>&1 \ && fail "_require-vgraph-main accepted an uncommitted VGraph" grep -q 'uncommitted' "$WORK/out" || fail "_require-vgraph-main does not say VGraph is uncommitted: $(cat "$WORK/out")" -for r in publish-mcp-node publish-website publish-cloud-run; do +for r in publish-website; do just --justfile "$REPO_ROOT/justfile" --show "$r" | grep -q "^$r[^:]*: _require-maintainer _require-vgraph-main" \ || fail "$r does not check VGraph before it builds: $(just --justfile "$REPO_ROOT/justfile" --show "$r" | grep "^$r")" done @@ -304,5 +306,13 @@ git -C "$WORK/vscode-vithanco" switch -qc some-pr just --justfile "$REPO_ROOT/justfile" --working-directory "$WORK" _require-vgraph-main >"$WORK/out" 2>&1 \ || fail "_require-vgraph-main refused over a plugin branch: $(cat "$WORK/out")" +# Given vgraph-mcp on another branch, when a release starts, then it refuses: +# publishing it tags and pushes whatever is checked out. +given_plugins_at 1.2.3 +git -C "$WORK/vgraph-mcp" switch -qc some-pr +just --justfile "$REPO_ROOT/justfile" --working-directory "$WORK" _release-preflight >"$WORK/out" 2>&1 \ + && fail "the release preflight accepted vgraph-mcp on a branch" +grep -q 'vgraph-mcp is on .some-pr.' "$WORK/out" || fail "does not name vgraph-mcp's branch: $(cat "$WORK/out")" + [ "$FAILED" -eq 0 ] && echo "✓ publish-plugins" exit "$FAILED" diff --git a/scripts/release-stamp.sh b/scripts/release-stamp.sh index f3b9df7..e214a52 100755 --- a/scripts/release-stamp.sh +++ b/scripts/release-stamp.sh @@ -4,8 +4,8 @@ # scripts/release-stamp.sh record # after release has built and checked everything # scripts/release-stamp.sh check # exit 0 when nothing that ships has changed since # -# The key is the content of VGraph and both plugin checkouts, uncommitted files -# included, not their commits: publish-plugins commits each plugin's bump after +# The key is the content of VGraph and every engine consumer's checkout, uncommitted files +# included, not their commits: publish-plugins and `just mcp publish` commit each bump after # the release, and that must not count as a change. set -euo pipefail @@ -13,7 +13,7 @@ STAMP=.build/release-passed key() { local dir idx - for dir in . obsidian-vithanco vscode-vithanco; do + for dir in . obsidian-vithanco vscode-vithanco vgraph-mcp; do idx=$(mktemp) # -p: git trusts an index entry's timestamps only against the index's # own mtime, so a fresh copy hides an edit made in the same second. diff --git a/scripts/release-stamp.test.sh b/scripts/release-stamp.test.sh index 0051b1b..2c2ceed 100755 --- a/scripts/release-stamp.test.sh +++ b/scripts/release-stamp.test.sh @@ -11,13 +11,13 @@ FAILED=0 fail() { echo "FAIL: $*" >&2; FAILED=1; } export GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@example.invalid GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@example.invalid -given_released() { # VGraph with both plugins, the plugins' bump uncommitted, stamp recorded +given_released() { # VGraph with every engine consumer, their bump uncommitted, stamp recorded WORK=$(mktemp -d "$ROOT/work.XXXXXX") || exit 1 git -C "$WORK" init -q -b main - printf '%s\n' .build/ obsidian-vithanco/ vscode-vithanco/ > "$WORK/.gitignore" + printf '%s\n' .build/ obsidian-vithanco/ vscode-vithanco/ vgraph-mcp/ > "$WORK/.gitignore" echo engine > "$WORK/engine.swift" git -C "$WORK" add . && git -C "$WORK" commit -qm engine - for p in obsidian-vithanco vscode-vithanco; do + for p in obsidian-vithanco vscode-vithanco vgraph-mcp; do git -C "$WORK" init -q -b main "$p" echo main.js > "$WORK/$p/.gitignore" echo '{"version":"1.0.0"}' > "$WORK/$p/package.json" @@ -39,7 +39,7 @@ stamp check && fail "holds with no release recorded" # Given the plugins' bump committed by publish-plugins, when resuming, then it still holds. given_released -for p in obsidian-vithanco vscode-vithanco; do git -C "$WORK/$p" commit -qam "chore: release 1.0.1"; done +for p in obsidian-vithanco vscode-vithanco vgraph-mcp; do git -C "$WORK/$p" commit -qam "chore: release 1.0.1"; done stamp check || fail "committing the released bump broke the stamp" # Given build output a release writes, when checking, then it still holds. @@ -57,6 +57,11 @@ given_released echo new > "$WORK/vscode-vithanco/extra.ts" stamp check && fail "holds after a plugin gained a file" +# Given an MCP server change, when checking, then it does not hold. +given_released +echo new > "$WORK/vgraph-mcp/Tool.swift" +stamp check && fail "holds after vgraph-mcp gained a file" + # Given a new VGraph commit, when checking, then it does not hold. given_released echo next > "$WORK/next.swift" && git -C "$WORK" add next.swift && git -C "$WORK" commit -qm next diff --git a/vgraph-mcp-node/.gitignore b/vgraph-mcp-node/.gitignore deleted file mode 100644 index e1f2563..0000000 --- a/vgraph-mcp-node/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Vendored build artefacts — `just mcp-node` repopulates them from the engine -# build. Not committed: the wasm alone is 4.1MB, and a copy in git is a copy -# that can disagree with the engine it was built from. -vendor/ -node_modules/ - -# npm pack output -*.tgz diff --git a/vgraph-mcp-node/LICENSE b/vgraph-mcp-node/LICENSE deleted file mode 100644 index 261eeb9..0000000 --- a/vgraph-mcp-node/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - 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/vgraph-mcp-node/NOTICE b/vgraph-mcp-node/NOTICE deleted file mode 100644 index d3b9613..0000000 --- a/vgraph-mcp-node/NOTICE +++ /dev/null @@ -1,59 +0,0 @@ -VGraph -Copyright 2024-2026 Klaus Kneupner, Vithanco - -This product includes software developed by Klaus Kneupner and contributors, -licensed under the Apache License, Version 2.0 (see LICENSE). - -The Vithanco name and logo are not licensed under Apache-2.0 and are not -granted by section 6 of it. The artwork is all rights reserved by Vithanco: the -files in graphics/, the mark's path data in -Sources/VGraphSVG/Utils/WatermarkRenderer.swift and in the `vithanco` icon of -Sources/VGraph/Domain/Icons/BuiltinIcons.swift, and its master copy in -docs/design/. Permitted use is described in graphics/README.md. - -It also includes, links or runs the following third-party works, each under -its own license. - -Graphviz — https://graphviz.org - Compiled into the layout engine through swiftGraphviz - (https://github.com/Vithanco/swiftGraphviz, EPL-2.0), currently Graphviz - 16.1.0. Graphviz is licensed under the Eclipse Public License 2.0; its source - is available from graphviz.org. - -DM Sans — https://github.com/googlefonts/dm-fonts - Copyright 2014 The DM Sans Project Authors. SIL Open Font License 1.1. - Bundled in fonts/; the license text is fonts/OFL.txt. - Its Bold outlines also form the letters in the `and`, `or` and `default` - icons (Sources/VGraph/Domain/Icons/BuiltinIcons.swift). - -librsvg — https://gitlab.gnome.org/GNOME/librsvg - LGPL-2.1-or-later. Installed from the distribution package (`librsvg2-bin`) - in the hosted server's container image and run as a separate process - (`rsvg-convert`) to turn SVG into PNG; it is not linked into VGraph. - -Swift runtime and Embedded Swift standard library — https://swift.org - Apache-2.0 with the Runtime Library Exception. Linked into every - VGraphWasm.wasm. - -@bjorn3/browser_wasi_shim — https://github.com/bjorn3/browser_wasi_shim - MIT or Apache-2.0. Runs the wasm module in browsers and Node. - -@resvg/resvg-wasm — https://github.com/yisibl/resvg-js - MPL-2.0. Turns SVG into PNG in the npm package. - -@modelcontextprotocol/sdk — https://github.com/modelcontextprotocol/typescript-sdk - MIT. MCP server in the npm package. - -Swift packages (Apache-2.0): swift-argument-parser, swift-atomics, -swift-collections, swift-log, swift-nio, swift-system, swift-syntax, -elementary, elementary-ui, carton, WasmTransformer. - -Swift packages (MIT): JavaScriptKit, eventsource. - -Model Context Protocol Swift SDK — https://github.com/modelcontextprotocol/swift-sdk - MIT for contributions made before the project's move to Apache-2.0, - Apache-2.0 afterwards; see its LICENSE. - -Source — https://github.com/Vithanco/VGraph - The engine is built from this repository; every package that embeds it - ships this NOTICE and the Apache-2.0 LICENSE. diff --git a/vgraph-mcp-node/README.md b/vgraph-mcp-node/README.md deleted file mode 100644 index ce2e9f9..0000000 --- a/vgraph-mcp-node/README.md +++ /dev/null @@ -1,80 +0,0 @@ -# @vithanco/vgraph-mcp - -The VGraph MCP server, running on your machine. - -Same tools and same engine as the hosted server at `mcp.vithanco.com` — the -difference is where the work happens. The engine is compiled to WebAssembly, so -a diagram is laid out and rendered locally, with no round trip and nothing to -pay for. - -```bash -npx @vithanco/vgraph-mcp -``` - -Claude Code, Claude Desktop, Cursor — anywhere an MCP server is configured by -command: - -```json -{ - "mcpServers": { - "vgraph": { "command": "npx", "args": ["-y", "@vithanco/vgraph-mcp"] } - } -} -``` - -The hosted server remains the better fit where there is no shell to run a -command in — claude.ai in the browser, ChatGPT connectors — and stays available: - -```json -{ "mcpServers": { "vgraph": { "url": "https://mcp.vithanco.com/mcp" } } } -``` - -## What is in here - -No graph logic. This is a host around the engine, the same way the Obsidian and -VS Code plugins are — they put the wasm behind a pane, this one puts it behind -a protocol on stdin. - -| file | what it does | -|---|---| -| `src/server.mjs` | MCP plumbing: list tools, dispatch, format the quality report | -| `src/render.mjs` | one render call per view: the report, then a picture per view | -| `src/wasm-host.mjs` | loads the wasm under WASI | -| `src/png.mjs` | rasterises the SVG | -| `tools.json` | tool definitions, generated from the Swift server | -| `vendor/` | the engine, its JS glue, and the fonts | - -`tools.json` is not written by hand. `scripts/dump-mcp-tools.sh` starts the -native `vgraph-mcp` binary and asks it, over MCP, what tools it offers — so the -VGL documentation the model reads has one source, in Swift, and a tool added -there appears here without anyone editing JavaScript. - -## Building it - -From the repository root: - -```bash -just mcp-node # build the wasm, vendor it with the fonts, refresh tools.json -just mcp-node-run # run it on stdio against the current build -``` - -`vendor/` is not committed. The wasm is 4.1MB, and a copy in git is a copy that -can disagree with the engine it was built from. - -## Two things that look like bugs and are not - -**The wasm writes to stderr.** It logs layout DEBUG lines to WASI stdout, and -under a stdio MCP server stdout carries JSON-RPC. `wasm-host.mjs` routes both -wasm fds to stderr; the noise is expected. What the hosted server logs is in -[`SECURITY.md`](../SECURITY.md); this local host is a separate implementation. - -**Fonts are bundled rather than read from the SVG.** The SVG carries an -`@import` for DM Sans, which browsers honour and rasterisers ignore — and resvg -ignores an embedded `@font-face` too. See `fonts/README.md` at the repository -root for why the faces are TTF and why there is one file per weight. - -## Licence and source - -Apache-2.0; see `LICENSE` and `NOTICE` (third-party components, including -Graphviz under EPL-2.0). The engine source is at -https://github.com/Vithanco/VGraph. diff --git a/vgraph-mcp-node/package-lock.json b/vgraph-mcp-node/package-lock.json deleted file mode 100644 index ba3c7c7..0000000 --- a/vgraph-mcp-node/package-lock.json +++ /dev/null @@ -1,2466 +0,0 @@ -{ - "name": "@vithanco/vgraph-mcp", - "version": "1.0.14", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "@vithanco/vgraph-mcp", - "version": "1.0.14", - "license": "Apache-2.0", - "dependencies": { - "@bjorn3/browser_wasi_shim": "^0.4.2", - "@modelcontextprotocol/sdk": "^1.0.0", - "@resvg/resvg-wasm": "^2.6.2" - }, - "bin": { - "vgraph-mcp": "src/server.mjs" - }, - "devDependencies": { - "vitest": "^5.1.0" - }, - "engines": { - "node": ">=20" - } - }, - "node_modules/@bjorn3/browser_wasi_shim": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/@bjorn3/browser_wasi_shim/-/browser_wasi_shim-0.4.2.tgz", - "integrity": "sha512-/iHkCVUG3VbcbmEHn5iIUpIrh7a7WPiwZ3sHy4HZKZzBdSadwdddYDZAII2zBvQYV0Lfi8naZngPCN7WPHI/hA==", - "license": "MIT OR Apache-2.0" - }, - "node_modules/@emnapi/core": { - "version": "2.0.0-beta.2", - "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-2.0.0-beta.2.tgz", - "integrity": "sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "@emnapi/wasi-threads": "2.2.0", - "tslib": "^2.4.0" - } - }, - "node_modules/@emnapi/runtime": { - "version": "2.0.0-beta.2", - "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-2.0.0-beta.2.tgz", - "integrity": "sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "tslib": "^2.4.0" - } - }, - "node_modules/@emnapi/wasi-threads": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-2.2.0.tgz", - "integrity": "sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "tslib": "^2.4.0" - } - }, - "node_modules/@hono/node-server": { - "version": "2.1.8", - "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.8.tgz", - "integrity": "sha512-jdf7FHh6A1lzjpHHQUgxsg2GeER2vMetnAOfeActzcoli6jamlK+NAwL6Dsr5Fl3BS3tYUQzCdtZjU8Qxv7bEA==", - "license": "MIT", - "engines": { - "node": ">=20" - }, - "peerDependencies": { - "hono": "^4 || ^5.0.0-0" - } - }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.3.tgz", - "integrity": "sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", - "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.31", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", - "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } - }, - "node_modules/@modelcontextprotocol/sdk": { - "version": "1.32.2", - "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.32.2.tgz", - "integrity": "sha512-SWsVtH/0vULSQStoZ6xxH2K09Li8fXYTMC64ZeogCdpZ3XSi1eCPOByV1OpuJxuI3OcmHhosDWYyii07tpPsLw==", - "license": "MIT", - "dependencies": { - "@hono/node-server": "^1.19.9 || ^2.0.5", - "ajv": "^8.17.1", - "ajv-formats": "^3.0.1", - "content-type": "^1.0.5", - "cors": "^2.8.5", - "cross-spawn": "^7.0.5", - "eventsource": "^3.0.2", - "eventsource-parser": "^3.0.0", - "express": "^5.2.1", - "express-rate-limit": "^8.2.1", - "hono": "^4.11.4", - "jose": "^6.1.3", - "json-schema-typed": "^8.0.2", - "pkce-challenge": "^5.0.0", - "raw-body": "^3.0.0", - "zod": "^3.25 || ^4.0", - "zod-to-json-schema": "^3.25.1" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "@cfworker/json-schema": "^4.1.1", - "zod": "^3.25 || ^4.0" - }, - "peerDependenciesMeta": { - "@cfworker/json-schema": { - "optional": true - }, - "zod": { - "optional": false - } - } - }, - "node_modules/@napi-rs/wasm-runtime": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.6.tgz", - "integrity": "sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "@tybys/wasm-util": "^0.10.3" - }, - "engines": { - "node": "^20.19.0 || ^22.13.0 || >=23.5.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/Brooooooklyn" - }, - "peerDependencies": { - "@emnapi/core": "^1.7.1 || 2.0.0-beta.2", - "@emnapi/runtime": "^1.7.1 || 2.0.0-beta.2" - } - }, - "node_modules/@oxc-project/types": { - "version": "0.156.0", - "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.156.0.tgz", - "integrity": "sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==", - "dev": true, - "license": "MIT", - "peer": true, - "funding": { - "url": "https://github.com/sponsors/oxc-project" - } - }, - "node_modules/@resvg/resvg-wasm": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/@resvg/resvg-wasm/-/resvg-wasm-2.6.2.tgz", - "integrity": "sha512-FqALmHI8D4o6lk/LRWDnhw95z5eO+eAa6ORjVg09YRR7BkcM6oPHU9uyC0gtQG5vpFLvgpeU4+zEAz2H8APHNw==", - "license": "MPL-2.0", - "engines": { - "node": ">= 10" - } - }, - "node_modules/@rolldown/binding-android-arm-eabi": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.19.tgz", - "integrity": "sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "peer": true, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-android-arm64": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.19.tgz", - "integrity": "sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "peer": true, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-darwin-arm64": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.19.tgz", - "integrity": "sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-darwin-x64": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.19.tgz", - "integrity": "sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-freebsd-x64": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.19.tgz", - "integrity": "sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "peer": true, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-linux-arm-gnueabihf": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.19.tgz", - "integrity": "sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-linux-arm64-gnu": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.19.tgz", - "integrity": "sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==", - "cpu": [ - "arm64" - ], - "dev": true, - "libc": [ - "glibc" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-linux-arm64-musl": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.19.tgz", - "integrity": "sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==", - "cpu": [ - "arm64" - ], - "dev": true, - "libc": [ - "musl" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-linux-ppc64-gnu": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.19.tgz", - "integrity": "sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==", - "cpu": [ - "ppc64" - ], - "dev": true, - "libc": [ - "glibc" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-linux-s390x-gnu": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.19.tgz", - "integrity": "sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==", - "cpu": [ - "s390x" - ], - "dev": true, - "libc": [ - "glibc" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-linux-x64-gnu": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.19.tgz", - "integrity": "sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==", - "cpu": [ - "x64" - ], - "dev": true, - "libc": [ - "glibc" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-linux-x64-musl": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.19.tgz", - "integrity": "sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==", - "cpu": [ - "x64" - ], - "dev": true, - "libc": [ - "musl" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-openharmony-arm64": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.19.tgz", - "integrity": "sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openharmony" - ], - "peer": true, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-wasm32-wasi": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.2.19.tgz", - "integrity": "sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==", - "cpu": [ - "wasm32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "@emnapi/core": "2.0.0-beta.2", - "@emnapi/runtime": "2.0.0-beta.2", - "@napi-rs/wasm-runtime": "1.2.6" - }, - "engines": { - "node": "^20.19.0 || ^22.13.0 || >=23.5.0" - } - }, - "node_modules/@rolldown/binding-win32-arm64-msvc": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.19.tgz", - "integrity": "sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-win32-x64-msvc": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.19.tgz", - "integrity": "sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/pluginutils": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.1.1.tgz", - "integrity": "sha512-glFIJDvLNDtJhT9qrMFWLPbvS+skxgt4L0K8Ei2YtnhPysAJnsI7nyxSJxKj4ADeKX0OLjC4ntRkwpLOoS3rwA==", - "dev": true, - "license": "MIT", - "peer": true - }, - "node_modules/@tybys/wasm-util": { - "version": "0.10.5", - "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.5.tgz", - "integrity": "sha512-dOGOPxlaNV+G046mZzN+9C0dAcQZeSKcXiVaM0TYy/LM4ttTmgSBDxYfovcYI8Em3+eAbiAYpvWLOv8+ZVRJKA==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "tslib": "^2.4.0" - } - }, - "node_modules/@types/chai": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", - "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/deep-eql": "*", - "assertion-error": "^2.0.1" - } - }, - "node_modules/@types/deep-eql": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", - "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/estree": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.10.tgz", - "integrity": "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==", - "dev": true, - "license": "MIT" - }, - "node_modules/@vitest/mocker": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.1.1.tgz", - "integrity": "sha512-b2OgTB4+3ImWIVafXKazJXwLKwQxUNnix6b3xUvUTMh7RyXlrtzoxfZr8aEz9zkHOMAS4K5lu3TvFWoiVeVTQg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/trace-mapping": "0.3.31", - "@vitest/spy": "5.1.1", - "estree-walker": "^3.0.3", - "magic-string": "^1.4.5" - }, - "funding": { - "url": "https://opencollective.com/vitest" - }, - "peerDependencies": { - "msw": "^2.4.9 || ^3.0.0", - "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" - }, - "peerDependenciesMeta": { - "msw": { - "optional": true - }, - "vite": { - "optional": true - } - } - }, - "node_modules/@vitest/spy": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.1.1.tgz", - "integrity": "sha512-6K8C6alQG1/Yc8/ZI22iJS7JEsxPdVzqtqDq+/xM4Z0mGVykemMVjLhqMy/q6/IHYG3kKD8hKSwRen/ZdyI9vQ==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/accepts": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", - "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", - "license": "MIT", - "dependencies": { - "mime-types": "^3.0.0", - "negotiator": "^1.0.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/ajv": { - "version": "8.20.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", - "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.3", - "fast-uri": "^3.0.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/ajv-formats": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", - "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", - "license": "MIT", - "dependencies": { - "ajv": "^8.0.0" - }, - "peerDependencies": { - "ajv": "^8.0.0" - }, - "peerDependenciesMeta": { - "ajv": { - "optional": true - } - } - }, - "node_modules/assertion-error": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", - "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - } - }, - "node_modules/body-parser": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.4.0.tgz", - "integrity": "sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==", - "license": "MIT", - "dependencies": { - "bytes": "^3.1.2", - "content-type": "^2.1.0", - "debug": "^4.4.3", - "http-errors": "^2.0.1", - "iconv-lite": "^0.7.3", - "on-finished": "^2.4.1", - "qs": "^6.16.1", - "raw-body": "^3.0.2", - "type-is": "^2.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/body-parser/node_modules/content-type": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", - "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/bytes": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", - "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/call-bind-apply-helpers": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", - "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/call-bound": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", - "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.2", - "get-intrinsic": "^1.3.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/chai": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-6.3.0.tgz", - "integrity": "sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "node_modules/content-disposition": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz", - "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/content-type": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", - "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/cookie": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", - "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/cookie-signature": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", - "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", - "license": "MIT", - "engines": { - "node": ">=6.6.0" - } - }, - "node_modules/cors": { - "version": "2.8.6", - "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz", - "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==", - "license": "MIT", - "dependencies": { - "object-assign": "^4", - "vary": "^1" - }, - "engines": { - "node": ">= 0.10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/cross-spawn": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", - "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", - "license": "MIT", - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/debug": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", - "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/detect-libc": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", - "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", - "dev": true, - "license": "Apache-2.0", - "peer": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/dunder-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", - "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.1", - "es-errors": "^1.3.0", - "gopd": "^1.2.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", - "license": "MIT" - }, - "node_modules/encodeurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", - "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/es-define-property": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", - "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-errors": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", - "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-module-lexer": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.2.tgz", - "integrity": "sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==", - "dev": true, - "license": "MIT" - }, - "node_modules/es-object-atoms": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", - "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", - "license": "MIT" - }, - "node_modules/estree-walker": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", - "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/estree": "^1.0.0" - } - }, - "node_modules/etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/eventsource": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz", - "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==", - "license": "MIT", - "dependencies": { - "eventsource-parser": "^3.0.1" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/eventsource-parser": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.1.1.tgz", - "integrity": "sha512-EKN1vKAMcZ8MlYMpaNuxN6R9yakzH6uajHcHVTqWJzvu5pWw9DyhbP35HH8MVBQ+dZjAfDxk+A8NiR9KWaXiyQ==", - "license": "MIT", - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/expect-type": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", - "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/express": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", - "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", - "license": "MIT", - "dependencies": { - "accepts": "^2.0.0", - "body-parser": "^2.2.1", - "content-disposition": "^1.0.0", - "content-type": "^1.0.5", - "cookie": "^0.7.1", - "cookie-signature": "^1.2.1", - "debug": "^4.4.0", - "depd": "^2.0.0", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "etag": "^1.8.1", - "finalhandler": "^2.1.0", - "fresh": "^2.0.0", - "http-errors": "^2.0.0", - "merge-descriptors": "^2.0.0", - "mime-types": "^3.0.0", - "on-finished": "^2.4.1", - "once": "^1.4.0", - "parseurl": "^1.3.3", - "proxy-addr": "^2.0.7", - "qs": "^6.14.0", - "range-parser": "^1.2.1", - "router": "^2.2.0", - "send": "^1.1.0", - "serve-static": "^2.2.0", - "statuses": "^2.0.1", - "type-is": "^2.0.1", - "vary": "^1.1.2" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/express-rate-limit": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.7.0.tgz", - "integrity": "sha512-hOwV7WOxXfjRpAM1DSJWZDXx3GhplwD8IfwuwvogD8i1Qnkgosw/H45s4ZnFAUHDAhPjlY9hLBvJhKmGMyY26g==", - "license": "MIT", - "dependencies": { - "debug": "^4.4.3", - "ip-address": "^10.2.0" - }, - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://github.com/sponsors/express-rate-limit" - }, - "peerDependencies": { - "express": ">= 4.11" - } - }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "license": "MIT" - }, - "node_modules/fast-uri": { - "version": "3.1.9", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz", - "integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fastify" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fastify" - } - ], - "license": "BSD-3-Clause" - }, - "node_modules/fdir": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", - "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.0.0" - }, - "peerDependencies": { - "picomatch": "^3 || ^4" - }, - "peerDependenciesMeta": { - "picomatch": { - "optional": true - } - } - }, - "node_modules/finalhandler": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", - "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", - "license": "MIT", - "dependencies": { - "debug": "^4.4.0", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "on-finished": "^2.4.1", - "parseurl": "^1.3.3", - "statuses": "^2.0.1" - }, - "engines": { - "node": ">= 18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/forwarded": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", - "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/fresh": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", - "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-intrinsic": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", - "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.2", - "es-define-property": "^1.0.1", - "es-errors": "^1.3.0", - "es-object-atoms": "^1.1.1", - "function-bind": "^1.1.2", - "get-proto": "^1.0.1", - "gopd": "^1.2.0", - "has-symbols": "^1.1.0", - "hasown": "^2.0.2", - "math-intrinsics": "^1.1.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", - "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", - "license": "MIT", - "dependencies": { - "dunder-proto": "^1.0.1", - "es-object-atoms": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/gopd": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", - "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-symbols": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", - "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/hasown": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", - "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", - "license": "MIT", - "dependencies": { - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/hono": { - "version": "4.13.18", - "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.18.tgz", - "integrity": "sha512-H9q/E1XizaWstJxUW881dmLxEj+t/TrGGnyxINkm4+sK0qUwsMtFdo2BWI9Vs3cIS19MU6b6iCijoUoEf4f3DA==", - "license": "MIT", - "engines": { - "node": ">=16.9.0" - } - }, - "node_modules/http-errors": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", - "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", - "license": "MIT", - "dependencies": { - "depd": "~2.0.0", - "inherits": "~2.0.4", - "setprototypeof": "~1.2.0", - "statuses": "~2.0.2", - "toidentifier": "~1.0.1" - }, - "engines": { - "node": ">= 0.8" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/iconv-lite": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", - "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==", - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "license": "ISC" - }, - "node_modules/ip-address": { - "version": "10.7.5", - "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.5.tgz", - "integrity": "sha512-t2v0rkILYv9WXmSL7TpAaU3HXgaFYOPUcH3QHgwQ++gpJuH3bqyMy4Fvt/DJCTKwzH3Cf+bAp5W/mFL39KPLzA==", - "license": "MIT", - "engines": { - "node": ">= 12" - } - }, - "node_modules/ipaddr.js": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", - "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", - "license": "MIT", - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/is-promise": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", - "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", - "license": "MIT" - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "license": "ISC" - }, - "node_modules/jose": { - "version": "6.2.12", - "resolved": "https://registry.npmjs.org/jose/-/jose-6.2.12.tgz", - "integrity": "sha512-9NiFmJEex0sy2Dk58j2UGBSHgUs2ypF9eZSu4L6vjOX3Dp96Sw1F3uL+H+D1sx02jZZdzUT0HgvCy59CuvXcWw==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/panva" - } - }, - "node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "license": "MIT" - }, - "node_modules/json-schema-typed": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/json-schema-typed/-/json-schema-typed-8.0.2.tgz", - "integrity": "sha512-fQhoXdcvc3V28x7C7BMs4P5+kNlgUURe2jmUT1T//oBRMDrqy1QPelJimwZGo7Hg9VPV3EQV5Bnq4hbFy2vetA==", - "license": "BSD-2-Clause" - }, - "node_modules/lightningcss": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz", - "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==", - "dev": true, - "license": "MPL-2.0", - "peer": true, - "dependencies": { - "detect-libc": "^2.0.3" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - }, - "optionalDependencies": { - "lightningcss-android-arm64": "1.33.0", - "lightningcss-darwin-arm64": "1.33.0", - "lightningcss-darwin-x64": "1.33.0", - "lightningcss-freebsd-x64": "1.33.0", - "lightningcss-linux-arm-gnueabihf": "1.33.0", - "lightningcss-linux-arm64-gnu": "1.33.0", - "lightningcss-linux-arm64-musl": "1.33.0", - "lightningcss-linux-x64-gnu": "1.33.0", - "lightningcss-linux-x64-musl": "1.33.0", - "lightningcss-win32-arm64-msvc": "1.33.0", - "lightningcss-win32-x64-msvc": "1.33.0" - } - }, - "node_modules/lightningcss-android-arm64": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz", - "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "android" - ], - "peer": true, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-darwin-arm64": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz", - "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-darwin-x64": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz", - "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-freebsd-x64": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz", - "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "freebsd" - ], - "peer": true, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-linux-arm-gnueabihf": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz", - "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-linux-arm64-gnu": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz", - "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==", - "cpu": [ - "arm64" - ], - "dev": true, - "libc": [ - "glibc" - ], - "license": "MPL-2.0", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-linux-arm64-musl": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz", - "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "libc": [ - "musl" - ], - "license": "MPL-2.0", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-linux-x64-gnu": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz", - "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==", - "cpu": [ - "x64" - ], - "dev": true, - "libc": [ - "glibc" - ], - "license": "MPL-2.0", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-linux-x64-musl": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz", - "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==", - "cpu": [ - "x64" - ], - "dev": true, - "libc": [ - "musl" - ], - "license": "MPL-2.0", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-win32-arm64-msvc": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz", - "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-win32-x64-msvc": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz", - "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/magic-string": { - "version": "1.4.5", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.5.tgz", - "integrity": "sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.6.0" - } - }, - "node_modules/math-intrinsics": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", - "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/media-typer": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.1.tgz", - "integrity": "sha512-yz3xRaG20c6/BOzvYoDaGtPmGscs7YivItZEEqe6GbwNfHuxu9YNmvnEkMzKldAGY4/80pRcQRZSEnhquk9XuQ==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/merge-descriptors": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", - "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mime-db": { - "version": "1.54.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", - "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", - "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", - "license": "MIT", - "dependencies": { - "mime-db": "^1.54.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" - }, - "node_modules/nanoid": { - "version": "3.3.20", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", - "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "peer": true, - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, - "node_modules/negotiator": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.1.0.tgz", - "integrity": "sha512-NMPBRMJgiQHjbd8phG3Vebdx4kZ1H121rbl5IkMqeOsahptB9BKo/d7oJ3zTXqTgagn2bWlNSXkh0QUGM31RYg==", - "license": "MIT", - "dependencies": { - "content-type": "^2.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/negotiator/node_modules/content-type": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", - "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-inspect": { - "version": "1.13.4", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", - "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/obug": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/obug/-/obug-3.0.0.tgz", - "integrity": "sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==", - "dev": true, - "funding": [ - "https://github.com/sponsors/sxzz", - "https://opencollective.com/debug" - ], - "license": "MIT", - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/on-finished": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", - "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", - "license": "MIT", - "dependencies": { - "ee-first": "1.1.1" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "license": "ISC", - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/path-to-regexp": { - "version": "8.4.2", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", - "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/picocolors": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", - "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", - "dev": true, - "license": "ISC", - "peer": true - }, - "node_modules/picomatch": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", - "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/pkce-challenge": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.1.tgz", - "integrity": "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ==", - "license": "MIT", - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/postcss": { - "version": "8.5.33", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.33.tgz", - "integrity": "sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/postcss" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "peer": true, - "dependencies": { - "nanoid": "^3.3.20", - "picocolors": "^1.1.1", - "source-map-js": "^1.2.2" - }, - "engines": { - "node": "^10 || ^12 || >=14" - } - }, - "node_modules/proxy-addr": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz", - "integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==", - "license": "MIT", - "dependencies": { - "forwarded": "0.2.0", - "ipaddr.js": "1.9.1" - }, - "engines": { - "node": ">= 0.10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/qs": { - "version": "6.16.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.1.tgz", - "integrity": "sha512-5Px6J7rfHBAGUhNQ3es4YzcOdBBw0SDcVtThJml4RdnKw4tKs2epA0kPZ+K8X+WiHktT93RHVcQ/3ym5aTCgtg==", - "license": "BSD-3-Clause", - "dependencies": { - "es-define-property": "^1.0.1", - "side-channel": "^1.1.1" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/range-parser": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.3.0.tgz", - "integrity": "sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/raw-body": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", - "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", - "license": "MIT", - "dependencies": { - "bytes": "~3.1.2", - "http-errors": "~2.0.1", - "iconv-lite": "~0.7.0", - "unpipe": "~1.0.0" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/rolldown": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.19.tgz", - "integrity": "sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@oxc-project/types": "=0.156.0", - "@rolldown/pluginutils": "^1.0.0" - }, - "bin": { - "rolldown": "bin/cli.mjs" - }, - "engines": { - "node": "^20.19.0 || >=22.12.0" - }, - "optionalDependencies": { - "@rolldown/binding-android-arm-eabi": "1.2.19", - "@rolldown/binding-android-arm64": "1.2.19", - "@rolldown/binding-darwin-arm64": "1.2.19", - "@rolldown/binding-darwin-x64": "1.2.19", - "@rolldown/binding-freebsd-x64": "1.2.19", - "@rolldown/binding-linux-arm-gnueabihf": "1.2.19", - "@rolldown/binding-linux-arm64-gnu": "1.2.19", - "@rolldown/binding-linux-arm64-musl": "1.2.19", - "@rolldown/binding-linux-ppc64-gnu": "1.2.19", - "@rolldown/binding-linux-s390x-gnu": "1.2.19", - "@rolldown/binding-linux-x64-gnu": "1.2.19", - "@rolldown/binding-linux-x64-musl": "1.2.19", - "@rolldown/binding-openharmony-arm64": "1.2.19", - "@rolldown/binding-wasm32-wasi": "1.2.19", - "@rolldown/binding-win32-arm64-msvc": "1.2.19", - "@rolldown/binding-win32-x64-msvc": "1.2.19" - } - }, - "node_modules/router": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", - "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", - "license": "MIT", - "dependencies": { - "debug": "^4.4.0", - "depd": "^2.0.0", - "is-promise": "^4.0.0", - "parseurl": "^1.3.3", - "path-to-regexp": "^8.0.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "license": "MIT" - }, - "node_modules/send": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", - "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", - "license": "MIT", - "dependencies": { - "debug": "^4.4.3", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "etag": "^1.8.1", - "fresh": "^2.0.0", - "http-errors": "^2.0.1", - "mime-types": "^3.0.2", - "ms": "^2.1.3", - "on-finished": "^2.4.1", - "range-parser": "^1.2.1", - "statuses": "^2.0.2" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/serve-static": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", - "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", - "license": "MIT", - "dependencies": { - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "parseurl": "^1.3.3", - "send": "^1.2.0" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/setprototypeof": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", - "license": "ISC" - }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "license": "MIT", - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/side-channel": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", - "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "object-inspect": "^1.13.4", - "side-channel-list": "^1.0.1", - "side-channel-map": "^1.0.1", - "side-channel-weakmap": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-list": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", - "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "object-inspect": "^1.13.4" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-map": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", - "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", - "license": "MIT", - "dependencies": { - "call-bound": "^1.0.2", - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.5", - "object-inspect": "^1.13.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-weakmap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", - "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", - "license": "MIT", - "dependencies": { - "call-bound": "^1.0.2", - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.5", - "object-inspect": "^1.13.3", - "side-channel-map": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/source-map-js": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", - "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", - "dev": true, - "license": "BSD-3-Clause", - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/statuses": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", - "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/std-env": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.3.0.tgz", - "integrity": "sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==", - "dev": true, - "license": "MIT" - }, - "node_modules/tinybench": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-6.2.3.tgz", - "integrity": "sha512-Al01C2JIBnO2CXCAPbpAl6sUiOZHeThGtHYNTa51JRw9PyWOCdr+9Ong05R4qg/Sk3+H645E8ov1h2c58ityNw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=20.0.0" - } - }, - "node_modules/tinyexec": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.1.tgz", - "integrity": "sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "node_modules/tinyglobby": { - "version": "0.2.17", - "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", - "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", - "dev": true, - "license": "MIT", - "dependencies": { - "fdir": "^6.5.0", - "picomatch": "^4.0.4" - }, - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/SuperchupuDev" - } - }, - "node_modules/toidentifier": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", - "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", - "license": "MIT", - "engines": { - "node": ">=0.6" - } - }, - "node_modules/tslib": { - "version": "2.9.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", - "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", - "dev": true, - "license": "0BSD", - "optional": true, - "peer": true - }, - "node_modules/type-is": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz", - "integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==", - "license": "MIT", - "dependencies": { - "content-type": "^2.0.0", - "media-typer": "^1.1.0", - "mime-types": "^3.0.0" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/type-is/node_modules/content-type": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", - "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/vite": { - "version": "8.3.8", - "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.8.tgz", - "integrity": "sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "lightningcss": "^1.33.0", - "picomatch": "^4.0.7", - "postcss": "^8.5.32", - "rolldown": "~1.2.18", - "tinyglobby": "^0.2.17" - }, - "bin": { - "vite": "bin/vite.js" - }, - "engines": { - "node": "^20.19.0 || >=22.12.0" - }, - "funding": { - "url": "https://github.com/vitejs/vite?sponsor=1" - }, - "optionalDependencies": { - "fsevents": "~2.3.3" - }, - "peerDependencies": { - "@types/node": "^20.19.0 || >=22.12.0", - "@vitejs/devtools": "^0.7.1 || ^0.8.0", - "esbuild": "^0.27.0 || ^0.28.0", - "jiti": ">=1.21.0", - "less": "^4.0.0", - "sass": "^1.70.0", - "sass-embedded": "^1.70.0", - "stylus": ">=0.54.8", - "sugarss": "^5.0.0", - "terser": "^5.16.0", - "tsx": "^4.8.1", - "yaml": "^2.4.2" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - }, - "@vitejs/devtools": { - "optional": true - }, - "esbuild": { - "optional": true - }, - "jiti": { - "optional": true - }, - "less": { - "optional": true - }, - "sass": { - "optional": true - }, - "sass-embedded": { - "optional": true - }, - "stylus": { - "optional": true - }, - "sugarss": { - "optional": true - }, - "terser": { - "optional": true - }, - "tsx": { - "optional": true - }, - "yaml": { - "optional": true - } - } - }, - "node_modules/vitest": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.1.1.tgz", - "integrity": "sha512-trVmzUFOSraCZcI3uZIMD5FqBh4atFkC/XuJP/IU7qtyQay0FCs3Ia+0QiQ2JJwGyWG/xrcBoJNel2+O7kEZ0g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/chai": "^5.2.2", - "@vitest/mocker": "5.1.1", - "chai": "^6.3.0", - "es-module-lexer": "^2.3.2", - "expect-type": "^1.4.0", - "magic-string": "^1.4.5", - "obug": "^3.0.0", - "picomatch": "^4.0.7", - "std-env": "^4.3.0", - "tinybench": "^6.2.3", - "tinyexec": "^1.3.1", - "tinyglobby": "^0.2.17", - "why-is-node-running": "3.2.1" - }, - "bin": { - "vitest": "vitest.mjs" - }, - "engines": { - "node": "^22.12.0 || ^24.0.0 || >=26.0.0" - }, - "funding": { - "url": "https://opencollective.com/vitest" - }, - "peerDependencies": { - "@edge-runtime/vm": "*", - "@opentelemetry/api": "^1.9.0", - "@types/node": "^22.0.0 || >=24.0.0", - "@vitest/browser-playwright": "5.1.1", - "@vitest/browser-preview": "5.1.1", - "@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0", - "@vitest/coverage-istanbul": "5.1.1", - "@vitest/coverage-v8": "5.1.1", - "@vitest/ui": "5.1.1", - "happy-dom": "*", - "jsdom": "*", - "vite": "^6.4.0 || ^7.0.0 || ^8.0.0" - }, - "peerDependenciesMeta": { - "@edge-runtime/vm": { - "optional": true - }, - "@opentelemetry/api": { - "optional": true - }, - "@types/node": { - "optional": true - }, - "@vitest/browser-playwright": { - "optional": true - }, - "@vitest/browser-preview": { - "optional": true - }, - "@vitest/browser-webdriverio": { - "optional": true - }, - "@vitest/coverage-istanbul": { - "optional": true - }, - "@vitest/coverage-v8": { - "optional": true - }, - "@vitest/ui": { - "optional": true - }, - "happy-dom": { - "optional": true - }, - "jsdom": { - "optional": true - }, - "vite": { - "optional": false - } - } - }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "license": "ISC", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/why-is-node-running": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-3.2.1.tgz", - "integrity": "sha512-Tb2FUhB4vUsGQlfSquQLYkApkuPAFQXGFzxWKHHumVz2dK+X1RUm/HnID4+TfIGYJ1kTcwOaCk/buYCEJr6YjQ==", - "dev": true, - "license": "MIT", - "bin": { - "why-is-node-running": "cli.js" - }, - "engines": { - "node": ">=20.11" - } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "license": "ISC" - }, - "node_modules/zod": { - "version": "4.6.7", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", - "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, - "node_modules/zod-to-json-schema": { - "version": "3.25.2", - "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.2.tgz", - "integrity": "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==", - "license": "ISC", - "peerDependencies": { - "zod": "^3.25.28 || ^4" - } - } - } -} diff --git a/vgraph-mcp-node/package.json b/vgraph-mcp-node/package.json deleted file mode 100644 index a29504e..0000000 --- a/vgraph-mcp-node/package.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "@vithanco/vgraph-mcp", - "version": "1.0.15", - "mcpName": "com.vithanco/vgraph-mcp", - "description": "Concept Maps, IBIS, Causal Loop Diagrams and Timelines as images. Runs locally via WebAssembly.", - "type": "module", - "license": "Apache-2.0", - "author": "Klaus Kneupner <klaus@vithanco.com>", - "homepage": "https://vithanco.com", - "repository": { - "type": "git", - "url": "git+https://github.com/Vithanco/VGraph.git", - "directory": "vgraph-mcp-node" - }, - "bugs": { - "url": "https://github.com/Vithanco/VGraph/issues" - }, - "keywords": [ - "mcp", - "modelcontextprotocol", - "diagram", - "concept-map", - "ibis", - "causal-loop-diagram", - "timeline", - "graphviz", - "webassembly", - "vgl" - ], - "bin": { - "vgraph-mcp": "src/server.mjs" - }, - "files": [ - "LICENSE", - "NOTICE", - "README.md", - "src", - "tools.json", - "vendor" - ], - "engines": { - "node": ">=20" - }, - "dependencies": { - "@bjorn3/browser_wasi_shim": "^0.4.2", - "@modelcontextprotocol/sdk": "^1.0.0", - "@resvg/resvg-wasm": "^2.6.2" - }, - "devDependencies": { - "vitest": "^5.1.0" - }, - "scripts": { - "test": "vitest run" - } -} diff --git a/vgraph-mcp-node/release.sh b/vgraph-mcp-node/release.sh deleted file mode 100755 index 3fe2f3a..0000000 --- a/vgraph-mcp-node/release.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash -# Bump the Node MCP host's version and refresh its vendored engine. -# Does NOT commit, tag, push, or publish — same rationale as the plugins': -# the bump folds into whatever commit makes sense. -# -# Usage: -# ./release.sh # auto patch bump -# ./release.sh --minor -# ./release.sh --major -# ./release.sh <version> # explicit version -# ./release.sh --bump-only [..] # write the version only, vendor nothing -# VGRAPH_REPO=/path/to/VGraph ./release.sh [args] -# -# Called by ../release-plugins.sh, which drives every consumer in plugins.json -# so all three hosts of the engine carry the same number. That is the point of -# the number here: it says which engine build you are running, and a bug report -# quoting it identifies the same thing whether it came from Obsidian, VS Code -# or npm. -# -# The version lives in two files — package.json and server.json, the latter -# twice — and `just publish-mcp-node` refuses to publish if they disagree. - -set -euo pipefail - -SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) -cd "$SCRIPT_DIR" - -CURRENT=$(node -p "require('./package.json').version") - -# --bump-only writes the version and stops: VGraph's `just plugins-release` -# bumps every consumer, and `just release` builds what ships. -ARG="" -BUMP_ONLY=0 -for a in "$@"; do - case "$a" in - --bump-only) BUMP_ONLY=1 ;; - *) ARG="$a" ;; - esac -done -case "$ARG" in - ""|--patch) BUMP=patch ;; - --minor) BUMP=minor ;; - --major) BUMP=major ;; - v*) - echo "Error: version must not start with 'v' (use 1.0.9, not v1.0.9)" - exit 1 - ;; - *) - if ! [[ "$ARG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Error: version must be semver (e.g. 1.0.9) or one of --patch/--minor/--major, got '$ARG'" - exit 1 - fi - BUMP="" - ;; -esac - -if [ -n "$BUMP" ]; then - NEW=$(node -p " - const [a,b,c] = '$CURRENT'.split('.').map(Number); - ({patch:[a,b,c+1], minor:[a,b+1,0], major:[a+1,0,0]})['$BUMP'].join('.') - ") -else - NEW="$ARG" -fi - -echo " $CURRENT → $NEW" - -node -e " -const fs = require('fs'); -for (const [file, apply] of [ - ['package.json', (j) => { j.version = '$NEW'; }], - ['server.json', (j) => { j.version = '$NEW'; j.packages[0].version = '$NEW'; }], -]) { - const j = JSON.parse(fs.readFileSync(file, 'utf8')); - apply(j); - fs.writeFileSync(file, JSON.stringify(j, null, 2) + '\n'); -} -" - -# The engine inside vendor/ is Apache-2.0: its LICENSE and NOTICE travel with it. -cp "$SCRIPT_DIR/../LICENSE" LICENSE -cp "$SCRIPT_DIR/../NOTICE" NOTICE - -if [ "$BUMP_ONLY" -eq 1 ]; then - echo "✓ Bumped to $NEW (nothing vendored)." - exit 0 -fi - -# Refresh the vendored engine from an already-built monorepo, the way the -# plugins re-copy VGraphWasm.wasm. A copy, not a build: building is `just -# mcp-node`, and a release script that silently spends three minutes compiling -# is a release script people stop running. -VGRAPH_REPO="${VGRAPH_REPO:-$(cd "$SCRIPT_DIR/.." && pwd)}" -if [ -d "$VGRAPH_REPO/website/Package" ] && [ -d "$VGRAPH_REPO/fonts" ]; then - rm -rf vendor - mkdir -p vendor - cp -R "$VGRAPH_REPO/website/Package" vendor/Package - cp -R "$VGRAPH_REPO/fonts" vendor/fonts - WASM_BYTES=$(wc -c < vendor/Package/VGraphWasm.wasm) - if [ "$WASM_BYTES" -gt 20000000 ]; then - echo " WARN: vendored engine is $WASM_BYTES bytes — that is a debug build." - echo " Run 'just mcp-node' before publishing." - fi - echo " vendored engine refreshed ($(du -sh vendor | cut -f1))" -else - echo " WARN: $VGRAPH_REPO/website/Package or /fonts missing — vendor/ not refreshed." -fi - -echo "" -echo "✓ Bumped to $NEW. Publish with: just publish-mcp-node" diff --git a/vgraph-mcp-node/server.json b/vgraph-mcp-node/server.json deleted file mode 100644 index 2b686b3..0000000 --- a/vgraph-mcp-node/server.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json", - "name": "com.vithanco/vgraph-mcp", - "description": "Concept Maps, IBIS, Causal Loop Diagrams and Timelines as images. Runs locally via WebAssembly.", - "repository": { - "url": "https://github.com/Vithanco/VGraph", - "source": "github" - }, - "version": "1.0.15", - "websiteUrl": "https://vithanco.com", - "packages": [ - { - "registryType": "npm", - "identifier": "@vithanco/vgraph-mcp", - "version": "1.0.15", - "transport": { - "type": "stdio" - } - } - ], - "remotes": [ - { - "type": "streamable-http", - "url": "https://mcp.vithanco.com/mcp" - } - ] -} diff --git a/vgraph-mcp-node/src/png.mjs b/vgraph-mcp-node/src/png.mjs deleted file mode 100644 index 177e0c1..0000000 --- a/vgraph-mcp-node/src/png.mjs +++ /dev/null @@ -1,62 +0,0 @@ -// SVG -> PNG via resvg compiled to wasm: keeps the "no native dependency" -// property that makes the npx story work. -// -// Fonts are bundled, not scavenged from the host and not read from the SVG: -// -// - resvg has no filesystem, so `loadSystemFonts` finds nothing. Whatever the -// host happens to have installed is irrelevant. -// - resvg also ignores an `@font-face` embedded in the SVG. Verified: the same -// SVG with a base64 DM Sans inlined and with no font information at all -// produce byte-identical output, with no text drawn. The `@import` the SVG -// carries for browsers does nothing here. -// -// So every face has to arrive as a buffer, and as TTF: -// -// - resvg-wasm panics ("unreachable") on DM Sans italic as woff2 — including -// Google's own unmodified file. The same face as TTF is fine. -// - resvg ignores a variable font's weight axis: one variable file renders -// 400, 500, 600 and 700 identically. Static instances per weight are the -// only way to get the weights the SVG asks for. -// -// DM Sans is SIL Open Font License; OFL.txt ships beside these files. -import { readFile, readdir } from 'node:fs/promises'; -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { createRequire } from 'node:module'; -import { initWasm, Resvg } from '@resvg/resvg-wasm'; - -const require = createRequire(import.meta.url); -const FONT_DIR = path.join(path.dirname(path.dirname(fileURLToPath(import.meta.url))), 'vendor', 'fonts'); - -let ready = null; -let fontBuffers = []; - -export async function initPng() { - if (ready) return ready; - ready = (async () => { - await initWasm(await readFile(require.resolve('@resvg/resvg-wasm/index_bg.wasm'))); - const files = (await readdir(FONT_DIR)).filter((f) => f.endsWith('.ttf')).sort(); - fontBuffers = await Promise.all(files.map((f) => readFile(path.join(FONT_DIR, f)))); - console.error(`[png] ${files.length} bundled face(s): ${files.join(', ')}`); - })(); - return ready; -} - -function render(svg, dpi) { - return new Resvg(svg, { - dpi, - font: { fontBuffers, defaultFontFamily: 'DM Sans', loadSystemFonts: false }, - }).render(); -} - -export async function svgToPng(svg, { dpi = 144 } = {}) { - await initPng(); - return Buffer.from(render(svg, dpi).asPng()); -} - -// RGBA, row by row. Tests read pixels from here rather than decoding the PNG. -export async function svgToPixels(svg, { dpi = 144 } = {}) { - await initPng(); - const image = render(svg, dpi); - return { width: image.width, height: image.height, pixels: image.pixels }; -} diff --git a/vgraph-mcp-node/src/render.mjs b/vgraph-mcp-node/src/render.mjs deleted file mode 100644 index c9142b8..0000000 --- a/vgraph-mcp-node/src/render.mjs +++ /dev/null @@ -1,66 +0,0 @@ -// Text and pictures for a document: the report once, then the default view and -// each declared view in document order. A document without views is the report -// and one uncaptioned picture, as it always was. The host takes the views from -// the engine and calls it once per view; no graph logic lives here. -export function makeRenderDiagram(api, svgToPng) { - const err = (text) => ({ isError: true, content: [{ type: 'text', text }] }); - - return async function renderDiagram({ vgl }) { - if (typeof vgl !== 'string') return err("Error: 'vgl' parameter is required."); - - let views; - let renderings; - try { - views = JSON.parse(api.listViews(vgl)); - if (views.error) return err(`Error rendering: ${views.error}`); - const shown = views.length - ? [{ caption: 'default', view: '' }, ...views.map((v) => ({ - caption: v.label ? `${v.name}: ${v.label}` : v.name, - view: v.name, - }))] - : [{ caption: null, view: '' }]; - renderings = shown.map(({ caption, view }) => ({ - caption, - parsed: JSON.parse(api.renderGraphWithQuality(vgl, view)), - })); - } catch (e) { - return err(`Error rendering: ${e}`); - } - const failed = renderings.find((r) => r.parsed.error); - if (failed) return err(`Error rendering: ${failed.parsed.error}`); - - const content = []; - // Findings are the model's, so every view carries the same report. - const quality = formatQuality(renderings[0].parsed.quality); - if (quality) content.push({ type: 'text', text: quality }); - - try { - for (const { caption, parsed } of renderings) { - const png = await svgToPng(parsed.svg); - if (caption) content.push({ type: 'text', text: caption }); - content.push({ type: 'image', data: png.toString('base64'), mimeType: 'image/png' }); - } - } catch (e) { - return err(`Error rasterising to PNG: ${e}`); - } - return { isError: false, content }; - }; -} - -// Mirrors QualityReport.formatted() in Swift — same sections, same order, so a -// user switching between this and the hosted server reads the same report. -function formatQuality(messages = []) { - const lines = []; - const section = (title, severity) => { - const items = messages.filter((m) => m.severity === severity); - if (!items.length) return; - if (lines.length) lines.push(''); - lines.push(title); - for (const m of items) lines.push(`- ${m.message}`); - }; - section('Quality metrics:', 'info'); - section('Warnings:', 'warning'); - section('Errors:', 'error'); - return lines.length ? lines.join('\n') : null; -} - diff --git a/vgraph-mcp-node/src/server.mjs b/vgraph-mcp-node/src/server.mjs deleted file mode 100644 index 60538fa..0000000 --- a/vgraph-mcp-node/src/server.mjs +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env node -// The VGraph MCP server, hosted locally around the WebAssembly engine. -// -// Same tools as the deployed `vgraph-mcp-http`, same engine — this one runs it -// on the caller's machine instead of over the network. It is a host, not a -// port: no graph logic lives here. That is the same relationship the Obsidian -// and VS Code plugins have with the wasm, with a protocol on stdin where they -// have a pane. -// -// Tool definitions are not duplicated either. tools.json is dumped from the -// native `vgraph-mcp` binary by scripts/dump-mcp-tools.sh, so the ~20KB of VGL -// documentation the model reads has exactly one source, in Swift. -import { readFile } from 'node:fs/promises'; -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { Server } from '@modelcontextprotocol/sdk/server/index.js'; -import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; -import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js'; -import { loadVGraph } from './wasm-host.mjs'; -import { svgToPng, initPng } from './png.mjs'; -import { makeRenderDiagram } from './render.mjs'; - -const ROOT = path.dirname(path.dirname(fileURLToPath(import.meta.url))); -// VGRAPH_WASM_DIR points at website/Package for a working copy that has not -// been vendored yet; the published package always has vendor/Package. -const PKG_DIR = process.env.VGRAPH_WASM_DIR ?? path.join(ROOT, 'vendor', 'Package'); - -const tools = JSON.parse(await readFile(path.join(ROOT, 'tools.json'), 'utf8')); - -// Eager: a cold first tool call is the latency a user actually feels, and both -// of these are tens of milliseconds. -const started = performance.now(); -const [api] = await Promise.all([loadVGraph(PKG_DIR), initPng()]); -console.error(`[vgraph-mcp] ready in ${(performance.now() - started).toFixed(0)}ms`); - -const server = new Server( - { name: 'vgraph', version: '1.0.0-local' }, - { capabilities: { tools: { listChanged: false } } }, -); - -const err = (text) => ({ isError: true, content: [{ type: 'text', text }] }); -const renderDiagram = makeRenderDiagram(api, svgToPng); - -server.setRequestHandler(ListToolsRequestSchema, async () => ({ - tools: tools.map(({ name, description, inputSchema }) => ({ name, description, inputSchema })), -})); - -server.setRequestHandler(CallToolRequestSchema, async (req) => { - const tool = tools.find((t) => t.name === req.params.name); - if (!tool) return err(`Unknown tool: ${req.params.name}`); - - const args = req.params.arguments ?? {}; - const began = performance.now(); - const result = tool.name === 'describe_notation' - ? describeNotation(args) - : await renderDiagram(args); - console.error(`[vgraph-mcp] ${tool.name} in ${(performance.now() - began).toFixed(0)}ms`); - return result; -}); - -// Text, not an image: the self-description of a notation. -function describeNotation({ notation }) { - if (typeof notation !== 'string') return err("Error: 'notation' parameter is required."); - const markdown = api.describeNotation(notation); - // The engine reports its own failures in-band, the same way renderGraph does. - if (markdown.startsWith('Error')) return err(markdown); - return { isError: false, content: [{ type: 'text', text: markdown }] }; -} - -await server.connect(new StdioServerTransport()); diff --git a/vgraph-mcp-node/src/wasm-host.mjs b/vgraph-mcp-node/src/wasm-host.mjs deleted file mode 100644 index a64a11b..0000000 --- a/vgraph-mcp-node/src/wasm-host.mjs +++ /dev/null @@ -1,32 +0,0 @@ -// Loads VGraphWasm under Node/WASI. -// -// Differs from the generated platforms/node.js in one way that matters for MCP: -// the wasm writes DEBUG/Warning lines to WASI stdout (fd 1), and the generated -// setup pipes those to console.log. Under a stdio MCP server stdout carries -// JSON-RPC, so both fds go to stderr here. -import { readFile } from 'node:fs/promises'; -import path from 'node:path'; -import { WASI, File, OpenFile, ConsoleStdout, PreopenDirectory } from '@bjorn3/browser_wasi_shim'; - -export async function loadVGraph(pkgDir) { - const { instantiate, MODULE_PATH } = await import(path.join(pkgDir, 'instantiate.js')); - - const wasi = new WASI([MODULE_PATH], [], [ - new OpenFile(new File([])), - ConsoleStdout.lineBuffered((l) => console.error('[wasm]', l)), - ConsoleStdout.lineBuffered((l) => console.error('[wasm]', l)), - new PreopenDirectory('/', new Map()), - ], { debug: false }); - - const module = await WebAssembly.compile(await readFile(path.join(pkgDir, MODULE_PATH))); - - const { exports } = await instantiate({ - module, - getImports: () => ({}), - wasi: Object.assign(wasi, { setInstance(i) { wasi.inst = i; } }), - addToCoreImports(importObject) { - importObject['wasi_snapshot_preview1']['proc_exit'] = (code) => process.exit(code); - }, - }); - return exports; -} diff --git a/vgraph-mcp-node/test/png.test.mjs b/vgraph-mcp-node/test/png.test.mjs deleted file mode 100644 index 94ef6cb..0000000 --- a/vgraph-mcp-node/test/png.test.mjs +++ /dev/null @@ -1,62 +0,0 @@ -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { describe, test, expect, beforeAll } from 'vitest'; -import { loadVGraph } from '../src/wasm-host.mjs'; -import { svgToPixels } from '../src/png.mjs'; - -// The real engine draws the diagram and the real PNG path renders it. Both come -// from vendor/Package, so these fail until `release.sh` has vendored a build -// that draws icons. -const PKG_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'vendor', 'Package'); - -let api; -beforeAll(async () => { - api = await loadVGraph(PKG_DIR); -}); - -const question = 'vgraph g: IBIS "T" {\n node q1: Question "Why?";\n}'; -const incorrectEquals = `vgraph a: Arithmetic "A" { - node three: Number "3"; node four: Number "4"; node op: Times; node eq: Equals "11"; - edge three -> op: times_first_operand; - edge four -> op: times_second_operand; - edge op -> eq: times_result; -}`; - -const withoutIcons = (svg) => svg.replace(/<use\b[^>]*href="#icon-[^"]*"[^>]*\/>/g, ''); - -// Icons are drawn white on the badge's coloured circle; nothing else in a light -// rendering of these diagrams is opaque white. -const opaqueWhite = ({ pixels }) => { - let count = 0; - for (let i = 0; i < pixels.length; i += 4) { - if (pixels[i] === 255 && pixels[i + 1] === 255 && pixels[i + 2] === 255 && pixels[i + 3] === 255) count++; - } - return count; -}; - -const differing = (a, b) => { - let count = 0; - for (let i = 0; i < a.pixels.length; i += 4) { - if (a.pixels[i] !== b.pixels[i] || a.pixels[i + 1] !== b.pixels[i + 1] || a.pixels[i + 2] !== b.pixels[i + 2]) count++; - } - return count; -}; - -describe('icons in the PNG path', () => { - test('Given a node type badge rendered to PNG, when its icon area is read, then it holds icon-coloured pixels', async () => { - const svg = api.renderGraph(question); - expect(opaqueWhite(await svgToPixels(svg))).toBeGreaterThan(5); - expect(differing(await svgToPixels(svg), await svgToPixels(withoutIcons(svg)))).toBeGreaterThan(20); - }); - - test('Given an incorrect equals node rendered to PNG, when its centre is read, then it holds icon-coloured pixels', async () => { - const svg = api.renderGraph(incorrectEquals); - expect(svg).not.toContain('≠'); - expect(differing(await svgToPixels(svg), await svgToPixels(withoutIcons(svg)))).toBeGreaterThan(20); - }); - - test('Given the same badge with its icon left out, when rendered to PNG, then the icon area holds no icon-coloured pixels', async () => { - const svg = withoutIcons(api.renderGraph(question)); - expect(opaqueWhite(await svgToPixels(svg))).toBe(0); - }); -}); diff --git a/vgraph-mcp-node/test/render.test.mjs b/vgraph-mcp-node/test/render.test.mjs deleted file mode 100644 index 93f4eca..0000000 --- a/vgraph-mcp-node/test/render.test.mjs +++ /dev/null @@ -1,50 +0,0 @@ -import { describe, test, expect } from 'vitest'; -import { makeRenderDiagram } from '../src/render.mjs'; - -// The engine is faked: what is under test is how the host assembles what the -// engine returns, not the engine (the wasm smoke tests cover that). -const fakeApi = (views) => ({ - listViews: () => JSON.stringify(views), - renderGraphWithQuality: (_vgl, view) => - JSON.stringify({ - svg: `svg:${view}`, - quality: [{ severity: 'warning', message: 'Too long' }], - }), -}); -const fakePng = async (svg) => Buffer.from(svg); - -const kinds = (result) => - result.content.map((c) => (c.type === 'image' ? `image:${Buffer.from(c.data, 'base64')}` : c.text)); - -describe('renderDiagram', () => { - test('two views: one report, then default and each view as a captioned picture', async () => { - const render = makeRenderDiagram( - fakeApi([{ name: 'a', label: 'Alpha' }, { name: 'b', label: 'Beta' }]), - fakePng, - ); - const result = await render({ vgl: 'x' }); - expect(result.isError).toBe(false); - expect(kinds(result)).toEqual([ - 'Warnings:\n- Too long', - 'default', 'image:svg:', - 'a: Alpha', 'image:svg:a', - 'b: Beta', 'image:svg:b', - ]); - }); - - test('no views: the report and one uncaptioned picture, as before', async () => { - const render = makeRenderDiagram(fakeApi([]), fakePng); - expect(kinds(await render({ vgl: 'x' }))).toEqual(['Warnings:\n- Too long', 'image:svg:']); - }); - - test('a view without a label is captioned by its name', async () => { - const render = makeRenderDiagram(fakeApi([{ name: 'a' }]), fakePng); - expect(kinds(await render({ vgl: 'x' })).slice(1, 2)).toEqual(['default']); - expect(kinds(await render({ vgl: 'x' }))[3]).toBe('a'); - }); - - test('the input is still just vgl', async () => { - const render = makeRenderDiagram(fakeApi([]), fakePng); - expect((await render({})).isError).toBe(true); - }); -}); diff --git a/vgraph-mcp-node/tools.json b/vgraph-mcp-node/tools.json deleted file mode 100644 index a3067e3..0000000 --- a/vgraph-mcp-node/tools.json +++ /dev/null @@ -1,127 +0,0 @@ -[ - { - "description": "Create a CLD diagram as PNG image. A Causal Loop Diagram (CLD) is a Systems Thinking tool that maps feedback loops between variables, showing how a change in one variable causes changes in others. It reveals reinforcing dynamics (exponential growth or decline) and balancing dynamics (stabilisation toward equilibrium).\n\nYou provide VGL (Vithanco Graph Language) code using the CLD notation and the tool renders it to an PNG image.\n\n## Core Concepts\n\nA CLD consists of **variables** (called Stocks) connected by **causal links** with polarity:\n\n- **same** (`s`): when A increases, B increases; when A decreases, B decreases. Drawn as a solid arrow.\n- **opposite** (`o`): when A increases, B decreases; when A decreases, B increases. Drawn as a dashed arrow.\n\nA **feedback loop** is a closed chain of causal links returning to the starting variable:\n\n- **Reinforcing loop (R)**: even number of `opposite` edges (including zero). Drives exponential growth or decline \u2014 a snowball effect.\n- **Balancing loop (B)**: odd number of `opposite` edges. Drives the system toward equilibrium \u2014 a thermostat effect.\n\n## How to Build a CLD\n\n1. Identify the key variables (stocks) in the system \u2014 things whose value can increase or decrease.\n2. For each pair of causally related variables, determine the polarity: does an increase in A cause B to increase (same) or decrease (opposite)?\n3. Trace closed loops and classify them as reinforcing or balancing using the counting rule.\n4. Give the diagram a title that frames the system boundary.\n\n## VGL Syntax\n\n```\nvgraph <id>: CLD \"<title>\" {\n <nodes and edges>\n}\n```\n\n### Node Types\n\n- `Stock` \u2014 A quantity or state in the system. Stock values change over time based on incoming causal links.\n\n```\nnode <id>: Stock \"<label>\"\n```\n\n### Edges\n\n- `same` \u2014 Positive causal link \u2014 both stocks change in the same direction. If the source increases, the target increases too. Marked with '+'.\n- `opposite` \u2014 Negative causal link \u2014 the stocks change in opposite directions. If the source increases, the target decreases. Marked with '\u2212'.\n\nCRITICAL: You MUST specify the edge type (`: same` or `: opposite`) on every edge. Both edge types connect Stock to Stock, so the type CANNOT be inferred \u2014 omitting it will cause an error.\n\n```\nedge <from_id> -> <to_id>: same\nedge <from_id> -> <to_id>: opposite\n```\n\n## Identifying Feedback Loops\n\nTo classify a loop, trace a closed path back to the starting variable and count the `opposite` edges:\n\n- **0 opposite edges** \u2192 Reinforcing (R): Population \u2192 Birth Rate \u2192 Population (more people \u2192 more births \u2192 even more people)\n- **1 opposite edge** \u2192 Balancing (B): Population \u2192 Death Rate \u2192 Population (more people \u2192 more deaths \u2192 fewer people)\n\nRule: even count = reinforcing, odd count = balancing.\n\n## Complete Example\n\n```\nvgraph populationCLD: CLD \"Population Dynamics\" {\n node population: Stock \"Population\"\n node births: Stock \"Birth Rate\"\n node deaths: Stock \"Death Rate\"\n node resources: Stock \"Available Resources\"\n\n edge population -> births: same\n edge births -> population: same\n edge population -> deaths: same\n edge deaths -> population: opposite\n edge population -> resources: opposite\n edge resources -> births: same\n}\n```\n\n**Loop analysis:**\n- **R1 (Reinforcing):** Population \u2192 Birth Rate \u2192 Population \u2014 0 opposite edges. More people produce more births, which increases population. Growth spiral.\n- **B1 (Balancing):** Population \u2192 Death Rate \u2192 Population \u2014 1 opposite edge. More people means more deaths, which reduces population. Death regulation.\n- **B2 (Balancing):** Population \u2192 Available Resources \u2192 Birth Rate \u2192 Population \u2014 1 opposite edge (population \u2192 resources). More people deplete resources, reducing birth rate. Resource constraint.\n\n## Rules\n\n1. ALWAYS specify the edge type (`: same` or `: opposite`) \u2014 it cannot be inferred\n2. Stock labels should be nouns or noun phrases representing measurable quantities that can increase or decrease (e.g. \"Population\", \"Revenue\", \"Stress Level\" \u2014 not \"People are born\" or \"Increasing\")\n3. Every Stock MUST connect to at least one other Stock \u2014 no isolated variables\n4. Think in terms of \"if A increases, what happens to B?\" to determine same vs opposite polarity\n5. Use meaningful IDs (population, revenue, stress \u2014 not n1, n2, n3)\n6. Keep the diagram focused on one system \u2014 the title should frame the boundary\n7. Aim for closed loops \u2014 a CLD without any feedback loop is just a causal chain and misses the point of systems thinking\n8. Prefer 3\u20136 variables per loop for clarity \u2014 larger loops are hard to trace and verify", - "inputSchema": { - "additionalProperties": false, - "properties": { - "vgl": { - "description": "Valid VGL code using the CLD notation. Must start with: vgraph <id>: CLD \"<title>\" { ... }", - "type": "string" - } - }, - "required": [ - "vgl" - ], - "type": "object" - }, - "name": "create_cld" - }, - { - "description": "Create a ConceptMap diagram as PNG image. A Concept Map defines the vocabulary of a domain through falsifiable propositions. It helps people align on exact wordings and shared understanding by stating facts as simple, readable sentences.\n\nYou provide VGL (Vithanco Graph Language) code using the ConceptMap notation and the tool renders it to an PNG image.\n\n## How to Build a Concept Map\n\n1. Start with a Guiding Question (used as the graph title) \u2014 it determines what belongs on the map.\n2. List all relevant concepts.\n3. Connect every concept through relations. ALWAYS form readable propositions.\n4. NEVER leave a concept unconnected. Every concept MUST connect to at least one relation.\n5. Reuse relations when multiple concepts share the same relationship.\n\n## VGL Syntax\n\n```\nvgraph <id>: ConceptMap \"<Guiding Question>\" {\n <nodes and edges>\n}\n```\n\n### Node Types\n\n- `Concept` \u2014 A noun or term placed in relation to others. Concepts are connected through Relations to form falsifiable propositions.\n- `EmphasizedConcept` \u2014 A highlighted concept to draw attention to key terms. Use sparingly for maximum impact.\n- `Relation` \u2014 A verb or linking phrase connecting two concepts. Together with source and target, forms a falsifiable proposition.\n\n```\nnode <id>: Concept \"<label>\"\nnode <id>: EmphasizedConcept \"<label>\"\nnode <id>: Relation \"<label>\"\n```\n\n### Edges\n\nValid connections:\n- Concept \u2192 Relation \u2014 A Concept connects to a Relation, forming the source of a proposition.\n- Relation \u2192 Concept \u2014 A Relation points to a Concept, completing the proposition.\n- EmphasizedConcept \u2192 Relation \u2014 An Emphasized Concept connects to a Relation, forming the source of a proposition.\n- Relation \u2192 EmphasizedConcept \u2014 A Relation points to an Emphasized Concept, completing the proposition.\n\n```\nedge <from_id> -> <to_id>\n```\n\nALWAYS form the pattern: Concept -> Relation -> Concept. This creates a readable proposition.\n\n## Reusing Relations\n\nWhen multiple concepts share the same relationship, reuse a single Relation node. No duplicate edges when reusing \u2014 create edges only where needed:\n\n**Multiple sources, one target:**\n```\nvgraph animals: ConceptMap \"What are common pets?\" {\n node dog: Concept \"Dog\"\n node cat: Concept \"Cat\"\n node isa: Relation \"is a\"\n node mammal: Concept \"Mammal\"\n\n edge dog -> isa\n edge cat -> isa\n edge isa -> mammal // Only ONE edge from relation to target\n}\n```\n\nBoth \"Dog is a Mammal\" and \"Cat is a Mammal\" share one Relation node \u2014 only 4 nodes total.\n\n**One source, multiple targets:**\n```\nvgraph typography: ConceptMap \"What defines a font?\" {\n node font: Concept \"Font\"\n node has: Relation \"has\"\n node weight: Concept \"Weight\"\n node style: Concept \"Style\"\n\n edge font -> has // Only ONE edge from source to relation\n edge has -> weight\n edge has -> style\n}\n```\n\nBoth \"Font has Weight\" and \"Font has Style\" share one Relation node \u2014 only 4 nodes total.\n\n**CRITICAL \u2014 Multiple inbound AND multiple outbound edges:**\n\nWhen a relation has BOTH multiple inbound edges (concepts pointing TO the relation) AND multiple outbound edges (relation pointing TO concepts), ALL inbound concepts must make sense as propositions with ALL outbound concepts. With n inbound and m outbound edges, you get n \u00d7 m propositions \u2014 all must be valid.\n\n**Invalid example:**\n```\nvgraph learning: ConceptMap \"What enables growth?\" {\n node learning: Concept \"Learning\"\n node accountability: Concept \"Accountability\"\n node enables: Relation \"enables\"\n\n edge learning -> enables\n edge accountability -> enables\n edge enables -> learning\n edge enables -> accountability\n}\n```\n\nThis creates 4 propositions (2 \u00d7 2):\n- Learning enables Learning \u274c (circular)\n- Learning enables Accountability \u2713\n- Accountability enables Learning \u2713\n- Accountability enables Accountability \u274c (circular)\n\n**Fix \u2014 Use specific relations:**\n```\nvgraph learning: ConceptMap \"What enables growth?\" {\n node learning: Concept \"Learning\"\n node accountability: Concept \"Accountability\"\n node facilitates: Relation \"facilitates\"\n node requires: Relation \"requires\"\n\n edge accountability -> facilitates\n edge facilitates -> learning\n\n edge learning -> requires\n edge requires -> accountability\n}\n```\n\nNow: \"Accountability facilitates Learning\" \u2713 and \"Learning requires Accountability\" \u2713\n\n**Fix \u2014 Restructure:**\n```\nvgraph learning: ConceptMap \"What enables growth?\" {\n node learning: Concept \"Learning\"\n node accountability: Concept \"Accountability\"\n node environment: Concept \"Environment\"\n node creates: Relation \"creates\"\n\n edge learning -> creates\n edge accountability -> creates\n edge creates -> environment\n}\n```\n\nNow: \"Learning creates Environment\" \u2713 and \"Accountability creates Environment\" \u2713\n\n## Complete Example\n\n```\nvgraph learningCM: ConceptMap \"What is Learning?\" {\n node student: Concept \"Student\"\n node subject: Concept \"Subject\"\n node practice: EmphasizedConcept \"Practice\"\n node understanding: Concept \"Understanding\"\n node resources: Concept \"Resources\"\n\n node learns: Relation \"learns\"\n node requires: Relation \"requires\"\n node leads_to: Relation \"leads to\"\n node uses: Relation \"uses\"\n\n edge student -> learns\n edge learns -> subject\n edge subject -> requires\n edge requires -> practice\n edge practice -> leads_to\n edge leads_to -> understanding\n edge subject -> uses\n edge uses -> resources\n}\n```\n\nPropositions: Student learns Subject, Subject requires Practice, Practice leads to Understanding, Subject uses Resources.\n\n## Rules\n\n1. ALWAYS form readable propositions \u2014 every Concept -> Relation -> Concept chain MUST read as a natural, falsifiable sentence\n2. NEVER leave a concept unconnected\n3. **Concept labels are nouns** \u2014 concept labels should be nouns or noun phrases (things, ideas, entities), not actions, sentences, or verb phrases. Use \"Understanding\" not \"How we understand things\"\n4. **Verb agreement** \u2014 Relation labels must match the subject's number: singular concepts (e.g., \"Student\", \"Dog\") use singular verbs (\"requires\", \"is\", \"has\"); plural concepts (e.g., \"LLMs\", \"Dogs\") use plural verbs (\"require\", \"are\", \"have\"). For mixed cases, use infinitive form without \"(s)\": \"enable\" not \"enables\", \"prevent\" not \"prevents\". The notation \"Dog(s)\" in concept labels can indicate the concept works in both forms, then use infinitive verb forms.\n5. **Guiding question as filter** \u2014 the guiding question determines what belongs on the map. Every concept MUST help answer it. If a concept does not contribute to answering the guiding question, it does not belong.\n6. **Relationship diversity** \u2014 use diverse relation types (not all \"is a\" or \"has\"). Avoid simple opposite pairs (e.g. \"is parent of\" / \"is child of\" are the same relationship stated twice in different directions). Use different verbs that reveal distinct aspects of how concepts relate.\n7. **Rich connectivity** \u2014 every concept should connect to at least 2 others via different relations. Aim for a network structure where multiple paths exist between concepts \u2014 not a chain (linear A\u2192B\u2192C) or a spoke (one central concept with everything hanging off it).\n8. Use meaningful IDs (student, practice \u2014 not n1, n2)\n9. Keep relation labels short (verbs or short phrases)\n10. Use EmphasizedConcept sparingly\n11. **Introduce abbreviations** \u2014 if a concept label uses an abbreviation, spell out the full term first: e.g. \"Gross National Product (GNP)\", not just \"GNP\"", - "inputSchema": { - "additionalProperties": false, - "properties": { - "vgl": { - "description": "Valid VGL code using the ConceptMap notation. Must start with: vgraph <id>: ConceptMap \"<title>\" { ... }", - "type": "string" - } - }, - "required": [ - "vgl" - ], - "type": "object" - }, - "name": "create_concept_map" - }, - { - "description": "Decompose a node into a detailed node and return the updated VGL document. Only a node whose type has a detailing can be decomposed; `describe_notation` lists them. The node keeps its id, type, label and attributes and becomes a group holding new details, one per edge, so every edge keeps its id and label and now ends at a detail. Rename and retype the new details afterwards.", - "inputSchema": { - "additionalProperties": false, - "properties": { - "node": { - "description": "Id of the node to decompose", - "type": "string" - }, - "vgl": { - "description": "The VGL document holding the node", - "type": "string" - } - }, - "required": [ - "vgl", - "node" - ], - "type": "object" - }, - "name": "decompose" - }, - { - "description": "Return the self-describing Markdown document for a built-in VGraph notation. The document includes the notation's purpose, when to use it, node types, edge types, group types, detailings (which node types can be decomposed and what goes inside them), history, and references.", - "inputSchema": { - "additionalProperties": false, - "properties": { - "notation": { - "description": "Name of the built-in notation", - "enum": [ - "IBIS", - "BBS", - "ImpactMapping", - "ConceptMap", - "CRT", - "EC", - "FRT", - "PRT", - "TRT", - "ADTree", - "GoalTree", - "CLD", - "DecisionTree", - "Timeline", - "C4", - "Arithmetic" - ], - "type": "string" - } - }, - "required": [ - "notation" - ], - "type": "object" - }, - "name": "describe_notation" - }, - { - "description": "Create a IBIS diagram as PNG image. IBIS (Issue-Based Information System) maps out any decision, discussion, or thought process using just four node types: Questions, Answers (Ideas), Pros, and Cons. Attaching Questions to any node lets you drill into any aspect at any depth.\n\nYou provide VGL (Vithanco Graph Language) code using the IBIS notation and the tool renders it to an PNG image.\n\n## How to Build an IBIS Diagram\n\n1. Start with a root Question (used as the graph title).\n2. Add Answers (Ideas) that respond to the question.\n3. Add Pro and Con arguments for each answer.\n4. Attach further Questions to any node to drill deeper.\n5. Keep going until the topic is explored to the depth you need.\n\n## VGL Syntax\n\n```\nvgraph <id>: IBIS \"<title>\" {\n <nodes and edges>\n}\n```\n\n### Node Types\n\n- `Question` \u2014 Questions are the key driver of IBIS. They are the starting point and can be connected to all other node types.\n- `Answer` \u2014 An idea or answer for a question. Answers are evaluated through pro and con arguments.\n- `Pro` \u2014 An argument in favour of an answer. Pros help evaluate and decide between competing answers.\n- `Con` \u2014 An argument against an answer. Cons help evaluate and decide between competing answers.\n\n```\nnode <id>: Question \"<label>\"\nnode <id>: Answer \"<label>\"\nnode <id>: Pro \"<label>\"\nnode <id>: Con \"<label>\"\n```\n\n### Edges\n\nEdge types are inferred from node types \u2014 just write `edge <from> -> <to>`.\n\nValid connections:\n- Question \u2192 Question \u2014 A question can raise a further question, enabling infinite depth of inquiry.\n- Answer \u2192 Question \u2014 An answer can raise a further question \u2014 e.g., to probe its assumptions.\n- Pro \u2192 Question \u2014 A pro argument can raise a further question \u2014 e.g., to test its validity.\n- Con \u2192 Question \u2014 A con argument can raise a further question \u2014 e.g., to explore how to overcome it.\n- Question \u2192 Answer \u2014 A question is answered by this idea or answer.\n- Answer \u2192 Pro \u2014 This answer is supported by a pro argument.\n- Answer \u2192 Con \u2014 This answer is objected to by a con argument.\n\n```\nedge <from_id> -> <to_id>\n```\n\n## The Drill-Down Mechanism\n\nThe power of IBIS is that you can attach a Question to **any** node type:\n- Question a Question: \"Shouldn't we rather discuss X?\"\n- Question an Answer: \"What would we need to implement this?\"\n- Question a Pro: \"Is this advantage really significant?\"\n- Question a Con: \"Can we mitigate this disadvantage?\"\n\nEach sub-question starts its own Answer/Pro/Con branch, allowing unlimited depth.\n\n## Complete Example\n\n```\nvgraph techChoice: IBIS \"Which database should we use?\" {\n node q1: Question \"Which database should we use?\"\n\n node a1: Answer \"PostgreSQL\"\n node a2: Answer \"MongoDB\"\n\n edge q1 -> a1\n edge q1 -> a2\n\n node pro1: Pro \"ACID compliance\"\n node pro2: Pro \"Mature ecosystem\"\n node con1: Con \"Schema migrations can be complex\"\n\n edge a1 -> pro1\n edge a1 -> pro2\n edge a1 -> con1\n\n node pro3: Pro \"Flexible schema\"\n node con2: Con \"Weaker transaction support\"\n\n edge a2 -> pro3\n edge a2 -> con2\n\n node q2: Question \"How to handle schema migrations?\"\n edge con1 -> q2\n\n node a3: Answer \"Use Flyway or Liquibase\"\n edge q2 -> a3\n\n node pro4: Pro \"Industry-standard tooling\"\n edge a3 -> pro4\n}\n```\n\n## Rules\n\n1. ALWAYS start with a root Question \u2014 it frames the entire diagram\n2. Follow the structure: Question -> Answer -> Pro/Con\n3. Use Questions to drill down \u2014 attach them to any node that needs exploration\n4. Keep labels concise \u2014 Questions as questions, Answers as noun phrases, Pros/Cons as short statements\n5. Use meaningful IDs (q1, mainIdea, costCon \u2014 not n1, n2, n3)\n6. Each Answer should have at least one Pro or Con to be useful\n7. Avoid orphan nodes \u2014 every node must connect to the tree", - "inputSchema": { - "additionalProperties": false, - "properties": { - "vgl": { - "description": "Valid VGL code using the IBIS notation. Must start with: vgraph <id>: IBIS \"<title>\" { ... }", - "type": "string" - } - }, - "required": [ - "vgl" - ], - "type": "object" - }, - "name": "create_ibis" - }, - { - "description": "Create a Timeline diagram as PNG image. A Timeline visualises events over time, optionally across multiple parallel tracks (groups). The default layout is left-to-right but can be changed to any direction. The base notation provides generic TimePoint and Event types \u2014 use `vnotation extends Timeline` to define domain-specific event types (e.g. Battle, Treaty, Release, Incident) with custom colours and categories.\n\nYou provide VGL (Vithanco Graph Language) code using the Timeline notation and the tool renders it to an PNG image.\n\n## Core Concept: alignGroup\n\nThe key mechanism is the `alignGroup` attribute. Nodes sharing the same `alignGroup` value are placed at the same position in the layout \u2014 pinned to the same column (left-to-right) or the same row (top-to-bottom). This is what creates time alignment.\n\n```\nnode t1800: TimePoint \"1800\" [alignGroup: \"1800\"]\nnode e1: Event \"Something happened\" [alignGroup: \"1800\"]\n```\n\nThese two nodes will appear at the same horizontal position because they share alignGroup \"1800\".\n\n## How to Build a Timeline\n\n1. Choose a title that describes the scope of the timeline.\n2. Decide whether you need TimePoints (axis markers) or whether alignGroup alone suffices.\n3. Add Events for things that happened, each with an `alignGroup` matching its time.\n4. Use `sequence` edges between TimePoints to form the visible time axis.\n5. Use `influence` edges between Events to show causal or contextual links.\n6. Optionally use groups to create named parallel tracks (countries, teams, systems).\n\n## VGL Syntax\n\n```\nvgraph <id>: Timeline \"<title>\" {\n <nodes, edges, and groups>\n}\n```\n\n### Node Types\n\n- `TimePoint` \u2014 A marker on the time axis labelling a point in time (e.g., '1805', 'Q3 2025'). Defines the temporal structure of the diagram.\n- `Event` \u2014 A generic event placed at a point in time. Extend with vnotation for domain-specific event types.\n\n```\nnode <id>: TimePoint \"<label>\" [alignGroup: \"<time_value>\"]\nnode <id>: Event \"<label>\" [alignGroup: \"<time_value>\"]\n```\n\nALWAYS include `alignGroup` on every node to ensure correct time alignment.\n\n### Edges\n\n- `sequence` \u2014 Links TimePoints in chronological order, creating the time axis. Rendered as a thin gray arrow.\n- `influence` \u2014 Shows a causal or dependency link between events. Dashed line that does not distort the layout alignment.\n\n`influence` can optionally carry a label.\n\n```\nedge <from_id> -> <to_id>: sequence\nedge <from_id> -> <to_id>: influence\nedge <from_id> -> <to_id>: influence \"<label>\"\n```\n\n### Groups (Tracks)\n\nGroups create named parallel tracks rendered as labelled cluster boxes. Groups are optional.\n\n```\ngroup <id> \"<label>\" {\n node <id>: Event \"<label>\" [alignGroup: \"<value>\"]\n}\n```\n\n## Changing Layout Direction\n\nThe default is left-to-right. Use `vnotation extends Timeline` to change direction. All four directions are supported: `topToBottom`, `bottomToTop`, `leftToRight`, `rightToLeft`.\n\n```\nvnotation VerticalTimeline extends Timeline {\n layout: topToBottom\n}\n\nvgraph myTimeline: VerticalTimeline \"My Timeline\" {\n ...\n}\n```\n\n## Custom Event Types with vnotation\n\nFor domain-specific timelines, use `vnotation extends Timeline` to add custom node types, edge types, and change the layout \u2014 all in one block. The base TimePoint and Event types plus sequence and influence edges remain available.\n\n```\nvnotation WarTimeline extends Timeline {\n layout: topToBottom\n node type: Battle [nodeStyle: withCategory, color: \"#883333\", category: \"Battle\"]\n node type: Treaty [nodeStyle: withCategory, color: \"#339933\", category: \"Treaty\"]\n edge type: resolved_by from: Battle to: Treaty\n edge type: influenced from: Battle to: Battle\n}\n\nvgraph napoleonicWars: WarTimeline \"Napoleonic Wars\" {\n node t1805: TimePoint \"1805\" [alignGroup: \"1805\"]\n node t1812: TimePoint \"1812\" [alignGroup: \"1812\"]\n node t1815: TimePoint \"1815\" [alignGroup: \"1815\"]\n edge t1805 -> t1812: sequence\n edge t1812 -> t1815: sequence\n node f1: Battle \"Battle of Austerlitz\" [alignGroup: \"1805\"]\n node f2: Battle \"Invasion of Russia\" [alignGroup: \"1812\"]\n node f3: Battle \"Battle of Waterloo\" [alignGroup: \"1815\"]\n node e1: Treaty \"Treaty of Pressburg\" [alignGroup: \"1805\"]\n node e2: Treaty \"Congress of Vienna\" [alignGroup: \"1815\"]\n edge f1 -> e1: resolved_by\n edge f3 -> e2: resolved_by\n edge f1 -> f2: influenced \"overconfidence\"\n edge f2 -> f3: influenced \"weakened army\"\n}\n```\n\n## Basic Example (without vnotation)\n\n```\nvgraph europe: Timeline \"19th Century Europe\" {\n node t1800: TimePoint \"1800\" [alignGroup: \"1800\"]\n node t1850: TimePoint \"1850\" [alignGroup: \"1850\"]\n node t1871: TimePoint \"1871\" [alignGroup: \"1871\"]\n edge t1800 -> t1850: sequence\n edge t1850 -> t1871: sequence\n\n group germany \"Germany\" {\n node g1: Event \"Napoleon defeats Prussia\" [alignGroup: \"1800\"]\n node g2: Event \"German Unification\" [alignGroup: \"1871\"]\n }\n\n group england \"England\" {\n node e1: Event \"Industrial Revolution peaks\" [alignGroup: \"1850\"]\n node e2: Event \"Franco-Prussian War impact\" [alignGroup: \"1871\"]\n }\n\n edge g1 -> g2: influence \"led to\"\n edge e1 -> e2: influence\n edge e1 -> g2: influence \"industrialization enabled\"\n}\n```\n\n## Rules\n\n1. ALWAYS use `alignGroup` on every node to ensure correct time alignment.\n2. TimePoints are optional \u2014 alignGroup alone suffices for alignment.\n3. Keep TimePoint labels short (dates, phase names).\n4. Use influence edges sparingly \u2014 only for meaningful causal or contextual links.\n5. Use meaningful IDs (t1800, battleOfWaterloo \u2014 not n1, n2).\n6. Groups are optional \u2014 use them when you have distinct parallel tracks.\n7. When you need domain-specific event types, use `vnotation extends Timeline` \u2014 don't overload the generic Event type.\n8. When changing layout direction, always use `vnotation extends Timeline` with a `layout:` directive \u2014 the base Timeline is always left-to-right.", - "inputSchema": { - "additionalProperties": false, - "properties": { - "vgl": { - "description": "Valid VGL code using the Timeline notation. Either `vgraph <id>: Timeline \"<title>\" { ... }` directly, or a `vnotation <Name> extends Timeline { ... }` block followed by `vgraph <id>: <Name> \"<title>\" { ... }`.", - "type": "string" - } - }, - "required": [ - "vgl" - ], - "type": "object" - }, - "name": "create_timeline" - } -] From aa9dccc00d83b83f92de9e4a9bff1eef1535228f Mon Sep 17 00:00:00 2001 From: Klaus Kneupner <Klaus@vithanco.com> Date: Sun, 22 Nov 2026 16:05:55 +0100 Subject: [PATCH 2/2] perf(release): ship the engine `just release` built, everywhere The engine-build check moves out of publish-plugins into scripts/check-engine-build.sh, so vgraph-mcp's npm publish can use the released engine instead of building its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --- .github/workflows/ci.yml | 2 +- docs/releasing.md | 8 +++-- justfile | 32 ++--------------- scripts/check-engine-build.sh | 42 ++++++++++++++++++++++ scripts/check-engine-build.test.sh | 58 ++++++++++++++++++++++++++++++ scripts/publish-plugins.test.sh | 2 +- 6 files changed, 110 insertions(+), 34 deletions(-) create mode 100755 scripts/check-engine-build.sh create mode 100755 scripts/check-engine-build.test.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a5702a..e24d236 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,7 +125,7 @@ jobs: - name: Shell tests run: | failed=0 - for t in check-wasm-optimized justfile-hygiene doctor-kegs doctor-sdk codeowners licence audit-public record-engine-build publish-plugins release-stamp ci-status; do + for t in check-wasm-optimized justfile-hygiene doctor-kegs doctor-sdk codeowners licence audit-public record-engine-build check-engine-build publish-plugins release-stamp ci-status; do echo "::group::$t" ./scripts/$t.test.sh || failed=1 echo "::endgroup::" diff --git a/docs/releasing.md b/docs/releasing.md index 80346ac..e9cd837 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -62,8 +62,12 @@ checks `main` after the push. Run `just publish-all` again. It skips `just release` while nothing that ships has changed since it passed, the plugins when they carry the version, and -`vgraph-mcp`'s tag, npm and the MCP Registry when each does. It redeploys the -website and Cloud Run, which is harmless. The registry publish retries on its own, because the registry stalls +`vgraph-mcp`'s tag, npm and the MCP Registry when each does, and Cloud Build +when an image was already built from the same sources (its tag is their hash). +It redeploys the website and Cloud Run, which is harmless. + +Nothing compiles twice. Every consumer ships the engine `just release` built: +the plugins and the npm host refuse any other (`scripts/check-engine-build.sh`). The registry publish retries on its own, because the registry stalls now and then. To finish one place by hand, run its recipe: `publish-plugins`, `publish-website`, `publish-vscode-marketplace`, or in `vgraph-mcp` diff --git a/justfile b/justfile index 7e689be..ab2838f 100644 --- a/justfile +++ b/justfile @@ -104,6 +104,7 @@ test filter='': build ./scripts/doctor-sdk.test.sh ./scripts/embedded-unicode.test.sh ./scripts/record-engine-build.test.sh + ./scripts/check-engine-build.test.sh ./scripts/codeowners.test.sh ./scripts/licence.test.sh ./scripts/audit-public.test.sh @@ -437,36 +438,7 @@ publish-plugins marketplace='now': _require-maintainer _release-preflight # Both plugins ship the engine, so a release must name the VGraph commit it was # built from: the one build-wasm.sh recorded. (_release-preflight has checked # VGraph and the plugin branches, and fetched origin/main.) - # What build-wasm.sh reads. A version-bump commit after the build is expected. - ENGINE_PATHS=(Sources Package.swift Package.resolved .swift-version build-wasm.sh - scripts/wasm-sdk.sh scripts/embedded-unicode.sh VGraphWasm/Package.swift - VGraphWasm/Package.resolved VGraphWasm/Sources VGraphWasm/VGraphEditor VGraphWasm/scripts) - BUILT="" - if [ ! -f website/Package/VGRAPH_BUILD ]; then - echo "Preflight: no record of which commit built website/Package — rebuild it with 'just release'." >&2 - FAIL=1 - else - read -r BUILT BUILT_SUM < website/Package/VGRAPH_BUILD - if [ "$BUILT" = unknown ]; then - echo "Preflight: the engine was built from an unknown commit — git could not read the checkout. Rebuild it here." >&2 - FAIL=1 - elif [ "${BUILT%-dirty}" != "$BUILT" ]; then - echo "Preflight: the engine was built from uncommitted changes on ${BUILT:0:12} — commit and merge them, then rebuild with 'just release'." >&2 - FAIL=1 - elif ! git merge-base --is-ancestor "$BUILT" origin/main 2>/dev/null; then - echo "Preflight: the engine was built from ${BUILT:0:12}, which is not on origin/main." >&2 - FAIL=1 - elif ! git diff --quiet "$BUILT" HEAD -- "${ENGINE_PATHS[@]}"; then - echo "Preflight: the engine sources changed since the build at ${BUILT:0:12} — rebuild with 'just release'." >&2 - FAIL=1 - fi - for w in website/Package obsidian-vithanco vscode-vithanco; do - if [ "$(shasum -a 256 < "$w/VGraphWasm.wasm" | cut -d' ' -f1)" != "$BUILT_SUM" ]; then - echo "Preflight: $w/VGraphWasm.wasm is not the engine built at ${BUILT:0:12}." >&2 - FAIL=1 - fi - done - fi + BUILT=$(./scripts/check-engine-build.sh obsidian-vithanco vscode-vithanco) || FAIL=1 ENGINE="VGraph ${BUILT:0:12}" for spec in "obsidian-vithanco:main.js" "vscode-vithanco:vithanco-${OBS_V}.vsix"; do DIR=${spec%%:*}; ASSET=${spec#*:} diff --git a/scripts/check-engine-build.sh b/scripts/check-engine-build.sh new file mode 100755 index 0000000..eccab77 --- /dev/null +++ b/scripts/check-engine-build.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# Is the engine in website/Package still the one to ship, and does each consumer +# carry exactly it? Prints the commit that built it; says what is wrong on stderr. +# +# scripts/check-engine-build.sh [consumer-dir...] # each holding a VGraphWasm.wasm +# +# Run from VGraph's root, after origin/main was fetched. A release ships the build +# `just release` made, so a consumer never rebuilds the engine to publish it. +set -uo pipefail + +# What build-wasm.sh reads. A version-bump commit after the build is expected. +ENGINE_PATHS=(Sources Package.swift Package.resolved .swift-version build-wasm.sh + scripts/wasm-sdk.sh scripts/embedded-unicode.sh VGraphWasm/Package.swift + VGraphWasm/Package.resolved VGraphWasm/Sources VGraphWasm/VGraphEditor VGraphWasm/scripts) + +if [ ! -f website/Package/VGRAPH_BUILD ]; then + echo "Preflight: no record of which commit built website/Package — rebuild it with 'just release'." >&2 + exit 1 +fi +read -r BUILT BUILT_SUM < website/Package/VGRAPH_BUILD +FAIL=0 +if [ "$BUILT" = unknown ]; then + echo "Preflight: the engine was built from an unknown commit — git could not read the checkout. Rebuild it here." >&2 + FAIL=1 +elif [ "${BUILT%-dirty}" != "$BUILT" ]; then + echo "Preflight: the engine was built from uncommitted changes on ${BUILT:0:12} — commit and merge them, then rebuild with 'just release'." >&2 + FAIL=1 +elif ! git merge-base --is-ancestor "$BUILT" origin/main 2>/dev/null; then + echo "Preflight: the engine was built from ${BUILT:0:12}, which is not on origin/main." >&2 + FAIL=1 +elif ! git diff --quiet "$BUILT" HEAD -- "${ENGINE_PATHS[@]}"; then + echo "Preflight: the engine sources changed since the build at ${BUILT:0:12} — rebuild with 'just release'." >&2 + FAIL=1 +fi +for w in website/Package "$@"; do + if [ "$(shasum -a 256 < "$w/VGraphWasm.wasm" | cut -d' ' -f1)" != "$BUILT_SUM" ]; then + echo "Preflight: $w/VGraphWasm.wasm is not the engine built at ${BUILT:0:12}." >&2 + FAIL=1 + fi +done +echo "$BUILT" +exit "$FAIL" diff --git a/scripts/check-engine-build.test.sh b/scripts/check-engine-build.test.sh new file mode 100755 index 0000000..cf8daa5 --- /dev/null +++ b/scripts/check-engine-build.test.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# Every consumer that ships the engine publishes the build `just release` made, +# rather than building its own: one check says that build is still the one to ship. +set -uo pipefail + +REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd) +ROOT=$(mktemp -d) || exit 1 +trap 'rm -rf "$ROOT"' EXIT +FAILED=0 +fail() { echo "FAIL: $*" >&2; FAILED=1; } +export GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@example.invalid GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@example.invalid + +given_built() { # VGraph on origin/main, its engine built and copied into consumer/ + WORK=$(mktemp -d "$ROOT/work.XXXXXX") || exit 1 + mkdir -p "$WORK/Sources" "$WORK/website/Package" "$WORK/consumer" + echo engine > "$WORK/Sources/engine.swift" + printf '%s\n' '*.git/' website/Package/ consumer/ out err > "$WORK/.gitignore" + git init -q --bare -b main "$WORK/vgraph.git" + git -C "$WORK" init -q -b main + git -C "$WORK" remote add origin "$WORK/vgraph.git" + git -C "$WORK" add . && git -C "$WORK" commit -qm engine && git -C "$WORK" push -q origin main + printf '\0asm\1\0\0\0' > "$WORK/website/Package/VGraphWasm.wasm" + ( cd "$WORK" && "$REPO_ROOT/scripts/record-engine-build.sh" website/Package ) + cp "$WORK/website/Package/VGraphWasm.wasm" "$WORK/consumer/" +} +check() { ( cd "$WORK" && "$REPO_ROOT/scripts/check-engine-build.sh" "$@" ) >"$WORK/out" 2>"$WORK/err"; } + +# Given a build of the current engine, when a consumer carries it, then the check +# passes and names the commit that built it. +given_built +check consumer || fail "a current build failed: $(cat "$WORK/err")" +[ "$(cat "$WORK/out")" = "$(git -C "$WORK" rev-parse HEAD)" ] || fail "does not print the build commit: $(cat "$WORK/out")" + +# Given a version bump committed after the build, then the build still counts. +given_built +echo '{}' > "$WORK/plugins.json" && git -C "$WORK" add plugins.json && git -C "$WORK" commit -qm bump && git -C "$WORK" push -q origin main +check consumer || fail "a bump after the build failed: $(cat "$WORK/err")" + +# Given an engine change after the build, then it fails and says to rebuild. +given_built +echo changed > "$WORK/Sources/engine.swift" && git -C "$WORK" commit -qam change && git -C "$WORK" push -q origin main +check consumer && fail "passed an engine built before the engine changed" +grep -q 'changed since' "$WORK/err" || fail "does not say the engine changed: $(cat "$WORK/err")" + +# Given a consumer carrying another wasm, then it fails and names that copy. +given_built +printf '\0asm\1\0\0\0\2' > "$WORK/consumer/VGraphWasm.wasm" +check consumer && fail "passed a consumer carrying another engine" +grep -q 'consumer/VGraphWasm.wasm' "$WORK/err" || fail "does not name the mismatched copy: $(cat "$WORK/err")" + +# Given no recorded build, then it fails and points at `just release`. +given_built +rm "$WORK/website/Package/VGRAPH_BUILD" +check consumer && fail "passed without a recorded build" +grep -q 'just release' "$WORK/err" || fail "does not point at 'just release': $(cat "$WORK/err")" + +[ "$FAILED" -eq 0 ] && echo "✓ check-engine-build" +exit "$FAILED" diff --git a/scripts/publish-plugins.test.sh b/scripts/publish-plugins.test.sh index 8d47d5b..1401625 100755 --- a/scripts/publish-plugins.test.sh +++ b/scripts/publish-plugins.test.sh @@ -45,7 +45,7 @@ given_plugins_at() { # version, in a fresh directory WORK with pushed plugin rep export GH_LOG="$WORK/gh.log" NPX_LOG="$WORK/npx.log" : > "$GH_LOG"; : > "$NPX_LOG" mkdir -p "$WORK/website/Package" "$WORK/scripts" - cp "$REPO_ROOT/scripts/check-wasm-optimized.sh" "$REPO_ROOT/scripts/vscode-marketplace.sh" "$WORK/scripts/" + cp "$REPO_ROOT/scripts/check-wasm-optimized.sh" "$REPO_ROOT/scripts/vscode-marketplace.sh" "$REPO_ROOT/scripts/check-engine-build.sh" "$WORK/scripts/" printf '\0asm\1\0\0\0' > "$WORK/website/Package/VGraphWasm.wasm" for p in obsidian-vithanco vscode-vithanco; do git init -q --bare -b main "$WORK/$p.git"