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:
15
packages/script/package.json
Normal file
15
packages/script/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package",
|
||||
"name": "@opencode-ai/script",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"semver": "^7.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "catalog:",
|
||||
"@types/semver": "^7.5.8"
|
||||
},
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
}
|
||||
}
|
||||
77
packages/script/src/index.ts
Normal file
77
packages/script/src/index.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import { $ } from "bun"
|
||||
import semver from "semver"
|
||||
import path from "path"
|
||||
|
||||
const rootPkgPath = path.resolve(import.meta.dir, "../../../package.json")
|
||||
const rootPkg = await Bun.file(rootPkgPath).json()
|
||||
const expectedBunVersion = rootPkg.packageManager?.split("@")[1]
|
||||
|
||||
if (!expectedBunVersion) {
|
||||
throw new Error("packageManager field not found in root package.json")
|
||||
}
|
||||
|
||||
// relax version requirement
|
||||
const expectedBunVersionRange = `^${expectedBunVersion}`
|
||||
|
||||
if (!semver.satisfies(process.versions.bun, expectedBunVersionRange)) {
|
||||
throw new Error(`This script requires bun@${expectedBunVersionRange}, but you are using bun@${process.versions.bun}`)
|
||||
}
|
||||
|
||||
const env = {
|
||||
OPENCODE_CHANNEL: process.env["OPENCODE_CHANNEL"],
|
||||
OPENCODE_BUMP: process.env["OPENCODE_BUMP"],
|
||||
OPENCODE_VERSION: process.env["OPENCODE_VERSION"],
|
||||
OPENCODE_RELEASE: process.env["OPENCODE_RELEASE"],
|
||||
}
|
||||
const CHANNEL = await (async () => {
|
||||
if (env.OPENCODE_CHANNEL) return env.OPENCODE_CHANNEL
|
||||
if (env.OPENCODE_BUMP) return "latest"
|
||||
if (env.OPENCODE_VERSION && !env.OPENCODE_VERSION.startsWith("0.0.0-")) return "latest"
|
||||
return await $`git branch --show-current`.text().then((x) => x.trim())
|
||||
})()
|
||||
const IS_PREVIEW = CHANNEL !== "latest"
|
||||
|
||||
const VERSION = await (async () => {
|
||||
if (env.OPENCODE_VERSION) return env.OPENCODE_VERSION
|
||||
if (IS_PREVIEW) return `0.0.0-${CHANNEL}-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}`
|
||||
const version = await fetch("https://registry.npmjs.org/opencode-ai/latest")
|
||||
.then((res) => {
|
||||
if (!res.ok) throw new Error(res.statusText)
|
||||
return res.json()
|
||||
})
|
||||
.then((data: any) => data.version)
|
||||
const [major, minor, patch] = version.split(".").map((x: string) => Number(x) || 0)
|
||||
const t = env.OPENCODE_BUMP?.toLowerCase()
|
||||
if (t === "major") return `${major + 1}.0.0`
|
||||
if (t === "minor") return `${major}.${minor + 1}.0`
|
||||
return `${major}.${minor}.${patch + 1}`
|
||||
})()
|
||||
|
||||
const bot = ["actions-user", "opencode", "opencode-agent[bot]"]
|
||||
const teamPath = path.resolve(import.meta.dir, "../../../.github/TEAM_MEMBERS")
|
||||
const team = [
|
||||
...(await Bun.file(teamPath)
|
||||
.text()
|
||||
.then((x) => x.split(/\r?\n/).map((x) => x.trim()))
|
||||
.then((x) => x.filter((x) => x && !x.startsWith("#")))),
|
||||
...bot,
|
||||
]
|
||||
|
||||
export const Script = {
|
||||
get channel() {
|
||||
return CHANNEL
|
||||
},
|
||||
get version() {
|
||||
return VERSION
|
||||
},
|
||||
get preview() {
|
||||
return IS_PREVIEW
|
||||
},
|
||||
get release(): boolean {
|
||||
return !!env.OPENCODE_RELEASE
|
||||
},
|
||||
get team() {
|
||||
return team
|
||||
},
|
||||
}
|
||||
console.log(`opencode script`, JSON.stringify(Script, null, 2))
|
||||
10
packages/script/sst-env.d.ts
vendored
Normal file
10
packages/script/sst-env.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/* This file is auto-generated by SST. Do not edit. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/* deno-fmt-ignore-file */
|
||||
/* biome-ignore-all lint: auto-generated */
|
||||
|
||||
/// <reference path="../../sst-env.d.ts" />
|
||||
|
||||
import "sst"
|
||||
export {}
|
||||
8
packages/script/tsconfig.json
Normal file
8
packages/script/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"extends": "@tsconfig/bun/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
||||
"noUncheckedIndexedAccess": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user