commit 4c1686b5f8250da4f5f0f2017c8c75420e3ec687 Author: Heretek-OpenCode Coordinator Date: Mon Oct 12 12:33:32 2026 -0400 chore: initialize Heretek-OpenCode greenfield monorepo with seed contracts diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d5427db --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules/ +dist/ +worktrees/ +*.log +.DS_Store diff --git a/package.json b/package.json new file mode 100644 index 0000000..a70396d --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "heretek-opencode-monorepo", + "private": true, + "workspaces": [ + "packages/*", + "packages/opencode-packs/packs/*" + ], + "scripts": { + "check": "bunx oxlint && bunx tsc --noEmit", + "test": "bun test" + }, + "devDependencies": { + "@types/node": "^22.0.0", + "oxlint": "^0.15.0", + "typescript": "^5.5.0", + "zod": "^3.23.8" + } +} diff --git a/packages/opencode-sdk/src/contracts.ts b/packages/opencode-sdk/src/contracts.ts new file mode 100644 index 0000000..04ef28d --- /dev/null +++ b/packages/opencode-sdk/src/contracts.ts @@ -0,0 +1,55 @@ +import { z } from "zod"; + +export const CriterionSchema = z.object({ + id: z.string(), + text: z.string(), + verify: z.enum(["cmd", "judge", "human"]), + status: z.enum(["unmet", "met", "waived_by_human"]), +}); + +export const TaskSchema = z.object({ + id: z.string(), + missionId: z.string(), + stage: z.enum(["grill", "research", "spec", "build", "qa_functional", "qa_adversarial", "human_pr"]), + state: z.enum(["pending", "ready", "running", "waiting_human", "done", "failed", "cancelled"]), + deps: z.array(z.string()), + lane: z.enum(["bwrap", "docker", "dagger"]), + branch: z.string(), + attempts: z.number().default(0), + budget: z.object({ maxDiffLines: z.number(), maxDurationMinutes: z.number() }), +}); + +export const MissionSchema = z.object({ + id: z.string(), + intent: z.string(), + acceptance: z.array(CriterionSchema), + state: z.enum(["pending", "active", "blocked", "done", "failed", "cancelled"]), +}); + +export const GateReportSchema = z.object({ + taskId: z.string(), + commit: z.string(), + runnerVersion: z.string(), + startedAt: z.string(), + durationMs: z.number(), + verdict: z.enum(["pass", "fail", "timeout"]), + checks: z.array(z.object({ + id: z.string(), + exit: z.number(), + durationMs: z.number(), + outputHash: z.string(), + })), + budget: z.object({ diffLines: z.number(), limit: z.number() }), +}); + +export const MCPToolDefSchema = z.object({ + name: z.string(), + description: z.string(), + inputSchema: z.record(z.any()), +}); + +export type Criterion = z.infer; +export type Task = z.infer; +export type Mission = z.infer; +export type GateReport = z.infer; +export type MCPToolDef = z.infer; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..1e5ccaf --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "Bundler", + "strict": true, + "skipLibCheck": true, + "esModuleInterop": true, + "resolveJsonModule": true, + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "outDir": "dist", + "types": ["node"] + }, + "include": ["packages/*/src/**/*", "packages/*/test/**/*", "packages/opencode-packs/packs/*/src/**/*"], + "exclude": ["node_modules", "dist", "worktrees"] +}