feat: improve skill import and runtime delivery

This commit is contained in:
lofyer
2026-08-07 21:01:17 +08:00
parent 954b42ef55
commit 417a9fccb6
63 changed files with 6136 additions and 527 deletions
+39
View File
@@ -225,6 +225,45 @@ describe('ContinueAgentRuntime', () => {
expect(prompt).toContain('test')
})
it('keeps a full bundled Skill payload on every platform', async () => {
const runtime = new ContinueAgentRuntime({
binaryPath: '',
configPath: 'C:\\safe config\\continue.yaml',
defaultWorkspace: process.cwd(),
hostCacheRoot: 'C:\\safe\\continue-host',
skillInstructions: `# Skills\n${'技'.repeat(30_000)}`.slice(0, 30_000),
createHostAdapter: () => ({
getPreparedHost: mocks.prepareHost,
run: mocks.runHost,
dispose: mocks.disposeHost
})
})
await collectEvents(runtime)
const prompt = String(mocks.runHost.mock.calls[0]?.[0])
expect(prompt).toContain('SYSTEM CAPABILITY INSTRUCTIONS')
expect(prompt.length).toBeGreaterThan(24_000)
})
it('reports oversized Skill payloads instead of dropping them silently', async () => {
const runtime = new ContinueAgentRuntime({
binaryPath: '',
configPath: 'C:\\safe config\\continue.yaml',
defaultWorkspace: process.cwd(),
hostCacheRoot: 'C:\\safe\\continue-host',
skillInstructions: '巨'.repeat(130_000),
createHostAdapter: () => ({
getPreparedHost: mocks.prepareHost,
run: mocks.runHost,
dispose: mocks.disposeHost
})
})
await expect(collectEvents(runtime)).rejects.toThrow('超过 Continue')
expect(mocks.runHost).not.toHaveBeenCalled()
})
it('blocks anonymous platform fallback without an explicit model configuration', async () => {
const runtime = new ContinueAgentRuntime({
binaryPath: '',
+15 -7
View File
@@ -43,8 +43,9 @@ export type ContinueRuntimeOptions = {
>
}
const MAX_CONTINUE_PROMPT_CHARACTERS =
process.platform === 'win32' ? 24_000 : 128_000
// The prompt reaches the Continue host through a local HTTP POST body, so no
// platform command-line limit applies to it.
const MAX_CONTINUE_PROMPT_CHARACTERS = 128_000
function continueToolFailureMessage(tool: ContinueHostTool): string {
const callId = tool.callId.slice(0, 128)
@@ -260,12 +261,19 @@ export class ContinueAgentRuntime implements AgentRuntime {
'CURRENT CONVERSATION:'
].join('\n')
: ''
const conversationContext =
if (
skillPrefix &&
skillPrefix.length + prompt.length <=
MAX_CONTINUE_PROMPT_CHARACTERS
? `${skillPrefix}\n${prompt}`
: prompt
skillPrefix.length + prompt.length > MAX_CONTINUE_PROMPT_CHARACTERS
) {
throw new Error(
`已启用的 Skill 说明与当前请求合计 ${(
skillPrefix.length + prompt.length
).toLocaleString()} 字符,超过 Continue ${MAX_CONTINUE_PROMPT_CHARACTERS.toLocaleString()} 字符上限。请在设置中减少分配给 Continue 的 Skill。`
)
}
const conversationContext = skillPrefix
? `${skillPrefix}\n${prompt}`
: prompt
const detection = await this.getDetection()
signal.throwIfAborted()
if (!detection.available || !detection.path) {