xharness AGENTS.md

A development guide for xharness, a project that provides both a command-line coding-agent engine and an Electron desktop interface.

In plain words
What is it for?
Use it when building, testing, debugging, packaging, or changing the CLI and desktop application.
Why use it?
It explains the commands, build steps, testing requirements, and separation between the engine and graphical interface, reducing mistakes such as changing code without rebuilding it.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/linearuncle/xharness/agents-md
Clone the repo
git clone --depth 1 https://github.com/linearuncle/xharness

Made for: Codex, OpenCode.

Per session 3,406 This file is loaded in full into every session.
When invoked 3,406 The same file — it is already loaded in full.
Security scan B 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.03406 $0.03406
Opus 5 $0.01703 $0.01703
Sonnet 5 $0.00681 $0.00681
Haiku 4.5 $0.00341 $0.00341

Measured 2d ago against content hash 8c4893456cc1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

xharness AGENTS.md scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootmediumPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

WAL 模式,三个库文件均 chmod 600——侧车不继承主库权限,openDb 时补 chmod)。
AGENTS.md · 165 lines

How it starts

The opening of the file, as written. The whole thing — 165 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

常用命令

npm run build                 # tsc 编译 src/ → dist/(GUI 依赖 dist,改核心后必须重建)
npx tsc --noEmit              # 类型检查
npm test                      # 单测(vitest unit project,API 全 mock,不耗 token)
npx vitest run --project unit test/unit/loop.test.ts   # 跑单个测试文件
npm run test:e2e              # E2E(先 build;需 ANTHROPIC_API_KEY/DEEPSEEK_API_KEY,无 key 整体 skip)
node dist/index.js -p "..."   # CLI 一次性模式(冒烟最快路径)

cd gui && npm start                        # 启动 Electron GUI(dev)
cd gui && node scripts/package-app.mjs     # 打包 release/xharness.app + mac-<arch>.zip

杀 GUI 进程用 pkill -f "MacOS/xharness"(Electron bundle 已被 postinstall 改名为 xharness.app,匹配 "Electron" 会失手)。GUI 调试/测试走 CDP (--remote-debugging-port=9223 + 原生 WebSocket 直连,gui/scripts/cdp-eval.mjs 驱动),完整方案与标准冒烟检查见 docs/cdp-testing.md

仓库形态

两个交付物,一个引擎:

  • CLIsrc/dist/,Node >= 22,ESM):终端 REPL / -p 一次性模式。
  • GUIgui/,Electron):不复制引擎代码,主进程直接 import "../dist/..."。 改 src/ 后不 npm run build,GUI 看不到变化。

GOAL.md 是产品规格(含各条设计决策与变更日期);docs/internal/ 是开发过程记录 (GoalBuddy 任务板、评审报告),改代码前有疑义先查 GOAL.md 对应条目。

核心架构与硬约束

分层铁律(违反即错,评审按此核对)

  • src/api/唯一接触供应商 SDK 与原始流事件的层,对外只发归一化领域事件 (text_delta | thinking_delta | tool_start | tool_end | error | turn_end): client.ts = 接口 + 共享重试/流聚合 + 按 config.apiFormat 分发; anthropic.ts = Messages 格式(唯一碰 @anthropic-ai/sdk); responses.ts = OpenAI Response 格式(零依赖 fetch+SSE,翻译成 RawStreamEvent 复用聚合)。
  • src/agent/loop.ts 只做回合编排:不碰 SDK、不读 process.env、不解析原始流、不内联压缩。
  • src/ui/render.ts 只消费领域事件。
  • src/config.tsloadConfig() 是全项目唯一 process.env 读取点。
  • 工具(src/tools/)只做副作用与返回,不感知会话状态;异常一律转 isError:true 的 ToolResult,不外抛。registry 禁止按工具名写特殊分支。

不变量:tool_use / tool_result 配对

history 中每个 tool_use 必须有配对 tool_result,否则官方 Anthropic 端点直接 400。 所有取舍(中断、上限 200 触顶、AskUserQuestion 被 SIGINT/EOF 打断)都用 is_error 占位块回填来保住配对——修改 loop/中断路径时此约束优先于其他一切语义。 单测里有 expectAllToolUsesPaired 辅助断言,改动相关逻辑必须覆盖。

Read the full file on GitHub · 165 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 165 lines · 3,406 tokens per session scan B 8c4893456cc1

Subscribe to this mod's changes

xharness AGENTS.md is an instructions file published in the GitHub repository linearuncle/xharness (10 stars, last pushed 29d ago), licensed MIT. It adds 3,406 tokens to every session, about $0.0170 per session on Opus 5. A static security scan graded it B with 1 finding (asks for root). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.