- 品牌替换:OpenCode/opencode → AirCoding/aircoding(16+ 文件) - Logo ASCII art:修复 left/right 行数不匹配导致的启动崩溃 - 启动诊断:添加 OPENCODE_PRINT_TIMING 计时探针 - dev 模式默认 --pure 跳过外部插件加载 - AGENTS.md 模板:追加 AirCoding 多 Agent 专项段落 - architect prompt + plugin:强化 AGENTS.md 产出验证
50 lines
1.8 KiB
TypeScript
50 lines
1.8 KiB
TypeScript
import { execFile } from "child_process"
|
|
import fs from "fs/promises"
|
|
import path from "path"
|
|
import { promisify } from "util"
|
|
import { pathToFileURL } from "url"
|
|
import { Repository } from "@opencode-ai/core/repository"
|
|
|
|
const exec = promisify(execFile)
|
|
|
|
export async function gitRemote(root: string) {
|
|
const origin = path.join(root, "origin.git")
|
|
const source = path.join(root, "source")
|
|
await git(root, "init", "--bare", origin)
|
|
await git(root, "init", source)
|
|
await git(source, "config", "user.email", "test@example.com")
|
|
await git(source, "config", "user.name", "Test")
|
|
await fs.writeFile(path.join(source, "README.md"), "one\n")
|
|
await git(source, "add", "README.md")
|
|
await git(source, "commit", "-m", "initial")
|
|
await git(source, "branch", "-M", "main")
|
|
await git(source, "remote", "add", "origin", pathToFileURL(origin).href)
|
|
await git(source, "push", "-u", "origin", "main")
|
|
await git(root, "--git-dir", origin, "symbolic-ref", "HEAD", "refs/heads/main")
|
|
return {
|
|
root,
|
|
source,
|
|
remote: pathToFileURL(origin).href,
|
|
reference: { ...Repository.parseRemote("owner/repo"), remote: pathToFileURL(origin).href },
|
|
}
|
|
}
|
|
|
|
export async function commit(source: string, content: string, message: string) {
|
|
await fs.writeFile(path.join(source, "README.md"), content)
|
|
await git(source, "add", "README.md")
|
|
await git(source, "commit", "-m", message)
|
|
await git(source, "push")
|
|
}
|
|
|
|
export async function branch(source: string, name: string, content: string) {
|
|
await git(source, "checkout", "-b", name)
|
|
await fs.writeFile(path.join(source, "README.md"), content)
|
|
await git(source, "add", "README.md")
|
|
await git(source, "commit", "-m", name)
|
|
await git(source, "push", "-u", "origin", name)
|
|
}
|
|
|
|
export async function git(cwd: string, ...args: string[]) {
|
|
await exec("git", args, { cwd })
|
|
}
|