feat: 品牌替换 + 启动优化 + AGENTS.md 模板定制
- 品牌替换:OpenCode/opencode → AirCoding/aircoding(16+ 文件) - Logo ASCII art:修复 left/right 行数不匹配导致的启动崩溃 - 启动诊断:添加 OPENCODE_PRINT_TIMING 计时探针 - dev 模式默认 --pure 跳过外部插件加载 - AGENTS.md 模板:追加 AirCoding 多 Agent 专项段落 - architect prompt + plugin:强化 AGENTS.md 产出验证
This commit is contained in:
65
packages/sdk/js/script/build.ts
Executable file
65
packages/sdk/js/script/build.ts
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bun
|
||||
import { fileURLToPath } from "url"
|
||||
|
||||
const dir = fileURLToPath(new URL("..", import.meta.url))
|
||||
process.chdir(dir)
|
||||
|
||||
import { $ } from "bun"
|
||||
import path from "path"
|
||||
|
||||
import { createClient } from "@hey-api/openapi-ts"
|
||||
|
||||
const opencode = path.resolve(dir, "../../opencode")
|
||||
|
||||
await $`bun dev generate > ${dir}/openapi.json`.cwd(opencode)
|
||||
|
||||
await createClient({
|
||||
input: "./openapi.json",
|
||||
output: {
|
||||
path: "./src/v2/gen",
|
||||
tsConfigPath: path.join(dir, "tsconfig.json"),
|
||||
clean: true,
|
||||
},
|
||||
plugins: [
|
||||
{
|
||||
name: "@hey-api/typescript",
|
||||
exportFromIndex: false,
|
||||
},
|
||||
{
|
||||
name: "@hey-api/sdk",
|
||||
instance: "OpencodeClient",
|
||||
exportFromIndex: false,
|
||||
auth: false,
|
||||
paramsStructure: "flat",
|
||||
},
|
||||
{
|
||||
name: "@hey-api/client-fetch",
|
||||
exportFromIndex: false,
|
||||
baseUrl: "http://localhost:4096",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
// Patch a @hey-api/openapi-ts codegen bug: SseFn incorrectly passes the
|
||||
// endpoint's TError into the second generic of ServerSentEventsResult, which
|
||||
// is the AsyncGenerator's TReturn slot. Iterator return values have nothing
|
||||
// to do with HTTP errors, and any consumer that calls `.return()` or returns
|
||||
// from a mock generator gets type-checked against the wrong shape. Drop the
|
||||
// arg so TReturn defaults to void.
|
||||
const sseTypesPath = "./src/v2/gen/client/types.gen.ts"
|
||||
const sseTypesFile = Bun.file(sseTypesPath)
|
||||
const sseTypesSource = await sseTypesFile.text()
|
||||
const sseTypesPatched = sseTypesSource.replace(
|
||||
"=> Promise<ServerSentEventsResult<TData, TError>>",
|
||||
"=> Promise<ServerSentEventsResult<TData>>",
|
||||
)
|
||||
if (sseTypesPatched === sseTypesSource) {
|
||||
throw new Error(`SseFn patch did not apply; @hey-api/openapi-ts output may have changed (${sseTypesPath})`)
|
||||
}
|
||||
await Bun.write(sseTypesPath, sseTypesPatched)
|
||||
|
||||
await $`bun prettier --write src/gen`
|
||||
await $`bun prettier --write src/v2`
|
||||
await $`rm -rf dist`
|
||||
await $`bun tsc`
|
||||
await $`rm openapi.json`
|
||||
Reference in New Issue
Block a user