mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-06-24 00:51:27 +08:00
feat(opencode): 全面升级OpenCode集成 (#2251)
- 修复ecc-hooks.ts中的硬编码ECC_VERSION(从package.json读取) - 改进错误处理机制(统一模式、详细错误信息) - 增强类型安全(添加ToolArgs、ToolInput等类型定义) - 改进跨平台兼容性(支持macOS、Windows、Linux) - 添加dependency-analyzer工具(依赖分析) - 改进format-code工具(错误处理、跨平台支持) - 改进lint-check工具(错误处理、跨平台支持) - 更新文档(代理26个、工具8个、命令26个) - 添加工具测试(6个测试用例) - 改进现有测试(7个测试用例) 所有测试通过(16/16) Co-authored-by: Pual-LI-6 <dj2112236494@outlook.com>
This commit is contained in:
committed by
GitHub
parent
e53b4d9e39
commit
3a08b0c7a8
@@ -100,6 +100,9 @@ async function main() {
|
||||
assert.strictEqual(env.PACKAGE_MANAGER, "pnpm")
|
||||
assert.strictEqual(env.DETECTED_LANGUAGES, "typescript,python")
|
||||
assert.strictEqual(env.PRIMARY_LANGUAGE, "typescript")
|
||||
// Verify ECC_VERSION is not hardcoded
|
||||
assert.ok(env.ECC_VERSION !== "1.8.0", "ECC_VERSION should not be hardcoded to 1.8.0")
|
||||
assert.ok(env.ECC_VERSION.match(/^\d+\.\d+\.\d+$/), "ECC_VERSION should be a valid semver version")
|
||||
}
|
||||
),
|
||||
],
|
||||
@@ -165,6 +168,84 @@ async function main() {
|
||||
}
|
||||
},
|
||||
],
|
||||
[
|
||||
"permission.ask handles read-only tools correctly",
|
||||
async () => withTempProject(
|
||||
[],
|
||||
async (projectDir) => {
|
||||
const client = createClient()
|
||||
const $ = createFailingShell()
|
||||
const hooks = await ECCHooksPlugin({ client, $, directory: projectDir })
|
||||
|
||||
// Test read-only tools
|
||||
const readResult = await hooks["permission.ask"]({ tool: "read", args: {} })
|
||||
assert.strictEqual(readResult.approved, true)
|
||||
assert.strictEqual(readResult.reason, "Read-only operation")
|
||||
|
||||
const globResult = await hooks["permission.ask"]({ tool: "glob", args: {} })
|
||||
assert.strictEqual(globResult.approved, true)
|
||||
assert.strictEqual(globResult.reason, "Read-only operation")
|
||||
|
||||
const grepResult = await hooks["permission.ask"]({ tool: "grep", args: {} })
|
||||
assert.strictEqual(grepResult.approved, true)
|
||||
assert.strictEqual(grepResult.reason, "Read-only operation")
|
||||
}
|
||||
),
|
||||
],
|
||||
[
|
||||
"permission.ask handles formatters correctly",
|
||||
async () => withTempProject(
|
||||
[],
|
||||
async (projectDir) => {
|
||||
const client = createClient()
|
||||
const $ = createFailingShell()
|
||||
const hooks = await ECCHooksPlugin({ client, $, directory: projectDir })
|
||||
|
||||
// Test formatter tools - note: args should be the command string, not object
|
||||
const prettierResult = await hooks["permission.ask"]({
|
||||
tool: "bash",
|
||||
args: "npx prettier --write src/index.ts"
|
||||
})
|
||||
console.log("prettierResult:", JSON.stringify(prettierResult))
|
||||
assert.strictEqual(prettierResult.approved, true)
|
||||
assert.strictEqual(prettierResult.reason, "Formatter execution")
|
||||
|
||||
const biomeResult = await hooks["permission.ask"]({
|
||||
tool: "bash",
|
||||
args: "npx @biomejs/biome format --write src/index.ts"
|
||||
})
|
||||
console.log("biomeResult:", JSON.stringify(biomeResult))
|
||||
assert.strictEqual(biomeResult.approved, true)
|
||||
assert.strictEqual(biomeResult.reason, "Formatter execution")
|
||||
}
|
||||
),
|
||||
],
|
||||
[
|
||||
"permission.ask handles test execution correctly",
|
||||
async () => withTempProject(
|
||||
[],
|
||||
async (projectDir) => {
|
||||
const client = createClient()
|
||||
const $ = createFailingShell()
|
||||
const hooks = await ECCHooksPlugin({ client, $, directory: projectDir })
|
||||
|
||||
// Test test execution tools
|
||||
const npmTestResult = await hooks["permission.ask"]({
|
||||
tool: "bash",
|
||||
args: { command: "npm test" }
|
||||
})
|
||||
assert.strictEqual(npmTestResult.approved, true)
|
||||
assert.strictEqual(npmTestResult.reason, "Test execution")
|
||||
|
||||
const vitestResult = await hooks["permission.ask"]({
|
||||
tool: "bash",
|
||||
args: { command: "npx vitest run" }
|
||||
})
|
||||
assert.strictEqual(vitestResult.approved, true)
|
||||
assert.strictEqual(vitestResult.reason, "Test execution")
|
||||
}
|
||||
),
|
||||
],
|
||||
]
|
||||
|
||||
let passed = 0
|
||||
|
||||
Reference in New Issue
Block a user