From 20773e12bd8f9757b0a99a4fc7b0b8103f6a8d4e Mon Sep 17 00:00:00 2001 From: imccyu Date: Wed, 17 Jun 2026 23:16:15 +0800 Subject: [PATCH 01/21] docs: add ADR TSC-first Build and One TSConfig --- docs/rfc/README.md | 1 + .../implemented/2026-06-20-ts-build-config.md | 67 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 docs/rfc/implemented/2026-06-20-ts-build-config.md diff --git a/docs/rfc/README.md b/docs/rfc/README.md index 48e99d37b8..88406034d5 100644 --- a/docs/rfc/README.md +++ b/docs/rfc/README.md @@ -60,6 +60,7 @@ Do NOT write one for a mechanical or local choice (a variable name, a one-file r | [Rich ACP bash rendering — the terminal card (`_meta`) and command classification](implemented/2026-06-18-acp-terminal-and-tool-rendering.md) | 2026-06-18 | | [ACP snapshot tests — record-once / replay-deterministic](implemented/2026-06-19-acp-snapshot-tests.md) | 2026-06-19 | | [Real-API e2e in CI against the external DeepSeek API](implemented/2026-06-19-real-api-e2e-ci.md) | 2026-06-19 | +| [TSC-first build and one tsconfig](implemented/2026-06-20-ts-build-config.md) | 2026-06-20 | ## Rejected diff --git a/docs/rfc/implemented/2026-06-20-ts-build-config.md b/docs/rfc/implemented/2026-06-20-ts-build-config.md new file mode 100644 index 0000000000..ab56b07e83 --- /dev/null +++ b/docs/rfc/implemented/2026-06-20-ts-build-config.md @@ -0,0 +1,67 @@ +# RFC: TSC-first build and one tsconfig + +Status: implemented (accepted 2026-06-20) + + + +## Context + +The current TypeScript build and typecheck setup had these issues: + +- `build` used `tsc` to transform `.ts` to `.d.ts` files for `packages/*` and `vendor/*`, and then used `tsdown` to transform `.ts` to bundled `.js` files. This made two tools do TypeScript transform. +- `typecheck` tended to validate packages, vendor source, examples, tests, and scripts through one root typecheck config. + +The goal is to make build and typecheck use matching tsconfig boundaries and TypeScript resolution/transform behavior. Build should generate `.js`, `.d.ts`, `.js.map`, and `.d.ts.map` through one compiler and config, so publish output and type validation stay consistent. + +Validation found several concrete technical issues and possible routes: + +- `tsdown` uses `oxc` to transform TypeScript, which is not the same behavior as `tsc`. + - Bundled `.d.ts` emitted by `tsdown` conflicts with Cordis' internal relative module augmentation shape. + - The tsc output is affected by `allowImportingTsExtensions`, so we need to ensure that generated `.js` files do not import `.ts` files and generated `.d.ts` files do not import `.js` files. Therefore, we need to adjust the import specifiers to extensionless in the TypeScript source. + - Bundled `.js` emitted by `tsdown` is not the same behavior as per-file `.js` emitted by `tsc -b`, such as decorator transform behavior. +- `vendor/*/src`, examples, tests, and scripts cannot all be plain-included in one root strict program. + - Directly typechecking `vendor/*/src` under the root strict config triggers many type errors outside this project's ownership. + - `package/*` dependencies on `vendor` are resolved to the `vendor/*/lib` for different tsconfig strictness. + + +## Decision + +In-package relative imports are extensionless. + +`pnpm run build` is a two-stage build: + +- Stage 1: `tsc -b tsconfig.build.json` emits publishable per-module `.js`, declarations `.d.ts`, JS sourcemaps `.js.map`, and declaration sourcemaps `.d.ts.map` into each package's `lib/typings`. This is the authoritative TypeScript compilation result. For publish we should keep `.d.ts` and ignore `.js` / `.js.map` / `.d.ts.map` + - The build project uses the project-reference graph that `tsc -b` compiles. For example, root `tsconfig.build.json` references package and vendor tsconfigs. It validates and emits package/vendor build results. +- Stage 2: a bundler reads the emitted JS under `lib/typings` and writes the bundled runtime entry as `lib/index.js` or `lib/index.mjs` (follow current behavior). This stage is bundling only. It must not read TypeScript source or emit declarations. + +`tsdown` is no longer the owner of TypeScript compilation or declaration output. + +`pnpm run typecheck` runs build mode over the root `tsconfig.json`. +- The root `tsconfig.json` is the single development/typecheck project. It has `noEmit` for demos, examples, tests, and scripts, and validates package/vendor source through references. +- Referenced package/vendor projects keep the same emit behavior as build, so typecheck can refresh their `lib/typings` outputs instead of using a separate no-emit graph. Project-specific strictness changes live in the owning `packages/*/tsconfig.json` or `vendor/*/tsconfig.json`. + +The command orchestration shape is: + +```sh +pnpm run build: +tsc -b tsconfig.build.json +tsdown + +pnpm run typecheck: +tsc -b tsconfig.json +``` + +`pnpm run demo:*` still runs `src` directly through tsx and root paths, without a compile step. + +## Consequences + +Build responsibilities are clearer: + +- Each module under `packages/*` and `vendor/*` has one local tsconfig for build, typecheck, and tools that run source directly, such as `tsx` and `vitest`. +- The `build` command uses `tsconfig.build.json`. `tsc -b` owns the publishable per-module `.js` and `.d.ts` output, and the bundler owns only `lib/index.*`. + - `lib/typings/*.d.ts` is the publish declaration output. + - `lib/typings/*.js` is only a bundler input and must not be used as a runtime entry or public import target. + - `lib/index.*` is the publish runtime output and is generated by the bundler, currently `tsdown`. +- The `typecheck` command uses `tsconfig.json`. Examples, tests, and scripts are checked by the root no-emit project, while packages and vendor modules keep the same emit behavior as `build`. Package and vendor source stays behind project-reference boundaries. + +The Cordis vendor copy now has one more type-structure divergence from upstream. During upstream sync, that divergence must be reapplied or explicitly retired. From 6f6e0517d452c5bce3cc06e5c7f7387e56cf43dc Mon Sep 17 00:00:00 2001 From: imccyu Date: Wed, 17 Jun 2026 23:17:38 +0800 Subject: [PATCH 02/21] refactor: ts in packages use extensionless import --- packages/acp/src/index.ts | 2 +- packages/agent-loop/src/agent.ts | 4 ++-- packages/agent-loop/src/index.ts | 8 ++++---- packages/agent-loop/src/loop.ts | 2 +- packages/agent/src/index.ts | 4 ++-- packages/bash-local/src/index.ts | 8 ++++---- packages/bash/src/index.ts | 4 ++-- packages/llm-deepseek/src/adapter.ts | 10 +++++----- packages/llm-deepseek/src/index.ts | 16 ++++++++-------- packages/llm-deepseek/src/serialize.ts | 2 +- packages/llm-deepseek/src/translate.ts | 4 ++-- packages/llm-pi-ai/src/adapter.ts | 2 +- packages/llm-pi-ai/src/index.ts | 10 +++++----- packages/llm/src/assembler.ts | 6 +++--- packages/llm/src/index.ts | 16 ++++++++-------- packages/llm/src/types.ts | 2 +- packages/session-persistence-jsonl/src/index.ts | 2 +- packages/session-persistence-sqlite/src/index.ts | 4 ++-- packages/session/src/index.ts | 12 ++++++------ packages/session/src/repair.ts | 2 +- packages/tools/src/index.ts | 2 +- packages/tools/src/schema.ts | 2 +- 22 files changed, 62 insertions(+), 62 deletions(-) diff --git a/packages/acp/src/index.ts b/packages/acp/src/index.ts index 780e907559..88441fb9c3 100644 --- a/packages/acp/src/index.ts +++ b/packages/acp/src/index.ts @@ -69,7 +69,7 @@ import { harnessBlockToAcpContent, promptHasUnsupportedContent, turnEndToStopReason, -} from './codec.ts' +} from './codec' export const name = 'acp' // The bridge programs against the interface packages only (architecture rule: diff --git a/packages/agent-loop/src/agent.ts b/packages/agent-loop/src/agent.ts index e964685b86..c207867d74 100644 --- a/packages/agent-loop/src/agent.ts +++ b/packages/agent-loop/src/agent.ts @@ -11,8 +11,8 @@ import type { AgentId, AgentOptions, AgentStatus, SendOptions } from '@deepseek- import type { Agent } from '@deepseek-ai/dsh-agent' import type { ContentBlock, MessageSource } from '@deepseek-ai/dsh-llm' import type { Session } from '@deepseek-ai/dsh-session' -import { Inbox } from './inbox.ts' -import { isTurnOpen, lastTurnNumber, runLoop } from './loop.ts' +import { Inbox } from './inbox' +import { isTurnOpen, lastTurnNumber, runLoop } from './loop' /** * The concrete {@link Agent} implementation owned by the agent-loop plugin. diff --git a/packages/agent-loop/src/index.ts b/packages/agent-loop/src/index.ts index f118959fce..7fadf00d24 100644 --- a/packages/agent-loop/src/index.ts +++ b/packages/agent-loop/src/index.ts @@ -18,11 +18,11 @@ import type { Session } from '@deepseek-ai/dsh-session' import type {} from '@deepseek-ai/dsh-system-prompt' import type {} from '@deepseek-ai/dsh-tools' import type { SessionPersistence } from '@deepseek-ai/dsh-session-persistence' -import { ReactLoopAgent } from './agent.ts' +import { ReactLoopAgent } from './agent' -export { ReactLoopAgent } from './agent.ts' -export { Inbox, type InboxMessage } from './inbox.ts' -export { runLoop } from './loop.ts' +export { ReactLoopAgent } from './agent' +export { Inbox, type InboxMessage } from './inbox' +export { runLoop } from './loop' declare module 'cordis' { interface Context { diff --git a/packages/agent-loop/src/loop.ts b/packages/agent-loop/src/loop.ts index dc1cbcf278..9063acca92 100644 --- a/packages/agent-loop/src/loop.ts +++ b/packages/agent-loop/src/loop.ts @@ -13,7 +13,7 @@ import { BlockAssembler, HarnessError } from '@deepseek-ai/dsh-llm' import type { Session, TurnEndReason, TurnTrigger } from '@deepseek-ai/dsh-session' import { renderPrompt } from '@deepseek-ai/dsh-system-prompt' import type {} from '@deepseek-ai/dsh-tools' -import type { ReactLoopAgent } from './agent.ts' +import type { ReactLoopAgent } from './agent' /** An Error with an optional machine-readable code (e.g., from LlmError or a throwing plugin). */ type CodedError = Error & { code?: string } diff --git a/packages/agent/src/index.ts b/packages/agent/src/index.ts index c9181081a3..beac6807f9 100644 --- a/packages/agent/src/index.ts +++ b/packages/agent/src/index.ts @@ -7,9 +7,9 @@ import { Context, Service } from 'cordis' import type { SessionId } from '@deepseek-ai/dsh-session' -import type { Agent, AgentOptions } from './types.ts' +import type { Agent, AgentOptions } from './types' -export * from './types.ts' +export * from './types' declare module 'cordis' { interface Context { diff --git a/packages/bash-local/src/index.ts b/packages/bash-local/src/index.ts index 7320276a1a..bf8f448b53 100644 --- a/packages/bash-local/src/index.ts +++ b/packages/bash-local/src/index.ts @@ -17,11 +17,11 @@ import { Context } from 'cordis' import z from 'schemastery' import { BashExecutor } from '@deepseek-ai/dsh-bash' import type { BashExecRequest, BashExecSpec, BashRunResult, BashTask, BashTaskRead } from '@deepseek-ai/dsh-bash' -import { runBash } from './run.ts' -import type { RunInternals, RunningBash } from './run.ts' +import { runBash } from './run' +import type { RunInternals, RunningBash } from './run' -export { DEFAULT_GRACE_MS, ENV_OVERRIDES, killGroup, OutputCollector, runBash } from './run.ts' -export type { RunInternals, RunningBash, SpawnOutcome, SpawnSpec } from './run.ts' +export { DEFAULT_GRACE_MS, ENV_OVERRIDES, killGroup, OutputCollector, runBash } from './run' +export type { RunInternals, RunningBash, SpawnOutcome, SpawnSpec } from './run' /** Plugin config (all optional — `static Config` supplies the defaults). */ export interface Config { diff --git a/packages/bash/src/index.ts b/packages/bash/src/index.ts index e22aad5ff3..af8b1a6727 100644 --- a/packages/bash/src/index.ts +++ b/packages/bash/src/index.ts @@ -15,7 +15,7 @@ */ import { Context, Service } from 'cordis' -import type { BashExecRequest, BashExecSpec, BashRunResult, BashTask, BashTaskListener, BashTaskRead } from './types.ts' +import type { BashExecRequest, BashExecSpec, BashRunResult, BashTask, BashTaskListener, BashTaskRead } from './types' export type { BashExecRequest, @@ -26,7 +26,7 @@ export type { BashTaskRead, BashTaskStatus, CollectedOutput, -} from './types.ts' +} from './types' declare module 'cordis' { interface Context { diff --git a/packages/llm-deepseek/src/adapter.ts b/packages/llm-deepseek/src/adapter.ts index fda527359a..f9250987f3 100644 --- a/packages/llm-deepseek/src/adapter.ts +++ b/packages/llm-deepseek/src/adapter.ts @@ -7,11 +7,11 @@ import { LlmAdapter, LlmError } from '@deepseek-ai/dsh-llm' import type { GenerateOptions, StreamChunk } from '@deepseek-ai/dsh-llm' -import { serializeRequest } from './serialize.ts' -import type { RequestDefaults } from './serialize.ts' -import { parseSse } from './sse.ts' -import { translate } from './translate.ts' -import type { WireError } from './types.ts' +import { serializeRequest } from './serialize' +import type { RequestDefaults } from './serialize' +import { parseSse } from './sse' +import { translate } from './translate' +import type { WireError } from './types' export interface DeepSeekAdapterOptions { apiKey: string diff --git a/packages/llm-deepseek/src/index.ts b/packages/llm-deepseek/src/index.ts index 79313f910f..f4f7e43635 100644 --- a/packages/llm-deepseek/src/index.ts +++ b/packages/llm-deepseek/src/index.ts @@ -21,15 +21,15 @@ import type { Context } from 'cordis' import z from 'schemastery' import type {} from '@deepseek-ai/dsh-llm' -import { DeepSeekAdapter } from './adapter.ts' +import { DeepSeekAdapter } from './adapter' -export { DeepSeekAdapter, httpErrorCode } from './adapter.ts' -export type { DeepSeekAdapterOptions } from './adapter.ts' -export { serializeMessages, serializeRequest } from './serialize.ts' -export type { RequestDefaults } from './serialize.ts' -export { DONE, parseSse } from './sse.ts' -export { mapFinishReason, mapUsage, translate } from './translate.ts' -export type * from './types.ts' +export { DeepSeekAdapter, httpErrorCode } from './adapter' +export type { DeepSeekAdapterOptions } from './adapter' +export { serializeMessages, serializeRequest } from './serialize' +export type { RequestDefaults } from './serialize' +export { DONE, parseSse } from './sse' +export { mapFinishReason, mapUsage, translate } from './translate' +export type * from './types' export const name = 'llm-deepseek' export const inject = ['llm'] diff --git a/packages/llm-deepseek/src/serialize.ts b/packages/llm-deepseek/src/serialize.ts index 4e967d6667..11b9028af0 100644 --- a/packages/llm-deepseek/src/serialize.ts +++ b/packages/llm-deepseek/src/serialize.ts @@ -18,7 +18,7 @@ import { LlmError } from '@deepseek-ai/dsh-llm' import type { ContentBlock, GenerateOptions, Message } from '@deepseek-ai/dsh-llm' -import type { WireMessage, WireRequest, WireTool } from './types.ts' +import type { WireMessage, WireRequest, WireTool } from './types' /** Adapter-level request defaults (from plugin config). */ export interface RequestDefaults { diff --git a/packages/llm-deepseek/src/translate.ts b/packages/llm-deepseek/src/translate.ts index 08cc019b61..ea5e50d7c1 100644 --- a/packages/llm-deepseek/src/translate.ts +++ b/packages/llm-deepseek/src/translate.ts @@ -16,8 +16,8 @@ import { CallId, LlmError } from '@deepseek-ai/dsh-llm' import type { ContentBlock, FinishReason, StreamChunk, TokenUsage } from '@deepseek-ai/dsh-llm' -import { DONE } from './sse.ts' -import type { WireChunk, WireUsage } from './types.ts' +import { DONE } from './sse' +import type { WireChunk, WireUsage } from './types' /** One open block under assembly. */ interface OpenBlock { diff --git a/packages/llm-pi-ai/src/adapter.ts b/packages/llm-pi-ai/src/adapter.ts index 38b05dc007..28046d0e04 100644 --- a/packages/llm-pi-ai/src/adapter.ts +++ b/packages/llm-pi-ai/src/adapter.ts @@ -15,7 +15,7 @@ import { stream as piStream } from '@earendil-works/pi-ai' import type { Model } from '@earendil-works/pi-ai' import { LlmAdapter, LlmError } from '@deepseek-ai/dsh-llm' import type { GenerateOptions, StreamChunk, ToolSchema } from '@deepseek-ai/dsh-llm' -import { toPiContext, toStreamChunks } from './convert.ts' +import { toPiContext, toStreamChunks } from './convert' /** Reasoning levels surfaced by this adapter (DeepSeek wire: high|max). */ export type PiAiReasoning = 'off' | 'high' | 'xhigh' diff --git a/packages/llm-pi-ai/src/index.ts b/packages/llm-pi-ai/src/index.ts index bef0d4b3f5..d146df5824 100644 --- a/packages/llm-pi-ai/src/index.ts +++ b/packages/llm-pi-ai/src/index.ts @@ -19,12 +19,12 @@ import type { Context } from 'cordis' import z from 'schemastery' import type {} from '@deepseek-ai/dsh-llm' -import { PiAiAdapter } from './adapter.ts' -import type { PiAiReasoning } from './adapter.ts' +import { PiAiAdapter } from './adapter' +import type { PiAiReasoning } from './adapter' -export { buildModel, PiAiAdapter } from './adapter.ts' -export type { PiAiAdapterOptions, PiAiReasoning } from './adapter.ts' -export { mapStopReason, mapUsage, toPiContext, toStreamChunks } from './convert.ts' +export { buildModel, PiAiAdapter } from './adapter' +export type { PiAiAdapterOptions, PiAiReasoning } from './adapter' +export { mapStopReason, mapUsage, toPiContext, toStreamChunks } from './convert' export const name = 'llm-pi-ai' export const inject = ['llm'] diff --git a/packages/llm/src/assembler.ts b/packages/llm/src/assembler.ts index a61d6cf044..9a8ea01b63 100644 --- a/packages/llm/src/assembler.ts +++ b/packages/llm/src/assembler.ts @@ -5,9 +5,9 @@ * @module @deepseek-ai/dsh-llm/assembler */ -import { CallId } from './brand.ts' -import { assertNever } from './never.ts' -import type { ContentBlock, FinishReason, GenerateResult, Message, StreamChunk, TokenUsage } from './types.ts' +import { CallId } from './brand' +import { assertNever } from './never' +import type { ContentBlock, FinishReason, GenerateResult, Message, StreamChunk, TokenUsage } from './types' interface PartialBlock { blockType: string diff --git a/packages/llm/src/index.ts b/packages/llm/src/index.ts index 460316ea50..b7348fa46d 100644 --- a/packages/llm/src/index.ts +++ b/packages/llm/src/index.ts @@ -7,15 +7,15 @@ */ import { Context, Service } from 'cordis' -import type { ContentBlock, GenerateOptions, GenerateResult, StreamChunk } from './types.ts' -import { BlockAssembler } from './assembler.ts' -import { HarnessError } from './error.ts' +import type { ContentBlock, GenerateOptions, GenerateResult, StreamChunk } from './types' +import { BlockAssembler } from './assembler' +import { HarnessError } from './error' -export * from './brand.ts' -export * from './never.ts' -export * from './error.ts' -export * from './types.ts' -export { BlockAssembler } from './assembler.ts' +export * from './brand' +export * from './never' +export * from './error' +export * from './types' +export { BlockAssembler } from './assembler' declare module 'cordis' { interface Context { diff --git a/packages/llm/src/types.ts b/packages/llm/src/types.ts index 863de94b16..0dd48417d1 100644 --- a/packages/llm/src/types.ts +++ b/packages/llm/src/types.ts @@ -19,7 +19,7 @@ * ``` */ -import type { CallId } from './brand.ts' +import type { CallId } from './brand' /** Cache hint attached to a content block (provider-interpreted). */ export type CacheHint = 'ephemeral' diff --git a/packages/session-persistence-jsonl/src/index.ts b/packages/session-persistence-jsonl/src/index.ts index 7a0c97637c..faa1e11de7 100644 --- a/packages/session-persistence-jsonl/src/index.ts +++ b/packages/session-persistence-jsonl/src/index.ts @@ -32,7 +32,7 @@ import { interruptedTurnClosers } from '@deepseek-ai/dsh-session' import type { Session, SessionEvent, SessionId, SessionMeta, SessionSummary } from '@deepseek-ai/dsh-session' import { encodeSegment, eventLine, logPath, parseHeaderMeta, scanLog, sessionDir, sidecarPath, toHeaderLine, -} from './format.ts' +} from './format' export interface Config { /** diff --git a/packages/session-persistence-sqlite/src/index.ts b/packages/session-persistence-sqlite/src/index.ts index d28fc8d6f7..1eab7df5c0 100644 --- a/packages/session-persistence-sqlite/src/index.ts +++ b/packages/session-persistence-sqlite/src/index.ts @@ -31,9 +31,9 @@ import { interruptedTurnClosers } from '@deepseek-ai/dsh-session' import type { Session, SessionEvent, SessionId, SessionMeta, SessionSummary } from '@deepseek-ai/dsh-session' import { openDatabase, rowToMeta, scanRows, type EventRow, type SessionRow, -} from './schema.ts' +} from './schema' -export { SCHEMA_VERSION } from './schema.ts' +export { SCHEMA_VERSION } from './schema' /** Plugin configuration. */ export interface Config { diff --git a/packages/session/src/index.ts b/packages/session/src/index.ts index 4796c05f51..f8d2993c98 100644 --- a/packages/session/src/index.ts +++ b/packages/session/src/index.ts @@ -9,13 +9,13 @@ import { Context, Service } from 'cordis' import { isAbsolute } from 'node:path' import type { ContentBlock, Message, MessageSource } from '@deepseek-ai/dsh-llm' -import { SessionId } from './types.ts' -import type { CreateSessionOptions, SessionEvent, SessionEventMap, SessionEventType, SessionHeader } from './types.ts' -import { isJsonValue } from './json.ts' +import { SessionId } from './types' +import type { CreateSessionOptions, SessionEvent, SessionEventMap, SessionEventType, SessionHeader } from './types' +import { isJsonValue } from './json' -export * from './types.ts' -export { isJsonValue } from './json.ts' -export { interruptedTurnClosers } from './repair.ts' +export * from './types' +export { isJsonValue } from './json' +export { interruptedTurnClosers } from './repair' declare module 'cordis' { interface Context { diff --git a/packages/session/src/repair.ts b/packages/session/src/repair.ts index 5cc62b37c7..6215ebc2a8 100644 --- a/packages/session/src/repair.ts +++ b/packages/session/src/repair.ts @@ -36,7 +36,7 @@ */ import type { CallId } from '@deepseek-ai/dsh-llm' -import type { SessionEvent } from './types.ts' +import type { SessionEvent } from './types' /** * Scan `events` for an open turn/step at the tail and return the synthetic diff --git a/packages/tools/src/index.ts b/packages/tools/src/index.ts index eee77445eb..32bb64160f 100644 --- a/packages/tools/src/index.ts +++ b/packages/tools/src/index.ts @@ -24,7 +24,7 @@ export { type InferArgs, type DefineToolOptions, type JsonSchemaObject, -} from './schema.ts' +} from './schema' declare module 'cordis' { interface Context { diff --git a/packages/tools/src/schema.ts b/packages/tools/src/schema.ts index 5e8887f11b..b38861fc2d 100644 --- a/packages/tools/src/schema.ts +++ b/packages/tools/src/schema.ts @@ -21,7 +21,7 @@ import type { ContentBlock } from '@deepseek-ai/dsh-llm' import { assertNever, HarnessError } from '@deepseek-ai/dsh-llm' -import type { ToolCallPresentation, ToolDefinition, ToolExecution, ToolResult, ToolResultPresentation } from './index.ts' +import type { ToolCallPresentation, ToolDefinition, ToolExecution, ToolResult, ToolResultPresentation } from './index' // --------------------------------------------------------------------------- // SchemaSpec — the author-facing per-property type From 29e674bfea988fcbccd6e847d14791a978ddfd66 Mon Sep 17 00:00:00 2001 From: imccyu Date: Wed, 17 Jun 2026 23:18:25 +0800 Subject: [PATCH 03/21] refactor: ts in vendor use extensionless import --- vendor/hmr/src/index.ts | 2 +- vendor/loader/src/config/entry.ts | 8 ++++---- vendor/loader/src/config/group.ts | 4 ++-- vendor/loader/src/config/isolate.ts | 4 ++-- vendor/loader/src/config/tree.ts | 4 ++-- vendor/loader/src/index.ts | 20 ++++++++++---------- vendor/logger-console/src/browser.ts | 4 ++-- vendor/logger-console/src/index.ts | 4 ++-- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/vendor/hmr/src/index.ts b/vendor/hmr/src/index.ts index ada10cc934..8948625db6 100644 --- a/vendor/hmr/src/index.ts +++ b/vendor/hmr/src/index.ts @@ -4,7 +4,7 @@ import { ModuleJob, ModuleLoader, ResolveResult } from '@cordisjs/plugin-loader' import type { Include } from '@cordisjs/plugin-include' import { ChokidarOptions, FSWatcher, watch } from 'chokidar' import { relative, resolve } from 'node:path' -import { handleError } from './error.ts' +import { handleError } from './error' import type {} from '@cordisjs/plugin-timer' import { fileURLToPath, pathToFileURL } from 'node:url' import { createRequire } from 'node:module' diff --git a/vendor/loader/src/config/entry.ts b/vendor/loader/src/config/entry.ts index c2959fe61e..8acba39548 100644 --- a/vendor/loader/src/config/entry.ts +++ b/vendor/loader/src/config/entry.ts @@ -1,9 +1,9 @@ import { Context, Fiber, Inject } from 'cordis' import { deepEqual, isNullable } from 'cosmokit' -import { Loader } from '../index.ts' -import { EntryGroup } from './group.ts' -import { EntryTree } from './tree.ts' -import { evaluate, interpolate } from './utils.ts' +import { Loader } from '../index' +import { EntryGroup } from './group' +import { EntryTree } from './tree' +import { evaluate, interpolate } from './utils' /** Serialized plugin entry options stored in loader config files. */ export interface EntryOptions { diff --git a/vendor/loader/src/config/group.ts b/vendor/loader/src/config/group.ts index f6ce0fe306..5966d87eb8 100644 --- a/vendor/loader/src/config/group.ts +++ b/vendor/loader/src/config/group.ts @@ -1,6 +1,6 @@ import { Context, Service } from 'cordis' -import { Entry, EntryOptions } from './entry.ts' -import { EntryTree } from './tree.ts' +import { Entry, EntryOptions } from './entry' +import { EntryTree } from './tree' /** Runtime owner for a list of child loader entries. */ export class EntryGroup { diff --git a/vendor/loader/src/config/isolate.ts b/vendor/loader/src/config/isolate.ts index a2e930c4fb..4b2f1df894 100644 --- a/vendor/loader/src/config/isolate.ts +++ b/vendor/loader/src/config/isolate.ts @@ -1,8 +1,8 @@ import { Context } from 'cordis' import { Dict } from 'cosmokit' -import { Entry } from './entry.ts' +import { Entry } from './entry' -declare module './entry.ts' { +declare module './entry' { interface EntryOptions { intercept?: Dict | null isolate?: Dict | null diff --git a/vendor/loader/src/config/tree.ts b/vendor/loader/src/config/tree.ts index 6855884e11..53f71220e1 100644 --- a/vendor/loader/src/config/tree.ts +++ b/vendor/loader/src/config/tree.ts @@ -1,7 +1,7 @@ import { composeError, Context } from 'cordis' import { Dict, isNonNullable } from 'cosmokit' -import { Entry, EntryOptions } from './entry.ts' -import { EntryGroup } from './group.ts' +import { Entry, EntryOptions } from './entry' +import { EntryGroup } from './group' /** Mutable tree of loader entries. Persistence is supplied by subclasses. */ export abstract class EntryTree { diff --git a/vendor/loader/src/index.ts b/vendor/loader/src/index.ts index e18fc2ffa2..764f04f995 100644 --- a/vendor/loader/src/index.ts +++ b/vendor/loader/src/index.ts @@ -1,22 +1,22 @@ import { Context, Inject, Service } from 'cordis' import { defineProperty, Dict, isNullable } from 'cosmokit' -import { ModuleLoader } from './internal.ts' -import { Entry, EntryOptions } from './config/entry.ts' -import isolate from './config/isolate.ts' -import { EntryTree } from './config/tree.ts' +import { ModuleLoader } from './internal' +import { Entry, EntryOptions } from './config/entry' +import isolate from './config/isolate' +import { EntryTree } from './config/tree' /** Re-export entry node APIs. */ -export * from './config/entry.ts' +export * from './config/entry' /** Re-export nested entry group APIs. */ -export * from './config/group.ts' +export * from './config/group' /** Re-export service isolation helpers. */ -export * from './config/isolate.ts' +export * from './config/isolate' /** Re-export entry tree persistence APIs. */ -export * from './config/tree.ts' +export * from './config/tree' /** Re-export loader config expression helpers. */ -export * from './config/utils.ts' +export * from './config/utils' /** Re-export Node internal module loader compatibility types. */ -export * from './internal.ts' +export * from './internal' declare module 'cordis' { interface Events { diff --git a/vendor/logger-console/src/browser.ts b/vendor/logger-console/src/browser.ts index bdbeaaf226..fb35366d14 100644 --- a/vendor/logger-console/src/browser.ts +++ b/vendor/logger-console/src/browser.ts @@ -1,8 +1,8 @@ import { Message } from 'cordis' -import { ConsoleExporter as Base } from './shared.js' +import { ConsoleExporter as Base } from './shared' /** Re-export shared console exporter config and base implementation. */ -export * from './shared.js' +export * from './shared' /** Browser console exporter that dispatches to native console methods. */ export class ConsoleExporter extends Base { diff --git a/vendor/logger-console/src/index.ts b/vendor/logger-console/src/index.ts index 87ab53d6dc..905287b1e8 100644 --- a/vendor/logger-console/src/index.ts +++ b/vendor/logger-console/src/index.ts @@ -1,10 +1,10 @@ import { Formatter } from 'cordis' import { inspect } from 'node:util' import supportsColor from 'supports-color' -import { ConsoleExporter as Base } from './shared.js' +import { ConsoleExporter as Base } from './shared' /** Re-export shared console exporter config and base implementation. */ -export * from './shared.js' +export * from './shared' const inspectFormatter: Formatter = (value, target) => { return inspect(value, { colors: !!target.colors, depth: Infinity, compact: true, breakLength: Infinity }) From 6b15b606d7c848ba14f5b678712a98adb7a2db12 Mon Sep 17 00:00:00 2001 From: imccyu Date: Wed, 17 Jun 2026 23:20:04 +0800 Subject: [PATCH 04/21] refactor: packages/tsconfig.json in packages use lib/typings/ as output subfolder --- packages/acp/package.json | 7 ++++--- packages/acp/tsconfig.json | 2 +- packages/agent-loop/package.json | 7 ++++--- packages/agent-loop/tsconfig.json | 2 +- packages/agent/package.json | 7 ++++--- packages/agent/tsconfig.json | 2 +- packages/bash-local/package.json | 7 ++++--- packages/bash-local/tsconfig.json | 2 +- packages/bash/package.json | 7 ++++--- packages/bash/tsconfig.json | 2 +- packages/invariants/package.json | 7 ++++--- packages/invariants/tsconfig.json | 2 +- packages/llm-deepseek/package.json | 7 ++++--- packages/llm-deepseek/tsconfig.json | 2 +- packages/llm-pi-ai/package.json | 7 ++++--- packages/llm-pi-ai/tsconfig.json | 2 +- packages/llm-replay/package.json | 7 ++++--- packages/llm-replay/tsconfig.json | 2 +- packages/llm/package.json | 7 ++++--- packages/llm/tsconfig.json | 2 +- packages/session-persistence-jsonl/package.json | 7 ++++--- packages/session-persistence-jsonl/tsconfig.json | 2 +- packages/session-persistence-sqlite/package.json | 7 ++++--- packages/session-persistence-sqlite/tsconfig.json | 2 +- packages/session-persistence/package.json | 7 ++++--- packages/session-persistence/tsconfig.json | 2 +- packages/session/package.json | 7 ++++--- packages/session/tsconfig.json | 2 +- packages/system-prompt/package.json | 7 ++++--- packages/system-prompt/tsconfig.json | 2 +- packages/tool-bash/package.json | 7 ++++--- packages/tool-bash/tsconfig.json | 2 +- packages/tools/package.json | 7 ++++--- packages/tools/tsconfig.json | 2 +- packages/ui-stdio/package.json | 7 ++++--- packages/ui-stdio/tsconfig.json | 2 +- 36 files changed, 90 insertions(+), 72 deletions(-) diff --git a/packages/acp/package.json b/packages/acp/package.json index 0a4a890658..ac23174ade 100644 --- a/packages/acp/package.json +++ b/packages/acp/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/acp/tsconfig.json b/packages/acp/tsconfig.json index 83330256e3..73d850e990 100644 --- a/packages/acp/tsconfig.json +++ b/packages/acp/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/agent-loop/package.json b/packages/agent-loop/package.json index b9744eab2a..9e54e4de4b 100644 --- a/packages/agent-loop/package.json +++ b/packages/agent-loop/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/agent-loop/tsconfig.json b/packages/agent-loop/tsconfig.json index 6751664d5c..93a07b2e41 100644 --- a/packages/agent-loop/tsconfig.json +++ b/packages/agent-loop/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/agent/package.json b/packages/agent/package.json index a215f35fb3..bca0ff7840 100644 --- a/packages/agent/package.json +++ b/packages/agent/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/agent/tsconfig.json b/packages/agent/tsconfig.json index 0806132292..c2b740741a 100644 --- a/packages/agent/tsconfig.json +++ b/packages/agent/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/bash-local/package.json b/packages/bash-local/package.json index b786c1bc37..de2f2d6c1a 100644 --- a/packages/bash-local/package.json +++ b/packages/bash-local/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/bash-local/tsconfig.json b/packages/bash-local/tsconfig.json index a657d8bf8e..576ebe64a8 100644 --- a/packages/bash-local/tsconfig.json +++ b/packages/bash-local/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/bash/package.json b/packages/bash/package.json index 52bf80282f..f65f5a6a7f 100644 --- a/packages/bash/package.json +++ b/packages/bash/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/bash/tsconfig.json b/packages/bash/tsconfig.json index 2617271c44..f5803cec7f 100644 --- a/packages/bash/tsconfig.json +++ b/packages/bash/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/invariants/package.json b/packages/invariants/package.json index 7508d3e7d8..409596871b 100644 --- a/packages/invariants/package.json +++ b/packages/invariants/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/invariants/tsconfig.json b/packages/invariants/tsconfig.json index 54fbb4adac..e87cca530d 100644 --- a/packages/invariants/tsconfig.json +++ b/packages/invariants/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/llm-deepseek/package.json b/packages/llm-deepseek/package.json index 077a2db169..0517a0c5a9 100644 --- a/packages/llm-deepseek/package.json +++ b/packages/llm-deepseek/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/llm-deepseek/tsconfig.json b/packages/llm-deepseek/tsconfig.json index eea89a4aac..ceacbf1ee2 100644 --- a/packages/llm-deepseek/tsconfig.json +++ b/packages/llm-deepseek/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/llm-pi-ai/package.json b/packages/llm-pi-ai/package.json index 6eb08a4b06..f2e9a34322 100644 --- a/packages/llm-pi-ai/package.json +++ b/packages/llm-pi-ai/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/llm-pi-ai/tsconfig.json b/packages/llm-pi-ai/tsconfig.json index eea89a4aac..ceacbf1ee2 100644 --- a/packages/llm-pi-ai/tsconfig.json +++ b/packages/llm-pi-ai/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/llm-replay/package.json b/packages/llm-replay/package.json index 50d469a352..b25fa04f03 100644 --- a/packages/llm-replay/package.json +++ b/packages/llm-replay/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/llm-replay/tsconfig.json b/packages/llm-replay/tsconfig.json index 0806132292..c2b740741a 100644 --- a/packages/llm-replay/tsconfig.json +++ b/packages/llm-replay/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/llm/package.json b/packages/llm/package.json index 317edc7ac2..835e89af7f 100644 --- a/packages/llm/package.json +++ b/packages/llm/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/llm/tsconfig.json b/packages/llm/tsconfig.json index 2617271c44..f5803cec7f 100644 --- a/packages/llm/tsconfig.json +++ b/packages/llm/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/session-persistence-jsonl/package.json b/packages/session-persistence-jsonl/package.json index 6193af910b..6a1e61c361 100644 --- a/packages/session-persistence-jsonl/package.json +++ b/packages/session-persistence-jsonl/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/session-persistence-jsonl/tsconfig.json b/packages/session-persistence-jsonl/tsconfig.json index 3595f989bd..23465c380e 100644 --- a/packages/session-persistence-jsonl/tsconfig.json +++ b/packages/session-persistence-jsonl/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/session-persistence-sqlite/package.json b/packages/session-persistence-sqlite/package.json index 463cf683be..4d6951ebbd 100644 --- a/packages/session-persistence-sqlite/package.json +++ b/packages/session-persistence-sqlite/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/session-persistence-sqlite/tsconfig.json b/packages/session-persistence-sqlite/tsconfig.json index 3595f989bd..23465c380e 100644 --- a/packages/session-persistence-sqlite/tsconfig.json +++ b/packages/session-persistence-sqlite/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/session-persistence/package.json b/packages/session-persistence/package.json index bd84fd1826..901381cffc 100644 --- a/packages/session-persistence/package.json +++ b/packages/session-persistence/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/session-persistence/tsconfig.json b/packages/session-persistence/tsconfig.json index 727294a720..ebfd4b98f3 100644 --- a/packages/session-persistence/tsconfig.json +++ b/packages/session-persistence/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/session/package.json b/packages/session/package.json index f4aa5839bc..d660624853 100644 --- a/packages/session/package.json +++ b/packages/session/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/session/tsconfig.json b/packages/session/tsconfig.json index e226412a53..747dd65daa 100644 --- a/packages/session/tsconfig.json +++ b/packages/session/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/system-prompt/package.json b/packages/system-prompt/package.json index eed76b8907..b5782f2c38 100644 --- a/packages/system-prompt/package.json +++ b/packages/system-prompt/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/system-prompt/tsconfig.json b/packages/system-prompt/tsconfig.json index e226412a53..747dd65daa 100644 --- a/packages/system-prompt/tsconfig.json +++ b/packages/system-prompt/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/tool-bash/package.json b/packages/tool-bash/package.json index aaf4fde4cc..e433fad938 100644 --- a/packages/tool-bash/package.json +++ b/packages/tool-bash/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/tool-bash/tsconfig.json b/packages/tool-bash/tsconfig.json index 4741cb67f3..131f52aca6 100644 --- a/packages/tool-bash/tsconfig.json +++ b/packages/tool-bash/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/tools/package.json b/packages/tools/package.json index a92015e55c..0a578547f2 100644 --- a/packages/tools/package.json +++ b/packages/tools/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/tools/tsconfig.json b/packages/tools/tsconfig.json index 8e29228fc8..20d6ab9643 100644 --- a/packages/tools/tsconfig.json +++ b/packages/tools/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ diff --git a/packages/ui-stdio/package.json b/packages/ui-stdio/package.json index 156984a72e..34216be977 100644 --- a/packages/ui-stdio/package.json +++ b/packages/ui-stdio/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "license": "BSD-3-Clause", diff --git a/packages/ui-stdio/tsconfig.json b/packages/ui-stdio/tsconfig.json index 33fa338e5f..f87b686386 100644 --- a/packages/ui-stdio/tsconfig.json +++ b/packages/ui-stdio/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/typings" }, "include": ["src"], "references": [ From 99db5497086bff43aff699c25c6e44e53da9902d Mon Sep 17 00:00:00 2001 From: imccyu Date: Wed, 17 Jun 2026 23:21:05 +0800 Subject: [PATCH 05/21] refactor: packages/tsconfig.json in vendor use lib/typings/ as output subfolder --- vendor/cordis/package.json | 7 ++++--- vendor/cordis/tsconfig.json | 2 +- vendor/cosmokit/package.json | 7 ++++--- vendor/cosmokit/tsconfig.json | 2 +- vendor/group/package.json | 7 ++++--- vendor/group/tsconfig.json | 2 +- vendor/hmr/package.json | 7 ++++--- vendor/hmr/tsconfig.json | 2 +- vendor/include/package.json | 7 ++++--- vendor/include/tsconfig.json | 2 +- vendor/loader/package.json | 7 ++++--- vendor/loader/tsconfig.json | 2 +- vendor/logger-console/package.json | 8 +++++--- vendor/logger-console/tsconfig.json | 2 +- vendor/schemastery/package.json | 6 ++++-- vendor/schemastery/tsconfig.json | 2 +- vendor/timer/package.json | 7 ++++--- vendor/timer/tsconfig.json | 2 +- 18 files changed, 46 insertions(+), 35 deletions(-) diff --git a/vendor/cordis/package.json b/vendor/cordis/package.json index 6b9e59a00b..33bd881dc2 100644 --- a/vendor/cordis/package.json +++ b/vendor/cordis/package.json @@ -6,18 +6,19 @@ "sideEffects": false, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "bin": "bin.js", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "bin.js" ], "author": "Shigma ", diff --git a/vendor/cordis/tsconfig.json b/vendor/cordis/tsconfig.json index b9829bf1df..e0b2a46462 100644 --- a/vendor/cordis/tsconfig.json +++ b/vendor/cordis/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib", + "outDir": "lib/typings", "noImplicitAny": false, "noImplicitThis": false, "strictFunctionTypes": false, diff --git a/vendor/cosmokit/package.json b/vendor/cosmokit/package.json index 92fdf8e903..ccb8f620fd 100644 --- a/vendor/cosmokit/package.json +++ b/vendor/cosmokit/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "author": "Shigma ", diff --git a/vendor/cosmokit/tsconfig.json b/vendor/cosmokit/tsconfig.json index 0db18e0f14..eb79653390 100644 --- a/vendor/cosmokit/tsconfig.json +++ b/vendor/cosmokit/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib", + "outDir": "lib/typings", "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, "noImplicitOverride": false, diff --git a/vendor/group/package.json b/vendor/group/package.json index 86e5043a10..cd638f59a7 100644 --- a/vendor/group/package.json +++ b/vendor/group/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "author": "Shigma ", diff --git a/vendor/group/tsconfig.json b/vendor/group/tsconfig.json index 137b02f7ac..2d93e6ae42 100644 --- a/vendor/group/tsconfig.json +++ b/vendor/group/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib", + "outDir": "lib/typings", "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, "noImplicitOverride": false, diff --git a/vendor/hmr/package.json b/vendor/hmr/package.json index 075968a3ba..1c3c088dd0 100644 --- a/vendor/hmr/package.json +++ b/vendor/hmr/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "author": "Shigma ", diff --git a/vendor/hmr/tsconfig.json b/vendor/hmr/tsconfig.json index 033f83429f..cfa1f07afd 100644 --- a/vendor/hmr/tsconfig.json +++ b/vendor/hmr/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib", + "outDir": "lib/typings", "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, "noImplicitOverride": false, diff --git a/vendor/include/package.json b/vendor/include/package.json index d42a1c0739..2b15cb4b90 100644 --- a/vendor/include/package.json +++ b/vendor/include/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "author": "Shigma ", diff --git a/vendor/include/tsconfig.json b/vendor/include/tsconfig.json index ae2c70f4bc..056206ecab 100644 --- a/vendor/include/tsconfig.json +++ b/vendor/include/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib", + "outDir": "lib/typings", "noImplicitAny": false, "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, diff --git a/vendor/loader/package.json b/vendor/loader/package.json index ee5dd088ff..8d43331708 100644 --- a/vendor/loader/package.json +++ b/vendor/loader/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "author": "Shigma ", diff --git a/vendor/loader/tsconfig.json b/vendor/loader/tsconfig.json index 84799662e0..ca6d75810a 100644 --- a/vendor/loader/tsconfig.json +++ b/vendor/loader/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib", + "outDir": "lib/typings", "noImplicitAny": false, "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, diff --git a/vendor/logger-console/package.json b/vendor/logger-console/package.json index b4a4c9634e..f96f94b23d 100644 --- a/vendor/logger-console/package.json +++ b/vendor/logger-console/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/shared.d.ts", + "types": "lib/typings/shared.d.ts", "exports": { ".": { - "types": "./lib/shared.d.ts", + "types": "./lib/typings/shared.d.ts", "node": "./lib/index.js", "default": "./lib/browser.js" }, @@ -16,7 +16,9 @@ "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/browser.js", + "lib/typings/**/*.d.ts", "src" ], "author": "Shigma ", diff --git a/vendor/logger-console/tsconfig.json b/vendor/logger-console/tsconfig.json index c632badb1b..8714f410b6 100644 --- a/vendor/logger-console/tsconfig.json +++ b/vendor/logger-console/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib", + "outDir": "lib/typings", "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, "noImplicitOverride": false, diff --git a/vendor/schemastery/package.json b/vendor/schemastery/package.json index 71f7744e5e..42aab72f69 100644 --- a/vendor/schemastery/package.json +++ b/vendor/schemastery/package.json @@ -5,9 +5,11 @@ "private": true, "main": "lib/index.cjs", "module": "lib/index.mjs", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "files": [ - "lib", + "lib/index.mjs", + "lib/index.cjs", + "lib/typings/**/*.d.ts", "src" ], "author": "Shigma ", diff --git a/vendor/schemastery/tsconfig.json b/vendor/schemastery/tsconfig.json index 5797e8902b..f901861a39 100644 --- a/vendor/schemastery/tsconfig.json +++ b/vendor/schemastery/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib", + "outDir": "lib/typings", "module": "preserve", "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, diff --git a/vendor/timer/package.json b/vendor/timer/package.json index 30bfe58280..8c7afeafc4 100644 --- a/vendor/timer/package.json +++ b/vendor/timer/package.json @@ -5,17 +5,18 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/typings/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/typings/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/typings/**/*.d.ts", "src" ], "author": "Shigma ", diff --git a/vendor/timer/tsconfig.json b/vendor/timer/tsconfig.json index 99c40177cd..fc4fc9f4fc 100644 --- a/vendor/timer/tsconfig.json +++ b/vendor/timer/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib", + "outDir": "lib/typings", "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, "noImplicitOverride": false, From 846ea4dd60c9a7f8407547231476a8d162aa3951 Mon Sep 17 00:00:00 2001 From: imccyu Date: Wed, 17 Jun 2026 23:32:08 +0800 Subject: [PATCH 06/21] docs: vendor README modifications --- vendor/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vendor/README.md b/vendor/README.md index 04e63f26c1..87fbc46fb1 100644 --- a/vendor/README.md +++ b/vendor/README.md @@ -31,9 +31,10 @@ Intentionally **not** vendored (verified unused by this set): `reggol`, `@cordis Keep this log exhaustive — every divergence from upstream must be listed. 1. **`hmr/src/index.ts`**: removed the `./locales/en-US.yml` / `./locales/zh-CN.yml` imports, the `.i18n({...})` call on the `Config` schema, and the `src/locales/` directory. Rationale: those imports require a runtime YAML loader hook (`@cordisjs/unyaml`) that we do not vendor; the i18n texts only localize config descriptions. -2. **All `package.json` files**: regenerated — added `private: true`, added `src` to `files` and a `./src/*` export where missing, removed upstream `devDependencies`/`scripts`/`repository` fields. Dependency and peer-dependency ranges preserved, except `hmr` declares `esbuild` as a direct dev dependency because its source imports the `BuildFailure` type and pnpm's strict workspace resolution requires the owner package to name that dependency. -3. **All `tsconfig.json` files**: regenerated to extend the repo-root `tsconfig.base.json` and declare project references. -4. **`schemastery/tsdown.config.ts` and `logger-console/tsdown.config.ts`**: ours, not upstream files — per-package build-shape overrides (dual ESM+CJS output; separate node/browser entries) for the repo-root tsdown build. Like the regenerated tsconfigs, they are not part of the upstream sync surface. +2. **All `package.json` files**: regenerated — added `private: true`, added precise `files` entries for bundled runtime files and `lib/typings/**/*.d.ts`, preserved `src` in `files` only for packages whose previous file list already shipped it, added a `./src/*` export where missing, pointed declaration metadata at `lib/typings`, and removed upstream `devDependencies`/`scripts`/`repository` fields. Dependency and peer-dependency ranges preserved, except `hmr` declares `esbuild` as a direct dev dependency because its source imports the `BuildFailure` type and pnpm's strict workspace resolution requires the owner package to name that dependency. +3. **All `tsconfig.json` files**: regenerated to extend the repo-root `tsconfig.base.json`, emit TypeScript intermediates to `lib/typings`, and declare project references. +4. **`loader/src/config/isolate.ts`**: changed the internal declaration merge specifier from `declare module './entry.ts'` to `declare module './entry'` so generated declarations are extensionless and no declaration postprocess is needed. +5. **`schemastery/tsdown.config.ts` and `logger-console/tsdown.config.ts`**: ours, not upstream files — per-package build-shape overrides (dual ESM+CJS output; separate node/browser entries) for the repo-root tsdown build. They read the JS emitted under `lib/typings` and then write the publish runtime entries under `lib/`. Like the regenerated tsconfigs, they are not part of the upstream sync surface. ## Sync procedure From 279e9f17eb62c237f92d404eb6b4a0d262e92868 Mon Sep 17 00:00:00 2001 From: imccyu Date: Wed, 17 Jun 2026 23:21:42 +0800 Subject: [PATCH 07/21] refactor: ts in packages/*/tests use extensionless import --- packages/acp/tests/bridge.spec.ts | 2 +- packages/acp/tests/codec.spec.ts | 2 +- packages/acp/tests/dispose.spec.ts | 2 +- packages/acp/tests/edges.spec.ts | 2 +- packages/acp/tests/harness.ts | 4 ++-- packages/acp/tests/load.spec.ts | 2 +- packages/acp/tests/multi-session.spec.ts | 2 +- packages/acp/tests/properties.spec.ts | 2 +- packages/acp/tests/stream-update.spec.ts | 2 +- packages/acp/tests/turns.spec.ts | 2 +- packages/agent-loop/tests/agent.spec.ts | 2 +- packages/agent-loop/tests/config-session-id.spec.ts | 2 +- packages/agent-loop/tests/coverage-edges.spec.ts | 2 +- packages/agent-loop/tests/loop.spec.ts | 2 +- packages/agent-loop/tests/resume.spec.ts | 2 +- packages/agent-loop/tests/review-fixes.spec.ts | 2 +- packages/llm-replay/tests/llm-replay.spec.ts | 2 +- packages/session-persistence-jsonl/tests/jsonl.spec.ts | 4 ++-- packages/session-persistence-sqlite/tests/sqlite.spec.ts | 4 ++-- packages/session-persistence/tests/contract.ts | 2 +- packages/session-persistence/tests/persistence.spec.ts | 4 ++-- packages/session/tests/repair.spec.ts | 4 ++-- packages/tool-bash/tests/integration.spec.ts | 2 +- packages/ui-stdio/tests/ui-stdio.spec.ts | 2 +- 24 files changed, 29 insertions(+), 29 deletions(-) diff --git a/packages/acp/tests/bridge.spec.ts b/packages/acp/tests/bridge.spec.ts index dd10a88bcb..af3b616aff 100644 --- a/packages/acp/tests/bridge.spec.ts +++ b/packages/acp/tests/bridge.spec.ts @@ -3,7 +3,7 @@ import { mkdtemp, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk' -import { makeBridgeHarness, textResponse, type BridgeHarness } from './harness.ts' +import { makeBridgeHarness, textResponse, type BridgeHarness } from './harness' /** * End-to-end bridge specs over an in-memory transport: a real diff --git a/packages/acp/tests/codec.spec.ts b/packages/acp/tests/codec.spec.ts index 38a7a6cb41..feb75e9a1a 100644 --- a/packages/acp/tests/codec.spec.ts +++ b/packages/acp/tests/codec.spec.ts @@ -6,7 +6,7 @@ import { harnessBlockToAcpContent, promptHasUnsupportedContent, turnEndToStopReason, -} from '../src/codec.ts' +} from '../src/codec' describe('turnEndToStopReason', () => { // The SDK rejects an unknown stopReason, so this must be total over every diff --git a/packages/acp/tests/dispose.spec.ts b/packages/acp/tests/dispose.spec.ts index 45e351ced5..dc179d9cd2 100644 --- a/packages/acp/tests/dispose.spec.ts +++ b/packages/acp/tests/dispose.spec.ts @@ -3,7 +3,7 @@ import { mkdtemp, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk' -import { makeBridgeHarness } from './harness.ts' +import { makeBridgeHarness } from './harness' describe('acp bridge — disposal & HMR safety', () => { let storageDir: string diff --git a/packages/acp/tests/edges.spec.ts b/packages/acp/tests/edges.spec.ts index 9484368322..b479b0b120 100644 --- a/packages/acp/tests/edges.spec.ts +++ b/packages/acp/tests/edges.spec.ts @@ -3,7 +3,7 @@ import { mkdtemp, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk' -import { makeBridgeHarness, textResponse, type BridgeHarness } from './harness.ts' +import { makeBridgeHarness, textResponse, type BridgeHarness } from './harness' describe('acp bridge — demux & config edges', () => { let storageDir: string diff --git a/packages/acp/tests/harness.ts b/packages/acp/tests/harness.ts index 4f6b5ac17a..4b41b013bd 100644 --- a/packages/acp/tests/harness.ts +++ b/packages/acp/tests/harness.ts @@ -30,8 +30,8 @@ import { type SessionNotification, type Stream, } from '@agentclientprotocol/sdk' -import * as AcpPlugin from '../src/index.ts' -import { type AcpConfig } from '../src/index.ts' +import * as AcpPlugin from '../src/index' +import { type AcpConfig } from '../src/index' /** A scripted mock adapter (mirrors the agent-loop test adapter). */ class MockAdapter extends LlmAdapter { diff --git a/packages/acp/tests/load.spec.ts b/packages/acp/tests/load.spec.ts index f06c707d85..c2a5237d89 100644 --- a/packages/acp/tests/load.spec.ts +++ b/packages/acp/tests/load.spec.ts @@ -4,7 +4,7 @@ import { tmpdir } from 'node:os' import { join } from 'node:path' import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk' import { SessionId } from '@deepseek-ai/dsh-session' -import { makeBridgeHarness, textResponse, toolCallResponse, type BridgeHarness, type CapturedUpdate } from './harness.ts' +import { makeBridgeHarness, textResponse, toolCallResponse, type BridgeHarness, type CapturedUpdate } from './harness' /** Concatenate the text of all agent_message_chunk updates. */ function messageText(updates: CapturedUpdate[]): string { diff --git a/packages/acp/tests/multi-session.spec.ts b/packages/acp/tests/multi-session.spec.ts index 1c20d2ba39..0a52cb66c1 100644 --- a/packages/acp/tests/multi-session.spec.ts +++ b/packages/acp/tests/multi-session.spec.ts @@ -3,7 +3,7 @@ import { mkdtemp, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk' -import { makeBridgeHarness, textResponse, type BridgeHarness, type CapturedUpdate } from './harness.ts' +import { makeBridgeHarness, textResponse, type BridgeHarness, type CapturedUpdate } from './harness' /** Text of the agent_message_chunk updates scoped to one session id. */ function messageTextFor(updates: { sessionId?: string; update: CapturedUpdate }[], sessionId: string): string { diff --git a/packages/acp/tests/properties.spec.ts b/packages/acp/tests/properties.spec.ts index 5364c02d7b..4013dae163 100644 --- a/packages/acp/tests/properties.spec.ts +++ b/packages/acp/tests/properties.spec.ts @@ -19,7 +19,7 @@ import fc from 'fast-check' import { CallId } from '@deepseek-ai/dsh-llm' import type { SessionEvent } from '@deepseek-ai/dsh-session' import type { SessionNotification } from '@agentclientprotocol/sdk' -import { streamSessionEventUpdate } from '../src/index.ts' +import { streamSessionEventUpdate } from '../src/index' const LEGAL_UPDATE_KINDS = new Set([ 'agent_message_chunk', diff --git a/packages/acp/tests/stream-update.spec.ts b/packages/acp/tests/stream-update.spec.ts index cdba5a3bf3..13c4c445cf 100644 --- a/packages/acp/tests/stream-update.spec.ts +++ b/packages/acp/tests/stream-update.spec.ts @@ -3,7 +3,7 @@ import { CallId } from '@deepseek-ai/dsh-llm' import type { SessionEvent } from '@deepseek-ai/dsh-session' import type { SessionNotification } from '@agentclientprotocol/sdk' import type { ToolDefinition, ToolRegistry } from '@deepseek-ai/dsh-tools' -import { streamSessionEventUpdate, agentOptions, ToolPresenter } from '../src/index.ts' +import { streamSessionEventUpdate, agentOptions, ToolPresenter } from '../src/index' /** Collect the updates a single event produces (no presenter → generic fallback). */ function updatesFor(event: SessionEvent): SessionNotification['update'][] { diff --git a/packages/acp/tests/turns.spec.ts b/packages/acp/tests/turns.spec.ts index 19c3be2556..da4a38a554 100644 --- a/packages/acp/tests/turns.spec.ts +++ b/packages/acp/tests/turns.spec.ts @@ -11,7 +11,7 @@ import { textResponse, toolCallResponse, type BridgeHarness, -} from './harness.ts' +} from './harness' /** Boilerplate: initialize + create one session, returning its id. */ async function newSession(h: BridgeHarness, clientCapabilities: Record = {}): Promise { diff --git a/packages/agent-loop/tests/agent.spec.ts b/packages/agent-loop/tests/agent.spec.ts index 7c46df956c..1f04fb7de6 100644 --- a/packages/agent-loop/tests/agent.spec.ts +++ b/packages/agent-loop/tests/agent.spec.ts @@ -7,7 +7,7 @@ import SystemPrompt from '@deepseek-ai/dsh-system-prompt' import ToolRegistry from '@deepseek-ai/dsh-tools' import AgentRegistry from '@deepseek-ai/dsh-agent' import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' -import { MockAdapter, textResponse } from './mock-adapter.ts' +import { MockAdapter, textResponse } from './mock-adapter' async function harness(adapter: MockAdapter) { const ctx = new Context() diff --git a/packages/agent-loop/tests/config-session-id.spec.ts b/packages/agent-loop/tests/config-session-id.spec.ts index 13a62bca8c..2dd911a178 100644 --- a/packages/agent-loop/tests/config-session-id.spec.ts +++ b/packages/agent-loop/tests/config-session-id.spec.ts @@ -10,7 +10,7 @@ import ToolRegistry from '@deepseek-ai/dsh-tools' import AgentRegistry from '@deepseek-ai/dsh-agent' import SessionPersistenceJsonl from '@deepseek-ai/dsh-session-persistence-jsonl' import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' -import { MockAdapter, textResponse } from './mock-adapter.ts' +import { MockAdapter, textResponse } from './mock-adapter' const dirs: string[] = [] afterEach(async () => { for (const d of dirs.splice(0)) await rm(d, { recursive: true, force: true }) }) diff --git a/packages/agent-loop/tests/coverage-edges.spec.ts b/packages/agent-loop/tests/coverage-edges.spec.ts index 96c061d2dd..ee76a22f6a 100644 --- a/packages/agent-loop/tests/coverage-edges.spec.ts +++ b/packages/agent-loop/tests/coverage-edges.spec.ts @@ -6,7 +6,7 @@ import SystemPrompt from '@deepseek-ai/dsh-system-prompt' import ToolRegistry, { defineTool } from '@deepseek-ai/dsh-tools' import AgentRegistry from '@deepseek-ai/dsh-agent' import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' -import { MockAdapter, textResponse, toolCallResponse } from './mock-adapter.ts' +import { MockAdapter, textResponse, toolCallResponse } from './mock-adapter' async function harness(adapter: MockAdapter) { const ctx = new Context() diff --git a/packages/agent-loop/tests/loop.spec.ts b/packages/agent-loop/tests/loop.spec.ts index f004e02f91..1d6cdee2d1 100644 --- a/packages/agent-loop/tests/loop.spec.ts +++ b/packages/agent-loop/tests/loop.spec.ts @@ -6,7 +6,7 @@ import SystemPrompt from '@deepseek-ai/dsh-system-prompt' import ToolRegistry, { defineTool } from '@deepseek-ai/dsh-tools' import AgentRegistry from '@deepseek-ai/dsh-agent' import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' -import { MockAdapter, maxTokensResponse, textResponse, toolCallResponse } from './mock-adapter.ts' +import { MockAdapter, maxTokensResponse, textResponse, toolCallResponse } from './mock-adapter' async function harness(adapter: MockAdapter) { const ctx = new Context() diff --git a/packages/agent-loop/tests/resume.spec.ts b/packages/agent-loop/tests/resume.spec.ts index 10313fdd26..508753753b 100644 --- a/packages/agent-loop/tests/resume.spec.ts +++ b/packages/agent-loop/tests/resume.spec.ts @@ -11,7 +11,7 @@ import ToolRegistry from '@deepseek-ai/dsh-tools' import AgentRegistry from '@deepseek-ai/dsh-agent' import SessionPersistenceJsonl from '@deepseek-ai/dsh-session-persistence-jsonl' import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' -import { MockAdapter, textResponse } from './mock-adapter.ts' +import { MockAdapter, textResponse } from './mock-adapter' const dirs: string[] = [] afterEach(async () => { for (const d of dirs.splice(0)) await rm(d, { recursive: true, force: true }) }) diff --git a/packages/agent-loop/tests/review-fixes.spec.ts b/packages/agent-loop/tests/review-fixes.spec.ts index 3f65ae737e..86306f9f9e 100644 --- a/packages/agent-loop/tests/review-fixes.spec.ts +++ b/packages/agent-loop/tests/review-fixes.spec.ts @@ -7,7 +7,7 @@ import ToolRegistry, { defineTool } from '@deepseek-ai/dsh-tools' import AgentRegistry, { AgentId } from '@deepseek-ai/dsh-agent' import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' import * as Invariants from '@deepseek-ai/dsh-invariants' -import { MockAdapter, textResponse, toolCallResponse } from './mock-adapter.ts' +import { MockAdapter, textResponse, toolCallResponse } from './mock-adapter' /** * Regression tests for the findings of the first architecture review diff --git a/packages/llm-replay/tests/llm-replay.spec.ts b/packages/llm-replay/tests/llm-replay.spec.ts index f16e988035..6b8ed2e355 100644 --- a/packages/llm-replay/tests/llm-replay.spec.ts +++ b/packages/llm-replay/tests/llm-replay.spec.ts @@ -14,7 +14,7 @@ import { loadReplayScript, name, parseSessionLog, -} from '../src/index.ts' +} from '../src/index' /** * Unit tests for the replay llm/stream plugin. These drive the listener through diff --git a/packages/session-persistence-jsonl/tests/jsonl.spec.ts b/packages/session-persistence-jsonl/tests/jsonl.spec.ts index 8257a9853c..88a21b5705 100644 --- a/packages/session-persistence-jsonl/tests/jsonl.spec.ts +++ b/packages/session-persistence-jsonl/tests/jsonl.spec.ts @@ -6,8 +6,8 @@ import { join } from 'node:path' import SessionStore, { SessionId } from '@deepseek-ai/dsh-session' import type { Session, SessionEvent, SessionMeta } from '@deepseek-ai/dsh-session' import SessionPersistenceJsonl from '@deepseek-ai/dsh-session-persistence-jsonl' -import { encodeSegment, logPath, scanLog, sessionDir, sidecarPath } from '../src/format.ts' -import { runPersistenceContract, meta, oneTurnLog } from '../../session-persistence/tests/contract.ts' +import { encodeSegment, logPath, scanLog, sessionDir, sidecarPath } from '../src/format' +import { runPersistenceContract, meta, oneTurnLog } from '../../session-persistence/tests/contract' let root: string const dirs: string[] = [] diff --git a/packages/session-persistence-sqlite/tests/sqlite.spec.ts b/packages/session-persistence-sqlite/tests/sqlite.spec.ts index d6216b7b50..3eb7cbad2c 100644 --- a/packages/session-persistence-sqlite/tests/sqlite.spec.ts +++ b/packages/session-persistence-sqlite/tests/sqlite.spec.ts @@ -6,8 +6,8 @@ import { join } from 'node:path' import SessionStore, { SessionId } from '@deepseek-ai/dsh-session' import type { Session, SessionEvent, SessionMeta } from '@deepseek-ai/dsh-session' import SessionPersistenceSqlite, { SCHEMA_VERSION } from '@deepseek-ai/dsh-session-persistence-sqlite' -import { openDatabase, scanRows, type EventRow } from '../src/schema.ts' -import { runPersistenceContract, meta, oneTurnLog } from '../../session-persistence/tests/contract.ts' +import { openDatabase, scanRows, type EventRow } from '../src/schema' +import { runPersistenceContract, meta, oneTurnLog } from '../../session-persistence/tests/contract' const dirs: string[] = [] afterEach(async () => { for (const d of dirs.splice(0)) await rm(d, { recursive: true, force: true }) }) diff --git a/packages/session-persistence/tests/contract.ts b/packages/session-persistence/tests/contract.ts index 73f6f653bd..3be9fadba2 100644 --- a/packages/session-persistence/tests/contract.ts +++ b/packages/session-persistence/tests/contract.ts @@ -12,7 +12,7 @@ import { describe, expect, it, vi } from 'vitest' import { SessionId } from '@deepseek-ai/dsh-session' import type { SessionEvent, SessionMeta } from '@deepseek-ai/dsh-session' import { CallId } from '@deepseek-ai/dsh-llm' -import type { SessionPersistence } from '../src/index.ts' +import type { SessionPersistence } from '../src/index' /** A backend under test plus its teardown. */ export interface ContractBackend { diff --git a/packages/session-persistence/tests/persistence.spec.ts b/packages/session-persistence/tests/persistence.spec.ts index 5c0a29131f..2c65639060 100644 --- a/packages/session-persistence/tests/persistence.spec.ts +++ b/packages/session-persistence/tests/persistence.spec.ts @@ -2,8 +2,8 @@ import { describe, expect, it } from 'vitest' import { Context } from 'cordis' import { SessionId, isJsonValue, interruptedTurnClosers } from '@deepseek-ai/dsh-session' import type { SessionEvent, SessionMeta, SessionSummary } from '@deepseek-ai/dsh-session' -import { SessionPersistence, assertSerializable, seedCoversPrefix } from '../src/index.ts' -import { runPersistenceContract, meta, oneTurnLog } from './contract.ts' +import { SessionPersistence, assertSerializable, seedCoversPrefix } from '../src/index' +import { runPersistenceContract, meta, oneTurnLog } from './contract' /** * A minimal in-memory {@link SessionPersistence} used to (a) cover the abstract diff --git a/packages/session/tests/repair.spec.ts b/packages/session/tests/repair.spec.ts index 57422e7719..2fa1bfae27 100644 --- a/packages/session/tests/repair.spec.ts +++ b/packages/session/tests/repair.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' import { CallId } from '@deepseek-ai/dsh-llm' -import { interruptedTurnClosers } from '../src/index.ts' -import type { SessionEvent } from '../src/index.ts' +import { interruptedTurnClosers } from '../src/index' +import type { SessionEvent } from '../src/index' /** * Unit coverage for the crash-recovery closer synthesis. The persistence diff --git a/packages/tool-bash/tests/integration.spec.ts b/packages/tool-bash/tests/integration.spec.ts index d31b3a5a7e..e2687b2708 100644 --- a/packages/tool-bash/tests/integration.spec.ts +++ b/packages/tool-bash/tests/integration.spec.ts @@ -9,7 +9,7 @@ import AgentRegistry from '@deepseek-ai/dsh-agent' import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' import { LocalBashExecutor } from '@deepseek-ai/dsh-bash-local' import * as ToolBash from '@deepseek-ai/dsh-tool-bash' -import { MockAdapter, textResponse, toolCallResponse } from '../../agent-loop/tests/mock-adapter.ts' +import { MockAdapter, textResponse, toolCallResponse } from '../../agent-loop/tests/mock-adapter' /** * Full-loop integration: a scripted mock model drives the REAL bash tool diff --git a/packages/ui-stdio/tests/ui-stdio.spec.ts b/packages/ui-stdio/tests/ui-stdio.spec.ts index bd5e0f7f91..72d82b539c 100644 --- a/packages/ui-stdio/tests/ui-stdio.spec.ts +++ b/packages/ui-stdio/tests/ui-stdio.spec.ts @@ -5,7 +5,7 @@ import type { Agent, AgentStatus } from '@deepseek-ai/dsh-agent' import AgentRegistry from '@deepseek-ai/dsh-agent' import type { ContentBlock } from '@deepseek-ai/dsh-llm' import type { Session, SessionEvent } from '@deepseek-ai/dsh-session' -import { createStdioChat, type Config, type StdioRuntime } from '../src/index.ts' +import { createStdioChat, type Config, type StdioRuntime } from '../src/index' /** * Unit tests for the stdio UI plugin. They drive the REAL plugin body From ec9b093cb0a4e4d7e323fdde9c06bcdf72e640c2 Mon Sep 17 00:00:00 2001 From: imccyu Date: Wed, 17 Jun 2026 23:31:38 +0800 Subject: [PATCH 08/21] build: two-step for packages/vendor build and README --- AGENTS.md | 4 ++-- docs/cookbook/adding-a-package.md | 6 +++--- docs/cookbook/adding-a-vendored-package.md | 14 +++++++------- docs/development.md | 2 +- package.json | 1 + packages/README.md | 2 +- pnpm-lock.yaml | 20 ++++++++++++++++++-- tsconfig.base.json | 12 +++++------- tsdown.config.ts | 10 +++++----- vendor/logger-console/tsdown.config.ts | 11 ++++++----- vendor/schemastery/tsdown.config.ts | 8 ++++---- 11 files changed, 53 insertions(+), 37 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 0533c4cf0a..e7a6c9e7e9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -88,7 +88,7 @@ pnpm run typecheck # tsc -b tsconfig.build.json (declarations) + tsc -p # tsconfig.typecheck.json (tests/examples typecheck too) pnpm run lint # eslint . pnpm run lint:fix # eslint . --fix -pnpm run build # tsc -b tsconfig.build.json && tsdown (JS bundles into lib/) +pnpm run build # tsc emits lib/typings, then tsdown bundles runtime lib/index.* pnpm run knip # dead-code / unused-dependency check pnpm run publint # package.json publish-correctness check (publishable packages/*) pnpm run hygiene # knip + publint + workspace constraints @@ -126,7 +126,7 @@ Dev/test/demo run **unbuilt** via tsx + the `paths` map in the root `tsconfig.js ## Conventions - **Package naming**: every npm package in this repo is `@deepseek-ai/dsh-` (vendored packages keep their upstream names and are `private: true`). -- **ESM everywhere** (`"type": "module"`); imports between workspace packages use package names, never relative paths across package boundaries. In-package imports use explicit `.ts` extensions (allowImportingTsExtensions). +- **ESM everywhere** (`"type": "module"`); imports between workspace packages use package names, never relative paths across package boundaries. In-package relative imports are extensionless so generated `.d.ts` files stay extensionless; `lib/typings/**/*.js` is a bundler-only intermediate, not a Node ESM entrypoint. - **`cordis` is a peerDependency** (+ devDependency) of every harness package, mirroring upstream convention. - **Registrations are effects**: anything a plugin contributes (adapter, tool, section, agent, event listener) goes through `ctx.effect()` / `ctx.on()` so disposal and HMR work. If you write a registry, `register()` must return the disposer. - **Typed events via declaration merging**: services declare their events in `declare module 'cordis' { interface Events { … } }`, and their ctx key in `interface Context`. Extensible unions use the merge-extensible-map pattern (see `ContentBlockMap`, `MessageSourceMap`). diff --git a/docs/cookbook/adding-a-package.md b/docs/cookbook/adding-a-package.md index ed40f242e4..9ae8033fe3 100644 --- a/docs/cookbook/adding-a-package.md +++ b/docs/cookbook/adding-a-package.md @@ -7,7 +7,7 @@ The file-by-file checklist for a new `@deepseek-ai/dsh-` package. (Verifie ``` packages// package.json # copy from packages/tools, adjust name/description/deps - tsconfig.json # extends ../../tsconfig.base.json, rootDir src, outDir lib, + tsconfig.json # extends ../../tsconfig.base.json, rootDir src, outDir lib/typings, # references: vendor/cosmokit, vendor/cordis (+ vendor/schemastery # if you use Config, + ../ for each dsh dependency) src/index.ts # service default export or plugin (name/inject/apply/Config) @@ -15,14 +15,14 @@ packages// README.md # service API, events, extension points, design notes ``` -package.json invariants (enforced by `pnpm run constraints` / `scripts/check-workspace-constraints.ts`): `private: true`, `version: 0.0.1`, `type: module`, `cordis` in BOTH peerDependencies and devDependencies (same range). Mirror every dsh peer dependency in devDependencies. `schemastery` goes in `dependencies` (it is a runtime validator), matching agent-loop. +package.json invariants (enforced by `pnpm run constraints` / `scripts/check-workspace-constraints.ts`): `private: true`, `version: 0.0.1`, `type: module`, `main: "lib/index.js"`, `types: "lib/typings/index.d.ts"`, `exports["."].types: "./lib/typings/index.d.ts"`, `cordis` in BOTH peerDependencies and devDependencies (same range). Mirror every dsh peer dependency in devDependencies. `schemastery` goes in `dependencies` (it is a runtime validator), matching agent-loop. The `files` list is precise: `lib/index.js`, `lib/typings/**/*.d.ts`, and `src`; do not publish `lib/typings` JS/map intermediates or stale root declaration files. ## 2. Register it in the root configs | File | Change | |---|---| | `tsconfig.base.json` | add `"@deepseek-ai/dsh-": ["./packages//src"]` to `paths` | -| `tsconfig.typecheck.json` | same entry (this file overrides the map wholesale) | +| `tsconfig.json` | add `{ "path": "./packages/" }` to `references` | | `tsconfig.build.json` | add `{ "path": "./packages/" }` to `references` | | `scripts/publint-all.ts` | add `'packages/'` to the array | | `knip.json` | only if the package has non-`*.spec.ts` entries (e.g. `*.e2e.ts` → add a per-workspace override like `packages/llm-deepseek`) | diff --git a/docs/cookbook/adding-a-vendored-package.md b/docs/cookbook/adding-a-vendored-package.md index fa3c754cb8..fb32d60d06 100644 --- a/docs/cookbook/adding-a-vendored-package.md +++ b/docs/cookbook/adding-a-vendored-package.md @@ -12,13 +12,13 @@ vendor// README.md LICENSE # if upstream ships them ``` -`tsconfig.json` mirrors the other vendored packages — `rootDir: src`, `outDir: lib`, the strictness relaxations upstream code needs, and a `references` entry for every other vendored package it imports: +`tsconfig.json` mirrors the other vendored packages — `rootDir: src`, `outDir: lib/typings`, the strictness relaxations upstream code needs, and a `references` entry for every other vendored package it imports: ```jsonc { "extends": "../../tsconfig.base.json", "compilerOptions": { - "rootDir": "src", "outDir": "lib", + "rootDir": "src", "outDir": "lib/typings", "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, "noImplicitOverride": false, "noUnusedLocals": false, "noUnusedParameters": false }, @@ -27,19 +27,19 @@ vendor// } ``` -`package.json` invariants: `"private": true` (vendored packages are never published), keep upstream's `name`/`version`/`exports`/`type`, and list its cordis deps in `peerDependencies` (matching the upstream manifest). Transitive upstream deps must themselves be vendored or already present — vendoring one package often means vendoring its dependency tree (e.g. `@cordisjs/plugin-http` pulls `@cordisjs/fetch-file`). +`package.json` invariants: `"private": true` (vendored packages are never published), keep upstream's `name`/`version`/`exports`/`type`, point declaration metadata at `lib/typings`, and list its cordis deps in `peerDependencies` (matching the upstream manifest). Transitive upstream deps must themselves be vendored or already present — vendoring one package often means vendoring its dependency tree (e.g. `@cordisjs/plugin-http` pulls `@cordisjs/fetch-file`). ## 2. Register it in the root configs | File | Change | |---|---| | `tsconfig.base.json` | add `"": ["./vendor//src"]` to `paths` | -| `tsconfig.typecheck.json` | add `"": ["./vendor//lib"]` — this file points at built declarations, not src. If the package's `types` entry isn't `lib/index.d.ts`, point at that built file instead (e.g. `logger-console` maps to `./vendor/logger-console/lib/shared`, matching its `"types": "lib/shared.d.ts"`). | +| `tsconfig.json` | add `{ "path": "./vendor/" }` to `references` | | `tsconfig.build.json` | add `{ "path": "./vendor/" }` to `references` (before the `packages/*` entries) | | `vendor/README.md` | add a manifest table row (dir, npm name, version, upstream repo, commit SHA) and log any local modifications | | `scripts/publint-all.ts` | only if the vendored package is itself published from here (vendored deps normally are not — skip) | -Covered automatically by globs — no edits needed: root `package.json` workspaces (`vendor/*`), `tsdown.config.ts`, `vitest.config.ts`, `eslint.config.mjs`. A per-package `vendor//tsdown.config.ts` is needed ONLY if the build shape diverges from the root default (dual ESM/CJS or multiple entries — see `vendor/schemastery` and `vendor/logger-console`). +Covered automatically by globs — no edits needed: root `package.json` workspaces (`vendor/*`), `tsdown.config.ts`, `vitest.config.ts`, `eslint.config.mjs`. A per-package `vendor//tsdown.config.ts` is needed ONLY if the build shape diverges from the root default (dual ESM/CJS or multiple entries — see `vendor/schemastery` and `vendor/logger-console`); its entry should read the JS emitted under `lib/typings`. ## 3. Mind the manifest guard @@ -49,8 +49,8 @@ Covered automatically by globs — no edits needed: root `package.json` workspac ```sh pnpm install # registers the workspace -pnpm run typecheck # the base→lib path split means: run once after a fresh add +pnpm run typecheck pnpm run build && pnpm run test && pnpm run constraints ``` -Note the `tsconfig` two-map split (called out in [AGENTS.md](../../AGENTS.md) § Secrets/.env): `lint`'s type-aware rules resolve vendored packages through their built `lib/` declarations, so run `pnpm run typecheck` (which builds them) once after adding the package or lint reports unresolved-type errors. +The source `paths` map is shared by build and root typecheck configs. The important isolation boundary is the project-reference graph: vendored source must be referenced through its own `vendor//tsconfig.json`, not pulled into a root strict program. diff --git a/docs/development.md b/docs/development.md index 2270aa0436..ff81ac4079 100644 --- a/docs/development.md +++ b/docs/development.md @@ -98,7 +98,7 @@ pnpm run verify-md-wrap # fail on hard-wrapped prose paragraphs in docs/README pnpm run doc-sync # doc-typecheck, event taxonomy, and markdown wrap verification pnpm run gen-module-graph # regenerate docs/module-graph.md from package peerDeps pnpm run verify-module-graph # fail if docs/module-graph.md is stale -pnpm run build # build declarations and JS bundles +pnpm run build # emit lib/typings intermediates, then bundle lib/index.* runtime files pnpm run hygiene # knip, publint, and workspace constraints ``` diff --git a/package.json b/package.json index 50319023cf..f8f79ee63e 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ ], "scripts": { "build": "tsc -b tsconfig.build.json && tsdown", + "clean:build": "rm -rf .typecheck packages/*/lib vendor/*/lib *.tsbuildinfo", "typecheck": "tsc -b tsconfig.build.json && tsc -p tsconfig.typecheck.json", "lint": "eslint .", "lint:fix": "eslint . --fix", diff --git a/packages/README.md b/packages/README.md index b9fe1aa5f1..25aabd038e 100644 --- a/packages/README.md +++ b/packages/README.md @@ -60,5 +60,5 @@ Each package has its own `README.md` with purpose, service API, events, extensio - **Declaration merging for events and ctx**: services declare their events in `declare module 'cordis' { interface Events { ... } }` and their ctx key in `interface Context`. - **Waterfall semantics**: `ctx.waterfall` listeners receive `(...args, next)` and MUST call `next()` to delegate; returning without it short-circuits (the veto mechanism). - **Extensible unions**: `ContentBlockMap`, `MessageSourceMap`, `FinishReasonMap`, `TurnTriggerMap`, `TurnEndReasonMap`, and `SessionEventMap` use the merge-extensible-map pattern so plugins can add variants via declaration merging. -- **ESM everywhere**; imports use package names across package boundaries, `.ts` extensions within a package. +- **ESM everywhere**; imports use package names across package boundaries and extensionless relative specifiers within a package. - **Tests**: vitest, colocated under `packages//tests/*.spec.ts`. Every registry needs an HMR-safety test. Err on the side of more tests. diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5026104cd9..d44608e415 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -49,7 +49,7 @@ importers: version: 0.3.21 tsdown: specifier: ^0.22.2 - version: 0.22.2(oxc-resolver@11.20.0)(publint@0.3.21)(tsx@4.22.4)(typescript@6.0.3) + version: 0.22.2(oxc-resolver@11.20.0)(publint@0.3.21)(tsx@4.22.4)(typescript@6.0.3)(unrun@0.3.1) tsx: specifier: ^4.22.4 version: 4.22.4 @@ -2620,6 +2620,16 @@ packages: unist-util-visit@5.1.0: resolution: {integrity: sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg==} + unrun@0.3.1: + resolution: {integrity: sha512-onIck/oNnCaytwths1ZVp1LK2Gq2hPoyFhiHebObuUXqR3S0uHuLLaBK8K6mRRgV7Ptip8AnNvaUsgzwWwBZuA==} + engines: {node: ^22.13.0 || >=24.0.0} + hasBin: true + peerDependencies: + synckit: ^0.11.11 + peerDependenciesMeta: + synckit: + optional: true + uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} @@ -4933,7 +4943,7 @@ snapshots: optionalDependencies: typescript: 6.0.3 - tsdown@0.22.2(oxc-resolver@11.20.0)(publint@0.3.21)(tsx@4.22.4)(typescript@6.0.3): + tsdown@0.22.2(oxc-resolver@11.20.0)(publint@0.3.21)(tsx@4.22.4)(typescript@6.0.3)(unrun@0.3.1): dependencies: ansis: 4.3.1 cac: 7.0.0 @@ -4954,6 +4964,7 @@ snapshots: publint: 0.3.21 tsx: 4.22.4 typescript: 6.0.3 + unrun: 0.3.1 transitivePeerDependencies: - '@ts-macro/tsc' - '@typescript/native-preview' @@ -5015,6 +5026,11 @@ snapshots: unist-util-is: 6.0.1 unist-util-visit-parents: 6.0.2 + unrun@0.3.1: + dependencies: + rolldown: 1.1.1 + optional: true + uri-js@4.4.1: dependencies: punycode: 2.3.1 diff --git a/tsconfig.base.json b/tsconfig.base.json index d26ab0d56d..56ccab1ccc 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -4,12 +4,12 @@ "module": "esnext", "moduleResolution": "bundler", "declaration": true, - "emitDeclarationOnly": true, + "sourceMap": true, + "declarationMap": true, "composite": true, "incremental": true, "skipLibCheck": true, "esModuleInterop": true, - "allowImportingTsExtensions": true, "verbatimModuleSyntax": false, "strict": true, "noUncheckedIndexedAccess": true, @@ -19,11 +19,9 @@ "noUnusedLocals": true, "noUnusedParameters": true, "types": ["node"], - // Source-level resolution for the build graph: without this, a fresh - // checkout's first `tsc -b` resolves sibling vendor plugins through their - // package.json types (vendor/*/lib/*.d.ts) which don't exist yet — TS2307 - // until a second run. Derived configs that want lib resolution - // (tsconfig.typecheck.json) override this map wholesale. + // Source-level resolution for every repo-local graph. Project references, + // not declaration path aliases, keep each package/vendor source compiled + // under its own tsconfig boundary. "paths": { "cordis": ["./vendor/cordis/src"], "cosmokit": ["./vendor/cosmokit/src"], diff --git a/tsdown.config.ts b/tsdown.config.ts index 3b9039cc36..d6c3cca603 100644 --- a/tsdown.config.ts +++ b/tsdown.config.ts @@ -1,10 +1,10 @@ import { defineConfig } from 'tsdown' /** - * JS bundling for all workspace packages (vendor/* + packages/*). - * Declarations are NOT produced here — `tsc -b tsconfig.build.json` owns - * .d.ts output (composite project references); hence `dts: false` and - * `clean: false` (lib/ already holds tsc's declarations). + * Runtime bundling for all workspace packages (vendor/* + packages/*). + * TypeScript source is compiled first by `tsc -b tsconfig.build.json`; tsdown + * reads only the emitted JS under lib/typings and writes lib/index.* runtime + * bundles. Declarations are NOT produced here, hence `dts: false`. * * Per-package shape overrides live in `/tsdown.config.ts` * (schemastery: dual ESM+CJS; logger-console: extra browser entry). @@ -13,7 +13,7 @@ export default defineConfig({ // Explicit globs: `workspace: true` would also discover examples/* (any // package.json), but only vendor/* and packages/* are pnpm workspaces. workspace: ['vendor/*', 'packages/*'], - entry: ['src/index.ts'], + entry: ['lib/typings/index.js'], outDir: 'lib', format: ['esm'], platform: 'node', diff --git a/vendor/logger-console/tsdown.config.ts b/vendor/logger-console/tsdown.config.ts index 3d9b213b6b..c85dad4a28 100644 --- a/vendor/logger-console/tsdown.config.ts +++ b/vendor/logger-console/tsdown.config.ts @@ -3,9 +3,10 @@ import { defineConfig } from 'tsdown' /** * logger-console ships two entries: the node exporter (index) and the * browser exporter (browser), selected via package.json `exports` - * conditions. They are built as two single-entry passes so the shared - * base class is inlined into each (matching upstream's published shape) - * instead of split into a hash-named chunk. + * conditions. The entries are JS emitted by tsc under lib/typings and are + * bundled as two single-entry passes so the shared base class is inlined into + * each (matching upstream's published shape) instead of split into a hash-named + * chunk. */ const shared = { outDir: 'lib', @@ -18,6 +19,6 @@ const shared = { } as const export default defineConfig([ - { ...shared, entry: ['src/index.ts'] }, - { ...shared, entry: ['src/browser.ts'] }, + { ...shared, entry: ['lib/typings/index.js'] }, + { ...shared, entry: ['lib/typings/browser.js'] }, ]) diff --git a/vendor/schemastery/tsdown.config.ts b/vendor/schemastery/tsdown.config.ts index 43b4384a06..b16c217750 100644 --- a/vendor/schemastery/tsdown.config.ts +++ b/vendor/schemastery/tsdown.config.ts @@ -2,12 +2,12 @@ import { defineConfig } from 'tsdown' /** * schemastery has no `"type": "module"` and publishes dual-format output - * (package.json: main → lib/index.cjs, module → lib/index.mjs). Pin the - * extensions explicitly — the defaults for a CommonJS package would emit - * .mjs/.js instead. + * (package.json: main → lib/index.cjs, module → lib/index.mjs). The entry is + * the JS emitted by tsc under lib/typings; pin the bundled extensions + * explicitly because the defaults for a CommonJS package would emit .mjs/.js. */ export default defineConfig({ - entry: ['src/index.ts'], + entry: ['lib/typings/index.js'], outDir: 'lib', format: ['esm', 'cjs'], platform: 'node', From dc04fea749161c2ebdac94fff908de3dca21df61 Mon Sep 17 00:00:00 2001 From: imccyu Date: Wed, 17 Jun 2026 23:41:18 +0800 Subject: [PATCH 09/21] feat: one tsconfig.json and different rules --- AGENTS.md | 8 +-- docs/development.md | 9 +-- eslint.config.mjs | 6 +- examples/acp-agent/tests/acp.snapshot.ts | 4 +- .../tests/snapshot-normalize.spec.ts | 2 +- .../coding-agent/tests/coding-task.e2e.ts | 2 +- examples/coding-agent/tests/full-loop.e2e.ts | 2 +- examples/coding-agent/tests/resume.e2e.ts | 2 +- package.json | 2 +- scripts/doc-typecheck.ts | 63 ++++++++----------- tsconfig.json | 40 +++++++++++- tsconfig.test.json | 10 --- tsconfig.typecheck.json | 40 ------------ vitest.config.ts | 8 +-- vitest.e2e.config.ts | 2 +- vitest.snapshot.config.ts | 2 +- 16 files changed, 89 insertions(+), 113 deletions(-) delete mode 100644 tsconfig.test.json delete mode 100644 tsconfig.typecheck.json diff --git a/AGENTS.md b/AGENTS.md index e7a6c9e7e9..4bb814cab7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -84,8 +84,7 @@ pnpm run test:snapshot # ACP snapshot tests (examples/*/tests/**/*.snapshot.ts) pnpm run test:snapshot:record # re-record fixtures + goldens against the real # API (needs DEEPSEEK_API_KEY); accept-the-diff = re-record # (or `pnpm run test:snapshot -u` to refresh goldens only) -pnpm run typecheck # tsc -b tsconfig.build.json (declarations) + tsc -p - # tsconfig.typecheck.json (tests/examples typecheck too) +pnpm run typecheck # tsc -b tsconfig.json pnpm run lint # eslint . pnpm run lint:fix # eslint . --fix pnpm run build # tsc emits lib/typings, then tsdown bundles runtime lib/index.* @@ -98,7 +97,8 @@ pnpm run verify-event-taxonomy # assert the event-taxonomy table in docs/archit # matches the interface Events declarations in source pnpm run verify-md-wrap # assert no hard-wrapped prose paragraphs in README.md, # docs/**/*.md, packages/*/README.md, AGENTS.md (one line per paragraph) -pnpm run doc-sync # doc-typecheck + verify-event-taxonomy + verify-md-wrap (CI runs this) +pnpm run verify-md-links # assert relative Markdown links resolve in checked docs +pnpm run doc-sync # doc-typecheck + verify-event-taxonomy + verify-md-wrap + verify-md-links (CI runs this) pnpm run demo:echo # run examples/echo-agent (no API key; type "echo hi" to # see a tool call) — the mock skeleton pnpm run demo:coding # run examples/coding-agent — the real agent (needs @@ -121,7 +121,7 @@ cordis.yml configs reference env vars with the `!!js` tag: `apiKey: !!js process **Lean on with-key e2e tests — we are DeepSeek and model inference is cheap.** A no-key test (mock adapter, or an operation that never reaches the model) is great for determinism and CI, but it can only prove the plumbing, not that the agent actually *works* against a real model. Do not ration real-API tests to save tokens: write many of them, cover the real flows (a real prompt that writes a file, a multi-turn conversation, tool use, cancellation mid-stream), and run them frequently while developing — locally and whenever you have a key in the environment. **Especially smoke tests**: a cheap with-key smoke test that boots the real example, sends one real prompt, and checks the world (a file on disk, a non-empty assistant turn) catches whole classes of "green unit tests, broken product" failures that mocks structurally cannot — the very gap that let the ACP inject bug ship (see [docs/postmortem/0001](docs/postmortem/0001-acp-default-export-drops-inject.md)). The self-skip rule is ONLY so CI (which has no secrets) stays green and so a contributor without a key isn't blocked — it is not a signal that real-API tests are expensive or second-class. When in doubt, add the with-key test AND run it. -Dev/test/demo run **unbuilt** via tsx + the `paths` map in the root `tsconfig.json` (`vitest` resolves through `tsconfig.test.json`). Building is only needed for publishing/consumption outside the repo — with one exception: `pnpm run lint`'s type-aware rules resolve vendor packages through their built declarations (`tsconfig.typecheck.json` → `vendor/*/lib`), so run `pnpm run typecheck` once after a fresh clone (CI does the same) or lint reports unresolved-type `no-unsafe-*` errors. +Dev/test/demo run **unbuilt** via tsx + the source `paths` map in the root `tsconfig.json` (`vitest` resolves through that same root config). Building is only needed for publishing/consumption outside the repo. Non-published code (`examples`, tests, and scripts) is checked by root `tsconfig.json`, which sets `noEmit` and references the package/vendor graph so those sources stay checked under their own tsconfig boundaries. ## Conventions diff --git a/docs/development.md b/docs/development.md index ff81ac4079..700b25251d 100644 --- a/docs/development.md +++ b/docs/development.md @@ -31,7 +31,7 @@ Run typecheck once after a fresh clone: pnpm run typecheck ``` -That first typecheck builds declaration output used by type-aware linting for vendored packages. Without it, `pnpm run lint` can report unresolved-type `no-unsafe-*` errors even when source code is fine. +That first typecheck runs the package/vendor build graph and the root no-emit `tsconfig.json` graph for examples, tests, and scripts. The root graph uses the same source `paths` map but relies on project references so vendored code is checked under its own tsconfig settings. If you are preparing to push from a fresh clone or worktree, also build once: @@ -89,20 +89,21 @@ Use these from the repo root: pnpm run test # unit tests pnpm run test:coverage # unit tests with per-file coverage gates pnpm run test:e2e # real-API tests; self-skips without DEEPSEEK_API_KEY -pnpm run typecheck # build declarations, then typecheck source, tests, and examples +pnpm run typecheck # build package/vendor outputs, then typecheck examples, tests, and scripts pnpm run lint # eslint . pnpm run lint:fix # eslint . --fix pnpm run doc-typecheck # compile checked TypeScript snippets in Markdown docs pnpm run verify-event-taxonomy # compare docs/architecture.md event names with source pnpm run verify-md-wrap # fail on hard-wrapped prose paragraphs in docs/README markdown -pnpm run doc-sync # doc-typecheck, event taxonomy, and markdown wrap verification +pnpm run verify-md-links # fail on broken relative Markdown links in checked docs +pnpm run doc-sync # doc-typecheck, event taxonomy, markdown wrap, and link verification pnpm run gen-module-graph # regenerate docs/module-graph.md from package peerDeps pnpm run verify-module-graph # fail if docs/module-graph.md is stale pnpm run build # emit lib/typings intermediates, then bundle lib/index.* runtime files pnpm run hygiene # knip, publint, and workspace constraints ``` -When changing package public behavior, update the relevant README or JSDoc in the same change. `pnpm run doc-sync` catches checked TypeScript snippets, event-taxonomy drift, and hard-wrapped markdown prose, but broader prose/API sync still needs review. +When changing package public behavior, update the relevant README or JSDoc in the same change. `pnpm run doc-sync` catches checked TypeScript snippets, event-taxonomy drift, hard-wrapped markdown prose, and broken relative Markdown links, but broader prose/API sync still needs review. ## Demos diff --git a/eslint.config.mjs b/eslint.config.mjs index a4f48af798..6e73e9418b 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -36,7 +36,7 @@ export default tseslint.config( ], languageOptions: { parserOptions: { - project: ['./tsconfig.typecheck.json'], + project: ['./packages/*/tsconfig.json', './tsconfig.json'], tsconfigRootDir: import.meta.dirname, }, }, @@ -81,13 +81,13 @@ export default tseslint.config( // --- tests: same rules, minus the friction that fights test ergonomics -- { - files: ['packages/*/tests/**/*.ts'], + files: ['packages/*/tests/**/*.ts', 'examples/*/tests/**/*.ts'], extends: [ ...tseslint.configs.strictTypeChecked, ], languageOptions: { parserOptions: { - project: ['./tsconfig.typecheck.json'], + project: ['./tsconfig.json'], tsconfigRootDir: import.meta.dirname, }, }, diff --git a/examples/acp-agent/tests/acp.snapshot.ts b/examples/acp-agent/tests/acp.snapshot.ts index 9f99ce9913..106586d099 100644 --- a/examples/acp-agent/tests/acp.snapshot.ts +++ b/examples/acp-agent/tests/acp.snapshot.ts @@ -3,8 +3,8 @@ import { existsSync } from 'node:fs' import { fileURLToPath } from 'node:url' import { dirname, join } from 'node:path' import { describe, expect, it } from 'vitest' -import { type InputScript, runScenario } from './snapshot-harness.ts' -import { type NormalizeContext, normalizeSessionLog, normalizeStdout } from './snapshot-normalize.ts' +import { type InputScript, runScenario } from './snapshot-harness' +import { type NormalizeContext, normalizeSessionLog, normalizeStdout } from './snapshot-normalize' /** * ACP snapshot tests (REPLAY by default, keyless). Each scenario under diff --git a/examples/acp-agent/tests/snapshot-normalize.spec.ts b/examples/acp-agent/tests/snapshot-normalize.spec.ts index bfdeab5dc8..33c1cabaea 100644 --- a/examples/acp-agent/tests/snapshot-normalize.spec.ts +++ b/examples/acp-agent/tests/snapshot-normalize.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { type NormalizeContext, normalizeSessionLog, normalizeStdout } from '../tests/snapshot-normalize.ts' +import { type NormalizeContext, normalizeSessionLog, normalizeStdout } from '../tests/snapshot-normalize' /** * Unit tests for the pure snapshot normalizers. Live as a *.spec.ts (runs in diff --git a/examples/coding-agent/tests/coding-task.e2e.ts b/examples/coding-agent/tests/coding-task.e2e.ts index 4684301725..e8a34950cb 100644 --- a/examples/coding-agent/tests/coding-task.e2e.ts +++ b/examples/coding-agent/tests/coding-task.e2e.ts @@ -4,7 +4,7 @@ import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, describe, expect, it } from 'vitest' import type { Context } from 'cordis' -import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness.ts' +import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness' /** * The swebench-style smoke test: a real model fixes a real bug in a temp diff --git a/examples/coding-agent/tests/full-loop.e2e.ts b/examples/coding-agent/tests/full-loop.e2e.ts index 93bc0b1fac..e73ae25236 100644 --- a/examples/coding-agent/tests/full-loop.e2e.ts +++ b/examples/coding-agent/tests/full-loop.e2e.ts @@ -1,6 +1,6 @@ import { afterEach, describe, expect, it } from 'vitest' import type { Context } from 'cordis' -import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness.ts' +import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness' /** * The first place a REAL model meets the REAL bash tool: the cheap canary diff --git a/examples/coding-agent/tests/resume.e2e.ts b/examples/coding-agent/tests/resume.e2e.ts index b720efa8c9..b5b7898830 100644 --- a/examples/coding-agent/tests/resume.e2e.ts +++ b/examples/coding-agent/tests/resume.e2e.ts @@ -4,7 +4,7 @@ import { join } from 'node:path' import { afterEach, describe, expect, it } from 'vitest' import type { Context } from 'cordis' import type { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' -import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness.ts' +import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness' /** * Proves durable conversation continuity end-to-end: run 1 tells the REAL model diff --git a/package.json b/package.json index f8f79ee63e..a1394cb9e5 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "scripts": { "build": "tsc -b tsconfig.build.json && tsdown", "clean:build": "rm -rf .typecheck packages/*/lib vendor/*/lib *.tsbuildinfo", - "typecheck": "tsc -b tsconfig.build.json && tsc -p tsconfig.typecheck.json", + "typecheck": "tsc -b tsconfig.json", "lint": "eslint .", "lint:fix": "eslint . --fix", "test": "vitest run", diff --git a/scripts/doc-typecheck.ts b/scripts/doc-typecheck.ts index 10068eb792..da86488e04 100644 --- a/scripts/doc-typecheck.ts +++ b/scripts/doc-typecheck.ts @@ -3,12 +3,12 @@ * Markdown so documentation can't drift from the API it documents. * * Every ```ts block in README.md, docs/** and packages/* /README.md is - * extracted to a temp file and compiled with `tsc --noEmit` against the - * workspace sources (resolved through the same `paths` map vitest uses, so no - * build is required first). A block that is a deliberate sketch rather than - * compilable code opts out with an explicit ` ```ts ignore-check ` info string - * — the opt-out is visible in the source, and this script reports the ratio so - * the escape hatch can't quietly become the norm. + * extracted to a temp typecheck project and compiled against the workspace + * sources through the same project-reference boundaries used by repo + * typecheck. A block that is a deliberate sketch rather than compilable code + * opts out with an explicit ` ```ts ignore-check ` info string — the opt-out + * is visible in the source, and this script reports the ratio so the escape + * hatch can't quietly become the norm. * * Run: `tsx scripts/doc-typecheck.ts`. */ @@ -59,41 +59,27 @@ function extractBlocks(absPath: string): Block[] { return blocks } -/** - * Read the workspace `paths` map from tsconfig.typecheck.json (JSONC). This map - * resolves vendored packages to their BUILT declarations (`lib`) and harness - * packages to source (`src`) — the same resolution `pnpm run lint`/`typecheck` use. - * Resolving vendor to `lib` (not `src`) is essential: otherwise tsc type-checks - * raw vendor source and floods the run with unrelated errors. Requires the - * vendor `lib/` to exist (a fresh clone runs `pnpm run build` first; CI does too). - */ -function workspacePaths(): Record { - const raw = readFileSync(join(root, 'tsconfig.typecheck.json'), 'utf8') - // Strip // line comments and /* */ block comments so JSON.parse accepts it. - const stripped = raw - .replace(/\/\*[\s\S]*?\*\//g, '') - .replace(/(^|[^:])\/\/.*$/gm, '$1') - return (JSON.parse(stripped) as { compilerOptions: { paths: Record } }) - .compilerOptions.paths +/** Reuse the repo typecheck graph references from a temp project one directory below root. */ +function workspaceReferences(): { path: string }[] { + const raw = readFileSync(join(root, 'tsconfig.json'), 'utf8') + const { references } = JSON.parse(raw) as { references: { path: string }[] } + return references.map(({ path }) => { + const relativeToTemp = path.startsWith('./') ? `../${path.slice(2)}` : `../${path}` + return { path: relativeToTemp } + }) } -/** The standalone tsconfig for the temp project (copies base resolution, no - * composite/declaration settings that would fight `--noEmit`). */ +/** The standalone tsconfig for the temp typecheck project. */ function tempTsconfig(): string { return JSON.stringify({ + extends: '../tsconfig.json', compilerOptions: { - target: 'es2024', - module: 'esnext', - moduleResolution: 'bundler', - allowImportingTsExtensions: true, - strict: true, - noEmit: true, - skipLibCheck: true, - types: ['node'], - baseUrl: root, - ignoreDeprecations: '6.0', - paths: workspacePaths(), + noUnusedLocals: false, + noUnusedParameters: false, + tsBuildInfoFile: './tsconfig.tsbuildinfo', }, + include: ['block-*.ts'], + references: workspaceReferences(), }) } @@ -125,11 +111,12 @@ try { }) try { - execFileSync('node_modules/.bin/tsc', ['-p', join(tmp, 'tsconfig.json')], { cwd: root, stdio: 'pipe' }) + execFileSync('node_modules/.bin/tsc', ['-b', join(tmp, 'tsconfig.json')], { cwd: root, stdio: 'pipe' }) } catch (error: unknown) { - const out = (error as { stdout?: Buffer }).stdout?.toString() ?? '' + const failed = error as { stdout?: Buffer; stderr?: Buffer } + const out = `${failed.stdout?.toString() ?? ''}${failed.stderr?.toString() ?? ''}` // Rewrite "block-N.ts(line,col)" to the real "file:fenceLine" for triage. - const remapped = out.replace(/block-(\d+)\.ts\((\d+),(\d+)\)/g, (_m, idx: string, ln: string, col: string) => { + const remapped = out.replace(/(?:[^\s:()]*[/\\])?block-(\d+)\.ts\((\d+),(\d+)\)/g, (_m, idx: string, ln: string, col: string) => { const block = fileForBlock.get(`block-${idx}.ts`) if (!block) return `block-${idx}.ts(${ln},${col})` return `${block.file} (block at line ${block.line}, +${ln}:${col})` diff --git a/tsconfig.json b/tsconfig.json index 725f31659f..61268f8bf9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,4 +1,42 @@ { "extends": "./tsconfig.base.json", - "files": [] + "compilerOptions": { + "noEmit": true + }, + "include": [ + "examples/*/src/**/*.ts", + "examples/*/start.ts", + "examples/*/tests/**/*.ts", + "packages/*/tests/**/*.ts", + "scripts/**/*.ts" + ], + "references": [ + { "path": "./vendor/cosmokit" }, + { "path": "./vendor/schemastery" }, + { "path": "./vendor/cordis" }, + { "path": "./vendor/loader" }, + { "path": "./vendor/include" }, + { "path": "./vendor/group" }, + { "path": "./vendor/timer" }, + { "path": "./vendor/hmr" }, + { "path": "./vendor/logger-console" }, + { "path": "./packages/llm" }, + { "path": "./packages/session" }, + { "path": "./packages/session-persistence" }, + { "path": "./packages/session-persistence-jsonl" }, + { "path": "./packages/session-persistence-sqlite" }, + { "path": "./packages/system-prompt" }, + { "path": "./packages/agent" }, + { "path": "./packages/tools" }, + { "path": "./packages/agent-loop" }, + { "path": "./packages/bash" }, + { "path": "./packages/llm-deepseek" }, + { "path": "./packages/llm-pi-ai" }, + { "path": "./packages/bash-local" }, + { "path": "./packages/tool-bash" }, + { "path": "./packages/invariants" }, + { "path": "./packages/acp" }, + { "path": "./packages/ui-stdio" }, + { "path": "./packages/llm-replay" } + ] } diff --git a/tsconfig.test.json b/tsconfig.test.json deleted file mode 100644 index 5976d5b43c..0000000000 --- a/tsconfig.test.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": true, - "emitDeclarationOnly": false, - "composite": false, - "types": ["node"] - }, - "include": ["vendor/*/src", "packages/*/src", "packages/*/tests", "examples"] -} diff --git a/tsconfig.typecheck.json b/tsconfig.typecheck.json deleted file mode 100644 index 77e2326775..0000000000 --- a/tsconfig.typecheck.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "compilerOptions": { - "noEmit": true, - "emitDeclarationOnly": false, - "composite": false, - "incremental": false, - "types": ["node"], - "paths": { - "cordis": ["./vendor/cordis/lib"], - "cosmokit": ["./vendor/cosmokit/lib"], - "schemastery": ["./vendor/schemastery/lib"], - "@cordisjs/plugin-loader": ["./vendor/loader/lib"], - "@cordisjs/plugin-include": ["./vendor/include/lib"], - "@cordisjs/plugin-group": ["./vendor/group/lib"], - "@cordisjs/plugin-timer": ["./vendor/timer/lib"], - "@cordisjs/plugin-hmr": ["./vendor/hmr/lib"], - "@cordisjs/plugin-logger-console": ["./vendor/logger-console/lib/shared"], - "@deepseek-ai/dsh-llm": ["./packages/llm/src"], - "@deepseek-ai/dsh-session": ["./packages/session/src"], - "@deepseek-ai/dsh-session-persistence": ["./packages/session-persistence/src"], - "@deepseek-ai/dsh-session-persistence-jsonl": ["./packages/session-persistence-jsonl/src"], - "@deepseek-ai/dsh-session-persistence-sqlite": ["./packages/session-persistence-sqlite/src"], - "@deepseek-ai/dsh-system-prompt": ["./packages/system-prompt/src"], - "@deepseek-ai/dsh-tools": ["./packages/tools/src"], - "@deepseek-ai/dsh-agent": ["./packages/agent/src"], - "@deepseek-ai/dsh-agent-loop": ["./packages/agent-loop/src"], - "@deepseek-ai/dsh-bash": ["./packages/bash/src"], - "@deepseek-ai/dsh-llm-deepseek": ["./packages/llm-deepseek/src"], - "@deepseek-ai/dsh-llm-pi-ai": ["./packages/llm-pi-ai/src"], - "@deepseek-ai/dsh-bash-local": ["./packages/bash-local/src"], - "@deepseek-ai/dsh-tool-bash": ["./packages/tool-bash/src"], - "@deepseek-ai/dsh-invariants": ["./packages/invariants/src"], - "@deepseek-ai/dsh-acp": ["./packages/acp/src"], - "@deepseek-ai/dsh-ui-stdio": ["./packages/ui-stdio/src"], - "@deepseek-ai/dsh-llm-replay": ["./packages/llm-replay/src"] - } - }, - "include": ["packages/*/src", "packages/*/tests", "examples", "scripts"] -} diff --git a/vitest.config.ts b/vitest.config.ts index 0878477fb4..6d8608d86e 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -5,9 +5,9 @@ export default defineConfig({ // Vite ≥8 warns that this plugin can be replaced by the native (experimental) // `resolve.tsconfigPaths: true`. It cannot — keep the plugin. Tests run // unbuilt (see AGENTS.md): bare workspace names like `cordis` or - // `@deepseek-ai/dsh-llm` must resolve to src/, and the only place that - // mapping exists is the root tsconfig.json `paths` map inherited by - // tsconfig.test.json. The native option is a bare boolean: for each + // `@deepseek-ai/dsh-llm` must resolve to src/, and that mapping comes from + // the root tsconfig.json paths map. The native option is a bare boolean: + // for each // importing file it discovers the NEAREST tsconfig.json and applies that // file's own `paths`. Every workspace under packages/* and vendor/* has its // own tsconfig.json without `paths`, so native resolution maps nothing, @@ -17,7 +17,7 @@ export default defineConfig({ // 15 workspace tsconfigs — including vendor/* ones, which are pinned // upstream copies (vendor/README.md). The plugin's `projects` option // instead applies the one root map to every importer. - plugins: [tsconfigPaths({ projects: ['./tsconfig.test.json'] })], + plugins: [tsconfigPaths({ projects: ['./tsconfig.json'] })], test: { include: ['packages/*/tests/**/*.spec.ts', 'examples/*/tests/**/*.spec.ts'], coverage: { diff --git a/vitest.e2e.config.ts b/vitest.e2e.config.ts index 9316d660da..903e38cafb 100644 --- a/vitest.e2e.config.ts +++ b/vitest.e2e.config.ts @@ -22,7 +22,7 @@ try { export default defineConfig({ // Same resolution note as vitest.config.ts: bare workspace names resolve // through the root tsconfig paths map; the native option cannot do this. - plugins: [tsconfigPaths({ projects: ['./tsconfig.test.json'] })], + plugins: [tsconfigPaths({ projects: ['./tsconfig.json'] })], test: { include: ['packages/*/tests/**/*.e2e.ts', 'examples/*/tests/**/*.e2e.ts'], // Real model calls: generous timeouts, and retries for transient flakes diff --git a/vitest.snapshot.config.ts b/vitest.snapshot.config.ts index 6dc4144044..ecc8d911aa 100644 --- a/vitest.snapshot.config.ts +++ b/vitest.snapshot.config.ts @@ -24,7 +24,7 @@ if (process.env.DSH_SNAPSHOT === 'record') { export default defineConfig({ // Same resolution note as vitest.config.ts: bare workspace names resolve // through the root tsconfig paths map; the native option cannot do this. - plugins: [tsconfigPaths({ projects: ['./tsconfig.test.json'] })], + plugins: [tsconfigPaths({ projects: ['./tsconfig.json'] })], test: { include: ['examples/*/tests/**/*.snapshot.ts'], // Each test boots a subprocess; give it room, and run files one at a time From c7e55fc0b17bf28572238e73dc0025e966349c59 Mon Sep 17 00:00:00 2001 From: imccyu Date: Wed, 17 Jun 2026 23:42:45 +0800 Subject: [PATCH 10/21] fix: change adr history to current tsconfig behavior --- docs/rfc/implemented/2026-06-11-doc-sync-enforcement.md | 6 ++++-- docs/rfc/implemented/2026-06-11-quality-gates.md | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/rfc/implemented/2026-06-11-doc-sync-enforcement.md b/docs/rfc/implemented/2026-06-11-doc-sync-enforcement.md index 68e6f0a03d..51aff694b8 100644 --- a/docs/rfc/implemented/2026-06-11-doc-sync-enforcement.md +++ b/docs/rfc/implemented/2026-06-11-doc-sync-enforcement.md @@ -12,13 +12,15 @@ AGENTS.md promises that docs and code stay strictly in sync, but the promise was Two gates, mirroring the existing `scripts/` style (tsx ESM, one job each): -1. **`doc-typecheck`** extracts every fenced ` ```ts ` block from `README.md`, `docs/**`, and `packages/*/README.md`, writes them to a temp project, and compiles with `tsc --noEmit`. The temp tsconfig copies only resolution-relevant options and the workspace `paths` map from `tsconfig.typecheck.json` (vendor → built `lib`, harness → `src`) — resolving vendor to `lib` is essential, or tsc type-checks raw vendor source and floods the run. A block that is a deliberate sketch opts out with an explicit ` ```ts ignore-check ` info string; the script reports the opt-out ratio and fails if it exceeds half, so the escape hatch can't quietly become the norm. +1. **`doc-typecheck`** extracts every fenced ` ```ts ` block from `README.md`, `docs/**`, and `packages/*/README.md`, writes them to a temp project extending the root `tsconfig.json`, and compiles it with `tsc -b`. The temp project reuses the source `paths` map and the root project references, so documentation examples see source while vendored code remains checked under its own tsconfig settings. A block that is a deliberate sketch opts out with an explicit ` ```ts ignore-check ` info string; the script reports the opt-out ratio and fails if it exceeds half, so the escape hatch can't quietly become the norm. 2. **`verify-event-taxonomy`** extracts the event names from the `interface Events` blocks across `packages/*/src` and from the taxonomy table in `docs/architecture.md`, and asserts the two sets match exactly. Verify, don't generate: the table keeps its hand-written Mode/Purpose columns; only the set of names is checked. (Landing this surfaced three events the table had been missing — `tools/change`, `llm/adapter-change`, `system-prompt/change`.) -Both run via a shared `doc-sync` package.json script that the lefthook pre-push hook and CI both invoke ([mechanical quality gates](2026-06-11-quality-gates.md): hooks and CI call the same scripts, so the gate fires locally before a push — not only after it). They run after `pnpm run typecheck` (which emits the vendor `lib/` that doc-typecheck resolves against). API-extractor golden reports ([the deferred API-extractor-reports proposal](../proposed/2026-06-11-api-extractor-reports.md)) were deliberately **deferred** — low value for an internal monorepo where reviewers already see the source diff, and a heavy, finicky dependency. +Both run via a shared `doc-sync` package.json script that the lefthook pre-push hook and CI both invoke ([mechanical quality gates](2026-06-11-quality-gates.md): hooks and CI call the same scripts, so the gate fires locally before a push — not only after it). They run after `pnpm run typecheck`, which validates the package/vendor build graph that doc-typecheck references. API-extractor golden reports ([the deferred API-extractor-reports proposal](../proposed/2026-06-11-api-extractor-reports.md)) were deliberately **deferred** — low value for an internal monorepo where reviewers already see the source diff, and a heavy, finicky dependency. **Amendment (2026-06-17):** a third gate, **`verify-md-wrap`**, was later folded into `doc-sync`. It parses each in-scope Markdown file (`README.md`, `docs/**`, `packages/*/README.md`, plus `AGENTS.md` / `packages/AGENTS.md`) with `mdast-util-from-markdown` + GFM and fails on any `paragraph` node spanning more than one source line, enforcing the AGENTS.md "Markdown is not hard-wrapped" convention. Same verify-don't-generate principle: it reports hard-wraps and never rewrites, so it adds no formatting churn. `doc-sync` is now three gates. +**Amendment (2026-06-18):** a fourth gate, **`verify-md-links`**, was later folded into `doc-sync` by the [Markdown cross-link validity linting RFC](2026-06-18-markdown-cross-link-lint.md). It checks that every relative Markdown link in the checked docs resolves to an existing file, so the RFC tree can use date-based filenames and relative links instead of stale numeric prose references. `doc-sync` is now four gates. + ## Consequences - Doc drift in the checkable classes now fails the pre-push hook and CI instead of waiting for a reviewer to notice. This is an instance of the "mechanical gates over prose" principle. diff --git a/docs/rfc/implemented/2026-06-11-quality-gates.md b/docs/rfc/implemented/2026-06-11-quality-gates.md index 1f3dd3c520..70ec37bdf8 100644 --- a/docs/rfc/implemented/2026-06-11-quality-gates.md +++ b/docs/rfc/implemented/2026-06-11-quality-gates.md @@ -12,7 +12,7 @@ This codebase is developed primarily by coding agents. Agents follow enforced ga Every AGENTS.md promise gets a command that exits non-zero, wired into git hooks and CI both calling the same package.json scripts: -- Max-strict TypeScript (`noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`, …); tests and examples typecheck in CI via `tsconfig.typecheck.json` (vendored packages resolve as built declarations). +- Max-strict TypeScript (`noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`, …); examples, tests, and scripts typecheck in CI via the root no-emit `tsconfig.json` while package/vendor code stays behind its own project-reference boundary. - ESLint strict-type-checked + @stylistic (the house style, enforced); vendored code excluded. - Per-file 100% coverage on `packages/*/src` (v8); unreachable defensive guards carry `/* v8 ignore */ ` with stated reasons instead of deletion. - knip (dead code/deps), publint (package correctness), workspace constraints (workspace rules: private, cordis peer+dev, uniform version, ESM). From ed94daed9ecc379631eb40ba1ef42295544a3460 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Sat, 20 Jun 2026 00:21:57 +0800 Subject: [PATCH 11/21] fix: address build config review findings --- .github/workflows/ci.yml | 16 ++++----- docs/cookbook/adding-a-package.md | 2 +- docs/cookbook/adding-a-vendored-package.md | 2 +- docs/rfc/README.md | 2 +- .../2026-06-11-tsdown-over-dumble.md | 6 ++-- ...onfig.md => 2026-06-17-ts-build-config.md} | 6 ++-- packages/acp/package.json | 1 + packages/agent-loop/package.json | 1 + packages/agent/package.json | 1 + packages/bash-local/package.json | 1 + packages/bash/package.json | 1 + packages/invariants/package.json | 1 + packages/llm-deepseek/package.json | 1 + packages/llm-pi-ai/package.json | 1 + packages/llm-replay/package.json | 1 + packages/llm/package.json | 1 + .../session-persistence-jsonl/package.json | 1 + .../session-persistence-sqlite/package.json | 1 + packages/session-persistence/package.json | 1 + packages/session/package.json | 1 + packages/system-prompt/package.json | 1 + packages/tool-bash/package.json | 1 + packages/tools/package.json | 1 + packages/ui-stdio/package.json | 1 + scripts/check-workspace-constraints.ts | 35 +++++++++++++++++++ scripts/doc-typecheck.ts | 9 ++++- vendor/README.md | 4 +-- vendor/cordis/package.json | 1 + vendor/cosmokit/package.json | 1 + vendor/group/package.json | 1 + vendor/hmr/package.json | 1 + vendor/include/package.json | 1 + vendor/loader/package.json | 1 + vendor/logger-console/package.json | 1 + vendor/schemastery/package.json | 1 + vendor/timer/package.json | 1 + 36 files changed, 88 insertions(+), 21 deletions(-) rename docs/rfc/implemented/{2026-06-20-ts-build-config.md => 2026-06-17-ts-build-config.md} (89%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b9a9fca4f..e35f69513a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,22 +33,20 @@ jobs: - name: Constraints run: pnpm run constraints - # Before lint: the type-aware ESLint config resolves vendor packages via - # their built declarations (tsconfig.typecheck.json -> vendor/*/lib), - # which `pnpm run typecheck` emits. Lint on a fresh checkout would otherwise - # see unresolved types and erupt with no-unsafe-* errors. + # Before lint: root typecheck validates the package/vendor reference graph + # and refreshes TSC intermediates so type-aware ESLint sees the same project + # boundaries as the build. - name: Typecheck (src + tests + examples) run: pnpm run typecheck - name: Lint run: pnpm run lint - # Doc-sync gates (doc-sync-enforcement RFC). doc-typecheck compiles the fenced ts blocks in - # the docs and resolves vendor packages via their built declarations, which - # the typecheck step above emits — so it runs after typecheck. The event - # taxonomy check and the markdown wrap check only read source. Same + # Doc-sync gates (doc-sync-enforcement RFC). doc-typecheck compiles the + # fenced ts blocks against the root project-reference graph. The event + # taxonomy, markdown wrap, and markdown link checks only read source. Same # `doc-sync` script the pre-push hook runs (quality-gates RFC: one source of truth). - - name: Doc-sync gates (doc code blocks + event taxonomy + markdown wrap) + - name: Doc-sync gates (doc code blocks + event taxonomy + markdown) run: pnpm run doc-sync # Module-graph freshness: regenerate docs/module-graph.md from the diff --git a/docs/cookbook/adding-a-package.md b/docs/cookbook/adding-a-package.md index 9ae8033fe3..c9962f27a1 100644 --- a/docs/cookbook/adding-a-package.md +++ b/docs/cookbook/adding-a-package.md @@ -15,7 +15,7 @@ packages// README.md # service API, events, extension points, design notes ``` -package.json invariants (enforced by `pnpm run constraints` / `scripts/check-workspace-constraints.ts`): `private: true`, `version: 0.0.1`, `type: module`, `main: "lib/index.js"`, `types: "lib/typings/index.d.ts"`, `exports["."].types: "./lib/typings/index.d.ts"`, `cordis` in BOTH peerDependencies and devDependencies (same range). Mirror every dsh peer dependency in devDependencies. `schemastery` goes in `dependencies` (it is a runtime validator), matching agent-loop. The `files` list is precise: `lib/index.js`, `lib/typings/**/*.d.ts`, and `src`; do not publish `lib/typings` JS/map intermediates or stale root declaration files. +package.json invariants (enforced by `pnpm run constraints` / `scripts/check-workspace-constraints.ts`): `private: true`, `version: 0.0.1`, `type: module`, `main: "lib/index.js"`, `types: "lib/typings/index.d.ts"`, `exports["."].types: "./lib/typings/index.d.ts"`, `exports["."].default: "./lib/index.js"`, `cordis` in BOTH peerDependencies and devDependencies (same range). Mirror every dsh peer dependency in devDependencies. `schemastery` goes in `dependencies` (it is a runtime validator), matching agent-loop. The `files` list is precise: `lib/index.js`, `lib/typings/**/*.d.ts`, `lib/typings/**/*.d.ts.map`, and `src`; do not publish `lib/typings` JS/map intermediates or stale root declaration files. ## 2. Register it in the root configs diff --git a/docs/cookbook/adding-a-vendored-package.md b/docs/cookbook/adding-a-vendored-package.md index fb32d60d06..ed54a0a578 100644 --- a/docs/cookbook/adding-a-vendored-package.md +++ b/docs/cookbook/adding-a-vendored-package.md @@ -27,7 +27,7 @@ vendor// } ``` -`package.json` invariants: `"private": true` (vendored packages are never published), keep upstream's `name`/`version`/`exports`/`type`, point declaration metadata at `lib/typings`, and list its cordis deps in `peerDependencies` (matching the upstream manifest). Transitive upstream deps must themselves be vendored or already present — vendoring one package often means vendoring its dependency tree (e.g. `@cordisjs/plugin-http` pulls `@cordisjs/fetch-file`). +`package.json` invariants: `"private": true` (vendored packages are never published), keep upstream's `name`/`version`/`exports`/`type`, point declaration metadata at `lib/typings`, publish `.d.ts` and `.d.ts.map` declaration outputs, and list its cordis deps in `peerDependencies` (matching the upstream manifest). Transitive upstream deps must themselves be vendored or already present — vendoring one package often means vendoring its dependency tree (e.g. `@cordisjs/plugin-http` pulls `@cordisjs/fetch-file`). ## 2. Register it in the root configs diff --git a/docs/rfc/README.md b/docs/rfc/README.md index 88406034d5..dcb9dab289 100644 --- a/docs/rfc/README.md +++ b/docs/rfc/README.md @@ -60,7 +60,7 @@ Do NOT write one for a mechanical or local choice (a variable name, a one-file r | [Rich ACP bash rendering — the terminal card (`_meta`) and command classification](implemented/2026-06-18-acp-terminal-and-tool-rendering.md) | 2026-06-18 | | [ACP snapshot tests — record-once / replay-deterministic](implemented/2026-06-19-acp-snapshot-tests.md) | 2026-06-19 | | [Real-API e2e in CI against the external DeepSeek API](implemented/2026-06-19-real-api-e2e-ci.md) | 2026-06-19 | -| [TSC-first build and one tsconfig](implemented/2026-06-20-ts-build-config.md) | 2026-06-20 | +| [TSC-first build and one tsconfig](implemented/2026-06-17-ts-build-config.md) | 2026-06-17 | ## Rejected diff --git a/docs/rfc/implemented/2026-06-11-tsdown-over-dumble.md b/docs/rfc/implemented/2026-06-11-tsdown-over-dumble.md index 283b236397..bd69ebbf31 100644 --- a/docs/rfc/implemented/2026-06-11-tsdown-over-dumble.md +++ b/docs/rfc/implemented/2026-06-11-tsdown-over-dumble.md @@ -15,12 +15,12 @@ Build output currently matters only for `pnpm run build` + publint (nothing publ Replace dumble with **tsdown** (rolldown-based, ~2.5M downloads/week, VoidZero-backed, actively released): - Root `tsdown.config.ts` with `workspace: ['vendor/*', 'packages/*']` (explicit globs, not `workspace: true`, which would also pick up `examples/*` — they have package.json files but are not pnpm workspaces). -- Shared shape: entry `src/index.ts`, `outDir: 'lib'`, ESM, `platform: node`, `target: es2024`, `fixedExtension: false` (keeps `.js` for `"type": "module"` packages), `dts: false` (tsc -b owns declarations), `clean: false` (lib/ holds tsc's .d.ts output). +- Shared shape: entry `lib/typings/index.js`, `outDir: 'lib'`, ESM, `platform: node`, `target: es2024`, `fixedExtension: false` (keeps `.js` for `"type": "module"` packages), `dts: false` (tsc -b owns declarations), `clean: false` (lib/ also holds TSC's `lib/typings` intermediate tree). The entry was originally `src/index.ts`; the [TSC-first build RFC](2026-06-17-ts-build-config.md) later moved tsdown to bundling TSC-emitted JS so TypeScript transform behavior comes from one compiler. - Two per-package overrides in vendor/ (ours, like the regenerated tsconfigs; logged in vendor/README.md): schemastery (dual `.mjs`/`.cjs` via `outExtensions`), logger-console (two single-entry passes so the shared base class is inlined into each entry instead of a hash-named chunk, matching upstream's published shape). -- `scripts/build.ts` deleted; `pnpm run build` = `tsc -b && tsdown`. +- `scripts/build.ts` deleted; `pnpm run build` = `tsc -b tsconfig.build.json && tsdown`. Alternatives considered: **direct esbuild script** (most established engine, zero wrapper risk, but hand-maintains the per-package spec table tsdown's workspace mode gives us); **pkgroll** (closest drop-in philosophically, but 78k dl/wk and Rollup-based — strictly weaker maintenance story than tsdown); **keep dumble** (perfect upstream alignment, unacceptable bus factor). ## Consequences -Output file lists are byte-for-byte-list identical to dumble's (verified by snapshot diff at migration time); externals still come from each package's dependencies/peerDependencies. We give up dumble's exports-field inference — new packages with non-default shapes need a per-package `tsdown.config.ts` instead of just package.json fields. Future option: tsdown could also absorb declaration bundling (isolatedDeclarations) if `tsc -b` ever becomes the bottleneck; that would be a new RFC. +Runtime bundle outputs still follow the dumble-era public entry shape (`lib/index.js`, plus package-specific variants such as `schemastery`'s `lib/index.mjs`/`lib/index.cjs` and `logger-console`'s `lib/browser.js`); declarations now live under `lib/typings` per the [TSC-first build RFC](2026-06-17-ts-build-config.md). Externals still come from each package's dependencies/peerDependencies. We give up dumble's exports-field inference — new packages with non-default shapes need a per-package `tsdown.config.ts` instead of just package.json fields. Future option: tsdown could also absorb declaration bundling (isolatedDeclarations) if `tsc -b` ever becomes the bottleneck; that would be a new RFC. diff --git a/docs/rfc/implemented/2026-06-20-ts-build-config.md b/docs/rfc/implemented/2026-06-17-ts-build-config.md similarity index 89% rename from docs/rfc/implemented/2026-06-20-ts-build-config.md rename to docs/rfc/implemented/2026-06-17-ts-build-config.md index ab56b07e83..9c64de454f 100644 --- a/docs/rfc/implemented/2026-06-20-ts-build-config.md +++ b/docs/rfc/implemented/2026-06-17-ts-build-config.md @@ -30,14 +30,14 @@ In-package relative imports are extensionless. `pnpm run build` is a two-stage build: -- Stage 1: `tsc -b tsconfig.build.json` emits publishable per-module `.js`, declarations `.d.ts`, JS sourcemaps `.js.map`, and declaration sourcemaps `.d.ts.map` into each package's `lib/typings`. This is the authoritative TypeScript compilation result. For publish we should keep `.d.ts` and ignore `.js` / `.js.map` / `.d.ts.map` +- Stage 1: `tsc -b tsconfig.build.json` emits per-module `.js`, declarations `.d.ts`, JS sourcemaps `.js.map`, and declaration sourcemaps `.d.ts.map` into each package's `lib/typings`. This is the authoritative TypeScript compilation result. For publish we keep `.d.ts` / `.d.ts.map` and ignore `.js` / `.js.map`. - The build project uses the project-reference graph that `tsc -b` compiles. For example, root `tsconfig.build.json` references package and vendor tsconfigs. It validates and emits package/vendor build results. - Stage 2: a bundler reads the emitted JS under `lib/typings` and writes the bundled runtime entry as `lib/index.js` or `lib/index.mjs` (follow current behavior). This stage is bundling only. It must not read TypeScript source or emit declarations. `tsdown` is no longer the owner of TypeScript compilation or declaration output. `pnpm run typecheck` runs build mode over the root `tsconfig.json`. -- The root `tsconfig.json` is the single development/typecheck project. It has `noEmit` for demos, examples, tests, and scripts, and validates package/vendor source through references. +- The root `tsconfig.json` is the single development/typecheck project. It typechecks examples, tests, and scripts with `noEmit`, and validates package/vendor source through references. - Referenced package/vendor projects keep the same emit behavior as build, so typecheck can refresh their `lib/typings` outputs instead of using a separate no-emit graph. Project-specific strictness changes live in the owning `packages/*/tsconfig.json` or `vendor/*/tsconfig.json`. The command orchestration shape is: @@ -59,7 +59,7 @@ Build responsibilities are clearer: - Each module under `packages/*` and `vendor/*` has one local tsconfig for build, typecheck, and tools that run source directly, such as `tsx` and `vitest`. - The `build` command uses `tsconfig.build.json`. `tsc -b` owns the publishable per-module `.js` and `.d.ts` output, and the bundler owns only `lib/index.*`. - - `lib/typings/*.d.ts` is the publish declaration output. + - `lib/typings/*.d.ts` and `.d.ts.map` are the publish declaration output. - `lib/typings/*.js` is only a bundler input and must not be used as a runtime entry or public import target. - `lib/index.*` is the publish runtime output and is generated by the bundler, currently `tsdown`. - The `typecheck` command uses `tsconfig.json`. Examples, tests, and scripts are checked by the root no-emit project, while packages and vendor modules keep the same emit behavior as `build`. Package and vendor source stays behind project-reference boundaries. diff --git a/packages/acp/package.json b/packages/acp/package.json index ac23174ade..9f052e5753 100644 --- a/packages/acp/package.json +++ b/packages/acp/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/agent-loop/package.json b/packages/agent-loop/package.json index 9e54e4de4b..ae7296d4df 100644 --- a/packages/agent-loop/package.json +++ b/packages/agent-loop/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/agent/package.json b/packages/agent/package.json index bca0ff7840..eb3a967338 100644 --- a/packages/agent/package.json +++ b/packages/agent/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/bash-local/package.json b/packages/bash-local/package.json index de2f2d6c1a..7a8f6fb2a4 100644 --- a/packages/bash-local/package.json +++ b/packages/bash-local/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/bash/package.json b/packages/bash/package.json index f65f5a6a7f..8f33a4ccff 100644 --- a/packages/bash/package.json +++ b/packages/bash/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/invariants/package.json b/packages/invariants/package.json index 409596871b..20ffc74bbf 100644 --- a/packages/invariants/package.json +++ b/packages/invariants/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/llm-deepseek/package.json b/packages/llm-deepseek/package.json index 0517a0c5a9..0da7a35b5e 100644 --- a/packages/llm-deepseek/package.json +++ b/packages/llm-deepseek/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/llm-pi-ai/package.json b/packages/llm-pi-ai/package.json index f2e9a34322..d212037a95 100644 --- a/packages/llm-pi-ai/package.json +++ b/packages/llm-pi-ai/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/llm-replay/package.json b/packages/llm-replay/package.json index b25fa04f03..d9569c2d02 100644 --- a/packages/llm-replay/package.json +++ b/packages/llm-replay/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/llm/package.json b/packages/llm/package.json index 835e89af7f..6a01d52c6c 100644 --- a/packages/llm/package.json +++ b/packages/llm/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/session-persistence-jsonl/package.json b/packages/session-persistence-jsonl/package.json index 6a1e61c361..8620858548 100644 --- a/packages/session-persistence-jsonl/package.json +++ b/packages/session-persistence-jsonl/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/session-persistence-sqlite/package.json b/packages/session-persistence-sqlite/package.json index 4d6951ebbd..ad5cec37d6 100644 --- a/packages/session-persistence-sqlite/package.json +++ b/packages/session-persistence-sqlite/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/session-persistence/package.json b/packages/session-persistence/package.json index 901381cffc..17b3c7a796 100644 --- a/packages/session-persistence/package.json +++ b/packages/session-persistence/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/session/package.json b/packages/session/package.json index d660624853..42ef62567e 100644 --- a/packages/session/package.json +++ b/packages/session/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/system-prompt/package.json b/packages/system-prompt/package.json index b5782f2c38..7e419ed29a 100644 --- a/packages/system-prompt/package.json +++ b/packages/system-prompt/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/tool-bash/package.json b/packages/tool-bash/package.json index e433fad938..23baf69058 100644 --- a/packages/tool-bash/package.json +++ b/packages/tool-bash/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/tools/package.json b/packages/tools/package.json index 0a578547f2..c78caf0f51 100644 --- a/packages/tools/package.json +++ b/packages/tools/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/ui-stdio/package.json b/packages/ui-stdio/package.json index 34216be977..8e7c54454f 100644 --- a/packages/ui-stdio/package.json +++ b/packages/ui-stdio/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/scripts/check-workspace-constraints.ts b/scripts/check-workspace-constraints.ts index 50b1a80078..263be4af5a 100644 --- a/scripts/check-workspace-constraints.ts +++ b/scripts/check-workspace-constraints.ts @@ -28,6 +28,15 @@ interface PackageManifest { version?: string private?: boolean type?: string + main?: string + types?: string + exports?: { + '.'?: { + types?: string + default?: string + } + } + files?: string[] peerDependencies?: Record devDependencies?: Record } @@ -58,6 +67,17 @@ function workspaceManifests(): WorkspaceManifest[] { return manifests } +const dshPackageFiles = [ + 'lib/index.js', + 'lib/typings/**/*.d.ts', + 'lib/typings/**/*.d.ts.map', + 'src', +] as const + +function sameStringList(actual: readonly string[] | undefined, expected: readonly string[]): boolean { + return !!actual && actual.length === expected.length && actual.every((value, index) => value === expected[index]) +} + function checkWorkspace({ dir, manifest }: WorkspaceManifest): string[] { const errors: string[] = [] const label = manifest.name ?? dir @@ -85,6 +105,21 @@ function checkWorkspace({ dir, manifest }: WorkspaceManifest): string[] { if (manifest.type !== 'module') { errors.push(`${label}: package.json must set "type": "module"`) } + if (manifest.main !== 'lib/index.js') { + errors.push(`${label}: package.json must set "main": "lib/index.js"`) + } + if (manifest.types !== 'lib/typings/index.d.ts') { + errors.push(`${label}: package.json must set "types": "lib/typings/index.d.ts"`) + } + if (manifest.exports?.['.']?.types !== './lib/typings/index.d.ts') { + errors.push(`${label}: package.json exports["."].types must be "./lib/typings/index.d.ts"`) + } + if (manifest.exports?.['.']?.default !== './lib/index.js') { + errors.push(`${label}: package.json exports["."].default must be "./lib/index.js"`) + } + if (!sameStringList(manifest.files, dshPackageFiles)) { + errors.push(`${label}: package.json files must be ${JSON.stringify(dshPackageFiles)}`) + } } return errors.map(error => `${relative(root, join(root, dir, 'package.json'))}: ${error}`) diff --git a/scripts/doc-typecheck.ts b/scripts/doc-typecheck.ts index da86488e04..fde2e5d60a 100644 --- a/scripts/doc-typecheck.ts +++ b/scripts/doc-typecheck.ts @@ -30,6 +30,13 @@ interface Block { code: string } +/** Strip JSONC comments from checked-in tsconfig files before JSON.parse. */ +function stripJsonComments(raw: string): string { + return raw + .replace(/\/\*[\s\S]*?\*\//g, '') + .replace(/(^|[^:])\/\/.*$/gm, '$1') +} + /** Extract every ```ts / ```ts ignore-check block from one Markdown file. */ function extractBlocks(absPath: string): Block[] { const text = readFileSync(absPath, 'utf8') @@ -62,7 +69,7 @@ function extractBlocks(absPath: string): Block[] { /** Reuse the repo typecheck graph references from a temp project one directory below root. */ function workspaceReferences(): { path: string }[] { const raw = readFileSync(join(root, 'tsconfig.json'), 'utf8') - const { references } = JSON.parse(raw) as { references: { path: string }[] } + const { references } = JSON.parse(stripJsonComments(raw)) as { references: { path: string }[] } return references.map(({ path }) => { const relativeToTemp = path.startsWith('./') ? `../${path.slice(2)}` : `../${path}` return { path: relativeToTemp } diff --git a/vendor/README.md b/vendor/README.md index 87fbc46fb1..43c53cfb53 100644 --- a/vendor/README.md +++ b/vendor/README.md @@ -31,9 +31,9 @@ Intentionally **not** vendored (verified unused by this set): `reggol`, `@cordis Keep this log exhaustive — every divergence from upstream must be listed. 1. **`hmr/src/index.ts`**: removed the `./locales/en-US.yml` / `./locales/zh-CN.yml` imports, the `.i18n({...})` call on the `Config` schema, and the `src/locales/` directory. Rationale: those imports require a runtime YAML loader hook (`@cordisjs/unyaml`) that we do not vendor; the i18n texts only localize config descriptions. -2. **All `package.json` files**: regenerated — added `private: true`, added precise `files` entries for bundled runtime files and `lib/typings/**/*.d.ts`, preserved `src` in `files` only for packages whose previous file list already shipped it, added a `./src/*` export where missing, pointed declaration metadata at `lib/typings`, and removed upstream `devDependencies`/`scripts`/`repository` fields. Dependency and peer-dependency ranges preserved, except `hmr` declares `esbuild` as a direct dev dependency because its source imports the `BuildFailure` type and pnpm's strict workspace resolution requires the owner package to name that dependency. +2. **All `package.json` files**: regenerated — added `private: true`, added precise `files` entries for bundled runtime files and `lib/typings/**/*.d.ts` / `.d.ts.map`, preserved `src` in `files` only for packages whose previous file list already shipped it, added a `./src/*` export where missing, pointed declaration metadata at `lib/typings`, and removed upstream `devDependencies`/`scripts`/`repository` fields. Dependency and peer-dependency ranges preserved, except `hmr` declares `esbuild` as a direct dev dependency because its source imports the `BuildFailure` type and pnpm's strict workspace resolution requires the owner package to name that dependency. 3. **All `tsconfig.json` files**: regenerated to extend the repo-root `tsconfig.base.json`, emit TypeScript intermediates to `lib/typings`, and declare project references. -4. **`loader/src/config/isolate.ts`**: changed the internal declaration merge specifier from `declare module './entry.ts'` to `declare module './entry'` so generated declarations are extensionless and no declaration postprocess is needed. +4. **Vendored TypeScript source internal specifiers**: changed local relative imports/exports from explicit `.ts` / `.js` specifiers to extensionless specifiers so generated `.js` and `.d.ts` intermediates are extensionless and no declaration postprocess is needed. This includes `loader/src/config/isolate.ts` changing `declare module './entry.ts'` to `declare module './entry'`. 5. **`schemastery/tsdown.config.ts` and `logger-console/tsdown.config.ts`**: ours, not upstream files — per-package build-shape overrides (dual ESM+CJS output; separate node/browser entries) for the repo-root tsdown build. They read the JS emitted under `lib/typings` and then write the publish runtime entries under `lib/`. Like the regenerated tsconfigs, they are not part of the upstream sync surface. ## Sync procedure diff --git a/vendor/cordis/package.json b/vendor/cordis/package.json index 33bd881dc2..59c3f69649 100644 --- a/vendor/cordis/package.json +++ b/vendor/cordis/package.json @@ -19,6 +19,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "bin.js" ], "author": "Shigma ", diff --git a/vendor/cosmokit/package.json b/vendor/cosmokit/package.json index ccb8f620fd..d313ce5477 100644 --- a/vendor/cosmokit/package.json +++ b/vendor/cosmokit/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "author": "Shigma ", diff --git a/vendor/group/package.json b/vendor/group/package.json index cd638f59a7..d8d56c7675 100644 --- a/vendor/group/package.json +++ b/vendor/group/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "author": "Shigma ", diff --git a/vendor/hmr/package.json b/vendor/hmr/package.json index 1c3c088dd0..7bab5dd3d8 100644 --- a/vendor/hmr/package.json +++ b/vendor/hmr/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "author": "Shigma ", diff --git a/vendor/include/package.json b/vendor/include/package.json index 2b15cb4b90..0c91733947 100644 --- a/vendor/include/package.json +++ b/vendor/include/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "author": "Shigma ", diff --git a/vendor/loader/package.json b/vendor/loader/package.json index 8d43331708..75b45a89a3 100644 --- a/vendor/loader/package.json +++ b/vendor/loader/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "author": "Shigma ", diff --git a/vendor/logger-console/package.json b/vendor/logger-console/package.json index f96f94b23d..33ec1d566a 100644 --- a/vendor/logger-console/package.json +++ b/vendor/logger-console/package.json @@ -19,6 +19,7 @@ "lib/index.js", "lib/browser.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "author": "Shigma ", diff --git a/vendor/schemastery/package.json b/vendor/schemastery/package.json index 42aab72f69..8ce5cc5aff 100644 --- a/vendor/schemastery/package.json +++ b/vendor/schemastery/package.json @@ -10,6 +10,7 @@ "lib/index.mjs", "lib/index.cjs", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "author": "Shigma ", diff --git a/vendor/timer/package.json b/vendor/timer/package.json index 8c7afeafc4..ff68a84aa0 100644 --- a/vendor/timer/package.json +++ b/vendor/timer/package.json @@ -17,6 +17,7 @@ "files": [ "lib/index.js", "lib/typings/**/*.d.ts", + "lib/typings/**/*.d.ts.map", "src" ], "author": "Shigma ", From 7f131dd4d8947185d87e575e26e568909b5bd3eb Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Sat, 20 Jun 2026 00:26:02 +0800 Subject: [PATCH 12/21] refactor: rename build typings dir to types --- AGENTS.md | 4 ++-- docs/cookbook/adding-a-package.md | 4 ++-- docs/cookbook/adding-a-vendored-package.md | 8 ++++---- docs/development.md | 2 +- .../rfc/implemented/2026-06-11-tsdown-over-dumble.md | 4 ++-- docs/rfc/implemented/2026-06-17-ts-build-config.md | 10 +++++----- packages/acp/package.json | 8 ++++---- packages/acp/tsconfig.json | 2 +- packages/agent-loop/package.json | 8 ++++---- packages/agent-loop/tsconfig.json | 2 +- packages/agent/package.json | 8 ++++---- packages/agent/tsconfig.json | 2 +- packages/bash-local/package.json | 8 ++++---- packages/bash-local/tsconfig.json | 2 +- packages/bash/package.json | 8 ++++---- packages/bash/tsconfig.json | 2 +- packages/invariants/package.json | 8 ++++---- packages/invariants/tsconfig.json | 2 +- packages/llm-deepseek/package.json | 8 ++++---- packages/llm-deepseek/tsconfig.json | 2 +- packages/llm-pi-ai/package.json | 8 ++++---- packages/llm-pi-ai/tsconfig.json | 2 +- packages/llm-replay/package.json | 8 ++++---- packages/llm-replay/tsconfig.json | 2 +- packages/llm/package.json | 8 ++++---- packages/llm/tsconfig.json | 2 +- packages/session-persistence-jsonl/package.json | 8 ++++---- packages/session-persistence-jsonl/tsconfig.json | 2 +- packages/session-persistence-sqlite/package.json | 8 ++++---- packages/session-persistence-sqlite/tsconfig.json | 2 +- packages/session-persistence/package.json | 8 ++++---- packages/session-persistence/tsconfig.json | 2 +- packages/session/package.json | 8 ++++---- packages/session/tsconfig.json | 2 +- packages/system-prompt/package.json | 8 ++++---- packages/system-prompt/tsconfig.json | 2 +- packages/tool-bash/package.json | 8 ++++---- packages/tool-bash/tsconfig.json | 2 +- packages/tools/package.json | 8 ++++---- packages/tools/tsconfig.json | 2 +- packages/ui-stdio/package.json | 8 ++++---- packages/ui-stdio/tsconfig.json | 2 +- scripts/check-workspace-constraints.ts | 12 ++++++------ tsdown.config.ts | 4 ++-- vendor/README.md | 6 +++--- vendor/cordis/package.json | 8 ++++---- vendor/cordis/tsconfig.json | 2 +- vendor/cosmokit/package.json | 8 ++++---- vendor/cosmokit/tsconfig.json | 2 +- vendor/group/package.json | 8 ++++---- vendor/group/tsconfig.json | 2 +- vendor/hmr/package.json | 8 ++++---- vendor/hmr/tsconfig.json | 2 +- vendor/include/package.json | 8 ++++---- vendor/include/tsconfig.json | 2 +- vendor/loader/package.json | 8 ++++---- vendor/loader/tsconfig.json | 2 +- vendor/logger-console/package.json | 8 ++++---- vendor/logger-console/tsconfig.json | 2 +- vendor/logger-console/tsdown.config.ts | 6 +++--- vendor/schemastery/package.json | 6 +++--- vendor/schemastery/tsconfig.json | 2 +- vendor/schemastery/tsdown.config.ts | 4 ++-- vendor/timer/package.json | 8 ++++---- vendor/timer/tsconfig.json | 2 +- 65 files changed, 166 insertions(+), 166 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 4bb814cab7..f9631fed4d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -87,7 +87,7 @@ pnpm run test:snapshot:record # re-record fixtures + goldens against the real pnpm run typecheck # tsc -b tsconfig.json pnpm run lint # eslint . pnpm run lint:fix # eslint . --fix -pnpm run build # tsc emits lib/typings, then tsdown bundles runtime lib/index.* +pnpm run build # tsc emits lib/types, then tsdown bundles runtime lib/index.* pnpm run knip # dead-code / unused-dependency check pnpm run publint # package.json publish-correctness check (publishable packages/*) pnpm run hygiene # knip + publint + workspace constraints @@ -126,7 +126,7 @@ Dev/test/demo run **unbuilt** via tsx + the source `paths` map in the root `tsco ## Conventions - **Package naming**: every npm package in this repo is `@deepseek-ai/dsh-` (vendored packages keep their upstream names and are `private: true`). -- **ESM everywhere** (`"type": "module"`); imports between workspace packages use package names, never relative paths across package boundaries. In-package relative imports are extensionless so generated `.d.ts` files stay extensionless; `lib/typings/**/*.js` is a bundler-only intermediate, not a Node ESM entrypoint. +- **ESM everywhere** (`"type": "module"`); imports between workspace packages use package names, never relative paths across package boundaries. In-package relative imports are extensionless so generated `.d.ts` files stay extensionless; `lib/types/**/*.js` is a bundler-only intermediate, not a Node ESM entrypoint. - **`cordis` is a peerDependency** (+ devDependency) of every harness package, mirroring upstream convention. - **Registrations are effects**: anything a plugin contributes (adapter, tool, section, agent, event listener) goes through `ctx.effect()` / `ctx.on()` so disposal and HMR work. If you write a registry, `register()` must return the disposer. - **Typed events via declaration merging**: services declare their events in `declare module 'cordis' { interface Events { … } }`, and their ctx key in `interface Context`. Extensible unions use the merge-extensible-map pattern (see `ContentBlockMap`, `MessageSourceMap`). diff --git a/docs/cookbook/adding-a-package.md b/docs/cookbook/adding-a-package.md index c9962f27a1..dac46e4db6 100644 --- a/docs/cookbook/adding-a-package.md +++ b/docs/cookbook/adding-a-package.md @@ -7,7 +7,7 @@ The file-by-file checklist for a new `@deepseek-ai/dsh-` package. (Verifie ``` packages// package.json # copy from packages/tools, adjust name/description/deps - tsconfig.json # extends ../../tsconfig.base.json, rootDir src, outDir lib/typings, + tsconfig.json # extends ../../tsconfig.base.json, rootDir src, outDir lib/types, # references: vendor/cosmokit, vendor/cordis (+ vendor/schemastery # if you use Config, + ../ for each dsh dependency) src/index.ts # service default export or plugin (name/inject/apply/Config) @@ -15,7 +15,7 @@ packages// README.md # service API, events, extension points, design notes ``` -package.json invariants (enforced by `pnpm run constraints` / `scripts/check-workspace-constraints.ts`): `private: true`, `version: 0.0.1`, `type: module`, `main: "lib/index.js"`, `types: "lib/typings/index.d.ts"`, `exports["."].types: "./lib/typings/index.d.ts"`, `exports["."].default: "./lib/index.js"`, `cordis` in BOTH peerDependencies and devDependencies (same range). Mirror every dsh peer dependency in devDependencies. `schemastery` goes in `dependencies` (it is a runtime validator), matching agent-loop. The `files` list is precise: `lib/index.js`, `lib/typings/**/*.d.ts`, `lib/typings/**/*.d.ts.map`, and `src`; do not publish `lib/typings` JS/map intermediates or stale root declaration files. +package.json invariants (enforced by `pnpm run constraints` / `scripts/check-workspace-constraints.ts`): `private: true`, `version: 0.0.1`, `type: module`, `main: "lib/index.js"`, `types: "lib/types/index.d.ts"`, `exports["."].types: "./lib/types/index.d.ts"`, `exports["."].default: "./lib/index.js"`, `cordis` in BOTH peerDependencies and devDependencies (same range). Mirror every dsh peer dependency in devDependencies. `schemastery` goes in `dependencies` (it is a runtime validator), matching agent-loop. The `files` list is precise: `lib/index.js`, `lib/types/**/*.d.ts`, `lib/types/**/*.d.ts.map`, and `src`; do not publish `lib/types` JS or JS-map intermediates or stale root declaration files. ## 2. Register it in the root configs diff --git a/docs/cookbook/adding-a-vendored-package.md b/docs/cookbook/adding-a-vendored-package.md index ed54a0a578..c45427e0b6 100644 --- a/docs/cookbook/adding-a-vendored-package.md +++ b/docs/cookbook/adding-a-vendored-package.md @@ -12,13 +12,13 @@ vendor// README.md LICENSE # if upstream ships them ``` -`tsconfig.json` mirrors the other vendored packages — `rootDir: src`, `outDir: lib/typings`, the strictness relaxations upstream code needs, and a `references` entry for every other vendored package it imports: +`tsconfig.json` mirrors the other vendored packages — `rootDir: src`, `outDir: lib/types`, the strictness relaxations upstream code needs, and a `references` entry for every other vendored package it imports: ```jsonc { "extends": "../../tsconfig.base.json", "compilerOptions": { - "rootDir": "src", "outDir": "lib/typings", + "rootDir": "src", "outDir": "lib/types", "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, "noImplicitOverride": false, "noUnusedLocals": false, "noUnusedParameters": false }, @@ -27,7 +27,7 @@ vendor// } ``` -`package.json` invariants: `"private": true` (vendored packages are never published), keep upstream's `name`/`version`/`exports`/`type`, point declaration metadata at `lib/typings`, publish `.d.ts` and `.d.ts.map` declaration outputs, and list its cordis deps in `peerDependencies` (matching the upstream manifest). Transitive upstream deps must themselves be vendored or already present — vendoring one package often means vendoring its dependency tree (e.g. `@cordisjs/plugin-http` pulls `@cordisjs/fetch-file`). +`package.json` invariants: `"private": true` (vendored packages are never published), keep upstream's `name`/`version`/`exports`/`type`, point declaration metadata at `lib/types`, publish `.d.ts` and `.d.ts.map` declaration outputs, and list its cordis deps in `peerDependencies` (matching the upstream manifest). Transitive upstream deps must themselves be vendored or already present — vendoring one package often means vendoring its dependency tree (e.g. `@cordisjs/plugin-http` pulls `@cordisjs/fetch-file`). ## 2. Register it in the root configs @@ -39,7 +39,7 @@ vendor// | `vendor/README.md` | add a manifest table row (dir, npm name, version, upstream repo, commit SHA) and log any local modifications | | `scripts/publint-all.ts` | only if the vendored package is itself published from here (vendored deps normally are not — skip) | -Covered automatically by globs — no edits needed: root `package.json` workspaces (`vendor/*`), `tsdown.config.ts`, `vitest.config.ts`, `eslint.config.mjs`. A per-package `vendor//tsdown.config.ts` is needed ONLY if the build shape diverges from the root default (dual ESM/CJS or multiple entries — see `vendor/schemastery` and `vendor/logger-console`); its entry should read the JS emitted under `lib/typings`. +Covered automatically by globs — no edits needed: root `package.json` workspaces (`vendor/*`), `tsdown.config.ts`, `vitest.config.ts`, `eslint.config.mjs`. A per-package `vendor//tsdown.config.ts` is needed ONLY if the build shape diverges from the root default (dual ESM/CJS or multiple entries — see `vendor/schemastery` and `vendor/logger-console`); its entry should read the JS emitted under `lib/types`. ## 3. Mind the manifest guard diff --git a/docs/development.md b/docs/development.md index 700b25251d..83d1cb3fac 100644 --- a/docs/development.md +++ b/docs/development.md @@ -99,7 +99,7 @@ pnpm run verify-md-links # fail on broken relative Markdown links in checked do pnpm run doc-sync # doc-typecheck, event taxonomy, markdown wrap, and link verification pnpm run gen-module-graph # regenerate docs/module-graph.md from package peerDeps pnpm run verify-module-graph # fail if docs/module-graph.md is stale -pnpm run build # emit lib/typings intermediates, then bundle lib/index.* runtime files +pnpm run build # emit lib/types intermediates, then bundle lib/index.* runtime files pnpm run hygiene # knip, publint, and workspace constraints ``` diff --git a/docs/rfc/implemented/2026-06-11-tsdown-over-dumble.md b/docs/rfc/implemented/2026-06-11-tsdown-over-dumble.md index bd69ebbf31..dc028d7e9b 100644 --- a/docs/rfc/implemented/2026-06-11-tsdown-over-dumble.md +++ b/docs/rfc/implemented/2026-06-11-tsdown-over-dumble.md @@ -15,7 +15,7 @@ Build output currently matters only for `pnpm run build` + publint (nothing publ Replace dumble with **tsdown** (rolldown-based, ~2.5M downloads/week, VoidZero-backed, actively released): - Root `tsdown.config.ts` with `workspace: ['vendor/*', 'packages/*']` (explicit globs, not `workspace: true`, which would also pick up `examples/*` — they have package.json files but are not pnpm workspaces). -- Shared shape: entry `lib/typings/index.js`, `outDir: 'lib'`, ESM, `platform: node`, `target: es2024`, `fixedExtension: false` (keeps `.js` for `"type": "module"` packages), `dts: false` (tsc -b owns declarations), `clean: false` (lib/ also holds TSC's `lib/typings` intermediate tree). The entry was originally `src/index.ts`; the [TSC-first build RFC](2026-06-17-ts-build-config.md) later moved tsdown to bundling TSC-emitted JS so TypeScript transform behavior comes from one compiler. +- Shared shape: entry `lib/types/index.js`, `outDir: 'lib'`, ESM, `platform: node`, `target: es2024`, `fixedExtension: false` (keeps `.js` for `"type": "module"` packages), `dts: false` (tsc -b owns declarations), `clean: false` (lib/ also holds TSC's `lib/types` intermediate tree). The entry was originally `src/index.ts`; the [TSC-first build RFC](2026-06-17-ts-build-config.md) later moved tsdown to bundling TSC-emitted JS so TypeScript transform behavior comes from one compiler. - Two per-package overrides in vendor/ (ours, like the regenerated tsconfigs; logged in vendor/README.md): schemastery (dual `.mjs`/`.cjs` via `outExtensions`), logger-console (two single-entry passes so the shared base class is inlined into each entry instead of a hash-named chunk, matching upstream's published shape). - `scripts/build.ts` deleted; `pnpm run build` = `tsc -b tsconfig.build.json && tsdown`. @@ -23,4 +23,4 @@ Alternatives considered: **direct esbuild script** (most established engine, zer ## Consequences -Runtime bundle outputs still follow the dumble-era public entry shape (`lib/index.js`, plus package-specific variants such as `schemastery`'s `lib/index.mjs`/`lib/index.cjs` and `logger-console`'s `lib/browser.js`); declarations now live under `lib/typings` per the [TSC-first build RFC](2026-06-17-ts-build-config.md). Externals still come from each package's dependencies/peerDependencies. We give up dumble's exports-field inference — new packages with non-default shapes need a per-package `tsdown.config.ts` instead of just package.json fields. Future option: tsdown could also absorb declaration bundling (isolatedDeclarations) if `tsc -b` ever becomes the bottleneck; that would be a new RFC. +Runtime bundle outputs still follow the dumble-era public entry shape (`lib/index.js`, plus package-specific variants such as `schemastery`'s `lib/index.mjs`/`lib/index.cjs` and `logger-console`'s `lib/browser.js`); declarations now live under `lib/types` per the [TSC-first build RFC](2026-06-17-ts-build-config.md). Externals still come from each package's dependencies/peerDependencies. We give up dumble's exports-field inference — new packages with non-default shapes need a per-package `tsdown.config.ts` instead of just package.json fields. Future option: tsdown could also absorb declaration bundling (isolatedDeclarations) if `tsc -b` ever becomes the bottleneck; that would be a new RFC. diff --git a/docs/rfc/implemented/2026-06-17-ts-build-config.md b/docs/rfc/implemented/2026-06-17-ts-build-config.md index 9c64de454f..6c5a11156f 100644 --- a/docs/rfc/implemented/2026-06-17-ts-build-config.md +++ b/docs/rfc/implemented/2026-06-17-ts-build-config.md @@ -30,15 +30,15 @@ In-package relative imports are extensionless. `pnpm run build` is a two-stage build: -- Stage 1: `tsc -b tsconfig.build.json` emits per-module `.js`, declarations `.d.ts`, JS sourcemaps `.js.map`, and declaration sourcemaps `.d.ts.map` into each package's `lib/typings`. This is the authoritative TypeScript compilation result. For publish we keep `.d.ts` / `.d.ts.map` and ignore `.js` / `.js.map`. +- Stage 1: `tsc -b tsconfig.build.json` emits per-module `.js`, declarations `.d.ts`, JS sourcemaps `.js.map`, and declaration sourcemaps `.d.ts.map` into each package's `lib/types`. This is the authoritative TypeScript compilation result. For publish we keep `.d.ts` / `.d.ts.map` and ignore `.js` / `.js.map`. - The build project uses the project-reference graph that `tsc -b` compiles. For example, root `tsconfig.build.json` references package and vendor tsconfigs. It validates and emits package/vendor build results. -- Stage 2: a bundler reads the emitted JS under `lib/typings` and writes the bundled runtime entry as `lib/index.js` or `lib/index.mjs` (follow current behavior). This stage is bundling only. It must not read TypeScript source or emit declarations. +- Stage 2: a bundler reads the emitted JS under `lib/types` and writes the bundled runtime entry as `lib/index.js` or `lib/index.mjs` (follow current behavior). This stage is bundling only. It must not read TypeScript source or emit declarations. `tsdown` is no longer the owner of TypeScript compilation or declaration output. `pnpm run typecheck` runs build mode over the root `tsconfig.json`. - The root `tsconfig.json` is the single development/typecheck project. It typechecks examples, tests, and scripts with `noEmit`, and validates package/vendor source through references. -- Referenced package/vendor projects keep the same emit behavior as build, so typecheck can refresh their `lib/typings` outputs instead of using a separate no-emit graph. Project-specific strictness changes live in the owning `packages/*/tsconfig.json` or `vendor/*/tsconfig.json`. +- Referenced package/vendor projects keep the same emit behavior as build, so typecheck can refresh their `lib/types` outputs instead of using a separate no-emit graph. Project-specific strictness changes live in the owning `packages/*/tsconfig.json` or `vendor/*/tsconfig.json`. The command orchestration shape is: @@ -59,8 +59,8 @@ Build responsibilities are clearer: - Each module under `packages/*` and `vendor/*` has one local tsconfig for build, typecheck, and tools that run source directly, such as `tsx` and `vitest`. - The `build` command uses `tsconfig.build.json`. `tsc -b` owns the publishable per-module `.js` and `.d.ts` output, and the bundler owns only `lib/index.*`. - - `lib/typings/*.d.ts` and `.d.ts.map` are the publish declaration output. - - `lib/typings/*.js` is only a bundler input and must not be used as a runtime entry or public import target. + - `lib/types/*.d.ts` and `.d.ts.map` are the publish declaration output. + - `lib/types/*.js` is only a bundler input and must not be used as a runtime entry or public import target. - `lib/index.*` is the publish runtime output and is generated by the bundler, currently `tsdown`. - The `typecheck` command uses `tsconfig.json`. Examples, tests, and scripts are checked by the root no-emit project, while packages and vendor modules keep the same emit behavior as `build`. Package and vendor source stays behind project-reference boundaries. diff --git a/packages/acp/package.json b/packages/acp/package.json index 9f052e5753..6973dc5e20 100644 --- a/packages/acp/package.json +++ b/packages/acp/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/acp/tsconfig.json b/packages/acp/tsconfig.json index 73d850e990..75c578f9ec 100644 --- a/packages/acp/tsconfig.json +++ b/packages/acp/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/agent-loop/package.json b/packages/agent-loop/package.json index ae7296d4df..6e92adb6ab 100644 --- a/packages/agent-loop/package.json +++ b/packages/agent-loop/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/agent-loop/tsconfig.json b/packages/agent-loop/tsconfig.json index 93a07b2e41..afec654d20 100644 --- a/packages/agent-loop/tsconfig.json +++ b/packages/agent-loop/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/agent/package.json b/packages/agent/package.json index eb3a967338..3d2d421a75 100644 --- a/packages/agent/package.json +++ b/packages/agent/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/agent/tsconfig.json b/packages/agent/tsconfig.json index c2b740741a..47e367a340 100644 --- a/packages/agent/tsconfig.json +++ b/packages/agent/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/bash-local/package.json b/packages/bash-local/package.json index 7a8f6fb2a4..bc1dc7eb40 100644 --- a/packages/bash-local/package.json +++ b/packages/bash-local/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/bash-local/tsconfig.json b/packages/bash-local/tsconfig.json index 576ebe64a8..6a578833d6 100644 --- a/packages/bash-local/tsconfig.json +++ b/packages/bash-local/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/bash/package.json b/packages/bash/package.json index 8f33a4ccff..865de7b643 100644 --- a/packages/bash/package.json +++ b/packages/bash/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/bash/tsconfig.json b/packages/bash/tsconfig.json index f5803cec7f..e4c6cd4e12 100644 --- a/packages/bash/tsconfig.json +++ b/packages/bash/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/invariants/package.json b/packages/invariants/package.json index 20ffc74bbf..97d6160b03 100644 --- a/packages/invariants/package.json +++ b/packages/invariants/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/invariants/tsconfig.json b/packages/invariants/tsconfig.json index e87cca530d..784b64253b 100644 --- a/packages/invariants/tsconfig.json +++ b/packages/invariants/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/llm-deepseek/package.json b/packages/llm-deepseek/package.json index 0da7a35b5e..8ebf71c5b5 100644 --- a/packages/llm-deepseek/package.json +++ b/packages/llm-deepseek/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/llm-deepseek/tsconfig.json b/packages/llm-deepseek/tsconfig.json index ceacbf1ee2..f6e5755202 100644 --- a/packages/llm-deepseek/tsconfig.json +++ b/packages/llm-deepseek/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/llm-pi-ai/package.json b/packages/llm-pi-ai/package.json index d212037a95..30911915ff 100644 --- a/packages/llm-pi-ai/package.json +++ b/packages/llm-pi-ai/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/llm-pi-ai/tsconfig.json b/packages/llm-pi-ai/tsconfig.json index ceacbf1ee2..f6e5755202 100644 --- a/packages/llm-pi-ai/tsconfig.json +++ b/packages/llm-pi-ai/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/llm-replay/package.json b/packages/llm-replay/package.json index d9569c2d02..ce57ea18ef 100644 --- a/packages/llm-replay/package.json +++ b/packages/llm-replay/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/llm-replay/tsconfig.json b/packages/llm-replay/tsconfig.json index c2b740741a..47e367a340 100644 --- a/packages/llm-replay/tsconfig.json +++ b/packages/llm-replay/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/llm/package.json b/packages/llm/package.json index 6a01d52c6c..9e45e31f28 100644 --- a/packages/llm/package.json +++ b/packages/llm/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/llm/tsconfig.json b/packages/llm/tsconfig.json index f5803cec7f..e4c6cd4e12 100644 --- a/packages/llm/tsconfig.json +++ b/packages/llm/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/session-persistence-jsonl/package.json b/packages/session-persistence-jsonl/package.json index 8620858548..ac18a38838 100644 --- a/packages/session-persistence-jsonl/package.json +++ b/packages/session-persistence-jsonl/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/session-persistence-jsonl/tsconfig.json b/packages/session-persistence-jsonl/tsconfig.json index 23465c380e..3209f6092d 100644 --- a/packages/session-persistence-jsonl/tsconfig.json +++ b/packages/session-persistence-jsonl/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/session-persistence-sqlite/package.json b/packages/session-persistence-sqlite/package.json index ad5cec37d6..b26c69461e 100644 --- a/packages/session-persistence-sqlite/package.json +++ b/packages/session-persistence-sqlite/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/session-persistence-sqlite/tsconfig.json b/packages/session-persistence-sqlite/tsconfig.json index 23465c380e..3209f6092d 100644 --- a/packages/session-persistence-sqlite/tsconfig.json +++ b/packages/session-persistence-sqlite/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/session-persistence/package.json b/packages/session-persistence/package.json index 17b3c7a796..ed6c80dfd9 100644 --- a/packages/session-persistence/package.json +++ b/packages/session-persistence/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/session-persistence/tsconfig.json b/packages/session-persistence/tsconfig.json index ebfd4b98f3..bfe2438963 100644 --- a/packages/session-persistence/tsconfig.json +++ b/packages/session-persistence/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/session/package.json b/packages/session/package.json index 42ef62567e..6136423ca2 100644 --- a/packages/session/package.json +++ b/packages/session/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/session/tsconfig.json b/packages/session/tsconfig.json index 747dd65daa..619f5e63cc 100644 --- a/packages/session/tsconfig.json +++ b/packages/session/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/system-prompt/package.json b/packages/system-prompt/package.json index 7e419ed29a..672f7a03ef 100644 --- a/packages/system-prompt/package.json +++ b/packages/system-prompt/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/system-prompt/tsconfig.json b/packages/system-prompt/tsconfig.json index 747dd65daa..619f5e63cc 100644 --- a/packages/system-prompt/tsconfig.json +++ b/packages/system-prompt/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/tool-bash/package.json b/packages/tool-bash/package.json index 23baf69058..f9092fabb6 100644 --- a/packages/tool-bash/package.json +++ b/packages/tool-bash/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/tool-bash/tsconfig.json b/packages/tool-bash/tsconfig.json index 131f52aca6..e47b47335c 100644 --- a/packages/tool-bash/tsconfig.json +++ b/packages/tool-bash/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/tools/package.json b/packages/tools/package.json index c78caf0f51..a6d3bbe0ca 100644 --- a/packages/tools/package.json +++ b/packages/tools/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/tools/tsconfig.json b/packages/tools/tsconfig.json index 20d6ab9643..c7a62d2fc3 100644 --- a/packages/tools/tsconfig.json +++ b/packages/tools/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/packages/ui-stdio/package.json b/packages/ui-stdio/package.json index 8e7c54454f..5d65356e79 100644 --- a/packages/ui-stdio/package.json +++ b/packages/ui-stdio/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/ui-stdio/tsconfig.json b/packages/ui-stdio/tsconfig.json index f87b686386..2f209f4bcc 100644 --- a/packages/ui-stdio/tsconfig.json +++ b/packages/ui-stdio/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings" + "outDir": "lib/types" }, "include": ["src"], "references": [ diff --git a/scripts/check-workspace-constraints.ts b/scripts/check-workspace-constraints.ts index 263be4af5a..306e09b132 100644 --- a/scripts/check-workspace-constraints.ts +++ b/scripts/check-workspace-constraints.ts @@ -69,8 +69,8 @@ function workspaceManifests(): WorkspaceManifest[] { const dshPackageFiles = [ 'lib/index.js', - 'lib/typings/**/*.d.ts', - 'lib/typings/**/*.d.ts.map', + 'lib/types/**/*.d.ts', + 'lib/types/**/*.d.ts.map', 'src', ] as const @@ -108,11 +108,11 @@ function checkWorkspace({ dir, manifest }: WorkspaceManifest): string[] { if (manifest.main !== 'lib/index.js') { errors.push(`${label}: package.json must set "main": "lib/index.js"`) } - if (manifest.types !== 'lib/typings/index.d.ts') { - errors.push(`${label}: package.json must set "types": "lib/typings/index.d.ts"`) + if (manifest.types !== 'lib/types/index.d.ts') { + errors.push(`${label}: package.json must set "types": "lib/types/index.d.ts"`) } - if (manifest.exports?.['.']?.types !== './lib/typings/index.d.ts') { - errors.push(`${label}: package.json exports["."].types must be "./lib/typings/index.d.ts"`) + if (manifest.exports?.['.']?.types !== './lib/types/index.d.ts') { + errors.push(`${label}: package.json exports["."].types must be "./lib/types/index.d.ts"`) } if (manifest.exports?.['.']?.default !== './lib/index.js') { errors.push(`${label}: package.json exports["."].default must be "./lib/index.js"`) diff --git a/tsdown.config.ts b/tsdown.config.ts index d6c3cca603..13570868f2 100644 --- a/tsdown.config.ts +++ b/tsdown.config.ts @@ -3,7 +3,7 @@ import { defineConfig } from 'tsdown' /** * Runtime bundling for all workspace packages (vendor/* + packages/*). * TypeScript source is compiled first by `tsc -b tsconfig.build.json`; tsdown - * reads only the emitted JS under lib/typings and writes lib/index.* runtime + * reads only the emitted JS under lib/types and writes lib/index.* runtime * bundles. Declarations are NOT produced here, hence `dts: false`. * * Per-package shape overrides live in `/tsdown.config.ts` @@ -13,7 +13,7 @@ export default defineConfig({ // Explicit globs: `workspace: true` would also discover examples/* (any // package.json), but only vendor/* and packages/* are pnpm workspaces. workspace: ['vendor/*', 'packages/*'], - entry: ['lib/typings/index.js'], + entry: ['lib/types/index.js'], outDir: 'lib', format: ['esm'], platform: 'node', diff --git a/vendor/README.md b/vendor/README.md index 43c53cfb53..dd55a9cd05 100644 --- a/vendor/README.md +++ b/vendor/README.md @@ -31,10 +31,10 @@ Intentionally **not** vendored (verified unused by this set): `reggol`, `@cordis Keep this log exhaustive — every divergence from upstream must be listed. 1. **`hmr/src/index.ts`**: removed the `./locales/en-US.yml` / `./locales/zh-CN.yml` imports, the `.i18n({...})` call on the `Config` schema, and the `src/locales/` directory. Rationale: those imports require a runtime YAML loader hook (`@cordisjs/unyaml`) that we do not vendor; the i18n texts only localize config descriptions. -2. **All `package.json` files**: regenerated — added `private: true`, added precise `files` entries for bundled runtime files and `lib/typings/**/*.d.ts` / `.d.ts.map`, preserved `src` in `files` only for packages whose previous file list already shipped it, added a `./src/*` export where missing, pointed declaration metadata at `lib/typings`, and removed upstream `devDependencies`/`scripts`/`repository` fields. Dependency and peer-dependency ranges preserved, except `hmr` declares `esbuild` as a direct dev dependency because its source imports the `BuildFailure` type and pnpm's strict workspace resolution requires the owner package to name that dependency. -3. **All `tsconfig.json` files**: regenerated to extend the repo-root `tsconfig.base.json`, emit TypeScript intermediates to `lib/typings`, and declare project references. +2. **All `package.json` files**: regenerated — added `private: true`, added precise `files` entries for bundled runtime files and `lib/types/**/*.d.ts` / `.d.ts.map`, preserved `src` in `files` only for packages whose previous file list already shipped it, added a `./src/*` export where missing, pointed declaration metadata at `lib/types`, and removed upstream `devDependencies`/`scripts`/`repository` fields. Dependency and peer-dependency ranges preserved, except `hmr` declares `esbuild` as a direct dev dependency because its source imports the `BuildFailure` type and pnpm's strict workspace resolution requires the owner package to name that dependency. +3. **All `tsconfig.json` files**: regenerated to extend the repo-root `tsconfig.base.json`, emit TypeScript intermediates to `lib/types`, and declare project references. 4. **Vendored TypeScript source internal specifiers**: changed local relative imports/exports from explicit `.ts` / `.js` specifiers to extensionless specifiers so generated `.js` and `.d.ts` intermediates are extensionless and no declaration postprocess is needed. This includes `loader/src/config/isolate.ts` changing `declare module './entry.ts'` to `declare module './entry'`. -5. **`schemastery/tsdown.config.ts` and `logger-console/tsdown.config.ts`**: ours, not upstream files — per-package build-shape overrides (dual ESM+CJS output; separate node/browser entries) for the repo-root tsdown build. They read the JS emitted under `lib/typings` and then write the publish runtime entries under `lib/`. Like the regenerated tsconfigs, they are not part of the upstream sync surface. +5. **`schemastery/tsdown.config.ts` and `logger-console/tsdown.config.ts`**: ours, not upstream files — per-package build-shape overrides (dual ESM+CJS output; separate node/browser entries) for the repo-root tsdown build. They read the JS emitted under `lib/types` and then write the publish runtime entries under `lib/`. Like the regenerated tsconfigs, they are not part of the upstream sync surface. ## Sync procedure diff --git a/vendor/cordis/package.json b/vendor/cordis/package.json index 59c3f69649..9d9ac07a34 100644 --- a/vendor/cordis/package.json +++ b/vendor/cordis/package.json @@ -6,11 +6,11 @@ "sideEffects": false, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "bin": "bin.js", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -18,8 +18,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "bin.js" ], "author": "Shigma ", diff --git a/vendor/cordis/tsconfig.json b/vendor/cordis/tsconfig.json index e0b2a46462..c7357481fd 100644 --- a/vendor/cordis/tsconfig.json +++ b/vendor/cordis/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings", + "outDir": "lib/types", "noImplicitAny": false, "noImplicitThis": false, "strictFunctionTypes": false, diff --git a/vendor/cosmokit/package.json b/vendor/cosmokit/package.json index d313ce5477..940fcdb539 100644 --- a/vendor/cosmokit/package.json +++ b/vendor/cosmokit/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "author": "Shigma ", diff --git a/vendor/cosmokit/tsconfig.json b/vendor/cosmokit/tsconfig.json index eb79653390..b7411f94f2 100644 --- a/vendor/cosmokit/tsconfig.json +++ b/vendor/cosmokit/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings", + "outDir": "lib/types", "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, "noImplicitOverride": false, diff --git a/vendor/group/package.json b/vendor/group/package.json index d8d56c7675..34a8f59ae2 100644 --- a/vendor/group/package.json +++ b/vendor/group/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "author": "Shigma ", diff --git a/vendor/group/tsconfig.json b/vendor/group/tsconfig.json index 2d93e6ae42..e512d1d84c 100644 --- a/vendor/group/tsconfig.json +++ b/vendor/group/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings", + "outDir": "lib/types", "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, "noImplicitOverride": false, diff --git a/vendor/hmr/package.json b/vendor/hmr/package.json index 7bab5dd3d8..28087d5fa8 100644 --- a/vendor/hmr/package.json +++ b/vendor/hmr/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "author": "Shigma ", diff --git a/vendor/hmr/tsconfig.json b/vendor/hmr/tsconfig.json index cfa1f07afd..8464912787 100644 --- a/vendor/hmr/tsconfig.json +++ b/vendor/hmr/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings", + "outDir": "lib/types", "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, "noImplicitOverride": false, diff --git a/vendor/include/package.json b/vendor/include/package.json index 0c91733947..f9314d0c5e 100644 --- a/vendor/include/package.json +++ b/vendor/include/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "author": "Shigma ", diff --git a/vendor/include/tsconfig.json b/vendor/include/tsconfig.json index 056206ecab..6fe5099b43 100644 --- a/vendor/include/tsconfig.json +++ b/vendor/include/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings", + "outDir": "lib/types", "noImplicitAny": false, "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, diff --git a/vendor/loader/package.json b/vendor/loader/package.json index 75b45a89a3..fde6d01d27 100644 --- a/vendor/loader/package.json +++ b/vendor/loader/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "author": "Shigma ", diff --git a/vendor/loader/tsconfig.json b/vendor/loader/tsconfig.json index ca6d75810a..2db62c7b63 100644 --- a/vendor/loader/tsconfig.json +++ b/vendor/loader/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings", + "outDir": "lib/types", "noImplicitAny": false, "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, diff --git a/vendor/logger-console/package.json b/vendor/logger-console/package.json index 33ec1d566a..8c0d8a0bda 100644 --- a/vendor/logger-console/package.json +++ b/vendor/logger-console/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/shared.d.ts", + "types": "lib/types/shared.d.ts", "exports": { ".": { - "types": "./lib/typings/shared.d.ts", + "types": "./lib/types/shared.d.ts", "node": "./lib/index.js", "default": "./lib/browser.js" }, @@ -18,8 +18,8 @@ "files": [ "lib/index.js", "lib/browser.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "author": "Shigma ", diff --git a/vendor/logger-console/tsconfig.json b/vendor/logger-console/tsconfig.json index 8714f410b6..cba4d151c7 100644 --- a/vendor/logger-console/tsconfig.json +++ b/vendor/logger-console/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings", + "outDir": "lib/types", "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, "noImplicitOverride": false, diff --git a/vendor/logger-console/tsdown.config.ts b/vendor/logger-console/tsdown.config.ts index c85dad4a28..0df6d4bd0b 100644 --- a/vendor/logger-console/tsdown.config.ts +++ b/vendor/logger-console/tsdown.config.ts @@ -3,7 +3,7 @@ import { defineConfig } from 'tsdown' /** * logger-console ships two entries: the node exporter (index) and the * browser exporter (browser), selected via package.json `exports` - * conditions. The entries are JS emitted by tsc under lib/typings and are + * conditions. The entries are JS emitted by tsc under lib/types and are * bundled as two single-entry passes so the shared base class is inlined into * each (matching upstream's published shape) instead of split into a hash-named * chunk. @@ -19,6 +19,6 @@ const shared = { } as const export default defineConfig([ - { ...shared, entry: ['lib/typings/index.js'] }, - { ...shared, entry: ['lib/typings/browser.js'] }, + { ...shared, entry: ['lib/types/index.js'] }, + { ...shared, entry: ['lib/types/browser.js'] }, ]) diff --git a/vendor/schemastery/package.json b/vendor/schemastery/package.json index 8ce5cc5aff..ec5791f3af 100644 --- a/vendor/schemastery/package.json +++ b/vendor/schemastery/package.json @@ -5,12 +5,12 @@ "private": true, "main": "lib/index.cjs", "module": "lib/index.mjs", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "files": [ "lib/index.mjs", "lib/index.cjs", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "author": "Shigma ", diff --git a/vendor/schemastery/tsconfig.json b/vendor/schemastery/tsconfig.json index f901861a39..b25fa05af7 100644 --- a/vendor/schemastery/tsconfig.json +++ b/vendor/schemastery/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings", + "outDir": "lib/types", "module": "preserve", "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, diff --git a/vendor/schemastery/tsdown.config.ts b/vendor/schemastery/tsdown.config.ts index b16c217750..57f2f5f6c4 100644 --- a/vendor/schemastery/tsdown.config.ts +++ b/vendor/schemastery/tsdown.config.ts @@ -3,11 +3,11 @@ import { defineConfig } from 'tsdown' /** * schemastery has no `"type": "module"` and publishes dual-format output * (package.json: main → lib/index.cjs, module → lib/index.mjs). The entry is - * the JS emitted by tsc under lib/typings; pin the bundled extensions + * the JS emitted by tsc under lib/types; pin the bundled extensions * explicitly because the defaults for a CommonJS package would emit .mjs/.js. */ export default defineConfig({ - entry: ['lib/typings/index.js'], + entry: ['lib/types/index.js'], outDir: 'lib', format: ['esm', 'cjs'], platform: 'node', diff --git a/vendor/timer/package.json b/vendor/timer/package.json index ff68a84aa0..07c41150e8 100644 --- a/vendor/timer/package.json +++ b/vendor/timer/package.json @@ -5,10 +5,10 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/typings/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/typings/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", @@ -16,8 +16,8 @@ }, "files": [ "lib/index.js", - "lib/typings/**/*.d.ts", - "lib/typings/**/*.d.ts.map", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "author": "Shigma ", diff --git a/vendor/timer/tsconfig.json b/vendor/timer/tsconfig.json index fc4fc9f4fc..843303e870 100644 --- a/vendor/timer/tsconfig.json +++ b/vendor/timer/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib/typings", + "outDir": "lib/types", "noUncheckedIndexedAccess": false, "exactOptionalPropertyTypes": false, "noImplicitOverride": false, From fd55d205484dee44b1d279d7551f096797f79e4c Mon Sep 17 00:00:00 2001 From: imccyu Date: Sun, 21 Jun 2026 23:57:00 +0800 Subject: [PATCH 13/21] revert: remove the non-branch changes introduced during the rebase --- AGENTS.md | 3 +-- docs/development.md | 1 - .../2026-06-11-doc-sync-enforcement.md | 2 -- pnpm-lock.yaml | 20 ++----------------- 4 files changed, 3 insertions(+), 23 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index f9631fed4d..f901b6d702 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -97,8 +97,7 @@ pnpm run verify-event-taxonomy # assert the event-taxonomy table in docs/archit # matches the interface Events declarations in source pnpm run verify-md-wrap # assert no hard-wrapped prose paragraphs in README.md, # docs/**/*.md, packages/*/README.md, AGENTS.md (one line per paragraph) -pnpm run verify-md-links # assert relative Markdown links resolve in checked docs -pnpm run doc-sync # doc-typecheck + verify-event-taxonomy + verify-md-wrap + verify-md-links (CI runs this) +pnpm run doc-sync # doc-typecheck + verify-event-taxonomy + verify-md-wrap (CI runs this) pnpm run demo:echo # run examples/echo-agent (no API key; type "echo hi" to # see a tool call) — the mock skeleton pnpm run demo:coding # run examples/coding-agent — the real agent (needs diff --git a/docs/development.md b/docs/development.md index 83d1cb3fac..5a14a23aa5 100644 --- a/docs/development.md +++ b/docs/development.md @@ -95,7 +95,6 @@ pnpm run lint:fix # eslint . --fix pnpm run doc-typecheck # compile checked TypeScript snippets in Markdown docs pnpm run verify-event-taxonomy # compare docs/architecture.md event names with source pnpm run verify-md-wrap # fail on hard-wrapped prose paragraphs in docs/README markdown -pnpm run verify-md-links # fail on broken relative Markdown links in checked docs pnpm run doc-sync # doc-typecheck, event taxonomy, markdown wrap, and link verification pnpm run gen-module-graph # regenerate docs/module-graph.md from package peerDeps pnpm run verify-module-graph # fail if docs/module-graph.md is stale diff --git a/docs/rfc/implemented/2026-06-11-doc-sync-enforcement.md b/docs/rfc/implemented/2026-06-11-doc-sync-enforcement.md index 51aff694b8..7918f5762c 100644 --- a/docs/rfc/implemented/2026-06-11-doc-sync-enforcement.md +++ b/docs/rfc/implemented/2026-06-11-doc-sync-enforcement.md @@ -19,8 +19,6 @@ Both run via a shared `doc-sync` package.json script that the lefthook pre-push **Amendment (2026-06-17):** a third gate, **`verify-md-wrap`**, was later folded into `doc-sync`. It parses each in-scope Markdown file (`README.md`, `docs/**`, `packages/*/README.md`, plus `AGENTS.md` / `packages/AGENTS.md`) with `mdast-util-from-markdown` + GFM and fails on any `paragraph` node spanning more than one source line, enforcing the AGENTS.md "Markdown is not hard-wrapped" convention. Same verify-don't-generate principle: it reports hard-wraps and never rewrites, so it adds no formatting churn. `doc-sync` is now three gates. -**Amendment (2026-06-18):** a fourth gate, **`verify-md-links`**, was later folded into `doc-sync` by the [Markdown cross-link validity linting RFC](2026-06-18-markdown-cross-link-lint.md). It checks that every relative Markdown link in the checked docs resolves to an existing file, so the RFC tree can use date-based filenames and relative links instead of stale numeric prose references. `doc-sync` is now four gates. - ## Consequences - Doc drift in the checkable classes now fails the pre-push hook and CI instead of waiting for a reviewer to notice. This is an instance of the "mechanical gates over prose" principle. diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d44608e415..5026104cd9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -49,7 +49,7 @@ importers: version: 0.3.21 tsdown: specifier: ^0.22.2 - version: 0.22.2(oxc-resolver@11.20.0)(publint@0.3.21)(tsx@4.22.4)(typescript@6.0.3)(unrun@0.3.1) + version: 0.22.2(oxc-resolver@11.20.0)(publint@0.3.21)(tsx@4.22.4)(typescript@6.0.3) tsx: specifier: ^4.22.4 version: 4.22.4 @@ -2620,16 +2620,6 @@ packages: unist-util-visit@5.1.0: resolution: {integrity: sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg==} - unrun@0.3.1: - resolution: {integrity: sha512-onIck/oNnCaytwths1ZVp1LK2Gq2hPoyFhiHebObuUXqR3S0uHuLLaBK8K6mRRgV7Ptip8AnNvaUsgzwWwBZuA==} - engines: {node: ^22.13.0 || >=24.0.0} - hasBin: true - peerDependencies: - synckit: ^0.11.11 - peerDependenciesMeta: - synckit: - optional: true - uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} @@ -4943,7 +4933,7 @@ snapshots: optionalDependencies: typescript: 6.0.3 - tsdown@0.22.2(oxc-resolver@11.20.0)(publint@0.3.21)(tsx@4.22.4)(typescript@6.0.3)(unrun@0.3.1): + tsdown@0.22.2(oxc-resolver@11.20.0)(publint@0.3.21)(tsx@4.22.4)(typescript@6.0.3): dependencies: ansis: 4.3.1 cac: 7.0.0 @@ -4964,7 +4954,6 @@ snapshots: publint: 0.3.21 tsx: 4.22.4 typescript: 6.0.3 - unrun: 0.3.1 transitivePeerDependencies: - '@ts-macro/tsc' - '@typescript/native-preview' @@ -5026,11 +5015,6 @@ snapshots: unist-util-is: 6.0.1 unist-util-visit-parents: 6.0.2 - unrun@0.3.1: - dependencies: - rolldown: 1.1.1 - optional: true - uri-js@4.4.1: dependencies: punycode: 2.3.1 From 88b75181adcd0a5278f8a4d771b125da49ece628 Mon Sep 17 00:00:00 2001 From: imccyu Date: Mon, 22 Jun 2026 00:51:41 +0800 Subject: [PATCH 14/21] fix: apply ts-build-config adjustment to new packages --- package.json | 2 +- packages/bash/bash/src/index.ts | 2 +- packages/core/agent-core/package.json | 8 ++-- .../core/agent-core/tests/agent-core.spec.ts | 2 +- packages/core/agent-core/tsconfig.json | 2 +- packages/core/agent-loop/tests/cancel.spec.ts | 2 +- .../agent/tests/gen-cordis-catalog.spec.ts | 2 +- .../llm/llm-deepseek/tests/adapter.e2e.ts | 2 +- .../llm/llm-deepseek/tests/adapter.spec.ts | 2 +- packages/llm/llm-pi-ai/tests/adapter.e2e.ts | 2 +- packages/llm/llm-pi-ai/tests/adapter.spec.ts | 2 +- packages/llm/llm/src/assembler.ts | 4 +- .../session-persistence/src/coordinator.ts | 2 +- .../session-persistence/src/index.ts | 4 +- .../tests/coordinator-contract.ts | 4 +- packages/ui/acp-agent/package.json | 11 +++-- packages/ui/acp-agent/tests/acp-agent.spec.ts | 2 +- packages/ui/acp-agent/tsconfig.json | 2 +- packages/ui/acp-agent/tsdown.config.ts | 7 ++-- packages/ui/stdio-agent/package.json | 11 +++-- .../ui/stdio-agent/tests/stdio-agent.spec.ts | 2 +- packages/ui/stdio-agent/tsconfig.json | 2 +- packages/ui/stdio-agent/tsdown.config.ts | 7 ++-- packages/util/brand/package.json | 8 ++-- packages/util/brand/tsconfig.json | 2 +- tsconfig.json | 40 ++++++++++--------- 26 files changed, 76 insertions(+), 60 deletions(-) diff --git a/package.json b/package.json index 05ca0cecad..1e6155ff94 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ ], "scripts": { "build": "tsc -b tsconfig.build.json && tsdown", - "clean:build": "rm -rf .typecheck packages/*/lib vendor/*/lib *.tsbuildinfo", + "clean:build": "rm -rf .typecheck packages/*/*/lib vendor/*/lib *.tsbuildinfo", "typecheck": "tsc -b tsconfig.json", "lint": "eslint .", "lint:fix": "eslint . --fix", diff --git a/packages/bash/bash/src/index.ts b/packages/bash/bash/src/index.ts index e7f4fad421..b8d7c619e1 100644 --- a/packages/bash/bash/src/index.ts +++ b/packages/bash/bash/src/index.ts @@ -17,7 +17,7 @@ import { Context, Service } from 'cordis' import type { BashExecRequest, BashExecSpec, BashRunResult, BashTask, BashTaskId, BashTaskListener, BashTaskRead, OwnerToken } from './types' -export { BashTaskId, OwnerToken } from './types.ts' +export { BashTaskId, OwnerToken } from './types' export type { BashExecRequest, BashExecSpec, diff --git a/packages/core/agent-core/package.json b/packages/core/agent-core/package.json index d6e716835b..a70ee30e71 100644 --- a/packages/core/agent-core/package.json +++ b/packages/core/agent-core/package.json @@ -5,17 +5,19 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/core/agent-core/tests/agent-core.spec.ts b/packages/core/agent-core/tests/agent-core.spec.ts index 67f5d88532..fe3d89eca6 100644 --- a/packages/core/agent-core/tests/agent-core.spec.ts +++ b/packages/core/agent-core/tests/agent-core.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' import { Context } from 'cordis' import Loader from '@cordisjs/plugin-loader' -import * as agentCore from '../src/index.ts' +import * as agentCore from '../src/index' import { AgentId } from '@deepseek-ai/dsh-agent' /** diff --git a/packages/core/agent-core/tsconfig.json b/packages/core/agent-core/tsconfig.json index 3cf1e3fb74..83bf06c586 100644 --- a/packages/core/agent-core/tsconfig.json +++ b/packages/core/agent-core/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/types" }, "include": [ "src" diff --git a/packages/core/agent-loop/tests/cancel.spec.ts b/packages/core/agent-loop/tests/cancel.spec.ts index 9cdaa1973b..71b1b80ea4 100644 --- a/packages/core/agent-loop/tests/cancel.spec.ts +++ b/packages/core/agent-loop/tests/cancel.spec.ts @@ -18,7 +18,7 @@ import SystemPrompt from '@deepseek-ai/dsh-system-prompt' import ToolRegistry from '@deepseek-ai/dsh-tools' import AgentRegistry, { AgentId } from '@deepseek-ai/dsh-agent' import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' -import { MockAdapter, textResponse } from './mock-adapter.ts' +import { MockAdapter, textResponse } from './mock-adapter' async function harness(adapter: MockAdapter) { const ctx = new Context() diff --git a/packages/core/agent/tests/gen-cordis-catalog.spec.ts b/packages/core/agent/tests/gen-cordis-catalog.spec.ts index ee2ce47699..e040b39b77 100644 --- a/packages/core/agent/tests/gen-cordis-catalog.spec.ts +++ b/packages/core/agent/tests/gen-cordis-catalog.spec.ts @@ -14,7 +14,7 @@ import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, describe, expect, it } from 'vitest' -import { collectEvents } from '../../../../scripts/gen-cordis-catalog.ts' +import { collectEvents } from '../../../../scripts/gen-cordis-catalog' /** Write a fixture package exposing one `interface Events` block and return the * scan root to hand `collectEvents`. */ diff --git a/packages/llm/llm-deepseek/tests/adapter.e2e.ts b/packages/llm/llm-deepseek/tests/adapter.e2e.ts index b01b498dff..51fbdbd187 100644 --- a/packages/llm/llm-deepseek/tests/adapter.e2e.ts +++ b/packages/llm/llm-deepseek/tests/adapter.e2e.ts @@ -4,7 +4,7 @@ import LlmService, { CallId } from '@deepseek-ai/dsh-llm' import type { Message, ToolSchema } from '@deepseek-ai/dsh-llm' import * as LlmDeepSeek from '@deepseek-ai/dsh-llm-deepseek' import type { Config } from '@deepseek-ai/dsh-llm-deepseek' -import { assemble, type AssembledResult } from './assemble.ts' +import { assemble, type AssembledResult } from './assemble' /** * Real-API e2e for the hand-rolled adapter: V4 Flash + V4 Pro across diff --git a/packages/llm/llm-deepseek/tests/adapter.spec.ts b/packages/llm/llm-deepseek/tests/adapter.spec.ts index 1abbebc060..f576831e2c 100644 --- a/packages/llm/llm-deepseek/tests/adapter.spec.ts +++ b/packages/llm/llm-deepseek/tests/adapter.spec.ts @@ -5,7 +5,7 @@ import { Context } from 'cordis' import LlmService, { LlmError } from '@deepseek-ai/dsh-llm' import * as LlmDeepSeek from '@deepseek-ai/dsh-llm-deepseek' import { DeepSeekAdapter, httpErrorCode } from '@deepseek-ai/dsh-llm-deepseek' -import { assemble } from './assemble.ts' +import { assemble } from './assemble' /** One scripted behavior for the next request the mock server receives. */ type Behavior = diff --git a/packages/llm/llm-pi-ai/tests/adapter.e2e.ts b/packages/llm/llm-pi-ai/tests/adapter.e2e.ts index fa30226ddf..678bb409fd 100644 --- a/packages/llm/llm-pi-ai/tests/adapter.e2e.ts +++ b/packages/llm/llm-pi-ai/tests/adapter.e2e.ts @@ -5,7 +5,7 @@ import type { Message, ToolSchema } from '@deepseek-ai/dsh-llm' import * as LlmPiAi from '@deepseek-ai/dsh-llm-pi-ai' import type { Config } from '@deepseek-ai/dsh-llm-pi-ai' import * as LlmDeepSeek from '@deepseek-ai/dsh-llm-deepseek' -import { assemble, type AssembledResult } from './assemble.ts' +import { assemble, type AssembledResult } from './assemble' /** * Real-API e2e for the pi-ai-backed adapter: V4 Flash + V4 Pro across all diff --git a/packages/llm/llm-pi-ai/tests/adapter.spec.ts b/packages/llm/llm-pi-ai/tests/adapter.spec.ts index 63f9f90456..bd09afff99 100644 --- a/packages/llm/llm-pi-ai/tests/adapter.spec.ts +++ b/packages/llm/llm-pi-ai/tests/adapter.spec.ts @@ -5,7 +5,7 @@ import { Context } from 'cordis' import LlmService, { CallId, LlmError } from '@deepseek-ai/dsh-llm' import * as LlmPiAi from '@deepseek-ai/dsh-llm-pi-ai' import { buildModel, PiAiAdapter } from '@deepseek-ai/dsh-llm-pi-ai' -import { assemble } from './assemble.ts' +import { assemble } from './assemble' /** Scripted SSE responses, one per request (OpenAI chat-completions shape). */ interface MockServer { diff --git a/packages/llm/llm/src/assembler.ts b/packages/llm/llm/src/assembler.ts index 65402738d8..fd13c34ad1 100644 --- a/packages/llm/llm/src/assembler.ts +++ b/packages/llm/llm/src/assembler.ts @@ -6,8 +6,8 @@ * @module @deepseek-ai/dsh-llm/assembler */ -import { CallId } from './brand.ts' -import { assertNever } from './never.ts' +import { CallId } from './brand' +import { assertNever } from './never' import type { ContentBlock, FinishReason, Message, StreamChunk, TokenUsage } from './types' interface PartialBlock { diff --git a/packages/session-persistence/session-persistence/src/coordinator.ts b/packages/session-persistence/session-persistence/src/coordinator.ts index 7c7b044ee1..ace8125ce2 100644 --- a/packages/session-persistence/session-persistence/src/coordinator.ts +++ b/packages/session-persistence/session-persistence/src/coordinator.ts @@ -27,7 +27,7 @@ import { Context } from 'cordis' import { interruptedTurnClosers, SESSION_FORMAT_VERSION } from '@deepseek-ai/dsh-session' import type { Session, SessionEvent, SessionId, SessionHeader } from '@deepseek-ai/dsh-session' -import { assertSerializable, seedCoversPrefix } from './index.ts' +import { assertSerializable, seedCoversPrefix } from './index' /** * A stored session's durable prefix as read back from a backend: its diff --git a/packages/session-persistence/session-persistence/src/index.ts b/packages/session-persistence/session-persistence/src/index.ts index a9ffd11792..239feb2825 100644 --- a/packages/session-persistence/session-persistence/src/index.ts +++ b/packages/session-persistence/session-persistence/src/index.ts @@ -29,8 +29,8 @@ import type { SessionEvent, SessionId, SessionHeader } from '@deepseek-ai/dsh-se export type { SessionHeader } from '@deepseek-ai/dsh-session' // The backend-agnostic write-path orchestration first-party backends compose. -export { PersistenceCoordinator } from './coordinator.ts' -export type { PersistenceBackend, StoredPrefix } from './coordinator.ts' +export { PersistenceCoordinator } from './coordinator' +export type { PersistenceBackend, StoredPrefix } from './coordinator' declare module 'cordis' { interface Context { diff --git a/packages/session-persistence/session-persistence/tests/coordinator-contract.ts b/packages/session-persistence/session-persistence/tests/coordinator-contract.ts index 431d02b4cb..7eab088deb 100644 --- a/packages/session-persistence/session-persistence/tests/coordinator-contract.ts +++ b/packages/session-persistence/session-persistence/tests/coordinator-contract.ts @@ -30,8 +30,8 @@ import { describe, expect, it } from 'vitest' import { Context, type Fiber } from 'cordis' import SessionStore, { SESSION_FORMAT_VERSION, SessionId } from '@deepseek-ai/dsh-session' import type { Session, SessionEvent } from '@deepseek-ai/dsh-session' -import type { SessionPersistence } from '../src/index.ts' -import { meta, oneTurnLog } from './contract.ts' +import type { SessionPersistence } from '../src/index' +import { meta, oneTurnLog } from './contract' /** * The backend-specific capabilities the orchestration suite needs beyond the diff --git a/packages/ui/acp-agent/package.json b/packages/ui/acp-agent/package.json index 0ecbba9e6a..72eb95b2f7 100644 --- a/packages/ui/acp-agent/package.json +++ b/packages/ui/acp-agent/package.json @@ -5,24 +5,27 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/types/index.d.ts", "bin": { "dsh-acp-agent": "lib/bin.js" }, "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./bin": { - "types": "./lib/bin.d.ts", + "types": "./lib/types/bin.d.ts", "default": "./lib/bin.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/bin.js", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/ui/acp-agent/tests/acp-agent.spec.ts b/packages/ui/acp-agent/tests/acp-agent.spec.ts index 7a02837fca..c8e7920669 100644 --- a/packages/ui/acp-agent/tests/acp-agent.spec.ts +++ b/packages/ui/acp-agent/tests/acp-agent.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' import { Context } from 'cordis' import Loader from '@cordisjs/plugin-loader' -import * as acpAgent from '../src/index.ts' +import * as acpAgent from '../src/index' /** * In-process unit coverage for the @deepseek-ai/dsh-acp-agent composition: diff --git a/packages/ui/acp-agent/tsconfig.json b/packages/ui/acp-agent/tsconfig.json index 773ca2e293..ffea8ec6f6 100644 --- a/packages/ui/acp-agent/tsconfig.json +++ b/packages/ui/acp-agent/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/types" }, "include": [ "src" diff --git a/packages/ui/acp-agent/tsdown.config.ts b/packages/ui/acp-agent/tsdown.config.ts index a0710d6e4d..9dd130b30d 100644 --- a/packages/ui/acp-agent/tsdown.config.ts +++ b/packages/ui/acp-agent/tsdown.config.ts @@ -3,11 +3,12 @@ import { defineConfig } from 'tsdown' /** * acp-agent ships TWO entries: the plugin (`index`) and the CLI `bin` (`bin`), * the latter referenced by package.json `bin`/`exports["./bin"]`. The root - * tsdown builds only `src/index.ts`, so this override adds `bin.ts`. - * Declarations come from `tsc -b` (dts: false), matching every package. + * tsdown builds only `lib/types/index.js`, so this override adds + * `lib/types/bin.js`. Declarations come from `tsc -b` (dts: false), + * matching every package. */ export default defineConfig({ - entry: ['src/index.ts', 'src/bin.ts'], + entry: ['lib/types/index.js', 'lib/types/bin.js'], outDir: 'lib', format: ['esm'], platform: 'node', diff --git a/packages/ui/stdio-agent/package.json b/packages/ui/stdio-agent/package.json index 45e8021607..bc9c98a411 100644 --- a/packages/ui/stdio-agent/package.json +++ b/packages/ui/stdio-agent/package.json @@ -5,24 +5,27 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/types/index.d.ts", "bin": { "dsh-stdio-agent": "lib/bin.js" }, "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./bin": { - "types": "./lib/bin.d.ts", + "types": "./lib/types/bin.d.ts", "default": "./lib/bin.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/bin.js", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/ui/stdio-agent/tests/stdio-agent.spec.ts b/packages/ui/stdio-agent/tests/stdio-agent.spec.ts index f72de0a1da..a5dc1fbf90 100644 --- a/packages/ui/stdio-agent/tests/stdio-agent.spec.ts +++ b/packages/ui/stdio-agent/tests/stdio-agent.spec.ts @@ -2,7 +2,7 @@ import { describe, it, expect } from 'vitest' import { Context } from 'cordis' import Loader from '@cordisjs/plugin-loader' import { AgentId } from '@deepseek-ai/dsh-agent' -import * as stdioAgent from '../src/index.ts' +import * as stdioAgent from '../src/index' /** * Unit coverage for the @deepseek-ai/dsh-stdio-agent app plugin: mounting it diff --git a/packages/ui/stdio-agent/tsconfig.json b/packages/ui/stdio-agent/tsconfig.json index 2130a6162c..58b492a549 100644 --- a/packages/ui/stdio-agent/tsconfig.json +++ b/packages/ui/stdio-agent/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/types" }, "include": [ "src" diff --git a/packages/ui/stdio-agent/tsdown.config.ts b/packages/ui/stdio-agent/tsdown.config.ts index 62dc986c08..53797cdd79 100644 --- a/packages/ui/stdio-agent/tsdown.config.ts +++ b/packages/ui/stdio-agent/tsdown.config.ts @@ -3,11 +3,12 @@ import { defineConfig } from 'tsdown' /** * stdio-agent ships TWO entries: the plugin (`index`) and the CLI `bin` * (`bin`), the latter referenced by package.json `bin`/`exports["./bin"]`. - * The root tsdown builds only `src/index.ts`, so this override adds `bin.ts`. - * Declarations come from `tsc -b` (dts: false), matching every package. + * The root tsdown builds only `lib/types/index.js`, so this override adds + * `lib/types/bin.js`. Declarations come from `tsc -b` (dts: false), + * matching every package. */ export default defineConfig({ - entry: ['src/index.ts', 'src/bin.ts'], + entry: ['lib/types/index.js', 'lib/types/bin.js'], outDir: 'lib', format: ['esm'], platform: 'node', diff --git a/packages/util/brand/package.json b/packages/util/brand/package.json index f0dcf7a8d7..8059952170 100644 --- a/packages/util/brand/package.json +++ b/packages/util/brand/package.json @@ -5,17 +5,19 @@ "private": true, "type": "module", "main": "lib/index.js", - "types": "lib/index.d.ts", + "types": "lib/types/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", + "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, "./src/*": "./src/*", "./package.json": "./package.json" }, "files": [ - "lib", + "lib/index.js", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", "src" ], "license": "BSD-3-Clause", diff --git a/packages/util/brand/tsconfig.json b/packages/util/brand/tsconfig.json index f8fc535ab7..749cb0208e 100644 --- a/packages/util/brand/tsconfig.json +++ b/packages/util/brand/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "lib" + "outDir": "lib/types" }, "include": [ "src" diff --git a/tsconfig.json b/tsconfig.json index d3adb723af..a4c1a8245c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,23 +20,27 @@ { "path": "./vendor/timer" }, { "path": "./vendor/hmr" }, { "path": "./vendor/logger-console" }, - { "path": "./packages/llm" }, - { "path": "./packages/session" }, - { "path": "./packages/session-persistence" }, - { "path": "./packages/session-persistence-jsonl" }, - { "path": "./packages/session-persistence-sqlite" }, - { "path": "./packages/system-prompt" }, - { "path": "./packages/agent" }, - { "path": "./packages/tools" }, - { "path": "./packages/agent-loop" }, - { "path": "./packages/bash" }, - { "path": "./packages/llm-deepseek" }, - { "path": "./packages/llm-pi-ai" }, - { "path": "./packages/bash-local" }, - { "path": "./packages/tool-bash" }, - { "path": "./packages/invariants" }, - { "path": "./packages/acp" }, - { "path": "./packages/ui-stdio" }, - { "path": "./packages/llm-replay" } + { "path": "./packages/util/brand" }, + { "path": "./packages/llm/llm" }, + { "path": "./packages/core/session" }, + { "path": "./packages/session-persistence/session-persistence" }, + { "path": "./packages/session-persistence/session-persistence-jsonl" }, + { "path": "./packages/session-persistence/session-persistence-sqlite" }, + { "path": "./packages/core/system-prompt" }, + { "path": "./packages/core/agent" }, + { "path": "./packages/core/tools" }, + { "path": "./packages/core/agent-loop" }, + { "path": "./packages/core/agent-core" }, + { "path": "./packages/bash/bash" }, + { "path": "./packages/llm/llm-deepseek" }, + { "path": "./packages/llm/llm-pi-ai" }, + { "path": "./packages/bash/bash-local" }, + { "path": "./packages/bash/tool-bash" }, + { "path": "./packages/support/invariants" }, + { "path": "./packages/ui/acp" }, + { "path": "./packages/ui/acp-agent" }, + { "path": "./packages/ui/stdio-agent" }, + { "path": "./packages/support/ui-stdio" }, + { "path": "./packages/support/llm-replay" } ] } From 732e121ff6c7ac63ec23ab6149a9d9b1312bf017 Mon Sep 17 00:00:00 2001 From: imccyu Date: Mon, 22 Jun 2026 01:01:08 +0800 Subject: [PATCH 15/21] fix: make constraints, lint and md-links happy --- docs/cookbook/adding-a-package.md | 2 +- docs/rfc/README.md | 2 +- .../2026-06-17-ts-build-config.md | 0 eslint.config.mjs | 2 +- scripts/check-workspace-constraints.ts | 26 +++++++++++++++---- 5 files changed, 24 insertions(+), 8 deletions(-) rename docs/rfc/implemented/{ => process}/2026-06-17-ts-build-config.md (100%) diff --git a/docs/cookbook/adding-a-package.md b/docs/cookbook/adding-a-package.md index b52761baf1..991db3be60 100644 --- a/docs/cookbook/adding-a-package.md +++ b/docs/cookbook/adding-a-package.md @@ -15,7 +15,7 @@ packages// README.md # service API, events, extension points, design notes ``` -package.json invariants (enforced by `pnpm run constraints` / `scripts/check-workspace-constraints.ts`): `private: true`, `version: 0.0.1`, `type: module`, `main: "lib/index.js"`, `types: "lib/types/index.d.ts"`, `exports["."].types: "./lib/types/index.d.ts"`, `exports["."].default: "./lib/index.js"`, `cordis` in BOTH peerDependencies and devDependencies (same range). Mirror every dsh peer dependency in devDependencies. `schemastery` goes in `dependencies` (it is a runtime validator), matching agent-loop. The `files` list is precise: `lib/index.js`, `lib/types/**/*.d.ts`, `lib/types/**/*.d.ts.map`, and `src`; do not publish `lib/types` JS or JS-map intermediates or stale root declaration files. +package.json invariants (enforced by `pnpm run constraints` / `scripts/check-workspace-constraints.ts`): `private: true`, `version: 0.0.1`, `type: module`, `main: "lib/index.js"`, `types: "lib/types/index.d.ts"`, `exports["."].types: "./lib/types/index.d.ts"`, `exports["."].default: "./lib/index.js"`, `cordis` in BOTH peerDependencies and devDependencies (same range). Mirror every dsh peer dependency in devDependencies. `schemastery` goes in `dependencies` (it is a runtime validator), matching agent-loop. The `files` list is precise: `lib/index.js`, `lib/types/**/*.d.ts`, `lib/types/**/*.d.ts.map`, and `src`; do not publish `lib/types` JS or JS-map intermediates or stale root declaration files. CLI app packages with a package `bin` include `lib/bin.js` immediately after `lib/index.js` in `files`. ## 2. Register it in the root configs diff --git a/docs/rfc/README.md b/docs/rfc/README.md index 08a5dae8f6..f46cb3495f 100644 --- a/docs/rfc/README.md +++ b/docs/rfc/README.md @@ -125,7 +125,7 @@ Do NOT write one for a mechanical or local choice (a variable name, a one-file r | [tsdown for JS bundling instead of dumble](implemented/process/2026-06-11-tsdown-over-dumble.md) | 2026-06-11 | | [Doc-sync enforcement](implemented/process/2026-06-11-doc-sync-enforcement.md) | 2026-06-11 | | [pnpm as the package manager instead of Yarn 4](implemented/process/2026-06-16-pnpm-over-yarn.md) | 2026-06-16 | -| [TSC-first build and one tsconfig](implemented/2026-06-17-ts-build-config.md) | 2026-06-17 | +| [TSC-first build and one tsconfig](implemented/process/2026-06-17-ts-build-config.md) | 2026-06-17 | | [Markdown cross-link validity linting](implemented/process/2026-06-18-markdown-cross-link-lint.md) | 2026-06-18 | | [Core-data-structures catalog and the `ts type-equiv` drift gate](implemented/process/2026-06-20-core-data-structures-catalog.md) | 2026-06-20 | | [Generated cordis events + services catalog](implemented/process/2026-06-20-generated-cordis-catalog.md) | 2026-06-20 | diff --git a/docs/rfc/implemented/2026-06-17-ts-build-config.md b/docs/rfc/implemented/process/2026-06-17-ts-build-config.md similarity index 100% rename from docs/rfc/implemented/2026-06-17-ts-build-config.md rename to docs/rfc/implemented/process/2026-06-17-ts-build-config.md diff --git a/eslint.config.mjs b/eslint.config.mjs index df7570c89e..52236e5d64 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -36,7 +36,7 @@ export default tseslint.config( ], languageOptions: { parserOptions: { - project: ['./packages/*/tsconfig.json', './tsconfig.json'], + project: ['./packages/*/*/tsconfig.json', './tsconfig.json'], tsconfigRootDir: import.meta.dirname, }, }, diff --git a/scripts/check-workspace-constraints.ts b/scripts/check-workspace-constraints.ts index 940de45f81..a669a8572d 100644 --- a/scripts/check-workspace-constraints.ts +++ b/scripts/check-workspace-constraints.ts @@ -35,12 +35,15 @@ interface PackageManifest { type?: string main?: string types?: string - exports?: { - '.'?: { + bin?: string | Record + exports?: Record< + string, + | { types?: string default?: string } - } + | undefined + > files?: string[] peerDependencies?: Record devDependencies?: Record @@ -89,10 +92,22 @@ const dshPackageFiles = [ 'src', ] as const +const dshBinPackageFiles = [ + 'lib/index.js', + 'lib/bin.js', + 'lib/types/**/*.d.ts', + 'lib/types/**/*.d.ts.map', + 'src', +] as const + function sameStringList(actual: readonly string[] | undefined, expected: readonly string[]): boolean { return !!actual && actual.length === expected.length && actual.every((value, index) => value === expected[index]) } +function expectedDshPackageFiles(manifest: PackageManifest): readonly string[] { + return manifest.bin ? dshBinPackageFiles : dshPackageFiles +} + function checkWorkspace({ dir, manifest }: WorkspaceManifest): string[] { const errors: string[] = [] const label = manifest.name ?? dir @@ -132,8 +147,9 @@ function checkWorkspace({ dir, manifest }: WorkspaceManifest): string[] { if (manifest.exports?.['.']?.default !== './lib/index.js') { errors.push(`${label}: package.json exports["."].default must be "./lib/index.js"`) } - if (!sameStringList(manifest.files, dshPackageFiles)) { - errors.push(`${label}: package.json files must be ${JSON.stringify(dshPackageFiles)}`) + const expectedFiles = expectedDshPackageFiles(manifest) + if (!sameStringList(manifest.files, expectedFiles)) { + errors.push(`${label}: package.json files must be ${JSON.stringify(expectedFiles)}`) } } From 94e7355449b96f2858f0c788cd2dd11ff57b1a5e Mon Sep 17 00:00:00 2001 From: imccyu Date: Mon, 22 Jun 2026 01:24:36 +0800 Subject: [PATCH 16/21] docs: update packages hierarchy to current rfc --- .../rfc/implemented/process/2026-06-17-ts-build-config.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/rfc/implemented/process/2026-06-17-ts-build-config.md b/docs/rfc/implemented/process/2026-06-17-ts-build-config.md index 6c5a11156f..f0a52d8d6a 100644 --- a/docs/rfc/implemented/process/2026-06-17-ts-build-config.md +++ b/docs/rfc/implemented/process/2026-06-17-ts-build-config.md @@ -8,7 +8,7 @@ Status: implemented (accepted 2026-06-20) The current TypeScript build and typecheck setup had these issues: -- `build` used `tsc` to transform `.ts` to `.d.ts` files for `packages/*` and `vendor/*`, and then used `tsdown` to transform `.ts` to bundled `.js` files. This made two tools do TypeScript transform. +- `build` used `tsc` to transform `.ts` to `.d.ts` files for packages under `packages//` and `vendor/*`, and then used `tsdown` to transform `.ts` to bundled `.js` files. This made two tools do TypeScript transform. - `typecheck` tended to validate packages, vendor source, examples, tests, and scripts through one root typecheck config. The goal is to make build and typecheck use matching tsconfig boundaries and TypeScript resolution/transform behavior. Build should generate `.js`, `.d.ts`, `.js.map`, and `.d.ts.map` through one compiler and config, so publish output and type validation stay consistent. @@ -21,7 +21,7 @@ Validation found several concrete technical issues and possible routes: - Bundled `.js` emitted by `tsdown` is not the same behavior as per-file `.js` emitted by `tsc -b`, such as decorator transform behavior. - `vendor/*/src`, examples, tests, and scripts cannot all be plain-included in one root strict program. - Directly typechecking `vendor/*/src` under the root strict config triggers many type errors outside this project's ownership. - - `package/*` dependencies on `vendor` are resolved to the `vendor/*/lib` for different tsconfig strictness. + - Package dependencies under `packages/*/*` on `vendor` are resolved to the `vendor/*/lib` for different tsconfig strictness. ## Decision @@ -38,7 +38,7 @@ In-package relative imports are extensionless. `pnpm run typecheck` runs build mode over the root `tsconfig.json`. - The root `tsconfig.json` is the single development/typecheck project. It typechecks examples, tests, and scripts with `noEmit`, and validates package/vendor source through references. -- Referenced package/vendor projects keep the same emit behavior as build, so typecheck can refresh their `lib/types` outputs instead of using a separate no-emit graph. Project-specific strictness changes live in the owning `packages/*/tsconfig.json` or `vendor/*/tsconfig.json`. +- Referenced package/vendor projects keep the same emit behavior as build, so typecheck can refresh their `lib/types` outputs instead of using a separate no-emit graph. Project-specific strictness changes live in the owning `packages/*/*/tsconfig.json` or `vendor/*/tsconfig.json`. The command orchestration shape is: @@ -57,7 +57,7 @@ tsc -b tsconfig.json Build responsibilities are clearer: -- Each module under `packages/*` and `vendor/*` has one local tsconfig for build, typecheck, and tools that run source directly, such as `tsx` and `vitest`. +- Each module under `packages//` and `vendor/*` has one local tsconfig for build, typecheck, and tools that run source directly, such as `tsx` and `vitest`. - The `build` command uses `tsconfig.build.json`. `tsc -b` owns the publishable per-module `.js` and `.d.ts` output, and the bundler owns only `lib/index.*`. - `lib/types/*.d.ts` and `.d.ts.map` are the publish declaration output. - `lib/types/*.js` is only a bundler input and must not be used as a runtime entry or public import target. From 07f4047ff0d0d5e8f4eb24b0747e1a92b578b424 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Mon, 22 Jun 2026 06:11:00 +0800 Subject: [PATCH 17/21] Use explicit ts specifiers for declarations Restore explicit .ts relative specifiers in source and enable rewriteRelativeImportExtensions so emitted JS uses .js while declarations keep explicit .ts specifiers. Add a NodeNext declaration-consumer gate to prevent extensionless declaration regressions. --- .github/workflows/ci.yml | 7 +- AGENTS.md | 6 +- docs/cookbook/adding-a-package.md | 2 + docs/cookbook/adding-a-vendored-package.md | 2 + docs/development.md | 5 +- .../process/2026-06-11-quality-gates.md | 2 +- .../process/2026-06-17-ts-build-config.md | 9 +- package.json | 3 +- packages/README.md | 2 +- packages/bash/bash-local/src/index.ts | 8 +- packages/bash/bash/src/index.ts | 6 +- packages/core/agent-loop/src/agent.ts | 4 +- packages/core/agent-loop/src/index.ts | 8 +- packages/core/agent-loop/src/loop.ts | 2 +- packages/core/agent/src/index.ts | 4 +- packages/core/session/src/index.ts | 12 +- packages/core/session/src/repair.ts | 2 +- packages/core/tools/src/index.ts | 2 +- packages/core/tools/src/schema.ts | 2 +- packages/llm/llm-deepseek/src/adapter.ts | 10 +- packages/llm/llm-deepseek/src/index.ts | 16 +- packages/llm/llm-deepseek/src/serialize.ts | 2 +- packages/llm/llm-deepseek/src/translate.ts | 4 +- packages/llm/llm-pi-ai/src/adapter.ts | 2 +- packages/llm/llm-pi-ai/src/index.ts | 10 +- packages/llm/llm/src/assembler.ts | 6 +- packages/llm/llm/src/index.ts | 14 +- packages/llm/llm/src/types.ts | 2 +- .../session-persistence-jsonl/src/index.ts | 2 +- .../session-persistence-sqlite/src/index.ts | 4 +- .../session-persistence/src/coordinator.ts | 2 +- .../session-persistence/src/index.ts | 4 +- packages/ui/acp/src/index.ts | 2 +- scripts/verify-node-next-types.ts | 160 ++++++++++++++++++ tsconfig.base.json | 2 + vendor/README.md | 2 +- vendor/cordis/src/context.ts | 12 +- vendor/cordis/src/events.ts | 8 +- vendor/cordis/src/fiber.ts | 10 +- vendor/cordis/src/index.ts | 14 +- vendor/cordis/src/logger.ts | 8 +- vendor/cordis/src/reflect.ts | 8 +- vendor/cordis/src/registry.ts | 8 +- vendor/cordis/src/service.ts | 4 +- vendor/cordis/src/utils.ts | 2 +- vendor/cosmokit/src/array.ts | 2 +- vendor/cosmokit/src/index.ts | 10 +- vendor/cosmokit/src/types.ts | 2 +- vendor/hmr/src/index.ts | 2 +- vendor/loader/src/config/entry.ts | 8 +- vendor/loader/src/config/group.ts | 4 +- vendor/loader/src/config/isolate.ts | 4 +- vendor/loader/src/config/tree.ts | 4 +- vendor/loader/src/index.ts | 20 +-- vendor/logger-console/src/browser.ts | 4 +- vendor/logger-console/src/index.ts | 4 +- 56 files changed, 323 insertions(+), 147 deletions(-) create mode 100644 scripts/verify-node-next-types.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47ca887219..f164e3c4c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,12 +69,13 @@ jobs: run: pnpm run test:snapshot # Before hygiene: publint validates the packed artifacts (lib/index.js), - # which only the tsdown bundling step emits. + # which only the tsdown bundling step emits, and verify-node-next-types + # validates the built declarations. - name: Build (tsc -b + tsdown bundles) run: pnpm run build - - name: Hygiene (knip + publint) - run: pnpm run knip && pnpm run publint + - name: Hygiene (knip + publint + constraints + NodeNext types) + run: pnpm run hygiene - name: Demo smoke test run: | diff --git a/AGENTS.md b/AGENTS.md index 2b38f32360..d7340c631d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -145,7 +145,7 @@ pnpm run lint:fix # eslint . --fix pnpm run build # tsc emits lib/types, then tsdown bundles runtime lib/index.* pnpm run knip # dead-code / unused-dependency check pnpm run publint # package.json publish-correctness check (every packages/*/* package) -pnpm run hygiene # knip + publint + workspace constraints +pnpm run hygiene # knip + publint + workspace constraints + NodeNext type-consumer check pnpm run doc-typecheck # typecheck every ```ts block in README.md, docs/**/*.md, # packages/*/*.md + packages/*/*/*.md (doc/code drift gate) pnpm run gen-cordis-catalog # regenerate docs/cordis-catalog/events-and-services.md @@ -160,6 +160,8 @@ pnpm run verify-package-paths # assert every packages/ cited in Markdown pnpm run verify-rfc-classification # assert every RFC lives in a valid # {lifecycle}/{class}/ folder and docs/rfc/README.md lists it # under the matching heading (closed class set + index completeness) +pnpm run verify-node-next-types # assert built declarations typecheck for a + # standard external NodeNext ESM TypeScript consumer pnpm run doc-sync # doc-typecheck + verify-cordis-catalog + verify-md-wrap + verify-md-links + verify-doc-refs + verify-package-paths + verify-rfc-classification + verify-type-equiv (CI runs this) pnpm run demo:echo # run examples/echo-agent (no API key; type "echo hi" to # see a tool call) — the mock skeleton @@ -188,7 +190,7 @@ Dev/test/demo run **unbuilt** via tsx + the source `paths` map in the root `tsco ## Conventions - **Package naming**: every npm package in this repo is `@deepseek-ai/dsh-` (vendored packages keep their upstream names and are `private: true`). -- **ESM everywhere** (`"type": "module"`); imports between workspace packages use package names, never relative paths across package boundaries. In-package relative imports are extensionless so generated `.d.ts` files stay extensionless; `lib/types/**/*.js` is a bundler-only intermediate, not a Node ESM entrypoint. +- **ESM everywhere** (`"type": "module"`); imports between workspace packages use package names, never relative paths across package boundaries. In-package relative imports use explicit `.ts` extensions; `rewriteRelativeImportExtensions` turns those into `.js` in emitted JS, while declarations keep explicit `.ts` specifiers that NodeNext/Node16 TypeScript consumers can resolve to sibling `.d.ts` files. `lib/types/**/*.js` is a bundler-only intermediate, not a Node ESM entrypoint. - **`cordis` is a peerDependency** (+ devDependency) of every harness package, mirroring upstream convention. - **Registrations are effects**: anything a plugin contributes (adapter, tool, section, agent, event listener) goes through `ctx.effect()` / `ctx.on()` so disposal and HMR work. If you write a registry, `register()` must return the disposer. - **Typed events via declaration merging**: services declare their events in `declare module 'cordis' { interface Events { … } }`, and their ctx key in `interface Context`. Extensible unions use the merge-extensible-map pattern (see `ContentBlockMap`, `MessageSourceMap`). diff --git a/docs/cookbook/adding-a-package.md b/docs/cookbook/adding-a-package.md index 991db3be60..593a0a93ba 100644 --- a/docs/cookbook/adding-a-package.md +++ b/docs/cookbook/adding-a-package.md @@ -17,6 +17,8 @@ packages// package.json invariants (enforced by `pnpm run constraints` / `scripts/check-workspace-constraints.ts`): `private: true`, `version: 0.0.1`, `type: module`, `main: "lib/index.js"`, `types: "lib/types/index.d.ts"`, `exports["."].types: "./lib/types/index.d.ts"`, `exports["."].default: "./lib/index.js"`, `cordis` in BOTH peerDependencies and devDependencies (same range). Mirror every dsh peer dependency in devDependencies. `schemastery` goes in `dependencies` (it is a runtime validator), matching agent-loop. The `files` list is precise: `lib/index.js`, `lib/types/**/*.d.ts`, `lib/types/**/*.d.ts.map`, and `src`; do not publish `lib/types` JS or JS-map intermediates or stale root declaration files. CLI app packages with a package `bin` include `lib/bin.js` immediately after `lib/index.js` in `files`. +In-package relative imports use explicit `.ts` specifiers in source (for example, `export * from './types.ts'`). The compiler rewrites those to `.js` in emitted JS and leaves explicit `.ts` specifiers in declarations, which standard NodeNext/Node16 TypeScript consumers resolve to the sibling `.d.ts` files. + ## 2. Register it in the root configs | File | Change | diff --git a/docs/cookbook/adding-a-vendored-package.md b/docs/cookbook/adding-a-vendored-package.md index 4f411c6f04..59df2f617b 100644 --- a/docs/cookbook/adding-a-vendored-package.md +++ b/docs/cookbook/adding-a-vendored-package.md @@ -29,6 +29,8 @@ vendor// `package.json` invariants: `"private": true` (vendored packages are never published), keep upstream's `name`/`version`/`exports`/`type`, point declaration metadata at `lib/types`, publish `.d.ts` and `.d.ts.map` declaration outputs, and list its cordis deps in `peerDependencies` (matching the upstream manifest). Transitive upstream deps must themselves be vendored or already present — vendoring one package often means vendoring its dependency tree (e.g. `@cordisjs/plugin-http` pulls `@cordisjs/fetch-file`). +Local relative imports/exports in vendored TypeScript source use explicit `.ts` specifiers after copying. This is a repo-local build-shape divergence from upstream: `rewriteRelativeImportExtensions` emits `.js` runtime imports while declarations keep explicit `.ts` specifiers that NodeNext/Node16 TypeScript consumers can resolve. + ## 2. Register it in the root configs | File | Change | diff --git a/docs/development.md b/docs/development.md index 5e4bf5d1e9..f2206d30c0 100644 --- a/docs/development.md +++ b/docs/development.md @@ -39,7 +39,7 @@ If you are preparing to push from a fresh clone or worktree, also build once: pnpm run build ``` -`pnpm run hygiene` includes `publint`, which validates package entrypoints against the built `lib/*.js` files. A fresh worktree has no bundled JS until `pnpm run build` runs. +`pnpm run hygiene` includes `publint`, which validates package entrypoints against the built `lib/*.js` files, and `verify-node-next-types`, which validates built declarations against a temporary NodeNext consumer. A fresh worktree has no bundled JS or declarations until `pnpm run build` runs. ## Environment variables @@ -101,7 +101,8 @@ pnpm run doc-sync # doc-typecheck, cordis-catalog freshness, markdown wrap pnpm run gen-module-graph # regenerate docs/module-graph.md from package peerDeps pnpm run verify-module-graph # fail if docs/module-graph.md is stale pnpm run build # emit lib/types intermediates, then bundle lib/index.* runtime files -pnpm run hygiene # knip, publint, and workspace constraints +pnpm run verify-node-next-types # fail if built declarations are not NodeNext-consumable +pnpm run hygiene # knip, publint, workspace constraints, and NodeNext declaration check ``` When changing package public behavior, update the relevant README or JSDoc in the same change. `pnpm run doc-sync` catches checked TypeScript snippets, cordis events/services catalog drift, and hard-wrapped markdown prose, but broader prose/API sync still needs review. diff --git a/docs/rfc/implemented/process/2026-06-11-quality-gates.md b/docs/rfc/implemented/process/2026-06-11-quality-gates.md index 3b41613b1a..277a56fa2b 100644 --- a/docs/rfc/implemented/process/2026-06-11-quality-gates.md +++ b/docs/rfc/implemented/process/2026-06-11-quality-gates.md @@ -15,7 +15,7 @@ Every AGENTS.md promise gets a command that exits non-zero, wired into git hooks - Max-strict TypeScript (`noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`, …); examples, tests, and scripts typecheck in CI via the root no-emit `tsconfig.json` while package/vendor code stays behind its own project-reference boundary. - ESLint strict-type-checked + @stylistic (the house style, enforced); vendored code excluded. - Per-file 100% coverage on `packages/*/src` (v8); unreachable defensive guards carry `/* v8 ignore */ ` with stated reasons instead of deletion. -- knip (dead code/deps), publint (package correctness), workspace constraints (workspace rules: private, cordis peer+dev, uniform version, ESM). +- knip (dead code/deps), publint (package correctness), workspace constraints (workspace rules: private, cordis peer+dev, uniform version, ESM), and a NodeNext consumer typecheck for built package declarations. - lefthook pre-commit (lint staged, typecheck, vendor-manifest guard) and pre-push (tests, hygiene); CI runs the full matrix on node 24/26 plus a demo smoke test driving the echo-agent end to end. ## Consequences diff --git a/docs/rfc/implemented/process/2026-06-17-ts-build-config.md b/docs/rfc/implemented/process/2026-06-17-ts-build-config.md index f0a52d8d6a..fdcc85aa38 100644 --- a/docs/rfc/implemented/process/2026-06-17-ts-build-config.md +++ b/docs/rfc/implemented/process/2026-06-17-ts-build-config.md @@ -17,7 +17,7 @@ Validation found several concrete technical issues and possible routes: - `tsdown` uses `oxc` to transform TypeScript, which is not the same behavior as `tsc`. - Bundled `.d.ts` emitted by `tsdown` conflicts with Cordis' internal relative module augmentation shape. - - The tsc output is affected by `allowImportingTsExtensions`, so we need to ensure that generated `.js` files do not import `.ts` files and generated `.d.ts` files do not import `.js` files. Therefore, we need to adjust the import specifiers to extensionless in the TypeScript source. + - The tsc output is affected by `allowImportingTsExtensions`, so we need to ensure that generated `.js` files do not import `.ts` files and generated `.d.ts` files do not contain extensionless relative imports. Therefore, in-package relative imports use explicit `.ts` specifiers in TypeScript source and `rewriteRelativeImportExtensions` rewrites those specifiers to `.js` in emitted JS. - Bundled `.js` emitted by `tsdown` is not the same behavior as per-file `.js` emitted by `tsc -b`, such as decorator transform behavior. - `vendor/*/src`, examples, tests, and scripts cannot all be plain-included in one root strict program. - Directly typechecking `vendor/*/src` under the root strict config triggers many type errors outside this project's ownership. @@ -26,7 +26,7 @@ Validation found several concrete technical issues and possible routes: ## Decision -In-package relative imports are extensionless. +In-package relative imports use explicit `.ts` specifiers. `pnpm run build` is a two-stage build: @@ -47,6 +47,9 @@ pnpm run build: tsc -b tsconfig.build.json tsdown +pnpm run verify-node-next-types: +tsx scripts/verify-node-next-types.ts + pnpm run typecheck: tsc -b tsconfig.json ``` @@ -60,8 +63,10 @@ Build responsibilities are clearer: - Each module under `packages//` and `vendor/*` has one local tsconfig for build, typecheck, and tools that run source directly, such as `tsx` and `vitest`. - The `build` command uses `tsconfig.build.json`. `tsc -b` owns the publishable per-module `.js` and `.d.ts` output, and the bundler owns only `lib/index.*`. - `lib/types/*.d.ts` and `.d.ts.map` are the publish declaration output. + - `lib/types/*.d.ts` uses explicit `.ts` relative specifiers, which TypeScript's NodeNext/Node16 resolver maps to sibling `.d.ts` files. - `lib/types/*.js` is only a bundler input and must not be used as a runtime entry or public import target. - `lib/index.*` is the publish runtime output and is generated by the bundler, currently `tsdown`. +- `pnpm run verify-node-next-types` scans built declarations for extensionless relative specifiers, then typechecks a temporary external ESM consumer with `moduleResolution: "NodeNext"` against the built `types`/`exports` surface, so declaration specifier regressions fail before publish. - The `typecheck` command uses `tsconfig.json`. Examples, tests, and scripts are checked by the root no-emit project, while packages and vendor modules keep the same emit behavior as `build`. Package and vendor source stays behind project-reference boundaries. The Cordis vendor copy now has one more type-structure divergence from upstream. During upstream sync, that divergence must be reapplied or explicitly retired. diff --git a/package.json b/package.json index 1e6155ff94..2e83cdca61 100644 --- a/package.json +++ b/package.json @@ -31,13 +31,14 @@ "verify-package-paths": "tsx scripts/verify-package-paths.ts", "verify-rfc-classification": "tsx scripts/verify-rfc-classification.ts", "verify-type-equiv": "tsx scripts/verify-type-equiv.ts", + "verify-node-next-types": "tsx scripts/verify-node-next-types.ts", "gen-cordis-catalog": "tsx scripts/gen-cordis-catalog.ts", "verify-cordis-catalog": "tsx scripts/gen-cordis-catalog.ts --check", "gen-module-graph": "tsx scripts/gen-module-graph.ts", "verify-module-graph": "tsx scripts/gen-module-graph.ts --check", "constraints": "tsx scripts/check-workspace-constraints.ts", "doc-sync": "pnpm run doc-typecheck && pnpm run verify-cordis-catalog && pnpm run verify-md-wrap && pnpm run verify-md-links && pnpm run verify-doc-refs && pnpm run verify-package-paths && pnpm run verify-rfc-classification && pnpm run verify-type-equiv", - "hygiene": "pnpm run knip && pnpm run publint && pnpm run constraints", + "hygiene": "pnpm run knip && pnpm run publint && pnpm run constraints && pnpm run verify-node-next-types", "demo:echo": "node --expose-internals --import tsx packages/ui/stdio-agent/src/bin.ts examples/echo-agent/cordis.yml", "demo:coding": "node --expose-internals --import tsx packages/ui/stdio-agent/src/bin.ts examples/coding-agent/cordis.yml", "demo:acp": "node --import tsx packages/ui/acp-agent/src/bin.ts examples/acp-agent/cordis.yml", diff --git a/packages/README.md b/packages/README.md index 976c9f7ac7..1fcc0c44d0 100644 --- a/packages/README.md +++ b/packages/README.md @@ -79,5 +79,5 @@ Each package has its own `README.md` with purpose, service API, events, extensio - **Declaration merging for events and ctx**: services declare their events in `declare module 'cordis' { interface Events { ... } }` and their ctx key in `interface Context`. - **Waterfall semantics**: `ctx.waterfall` listeners receive `(...args, next)` and MUST call `next()` to delegate; returning without it short-circuits (the veto mechanism). - **Extensible unions**: `ContentBlockMap`, `MessageSourceMap`, `FinishReasonMap`, `TurnTriggerMap`, `TurnEndReasonMap`, and `SessionEventMap` use the merge-extensible-map pattern so plugins can add variants via declaration merging. -- **ESM everywhere**; imports use package names across package boundaries and extensionless relative specifiers within a package. +- **ESM everywhere**; imports use package names across package boundaries and explicit `.ts` relative specifiers within a package. - **Tests**: vitest, colocated under `packages///tests/*.spec.ts`. Every registry needs an HMR-safety test. Err on the side of more tests. diff --git a/packages/bash/bash-local/src/index.ts b/packages/bash/bash-local/src/index.ts index b2d117324b..05f1ed75dd 100644 --- a/packages/bash/bash-local/src/index.ts +++ b/packages/bash/bash-local/src/index.ts @@ -17,11 +17,11 @@ import { Context } from 'cordis' import z from 'schemastery' import { BashExecutor, BashTaskId } from '@deepseek-ai/dsh-bash' import type { BashExecRequest, BashExecSpec, BashRunResult, BashTask, BashTaskRead, OwnerToken } from '@deepseek-ai/dsh-bash' -import { runBash } from './run' -import type { RunInternals, RunningBash } from './run' +import { runBash } from './run.ts' +import type { RunInternals, RunningBash } from './run.ts' -export { DEFAULT_GRACE_MS, ENV_OVERRIDES, killGroup, OutputCollector, runBash } from './run' -export type { RunInternals, RunningBash, SpawnOutcome, SpawnSpec } from './run' +export { DEFAULT_GRACE_MS, ENV_OVERRIDES, killGroup, OutputCollector, runBash } from './run.ts' +export type { RunInternals, RunningBash, SpawnOutcome, SpawnSpec } from './run.ts' /** Plugin config (all optional — `static Config` supplies the defaults). */ export interface Config { diff --git a/packages/bash/bash/src/index.ts b/packages/bash/bash/src/index.ts index b8d7c619e1..01c5c081c3 100644 --- a/packages/bash/bash/src/index.ts +++ b/packages/bash/bash/src/index.ts @@ -15,9 +15,9 @@ */ import { Context, Service } from 'cordis' -import type { BashExecRequest, BashExecSpec, BashRunResult, BashTask, BashTaskId, BashTaskListener, BashTaskRead, OwnerToken } from './types' +import type { BashExecRequest, BashExecSpec, BashRunResult, BashTask, BashTaskId, BashTaskListener, BashTaskRead, OwnerToken } from './types.ts' -export { BashTaskId, OwnerToken } from './types' +export { BashTaskId, OwnerToken } from './types.ts' export type { BashExecRequest, BashExecSpec, @@ -27,7 +27,7 @@ export type { BashTaskRead, BashTaskStatus, CollectedOutput, -} from './types' +} from './types.ts' declare module 'cordis' { interface Context { diff --git a/packages/core/agent-loop/src/agent.ts b/packages/core/agent-loop/src/agent.ts index c6188c9a7e..402a9a8416 100644 --- a/packages/core/agent-loop/src/agent.ts +++ b/packages/core/agent-loop/src/agent.ts @@ -11,8 +11,8 @@ import type { AgentId, AgentOptions, AgentStatus, SendOptions } from '@deepseek- import type { Agent } from '@deepseek-ai/dsh-agent' import type { ContentBlock, MessageSource } from '@deepseek-ai/dsh-llm' import type { Session } from '@deepseek-ai/dsh-session' -import { Inbox } from './inbox' -import { isTurnOpen, lastTurnNumber, runLoop } from './loop' +import { Inbox } from './inbox.ts' +import { isTurnOpen, lastTurnNumber, runLoop } from './loop.ts' /** * The concrete {@link Agent} implementation owned by the agent-loop plugin. diff --git a/packages/core/agent-loop/src/index.ts b/packages/core/agent-loop/src/index.ts index 86fe091b85..90d641eeeb 100644 --- a/packages/core/agent-loop/src/index.ts +++ b/packages/core/agent-loop/src/index.ts @@ -17,11 +17,11 @@ import type { Session } from '@deepseek-ai/dsh-session' import type {} from '@deepseek-ai/dsh-system-prompt' import type {} from '@deepseek-ai/dsh-tools' import type { SessionPersistence } from '@deepseek-ai/dsh-session-persistence' -import { ReactLoopAgent } from './agent' +import { ReactLoopAgent } from './agent.ts' -export { ReactLoopAgent } from './agent' -export { Inbox, type InboxMessage } from './inbox' -export { runLoop } from './loop' +export { ReactLoopAgent } from './agent.ts' +export { Inbox, type InboxMessage } from './inbox.ts' +export { runLoop } from './loop.ts' declare module 'cordis' { interface Context { diff --git a/packages/core/agent-loop/src/loop.ts b/packages/core/agent-loop/src/loop.ts index 443f98d13a..8d19c464fd 100644 --- a/packages/core/agent-loop/src/loop.ts +++ b/packages/core/agent-loop/src/loop.ts @@ -13,7 +13,7 @@ import { BlockAssembler, HarnessError } from '@deepseek-ai/dsh-llm' import type { Session, TurnEndReason, TurnTrigger } from '@deepseek-ai/dsh-session' import { renderPrompt } from '@deepseek-ai/dsh-system-prompt' import type {} from '@deepseek-ai/dsh-tools' -import type { ReactLoopAgent } from './agent' +import type { ReactLoopAgent } from './agent.ts' /** An Error with an optional machine-readable code (e.g., from LlmError or a throwing plugin). */ type CodedError = Error & { code?: string } diff --git a/packages/core/agent/src/index.ts b/packages/core/agent/src/index.ts index b39d8343d7..158946178c 100644 --- a/packages/core/agent/src/index.ts +++ b/packages/core/agent/src/index.ts @@ -7,9 +7,9 @@ import { Context, Service } from 'cordis' import type { SessionId } from '@deepseek-ai/dsh-session' -import type { Agent, AgentId, AgentOptions } from './types' +import type { Agent, AgentId, AgentOptions } from './types.ts' -export * from './types' +export * from './types.ts' declare module 'cordis' { interface Context { diff --git a/packages/core/session/src/index.ts b/packages/core/session/src/index.ts index 56d8352c36..cef91c110c 100644 --- a/packages/core/session/src/index.ts +++ b/packages/core/session/src/index.ts @@ -9,13 +9,13 @@ import { Context, Service } from 'cordis' import { isAbsolute } from 'node:path' import type { ContentBlock, Message, MessageSource } from '@deepseek-ai/dsh-llm' -import { SESSION_FORMAT_VERSION, SessionId } from './types' -import type { CreateSessionOptions, SessionEvent, SessionEventMap, SessionEventType, SessionHeader } from './types' -import { isJsonValue } from './json' +import { SESSION_FORMAT_VERSION, SessionId } from './types.ts' +import type { CreateSessionOptions, SessionEvent, SessionEventMap, SessionEventType, SessionHeader } from './types.ts' +import { isJsonValue } from './json.ts' -export * from './types' -export { isJsonValue } from './json' -export { interruptedTurnClosers } from './repair' +export * from './types.ts' +export { isJsonValue } from './json.ts' +export { interruptedTurnClosers } from './repair.ts' declare module 'cordis' { interface Context { diff --git a/packages/core/session/src/repair.ts b/packages/core/session/src/repair.ts index 6215ebc2a8..5cc62b37c7 100644 --- a/packages/core/session/src/repair.ts +++ b/packages/core/session/src/repair.ts @@ -36,7 +36,7 @@ */ import type { CallId } from '@deepseek-ai/dsh-llm' -import type { SessionEvent } from './types' +import type { SessionEvent } from './types.ts' /** * Scan `events` for an open turn/step at the tail and return the synthetic diff --git a/packages/core/tools/src/index.ts b/packages/core/tools/src/index.ts index 6a70cfdd01..5a17aa2b0c 100644 --- a/packages/core/tools/src/index.ts +++ b/packages/core/tools/src/index.ts @@ -24,7 +24,7 @@ export { type InferArgs, type DefineToolOptions, type JsonSchemaObject, -} from './schema' +} from './schema.ts' declare module 'cordis' { interface Context { diff --git a/packages/core/tools/src/schema.ts b/packages/core/tools/src/schema.ts index 16b46cd5d7..b717eabf9a 100644 --- a/packages/core/tools/src/schema.ts +++ b/packages/core/tools/src/schema.ts @@ -21,7 +21,7 @@ import type { ContentBlock } from '@deepseek-ai/dsh-llm' import { assertNever, HarnessError } from '@deepseek-ai/dsh-llm' -import type { ToolCallPresentation, ToolDefinition, ToolExecution, ToolResult, ToolResultPresentation } from './index' +import type { ToolCallPresentation, ToolDefinition, ToolExecution, ToolResult, ToolResultPresentation } from './index.ts' // --------------------------------------------------------------------------- // SchemaSpec — the author-facing per-property type diff --git a/packages/llm/llm-deepseek/src/adapter.ts b/packages/llm/llm-deepseek/src/adapter.ts index f9250987f3..fda527359a 100644 --- a/packages/llm/llm-deepseek/src/adapter.ts +++ b/packages/llm/llm-deepseek/src/adapter.ts @@ -7,11 +7,11 @@ import { LlmAdapter, LlmError } from '@deepseek-ai/dsh-llm' import type { GenerateOptions, StreamChunk } from '@deepseek-ai/dsh-llm' -import { serializeRequest } from './serialize' -import type { RequestDefaults } from './serialize' -import { parseSse } from './sse' -import { translate } from './translate' -import type { WireError } from './types' +import { serializeRequest } from './serialize.ts' +import type { RequestDefaults } from './serialize.ts' +import { parseSse } from './sse.ts' +import { translate } from './translate.ts' +import type { WireError } from './types.ts' export interface DeepSeekAdapterOptions { apiKey: string diff --git a/packages/llm/llm-deepseek/src/index.ts b/packages/llm/llm-deepseek/src/index.ts index f4f7e43635..79313f910f 100644 --- a/packages/llm/llm-deepseek/src/index.ts +++ b/packages/llm/llm-deepseek/src/index.ts @@ -21,15 +21,15 @@ import type { Context } from 'cordis' import z from 'schemastery' import type {} from '@deepseek-ai/dsh-llm' -import { DeepSeekAdapter } from './adapter' +import { DeepSeekAdapter } from './adapter.ts' -export { DeepSeekAdapter, httpErrorCode } from './adapter' -export type { DeepSeekAdapterOptions } from './adapter' -export { serializeMessages, serializeRequest } from './serialize' -export type { RequestDefaults } from './serialize' -export { DONE, parseSse } from './sse' -export { mapFinishReason, mapUsage, translate } from './translate' -export type * from './types' +export { DeepSeekAdapter, httpErrorCode } from './adapter.ts' +export type { DeepSeekAdapterOptions } from './adapter.ts' +export { serializeMessages, serializeRequest } from './serialize.ts' +export type { RequestDefaults } from './serialize.ts' +export { DONE, parseSse } from './sse.ts' +export { mapFinishReason, mapUsage, translate } from './translate.ts' +export type * from './types.ts' export const name = 'llm-deepseek' export const inject = ['llm'] diff --git a/packages/llm/llm-deepseek/src/serialize.ts b/packages/llm/llm-deepseek/src/serialize.ts index 11b9028af0..4e967d6667 100644 --- a/packages/llm/llm-deepseek/src/serialize.ts +++ b/packages/llm/llm-deepseek/src/serialize.ts @@ -18,7 +18,7 @@ import { LlmError } from '@deepseek-ai/dsh-llm' import type { ContentBlock, GenerateOptions, Message } from '@deepseek-ai/dsh-llm' -import type { WireMessage, WireRequest, WireTool } from './types' +import type { WireMessage, WireRequest, WireTool } from './types.ts' /** Adapter-level request defaults (from plugin config). */ export interface RequestDefaults { diff --git a/packages/llm/llm-deepseek/src/translate.ts b/packages/llm/llm-deepseek/src/translate.ts index ea5e50d7c1..08cc019b61 100644 --- a/packages/llm/llm-deepseek/src/translate.ts +++ b/packages/llm/llm-deepseek/src/translate.ts @@ -16,8 +16,8 @@ import { CallId, LlmError } from '@deepseek-ai/dsh-llm' import type { ContentBlock, FinishReason, StreamChunk, TokenUsage } from '@deepseek-ai/dsh-llm' -import { DONE } from './sse' -import type { WireChunk, WireUsage } from './types' +import { DONE } from './sse.ts' +import type { WireChunk, WireUsage } from './types.ts' /** One open block under assembly. */ interface OpenBlock { diff --git a/packages/llm/llm-pi-ai/src/adapter.ts b/packages/llm/llm-pi-ai/src/adapter.ts index 0f92da4bed..e15cce8252 100644 --- a/packages/llm/llm-pi-ai/src/adapter.ts +++ b/packages/llm/llm-pi-ai/src/adapter.ts @@ -16,7 +16,7 @@ import type { Model } from '@earendil-works/pi-ai' import { LlmAdapter, LlmError } from '@deepseek-ai/dsh-llm' import { CallId } from '@deepseek-ai/dsh-llm' import type { GenerateOptions, StreamChunk, ToolSchema } from '@deepseek-ai/dsh-llm' -import { toPiContext, toStreamChunks } from './convert' +import { toPiContext, toStreamChunks } from './convert.ts' /** Reasoning levels surfaced by this adapter (DeepSeek wire: high|max). */ export type PiAiReasoning = 'off' | 'high' | 'xhigh' diff --git a/packages/llm/llm-pi-ai/src/index.ts b/packages/llm/llm-pi-ai/src/index.ts index d146df5824..bef0d4b3f5 100644 --- a/packages/llm/llm-pi-ai/src/index.ts +++ b/packages/llm/llm-pi-ai/src/index.ts @@ -19,12 +19,12 @@ import type { Context } from 'cordis' import z from 'schemastery' import type {} from '@deepseek-ai/dsh-llm' -import { PiAiAdapter } from './adapter' -import type { PiAiReasoning } from './adapter' +import { PiAiAdapter } from './adapter.ts' +import type { PiAiReasoning } from './adapter.ts' -export { buildModel, PiAiAdapter } from './adapter' -export type { PiAiAdapterOptions, PiAiReasoning } from './adapter' -export { mapStopReason, mapUsage, toPiContext, toStreamChunks } from './convert' +export { buildModel, PiAiAdapter } from './adapter.ts' +export type { PiAiAdapterOptions, PiAiReasoning } from './adapter.ts' +export { mapStopReason, mapUsage, toPiContext, toStreamChunks } from './convert.ts' export const name = 'llm-pi-ai' export const inject = ['llm'] diff --git a/packages/llm/llm/src/assembler.ts b/packages/llm/llm/src/assembler.ts index fd13c34ad1..328ef01c54 100644 --- a/packages/llm/llm/src/assembler.ts +++ b/packages/llm/llm/src/assembler.ts @@ -6,9 +6,9 @@ * @module @deepseek-ai/dsh-llm/assembler */ -import { CallId } from './brand' -import { assertNever } from './never' -import type { ContentBlock, FinishReason, Message, StreamChunk, TokenUsage } from './types' +import { CallId } from './brand.ts' +import { assertNever } from './never.ts' +import type { ContentBlock, FinishReason, Message, StreamChunk, TokenUsage } from './types.ts' interface PartialBlock { blockType: string diff --git a/packages/llm/llm/src/index.ts b/packages/llm/llm/src/index.ts index 2f9e51e215..320838a8a6 100644 --- a/packages/llm/llm/src/index.ts +++ b/packages/llm/llm/src/index.ts @@ -7,14 +7,14 @@ */ import { Context, Service } from 'cordis' -import type { GenerateOptions, StreamChunk } from './types' -import { HarnessError } from './error' +import type { GenerateOptions, StreamChunk } from './types.ts' +import { HarnessError } from './error.ts' -export * from './brand' -export * from './never' -export * from './error' -export * from './types' -export { BlockAssembler } from './assembler' +export * from './brand.ts' +export * from './never.ts' +export * from './error.ts' +export * from './types.ts' +export { BlockAssembler } from './assembler.ts' declare module 'cordis' { interface Context { diff --git a/packages/llm/llm/src/types.ts b/packages/llm/llm/src/types.ts index 158492d99c..63fc0f5b0c 100644 --- a/packages/llm/llm/src/types.ts +++ b/packages/llm/llm/src/types.ts @@ -19,7 +19,7 @@ * ``` */ -import type { CallId } from './brand' +import type { CallId } from './brand.ts' /** Cache hint attached to a content block (provider-interpreted). */ export type CacheHint = 'ephemeral' diff --git a/packages/session-persistence/session-persistence-jsonl/src/index.ts b/packages/session-persistence/session-persistence-jsonl/src/index.ts index 6992b4fa53..6de7eafeb3 100644 --- a/packages/session-persistence/session-persistence-jsonl/src/index.ts +++ b/packages/session-persistence/session-persistence-jsonl/src/index.ts @@ -29,7 +29,7 @@ import { import type { Session, SessionEvent, SessionId, SessionHeader } from '@deepseek-ai/dsh-session' import { encodeSegment, eventLine, logPath, parseHeaderMeta, scanLog, sessionDir, toHeaderLine, -} from './format' +} from './format.ts' export interface Config { /** diff --git a/packages/session-persistence/session-persistence-sqlite/src/index.ts b/packages/session-persistence/session-persistence-sqlite/src/index.ts index 701ab6e0bc..cef61cb071 100644 --- a/packages/session-persistence/session-persistence-sqlite/src/index.ts +++ b/packages/session-persistence/session-persistence-sqlite/src/index.ts @@ -29,9 +29,9 @@ import { import type { Session, SessionEvent, SessionId, SessionHeader } from '@deepseek-ai/dsh-session' import { openDatabase, rowToMeta, scanRows, type EventRow, type SessionRow, -} from './schema' +} from './schema.ts' -export { SCHEMA_VERSION } from './schema' +export { SCHEMA_VERSION } from './schema.ts' /** Plugin configuration. */ export interface Config { diff --git a/packages/session-persistence/session-persistence/src/coordinator.ts b/packages/session-persistence/session-persistence/src/coordinator.ts index ace8125ce2..7c7b044ee1 100644 --- a/packages/session-persistence/session-persistence/src/coordinator.ts +++ b/packages/session-persistence/session-persistence/src/coordinator.ts @@ -27,7 +27,7 @@ import { Context } from 'cordis' import { interruptedTurnClosers, SESSION_FORMAT_VERSION } from '@deepseek-ai/dsh-session' import type { Session, SessionEvent, SessionId, SessionHeader } from '@deepseek-ai/dsh-session' -import { assertSerializable, seedCoversPrefix } from './index' +import { assertSerializable, seedCoversPrefix } from './index.ts' /** * A stored session's durable prefix as read back from a backend: its diff --git a/packages/session-persistence/session-persistence/src/index.ts b/packages/session-persistence/session-persistence/src/index.ts index 239feb2825..a9ffd11792 100644 --- a/packages/session-persistence/session-persistence/src/index.ts +++ b/packages/session-persistence/session-persistence/src/index.ts @@ -29,8 +29,8 @@ import type { SessionEvent, SessionId, SessionHeader } from '@deepseek-ai/dsh-se export type { SessionHeader } from '@deepseek-ai/dsh-session' // The backend-agnostic write-path orchestration first-party backends compose. -export { PersistenceCoordinator } from './coordinator' -export type { PersistenceBackend, StoredPrefix } from './coordinator' +export { PersistenceCoordinator } from './coordinator.ts' +export type { PersistenceBackend, StoredPrefix } from './coordinator.ts' declare module 'cordis' { interface Context { diff --git a/packages/ui/acp/src/index.ts b/packages/ui/acp/src/index.ts index 159fcb8044..ec79e97443 100644 --- a/packages/ui/acp/src/index.ts +++ b/packages/ui/acp/src/index.ts @@ -74,7 +74,7 @@ import { harnessBlockToAcpContent, promptHasUnsupportedContent, turnEndToStopReason, -} from './codec' +} from './codec.ts' export const name = 'acp' // The bridge programs against the interface packages only (architecture rule: diff --git a/scripts/verify-node-next-types.ts b/scripts/verify-node-next-types.ts new file mode 100644 index 0000000000..0f2e392666 --- /dev/null +++ b/scripts/verify-node-next-types.ts @@ -0,0 +1,160 @@ +/** + * Verify that built package declarations are consumable by a standard external + * TypeScript ESM project using NodeNext resolution. + * + * Run after `pnpm run build` has emitted declaration files under package + * `lib/types` directories. + */ + +import { execFileSync } from 'node:child_process' +import { existsSync, globSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync, writeFileSync } from 'node:fs' +import { dirname, resolve } from 'node:path' + +const root = resolve(import.meta.dirname, '..') + +interface ExportTarget { + types?: string +} + +interface PackageManifest { + name?: string + types?: string + exports?: Record +} + +interface WorkspacePackage { + dir: string + name: string + manifest: PackageManifest +} + +function readPackage(path: string): WorkspacePackage | null { + const manifest = JSON.parse(readFileSync(path, 'utf8')) as PackageManifest + if (!manifest.name) return null + return { dir: dirname(path), name: manifest.name, manifest } +} + +function workspacePackages(): WorkspacePackage[] { + return [ + ...globSync('vendor/*/package.json', { cwd: root }), + ...globSync('packages/*/*/package.json', { cwd: root }), + ] + .map(path => readPackage(resolve(root, path))) + .filter(pkg => pkg !== null) + .sort((a, b) => a.name.localeCompare(b.name)) +} + +const declarationSpecifierPattern = /(?:from\s*|import\s*\(\s*|import\s+|declare\s+module\s*)["'](\.{0,2}(?:\/[^"']*)?)["']/g +const hasExtension = /\.[^/.]+$/ + +function extensionlessRelativeSpecifiers(): string[] { + const errors: string[] = [] + const files = [ + ...globSync('vendor/*/lib/types/**/*.d.ts', { cwd: root }), + ...globSync('packages/*/*/lib/types/**/*.d.ts', { cwd: root }), + ].sort() + + for (const file of files) { + const text = readFileSync(resolve(root, file), 'utf8') + for (const match of text.matchAll(declarationSpecifierPattern)) { + const specifier = match[1] + if (!specifier) continue + const isRelative = specifier === '.' || specifier.startsWith('./') || specifier.startsWith('../') + if (isRelative && !hasExtension.test(specifier)) errors.push(`${file}: ${specifier}`) + } + } + + return errors +} + +function publicSpecifiers(pkg: WorkspacePackage): string[] { + const specifiers = new Set() + if (pkg.manifest.types) specifiers.add(pkg.name) + + for (const [key, target] of Object.entries(pkg.manifest.exports ?? {})) { + if (key.includes('*') || key === './package.json') continue + if (typeof target !== 'object' || target === null || !target.types) continue + specifiers.add(key === '.' ? pkg.name : `${pkg.name}/${key.slice(2)}`) + } + + return [...specifiers].sort() +} + +function linkPackage(pkg: WorkspacePackage, nodeModules: string): void { + const parts = pkg.name.split('/') + const link = resolve(nodeModules, ...parts) + mkdirSync(dirname(link), { recursive: true }) + symlinkSync(pkg.dir, link, 'dir') +} + +const packages = workspacePackages() +const badSpecifiers = extensionlessRelativeSpecifiers() +if (badSpecifiers.length > 0) { + console.error('verify-node-next-types: declaration files still contain extensionless relative specifiers.') + console.error(badSpecifiers.join('\n')) + process.exit(1) +} + +const missingOutputs = packages + .filter(pkg => pkg.manifest.types && !existsSync(resolve(pkg.dir, pkg.manifest.types))) + .map(pkg => `${pkg.name}: missing ${pkg.manifest.types}`) + +if (missingOutputs.length > 0) { + console.error('verify-node-next-types: build outputs are missing; run `pnpm run build` first.') + console.error(missingOutputs.join('\n')) + process.exit(1) +} + +const tmp = mkdtempSync(resolve(root, '.node-next-types-')) +let failed = false + +try { + const nodeModules = resolve(tmp, 'node_modules') + mkdirSync(nodeModules, { recursive: true }) + for (const pkg of packages) linkPackage(pkg, nodeModules) + + const rootTypes = resolve(root, 'node_modules/@types/node') + if (existsSync(rootTypes)) { + const typesDir = resolve(nodeModules, '@types') + mkdirSync(typesDir, { recursive: true }) + symlinkSync(rootTypes, resolve(typesDir, 'node'), 'dir') + } + + writeFileSync(resolve(tmp, 'package.json'), `${JSON.stringify({ type: 'module', private: true }, null, 2)}\n`) + writeFileSync(resolve(tmp, 'tsconfig.json'), `${JSON.stringify({ + compilerOptions: { + target: 'es2024', + module: 'NodeNext', + moduleResolution: 'NodeNext', + strict: true, + // Third-party SDK declarations can have their own lib-check noise under a + // symlinked temp install. The explicit scan above owns our regression: + // extensionless relative specifiers in built declarations. + skipLibCheck: true, + preserveSymlinks: true, + noEmit: true, + types: ['node'], + }, + include: ['index.ts'], + }, null, 2)}\n`) + + const imports = packages.flatMap(publicSpecifiers) + .map((specifier, index) => `import * as mod${index} from ${JSON.stringify(specifier)};\nvoid mod${index};`) + .join('\n') + writeFileSync(resolve(tmp, 'index.ts'), `${imports}\n`) + + execFileSync(resolve(root, 'node_modules/.bin/tsc'), ['-p', resolve(tmp, 'tsconfig.json'), '--pretty', 'false'], { + cwd: root, + stdio: 'pipe', + }) + console.log(`verify-node-next-types: ${packages.length} workspace package declaration surface(s) compile under NodeNext.`) +} catch (error: unknown) { + failed = true + const output = error as { stdout?: Buffer; stderr?: Buffer } + console.error('verify-node-next-types: NodeNext consumer typecheck failed.\n') + console.error(`${output.stdout?.toString() ?? ''}${output.stderr?.toString() ?? ''}`) +} finally { + rmSync(tmp, { recursive: true, force: true }) +} + +if (failed) process.exit(1) diff --git a/tsconfig.base.json b/tsconfig.base.json index f84c424b6d..3d6d1fc42a 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -10,6 +10,8 @@ "incremental": true, "skipLibCheck": true, "esModuleInterop": true, + "allowImportingTsExtensions": true, + "rewriteRelativeImportExtensions": true, "verbatimModuleSyntax": false, "strict": true, "noUncheckedIndexedAccess": true, diff --git a/vendor/README.md b/vendor/README.md index dd55a9cd05..bf0f0b5a8c 100644 --- a/vendor/README.md +++ b/vendor/README.md @@ -33,7 +33,7 @@ Keep this log exhaustive — every divergence from upstream must be listed. 1. **`hmr/src/index.ts`**: removed the `./locales/en-US.yml` / `./locales/zh-CN.yml` imports, the `.i18n({...})` call on the `Config` schema, and the `src/locales/` directory. Rationale: those imports require a runtime YAML loader hook (`@cordisjs/unyaml`) that we do not vendor; the i18n texts only localize config descriptions. 2. **All `package.json` files**: regenerated — added `private: true`, added precise `files` entries for bundled runtime files and `lib/types/**/*.d.ts` / `.d.ts.map`, preserved `src` in `files` only for packages whose previous file list already shipped it, added a `./src/*` export where missing, pointed declaration metadata at `lib/types`, and removed upstream `devDependencies`/`scripts`/`repository` fields. Dependency and peer-dependency ranges preserved, except `hmr` declares `esbuild` as a direct dev dependency because its source imports the `BuildFailure` type and pnpm's strict workspace resolution requires the owner package to name that dependency. 3. **All `tsconfig.json` files**: regenerated to extend the repo-root `tsconfig.base.json`, emit TypeScript intermediates to `lib/types`, and declare project references. -4. **Vendored TypeScript source internal specifiers**: changed local relative imports/exports from explicit `.ts` / `.js` specifiers to extensionless specifiers so generated `.js` and `.d.ts` intermediates are extensionless and no declaration postprocess is needed. This includes `loader/src/config/isolate.ts` changing `declare module './entry.ts'` to `declare module './entry'`. +4. **Vendored TypeScript source internal specifiers**: changed local relative imports/exports from upstream's specifier shape to explicit `.ts` specifiers so TypeScript rewrites emitted JS to `.js` while declarations keep explicit, NodeNext-safe `.ts` specifiers. This includes `loader/src/config/isolate.ts` using `declare module './entry.ts'`. 5. **`schemastery/tsdown.config.ts` and `logger-console/tsdown.config.ts`**: ours, not upstream files — per-package build-shape overrides (dual ESM+CJS output; separate node/browser entries) for the repo-root tsdown build. They read the JS emitted under `lib/types` and then write the publish runtime entries under `lib/`. Like the regenerated tsconfigs, they are not part of the upstream sync surface. ## Sync procedure diff --git a/vendor/cordis/src/context.ts b/vendor/cordis/src/context.ts index 768ba52d6f..8b21c464b2 100644 --- a/vendor/cordis/src/context.ts +++ b/vendor/cordis/src/context.ts @@ -1,10 +1,10 @@ import { Dict } from 'cosmokit' -import { EventsService } from './events' -import { LoggerService } from './logger' -import { ReflectService } from './reflect' -import { InjectKey, RegistryService } from './registry' -import { getTraceable, symbols } from './utils' -import { Fiber } from './fiber' +import { EventsService } from './events.ts' +import { LoggerService } from './logger.ts' +import { ReflectService } from './reflect.ts' +import { InjectKey, RegistryService } from './registry.ts' +import { getTraceable, symbols } from './utils.ts' +import { Fiber } from './fiber.ts' /** * Public shape of a Cordis context. diff --git a/vendor/cordis/src/events.ts b/vendor/cordis/src/events.ts index f7dcf011f4..4461816537 100644 --- a/vendor/cordis/src/events.ts +++ b/vendor/cordis/src/events.ts @@ -1,7 +1,7 @@ import { defineProperty, Promisify } from 'cosmokit' -import { Context } from './context' -import { Fiber, FiberState } from './fiber' -import { DisposableList, symbols } from './utils' +import { Context } from './context.ts' +import { Fiber, FiberState } from './fiber.ts' +import { DisposableList, symbols } from './utils.ts' /** Return whether an event result should stop a bail-style dispatch. */ export function isBailed(value: any) { @@ -25,7 +25,7 @@ export type ThisType = F extends (this: infer T, ...args: any) => any ? T : n */ export type DispatchMode = 'emit' | 'parallel' | 'serial' | 'bail' | 'waterfall' -declare module './context' { +declare module './context.ts' { export interface Context { /* eslint-disable max-len */ parallel(name: K, ...args: Parameters): Promise diff --git a/vendor/cordis/src/fiber.ts b/vendor/cordis/src/fiber.ts index 840bc54352..fd472e7733 100644 --- a/vendor/cordis/src/fiber.ts +++ b/vendor/cordis/src/fiber.ts @@ -1,11 +1,11 @@ import { Awaitable, defineProperty, Dict, isNullable } from 'cosmokit' -import { Context } from './context' -import { Plugin } from './registry' -import { buildOuterStack, composeError, DisposableList, getTraceable, isConstructor, isObject, symbols } from './utils' -import { Impl } from './reflect' +import { Context } from './context.ts' +import { Plugin } from './registry.ts' +import { buildOuterStack, composeError, DisposableList, getTraceable, isConstructor, isObject, symbols } from './utils.ts' +import { Impl } from './reflect.ts' import { StandardSchemaV1 } from '@standard-schema/spec' -declare module './context' { +declare module './context.ts' { export interface Context extends Pick { fiber: Fiber } diff --git a/vendor/cordis/src/index.ts b/vendor/cordis/src/index.ts index 83d160395e..d0814213e0 100644 --- a/vendor/cordis/src/index.ts +++ b/vendor/cordis/src/index.ts @@ -1,14 +1,14 @@ /** Core context type and root context implementation. */ -export * from './context' +export * from './context.ts' /** Event bus, dispatch modes, and event augmentation types. */ -export * from './events' +export * from './events.ts' /** Plugin fiber lifecycle, effects, and config validation helpers. */ -export * from './fiber' +export * from './fiber.ts' /** Logger facade, logger service, message, exporter, and formatting types. */ -export * from './logger' +export * from './logger.ts' /** Plugin registry, dependency injection, and plugin entrypoint types. */ -export * from './registry' +export * from './registry.ts' /** Base service class and service lifecycle symbols. */ -export * from './service' +export * from './service.ts' /** Shared internal helpers used by context, services, and plugin fibers. */ -export * from './utils' +export * from './utils.ts' diff --git a/vendor/cordis/src/logger.ts b/vendor/cordis/src/logger.ts index f76ac2cdb7..a1e97c165a 100644 --- a/vendor/cordis/src/logger.ts +++ b/vendor/cordis/src/logger.ts @@ -1,9 +1,9 @@ import { defineProperty, hyphenate } from 'cosmokit' -import { Context } from './context' -import { Fiber } from './fiber' -import { createCallable, joinPrototype, symbols, Tracker } from './utils' +import { Context } from './context.ts' +import { Fiber } from './fiber.ts' +import { createCallable, joinPrototype, symbols, Tracker } from './utils.ts' -declare module './context' { +declare module './context.ts' { interface Intercept { logger: LoggerService.Intercept } diff --git a/vendor/cordis/src/reflect.ts b/vendor/cordis/src/reflect.ts index 4bc9fb44db..212ec4e779 100644 --- a/vendor/cordis/src/reflect.ts +++ b/vendor/cordis/src/reflect.ts @@ -1,9 +1,9 @@ import { defineProperty, Dict, isNullable } from 'cosmokit' -import { Context } from './context' -import { getTraceable, symbols, withProps } from './utils' -import { Fiber, FiberState } from './fiber' +import { Context } from './context.ts' +import { getTraceable, symbols, withProps } from './utils.ts' +import { Fiber, FiberState } from './fiber.ts' -declare module './context' { +declare module './context.ts' { interface Context { get(name: K, strict?: boolean): undefined | this[K] get(name: string, strict?: boolean): any diff --git a/vendor/cordis/src/registry.ts b/vendor/cordis/src/registry.ts index fae7712df9..9dfa10a06b 100644 --- a/vendor/cordis/src/registry.ts +++ b/vendor/cordis/src/registry.ts @@ -1,8 +1,8 @@ import { defineProperty, Dict } from 'cosmokit' import { StandardSchemaV1 } from '@standard-schema/spec' -import { Context } from './context' -import { Fiber } from './fiber' -import { buildOuterStack, DisposableList, symbols, withProps } from './utils' +import { Context } from './context.ts' +import { Fiber } from './fiber.ts' +import { buildOuterStack, DisposableList, symbols, withProps } from './utils.ts' function isApplicable(object: Plugin) { return object && typeof object === 'object' && typeof object.apply === 'function' @@ -140,7 +140,7 @@ type GetPluginConfig

= ? S : GetPluginParameters

[0] -declare module './context' { +declare module './context.ts' { export interface Context { inject(deps: Inject, callback: Plugin.Function): Fiber & PromiseLike plugin

(plugin: P, ...args: Spread>): Fiber & PromiseLike diff --git a/vendor/cordis/src/service.ts b/vendor/cordis/src/service.ts index 4cc9f307f2..30895247c1 100644 --- a/vendor/cordis/src/service.ts +++ b/vendor/cordis/src/service.ts @@ -1,6 +1,6 @@ import { defineProperty } from 'cosmokit' -import { Context } from './context' -import { createCallable, joinPrototype, symbols, Tracker } from './utils' +import { Context } from './context.ts' +import { createCallable, joinPrototype, symbols, Tracker } from './utils.ts' /** * Base class for services that expose a named API on `ctx`. diff --git a/vendor/cordis/src/utils.ts b/vendor/cordis/src/utils.ts index 46dd962c6f..2fd499bd0c 100644 --- a/vendor/cordis/src/utils.ts +++ b/vendor/cordis/src/utils.ts @@ -1,5 +1,5 @@ import { defineProperty } from 'cosmokit' -import type { Context, Service } from '.' +import type { Context, Service } from './index.ts' /** Ordered collection of disposable values with O(1) deletion by value. */ export class DisposableList { diff --git a/vendor/cosmokit/src/array.ts b/vendor/cosmokit/src/array.ts index ccbc4b2752..18ed5e407f 100644 --- a/vendor/cosmokit/src/array.ts +++ b/vendor/cosmokit/src/array.ts @@ -1,4 +1,4 @@ -import { isNullable } from './misc' +import { isNullable } from './misc.ts' /** Return true when every item in `array2` is present in `array1`. */ export function contain(array1: readonly any[], array2: readonly any[]) { diff --git a/vendor/cosmokit/src/index.ts b/vendor/cosmokit/src/index.ts index 088e81c54f..9fe48de069 100644 --- a/vendor/cosmokit/src/index.ts +++ b/vendor/cosmokit/src/index.ts @@ -1,10 +1,10 @@ /** Array set and normalization helpers. */ -export * from './array' +export * from './array.ts' /** Runtime type, binary, clone, and equality helpers. */ -export * from './types' +export * from './types.ts' /** Shared utility types and object helpers. */ -export * from './misc' +export * from './misc.ts' /** String case, path, and property formatting helpers. */ -export * from './string' +export * from './string.ts' /** Time constants, parsing, and formatting helpers. */ -export * from './time' +export * from './time.ts' diff --git a/vendor/cosmokit/src/types.ts b/vendor/cosmokit/src/types.ts index b4d1e5bed8..499a46273a 100644 --- a/vendor/cosmokit/src/types.ts +++ b/vendor/cosmokit/src/types.ts @@ -1,4 +1,4 @@ -import { isNullable } from './misc' +import { isNullable } from './misc.ts' type GlobalConstructorNames = keyof { [K in keyof typeof globalThis as typeof globalThis[K] extends abstract new (...args: any) => any ? K : never]: K diff --git a/vendor/hmr/src/index.ts b/vendor/hmr/src/index.ts index 8948625db6..ada10cc934 100644 --- a/vendor/hmr/src/index.ts +++ b/vendor/hmr/src/index.ts @@ -4,7 +4,7 @@ import { ModuleJob, ModuleLoader, ResolveResult } from '@cordisjs/plugin-loader' import type { Include } from '@cordisjs/plugin-include' import { ChokidarOptions, FSWatcher, watch } from 'chokidar' import { relative, resolve } from 'node:path' -import { handleError } from './error' +import { handleError } from './error.ts' import type {} from '@cordisjs/plugin-timer' import { fileURLToPath, pathToFileURL } from 'node:url' import { createRequire } from 'node:module' diff --git a/vendor/loader/src/config/entry.ts b/vendor/loader/src/config/entry.ts index 8acba39548..c2959fe61e 100644 --- a/vendor/loader/src/config/entry.ts +++ b/vendor/loader/src/config/entry.ts @@ -1,9 +1,9 @@ import { Context, Fiber, Inject } from 'cordis' import { deepEqual, isNullable } from 'cosmokit' -import { Loader } from '../index' -import { EntryGroup } from './group' -import { EntryTree } from './tree' -import { evaluate, interpolate } from './utils' +import { Loader } from '../index.ts' +import { EntryGroup } from './group.ts' +import { EntryTree } from './tree.ts' +import { evaluate, interpolate } from './utils.ts' /** Serialized plugin entry options stored in loader config files. */ export interface EntryOptions { diff --git a/vendor/loader/src/config/group.ts b/vendor/loader/src/config/group.ts index 5966d87eb8..f6ce0fe306 100644 --- a/vendor/loader/src/config/group.ts +++ b/vendor/loader/src/config/group.ts @@ -1,6 +1,6 @@ import { Context, Service } from 'cordis' -import { Entry, EntryOptions } from './entry' -import { EntryTree } from './tree' +import { Entry, EntryOptions } from './entry.ts' +import { EntryTree } from './tree.ts' /** Runtime owner for a list of child loader entries. */ export class EntryGroup { diff --git a/vendor/loader/src/config/isolate.ts b/vendor/loader/src/config/isolate.ts index 4b2f1df894..a2e930c4fb 100644 --- a/vendor/loader/src/config/isolate.ts +++ b/vendor/loader/src/config/isolate.ts @@ -1,8 +1,8 @@ import { Context } from 'cordis' import { Dict } from 'cosmokit' -import { Entry } from './entry' +import { Entry } from './entry.ts' -declare module './entry' { +declare module './entry.ts' { interface EntryOptions { intercept?: Dict | null isolate?: Dict | null diff --git a/vendor/loader/src/config/tree.ts b/vendor/loader/src/config/tree.ts index 53f71220e1..6855884e11 100644 --- a/vendor/loader/src/config/tree.ts +++ b/vendor/loader/src/config/tree.ts @@ -1,7 +1,7 @@ import { composeError, Context } from 'cordis' import { Dict, isNonNullable } from 'cosmokit' -import { Entry, EntryOptions } from './entry' -import { EntryGroup } from './group' +import { Entry, EntryOptions } from './entry.ts' +import { EntryGroup } from './group.ts' /** Mutable tree of loader entries. Persistence is supplied by subclasses. */ export abstract class EntryTree { diff --git a/vendor/loader/src/index.ts b/vendor/loader/src/index.ts index 764f04f995..e18fc2ffa2 100644 --- a/vendor/loader/src/index.ts +++ b/vendor/loader/src/index.ts @@ -1,22 +1,22 @@ import { Context, Inject, Service } from 'cordis' import { defineProperty, Dict, isNullable } from 'cosmokit' -import { ModuleLoader } from './internal' -import { Entry, EntryOptions } from './config/entry' -import isolate from './config/isolate' -import { EntryTree } from './config/tree' +import { ModuleLoader } from './internal.ts' +import { Entry, EntryOptions } from './config/entry.ts' +import isolate from './config/isolate.ts' +import { EntryTree } from './config/tree.ts' /** Re-export entry node APIs. */ -export * from './config/entry' +export * from './config/entry.ts' /** Re-export nested entry group APIs. */ -export * from './config/group' +export * from './config/group.ts' /** Re-export service isolation helpers. */ -export * from './config/isolate' +export * from './config/isolate.ts' /** Re-export entry tree persistence APIs. */ -export * from './config/tree' +export * from './config/tree.ts' /** Re-export loader config expression helpers. */ -export * from './config/utils' +export * from './config/utils.ts' /** Re-export Node internal module loader compatibility types. */ -export * from './internal' +export * from './internal.ts' declare module 'cordis' { interface Events { diff --git a/vendor/logger-console/src/browser.ts b/vendor/logger-console/src/browser.ts index fb35366d14..b45a15e228 100644 --- a/vendor/logger-console/src/browser.ts +++ b/vendor/logger-console/src/browser.ts @@ -1,8 +1,8 @@ import { Message } from 'cordis' -import { ConsoleExporter as Base } from './shared' +import { ConsoleExporter as Base } from './shared.ts' /** Re-export shared console exporter config and base implementation. */ -export * from './shared' +export * from './shared.ts' /** Browser console exporter that dispatches to native console methods. */ export class ConsoleExporter extends Base { diff --git a/vendor/logger-console/src/index.ts b/vendor/logger-console/src/index.ts index 905287b1e8..d46ac6413f 100644 --- a/vendor/logger-console/src/index.ts +++ b/vendor/logger-console/src/index.ts @@ -1,10 +1,10 @@ import { Formatter } from 'cordis' import { inspect } from 'node:util' import supportsColor from 'supports-color' -import { ConsoleExporter as Base } from './shared' +import { ConsoleExporter as Base } from './shared.ts' /** Re-export shared console exporter config and base implementation. */ -export * from './shared' +export * from './shared.ts' const inspectFormatter: Formatter = (value, target) => { return inspect(value, { colors: !!target.colors, depth: Infinity, compact: true, breakLength: Infinity }) From 67317938595e2b4925130f5068730d4373ce366f Mon Sep 17 00:00:00 2001 From: imccyu Date: Mon, 22 Jun 2026 09:02:58 +0800 Subject: [PATCH 18/21] revert: use rewriteRelativeImportExtensions for NextNode .d.ts resolve --- examples/acp-agent/tests/acp.snapshot.ts | 4 ++-- examples/acp-agent/tests/snapshot-normalize.spec.ts | 2 +- examples/coding-agent/tests/coding-task.e2e.ts | 2 +- examples/coding-agent/tests/full-loop.e2e.ts | 2 +- examples/coding-agent/tests/resume.e2e.ts | 2 +- packages/bash/tool-bash/tests/integration.spec.ts | 2 +- packages/core/agent-core/tests/agent-core.spec.ts | 2 +- packages/core/agent-loop/tests/agent.spec.ts | 2 +- packages/core/agent-loop/tests/cancel.spec.ts | 2 +- packages/core/agent-loop/tests/config-session-id.spec.ts | 2 +- packages/core/agent-loop/tests/coverage-edges.spec.ts | 2 +- packages/core/agent-loop/tests/loop.spec.ts | 2 +- packages/core/agent-loop/tests/resume.spec.ts | 2 +- packages/core/agent-loop/tests/review-fixes.spec.ts | 2 +- packages/core/agent/tests/gen-cordis-catalog.spec.ts | 2 +- packages/core/session/tests/repair.spec.ts | 4 ++-- packages/llm/llm-deepseek/tests/adapter.e2e.ts | 2 +- packages/llm/llm-deepseek/tests/adapter.spec.ts | 2 +- packages/llm/llm-pi-ai/tests/adapter.e2e.ts | 2 +- packages/llm/llm-pi-ai/tests/adapter.spec.ts | 2 +- .../session-persistence-jsonl/tests/jsonl.spec.ts | 6 +++--- .../session-persistence-sqlite/tests/sqlite.spec.ts | 6 +++--- .../session-persistence/tests/contract.ts | 2 +- .../session-persistence/tests/coordinator-contract.ts | 4 ++-- .../session-persistence/tests/persistence.spec.ts | 6 +++--- packages/support/llm-replay/tests/llm-replay.spec.ts | 2 +- packages/support/ui-stdio/tests/ui-stdio.spec.ts | 2 +- packages/ui/acp-agent/tests/acp-agent.spec.ts | 2 +- packages/ui/acp/tests/bridge.spec.ts | 2 +- packages/ui/acp/tests/codec.spec.ts | 2 +- packages/ui/acp/tests/dispose.spec.ts | 2 +- packages/ui/acp/tests/edges.spec.ts | 2 +- packages/ui/acp/tests/harness.ts | 4 ++-- packages/ui/acp/tests/load.spec.ts | 2 +- packages/ui/acp/tests/multi-session.spec.ts | 2 +- packages/ui/acp/tests/properties.spec.ts | 2 +- packages/ui/acp/tests/stream-update.spec.ts | 2 +- packages/ui/acp/tests/turns.spec.ts | 2 +- packages/ui/stdio-agent/tests/stdio-agent.spec.ts | 2 +- 39 files changed, 49 insertions(+), 49 deletions(-) diff --git a/examples/acp-agent/tests/acp.snapshot.ts b/examples/acp-agent/tests/acp.snapshot.ts index d5a6e1551f..be6aabada0 100644 --- a/examples/acp-agent/tests/acp.snapshot.ts +++ b/examples/acp-agent/tests/acp.snapshot.ts @@ -3,8 +3,8 @@ import { existsSync } from 'node:fs' import { fileURLToPath } from 'node:url' import { dirname, join } from 'node:path' import { describe, expect, it } from 'vitest' -import { type InputScript, runScenario } from './snapshot-harness' -import { type NormalizeContext, normalizeSessionLog, normalizeStdout } from './snapshot-normalize' +import { type InputScript, runScenario } from './snapshot-harness.ts' +import { type NormalizeContext, normalizeSessionLog, normalizeStdout } from './snapshot-normalize.ts' /** * ACP snapshot tests (REPLAY by default, keyless). Each scenario under diff --git a/examples/acp-agent/tests/snapshot-normalize.spec.ts b/examples/acp-agent/tests/snapshot-normalize.spec.ts index a83d7682e0..b220344bb9 100644 --- a/examples/acp-agent/tests/snapshot-normalize.spec.ts +++ b/examples/acp-agent/tests/snapshot-normalize.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { type NormalizeContext, normalizeSessionLog, normalizeStdout } from '../tests/snapshot-normalize' +import { type NormalizeContext, normalizeSessionLog, normalizeStdout } from '../tests/snapshot-normalize.ts' /** * Unit tests for the pure snapshot normalizers. Live as a *.spec.ts (runs in diff --git a/examples/coding-agent/tests/coding-task.e2e.ts b/examples/coding-agent/tests/coding-task.e2e.ts index 2f3dc2ae3b..68bca5cdfa 100644 --- a/examples/coding-agent/tests/coding-task.e2e.ts +++ b/examples/coding-agent/tests/coding-task.e2e.ts @@ -5,7 +5,7 @@ import { join } from 'node:path' import { afterEach, describe, expect, it } from 'vitest' import type { Context } from 'cordis' import { AgentId } from '@deepseek-ai/dsh-agent' -import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness' +import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness.ts' /** * The swebench-style smoke test: a real model fixes a real bug in a temp diff --git a/examples/coding-agent/tests/full-loop.e2e.ts b/examples/coding-agent/tests/full-loop.e2e.ts index 7a511d6d99..2b70d6f339 100644 --- a/examples/coding-agent/tests/full-loop.e2e.ts +++ b/examples/coding-agent/tests/full-loop.e2e.ts @@ -1,7 +1,7 @@ import { afterEach, describe, expect, it } from 'vitest' import type { Context } from 'cordis' import { AgentId } from '@deepseek-ai/dsh-agent' -import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness' +import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness.ts' /** * The first place a REAL model meets the REAL bash tool: the cheap canary diff --git a/examples/coding-agent/tests/resume.e2e.ts b/examples/coding-agent/tests/resume.e2e.ts index c829f34ced..450938fc6d 100644 --- a/examples/coding-agent/tests/resume.e2e.ts +++ b/examples/coding-agent/tests/resume.e2e.ts @@ -6,7 +6,7 @@ import type { Context } from 'cordis' import type { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' import { AgentId } from '@deepseek-ai/dsh-agent' import { SessionId } from '@deepseek-ai/dsh-session' -import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness' +import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness.ts' /** * Proves durable conversation continuity end-to-end: run 1 tells the REAL model diff --git a/packages/bash/tool-bash/tests/integration.spec.ts b/packages/bash/tool-bash/tests/integration.spec.ts index 154d3dc67a..a67809ffee 100644 --- a/packages/bash/tool-bash/tests/integration.spec.ts +++ b/packages/bash/tool-bash/tests/integration.spec.ts @@ -10,7 +10,7 @@ import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' import { LocalBashExecutor } from '@deepseek-ai/dsh-bash-local' import { BashTaskId } from '@deepseek-ai/dsh-bash' import * as ToolBash from '@deepseek-ai/dsh-tool-bash' -import { MockAdapter, textResponse, toolCallResponse } from '../../../core/agent-loop/tests/mock-adapter' +import { MockAdapter, textResponse, toolCallResponse } from '../../../core/agent-loop/tests/mock-adapter.ts' /** * Full-loop integration: a scripted mock model drives the REAL bash tool diff --git a/packages/core/agent-core/tests/agent-core.spec.ts b/packages/core/agent-core/tests/agent-core.spec.ts index fe3d89eca6..67f5d88532 100644 --- a/packages/core/agent-core/tests/agent-core.spec.ts +++ b/packages/core/agent-core/tests/agent-core.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' import { Context } from 'cordis' import Loader from '@cordisjs/plugin-loader' -import * as agentCore from '../src/index' +import * as agentCore from '../src/index.ts' import { AgentId } from '@deepseek-ai/dsh-agent' /** diff --git a/packages/core/agent-loop/tests/agent.spec.ts b/packages/core/agent-loop/tests/agent.spec.ts index 54ebc9fdc5..ed163bf4c2 100644 --- a/packages/core/agent-loop/tests/agent.spec.ts +++ b/packages/core/agent-loop/tests/agent.spec.ts @@ -7,7 +7,7 @@ import SystemPrompt from '@deepseek-ai/dsh-system-prompt' import ToolRegistry from '@deepseek-ai/dsh-tools' import AgentRegistry from '@deepseek-ai/dsh-agent' import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' -import { MockAdapter, textResponse } from './mock-adapter' +import { MockAdapter, textResponse } from './mock-adapter.ts' async function harness(adapter: MockAdapter) { const ctx = new Context() diff --git a/packages/core/agent-loop/tests/cancel.spec.ts b/packages/core/agent-loop/tests/cancel.spec.ts index 71b1b80ea4..9cdaa1973b 100644 --- a/packages/core/agent-loop/tests/cancel.spec.ts +++ b/packages/core/agent-loop/tests/cancel.spec.ts @@ -18,7 +18,7 @@ import SystemPrompt from '@deepseek-ai/dsh-system-prompt' import ToolRegistry from '@deepseek-ai/dsh-tools' import AgentRegistry, { AgentId } from '@deepseek-ai/dsh-agent' import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' -import { MockAdapter, textResponse } from './mock-adapter' +import { MockAdapter, textResponse } from './mock-adapter.ts' async function harness(adapter: MockAdapter) { const ctx = new Context() diff --git a/packages/core/agent-loop/tests/config-session-id.spec.ts b/packages/core/agent-loop/tests/config-session-id.spec.ts index c3045c7f7c..8cf5bd81f8 100644 --- a/packages/core/agent-loop/tests/config-session-id.spec.ts +++ b/packages/core/agent-loop/tests/config-session-id.spec.ts @@ -10,7 +10,7 @@ import ToolRegistry from '@deepseek-ai/dsh-tools' import AgentRegistry, { AgentId } from '@deepseek-ai/dsh-agent' import SessionPersistenceJsonl from '@deepseek-ai/dsh-session-persistence-jsonl' import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' -import { MockAdapter, textResponse } from './mock-adapter' +import { MockAdapter, textResponse } from './mock-adapter.ts' const dirs: string[] = [] afterEach(async () => { for (const d of dirs.splice(0)) await rm(d, { recursive: true, force: true }) }) diff --git a/packages/core/agent-loop/tests/coverage-edges.spec.ts b/packages/core/agent-loop/tests/coverage-edges.spec.ts index 2fec2b2c66..3eefbf6986 100644 --- a/packages/core/agent-loop/tests/coverage-edges.spec.ts +++ b/packages/core/agent-loop/tests/coverage-edges.spec.ts @@ -6,7 +6,7 @@ import SystemPrompt from '@deepseek-ai/dsh-system-prompt' import ToolRegistry, { defineTool } from '@deepseek-ai/dsh-tools' import AgentRegistry, { AgentId } from '@deepseek-ai/dsh-agent' import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' -import { MockAdapter, textResponse, toolCallResponse } from './mock-adapter' +import { MockAdapter, textResponse, toolCallResponse } from './mock-adapter.ts' async function harness(adapter: MockAdapter) { const ctx = new Context() diff --git a/packages/core/agent-loop/tests/loop.spec.ts b/packages/core/agent-loop/tests/loop.spec.ts index d0fb76b1e9..d018eff7a2 100644 --- a/packages/core/agent-loop/tests/loop.spec.ts +++ b/packages/core/agent-loop/tests/loop.spec.ts @@ -6,7 +6,7 @@ import SystemPrompt from '@deepseek-ai/dsh-system-prompt' import ToolRegistry, { defineTool } from '@deepseek-ai/dsh-tools' import AgentRegistry, { AgentId } from '@deepseek-ai/dsh-agent' import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' -import { MockAdapter, maxTokensResponse, textResponse, toolCallResponse } from './mock-adapter' +import { MockAdapter, maxTokensResponse, textResponse, toolCallResponse } from './mock-adapter.ts' async function harness(adapter: MockAdapter) { const ctx = new Context() diff --git a/packages/core/agent-loop/tests/resume.spec.ts b/packages/core/agent-loop/tests/resume.spec.ts index 63b2c700e2..6192396cab 100644 --- a/packages/core/agent-loop/tests/resume.spec.ts +++ b/packages/core/agent-loop/tests/resume.spec.ts @@ -11,7 +11,7 @@ import ToolRegistry from '@deepseek-ai/dsh-tools' import AgentRegistry, { AgentId } from '@deepseek-ai/dsh-agent' import SessionPersistenceJsonl from '@deepseek-ai/dsh-session-persistence-jsonl' import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' -import { MockAdapter, textResponse } from './mock-adapter' +import { MockAdapter, textResponse } from './mock-adapter.ts' const dirs: string[] = [] afterEach(async () => { for (const d of dirs.splice(0)) await rm(d, { recursive: true, force: true }) }) diff --git a/packages/core/agent-loop/tests/review-fixes.spec.ts b/packages/core/agent-loop/tests/review-fixes.spec.ts index c8e725ed26..ed0900c4a1 100644 --- a/packages/core/agent-loop/tests/review-fixes.spec.ts +++ b/packages/core/agent-loop/tests/review-fixes.spec.ts @@ -7,7 +7,7 @@ import ToolRegistry, { defineTool } from '@deepseek-ai/dsh-tools' import AgentRegistry, { AgentId } from '@deepseek-ai/dsh-agent' import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop' import * as Invariants from '@deepseek-ai/dsh-invariants' -import { MockAdapter, textResponse, toolCallResponse } from './mock-adapter' +import { MockAdapter, textResponse, toolCallResponse } from './mock-adapter.ts' /** * Regression tests for the findings of the first architecture review diff --git a/packages/core/agent/tests/gen-cordis-catalog.spec.ts b/packages/core/agent/tests/gen-cordis-catalog.spec.ts index e040b39b77..ee2ce47699 100644 --- a/packages/core/agent/tests/gen-cordis-catalog.spec.ts +++ b/packages/core/agent/tests/gen-cordis-catalog.spec.ts @@ -14,7 +14,7 @@ import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, describe, expect, it } from 'vitest' -import { collectEvents } from '../../../../scripts/gen-cordis-catalog' +import { collectEvents } from '../../../../scripts/gen-cordis-catalog.ts' /** Write a fixture package exposing one `interface Events` block and return the * scan root to hand `collectEvents`. */ diff --git a/packages/core/session/tests/repair.spec.ts b/packages/core/session/tests/repair.spec.ts index 2fa1bfae27..57422e7719 100644 --- a/packages/core/session/tests/repair.spec.ts +++ b/packages/core/session/tests/repair.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' import { CallId } from '@deepseek-ai/dsh-llm' -import { interruptedTurnClosers } from '../src/index' -import type { SessionEvent } from '../src/index' +import { interruptedTurnClosers } from '../src/index.ts' +import type { SessionEvent } from '../src/index.ts' /** * Unit coverage for the crash-recovery closer synthesis. The persistence diff --git a/packages/llm/llm-deepseek/tests/adapter.e2e.ts b/packages/llm/llm-deepseek/tests/adapter.e2e.ts index 51fbdbd187..b01b498dff 100644 --- a/packages/llm/llm-deepseek/tests/adapter.e2e.ts +++ b/packages/llm/llm-deepseek/tests/adapter.e2e.ts @@ -4,7 +4,7 @@ import LlmService, { CallId } from '@deepseek-ai/dsh-llm' import type { Message, ToolSchema } from '@deepseek-ai/dsh-llm' import * as LlmDeepSeek from '@deepseek-ai/dsh-llm-deepseek' import type { Config } from '@deepseek-ai/dsh-llm-deepseek' -import { assemble, type AssembledResult } from './assemble' +import { assemble, type AssembledResult } from './assemble.ts' /** * Real-API e2e for the hand-rolled adapter: V4 Flash + V4 Pro across diff --git a/packages/llm/llm-deepseek/tests/adapter.spec.ts b/packages/llm/llm-deepseek/tests/adapter.spec.ts index f576831e2c..1abbebc060 100644 --- a/packages/llm/llm-deepseek/tests/adapter.spec.ts +++ b/packages/llm/llm-deepseek/tests/adapter.spec.ts @@ -5,7 +5,7 @@ import { Context } from 'cordis' import LlmService, { LlmError } from '@deepseek-ai/dsh-llm' import * as LlmDeepSeek from '@deepseek-ai/dsh-llm-deepseek' import { DeepSeekAdapter, httpErrorCode } from '@deepseek-ai/dsh-llm-deepseek' -import { assemble } from './assemble' +import { assemble } from './assemble.ts' /** One scripted behavior for the next request the mock server receives. */ type Behavior = diff --git a/packages/llm/llm-pi-ai/tests/adapter.e2e.ts b/packages/llm/llm-pi-ai/tests/adapter.e2e.ts index 678bb409fd..fa30226ddf 100644 --- a/packages/llm/llm-pi-ai/tests/adapter.e2e.ts +++ b/packages/llm/llm-pi-ai/tests/adapter.e2e.ts @@ -5,7 +5,7 @@ import type { Message, ToolSchema } from '@deepseek-ai/dsh-llm' import * as LlmPiAi from '@deepseek-ai/dsh-llm-pi-ai' import type { Config } from '@deepseek-ai/dsh-llm-pi-ai' import * as LlmDeepSeek from '@deepseek-ai/dsh-llm-deepseek' -import { assemble, type AssembledResult } from './assemble' +import { assemble, type AssembledResult } from './assemble.ts' /** * Real-API e2e for the pi-ai-backed adapter: V4 Flash + V4 Pro across all diff --git a/packages/llm/llm-pi-ai/tests/adapter.spec.ts b/packages/llm/llm-pi-ai/tests/adapter.spec.ts index bd09afff99..63f9f90456 100644 --- a/packages/llm/llm-pi-ai/tests/adapter.spec.ts +++ b/packages/llm/llm-pi-ai/tests/adapter.spec.ts @@ -5,7 +5,7 @@ import { Context } from 'cordis' import LlmService, { CallId, LlmError } from '@deepseek-ai/dsh-llm' import * as LlmPiAi from '@deepseek-ai/dsh-llm-pi-ai' import { buildModel, PiAiAdapter } from '@deepseek-ai/dsh-llm-pi-ai' -import { assemble } from './assemble' +import { assemble } from './assemble.ts' /** Scripted SSE responses, one per request (OpenAI chat-completions shape). */ interface MockServer { diff --git a/packages/session-persistence/session-persistence-jsonl/tests/jsonl.spec.ts b/packages/session-persistence/session-persistence-jsonl/tests/jsonl.spec.ts index aa2a8080d5..1df70f9c9a 100644 --- a/packages/session-persistence/session-persistence-jsonl/tests/jsonl.spec.ts +++ b/packages/session-persistence/session-persistence-jsonl/tests/jsonl.spec.ts @@ -6,9 +6,9 @@ import { join } from 'node:path' import SessionStore, { SessionId } from '@deepseek-ai/dsh-session' import type { Session, SessionEvent } from '@deepseek-ai/dsh-session' import SessionPersistenceJsonl from '@deepseek-ai/dsh-session-persistence-jsonl' -import { encodeSegment, logPath, scanLog, sessionDir } from '../src/format' -import { runPersistenceContract, meta, oneTurnLog } from '../../session-persistence/tests/contract' -import { runCoordinatorContract, type CoordinatorFixture } from '../../session-persistence/tests/coordinator-contract' +import { encodeSegment, logPath, scanLog, sessionDir } from '../src/format.ts' +import { runPersistenceContract, meta, oneTurnLog } from '../../session-persistence/tests/contract.ts' +import { runCoordinatorContract, type CoordinatorFixture } from '../../session-persistence/tests/coordinator-contract.ts' let root: string const dirs: string[] = [] diff --git a/packages/session-persistence/session-persistence-sqlite/tests/sqlite.spec.ts b/packages/session-persistence/session-persistence-sqlite/tests/sqlite.spec.ts index af35c6c709..2bc9c59643 100644 --- a/packages/session-persistence/session-persistence-sqlite/tests/sqlite.spec.ts +++ b/packages/session-persistence/session-persistence-sqlite/tests/sqlite.spec.ts @@ -6,9 +6,9 @@ import { join } from 'node:path' import SessionStore, { SessionId } from '@deepseek-ai/dsh-session' import type { Session, SessionEvent } from '@deepseek-ai/dsh-session' import SessionPersistenceSqlite, { SCHEMA_VERSION } from '@deepseek-ai/dsh-session-persistence-sqlite' -import { openDatabase, scanRows, type EventRow } from '../src/schema' -import { runPersistenceContract, meta, oneTurnLog } from '../../session-persistence/tests/contract' -import { runCoordinatorContract, type CoordinatorFixture } from '../../session-persistence/tests/coordinator-contract' +import { openDatabase, scanRows, type EventRow } from '../src/schema.ts' +import { runPersistenceContract, meta, oneTurnLog } from '../../session-persistence/tests/contract.ts' +import { runCoordinatorContract, type CoordinatorFixture } from '../../session-persistence/tests/coordinator-contract.ts' const dirs: string[] = [] afterEach(async () => { for (const d of dirs.splice(0)) await rm(d, { recursive: true, force: true }) }) diff --git a/packages/session-persistence/session-persistence/tests/contract.ts b/packages/session-persistence/session-persistence/tests/contract.ts index 36356f3689..a0f0e7bfa0 100644 --- a/packages/session-persistence/session-persistence/tests/contract.ts +++ b/packages/session-persistence/session-persistence/tests/contract.ts @@ -12,7 +12,7 @@ import { describe, expect, it } from 'vitest' import { SESSION_FORMAT_VERSION, SessionId } from '@deepseek-ai/dsh-session' import type { SessionEvent, SessionHeader } from '@deepseek-ai/dsh-session' import { CallId } from '@deepseek-ai/dsh-llm' -import type { SessionPersistence } from '../src/index' +import type { SessionPersistence } from '../src/index.ts' /** A backend under test plus its teardown. */ export interface ContractBackend { diff --git a/packages/session-persistence/session-persistence/tests/coordinator-contract.ts b/packages/session-persistence/session-persistence/tests/coordinator-contract.ts index 7eab088deb..431d02b4cb 100644 --- a/packages/session-persistence/session-persistence/tests/coordinator-contract.ts +++ b/packages/session-persistence/session-persistence/tests/coordinator-contract.ts @@ -30,8 +30,8 @@ import { describe, expect, it } from 'vitest' import { Context, type Fiber } from 'cordis' import SessionStore, { SESSION_FORMAT_VERSION, SessionId } from '@deepseek-ai/dsh-session' import type { Session, SessionEvent } from '@deepseek-ai/dsh-session' -import type { SessionPersistence } from '../src/index' -import { meta, oneTurnLog } from './contract' +import type { SessionPersistence } from '../src/index.ts' +import { meta, oneTurnLog } from './contract.ts' /** * The backend-specific capabilities the orchestration suite needs beyond the diff --git a/packages/session-persistence/session-persistence/tests/persistence.spec.ts b/packages/session-persistence/session-persistence/tests/persistence.spec.ts index cc7da9a41c..4e4cf67822 100644 --- a/packages/session-persistence/session-persistence/tests/persistence.spec.ts +++ b/packages/session-persistence/session-persistence/tests/persistence.spec.ts @@ -5,9 +5,9 @@ import type { Session, SessionEvent, SessionHeader } from '@deepseek-ai/dsh-sess import { SessionPersistence, PersistenceCoordinator, assertSerializable, seedCoversPrefix, type PersistenceBackend, type StoredPrefix, -} from '../src/index' -import { runPersistenceContract, meta, oneTurnLog } from './contract' -import { runCoordinatorContract, type CoordinatorFixture } from './coordinator-contract' +} from '../src/index.ts' +import { runPersistenceContract, meta, oneTurnLog } from './contract.ts' +import { runCoordinatorContract, type CoordinatorFixture } from './coordinator-contract.ts' /** The durable store shape: materialized sessions only (no lazy entries). */ type MemoryStore = Map diff --git a/packages/support/llm-replay/tests/llm-replay.spec.ts b/packages/support/llm-replay/tests/llm-replay.spec.ts index e81f3729a0..925881273a 100644 --- a/packages/support/llm-replay/tests/llm-replay.spec.ts +++ b/packages/support/llm-replay/tests/llm-replay.spec.ts @@ -14,7 +14,7 @@ import { loadReplayScript, name, parseSessionLog, -} from '../src/index' +} from '../src/index.ts' /** * Unit tests for the replay llm/stream plugin. These drive the listener through diff --git a/packages/support/ui-stdio/tests/ui-stdio.spec.ts b/packages/support/ui-stdio/tests/ui-stdio.spec.ts index 72d82b539c..bd5e0f7f91 100644 --- a/packages/support/ui-stdio/tests/ui-stdio.spec.ts +++ b/packages/support/ui-stdio/tests/ui-stdio.spec.ts @@ -5,7 +5,7 @@ import type { Agent, AgentStatus } from '@deepseek-ai/dsh-agent' import AgentRegistry from '@deepseek-ai/dsh-agent' import type { ContentBlock } from '@deepseek-ai/dsh-llm' import type { Session, SessionEvent } from '@deepseek-ai/dsh-session' -import { createStdioChat, type Config, type StdioRuntime } from '../src/index' +import { createStdioChat, type Config, type StdioRuntime } from '../src/index.ts' /** * Unit tests for the stdio UI plugin. They drive the REAL plugin body diff --git a/packages/ui/acp-agent/tests/acp-agent.spec.ts b/packages/ui/acp-agent/tests/acp-agent.spec.ts index c8e7920669..7a02837fca 100644 --- a/packages/ui/acp-agent/tests/acp-agent.spec.ts +++ b/packages/ui/acp-agent/tests/acp-agent.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' import { Context } from 'cordis' import Loader from '@cordisjs/plugin-loader' -import * as acpAgent from '../src/index' +import * as acpAgent from '../src/index.ts' /** * In-process unit coverage for the @deepseek-ai/dsh-acp-agent composition: diff --git a/packages/ui/acp/tests/bridge.spec.ts b/packages/ui/acp/tests/bridge.spec.ts index 8089894ba1..e9ebca8d62 100644 --- a/packages/ui/acp/tests/bridge.spec.ts +++ b/packages/ui/acp/tests/bridge.spec.ts @@ -4,7 +4,7 @@ import { tmpdir } from 'node:os' import { join } from 'node:path' import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk' import { AgentId } from '@deepseek-ai/dsh-agent' -import { makeBridgeHarness, textResponse, type BridgeHarness } from './harness' +import { makeBridgeHarness, textResponse, type BridgeHarness } from './harness.ts' /** * End-to-end bridge specs over an in-memory transport: a real diff --git a/packages/ui/acp/tests/codec.spec.ts b/packages/ui/acp/tests/codec.spec.ts index 6149d35227..9d82fe7533 100644 --- a/packages/ui/acp/tests/codec.spec.ts +++ b/packages/ui/acp/tests/codec.spec.ts @@ -6,7 +6,7 @@ import { harnessBlockToAcpContent, promptHasUnsupportedContent, turnEndToStopReason, -} from '../src/codec' +} from '../src/codec.ts' describe('turnEndToStopReason', () => { // The SDK rejects an unknown stopReason, so this must be total over every diff --git a/packages/ui/acp/tests/dispose.spec.ts b/packages/ui/acp/tests/dispose.spec.ts index 79d18612cc..ac092d9d16 100644 --- a/packages/ui/acp/tests/dispose.spec.ts +++ b/packages/ui/acp/tests/dispose.spec.ts @@ -5,7 +5,7 @@ import { join } from 'node:path' import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk' import { SessionId } from '@deepseek-ai/dsh-session' import { AgentId } from '@deepseek-ai/dsh-agent' -import { makeBridgeHarness, textResponse } from './harness' +import { makeBridgeHarness, textResponse } from './harness.ts' describe('acp bridge — disposal & HMR safety', () => { let storageDir: string diff --git a/packages/ui/acp/tests/edges.spec.ts b/packages/ui/acp/tests/edges.spec.ts index 1d31769202..69c935139d 100644 --- a/packages/ui/acp/tests/edges.spec.ts +++ b/packages/ui/acp/tests/edges.spec.ts @@ -5,7 +5,7 @@ import { join } from 'node:path' import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk' import { AgentId } from '@deepseek-ai/dsh-agent' import { SessionId } from '@deepseek-ai/dsh-session' -import { makeBridgeHarness, textResponse, type BridgeHarness } from './harness' +import { makeBridgeHarness, textResponse, type BridgeHarness } from './harness.ts' describe('acp bridge — demux & config edges', () => { let storageDir: string diff --git a/packages/ui/acp/tests/harness.ts b/packages/ui/acp/tests/harness.ts index 4b41b013bd..4f6b5ac17a 100644 --- a/packages/ui/acp/tests/harness.ts +++ b/packages/ui/acp/tests/harness.ts @@ -30,8 +30,8 @@ import { type SessionNotification, type Stream, } from '@agentclientprotocol/sdk' -import * as AcpPlugin from '../src/index' -import { type AcpConfig } from '../src/index' +import * as AcpPlugin from '../src/index.ts' +import { type AcpConfig } from '../src/index.ts' /** A scripted mock adapter (mirrors the agent-loop test adapter). */ class MockAdapter extends LlmAdapter { diff --git a/packages/ui/acp/tests/load.spec.ts b/packages/ui/acp/tests/load.spec.ts index d0da3e5cd6..a87fa49a9e 100644 --- a/packages/ui/acp/tests/load.spec.ts +++ b/packages/ui/acp/tests/load.spec.ts @@ -5,7 +5,7 @@ import { join } from 'node:path' import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk' import { SESSION_FORMAT_VERSION, SessionId } from '@deepseek-ai/dsh-session' import { AgentId } from '@deepseek-ai/dsh-agent' -import { makeBridgeHarness, textResponse, toolCallResponse, type BridgeHarness, type CapturedUpdate } from './harness' +import { makeBridgeHarness, textResponse, toolCallResponse, type BridgeHarness, type CapturedUpdate } from './harness.ts' /** Concatenate the text of all agent_message_chunk updates. */ function messageText(updates: CapturedUpdate[]): string { diff --git a/packages/ui/acp/tests/multi-session.spec.ts b/packages/ui/acp/tests/multi-session.spec.ts index d93f45a4b9..ca11934046 100644 --- a/packages/ui/acp/tests/multi-session.spec.ts +++ b/packages/ui/acp/tests/multi-session.spec.ts @@ -4,7 +4,7 @@ import { tmpdir } from 'node:os' import { join } from 'node:path' import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk' import { AgentId } from '@deepseek-ai/dsh-agent' -import { makeBridgeHarness, textResponse, type BridgeHarness, type CapturedUpdate } from './harness' +import { makeBridgeHarness, textResponse, type BridgeHarness, type CapturedUpdate } from './harness.ts' /** Text of the agent_message_chunk updates scoped to one session id. */ function messageTextFor(updates: { sessionId?: string; update: CapturedUpdate }[], sessionId: string): string { diff --git a/packages/ui/acp/tests/properties.spec.ts b/packages/ui/acp/tests/properties.spec.ts index fec9ebcacd..3dcb4c760f 100644 --- a/packages/ui/acp/tests/properties.spec.ts +++ b/packages/ui/acp/tests/properties.spec.ts @@ -19,7 +19,7 @@ import fc from 'fast-check' import { CallId } from '@deepseek-ai/dsh-llm' import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session' import type { SessionNotification } from '@agentclientprotocol/sdk' -import { streamSessionEventUpdate } from '../src/index' +import { streamSessionEventUpdate } from '../src/index.ts' const LEGAL_UPDATE_KINDS = new Set([ 'agent_message_chunk', diff --git a/packages/ui/acp/tests/stream-update.spec.ts b/packages/ui/acp/tests/stream-update.spec.ts index 34271a3350..30cbd17c40 100644 --- a/packages/ui/acp/tests/stream-update.spec.ts +++ b/packages/ui/acp/tests/stream-update.spec.ts @@ -3,7 +3,7 @@ import { CallId } from '@deepseek-ai/dsh-llm' import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session' import type { SessionNotification } from '@agentclientprotocol/sdk' import type { ToolDefinition, ToolRegistry } from '@deepseek-ai/dsh-tools' -import { streamSessionEventUpdate, agentOptions, ToolPresenter } from '../src/index' +import { streamSessionEventUpdate, agentOptions, ToolPresenter } from '../src/index.ts' /** Collect the updates a single event produces (no presenter → generic fallback). */ function updatesFor(event: SessionEvent): SessionNotification['update'][] { diff --git a/packages/ui/acp/tests/turns.spec.ts b/packages/ui/acp/tests/turns.spec.ts index 7a032d0f2f..7634602a35 100644 --- a/packages/ui/acp/tests/turns.spec.ts +++ b/packages/ui/acp/tests/turns.spec.ts @@ -12,7 +12,7 @@ import { textResponse, toolCallResponse, type BridgeHarness, -} from './harness' +} from './harness.ts' /** Boilerplate: initialize + create one session, returning its id. */ async function newSession(h: BridgeHarness, clientCapabilities: Record = {}): Promise { diff --git a/packages/ui/stdio-agent/tests/stdio-agent.spec.ts b/packages/ui/stdio-agent/tests/stdio-agent.spec.ts index a5dc1fbf90..f72de0a1da 100644 --- a/packages/ui/stdio-agent/tests/stdio-agent.spec.ts +++ b/packages/ui/stdio-agent/tests/stdio-agent.spec.ts @@ -2,7 +2,7 @@ import { describe, it, expect } from 'vitest' import { Context } from 'cordis' import Loader from '@cordisjs/plugin-loader' import { AgentId } from '@deepseek-ai/dsh-agent' -import * as stdioAgent from '../src/index' +import * as stdioAgent from '../src/index.ts' /** * Unit coverage for the @deepseek-ai/dsh-stdio-agent app plugin: mounting it From fa9438bf161a4960145d7a9e28c8ea76382162b9 Mon Sep 17 00:00:00 2001 From: imccyu Date: Mon, 22 Jun 2026 09:03:28 +0800 Subject: [PATCH 19/21] docs: update rewriteRelativeImportExtensions to current rfc --- .../rfc/implemented/process/2026-06-17-ts-build-config.md | 5 +++-- scripts/verify-node-next-types.ts | 8 ++++---- tsconfig.json | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/rfc/implemented/process/2026-06-17-ts-build-config.md b/docs/rfc/implemented/process/2026-06-17-ts-build-config.md index fdcc85aa38..a45962c70e 100644 --- a/docs/rfc/implemented/process/2026-06-17-ts-build-config.md +++ b/docs/rfc/implemented/process/2026-06-17-ts-build-config.md @@ -17,7 +17,7 @@ Validation found several concrete technical issues and possible routes: - `tsdown` uses `oxc` to transform TypeScript, which is not the same behavior as `tsc`. - Bundled `.d.ts` emitted by `tsdown` conflicts with Cordis' internal relative module augmentation shape. - - The tsc output is affected by `allowImportingTsExtensions`, so we need to ensure that generated `.js` files do not import `.ts` files and generated `.d.ts` files do not contain extensionless relative imports. Therefore, in-package relative imports use explicit `.ts` specifiers in TypeScript source and `rewriteRelativeImportExtensions` rewrites those specifiers to `.js` in emitted JS. + - The tsc output is affected by `allowImportingTsExtensions`, so we need to ensure that generated `.js` files do not import `.ts` files and generated `.d.ts` files keep explicit relative specifiers that NodeNext/Node16 accepts. Therefore, in-package relative imports use explicit `.ts` specifiers in TypeScript source and `rewriteRelativeImportExtensions` rewrites those specifiers to `.js` in emitted JS. - Bundled `.js` emitted by `tsdown` is not the same behavior as per-file `.js` emitted by `tsc -b`, such as decorator transform behavior. - `vendor/*/src`, examples, tests, and scripts cannot all be plain-included in one root strict program. - Directly typechecking `vendor/*/src` under the root strict config triggers many type errors outside this project's ownership. @@ -39,6 +39,7 @@ In-package relative imports use explicit `.ts` specifiers. `pnpm run typecheck` runs build mode over the root `tsconfig.json`. - The root `tsconfig.json` is the single development/typecheck project. It typechecks examples, tests, and scripts with `noEmit`, and validates package/vendor source through references. - Referenced package/vendor projects keep the same emit behavior as build, so typecheck can refresh their `lib/types` outputs instead of using a separate no-emit graph. Project-specific strictness changes live in the owning `packages/*/*/tsconfig.json` or `vendor/*/tsconfig.json`. +- The root no-emit project disables `rewriteRelativeImportExtensions`; it emits nothing and includes tests that import helpers across project-reference boundaries. Package/vendor emit projects keep the rewrite enabled. The command orchestration shape is: @@ -66,7 +67,7 @@ Build responsibilities are clearer: - `lib/types/*.d.ts` uses explicit `.ts` relative specifiers, which TypeScript's NodeNext/Node16 resolver maps to sibling `.d.ts` files. - `lib/types/*.js` is only a bundler input and must not be used as a runtime entry or public import target. - `lib/index.*` is the publish runtime output and is generated by the bundler, currently `tsdown`. -- `pnpm run verify-node-next-types` scans built declarations for extensionless relative specifiers, then typechecks a temporary external ESM consumer with `moduleResolution: "NodeNext"` against the built `types`/`exports` surface, so declaration specifier regressions fail before publish. +- `pnpm run verify-node-next-types` scans built declarations for relative specifiers without file extensions, then typechecks a temporary external ESM consumer with `moduleResolution: "NodeNext"` against the built `types`/`exports` surface, so declaration specifier regressions fail before publish. - The `typecheck` command uses `tsconfig.json`. Examples, tests, and scripts are checked by the root no-emit project, while packages and vendor modules keep the same emit behavior as `build`. Package and vendor source stays behind project-reference boundaries. The Cordis vendor copy now has one more type-structure divergence from upstream. During upstream sync, that divergence must be reapplied or explicitly retired. diff --git a/scripts/verify-node-next-types.ts b/scripts/verify-node-next-types.ts index 0f2e392666..7883a855c3 100644 --- a/scripts/verify-node-next-types.ts +++ b/scripts/verify-node-next-types.ts @@ -47,7 +47,7 @@ function workspacePackages(): WorkspacePackage[] { const declarationSpecifierPattern = /(?:from\s*|import\s*\(\s*|import\s+|declare\s+module\s*)["'](\.{0,2}(?:\/[^"']*)?)["']/g const hasExtension = /\.[^/.]+$/ -function extensionlessRelativeSpecifiers(): string[] { +function relativeSpecifiersMissingExtensions(): string[] { const errors: string[] = [] const files = [ ...globSync('vendor/*/lib/types/**/*.d.ts', { cwd: root }), @@ -88,9 +88,9 @@ function linkPackage(pkg: WorkspacePackage, nodeModules: string): void { } const packages = workspacePackages() -const badSpecifiers = extensionlessRelativeSpecifiers() +const badSpecifiers = relativeSpecifiersMissingExtensions() if (badSpecifiers.length > 0) { - console.error('verify-node-next-types: declaration files still contain extensionless relative specifiers.') + console.error('verify-node-next-types: declaration files still contain relative specifiers without file extensions.') console.error(badSpecifiers.join('\n')) process.exit(1) } @@ -129,7 +129,7 @@ try { strict: true, // Third-party SDK declarations can have their own lib-check noise under a // symlinked temp install. The explicit scan above owns our regression: - // extensionless relative specifiers in built declarations. + // relative specifiers without file extensions in built declarations. skipLibCheck: true, preserveSymlinks: true, noEmit: true, diff --git a/tsconfig.json b/tsconfig.json index a4c1a8245c..bc5aee0bb9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,8 @@ { "extends": "./tsconfig.base.json", "compilerOptions": { - "noEmit": true + "noEmit": true, + "rewriteRelativeImportExtensions": false }, "include": [ "examples/*/src/**/*.ts", From 475c68cbe8804972fc5ca761b023077c76644b11 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Mon, 22 Jun 2026 11:36:35 +0800 Subject: [PATCH 20/21] docs: sync package cookbook with build config --- docs/cookbook/adding-a-package.md | 22 ++++++++++--------- .../2026-06-20-package-hierarchy.md | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/docs/cookbook/adding-a-package.md b/docs/cookbook/adding-a-package.md index 593a0a93ba..3c9cdb07d5 100644 --- a/docs/cookbook/adding-a-package.md +++ b/docs/cookbook/adding-a-package.md @@ -5,16 +5,19 @@ The file-by-file checklist for a new `@deepseek-ai/dsh-` package. (Verifie ## 1. Create the package ``` -packages// +packages/// package.json # copy from packages/core/tools, adjust name/description/deps - tsconfig.json # extends ../../tsconfig.base.json, rootDir src, outDir lib/types, - # references: vendor/cosmokit, vendor/cordis (+ vendor/schemastery - # if you use Config, + ../ for each dsh dependency) + tsconfig.json # extends ../../../tsconfig.base.json, rootDir src, + # outDir lib/types, references: ../../../vendor/cosmokit, + # ../../../vendor/cordis (+ ../../../vendor/schemastery if + # you use Config, + ../..// for each dsh dep) src/index.ts # service default export or plugin (name/inject/apply/Config) tests/.spec.ts README.md # service API, events, extension points, design notes ``` +Choose an existing group when one matches the package's role (`core`, `llm`, `bash`, `session-persistence`, `ui`, `util`, or `support`). A new group is allowed, but it is a pure container: no `package.json`, no source files, and packages still sit exactly one level below it. + package.json invariants (enforced by `pnpm run constraints` / `scripts/check-workspace-constraints.ts`): `private: true`, `version: 0.0.1`, `type: module`, `main: "lib/index.js"`, `types: "lib/types/index.d.ts"`, `exports["."].types: "./lib/types/index.d.ts"`, `exports["."].default: "./lib/index.js"`, `cordis` in BOTH peerDependencies and devDependencies (same range). Mirror every dsh peer dependency in devDependencies. `schemastery` goes in `dependencies` (it is a runtime validator), matching agent-loop. The `files` list is precise: `lib/index.js`, `lib/types/**/*.d.ts`, `lib/types/**/*.d.ts.map`, and `src`; do not publish `lib/types` JS or JS-map intermediates or stale root declaration files. CLI app packages with a package `bin` include `lib/bin.js` immediately after `lib/index.js` in `files`. In-package relative imports use explicit `.ts` specifiers in source (for example, `export * from './types.ts'`). The compiler rewrites those to `.js` in emitted JS and leaves explicit `.ts` specifiers in declarations, which standard NodeNext/Node16 TypeScript consumers resolve to the sibling `.d.ts` files. @@ -23,13 +26,12 @@ In-package relative imports use explicit `.ts` specifiers in source (for example | File | Change | |---|---| -| `tsconfig.base.json` | add `"@deepseek-ai/dsh-": ["./packages//src"]` to `paths` | -| `tsconfig.json` | add `{ "path": "./packages/" }` to `references` | -| `tsconfig.build.json` | add `{ "path": "./packages/" }` to `references` | -| `scripts/publint-all.ts` | add `'packages/'` to the array | +| `tsconfig.base.json` | no edit for an existing group; for a new group, add a `./packages//*/src` candidate to the `@deepseek-ai/dsh-*` wildcard | +| `tsconfig.json` | add `{ "path": "./packages//" }` to `references` | +| `tsconfig.build.json` | add `{ "path": "./packages//" }` to `references` | | `knip.json` | only if the package has non-`*.spec.ts` entries (e.g. `*.e2e.ts` → add a per-workspace override like `packages/llm/llm-deepseek`) | -Covered automatically by globs — no edits needed: root `package.json` workspaces, `tsdown.config.ts`, `vitest.config.ts`, `eslint.config.mjs`. +Covered automatically by globs or package-manifest discovery — no edits needed: root `package.json` workspaces, `scripts/publint-all.ts`, `tsdown.config.ts`, `vitest.config.ts`, `eslint.config.mjs`, `scripts/check-workspace-constraints.ts`. ## 3. Decide the package topology @@ -41,7 +43,7 @@ For a swappable capability, split interface / implementation / consumer into sep pnpm install # registers the workspace pnpm run constraints && pnpm run typecheck && pnpm run lint pnpm run test:coverage # 100% per-file over src (types.ts exempt) -pnpm run build && pnpm run knip && pnpm run publint +pnpm run build && pnpm run hygiene ``` Test expectations: every registry/registration needs an HMR-safety test (register from a child fiber, dispose it, assert cleanup). Excessive tests are welcome — see AGENTS.md. diff --git a/docs/rfc/implemented/architecture/2026-06-20-package-hierarchy.md b/docs/rfc/implemented/architecture/2026-06-20-package-hierarchy.md index 60e295e767..8b198ed9c6 100644 --- a/docs/rfc/implemented/architecture/2026-06-20-package-hierarchy.md +++ b/docs/rfc/implemented/architecture/2026-06-20-package-hierarchy.md @@ -51,7 +51,7 @@ packages/ The package list had been enumerated in five places. The uniform depth-2 layout lets most of them be derived instead: -- `tsconfig.base.json` and `tsconfig.typecheck.json` each map every package through a single `@deepseek-ai/dsh-*` `paths` wildcard listing one candidate per group, in place of 18 per-package entries. (One subtlety this introduced: a path candidate contains `/*/`, which a naive regex comment-stripper mistakes for a block comment — `scripts/doc-typecheck.ts` reads the `paths` map via the TypeScript JSONC API rather than stripping comments by hand for exactly this reason.) +- `tsconfig.base.json` maps every package through a single `@deepseek-ai/dsh-*` `paths` wildcard listing one candidate per group, in place of per-package entries. Root `tsconfig.json` reuses that source map and carries the explicit project references that keep package/vendor typecheck boundaries intact. (One subtlety this introduced: a path candidate contains `/*/`, which a naive regex comment-stripper mistakes for a block comment — `scripts/doc-typecheck.ts` reads the JSONC config through TypeScript's parser rather than stripping comments by hand for exactly this reason.) - `scripts/publint-all.ts` derives its list by reading the hierarchy (`packages//`), resolving the `TODO(package-inventory)`. - `tsconfig.build.json`'s project `references` stay an explicit list — TypeScript project references have no wildcard form. Generating these from a manifest is left to a follow-up (see [discover package inventories](../../proposed/process/2026-06-20-discover-package-inventory.md)). From 3a67d0a8825a6d494ed7fdc8a6c6c401476d0044 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Mon, 22 Jun 2026 12:54:11 +0800 Subject: [PATCH 21/21] docs: sync development CI gate docs --- docs/development.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/development.md b/docs/development.md index f2206d30c0..99f67e671d 100644 --- a/docs/development.md +++ b/docs/development.md @@ -76,10 +76,10 @@ The GitHub workflow runs these gates on each pull request: - `pnpm run test:coverage` - `pnpm run test:snapshot` - `pnpm run build` -- `pnpm run knip && pnpm run publint` +- `pnpm run hygiene` - an echo-agent smoke test that checks the demo's tool call, tool result, and JSONL output -`pnpm run hygiene` is the local shorthand for `pnpm run knip && pnpm run publint && pnpm run constraints`; CI splits `pnpm run constraints` into its own earlier step, then runs `pnpm run knip && pnpm run publint` after `pnpm run build`. +`pnpm run hygiene` is the local shorthand for `pnpm run knip && pnpm run publint && pnpm run constraints && pnpm run verify-node-next-types`; CI also runs `pnpm run constraints` as an earlier fail-fast step, then runs the full hygiene script after `pnpm run build`. ## Daily commands