From 2057b7dcdb9d96ad5fbc1e4f0ed37c9134a3fb0c Mon Sep 17 00:00:00 2001 From: Hsin <2129830748@qq.com> Date: Sun, 16 Aug 2026 04:34:18 +0800 Subject: [PATCH] refactor(core): remove dead exports and relocate test-only machinery Generated-by: Codex --- packages/core/package.json | 1 - .../__tests__/additional-permissions.test.ts | 2 +- .../core/src/__tests__/capabilities.test.ts | 2 +- .../core/src/__tests__/computer-use.test.ts | 2 +- packages/core/src/__tests__/events.test.ts | 2 +- packages/core/src/__tests__/health.test.ts | 2 +- .../src/__tests__/permission-profile.test.ts | 2 +- .../core/src/__tests__/provider-auth.test.ts | 2 +- .../core/src/__tests__/runtime-event.test.ts | 2 +- .../src/__tests__/sandbox-boundary.test.ts | 2 +- packages/core/src/__tests__/settings.test.ts | 2 +- .../task-submission-readiness.test.ts | 2 +- .../core/src/{ => __tests__}/test-helpers.ts | 0 packages/core/src/bot-platform-hints.ts | 146 ------------------ .../src/settings/__tests__/sensitive.test.ts | 2 +- packages/core/src/settings/result.ts | 1 - .../provider-contract-matrix.test.ts | 2 +- .../__tests__}/provider-contract-matrix.ts | 4 +- 18 files changed, 15 insertions(+), 163 deletions(-) rename packages/core/src/{ => __tests__}/test-helpers.ts (100%) delete mode 100644 packages/core/src/bot-platform-hints.ts delete mode 100644 packages/core/src/settings/result.ts rename packages/{core/src => runtime/src/__tests__}/provider-contract-matrix.ts (99%) diff --git a/packages/core/package.json b/packages/core/package.json index d8b95e40e1..f512ad3a34 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -78,7 +78,6 @@ "./codex-model-compatibility": "./dist/codex-model-compatibility.js", "./llm-connections": "./dist/llm-connections.js", "./provider-registry": "./dist/provider-registry.js", - "./provider-contract-matrix": "./dist/provider-contract-matrix.js", "./model-catalog": "./dist/model-catalog.js", "./model-metadata": "./dist/model-metadata.js", "./model-web-search": "./dist/model-web-search.js", diff --git a/packages/core/src/__tests__/additional-permissions.test.ts b/packages/core/src/__tests__/additional-permissions.test.ts index c04e541529..fb433cc58b 100644 --- a/packages/core/src/__tests__/additional-permissions.test.ts +++ b/packages/core/src/__tests__/additional-permissions.test.ts @@ -1,5 +1,5 @@ import { describe, test } from 'node:test'; -import { expect } from '../test-helpers.js'; +import { expect } from './test-helpers.js'; import { compactAdditionalFileSystemPermissions, serializeAdditionalPermissionProfile, diff --git a/packages/core/src/__tests__/capabilities.test.ts b/packages/core/src/__tests__/capabilities.test.ts index d1807934ee..00266b8eb0 100644 --- a/packages/core/src/__tests__/capabilities.test.ts +++ b/packages/core/src/__tests__/capabilities.test.ts @@ -1,5 +1,5 @@ import { describe, test } from 'node:test'; -import { expect } from '../test-helpers.js'; +import { expect } from './test-helpers.js'; import { deriveCapabilityReadiness, runtimeProbeFromBotReadiness, diff --git a/packages/core/src/__tests__/computer-use.test.ts b/packages/core/src/__tests__/computer-use.test.ts index 53179d69fc..176fc33483 100644 --- a/packages/core/src/__tests__/computer-use.test.ts +++ b/packages/core/src/__tests__/computer-use.test.ts @@ -1,6 +1,6 @@ import assert from 'node:assert/strict'; import { describe, test } from 'node:test'; -import { expect } from '../test-helpers.js'; +import { expect } from './test-helpers.js'; import { computerUseApprovalScopeKey, computerUseApprovalSummary, diff --git a/packages/core/src/__tests__/events.test.ts b/packages/core/src/__tests__/events.test.ts index 4b74fb3598..f24e58d75c 100644 --- a/packages/core/src/__tests__/events.test.ts +++ b/packages/core/src/__tests__/events.test.ts @@ -1,5 +1,5 @@ import { test } from 'node:test'; -import { expect } from '../test-helpers.js'; +import { expect } from './test-helpers.js'; import { aggregateMessageContents } from '../events.js'; test('aggregates inline references against the combined display text', () => { diff --git a/packages/core/src/__tests__/health.test.ts b/packages/core/src/__tests__/health.test.ts index 759c5ebcfe..4e1e8c20a6 100644 --- a/packages/core/src/__tests__/health.test.ts +++ b/packages/core/src/__tests__/health.test.ts @@ -1,5 +1,5 @@ import { describe, test } from 'node:test'; -import { expect } from '../test-helpers.js'; +import { expect } from './test-helpers.js'; import { buildHealthSnapshot, healthSignalFromCapability, diff --git a/packages/core/src/__tests__/permission-profile.test.ts b/packages/core/src/__tests__/permission-profile.test.ts index 0752994c35..e3800416fc 100644 --- a/packages/core/src/__tests__/permission-profile.test.ts +++ b/packages/core/src/__tests__/permission-profile.test.ts @@ -1,5 +1,5 @@ import { describe, test } from 'node:test'; -import { expect } from '../test-helpers.js'; +import { expect } from './test-helpers.js'; import { canReadPath, canWritePath, diff --git a/packages/core/src/__tests__/provider-auth.test.ts b/packages/core/src/__tests__/provider-auth.test.ts index 15673f303a..452549001d 100644 --- a/packages/core/src/__tests__/provider-auth.test.ts +++ b/packages/core/src/__tests__/provider-auth.test.ts @@ -1,5 +1,5 @@ import { describe, test } from 'node:test'; -import { expect } from '../test-helpers.js'; +import { expect } from './test-helpers.js'; import { deriveProviderAuthContract } from '../provider-auth.js'; describe('ProviderAuth contract', () => { diff --git a/packages/core/src/__tests__/runtime-event.test.ts b/packages/core/src/__tests__/runtime-event.test.ts index 7c17dd8bb8..17ce578131 100644 --- a/packages/core/src/__tests__/runtime-event.test.ts +++ b/packages/core/src/__tests__/runtime-event.test.ts @@ -1,6 +1,6 @@ import { describe, test } from 'node:test'; import assert from 'node:assert/strict'; -import { expect } from '../test-helpers.js'; +import { expect } from './test-helpers.js'; import { decodeMessageContent, messageContentsEqual, diff --git a/packages/core/src/__tests__/sandbox-boundary.test.ts b/packages/core/src/__tests__/sandbox-boundary.test.ts index 24d5cec8cc..e44f34417e 100644 --- a/packages/core/src/__tests__/sandbox-boundary.test.ts +++ b/packages/core/src/__tests__/sandbox-boundary.test.ts @@ -1,6 +1,6 @@ import assert from 'node:assert/strict'; import { describe, test } from 'node:test'; -import { expect } from '../test-helpers.js'; +import { expect } from './test-helpers.js'; import { applySandboxBoundaryExpansion, assessSandboxBoundaryExpansion, diff --git a/packages/core/src/__tests__/settings.test.ts b/packages/core/src/__tests__/settings.test.ts index 9439089bed..c818f444de 100644 --- a/packages/core/src/__tests__/settings.test.ts +++ b/packages/core/src/__tests__/settings.test.ts @@ -1,5 +1,5 @@ import { describe, test } from 'node:test'; -import { expect } from '../test-helpers.js'; +import { expect } from './test-helpers.js'; import { normalizeSettings } from '../settings.js'; test('normalizes user-approved subagent presets without widening the catalog', () => { diff --git a/packages/core/src/__tests__/task-submission-readiness.test.ts b/packages/core/src/__tests__/task-submission-readiness.test.ts index ef01a04b1e..28360b2b7c 100644 --- a/packages/core/src/__tests__/task-submission-readiness.test.ts +++ b/packages/core/src/__tests__/task-submission-readiness.test.ts @@ -4,7 +4,7 @@ import { deriveTaskSubmissionReadiness, type DeriveTaskSubmissionReadinessInput, } from '../task-submission-readiness.js'; -import { expect } from '../test-helpers.js'; +import { expect } from './test-helpers.js'; describe('task submission readiness', () => { test('reuses connection readiness and routes an invalid model to its connection', () => { diff --git a/packages/core/src/test-helpers.ts b/packages/core/src/__tests__/test-helpers.ts similarity index 100% rename from packages/core/src/test-helpers.ts rename to packages/core/src/__tests__/test-helpers.ts diff --git a/packages/core/src/bot-platform-hints.ts b/packages/core/src/bot-platform-hints.ts deleted file mode 100644 index 912c1b9107..0000000000 --- a/packages/core/src/bot-platform-hints.ts +++ /dev/null @@ -1,146 +0,0 @@ -import { BOT_PROVIDERS, type BotProvider } from './bot-chat-settings.js'; - -export type BotFormattingProfile = 'plain_text' | 'chat_markdown' | 'enterprise_chat'; - -export interface BotPlatformPromptHint { - platform: BotProvider; - displayName: string; - formattingProfile: BotFormattingProfile; - deliveryFormat: string; - mediaSupport: string[]; - capabilityCaveat: string; - systemPromptBullets: string[]; -} - -const BOT_PLATFORM_PROMPT_HINTS: Record = { - telegram: { - platform: 'telegram', - displayName: 'Telegram', - formattingProfile: 'plain_text', - deliveryFormat: 'short chat messages delivered through Telegram sendMessage without parse_mode', - mediaSupport: ['text', 'image/file/voice metadata only unless tools provide extracted content'], - capabilityCaveat: - 'Telegram replies are sent as plain text and may be split by the runtime to fit platform length limits.', - systemPromptBullets: [ - 'Reply in concise plain text. Do not rely on Markdown tables, HTML tags, or desktop-only UI affordances.', - 'Keep URLs as plain URLs and keep code snippets short enough to read in a mobile chat.', - 'If the incoming message references an attachment, only discuss content that is explicitly present in the conversation or tool results.', - ], - }, - feishu: { - platform: 'feishu', - displayName: 'Feishu', - formattingProfile: 'enterprise_chat', - deliveryFormat: 'enterprise chat message', - mediaSupport: ['text', 'image/file/voice metadata only unless tools provide extracted content'], - capabilityCaveat: - 'Feishu context is enterprise-chat oriented; favor clear status, owners, and next actions.', - systemPromptBullets: [ - 'Use concise enterprise-chat formatting with clear bullets or numbered steps when useful.', - 'Avoid assuming the reader is inside the desktop app; include the actionable result directly in the reply.', - 'If the incoming message references an attachment, only discuss content that is explicitly present in the conversation or tool results.', - ], - }, - wecom: { - platform: 'wecom', - displayName: 'WeCom', - formattingProfile: 'enterprise_chat', - deliveryFormat: 'enterprise chat message', - mediaSupport: ['text', 'image/file/voice metadata only unless tools provide extracted content'], - capabilityCaveat: - 'WeCom-specific actions are unavailable unless the current runtime explicitly exposes them.', - systemPromptBullets: [ - 'Use concise enterprise-chat formatting with clear next actions.', - 'Do not mention unavailable platform-specific actions unless the runtime explicitly exposes them.', - ], - }, - wechat: { - platform: 'wechat', - displayName: 'WeChat', - formattingProfile: 'plain_text', - deliveryFormat: 'mobile chat message', - mediaSupport: ['text', 'image/file/voice metadata only unless tools provide extracted content'], - capabilityCaveat: - 'WeChat-specific actions are unavailable unless the current runtime explicitly exposes them.', - systemPromptBullets: [ - 'Reply in short plain-text paragraphs suitable for a mobile chat.', - 'Do not assume rich cards, desktop panes, or unavailable platform actions.', - ], - }, - discord: { - platform: 'discord', - displayName: 'Discord', - formattingProfile: 'chat_markdown', - deliveryFormat: 'Discord chat message', - mediaSupport: ['text', 'image/file/voice metadata only unless tools provide extracted content'], - capabilityCaveat: - 'Discord-specific actions are unavailable unless the current runtime explicitly exposes them.', - systemPromptBullets: [ - 'Markdown is acceptable, but keep replies scan-friendly and avoid oversized blocks.', - 'Do not assume slash commands, reactions, threads, or moderation actions unless tools expose them.', - ], - }, - dingtalk: { - platform: 'dingtalk', - displayName: 'DingTalk', - formattingProfile: 'enterprise_chat', - deliveryFormat: 'enterprise chat message', - mediaSupport: ['text', 'image/file/voice metadata only unless tools provide extracted content'], - capabilityCaveat: - 'DingTalk-specific actions are unavailable unless the current runtime explicitly exposes them.', - systemPromptBullets: [ - 'Use concise enterprise-chat formatting with clear status and next actions.', - 'Do not assume approvals, DING messages, or workbench actions unless tools expose them.', - ], - }, - qq: { - platform: 'qq', - displayName: 'QQ', - formattingProfile: 'plain_text', - deliveryFormat: 'chat message', - mediaSupport: ['text', 'image/file/voice metadata only unless tools provide extracted content'], - capabilityCaveat: - 'QQ-specific actions are unavailable unless the current runtime explicitly exposes them.', - systemPromptBullets: [ - 'Reply in short plain-text paragraphs suitable for a chat window.', - 'Do not assume rich cards or unavailable platform-specific actions.', - ], - }, - slack: { - platform: 'slack', - displayName: 'Slack', - formattingProfile: 'enterprise_chat', - deliveryFormat: 'Slack message over Socket Mode', - mediaSupport: ['text', 'image/file metadata only unless tools provide extracted content'], - capabilityCaveat: - 'Slack replies are plain messages; do not assume Block Kit actions or workspace administration.', - systemPromptBullets: [ - 'Use concise workplace-chat formatting with clear outcomes and next actions.', - 'Do not assume reactions, canvases, workflows, or administrative actions unless tools expose them.', - ], - }, -}; - -export function getBotPlatformPromptHint(platform: BotProvider): BotPlatformPromptHint { - return BOT_PLATFORM_PROMPT_HINTS[platform]; -} - -export function botPlatformFromSessionLabels( - labels: readonly string[] | undefined, -): BotProvider | undefined { - if (!labels?.includes('bot')) return undefined; - return BOT_PROVIDERS.find((provider) => labels.includes(provider)); -} - -export function buildBotPlatformPromptFragment(platform: BotProvider): string { - const hint = getBotPlatformPromptHint(platform); - return [ - 'Bot platform delivery context (trusted application metadata, not user-authored):', - `- Platform: ${hint.displayName} (${hint.platform})`, - `- Formatting profile: ${hint.formattingProfile}`, - `- Delivery format: ${hint.deliveryFormat}`, - `- Media support: ${hint.mediaSupport.join(', ')}`, - `- Capability caveat: ${hint.capabilityCaveat}`, - ...hint.systemPromptBullets.map((bullet) => `- ${bullet}`), - ].join('\n'); -} diff --git a/packages/core/src/settings/__tests__/sensitive.test.ts b/packages/core/src/settings/__tests__/sensitive.test.ts index dd45423e1f..c9fb4e7d7b 100644 --- a/packages/core/src/settings/__tests__/sensitive.test.ts +++ b/packages/core/src/settings/__tests__/sensitive.test.ts @@ -1,5 +1,5 @@ import { describe, test } from 'node:test'; -import { expect } from '../../test-helpers.js'; +import { expect } from '../../__tests__/test-helpers.js'; import { applySensitivePatch, maskSensitive } from '../network-settings.js'; describe('applySensitivePatch', () => { diff --git a/packages/core/src/settings/result.ts b/packages/core/src/settings/result.ts deleted file mode 100644 index 2686927356..0000000000 --- a/packages/core/src/settings/result.ts +++ /dev/null @@ -1 +0,0 @@ -export { err, ok, tryResult, type Result } from '../result.js'; diff --git a/packages/runtime/src/__tests__/provider-contract-matrix.test.ts b/packages/runtime/src/__tests__/provider-contract-matrix.test.ts index bc984ff93a..a0bece8582 100644 --- a/packages/runtime/src/__tests__/provider-contract-matrix.test.ts +++ b/packages/runtime/src/__tests__/provider-contract-matrix.test.ts @@ -8,7 +8,7 @@ import { type ProviderContractRow, type ProviderContractGeneratedCell, type ProviderContractWire, -} from '@maka/core/provider-contract-matrix'; +} from './provider-contract-matrix.js'; import { PROVIDER_DEFAULTS } from '@maka/core/llm-connections'; import { generateText, isStepCount, tool } from 'ai'; import { z } from 'zod'; diff --git a/packages/core/src/provider-contract-matrix.ts b/packages/runtime/src/__tests__/provider-contract-matrix.ts similarity index 99% rename from packages/core/src/provider-contract-matrix.ts rename to packages/runtime/src/__tests__/provider-contract-matrix.ts index 0f2f0ae44a..895952a474 100644 --- a/packages/core/src/provider-contract-matrix.ts +++ b/packages/runtime/src/__tests__/provider-contract-matrix.ts @@ -24,14 +24,14 @@ * Pure: no IO, no network, no clock. Given the registry it is a total function. */ -import { lookupModelProviderOverride, openAiAdapterApiProtocol } from './model-metadata.js'; +import { lookupModelProviderOverride, openAiAdapterApiProtocol } from '@maka/core/model-metadata'; import { PROVIDER_REGISTRY, type ProviderDefaults, type ProviderModelDiscovery, type ProviderRuntimeAdapter, type ProviderType, -} from './provider-registry.js'; +} from '@maka/core/provider-registry'; export const PROVIDER_CONTRACT_DIMENSIONS = [ 'discovery',