Skip to content
TypeScript

Stage 1 correctness: best-highlight, REPL resilience, codex harness, parser, Pages

Claudec19f166e739a
diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml
index f5be986..f58f811 100644
--- a/.github/workflows/pages.yml
+++ b/.github/workflows/pages.yml
@@ -1,9 +1,10 @@
name: Pages
+# push 만 트리거 — pull_request 를 함께 걸면 같은 커밋에 두 run 이 생기고, 전역 concurrency 가
+# 하나를 cancel → PR 에 cancelled 체크가 남아 mergeable_state 가 unstable 이 된다.
on:
push:
branches: [main, "claude/**"]
- pull_request:
workflow_dispatch:
permissions:
@@ -12,7 +13,7 @@ permissions:
id-token: write
concurrency:
- group: pages
+ group: pages-${{ github.ref }}
cancel-in-progress: true
jobs:
diff --git a/src/harness.ts b/src/harness.ts
index 8d15152..765a012 100644
--- a/src/harness.ts
+++ b/src/harness.ts
@@ -15,8 +15,10 @@ export type CodexHomeStatus = "none" | "built" | "pending";
const CC_HARNESSES = new Set(["superpowers", "omc", "ecc", "ponytail", "mattpocock"]);
const CODEX_HARNESSES = new Set(["omx", "lazycodex", "omo"]);
-// 멀티모델 에이전트(opencode/openclaw/hermes)에 work_dir materialize 로 적용 가능한 하네스
-const MULTIMODEL_HARNESSES = new Set(["omo", "ponytail", "mattpocock"]);
+// work_dir 에 룰(AGENTS.md/skills)을 materialize 해서 적용 가능한 하네스.
+// 멀티모델 에이전트(opencode/openclaw/hermes) + codex(작업 폴더의 AGENTS.md 를 읽음) 공용 경로.
+// superpowers 포함 — config 가 codex 호환으로 선언한 하네스가 조용히 baseline 으로 돌지 않도록.
+const RULES_HARNESSES = new Set(["omo", "ponytail", "mattpocock", "superpowers"]);
// 하네스 → 플러그인 디렉터리 이름 후보
const PLUGIN_DIR_NAMES: Record<string, string[]> = {
@@ -91,11 +93,11 @@ export function harnessCodexEnv(harness: string): Record<string, string> {
}
/**
- * 멀티모델 에이전트(opencode/openclaw/hermes)에 하네스를 per-run materialize.
+ * 룰형 하네스를 per-run materialize — 멀티모델 에이전트 + codex 공용.
* 룰 캐시가 있으면 AGENTS.md/skills 를 work_dir 로 복사. 반환=적용 여부. 절대 throw 금지.
*/
export function applyHarnessToWorkdir(harness: string, workDir: string): boolean {
- if (harness === "none" || !MULTIMODEL_HARNESSES.has(harness)) return false;
+ if (harness === "none" || !RULES_HARNESSES.has(harness)) return false;
const src = harnessRulesPath(harness);
if (!existsSync(src)) return false;
try {
@@ -124,7 +126,7 @@ export function harnessStatus(harness: string): HarnessStatus {
// cc 플러그인 / codex 홈 / 멀티모델 룰 캐시 중 하나라도 있으면 applied
if (findCcPluginDir(harness)) return "applied";
if (CODEX_HARNESSES.has(harness) && existsSync(codexHomePath(harness))) return "applied";
- if (MULTIMODEL_HARNESSES.has(harness) && existsSync(harnessRulesPath(harness))) return "applied";
+ if (RULES_HARNESSES.has(harness) && existsSync(harnessRulesPath(harness))) return "applied";
return "unavailable";
}
diff --git a/src/install.ts b/src/install.ts
index a56e10d..38bf53a 100644
--- a/src/install.ts
+++ b/src/install.ts
@@ -43,11 +43,12 @@ const CODEX_HARNESS_SRC: Record<string, { src: string; plugin: string }> = {
lazycodex: { src: "lazycodex/marketplace", plugin: "lazycodex" },
omo: { src: "code-yeongyu/oh-my-openagent", plugin: "oh-my-openagent" },
};
-// 멀티모델(opencode/openclaw/hermes) 룰 캐시 소스(repo) — work_dir 로 materialize 됨
+// 룰 캐시 소스(repo) — work_dir 로 materialize 됨(멀티모델 에이전트 + codex 공용 적용 경로)
const MULTIMODEL_HARNESS_SRC: Record<string, { repo: string; install: string }> = {
omo: { repo: "code-yeongyu/oh-my-openagent", install: "bunx oh-my-openagent install" },
ponytail: { repo: "DietrichGebert/ponytail", install: "npx ponytail install" },
mattpocock: { repo: "mattpocock/skills", install: "npx degit mattpocock/skills" },
+ superpowers: { repo: "obra/superpowers", install: "npx degit obra/superpowers" },
};
const ALL_HARNESSES = Object.keys(HARNESSES).filter((h) => h !== "none");
diff --git a/src/orchestrator.ts b/src/orchestrator.ts
index 00187c6..a280666 100644
--- a/src/orchestrator.ts
+++ b/src/orchestrator.ts
@@ -5,7 +5,13 @@
*/
import { readFileSync } from "node:fs";
import { join } from "node:path";
-import { difficultyMap, instructionFor, isLocalBench, taskIds } from "./benches/index";
+import {
+ difficultyMap,
+ instructionFor,
+ isLocalBench,
+ listLocalBenches,
+ taskIds,
+} from "./benches/index";
import { expand, parseComboId } from "./combos";
import { resolveModelAlias } from "./config";
import { buildFlow, renderGraphHtml, writeFlowJson } from "./flow";
@@ -36,7 +42,14 @@ function loadCatalog(bench: string): string[] {
try {
return new TerminalBenchRunner().loadTaskCatalog(bench);
} catch {
- return new MockRunner().loadTaskCatalog(bench);
+ try {
+ return new MockRunner().loadTaskCatalog(bench);
+ } catch {
+ // 폴백까지 실패(미지의 벤치) — 원인/대안이 담긴 명확한 에러 하나로 승격.
+ throw new Error(
+ `unknown bench '${bench}' — available: ${[...listLocalBenches(), "terminal-bench-v2"].join(", ")}`,
+ );
+ }
}
}
diff --git a/src/report.ts b/src/report.ts
index 9286190..64d7e81 100644
--- a/src/report.ts
+++ b/src/report.ts
@@ -613,7 +613,7 @@ export function renderReportHtml(input: ReportInput): string {
return `<!doctype html><html lang="${lang}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>theseus — ${esc(tr(lang, "results_table"))}</title>
<style>
-:root{--sea:${THEME.sea};--seaDeep:${THEME.seaDeep};--hull:${THEME.hull};--sail:${THEME.sail};--rope:${THEME.rope};--foam:${THEME.foam};--ink:${THEME.ink};--mist:${THEME.mist};--grid:${THEME.grid}}
+:root{--sea:${THEME.sea};--seaDeep:${THEME.seaDeep};--hull:${THEME.hull};--sail:${THEME.sail};--rope:${THEME.rope};--foam:${THEME.foam};--ink:${THEME.ink};--mist:${THEME.mist};--grid:${THEME.grid};--best:${THEME.best}}
*{box-sizing:border-box}
body{font-family:ui-sans-serif,system-ui,sans-serif;background:var(--sea);color:var(--ink);margin:0;padding:0;line-height:1.45}
.wrap{max-width:980px;margin:0 auto;padding:20px}
diff --git a/src/runners/codexCli.ts b/src/runners/codexCli.ts
index 5141248..d8832c2 100644
--- a/src/runners/codexCli.ts
+++ b/src/runners/codexCli.ts
@@ -9,7 +9,7 @@ import { join } from "node:path";
import { instructionFor, isLocalBench, setupTask, taskIds, verify } from "../benches/index";
import { parseComboId } from "../combos";
import { resolveModelAlias } from "../config";
-import { harnessCodexEnv } from "../harness";
+import { applyHarnessToWorkdir, harnessCodexEnv } from "../harness";
import type { RawRunArtifact, RunInvocation } from "../models";
import { type RunnerAdapter, RunnerUnavailable } from "./base";
import { commandExists, execCapture } from "./util";
@@ -51,6 +51,9 @@ export class CodexCliRunner implements RunnerAdapter {
];
const env = harnessCodexEnv(harness);
+ // 룰형 하네스(superpowers/ponytail/mattpocock)는 work_dir 에 AGENTS.md 를 materialize —
+ // codex 는 cwd 의 AGENTS.md 를 읽으므로 이것이 실제 적용 경로다(조용한 baseline 방지).
+ applyHarnessToWorkdir(harness, work);
const res = await execCapture("codex", args, { cwd: work, timeoutS: inv.timeoutS, env });
// stdout = thread-event JSONL
diff --git a/src/session.ts b/src/session.ts
index 98235d8..db9302e 100644
--- a/src/session.ts
+++ b/src/session.ts
@@ -442,13 +442,21 @@ export async function runSession(init: { language: Lang; outDir: string }): Prom
for (const l of r.lines) console.log(l);
const a = r.action;
if (a.kind === "exit") break;
- if (a.kind === "run") await doRun(state);
- else if (a.kind === "view") await doView(state, a.open, srv);
- else if (a.kind === "results") {
- const runs = listRuns(state.outDir);
- if (!runs.length) console.log(pc.yellow(` no runs in ${state.outDir}/`));
- // 최근 run 은 report 로 — 여기서는 안내만(상세 표는 /run 직후 출력)
- else console.log(pc.dim(` ${runs.length} run(s); use /view for the gallery`));
+ // REPL 은 어떤 명령이 실패해도 살아남는다 — 에러는 출력하고 프롬프트로 복귀.
+ try {
+ if (a.kind === "run") await doRun(state);
+ else if (a.kind === "view") await doView(state, a.open, srv);
+ else if (a.kind === "results") {
+ const runs = listRuns(state.outDir);
+ if (!runs.length) console.log(pc.yellow(` no runs in ${state.outDir}/`));
+ // 최근 run 은 report 로 — 여기서는 안내만(상세 표는 /run 직후 출력)
+ else console.log(pc.dim(` ${runs.length} run(s); use /view for the gallery`));
+ }
+ } catch (e) {
+ console.log(pc.red(` ${a.kind} failed: ${(e as Error).message}`));
+ if (a.kind === "view" && /EADDRINUSE/.test(String(e))) {
+ console.log(pc.dim(` port ${state.port} is busy — the gallery may already be running`));
+ }
}
}
diff --git a/src/transcripts/defensive.ts b/src/transcripts/defensive.ts
index 16b16ae..4d804ed 100644
--- a/src/transcripts/defensive.ts
+++ b/src/transcripts/defensive.ts
@@ -35,10 +35,20 @@ const TOKEN_KEYS: Record<string, keyof Pick<Acc, "in" | "out" | "cr" | "cc">> =
const TOOL_TYPE_RE = /tool|command|item\.completed|file_change|step/i;
const SUBAGENT_RE = /\b(task|subagent)\b/i;
-function scan(node: unknown, acc: Acc, depth = 0): void {
+/**
+ * anc — 조상 노드가 이미 도구 이벤트로 집계됐는지. 래퍼({type:"item.completed", item:{type:"command_…"}})
+ * 안의 중첩 객체는 같은 논리 이벤트의 상세이므로 toolCalls 를 다시 세지 않는다(이중 집계 방지).
+ * 단, 조상이 서브에이전트로 안 잡힌 경우 중첩 마커의 subagent 판정은 1회 허용(포착 누락 방지).
+ */
+function scan(
+ node: unknown,
+ acc: Acc,
+ depth = 0,
+ anc: { counted: boolean; sub: boolean } = { counted: false, sub: false },
+): void {
if (depth > 8 || node === null || typeof node !== "object") return;
if (Array.isArray(node)) {
- for (const v of node) scan(v, acc, depth + 1);
+ for (const v of node) scan(v, acc, depth + 1, anc);
return;
}
const obj = node as Record<string, unknown>;
@@ -55,14 +65,21 @@ function scan(node: unknown, acc: Acc, depth = 0): void {
const type = typeof obj.type === "string" ? (obj.type as string) : "";
const name = typeof obj.name === "string" ? (obj.name as string) : "";
const isSub = SUBAGENT_RE.test(type) || SUBAGENT_RE.test(name);
- if ((type && TOOL_TYPE_RE.test(type)) || isSub) {
+ const matched = (type !== "" && TOOL_TYPE_RE.test(type)) || isSub;
+ let next = anc;
+ if (matched && !anc.counted) {
acc.toolCalls += 1;
acc.tools.push(name || type);
acc.steps.push(name || type);
if (isSub) acc.subagents += 1;
if (isMcp(name) || isMcp(type)) acc.mcp += 1;
+ next = { counted: true, sub: isSub };
+ } else if (matched && anc.counted && isSub && !anc.sub) {
+ // 래퍼는 일반 도구로 집계됐지만 안쪽이 서브에이전트 마커 — 판정만 승격(중복 toolCall 없음).
+ acc.subagents += 1;
+ next = { counted: true, sub: true };
}
- for (const v of Object.values(obj)) scan(v, acc, depth + 1);
+ for (const v of Object.values(obj)) scan(v, acc, depth + 1, next);
}
export class DefensiveParser implements TranscriptParser {