`ui/src` now builds two ways from one tree: the static app `codegraph ui` serves, and — via `svelte-package` — a Svelte library the Pro app imports. A forked component would be a second answer to the same question about the same graph, so there is no fork. Everything a screen knows arrives through a `GraphAdapter`: eleven methods answering the wire shapes verbatim, with `createHttpAdapter()` (the loopback JSON API) as the default and a host's in-process engine reads as the point. `lib/api.ts` became a one-line-per-call facade over it, which is why no call site in the views changed. The payload types moved to `lib/wire.ts` — no imports, no runtime — so a host can depend on the vocabulary alone. Two more seams and one guard: - `lib/navigation.ts` holds the href builders behind a `NavigationDriver`, so a host addresses its own URL space. The app's half — the hash parser and the live route, which attach window listeners at module scope — stays in `router.svelte.ts` and is pruned out of the package: rendering a Symbol view must not install a hash router in somebody else's application. - `lib/theme.css` carries the design tokens and maps Svelte Flow's `--xy-*` variables onto them, so a host never sees library defaults. Dark now also answers to a bare `[data-theme]`, which is how `<CodegraphUi theme>` themes a container rather than the document. - `scripts/check-ui-package.mjs` prunes the app's shell, resolves the extensionless specifiers svelte-package leaves behind, and asserts that nothing but `lib/adapter.js` reaches the network. The search box, its keyboard and its panel are one component now (`SearchPalette`), because splitting them is what breaks a palette. `__tests__/ui-package.test.ts` mounts the three screens from the package entry against a mock adapter in jsdom; it runs as a second vitest project so the `browser` resolve condition it needs cannot reach the engine's suites. Versioned with the engine. Prepared, not published: `private: true` is the guard and `pack-npm.sh` only packs a tarball under CODEGRAPH_PACK_UI=1.
43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
import { defineConfig } from 'vitest/config';
|
|
|
|
/**
|
|
* The SHARED base. `vitest.workspace.mts` extends it twice — once for the
|
|
* engine's node-environment suites and once for the viewer package's jsdom
|
|
* one — so the environment, the plugins and the module-resolution conditions
|
|
* a browser test needs cannot leak into the other 200-odd suites.
|
|
*/
|
|
export default defineConfig({
|
|
test: {
|
|
globals: true,
|
|
environment: 'node',
|
|
include: ['__tests__/**/*.test.ts'],
|
|
/**
|
|
* Several MCP integration tests (mcp-daemon, mcp-initialize, mcp-ppid-watchdog,
|
|
* mcp-roots) spawn `dist/bin/codegraph.js serve --mcp` with `process.execPath`
|
|
* and rely on the child inheriting `process.env`. On a Node >= 25 dev machine
|
|
* the CLI's hard-block (src/bin/codegraph.ts) would otherwise exit the child
|
|
* before it ever responds, so every spawn-based test times out — see #478.
|
|
*
|
|
* Setting the override here keeps the CLI's runtime guard intact for end
|
|
* users (it's still enforced when `codegraph` is invoked directly) while
|
|
* letting the test suite run on whatever Node the contributor happens to
|
|
* have installed. CI on Node 22/23 is unaffected — the guard doesn't fire
|
|
* there, so the variable is a no-op.
|
|
*/
|
|
env: {
|
|
CODEGRAPH_ALLOW_UNSAFE_NODE: '1',
|
|
/**
|
|
* The suite spawns real CLI/MCP processes; without this they would write
|
|
* telemetry state into the contributor's real ~/.codegraph and count test
|
|
* tool calls as real usage. The telemetry unit tests are unaffected —
|
|
* they inject their own `env` via the Telemetry constructor.
|
|
*/
|
|
CODEGRAPH_TELEMETRY: '0',
|
|
},
|
|
coverage: {
|
|
provider: 'v8',
|
|
reporter: ['text', 'json', 'html'],
|
|
},
|
|
},
|
|
});
|