build: split tsgo prod and test graphs

This commit is contained in:
Peter Steinberger
2026-04-18 18:04:16 +01:00
parent 753183e081
commit 07785c6dbc
6 changed files with 37 additions and 8 deletions

View File

@@ -50,13 +50,13 @@
- Keep files under ~700 LOC - extract helpers when larger - Keep files under ~700 LOC - extract helpers when larger
- Colocated tests: `*.test.ts` next to source files - Colocated tests: `*.test.ts` next to source files
- Run `pnpm check` before commits (lint + format) - Run `pnpm check` before commits (lint + format)
- Run `pnpm tsgo` for type checking - Run `pnpm tsgo` for production type checking, or `pnpm tsgo:all` for production plus test types
## Stack & Commands ## Stack & Commands
- **Package manager**: pnpm (`pnpm install`) - **Package manager**: pnpm (`pnpm install`)
- **Dev**: `pnpm openclaw ...` or `pnpm dev` - **Dev**: `pnpm openclaw ...` or `pnpm dev`
- **Type-check**: `pnpm tsgo` - **Type-check**: `pnpm tsgo` (production), `pnpm tsgo:all` (production plus tests)
- **Lint/format**: `pnpm check` - **Lint/format**: `pnpm check`
- **Tests**: `pnpm test` - **Tests**: `pnpm test`
- **Build**: `pnpm build` - **Build**: `pnpm build`

View File

@@ -127,7 +127,7 @@
- Node remains supported for running built output (`dist/*`) and production installs. - Node remains supported for running built output (`dist/*`) and production installs.
- Mac packaging (dev): `scripts/package-mac-app.sh` defaults to current arch. - Mac packaging (dev): `scripts/package-mac-app.sh` defaults to current arch.
- Type-check/build: `pnpm build` - Type-check/build: `pnpm build`
- TypeScript checks: `pnpm tsgo` - TypeScript checks: `pnpm tsgo` (prod graph), `pnpm tsgo:test` (test graph), `pnpm tsgo:all` (both; used by `pnpm check`)
- Lint/format: `pnpm check` - Lint/format: `pnpm check`
- Local agent/dev shells default to host-aware `OPENCLAW_LOCAL_CHECK=1` behavior for `pnpm tsgo` and `pnpm lint`; set `OPENCLAW_LOCAL_CHECK_MODE=throttled` to force the lower-memory profile, `OPENCLAW_LOCAL_CHECK_MODE=full` to keep lock-only behavior, or `OPENCLAW_LOCAL_CHECK=0` in CI/shared runs. - Local agent/dev shells default to host-aware `OPENCLAW_LOCAL_CHECK=1` behavior for `pnpm tsgo` and `pnpm lint`; set `OPENCLAW_LOCAL_CHECK_MODE=throttled` to force the lower-memory profile, `OPENCLAW_LOCAL_CHECK_MODE=full` to keep lock-only behavior, or `OPENCLAW_LOCAL_CHECK=0` in CI/shared runs.
- Format check: `pnpm format:check` (oxfmt --check) - Format check: `pnpm format:check` (oxfmt --check)
@@ -146,7 +146,7 @@
- Config schema drift uses `pnpm config:docs:gen` / `pnpm config:docs:check`. - Config schema drift uses `pnpm config:docs:gen` / `pnpm config:docs:check`.
- Plugin SDK API drift uses `pnpm plugin-sdk:api:gen` / `pnpm plugin-sdk:api:check`. - Plugin SDK API drift uses `pnpm plugin-sdk:api:gen` / `pnpm plugin-sdk:api:check`.
- If you change config schema/help or the public Plugin SDK surface, run the matching gen command and commit the updated `.sha256` hash file. Keep the two drift-check flows adjacent in scripts/workflows/docs guidance rather than inventing a third pattern. - If you change config schema/help or the public Plugin SDK surface, run the matching gen command and commit the updated `.sha256` hash file. Keep the two drift-check flows adjacent in scripts/workflows/docs guidance rather than inventing a third pattern.
- When `pnpm tsgo` fails, triage by coherent surface instead of by raw error count: rerun the gate, group failures by package/module/type contract, open the source-of-truth type or export file first, fix the root mismatch, then rerun `pnpm tsgo` before widening into downstream consumers. Check `origin/main` before doing broad cleanup because some apparent type debt is already fixed upstream. - When `pnpm tsgo` or `pnpm tsgo:test` fails, triage by coherent surface instead of by raw error count: rerun the failing graph, group failures by package/module/type contract, open the source-of-truth type or export file first, fix the root mismatch, then rerun the failing graph before widening into downstream consumers. Check `origin/main` before doing broad cleanup because some apparent type debt is already fixed upstream.
- For narrowly scoped changes, prefer narrowly scoped tests that directly validate the touched behavior. If no meaningful scoped test exists, say so explicitly and use the next most direct validation available. - For narrowly scoped changes, prefer narrowly scoped tests that directly validate the touched behavior. If no meaningful scoped test exists, say so explicitly and use the next most direct validation available.
- Verification modes for work on `main`: - Verification modes for work on `main`:
- Default mode: `main` is relatively stable. Count pre-commit hook coverage when it already verified the current tree, avoid rerunning the exact same checks just for ceremony, and prefer keeping CI/main green before landing. - Default mode: `main` is relatively stable. Count pre-commit hook coverage when it already verified the current tree, avoid rerunning the exact same checks just for ceremony, and prefer keeping CI/main green before landing.

View File

@@ -1232,7 +1232,7 @@
"canon:check:json": "node scripts/canon.mjs check --json", "canon:check:json": "node scripts/canon.mjs check --json",
"canon:enforce": "node scripts/canon.mjs enforce --json", "canon:enforce": "node scripts/canon.mjs enforce --json",
"canvas:a2ui:bundle": "node scripts/bundle-a2ui.mjs", "canvas:a2ui:bundle": "node scripts/bundle-a2ui.mjs",
"check": "pnpm check:no-conflict-markers && pnpm tool-display:check && pnpm check:host-env-policy:swift && pnpm tsgo && pnpm lint && pnpm lint:webhook:no-low-level-body-read && pnpm lint:auth:no-pairing-store-group && pnpm lint:auth:pairing-account-scope && pnpm check:import-cycles && pnpm check:madge-import-cycles", "check": "pnpm check:no-conflict-markers && pnpm tool-display:check && pnpm check:host-env-policy:swift && pnpm tsgo:all && pnpm lint && pnpm lint:webhook:no-low-level-body-read && pnpm lint:auth:no-pairing-store-group && pnpm lint:auth:pairing-account-scope && pnpm check:import-cycles && pnpm check:madge-import-cycles",
"check:base-config-schema": "node --import tsx scripts/generate-base-config-schema.ts --check", "check:base-config-schema": "node --import tsx scripts/generate-base-config-schema.ts --check",
"check:bundled-channel-config-metadata": "node --import tsx scripts/generate-bundled-channel-config-metadata.ts --check", "check:bundled-channel-config-metadata": "node --import tsx scripts/generate-bundled-channel-config-metadata.ts --check",
"check:docs": "pnpm format:docs:check && pnpm lint:docs && pnpm docs:check-i18n-glossary && pnpm docs:check-links", "check:docs": "pnpm format:docs:check && pnpm lint:docs && pnpm docs:check-i18n-glossary && pnpm docs:check-links",
@@ -1465,7 +1465,10 @@
"tool-display:check": "node --import tsx scripts/tool-display.ts --check", "tool-display:check": "node --import tsx scripts/tool-display.ts --check",
"tool-display:write": "node --import tsx scripts/tool-display.ts --write", "tool-display:write": "node --import tsx scripts/tool-display.ts --write",
"ts-topology": "node --import tsx scripts/ts-topology.ts", "ts-topology": "node --import tsx scripts/ts-topology.ts",
"tsgo": "node scripts/run-tsgo.mjs", "tsgo": "pnpm tsgo:prod",
"tsgo:all": "pnpm tsgo:prod && pnpm tsgo:test",
"tsgo:prod": "node scripts/run-tsgo.mjs -p tsconfig.prod.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/prod.tsbuildinfo",
"tsgo:test": "node scripts/run-tsgo.mjs -p tsconfig.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/test.tsbuildinfo",
"tui": "node scripts/run-node.mjs tui", "tui": "node scripts/run-node.mjs tui",
"tui:dev": "OPENCLAW_PROFILE=dev node scripts/run-node.mjs --dev tui", "tui:dev": "OPENCLAW_PROFILE=dev node scripts/run-node.mjs --dev tui",
"ui:build": "node scripts/ui.js build", "ui:build": "node scripts/ui.js build",

View File

@@ -57,6 +57,10 @@ function makeMessages(count: number, size: number): AgentMessage[] {
return Array.from({ length: count }, (_, index) => makeMessage(index + 1, size)); return Array.from({ length: count }, (_, index) => makeMessage(index + 1, size));
} }
function compareTimestampIds(left: AgentMessage["timestamp"], right: AgentMessage["timestamp"]) {
return left < right ? -1 : left > right ? 1 : 0;
}
function makeAssistantToolCall( function makeAssistantToolCall(
timestamp: number, timestamp: number,
toolCallId: string, toolCallId: string,
@@ -300,8 +304,8 @@ describe("pruneHistoryForContextShare", () => {
const allIds = [ const allIds = [
...pruned.droppedMessagesList.map((m) => m.timestamp), ...pruned.droppedMessagesList.map((m) => m.timestamp),
...pruned.messages.map((m) => m.timestamp), ...pruned.messages.map((m) => m.timestamp),
].toSorted((a, b) => a - b); ].toSorted(compareTimestampIds);
const originalIds = messages.map((m) => m.timestamp).toSorted((a, b) => a - b); const originalIds = messages.map((m) => m.timestamp).toSorted(compareTimestampIds);
expect(allIds).toEqual(originalIds); expect(allIds).toEqual(originalIds);
}); });

4
tsconfig.prod.json Normal file
View File

@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "dist", "**/dist/**", "**/*.test.ts", "**/*.test.tsx", "test/**"]
}

18
tsconfig.test.json Normal file
View File

@@ -0,0 +1,18 @@
{
"extends": "./tsconfig.json",
"include": [
"src/**/*.d.ts",
"src/**/*.test.ts",
"src/**/*.test.tsx",
"ui/**/*.d.ts",
"ui/**/*.test.ts",
"ui/**/*.test.tsx",
"extensions/**/*.d.ts",
"extensions/**/*.test.ts",
"extensions/**/*.test.tsx",
"packages/**/*.d.ts",
"packages/**/*.test.ts",
"packages/**/*.test.tsx"
],
"exclude": ["node_modules", "dist", "**/dist/**"]
}