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:
airlongdian
2026-06-14 09:31:29 +08:00
commit e2fd375a1c
5757 changed files with 1170016 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
import { describe, expect, test } from "bun:test"
import path from "path"
import { pathToFileURL } from "url"
import { Repository } from "@opencode-ai/core/repository"
describe("Repository", () => {
test("parses github shorthand and builds an explicit-root cache path", () => {
const reference = Repository.parseRemote("owner/repo")
expect(reference).toMatchObject({
host: "github.com",
path: "owner/repo",
segments: ["owner", "repo"],
owner: "owner",
repo: "repo",
remote: "https://github.com/owner/repo.git",
label: "owner/repo",
})
expect(Repository.cachePath("/cache", reference)).toBe(path.join("/cache", "github.com", "owner", "repo"))
expect(Repository.cacheIdentity(reference)).toBe("github.com/owner/repo")
})
test("parses host path and scp remote references", () => {
expect(Repository.parseRemote("gitlab.com/group/repo")).toMatchObject({
host: "gitlab.com",
path: "group/repo",
remote: "https://gitlab.com/group/repo.git",
label: "gitlab.com/group/repo",
})
expect(Repository.parseRemote("git@github.com:owner/repo.git")).toMatchObject({
host: "github.com",
path: "owner/repo",
remote: "git@github.com:owner/repo.git",
label: "owner/repo",
})
})
test("keeps local file repositories distinct from remote repositories", () => {
const localPath = path.resolve("repo.git")
const reference = Repository.parse(pathToFileURL(localPath).href)
expect(reference).toMatchObject({ host: "file", protocol: "file:", label: localPath })
expect(reference && Repository.isFile(reference)).toBe(true)
expect(reference && Repository.isRemote(reference)).toBe(false)
expect(() => Repository.parseRemote(pathToFileURL(localPath).href)).toThrow(
Repository.UnsupportedLocalRepositoryError,
)
})
test("rejects unsafe remote references and branches with typed errors", () => {
expect(() => Repository.parseRemote("not-a-repo")).toThrow(Repository.InvalidReferenceError)
expect(() => Repository.parseRemote("git@github.com:../../../etc/passwd")).toThrow(Repository.InvalidReferenceError)
expect(() => Repository.validateBranch("feature/docs.v1")).not.toThrow()
expect(() => Repository.validateBranch("-bad")).toThrow(Repository.InvalidBranchError)
expect(() => Repository.validateBranch("bad..branch")).toThrow(Repository.InvalidBranchError)
expect(() => Repository.validateBranch("bad branch")).toThrow(Repository.InvalidBranchError)
})
test("compares cache identity independent of input spelling", () => {
const shorthand = Repository.parseRemote("owner/repo")
expect(Repository.same(shorthand, Repository.parseRemote("https://github.com/owner/repo.git"))).toBe(true)
expect(Repository.same(shorthand, Repository.parseRemote("github.com/owner/repo"))).toBe(true)
})
})