feat(aircoding): AirCoding V2 baseline — deterministic multi-agent architecture

Forked from OpenCode v1.17.4 with multi-agent system:
- 5 agents: aircoding, scheduler, worker, architect, reviewer
- Deterministic DAG scheduling engine (coordinator_tick)
- Tool whitelists as hard enforcement
- AirCoding validation plugin
- V1 requirements: C4 docs, ADR, AGENTS.md, debug-log.md
- Design documents in docs/
This commit is contained in:
airlongdian
2026-06-13 21:53:43 +08:00
commit deaf7eb806
5757 changed files with 1169969 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bun
import { $ } from "bun"
import { readdir, rm } from "node:fs/promises"
await rm("dist", { recursive: true, force: true })
await $`bunx tsc --emitDeclarationOnly`
const build = await Bun.build({
entrypoints: ["src/index.ts"],
outdir: "dist",
target: "node",
format: "esm",
packages: "external",
})
if (!build.success) throw new AggregateError(build.logs, "Failed to build @opencode-ai/http-recorder")
const publicFiles = new Set(["index.js", "index.d.ts", "effect.d.ts", "socket.d.ts", "types.d.ts"])
await Promise.all(
(await readdir("dist")).filter((file) => !publicFiles.has(file)).map((file) => rm(`dist/${file}`, { force: true })),
)

View File

@@ -0,0 +1,35 @@
#!/usr/bin/env bun
import { $ } from "bun"
import { fileURLToPath } from "node:url"
const dir = fileURLToPath(new URL("..", import.meta.url))
export const pack = async () => {
process.chdir(dir)
await $`bun run build`
const original = await Bun.file("package.json").text()
// oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- package.json is validated by the package schema and build checks.
const pkg = JSON.parse(original) as {
readonly version: string
exports: Record<string, string | { readonly import: string; readonly types: string }>
}
for (const [key, value] of Object.entries(pkg.exports)) {
if (key === "./internal") {
delete pkg.exports[key]
continue
}
if (typeof value !== "string") continue
const file = value.replace("./src/", "./dist/").replace(/\.ts$/, "")
pkg.exports[key] = { import: `${file}.js`, types: `${file}.d.ts` }
}
await Bun.write("package.json", JSON.stringify(pkg, null, 2))
try {
await $`bun pm pack`
return fileURLToPath(new URL(`../opencode-ai-http-recorder-${pkg.version}.tgz`, import.meta.url))
} finally {
await Bun.write("package.json", original)
}
}
if (import.meta.main) await pack()

View File

@@ -0,0 +1,75 @@
#!/usr/bin/env bun
import { mkdtemp, rm, writeFile } from "node:fs/promises"
import { tmpdir } from "node:os"
import path from "node:path"
import { pack } from "./pack.js"
const run = async (command: ReadonlyArray<string>, cwd: string) => {
const process = Bun.spawn(command, { cwd, env: globalThis.process.env, stdout: "inherit", stderr: "inherit" })
const exitCode = await process.exited
if (exitCode !== 0) throw new Error(`${command.join(" ")} exited with code ${exitCode}`)
}
export const verifyPackage = async (archive: string) => {
const directory = await mkdtemp(path.join(tmpdir(), "http-recorder-consumer-"))
try {
await writeFile(
path.join(directory, "package.json"),
JSON.stringify({ name: "http-recorder-consumer", private: true, type: "module" }),
)
await writeFile(
path.join(directory, "consumer.ts"),
`import { HttpRecorder } from "@opencode-ai/http-recorder"
import { NodeSocket } from "@effect/platform-node"
import { Layer } from "effect"
import { HttpClient } from "effect/unstable/http"
import { Socket } from "effect/unstable/socket"
const options: HttpRecorder.RecorderOptions = { redact: { jsonFields: ["access_token"] } }
HttpRecorder.http("consumer", options) satisfies Layer.Layer<HttpClient.HttpClient>
HttpRecorder.socket("consumer/socket", options).pipe(
Layer.provide(NodeSocket.layerWebSocket("wss://example.test")),
) satisfies Layer.Layer<Socket.Socket>
`,
)
await writeFile(
path.join(directory, "tsconfig.json"),
JSON.stringify({
compilerOptions: {
target: "ES2022",
module: "NodeNext",
moduleResolution: "NodeNext",
strict: true,
noEmit: true,
// Required by effect@4.0.0-beta.74: its schema.d.ts references an undeclared SchemaErrorTypeId.
skipLibCheck: true,
lib: ["ES2022", "DOM", "ESNext.Disposable"],
},
include: ["consumer.ts"],
}),
)
await run(["npm", "install", archive, "typescript@5.8.2"], directory)
await run(
[
"node",
"--input-type=module",
"-e",
'import("@opencode-ai/http-recorder").then((module) => { const root = Object.keys(module).sort(); const namespace = Object.keys(module.HttpRecorder).sort(); if (JSON.stringify(root) !== JSON.stringify(["HttpRecorder"])) throw new Error(`Unexpected root exports: ${root}`); if (JSON.stringify(namespace) !== JSON.stringify(["http", "socket"])) throw new Error(`Unexpected namespace exports: ${namespace}`) })',
],
directory,
)
await run([path.join(directory, "node_modules", ".bin", "tsc"), "--noEmit"], directory)
} finally {
await rm(directory, { recursive: true, force: true })
}
}
if (import.meta.main) {
const archive = await pack()
try {
await verifyPackage(archive)
} finally {
await Bun.file(archive).delete()
}
}