build: one tsc -b build and a source export condition (P2.1)
- tsconfig.build.json references the nine in-scope packages; each package is composite and references the workspace packages it depends on. build:packages is now `tsc -b tsconfig.build.json` instead of a chain of cd commands. - Every in-scope package exports its TypeScript entry under a `source` condition next to the dist/ entries. Vitest, tsx (dev:server, the Tauri dev launch, the e2e server), the sidecar and launcher bundles and the web app resolve it, so none of them needs build:packages first or can pick up a stale dist/. The vitest src aliases remain only for the excluded packages that have no source export. - Published packages with a files list (agent, cli, marketplace) pack src/ too, so the source condition never points at a missing file. - tsconfig.tests.json and `npm run typecheck:tests` type-check the test suites of the in-scope packages. They report 426 existing errors, so the CI step is advisory for now. - The root test run leaves out the excluded and postponed packages (hive-mind-*, memory-mcp, wiki-compiler, team-server, waggle-dance, worker, weaver); they are not built either. - CI runs the test job on Ubuntu, macOS and Windows with Node 22.23.2 (ADR-0008), and no longer builds the hook runtime and the memory MCP server.
This commit is contained in:
69
.github/workflows/ci.yml
vendored
69
.github/workflows/ci.yml
vendored
@@ -6,14 +6,20 @@ on:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
# Runs on the three desktop platforms of the community edition (P1.3b, P2.1).
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# The Node version the installer and the desktop app ship (ADR-0008).
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
node-version: 22.23.2
|
||||
|
||||
- name: Cache npm dependencies
|
||||
uses: actions/cache@v4
|
||||
@@ -23,24 +29,23 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-npm-
|
||||
|
||||
# NOTE: the switch to `npm ci` (deterministic, lockfile-faithful) is deferred
|
||||
# to the deps/lockfile hardening pass, after the root package-lock.json is
|
||||
# regenerated in sync with every workspace manifest. `npm install` is the
|
||||
# safe, lockfile-tolerant install until then.
|
||||
- run: npm install
|
||||
env:
|
||||
ONNXRUNTIME_NODE_INSTALL_CUDA: skip
|
||||
|
||||
# Real typecheck gate. The old step ran `npx tsc --noEmit` against the root
|
||||
# tsconfig.json, whose `"files": ["apps/web/src/vite-env.d.ts"]` (and no
|
||||
# `include`) typechecks essentially nothing. build:packages is the actual
|
||||
# `tsc --build` chain for every @waggle/* package (shared → hive-mind-core →
|
||||
# core → agent → server) and also emits the dist/ that apps/web unit tests
|
||||
# import; typecheck:web is the real apps/web check (tsc -p tsconfig.app.json).
|
||||
- name: Type check — workspace packages (tsc --build chain)
|
||||
# One `tsc -b` over the project references in tsconfig.build.json: every
|
||||
# in-scope @waggle/* package, in dependency order.
|
||||
- name: Type check — workspace packages (tsc -b)
|
||||
run: npm run build:packages
|
||||
|
||||
- name: Type check — web (apps/web, tsc -p tsconfig.app.json)
|
||||
run: npm run typecheck:web
|
||||
|
||||
# Advisory until the existing test type errors are fixed.
|
||||
- name: Type check — tests (tsconfig.tests.json)
|
||||
run: npm run typecheck:tests
|
||||
continue-on-error: true
|
||||
|
||||
- name: Lint (root flat config)
|
||||
run: npm run lint
|
||||
|
||||
@@ -54,39 +59,31 @@ jobs:
|
||||
# dist/ payload explicitly so CI proves a fresh checkout.
|
||||
- name: Build package-install test runtimes
|
||||
run: |
|
||||
npm run build:hook-runtime
|
||||
npm run build --workspace @waggle/cli
|
||||
npm run build --workspace @waggle-ai/waggle
|
||||
npm run build --workspace waggle-memory-mcp
|
||||
|
||||
- name: Unit tests — packages + cross-cutting (root vitest)
|
||||
run: |
|
||||
npm test -- \
|
||||
--exclude=packages/cli/tests/cli-runtime.test.ts \
|
||||
--exclude=packages/marketplace/tests/cli-runtime.test.ts \
|
||||
--exclude=packages/hive-mind-cli/tests/cli-help.test.ts \
|
||||
--exclude=packages/hive-mind-mcp-server/tests/runtime.test.ts \
|
||||
--exclude=packages/launcher/tests/cli.test.ts \
|
||||
--exclude=packages/memory-mcp/tests/runtime.test.ts \
|
||||
run: >-
|
||||
npm test --
|
||||
--exclude=packages/cli/tests/cli-runtime.test.ts
|
||||
--exclude=packages/marketplace/tests/cli-runtime.test.ts
|
||||
--exclude=packages/launcher/tests/cli.test.ts
|
||||
--maxWorkers=2
|
||||
|
||||
# These tests each create a temporary project and run npm install. Running
|
||||
# several cold installs in parallel makes individual test timeouts measure
|
||||
# runner contention rather than package correctness.
|
||||
- name: Package-install runtime tests (serial)
|
||||
run: |
|
||||
npx vitest run \
|
||||
packages/cli/tests/cli-runtime.test.ts \
|
||||
packages/marketplace/tests/cli-runtime.test.ts \
|
||||
packages/hive-mind-cli/tests/cli-help.test.ts \
|
||||
packages/hive-mind-mcp-server/tests/runtime.test.ts \
|
||||
packages/launcher/tests/cli.test.ts \
|
||||
packages/memory-mcp/tests/runtime.test.ts \
|
||||
--maxWorkers=1 \
|
||||
run: >-
|
||||
npx vitest run
|
||||
packages/cli/tests/cli-runtime.test.ts
|
||||
packages/marketplace/tests/cli-runtime.test.ts
|
||||
packages/launcher/tests/cli.test.ts
|
||||
--maxWorkers=1
|
||||
--no-file-parallelism
|
||||
|
||||
# The root vitest.config.ts excludes `apps/**`, so apps/web's own 131-file
|
||||
# suite never ran in CI. Run it via its own vitest config (jsdom). Blocking.
|
||||
# The root vitest.config.ts excludes `apps/**`; apps/web runs its own
|
||||
# suite (jsdom).
|
||||
- name: Unit tests — apps/web
|
||||
run: npm run test -w apps/web
|
||||
|
||||
@@ -110,7 +107,7 @@ jobs:
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
node-version: 22.23.2
|
||||
|
||||
- name: Cache npm dependencies
|
||||
uses: actions/cache@v4
|
||||
@@ -143,7 +140,7 @@ jobs:
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
node-version: 22.23.2
|
||||
|
||||
- name: Cache npm dependencies
|
||||
uses: actions/cache@v4
|
||||
|
||||
@@ -621,7 +621,12 @@ fn build_service_command(
|
||||
|
||||
let mut cmd = if service_script.kind == ServiceScriptKind::DevSource {
|
||||
let mut c = Command::new(&node_path);
|
||||
c.arg("--import").arg("tsx").arg(&service_script.path);
|
||||
// Workspace packages resolve to their sources through the `source`
|
||||
// export condition, so a dev launch needs no build:packages first.
|
||||
c.arg("--conditions=source")
|
||||
.arg("--import")
|
||||
.arg("tsx")
|
||||
.arg(&service_script.path);
|
||||
c
|
||||
} else {
|
||||
let mut c = Command::new(&node_path);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"module": "ESNext",
|
||||
"moduleDetection": "force",
|
||||
"moduleResolution": "bundler",
|
||||
"customConditions": ["source"],
|
||||
"noEmit": true,
|
||||
"noFallthroughCasesInSwitch": false,
|
||||
"noImplicitAny": false,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { defineConfig } from "vite";
|
||||
import { defineConfig, defaultClientConditions } from "vite";
|
||||
import react from "@vitejs/plugin-react-swc";
|
||||
import path from "path";
|
||||
import { componentTagger } from "lovable-tagger";
|
||||
@@ -47,6 +47,9 @@ export default defineConfig(({ mode }) => ({
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
// Workspace packages (@waggle/shared) resolve to src/ through their
|
||||
// `source` export, so the UI builds without build:packages (P2.1).
|
||||
conditions: ["source", ...defaultClientConditions],
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "./src"),
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { defineConfig } from "vitest/config";
|
||||
import { defaultClientConditions } from "vite";
|
||||
import react from "@vitejs/plugin-react-swc";
|
||||
import path from "path";
|
||||
|
||||
@@ -27,6 +28,7 @@ export default defineConfig({
|
||||
retry: 1,
|
||||
},
|
||||
resolve: {
|
||||
conditions: ["source", ...defaultClientConditions],
|
||||
alias: { "@": path.resolve(__dirname, "./src") },
|
||||
},
|
||||
});
|
||||
|
||||
@@ -14,12 +14,13 @@
|
||||
"scripts": {
|
||||
"dev": "cd apps/web && npx vite",
|
||||
"dev:web": "npm run dev",
|
||||
"dev:server": "cd packages/server && npx tsx src/local/start.ts",
|
||||
"dev:server": "cd packages/server && npx tsx --conditions=source src/local/start.ts",
|
||||
"build": "cd apps/web && npx tsc --noEmit -p tsconfig.app.json && npx vite build --outDir ../../dist --emptyOutDir",
|
||||
"build:dev": "cd apps/web && npx vite build --mode development --outDir ../../dist --emptyOutDir",
|
||||
"typecheck:web": "cd apps/web && npx tsc --noEmit -p tsconfig.app.json",
|
||||
"typecheck:tests": "tsc -p tsconfig.tests.json",
|
||||
"preview": "cd apps/web && npx vite preview",
|
||||
"build:packages": "cd packages/shared && npx tsc --build && cd ../memory-contract && npx tsc --build && cd ../memory-mem0 && npx tsc --build && cd ../core && npx tsc --build && cd ../marketplace && npx tsc --build && cd ../agent && npx tsc --build && cd ../server && npx tsc --build",
|
||||
"build:packages": "tsc -b tsconfig.build.json",
|
||||
"build:hook-runtime": "node scripts/build-hook-runtime.mjs",
|
||||
"build:all": "npm run build:packages && npm run build",
|
||||
"dev:www": "npm run dev -w apps/www",
|
||||
|
||||
@@ -7,16 +7,19 @@
|
||||
"types": "dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
},
|
||||
"./external-process-env": {
|
||||
"source": "./src/external-process-env.ts",
|
||||
"types": "./dist/external-process-env.d.ts",
|
||||
"import": "./dist/external-process-env.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
"dist",
|
||||
"src"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc --build --force && node ../../scripts/stage-agent-pptx-runtime.mjs",
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
"exclude": ["node_modules", "dist", "tests"],
|
||||
"references": [
|
||||
{ "path": "../core" },
|
||||
{ "path": "../memory-contract" }
|
||||
{ "path": "../marketplace" },
|
||||
{ "path": "../memory-contract" },
|
||||
{ "path": "../shared" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"types": "dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
}
|
||||
@@ -16,6 +17,7 @@
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"bin"
|
||||
],
|
||||
"license": "MIT",
|
||||
@@ -46,7 +48,7 @@
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"test": "node ../../node_modules/vitest/vitest.mjs run --root ../.. --config vitest.config.ts packages/cli/tests/commands.test.ts packages/cli/tests/admin.test.ts packages/cli/tests/renderer.test.ts packages/cli/tests/memory-persistence-hard.test.ts packages/cli/tests/auth.test.ts packages/cli/tests/mode-detector.test.ts packages/cli/tests/comprehensive-e2e.test.ts packages/cli/tests/cli-runtime.test.ts",
|
||||
"dev": "tsx src/index.ts"
|
||||
"dev": "tsx --conditions=source src/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@waggle/core": "*",
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["node_modules", "dist", "tests"],
|
||||
"references": [
|
||||
{ "path": "../core" },
|
||||
{ "path": "../agent" },
|
||||
{ "path": "../core" },
|
||||
{ "path": "../memory-contract" },
|
||||
{ "path": "../memory-mem0" }
|
||||
]
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"types": "dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["node_modules", "dist", "tests"],
|
||||
"references": [
|
||||
{ "path": "../memory-contract" }
|
||||
{ "path": "../memory-contract" },
|
||||
{ "path": "../shared" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"start": "tsx src/cli.ts",
|
||||
"start": "tsx --conditions=source src/cli.ts",
|
||||
"test": "node ../../node_modules/vitest/vitest.mjs run --root ../.. --config vitest.config.ts packages/launcher/tests/cli.test.ts",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
|
||||
@@ -12,6 +12,10 @@ export default defineConfig({
|
||||
// Inline all @waggle/* workspace packages into the bundle.
|
||||
// Third-party npm packages stay external (installed as dependencies).
|
||||
noExternal: [/^@waggle\//],
|
||||
// Build the workspace packages from their source export, not a stale dist/.
|
||||
esbuildOptions(options) {
|
||||
options.conditions = ['source'];
|
||||
},
|
||||
// Runtime packages that cannot be bundled safely.
|
||||
external: [
|
||||
'@huggingface/transformers',
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"types": "dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
}
|
||||
@@ -41,6 +42,7 @@
|
||||
},
|
||||
"files": [
|
||||
"dist/",
|
||||
"src/",
|
||||
"README.md"
|
||||
],
|
||||
"keywords": [
|
||||
|
||||
@@ -113,9 +113,11 @@ describe('marketplace CLI runtime UX', () => {
|
||||
expect(pkg.main).toBe('dist/index.js');
|
||||
expect(pkg.types).toBe('dist/index.d.ts');
|
||||
expect(pkg.exports['.']).toEqual({
|
||||
source: './src/index.ts',
|
||||
import: './dist/index.js',
|
||||
types: './dist/index.d.ts',
|
||||
});
|
||||
expect(packedFiles.has('src/index.ts')).toBe(true);
|
||||
expect(packedFiles.has('dist/index.js')).toBe(true);
|
||||
expect(packedFiles.has('dist/index.d.ts')).toBe(true);
|
||||
expect(packedFiles.has('dist/cli.js')).toBe(true);
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true
|
||||
"isolatedModules": true,
|
||||
"composite": true
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
}
|
||||
|
||||
@@ -17,5 +17,8 @@
|
||||
"composite": true
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["node_modules", "dist", "tests"]
|
||||
"exclude": ["node_modules", "dist", "tests"],
|
||||
"references": [
|
||||
{ "path": "../memory-contract" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -6,7 +6,11 @@
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
".": {
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
|
||||
@@ -17,5 +17,8 @@
|
||||
"composite": true
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["node_modules", "dist", "tests"]
|
||||
"exclude": ["node_modules", "dist", "tests"],
|
||||
"references": [
|
||||
{ "path": "../shared" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -3,15 +3,27 @@
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"./local": "./src/local/index.ts",
|
||||
"./local/service": "./src/local/service.ts",
|
||||
"./local/routes/*": "./src/local/routes/*.ts"
|
||||
"./local": {
|
||||
"source": "./src/local/index.ts",
|
||||
"types": "./dist/local/index.d.ts",
|
||||
"import": "./dist/local/index.js"
|
||||
},
|
||||
"./local/service": {
|
||||
"source": "./src/local/service.ts",
|
||||
"types": "./dist/local/service.d.ts",
|
||||
"import": "./dist/local/service.js"
|
||||
},
|
||||
"./local/routes/*": {
|
||||
"source": "./src/local/routes/*.ts",
|
||||
"types": "./dist/local/routes/*.d.ts",
|
||||
"import": "./dist/local/routes/*.js"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "tsx watch src/local/start.ts",
|
||||
"dev": "tsx watch --conditions=source src/local/start.ts",
|
||||
"build": "tsc",
|
||||
"test": "node ../../node_modules/vitest/vitest.mjs run --root ../.. --config vitest.config.ts packages/server/tests --maxWorkers=1 --silent",
|
||||
"start:local": "tsx src/local/start.ts"
|
||||
"start:local": "tsx --conditions=source src/local/start.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "^0.78.0",
|
||||
|
||||
@@ -16,9 +16,15 @@
|
||||
"sourceMap": true,
|
||||
"composite": true
|
||||
},
|
||||
"references": [
|
||||
{ "path": "../shared" }
|
||||
],
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["node_modules", "dist", "tests"]
|
||||
"exclude": ["node_modules", "dist", "tests"],
|
||||
"references": [
|
||||
{ "path": "../agent" },
|
||||
{ "path": "../core" },
|
||||
{ "path": "../marketplace" },
|
||||
{ "path": "../memory-contract" },
|
||||
{ "path": "../memory-mem0" },
|
||||
{ "path": "../sdk" },
|
||||
{ "path": "../shared" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ export default defineConfig({
|
||||
* The server auto-detects <root>/dist per packages/server/src/local/
|
||||
* index.ts — no WAGGLE_FRONTEND_DIR override needed. */
|
||||
webServer: {
|
||||
command: `npm run build:all && ${e2eNodeCommand} node_modules/tsx/dist/cli.mjs packages/server/src/local/start.ts${e2eSkipLiteLLM ? ' --skip-litellm' : ''}`,
|
||||
command: `npm run build:all && ${e2eNodeCommand} node_modules/tsx/dist/cli.mjs --conditions=source packages/server/src/local/start.ts${e2eSkipLiteLLM ? ' --skip-litellm' : ''}`,
|
||||
url: new URL('/health', e2eBaseURL).toString(),
|
||||
reuseExistingServer: e2eReuseExistingServer,
|
||||
timeout: 600_000, // Cold Windows build + scanning + tsx sidecar import can exceed 5 min
|
||||
|
||||
@@ -173,23 +173,11 @@ try {
|
||||
format: 'esm',
|
||||
outfile: outFile,
|
||||
external: EXTERNAL,
|
||||
// P4/D12: workspace package metadata can resolve to gitignored dist/.
|
||||
// Alias all bundled first-party packages to their tracked source entry.
|
||||
// Without these aliases the bundle silently embeds whatever dist/ was
|
||||
// last compiled — the same stale-server-in-the-binary class D12 exists
|
||||
// to kill — and a clean checkout can't build at all without
|
||||
// build:packages. Alias to source so the bundle ALWAYS compiles from
|
||||
// src, like the vitest aliases do. Exact subpath aliases must precede
|
||||
// their package root so esbuild never appends a subpath to index.ts.
|
||||
alias: {
|
||||
'@waggle/agent/external-process-env': path.join(root, 'packages', 'agent', 'src', 'external-process-env.ts'),
|
||||
'@waggle/agent': path.join(root, 'packages', 'agent', 'src', 'index.ts'),
|
||||
'@waggle/core': path.join(root, 'packages', 'core', 'src', 'index.ts'),
|
||||
'@waggle/marketplace': path.join(root, 'packages', 'marketplace', 'src', 'index.ts'),
|
||||
'@waggle/memory-contract': path.join(root, 'packages', 'memory-contract', 'src', 'index.ts'),
|
||||
'@waggle/memory-mem0': path.join(root, 'packages', 'memory-mem0', 'src', 'index.ts'),
|
||||
'@waggle/shared': path.join(root, 'packages', 'shared', 'src', 'index.ts'),
|
||||
},
|
||||
// P4/D12: workspace packages publish dist/ entries, which are gitignored
|
||||
// and can be stale. Every first-party package also exports its source
|
||||
// under the `source` condition, so the bundle always compiles from src/
|
||||
// and a clean checkout builds without build:packages.
|
||||
conditions: ['source'],
|
||||
sourcemap: false,
|
||||
minify: true,
|
||||
// metafile lets stage-sidecar-deps.mjs enumerate exactly which of the
|
||||
|
||||
14
tsconfig.build.json
Normal file
14
tsconfig.build.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "packages/shared" },
|
||||
{ "path": "packages/memory-contract" },
|
||||
{ "path": "packages/memory-mem0" },
|
||||
{ "path": "packages/core" },
|
||||
{ "path": "packages/marketplace" },
|
||||
{ "path": "packages/sdk" },
|
||||
{ "path": "packages/agent" },
|
||||
{ "path": "packages/server" },
|
||||
{ "path": "packages/cli" }
|
||||
]
|
||||
}
|
||||
27
tsconfig.tests.json
Normal file
27
tsconfig.tests.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"customConditions": ["source"],
|
||||
"lib": ["ES2022", "DOM"],
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"resolveJsonModule": true,
|
||||
"allowImportingTsExtensions": true,
|
||||
"noEmit": true,
|
||||
"types": ["node", "vitest/globals"]
|
||||
},
|
||||
"include": [
|
||||
"packages/shared/tests/**/*.ts",
|
||||
"packages/memory-contract/tests/**/*.ts",
|
||||
"packages/memory-mem0/tests/**/*.ts",
|
||||
"packages/core/tests/**/*.ts",
|
||||
"packages/marketplace/tests/**/*.ts",
|
||||
"packages/sdk/tests/**/*.ts",
|
||||
"packages/agent/tests/**/*.ts",
|
||||
"packages/server/tests/**/*.ts",
|
||||
"packages/cli/tests/**/*.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,35 +1,36 @@
|
||||
import { readdirSync, existsSync } from 'node:fs';
|
||||
import { readdirSync, existsSync, readFileSync } from 'node:fs';
|
||||
import { resolve, join } from 'node:path';
|
||||
|
||||
/**
|
||||
* Map every `@waggle/<dir>` workspace package to its TypeScript source entry
|
||||
* (`packages/<dir>/src/index.ts`) so vitest resolves them from source without
|
||||
* a build step.
|
||||
*
|
||||
* Why: several packages (shared, all hive-mind-*, cli, mcp-server) declare a
|
||||
* `dist/` entry in package.json `exports` — correct for publishing, but on a
|
||||
* fresh checkout (including CI) `dist/` isn't built, so importing them in tests
|
||||
* fails with "Failed to resolve entry for package". Aliasing to `src/` — the
|
||||
* same trick the former inline `@waggle/marketplace` alias used — makes the test
|
||||
* environment build-independent. Packages that already export `src/` (agent,
|
||||
* core, …) resolve to the same place, so the alias is a no-op for them.
|
||||
*
|
||||
* Only packages with a real `src/index.ts` are aliased (guarded), so dirs
|
||||
* without that entry (e.g. admin-web) are left to normal resolution.
|
||||
* Resolve conditions for the test runs: workspace packages export their
|
||||
* TypeScript source under the `source` condition (P2.1), so tests run against
|
||||
* src/ without a build step, the same way tsx and the sidecar bundle do.
|
||||
*/
|
||||
export const WAGGLE_SOURCE_CONDITIONS = ['source', 'module', 'node', 'development|production'];
|
||||
|
||||
/**
|
||||
* Map the `@waggle/<dir>` packages that do not export a `source` condition to
|
||||
* their `src/` directory. Only the packages excluded from the community
|
||||
* edition (hive-mind-*, memory-mcp, wiki-compiler and the postponed team
|
||||
* packages) still need this; it goes away with them.
|
||||
*
|
||||
* The alias target is the `src/` DIRECTORY (not `src/index.ts`): vite resolves
|
||||
* a bare `@waggle/x` import to the directory's index, AND a subpath import like
|
||||
* `@waggle/server/local/service` to `…/src/local/service`. Pointing at the file
|
||||
* instead would rewrite the subpath to `…/src/index.ts/local/service` and break.
|
||||
* `@waggle/x/scope` to `…/src/scope`.
|
||||
*/
|
||||
export function waggleSrcAliases(repoRoot: string): Record<string, string> {
|
||||
const pkgsDir = resolve(repoRoot, 'packages');
|
||||
const aliases: Record<string, string> = {};
|
||||
for (const dir of readdirSync(pkgsDir)) {
|
||||
const srcDir = join(pkgsDir, dir, 'src');
|
||||
if (existsSync(join(srcDir, 'index.ts'))) {
|
||||
if (!existsSync(join(srcDir, 'index.ts')) || exportsSource(join(pkgsDir, dir, 'package.json'))) continue;
|
||||
aliases[`@waggle/${dir}`] = srcDir;
|
||||
}
|
||||
}
|
||||
return aliases;
|
||||
}
|
||||
|
||||
function exportsSource(manifestPath: string): boolean {
|
||||
if (!existsSync(manifestPath)) return false;
|
||||
const manifest = JSON.parse(readFileSync(manifestPath, 'utf-8')) as { exports?: unknown };
|
||||
return JSON.stringify(manifest.exports ?? null).includes('"source"');
|
||||
}
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
import path from 'node:path';
|
||||
import { INFRA_TEST_SUITES } from './vitest.infra-suites';
|
||||
import { waggleSrcAliases } from './vitest.aliases';
|
||||
import { WAGGLE_SOURCE_CONDITIONS, waggleSrcAliases } from './vitest.aliases';
|
||||
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
// Workspace packages resolve to src/ through their `source` export, so
|
||||
// tests need no build step (P2.1).
|
||||
conditions: WAGGLE_SOURCE_CONDITIONS,
|
||||
alias: {
|
||||
// Resolve every @waggle/* workspace package from src/ so tests don't need
|
||||
// a build step (several packages export dist/, unbuilt on fresh checkout/CI).
|
||||
// Packages without a `source` export (the excluded ones) map to src/.
|
||||
...waggleSrcAliases(__dirname),
|
||||
// App uses @/ alias for src directory
|
||||
'@/': path.resolve(__dirname, 'app/src') + '/',
|
||||
'@': path.resolve(__dirname, 'app/src'),
|
||||
},
|
||||
},
|
||||
ssr: {
|
||||
resolve: { conditions: WAGGLE_SOURCE_CONDITIONS },
|
||||
},
|
||||
test: {
|
||||
globals: true,
|
||||
// Passing tests should not bury failures under expected provider/startup
|
||||
@@ -37,6 +42,11 @@ export default defineConfig({
|
||||
// via `npm run test:infra`.
|
||||
exclude: [
|
||||
'apps/**', 'node_modules/**', '**/__faza1-closed/**',
|
||||
// Packages outside the community edition: excluded ones (ADR-0002) and
|
||||
// the postponed team runtime (ADR-0003). They are not built either.
|
||||
'packages/hive-mind-*/**', 'packages/memory-mcp/**', 'packages/wiki-compiler/**',
|
||||
'packages/team-server/**', 'packages/waggle-dance/**', 'packages/worker/**',
|
||||
'packages/weaver/**',
|
||||
...INFRA_TEST_SUITES,
|
||||
// Copies the ~13MB pre-built packages/marketplace/marketplace.db fixture
|
||||
// (createTempDb). Proper fix: regenerate it from sources-seed.ts in test
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
import path from 'node:path';
|
||||
import { INFRA_TEST_SUITES } from './vitest.infra-suites';
|
||||
import { waggleSrcAliases } from './vitest.aliases';
|
||||
import { WAGGLE_SOURCE_CONDITIONS, waggleSrcAliases } from './vitest.aliases';
|
||||
|
||||
/**
|
||||
* Infra-lane vitest config — runs ONLY the suites that require live PostgreSQL
|
||||
@@ -13,12 +13,16 @@ import { waggleSrcAliases } from './vitest.aliases';
|
||||
*/
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
conditions: WAGGLE_SOURCE_CONDITIONS,
|
||||
alias: {
|
||||
...waggleSrcAliases(__dirname),
|
||||
'@/': path.resolve(__dirname, 'app/src') + '/',
|
||||
'@': path.resolve(__dirname, 'app/src'),
|
||||
},
|
||||
},
|
||||
ssr: {
|
||||
resolve: { conditions: WAGGLE_SOURCE_CONDITIONS },
|
||||
},
|
||||
test: {
|
||||
globals: true,
|
||||
testTimeout: 30_000,
|
||||
|
||||
Reference in New Issue
Block a user