Skip to content

[feat] Detect and inject a build-stack descriptor in mark-build#35

Merged
ejntaylor merged 1 commit into
mainfrom
server-stack-descriptor
Jul 13, 2026
Merged

[feat] Detect and inject a build-stack descriptor in mark-build#35
ejntaylor merged 1 commit into
mainfrom
server-stack-descriptor

Conversation

@ejntaylor

Copy link
Copy Markdown
Contributor

What

mark-build now derives a coarse stack descriptor from the lockfile plus the build-time environment and injects it as window.__PATCHSTACK_STACK__ in every built HTML file, alongside the existing __PATCHSTACK_PROD__ flag and __PATCHSTACK_BUILD__ fingerprint.

The descriptor captures:

  • frameworknext, nuxt, tanstack-start, remix, astro, sveltekit, …
  • uireact, vue, svelte, solid, angular, …
  • bundlervite, webpack, rspack, …
  • runtime — deployment-target hint from deps (cloudflare-workers, vercel, netlify)
  • builder — the vibe platform that generated the project (lovable, replit, …)
  • hostingEnvKeys — the names (never values) of hosting-related build-env vars (CF_PAGES, VERCEL_REGION, …), reusing server-insight's env-fingerprint patterns

Why

The disclosure widget can't introspect the host's server — it runs only in the browser. But the connector runs in Node at build time, where the lockfile is ground truth for the framework/toolchain and process.env carries hosting fingerprints. Stamping that into the page lets the widget report how each site was built and hosted, so Patchstack learns its deployment landscape across every vibe platform — without shipping a runtime probe onto the host server.

Detection is a data-driven registry (src/stack.ts) — add one row to teach a new framework, bundler, or platform.

Safety

  • Only coarse labels and env-var key names are emitted — never env values, never secrets.
  • Best-effort and non-fatal: a missing/unreadable lockfile or unrecognised stack just omits the descriptor; mark-build never fails the build.
  • Injection is skipped entirely when the descriptor carries no signal.

Tests

  • New tests/stack.test.ts — detection registry + env-key allowlisting.
  • Extended tests/mark-build.test.ts — snippet injects/omits the stack correctly.
  • Full suite: 121 passing; typecheck + build clean.

🤖 Generated with Claude Code

mark-build now derives a coarse stack descriptor from the lockfile
(framework, UI, bundler, deployment runtime, and the vibe/builder
platform such as Lovable) plus the NAMES of hosting-related build-env
vars, and injects it as `window.__PATCHSTACK_STACK__` alongside the
existing production flag and build fingerprint.

The disclosure widget reads this to report how each site was built,
so Patchstack learns the deployment landscape it protects across every
vibe platform — without shipping a runtime probe onto the host server.
Detection is a data-driven registry (add a row to teach a new stack)
and only surfaces coarse labels and env-var key names, never values.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderbuds

coderbuds Bot commented Jul 13, 2026

Copy link
Copy Markdown

Adds robust stack detection and injection with clear patterns and solid tests.

🎯 Quality: 100% Elite · 📦 Size: Large — consider splitting if possible

📈 This month: Your 215th PR — above team average · Averaging Excellent

See how your team is trending →

@ejntaylor

Copy link
Copy Markdown
Contributor Author

/review

@ejntaylor ejntaylor merged commit 3d1ff2d into main Jul 13, 2026
7 of 8 checks passed
@ejntaylor ejntaylor deleted the server-stack-descriptor branch July 13, 2026 13:29
ejntaylor added a commit that referenced this pull request Jul 13, 2026
Resolves the import conflict in src/cli.ts — both features coexist.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants