From 07785c6dbc1d94ef90a9f5e11adbb66895fbf93a Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 18 Apr 2026 18:04:16 +0100 Subject: [PATCH] build: split tsgo prod and test graphs --- .github/instructions/copilot.instructions.md | 4 ++-- AGENTS.md | 4 ++-- package.json | 7 +++++-- src/agents/compaction.test.ts | 8 ++++++-- tsconfig.prod.json | 4 ++++ tsconfig.test.json | 18 ++++++++++++++++++ 6 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 tsconfig.prod.json create mode 100644 tsconfig.test.json diff --git a/.github/instructions/copilot.instructions.md b/.github/instructions/copilot.instructions.md index 8686521cfc7..623ebcd8ccb 100644 --- a/.github/instructions/copilot.instructions.md +++ b/.github/instructions/copilot.instructions.md @@ -50,13 +50,13 @@ - Keep files under ~700 LOC - extract helpers when larger - Colocated tests: `*.test.ts` next to source files - 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 - **Package manager**: pnpm (`pnpm install`) - **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` - **Tests**: `pnpm test` - **Build**: `pnpm build` diff --git a/AGENTS.md b/AGENTS.md index 757bb48afcf..ae18d596881 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -127,7 +127,7 @@ - Node remains supported for running built output (`dist/*`) and production installs. - Mac packaging (dev): `scripts/package-mac-app.sh` defaults to current arch. - 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` - 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) @@ -146,7 +146,7 @@ - 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`. - 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. - 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. diff --git a/package.json b/package.json index 0af1beac893..08bc916121d 100644 --- a/package.json +++ b/package.json @@ -1232,7 +1232,7 @@ "canon:check:json": "node scripts/canon.mjs check --json", "canon:enforce": "node scripts/canon.mjs enforce --json", "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: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", @@ -1465,7 +1465,10 @@ "tool-display:check": "node --import tsx scripts/tool-display.ts --check", "tool-display:write": "node --import tsx scripts/tool-display.ts --write", "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:dev": "OPENCLAW_PROFILE=dev node scripts/run-node.mjs --dev tui", "ui:build": "node scripts/ui.js build", diff --git a/src/agents/compaction.test.ts b/src/agents/compaction.test.ts index 0f5648b6109..ce273e67e92 100644 --- a/src/agents/compaction.test.ts +++ b/src/agents/compaction.test.ts @@ -57,6 +57,10 @@ function makeMessages(count: number, size: number): AgentMessage[] { 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( timestamp: number, toolCallId: string, @@ -300,8 +304,8 @@ describe("pruneHistoryForContextShare", () => { const allIds = [ ...pruned.droppedMessagesList.map((m) => m.timestamp), ...pruned.messages.map((m) => m.timestamp), - ].toSorted((a, b) => a - b); - const originalIds = messages.map((m) => m.timestamp).toSorted((a, b) => a - b); + ].toSorted(compareTimestampIds); + const originalIds = messages.map((m) => m.timestamp).toSorted(compareTimestampIds); expect(allIds).toEqual(originalIds); }); diff --git a/tsconfig.prod.json b/tsconfig.prod.json new file mode 100644 index 00000000000..b61411212fb --- /dev/null +++ b/tsconfig.prod.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "exclude": ["node_modules", "dist", "**/dist/**", "**/*.test.ts", "**/*.test.tsx", "test/**"] +} diff --git a/tsconfig.test.json b/tsconfig.test.json new file mode 100644 index 00000000000..dc48349b7ba --- /dev/null +++ b/tsconfig.test.json @@ -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/**"] +}