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:
73
.github/workflows/ci.yml
vendored
73
.github/workflows/ci.yml
vendored
@@ -6,14 +6,20 @@ on:
|
|||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
# Runs on the three desktop platforms of the community edition (P1.3b, P2.1).
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# The Node version the installer and the desktop app ship (ADR-0008).
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 22.23.2
|
||||||
|
|
||||||
- name: Cache npm dependencies
|
- name: Cache npm dependencies
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
@@ -23,24 +29,23 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-npm-
|
${{ 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
|
- run: npm install
|
||||||
|
env:
|
||||||
|
ONNXRUNTIME_NODE_INSTALL_CUDA: skip
|
||||||
|
|
||||||
# Real typecheck gate. The old step ran `npx tsc --noEmit` against the root
|
# One `tsc -b` over the project references in tsconfig.build.json: every
|
||||||
# tsconfig.json, whose `"files": ["apps/web/src/vite-env.d.ts"]` (and no
|
# in-scope @waggle/* package, in dependency order.
|
||||||
# `include`) typechecks essentially nothing. build:packages is the actual
|
- name: Type check — workspace packages (tsc -b)
|
||||||
# `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)
|
|
||||||
run: npm run build:packages
|
run: npm run build:packages
|
||||||
|
|
||||||
- name: Type check — web (apps/web, tsc -p tsconfig.app.json)
|
- name: Type check — web (apps/web, tsc -p tsconfig.app.json)
|
||||||
run: npm run typecheck:web
|
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)
|
- name: Lint (root flat config)
|
||||||
run: npm run lint
|
run: npm run lint
|
||||||
|
|
||||||
@@ -54,39 +59,31 @@ jobs:
|
|||||||
# dist/ payload explicitly so CI proves a fresh checkout.
|
# dist/ payload explicitly so CI proves a fresh checkout.
|
||||||
- name: Build package-install test runtimes
|
- name: Build package-install test runtimes
|
||||||
run: |
|
run: |
|
||||||
npm run build:hook-runtime
|
|
||||||
npm run build --workspace @waggle/cli
|
npm run build --workspace @waggle/cli
|
||||||
npm run build --workspace @waggle-ai/waggle
|
npm run build --workspace @waggle-ai/waggle
|
||||||
npm run build --workspace waggle-memory-mcp
|
|
||||||
|
|
||||||
- name: Unit tests — packages + cross-cutting (root vitest)
|
- name: Unit tests — packages + cross-cutting (root vitest)
|
||||||
run: |
|
run: >-
|
||||||
npm test -- \
|
npm test --
|
||||||
--exclude=packages/cli/tests/cli-runtime.test.ts \
|
--exclude=packages/cli/tests/cli-runtime.test.ts
|
||||||
--exclude=packages/marketplace/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/launcher/tests/cli.test.ts
|
||||||
--exclude=packages/hive-mind-mcp-server/tests/runtime.test.ts \
|
--maxWorkers=2
|
||||||
--exclude=packages/launcher/tests/cli.test.ts \
|
|
||||||
--exclude=packages/memory-mcp/tests/runtime.test.ts \
|
|
||||||
--maxWorkers=2
|
|
||||||
|
|
||||||
# These tests each create a temporary project and run npm install. Running
|
# These tests each create a temporary project and run npm install. Running
|
||||||
# several cold installs in parallel makes individual test timeouts measure
|
# several cold installs in parallel makes individual test timeouts measure
|
||||||
# runner contention rather than package correctness.
|
# runner contention rather than package correctness.
|
||||||
- name: Package-install runtime tests (serial)
|
- name: Package-install runtime tests (serial)
|
||||||
run: |
|
run: >-
|
||||||
npx vitest run \
|
npx vitest run
|
||||||
packages/cli/tests/cli-runtime.test.ts \
|
packages/cli/tests/cli-runtime.test.ts
|
||||||
packages/marketplace/tests/cli-runtime.test.ts \
|
packages/marketplace/tests/cli-runtime.test.ts
|
||||||
packages/hive-mind-cli/tests/cli-help.test.ts \
|
packages/launcher/tests/cli.test.ts
|
||||||
packages/hive-mind-mcp-server/tests/runtime.test.ts \
|
--maxWorkers=1
|
||||||
packages/launcher/tests/cli.test.ts \
|
--no-file-parallelism
|
||||||
packages/memory-mcp/tests/runtime.test.ts \
|
|
||||||
--maxWorkers=1 \
|
|
||||||
--no-file-parallelism
|
|
||||||
|
|
||||||
# The root vitest.config.ts excludes `apps/**`, so apps/web's own 131-file
|
# The root vitest.config.ts excludes `apps/**`; apps/web runs its own
|
||||||
# suite never ran in CI. Run it via its own vitest config (jsdom). Blocking.
|
# suite (jsdom).
|
||||||
- name: Unit tests — apps/web
|
- name: Unit tests — apps/web
|
||||||
run: npm run test -w apps/web
|
run: npm run test -w apps/web
|
||||||
|
|
||||||
@@ -110,7 +107,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 22.23.2
|
||||||
|
|
||||||
- name: Cache npm dependencies
|
- name: Cache npm dependencies
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
@@ -143,7 +140,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 22.23.2
|
||||||
|
|
||||||
- name: Cache npm dependencies
|
- name: Cache npm dependencies
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
|
|||||||
@@ -621,7 +621,12 @@ fn build_service_command(
|
|||||||
|
|
||||||
let mut cmd = if service_script.kind == ServiceScriptKind::DevSource {
|
let mut cmd = if service_script.kind == ServiceScriptKind::DevSource {
|
||||||
let mut c = Command::new(&node_path);
|
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
|
c
|
||||||
} else {
|
} else {
|
||||||
let mut c = Command::new(&node_path);
|
let mut c = Command::new(&node_path);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"moduleDetection": "force",
|
"moduleDetection": "force",
|
||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
|
"customConditions": ["source"],
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"noFallthroughCasesInSwitch": false,
|
"noFallthroughCasesInSwitch": false,
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { defineConfig } from "vite";
|
import { defineConfig, defaultClientConditions } from "vite";
|
||||||
import react from "@vitejs/plugin-react-swc";
|
import react from "@vitejs/plugin-react-swc";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { componentTagger } from "lovable-tagger";
|
import { componentTagger } from "lovable-tagger";
|
||||||
@@ -47,6 +47,9 @@ export default defineConfig(({ mode }) => ({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
resolve: {
|
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: {
|
alias: {
|
||||||
"@": path.resolve(__dirname, "./src"),
|
"@": path.resolve(__dirname, "./src"),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { defineConfig } from "vitest/config";
|
import { defineConfig } from "vitest/config";
|
||||||
|
import { defaultClientConditions } from "vite";
|
||||||
import react from "@vitejs/plugin-react-swc";
|
import react from "@vitejs/plugin-react-swc";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ export default defineConfig({
|
|||||||
retry: 1,
|
retry: 1,
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
|
conditions: ["source", ...defaultClientConditions],
|
||||||
alias: { "@": path.resolve(__dirname, "./src") },
|
alias: { "@": path.resolve(__dirname, "./src") },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,12 +14,13 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "cd apps/web && npx vite",
|
"dev": "cd apps/web && npx vite",
|
||||||
"dev:web": "npm run dev",
|
"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": "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",
|
"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: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",
|
"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:hook-runtime": "node scripts/build-hook-runtime.mjs",
|
||||||
"build:all": "npm run build:packages && npm run build",
|
"build:all": "npm run build:packages && npm run build",
|
||||||
"dev:www": "npm run dev -w apps/www",
|
"dev:www": "npm run dev -w apps/www",
|
||||||
|
|||||||
@@ -7,16 +7,19 @@
|
|||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
"source": "./src/index.ts",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"import": "./dist/index.js"
|
"import": "./dist/index.js"
|
||||||
},
|
},
|
||||||
"./external-process-env": {
|
"./external-process-env": {
|
||||||
|
"source": "./src/external-process-env.ts",
|
||||||
"types": "./dist/external-process-env.d.ts",
|
"types": "./dist/external-process-env.d.ts",
|
||||||
"import": "./dist/external-process-env.js"
|
"import": "./dist/external-process-env.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist",
|
||||||
|
"src"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc --build --force && node ../../scripts/stage-agent-pptx-runtime.mjs",
|
"build": "tsc --build --force && node ../../scripts/stage-agent-pptx-runtime.mjs",
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
"exclude": ["node_modules", "dist", "tests"],
|
"exclude": ["node_modules", "dist", "tests"],
|
||||||
"references": [
|
"references": [
|
||||||
{ "path": "../core" },
|
{ "path": "../core" },
|
||||||
{ "path": "../memory-contract" }
|
{ "path": "../marketplace" },
|
||||||
|
{ "path": "../memory-contract" },
|
||||||
|
{ "path": "../shared" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
"source": "./src/index.ts",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"import": "./dist/index.js"
|
"import": "./dist/index.js"
|
||||||
}
|
}
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist",
|
"dist",
|
||||||
|
"src",
|
||||||
"bin"
|
"bin"
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -46,7 +48,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"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",
|
"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": {
|
"dependencies": {
|
||||||
"@waggle/core": "*",
|
"@waggle/core": "*",
|
||||||
|
|||||||
@@ -19,8 +19,8 @@
|
|||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
"exclude": ["node_modules", "dist", "tests"],
|
"exclude": ["node_modules", "dist", "tests"],
|
||||||
"references": [
|
"references": [
|
||||||
{ "path": "../core" },
|
|
||||||
{ "path": "../agent" },
|
{ "path": "../agent" },
|
||||||
|
{ "path": "../core" },
|
||||||
{ "path": "../memory-contract" },
|
{ "path": "../memory-contract" },
|
||||||
{ "path": "../memory-mem0" }
|
{ "path": "../memory-mem0" }
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
"source": "./src/index.ts",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"import": "./dist/index.js"
|
"import": "./dist/index.js"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
"exclude": ["node_modules", "dist", "tests"],
|
"exclude": ["node_modules", "dist", "tests"],
|
||||||
"references": [
|
"references": [
|
||||||
{ "path": "../memory-contract" }
|
{ "path": "../memory-contract" },
|
||||||
|
{ "path": "../shared" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsup",
|
"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",
|
"test": "node ../../node_modules/vitest/vitest.mjs run --root ../.. --config vitest.config.ts packages/launcher/tests/cli.test.ts",
|
||||||
"prepublishOnly": "npm run build"
|
"prepublishOnly": "npm run build"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ export default defineConfig({
|
|||||||
// Inline all @waggle/* workspace packages into the bundle.
|
// Inline all @waggle/* workspace packages into the bundle.
|
||||||
// Third-party npm packages stay external (installed as dependencies).
|
// Third-party npm packages stay external (installed as dependencies).
|
||||||
noExternal: [/^@waggle\//],
|
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.
|
// Runtime packages that cannot be bundled safely.
|
||||||
external: [
|
external: [
|
||||||
'@huggingface/transformers',
|
'@huggingface/transformers',
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
"source": "./src/index.ts",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"import": "./dist/index.js"
|
"import": "./dist/index.js"
|
||||||
}
|
}
|
||||||
@@ -41,6 +42,7 @@
|
|||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/",
|
"dist/",
|
||||||
|
"src/",
|
||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -113,9 +113,11 @@ describe('marketplace CLI runtime UX', () => {
|
|||||||
expect(pkg.main).toBe('dist/index.js');
|
expect(pkg.main).toBe('dist/index.js');
|
||||||
expect(pkg.types).toBe('dist/index.d.ts');
|
expect(pkg.types).toBe('dist/index.d.ts');
|
||||||
expect(pkg.exports['.']).toEqual({
|
expect(pkg.exports['.']).toEqual({
|
||||||
|
source: './src/index.ts',
|
||||||
import: './dist/index.js',
|
import: './dist/index.js',
|
||||||
types: './dist/index.d.ts',
|
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.js')).toBe(true);
|
||||||
expect(packedFiles.has('dist/index.d.ts')).toBe(true);
|
expect(packedFiles.has('dist/index.d.ts')).toBe(true);
|
||||||
expect(packedFiles.has('dist/cli.js')).toBe(true);
|
expect(packedFiles.has('dist/cli.js')).toBe(true);
|
||||||
|
|||||||
@@ -14,7 +14,8 @@
|
|||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true
|
"isolatedModules": true,
|
||||||
|
"composite": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
"exclude": ["node_modules", "dist"]
|
"exclude": ["node_modules", "dist"]
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
"source": "./src/index.ts",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"import": "./dist/index.js"
|
"import": "./dist/index.js"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
"source": "./src/index.ts",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"import": "./dist/index.js"
|
"import": "./dist/index.js"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,5 +17,8 @@
|
|||||||
"composite": true
|
"composite": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"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",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": {
|
||||||
|
"source": "./src/index.ts",
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"import": "./dist/index.js"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -17,5 +17,8 @@
|
|||||||
"composite": true
|
"composite": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
"exclude": ["node_modules", "dist", "tests"]
|
"exclude": ["node_modules", "dist", "tests"],
|
||||||
|
"references": [
|
||||||
|
{ "path": "../shared" }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,27 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
"./local": "./src/local/index.ts",
|
"./local": {
|
||||||
"./local/service": "./src/local/service.ts",
|
"source": "./src/local/index.ts",
|
||||||
"./local/routes/*": "./src/local/routes/*.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": {
|
"scripts": {
|
||||||
"dev": "tsx watch src/local/start.ts",
|
"dev": "tsx watch --conditions=source src/local/start.ts",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"test": "node ../../node_modules/vitest/vitest.mjs run --root ../.. --config vitest.config.ts packages/server/tests --maxWorkers=1 --silent",
|
"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": {
|
"dependencies": {
|
||||||
"@anthropic-ai/sdk": "^0.78.0",
|
"@anthropic-ai/sdk": "^0.78.0",
|
||||||
|
|||||||
@@ -16,9 +16,15 @@
|
|||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"composite": true
|
"composite": true
|
||||||
},
|
},
|
||||||
"references": [
|
|
||||||
{ "path": "../shared" }
|
|
||||||
],
|
|
||||||
"include": ["src/**/*.ts"],
|
"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",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
"source": "./src/index.ts",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"import": "./dist/index.js"
|
"import": "./dist/index.js"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export default defineConfig({
|
|||||||
* The server auto-detects <root>/dist per packages/server/src/local/
|
* The server auto-detects <root>/dist per packages/server/src/local/
|
||||||
* index.ts — no WAGGLE_FRONTEND_DIR override needed. */
|
* index.ts — no WAGGLE_FRONTEND_DIR override needed. */
|
||||||
webServer: {
|
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(),
|
url: new URL('/health', e2eBaseURL).toString(),
|
||||||
reuseExistingServer: e2eReuseExistingServer,
|
reuseExistingServer: e2eReuseExistingServer,
|
||||||
timeout: 600_000, // Cold Windows build + scanning + tsx sidecar import can exceed 5 min
|
timeout: 600_000, // Cold Windows build + scanning + tsx sidecar import can exceed 5 min
|
||||||
|
|||||||
@@ -173,23 +173,11 @@ try {
|
|||||||
format: 'esm',
|
format: 'esm',
|
||||||
outfile: outFile,
|
outfile: outFile,
|
||||||
external: EXTERNAL,
|
external: EXTERNAL,
|
||||||
// P4/D12: workspace package metadata can resolve to gitignored dist/.
|
// P4/D12: workspace packages publish dist/ entries, which are gitignored
|
||||||
// Alias all bundled first-party packages to their tracked source entry.
|
// and can be stale. Every first-party package also exports its source
|
||||||
// Without these aliases the bundle silently embeds whatever dist/ was
|
// under the `source` condition, so the bundle always compiles from src/
|
||||||
// last compiled — the same stale-server-in-the-binary class D12 exists
|
// and a clean checkout builds without build:packages.
|
||||||
// to kill — and a clean checkout can't build at all without
|
conditions: ['source'],
|
||||||
// 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'),
|
|
||||||
},
|
|
||||||
sourcemap: false,
|
sourcemap: false,
|
||||||
minify: true,
|
minify: true,
|
||||||
// metafile lets stage-sidecar-deps.mjs enumerate exactly which of the
|
// 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';
|
import { resolve, join } from 'node:path';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map every `@waggle/<dir>` workspace package to its TypeScript source entry
|
* Resolve conditions for the test runs: workspace packages export their
|
||||||
* (`packages/<dir>/src/index.ts`) so vitest resolves them from source without
|
* TypeScript source under the `source` condition (P2.1), so tests run against
|
||||||
* a build step.
|
* src/ without a build step, the same way tsx and the sidecar bundle do.
|
||||||
*
|
*/
|
||||||
* Why: several packages (shared, all hive-mind-*, cli, mcp-server) declare a
|
export const WAGGLE_SOURCE_CONDITIONS = ['source', 'module', 'node', 'development|production'];
|
||||||
* `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
|
* Map the `@waggle/<dir>` packages that do not export a `source` condition to
|
||||||
* same trick the former inline `@waggle/marketplace` alias used — makes the test
|
* their `src/` directory. Only the packages excluded from the community
|
||||||
* environment build-independent. Packages that already export `src/` (agent,
|
* edition (hive-mind-*, memory-mcp, wiki-compiler and the postponed team
|
||||||
* core, …) resolve to the same place, so the alias is a no-op for them.
|
* packages) still need this; it goes away with 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.
|
|
||||||
*
|
*
|
||||||
* The alias target is the `src/` DIRECTORY (not `src/index.ts`): vite resolves
|
* 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
|
* 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
|
* `@waggle/x/scope` to `…/src/scope`.
|
||||||
* instead would rewrite the subpath to `…/src/index.ts/local/service` and break.
|
|
||||||
*/
|
*/
|
||||||
export function waggleSrcAliases(repoRoot: string): Record<string, string> {
|
export function waggleSrcAliases(repoRoot: string): Record<string, string> {
|
||||||
const pkgsDir = resolve(repoRoot, 'packages');
|
const pkgsDir = resolve(repoRoot, 'packages');
|
||||||
const aliases: Record<string, string> = {};
|
const aliases: Record<string, string> = {};
|
||||||
for (const dir of readdirSync(pkgsDir)) {
|
for (const dir of readdirSync(pkgsDir)) {
|
||||||
const srcDir = join(pkgsDir, dir, 'src');
|
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;
|
aliases[`@waggle/${dir}`] = srcDir;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return aliases;
|
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 { defineConfig } from 'vitest/config';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { INFRA_TEST_SUITES } from './vitest.infra-suites';
|
import { INFRA_TEST_SUITES } from './vitest.infra-suites';
|
||||||
import { waggleSrcAliases } from './vitest.aliases';
|
import { WAGGLE_SOURCE_CONDITIONS, waggleSrcAliases } from './vitest.aliases';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
resolve: {
|
resolve: {
|
||||||
|
// Workspace packages resolve to src/ through their `source` export, so
|
||||||
|
// tests need no build step (P2.1).
|
||||||
|
conditions: WAGGLE_SOURCE_CONDITIONS,
|
||||||
alias: {
|
alias: {
|
||||||
// Resolve every @waggle/* workspace package from src/ so tests don't need
|
// Packages without a `source` export (the excluded ones) map to src/.
|
||||||
// a build step (several packages export dist/, unbuilt on fresh checkout/CI).
|
|
||||||
...waggleSrcAliases(__dirname),
|
...waggleSrcAliases(__dirname),
|
||||||
// App uses @/ alias for src directory
|
// App uses @/ alias for src directory
|
||||||
'@/': path.resolve(__dirname, 'app/src') + '/',
|
'@/': path.resolve(__dirname, 'app/src') + '/',
|
||||||
'@': path.resolve(__dirname, 'app/src'),
|
'@': path.resolve(__dirname, 'app/src'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
ssr: {
|
||||||
|
resolve: { conditions: WAGGLE_SOURCE_CONDITIONS },
|
||||||
|
},
|
||||||
test: {
|
test: {
|
||||||
globals: true,
|
globals: true,
|
||||||
// Passing tests should not bury failures under expected provider/startup
|
// Passing tests should not bury failures under expected provider/startup
|
||||||
@@ -37,6 +42,11 @@ export default defineConfig({
|
|||||||
// via `npm run test:infra`.
|
// via `npm run test:infra`.
|
||||||
exclude: [
|
exclude: [
|
||||||
'apps/**', 'node_modules/**', '**/__faza1-closed/**',
|
'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,
|
...INFRA_TEST_SUITES,
|
||||||
// Copies the ~13MB pre-built packages/marketplace/marketplace.db fixture
|
// Copies the ~13MB pre-built packages/marketplace/marketplace.db fixture
|
||||||
// (createTempDb). Proper fix: regenerate it from sources-seed.ts in test
|
// (createTempDb). Proper fix: regenerate it from sources-seed.ts in test
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { defineConfig } from 'vitest/config';
|
import { defineConfig } from 'vitest/config';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { INFRA_TEST_SUITES } from './vitest.infra-suites';
|
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
|
* Infra-lane vitest config — runs ONLY the suites that require live PostgreSQL
|
||||||
@@ -13,12 +13,16 @@ import { waggleSrcAliases } from './vitest.aliases';
|
|||||||
*/
|
*/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
resolve: {
|
resolve: {
|
||||||
|
conditions: WAGGLE_SOURCE_CONDITIONS,
|
||||||
alias: {
|
alias: {
|
||||||
...waggleSrcAliases(__dirname),
|
...waggleSrcAliases(__dirname),
|
||||||
'@/': path.resolve(__dirname, 'app/src') + '/',
|
'@/': path.resolve(__dirname, 'app/src') + '/',
|
||||||
'@': path.resolve(__dirname, 'app/src'),
|
'@': path.resolve(__dirname, 'app/src'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
ssr: {
|
||||||
|
resolve: { conditions: WAGGLE_SOURCE_CONDITIONS },
|
||||||
|
},
|
||||||
test: {
|
test: {
|
||||||
globals: true,
|
globals: true,
|
||||||
testTimeout: 30_000,
|
testTimeout: 30_000,
|
||||||
|
|||||||
Reference in New Issue
Block a user