mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 13:55:50 +00:00
feat: 整合功能恢复与技能学习闭环(含 ECC v2.1 parity + Opus 4.7 接入 + prompt 工程优化)
主要变更: - Skill Learning 闭环系统 (9/9 AC) - Opus 4.7 模型层接入 + adaptive thinking - Prompt 工程优化 (64 审计测试) - Agent Teams 简化门控 (默认启用) - Windows Terminal 后端修复 (EncodedCommand/WT_SESSION) - TF-IDF 技能搜索精准化 (字段加权/CJK 优化) - Autonomy 系统 (/autonomy 命令) - ACP 协议完整实现 - mock.module 泄漏修复 (CI 全绿) - 152+ lint/type 修复
This commit is contained in:
50
packages/url-handler-napi/src/__tests__/index.test.ts
Normal file
50
packages/url-handler-napi/src/__tests__/index.test.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { afterEach, describe, expect, test } from 'bun:test'
|
||||
import { waitForUrlEvent } from '../index'
|
||||
|
||||
const originalEnv = {
|
||||
CLAUDE_CODE_URL_EVENT: process.env.CLAUDE_CODE_URL_EVENT,
|
||||
CLAUDE_CODE_DEEP_LINK_URL: process.env.CLAUDE_CODE_DEEP_LINK_URL,
|
||||
CLAUDE_CODE_URL: process.env.CLAUDE_CODE_URL,
|
||||
}
|
||||
const originalArgv = process.argv.slice()
|
||||
|
||||
afterEach(() => {
|
||||
for (const [key, value] of Object.entries(originalEnv)) {
|
||||
if (value === undefined) {
|
||||
delete process.env[key]
|
||||
} else {
|
||||
process.env[key] = value
|
||||
}
|
||||
}
|
||||
process.argv = originalArgv.slice()
|
||||
})
|
||||
|
||||
describe('waitForUrlEvent', () => {
|
||||
test('resolves to null without a timeout', async () => {
|
||||
await expect(waitForUrlEvent()).resolves.toBeNull()
|
||||
})
|
||||
|
||||
test('resolves to null with an explicit timeout', async () => {
|
||||
await expect(waitForUrlEvent(1)).resolves.toBeNull()
|
||||
})
|
||||
|
||||
test('returns a Claude URL from environment variables', async () => {
|
||||
process.env.CLAUDE_CODE_URL_EVENT = 'claude-cli://prompt?q=hello'
|
||||
|
||||
await expect(waitForUrlEvent()).resolves.toBe(
|
||||
'claude-cli://prompt?q=hello',
|
||||
)
|
||||
})
|
||||
|
||||
test('returns a Claude URL from argv', async () => {
|
||||
process.argv = [...originalArgv, 'claude://prompt?q=hello']
|
||||
|
||||
await expect(waitForUrlEvent()).resolves.toBe('claude://prompt?q=hello')
|
||||
})
|
||||
|
||||
test('rejects URLs exceeding the maximum length', async () => {
|
||||
process.env.CLAUDE_CODE_URL_EVENT = `claude-cli://${'x'.repeat(2048)}`
|
||||
|
||||
await expect(waitForUrlEvent()).resolves.toBeNull()
|
||||
})
|
||||
})
|
||||
@@ -1,3 +1,48 @@
|
||||
const MAX_URL_LENGTH = 2048
|
||||
|
||||
/**
|
||||
* Check for a pending URL event from environment variables or CLI arguments.
|
||||
*
|
||||
* This is a synchronous snapshot check, not an event listener. The optional
|
||||
* timeout parameter is retained for API compatibility but has no practical
|
||||
* effect since process.env and process.argv do not change at runtime.
|
||||
* Callers that need to wait for an OS-level deep link activation should use
|
||||
* an IPC channel or platform-specific event listener instead.
|
||||
*/
|
||||
export async function waitForUrlEvent(timeoutMs?: number): Promise<string | null> {
|
||||
return null
|
||||
return findUrlEvent()
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks three env var sources (set by the OS URL scheme handler or installer)
|
||||
* and then CLI arguments for a claude:// deep link URL.
|
||||
*
|
||||
* Priority order:
|
||||
* 1. CLAUDE_CODE_URL_EVENT — set by the OS URL scheme handler on activation
|
||||
* 2. CLAUDE_CODE_DEEP_LINK_URL — set by the desktop app launcher
|
||||
* 3. CLAUDE_CODE_URL — legacy / manual override
|
||||
* 4. CLI arguments — e.g. `claude claude://...`
|
||||
*/
|
||||
function findUrlEvent(): string | null {
|
||||
for (const key of [
|
||||
'CLAUDE_CODE_URL_EVENT',
|
||||
'CLAUDE_CODE_DEEP_LINK_URL',
|
||||
'CLAUDE_CODE_URL',
|
||||
]) {
|
||||
const value = process.env[key]
|
||||
if (isClaudeUrl(value)) {
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
const arg = process.argv.find(isClaudeUrl)
|
||||
return arg ?? null
|
||||
}
|
||||
|
||||
function isClaudeUrl(value: unknown): value is string {
|
||||
return (
|
||||
typeof value === 'string' &&
|
||||
value.length <= MAX_URL_LENGTH &&
|
||||
(value.startsWith('claude-cli://') || value.startsWith('claude://'))
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user