Skip to content
项目

karamage/cc-harness-studio

在 GitHub 查看

关于

An integrated design, wiring, simulation, and verification studio for autonomous AI harnesses.

人工智能与机器学习

这些数字如何统计

实测星标增长

24小时
0
7天
正在收集历史
15天
正在收集历史
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文
CC Harness Studio logo

CC Harness Studio

Sharpen Your Harness Design.

Tired of hand-editing scattered AGENTS.md, skills, and fragile hooks?

I built an integrated design, wiring, simulation, and verification studio for autonomous AI harnesses.

It parses your repository's Markdown, JSON, and scripts into a single Unified Harness Graph IR so you can visually wire agents, simulate context token budgets, compile autonomous loops, and test deterministic guardrails — with zero lock-in.

Features Install Usage Develop

CI macOS 13+ Rust React 19 XYFlow v12 Claude Code optional MIT License

Website · Try Simulator in Browser · 日本語の README はこちら · Architecture Plan (JA)

⭐ If it helps you build more reliable AI harnesses, a star helps other engineers find it.
Follow @kara_mage on X for early access to our products.

CC Harness Studio — Sharpen Your Harness Design. Visual topology, bounded loops, context budgets & deterministic hooks.

[!TIP] CC Harness Studio stores no proprietary database and no Claude credentials. Every design compiles cleanly back to standard Git-native files (AGENTS.md, CLAUDE.md, .claude/**, .mcp.json, .harness/**). Static diagnostics, context simulation, hook testbench, and workflow compilation work 100% locally offline — claude CLI is only needed when you run optional AI audit/co-design tasks.

[!NOTE] This is an independent project, not affiliated with, endorsed by, or sponsored by Anthropic. Claude is a trademark of Anthropic, PBC.

🌟 Overview

Building an autonomous AI coding system is not about writing one big Markdown file. It is about meshing five gears together — Context Hierarchy, Capability Bundles (Skills + Scripts + MCP), Role-Isolated Subagents, Bounded Autonomous Loops, and Deterministic Guardrails (Hooks & Permissions) — so the agent finishes the task without drifting or breaking invariants.

CC Harness Studio reads all of those scattered repository assets into a single Unified Harness Graph IR (hc-core) and gives you a fast, dark-mode studio (as a ~6.7 MB native macOS .app, a local Web Studio server, or a headless CI CLI) to design, wire, simulate, compile, and verify your harness before an AI ever touches production code.

🆚 How it differs

CC Harness Studio Hand-editing .md & .json Cloud agent builders (Dify / LangGraph Cloud)
Source of truth Git-native standard files (AGENTS.md, .claude/**, .harness/**) Git-native files, scattered across folders Vendor database / proprietary YAML
Wiring & overview Interactive 5-lane Topology Canvas with drag-to-wire & live diagnostics Mental model only; broken @import and orphan skills go unnoticed Visual graph, but disconnected from Claude Code / Codex repos
Natural-language rules vs Hooks Soft-to-Hard Compiler + sandboxed Hook Testbench (exit 0 vs exit 2) Easy to ship broken hooks (e.g. unset $CLAUDE_FILE_PATHS) No Claude Code lifecycle hook simulation
Context window visibility Context Stack Simulator + Token Budget Waterfall per target file Guessing what loads and how many tokens it costs Prompt templates only
Safe editing Scoped Harness Sandbox + multi-file Hunk Diff + 1-click snapshot rollback Direct writes, easy to break JSON/shell syntax Remote save

The other columns describe typical workflows; individual setups differ.

📋 Table of Contents

✨ Features

1. System Topology Canvas

  • 5 logical swimlanes: Context Hierarchy → Entrypoints (Commands) → Agents & Loops → Skill Bundles → Guardrails & MCP — auto-aligned on an interactive pan/zoom canvas with MiniMap and problem-only filter.
  • Direct wiring: drag a wire from Context → Context to insert @path imports, Agent → Skill to attach skill procedures, Agent → MCP to grant mcp__<server>__* tool permissions, or Command → Workflow/Agent/Skill to connect entrypoints.
  • Live diagnostic overlays: broken @import links, orphan skills, over-privileged agents, and buggy hooks light up directly on the graph.
  • Quick create (Cmd+K): generate new Skill Bundles (with scripts/ & references/), Subagents, Loop Graphs, Guardrail Hooks, Context Rules, Commands, or MCP Servers from templates in seconds.

CC Harness Studio System Topology Canvas: 5 swimlanes showing Context Hierarchy, Entrypoints, Agents & Loops, Skill Bundles, and Guardrails & MCP with live diagnostics
System Topology Canvas — inspect all 5 harness gears, drag to wire dependencies, and spot broken imports or unrestricted agents at a glance. (Sample: examples/pocket-ledger)

2. Autonomous Loop & Workflow Studio

  • Executable loop graphs, not dead diagrams: visually compose Trigger, ContextPrime, ActionStep, SkillInvoke, AgentDelegate, ScriptGate, CriticGate, HumanGate, and End nodes with animated feedback edges.
  • First-class LoopFrame semantics: configure max_iterations, exit_condition, context_isolation (fresh_subagent / progress_ledger / shared_window), progress_file, and escalation_target so autonomous loops never spin forever.
  • Auto-detected project scripts: automatically discovers scripts from package.json and Cargo.toml for 1-click ScriptGate insertion.
  • One-click Harness Compiler: compiles any loop graph into:
    • lossless .harness/workflows/<name>.md (extended Mermaid + loop_frames frontmatter + step bodies),
    • an executable Claude Code slash command .claude/commands/run-<name>.md,
    • a deterministic verification gate script .harness/scripts/run-<name>-gate.sh (exit 0 / exit 2),
    • and optional Stop hook wiring in .claude/settings.json.

Autonomous Loop & Workflow Studio with LoopFrame controls, auto-detected scripts, and one-click Harness Compiler
Autonomous Loop Studio — define bounded LoopFrame iterations, ScriptGate / CriticGate / HumanGate nodes, and compile into executable slash commands and gate scripts.

3. Context & Bundle Workbench

  • Context Stack Simulator & Token Budget Waterfall: enter any repository file path (e.g. packages/api/src/index.ts) and a sample task prompt to see the exact load order and token breakdown — Root AGENTS.md/CLAUDE.md, Skill frontmatter index, MCP schema overhead, ancestor directory AGENTS.md, matching .claude/rules/*.md globs, recursive @import expansions, and triggered SKILL.md bodies.
  • Duplication detector & 1-click consolidation: detects overlap between AGENTS.md and CLAUDE.md and proposes consolidating CLAUDE.md into @AGENTS.md plus Claude-specific deltas.
  • Capability Bundle Editor: edit SKILL.md together with bundled scripts/*.sh, scripts/*.py, references/*, and examples/* inside a tabbed CodeMirror 6 editor (Markdown / Shell / Python / JSON / YAML + native macOS IME).
  • Subagent Role Matrix: compare every subagent's model (inherit / opus / sonnet / haiku) and tool permissions (Read, Grep, Glob, Edit, Write, scoped Bash(...), MCP tools) side by side and tighten unrestricted agents with one click.

Context Stack Simulator showing Token Budget Waterfall, AGENTS.md/CLAUDE.md duplication banner, and layered context resolution
Context Stack Simulator — inspect exact token budgets, glob rules, recursive @import expansions, triggered skills, and 1-click @AGENTS.md deduplication.

4. Guardrails & Hook Pipeline

  • 6-stage lifecycle pipeline: visually inspect and edit SessionStart → UserPromptSubmit → PreToolUse → PostToolUse → SubagentStop → Stop hooks alongside permissions.allow / permissions.deny.
  • Sandboxed Hook Testbench: feed simulated Claude Code JSON stdin payloads (e.g. Edit targeting packages/api/drizzle/0001.sql) to any hook command or .harness/hooks/*.sh script and immediately inspect the verdict (ALLOWED exit 0, BLOCKED exit 2 + stderr feedback injected to AI, or error hints such as unset $CLAUDE_FILE_PATHS).
  • Soft-to-Hard Rule Compiler: scans AGENTS.md / CLAUDE.md for natural-language prohibitions and mandatory checks ("Never edit packages/api/drizzle/ by hand", "Never commit .env", "Must pass pnpm test"), checks actual hook script contents to see whether they are enforced, and compiles unprotected Soft Rules into executable shell hooks + .claude/settings.json entries.

Guardrails & Hook Pipeline with 6 lifecycle stages, Hook Testbench, Permissions Boundary, and Soft-to-Hard Rule Compiler
Guardrails & Hook Pipeline — manage all 6 Claude Code hook stages, dry-run hooks against simulated JSON payloads, and compile natural-language rules into deterministic guardrails.

5. Execution Lab & Diagnostics

  • Actionable Harness Diagnostics: replaces vague scores with concrete Blocker / Warning / Optimization items, each linked directly to the target view/node and a 1-click Quick Fix transaction when auto-fixable.
  • Read-Only Isolated AI Co-Design (claude -p --output-format stream-json): run AI Harness Audit, AI Improvement Proposals, or AI Autonomous Loop Design while observing every read-only tool call in real time in the bottom Live Trace drawer. Proposed edits always route through the Hunk Diff reviewer.

Execution Lab & Diagnostics showing Blocker/Warning/Optimization findings with 1-click Quick Fix buttons and Read-Only AI Co-Design Lab
Execution Lab & Diagnostics — jump straight to broken nodes, generate 1-click Quick Fix diffs, or run read-only isolated AI audits with live stream-json tracing.

6. Multi-File Diff, Snapshots & Hybrid Runtime

  • Unified Hunk Diff Drawer: every mutation — wiring, compiling, form editing, Quick Fix, or AI proposal — stages a multi-file TransactionPlan with per-file checkboxes before touching disk.
  • Automatic Snapshots & 1-Click Rollback: every apply snapshots the prior state outside your Git tree so you can roll back any generation cleanly.
  • 3 Ways to Run: native macOS .app (~6.7 MB via tao/wry WKWebView), local Web Studio (studio), or headless CI CLI (check / compile / run).

🚀 Installation

Download (macOS, Apple Silicon / Intel)

Grab the latest build from GitHub Releases:

File Contents
CC-Harness-Studio-<ver>-macos-arm64.dmg Native .app (drag into Applications)
CC-Harness-Studio-<ver>-macos-arm64.zip Same .app, zipped
cc-harness-studio-<ver>-macos-arm64.tar.gz Standalone CLI binary (studio / check / compile / run)

For Intel Macs, use the same files with x86_64 in place of arm64.

Release builds are signed with a Developer ID and notarized by Apple, so they open without Gatekeeper warnings.

Prerequisites

  • macOS 13+ (Apple Silicon or Intel) for the native .app bundle
  • Rust (stable, pinned via rust-toolchain.toml) and Node.js 20+
  • Claude Code (claude) — optional; only required for the AI Co-Design Lab

Build from source

git clone https://github.com/karamage/cc-harness-studio.git
cd cc-harness-studio

# 1. Install frontend dependencies and build the embedded Studio UI
cd ui && npm install && npm run build && cd ..

# 2. Run Rust core & runtime test suite
cargo test --workspace

# 3. Build self-contained macOS .app bundle (~6.7 MB)
scripts/bundle.sh

Launch the built native app:

open "target/CC Harness Studio.app"

[!IMPORTANT] Locally built .app bundles are ad-hoc signed. If macOS prompts on first launch, allow it in System Settings → Privacy & Security → Open Anyway, or run directly via cargo run -p cc-harness-studio.

📖 Usage

Studio workflow

Open repo → Inspect Topology Canvas → Wire nodes / Design Loop → Simulate Context → Test Hooks → Review Diff & Apply
  1. Try the built-in sample first: run cargo run -p cc-harness-studio (or open examples/pocket-ledger) to explore a realistic monorepo harness containing hierarchical AGENTS.md, glob-scoped .claude/rules/, bundled skill scripts, a working PreToolUse Drizzle blocker hook, and intentional harness issues ready for 1-click Quick Fixes.
  2. Design & wire: switch across the 5 left-rail modes (Topology, Loops, Context, Guardrails, Lab) or press Cmd+K to search nodes or scaffold new harness assets.
  3. Verify before applying: inspect all generated files in the bottom Diff Review drawer, toggle individual files if desired, and click Apply with Snapshot.

Headless CLI (CI & scripting)

Every core capability also runs headlessly from the terminal or CI:

# Launch native macOS desktop window (default)
cc-harness-studio [repo-path]

# Launch local Web Studio server (with live file watcher & WebSocket)
cc-harness-studio studio [repo-path] --port 4173 --open

# Run static harness diagnostics (exits with code 2 on Blocker findings)
cc-harness-studio check examples/pocket-ledger
cc-harness-studio check examples/pocket-ledger --json

# Compile loop graphs into /run-<name> commands & gate scripts
cc-harness-studio compile examples/pocket-ledger --workflow feature-loop          # dry-run
cc-harness-studio compile examples/pocket-ledger --workflow feature-loop --write  # apply with snapshot

# Dry-run or execute deterministic ScriptGates in a workflow
cc-harness-studio run examples/pocket-ledger --workflow feature-loop
cc-harness-studio run examples/pocket-ledger --workflow feature-loop --execute-gates

Supported harness assets

Category Standard Paths
Context & Rules AGENTS.md, CLAUDE.md, GEMINI.md (any depth), .claude/rules/**/*.md, .cursor/rules/**/*, .github/copilot-instructions.md
Skill Bundles **/SKILL.md + bundled scripts/**, references/**, examples/**
Subagents & Commands .claude/agents/**/*.md, .claude/commands/**/*.md
Guardrails & MCP .claude/settings.json (hooks, permissions), .harness/hooks/**, .mcp.json
Autonomous Loops .harness/workflows/*.md, .harness/scripts/*-gate.sh, .harness/progress/*.md

Built-in loop templates

Template Flow
feature-tdd-loop Plan → Small-step impl → write-tests skill → ScriptGate → Read-only CriticGate → HumanGate
ci-auto-repair CI failure log → Minimal repro test → Root-cause fix → Regression ScriptGate → CriticGate → HumanGate
safe-db-migration Schema edit → db-migration skill & script → Migration & test ScriptGate → Destructive-change HumanGate
multi-agent-spec-to-pr Architect → Worker × test-runner Verifier isolated loop → Security/Code CriticGate → HumanGate

Diagnostics severity

Severity Meaning Examples
Blocker Broken or unsafe harness wiring that fails at runtime Broken @import, unset $CLAUDE_FILE_PATHS in hook, missing hook script, unbounded feedback loop
Warning High-risk drift or missing deterministic enforcement Unrestricted subagent tools, unprotected Soft Rule, AGENTS.md/CLAUDE.md duplication, context budget exceeded
Optimization Hygiene and discoverability improvements Uncompiled workflow, orphan skill, weak skill description trigger, missing Stop hook

🏗 How it works

CC Harness Studio.app (~6.7 MB single Rust binary + embedded UI)
├── Native Desktop Shell (tao + wry WKWebView)   opens loopback URL with native file dialog (rfd)
├── Local Studio Host (axum + WebSocket + notify)
│   ├── Embedded React 19 UI (rust-embed ← ui/dist)
│   ├── File watcher broadcasts live graph updates over /ws
│   └── REST API + real-time TraceEvent stream over /ws
├── hc-core (pure Rust domain engine)
│   ├── Unified Harness Graph IR & .gitignore-aware scanner
│   ├── Context Stack Simulator & AGENTS/CLAUDE deduplicator
│   ├── Soft-to-Hard Rule Extractor & Guardrail Compiler
│   ├── Lossless LoopGraph parser/serializer & Harness Compiler
│   └── Scoped Harness Sandbox (allowlist, sh -n/JSON validation, Hunk Diff, snapshots)
└── hc-runtime (tokio async execution engine)
    ├── Hook Testbench (simulated JSON stdin → exit 0 / exit 2 verdict)
    ├── Autonomous Loop & ScriptGate Verification Runner
    └── Read-Only Isolated `claude -p --output-format stream-json` Runner

🔒 Security

  1. Local loopback only: the studio server binds strictly to 127.0.0.1 (random ephemeral port in desktop mode).
  2. Scoped Harness Sandbox: all writes pass through hc_core::sandbox::is_allowed_path. Application source code (src/**, packages/*/src/**), .git/**, .env*, CLAUDE.local.md, private keys (*.pem, *.key, id_rsa*, id_ed25519*), and symlink escapes outside the repository are unconditionally rejected.
  3. Pre-write syntax & schema validation: .json files are parsed and schema-checked (.claude/settings.json merges only hooks and permissions, preserving unknown keys); .sh scripts are validated with sh -n before any byte is written.
  4. Strict Read-Only AI isolation: when invoking claude -p, hc-runtime runs in an empty temporary working directory with --restricted --strict-mcp-config --tools Read,Grep,Glob --permission-mode dontAsk --no-session-persistence and LOCKDOWN_SETTINGS denying .env*, .ssh, .aws, keys, and CLAUDE.local.md. Write, Edit, and Bash are never granted.
  5. No telemetry: zero analytics or background network calls. Everything stays on your machine (and only talks to Anthropic via your local claude CLI when you explicitly start an AI lab run).

🛠 Development

Tech stack

  • Core & Runtime: Rust (Edition 2024), tokio, ignore, globset, similar, serde_yaml
  • Desktop & Server: axum 0.8 (REST + WebSocket), notify 8, rust-embed, tao + wry (WKWebView), rfd
  • Frontend: React 19 + TypeScript + Vite 6 + Tailwind CSS v4 + @xyflow/react v12 + @dagrejs/dagre + CodeMirror 6 + lucide-react

Project structure

cc-harness-studio/
├── crates/
│   ├── hc-core/               # Unified Harness IR, scanner, simulator, Soft-to-Hard rules, compiler, lint, sandbox
│   ├── hc-runtime/            # Hook Testbench, Loop Runner, Read-Only claude -p stream-json runner
│   └── hc-studio/             # Hybrid CLI, Axum REST/WS server, file watcher, tao/wry native desktop host
├── ui/
│   ├── public/                # App icon & favicon
│   └── src/
│       ├── views/             # TopologyView, LoopsView, ContextWorkbenchView, GuardrailsView, ExecutionLabView
│       └── components/        # CodeEditor (CM6), DiffDrawer, NodeInspector, CommandPalette
├── examples/pocket-ledger/    # Realistic monorepo sample harness (rules, bundled scripts, hooks, workflows)
└── scripts/                   # bundle.sh (.app packaging), gen_icon.py (2x supersampled icon generator)

Commands

# Run all Rust unit & integration tests
cargo test --workspace

# Typecheck and build production UI
cd ui && npm run build

# Frontend hot-reload dev mode (run in two terminals)
cargo run -p cc-harness-studio -- studio examples/pocket-ledger --port 4173
cd ui && npm run dev

# Regenerate AppIcon.png / AppIcon.icns / favicon
python3 scripts/gen_icon.py

# Build production macOS .app bundle (ad-hoc signed unless SIGN_IDENTITY is set)
scripts/bundle.sh

# Build signed + notarized release artifacts into target/dist
SIGN_IDENTITY="Developer ID Application: ..." NOTARY_PROFILE=<notarytool profile> scripts/release.sh

🤝 Contributing

Issues and pull requests are welcome. Before opening a PR, please make sure both cargo test --workspace and cd ui && npm run build pass cleanly.

Areas where help is especially welcome:

  • 🐛 Bug reports and edge-case harness fixtures
  • 🧭 Additional built-in autonomous loop templates and diagnostic rules
  • 🌐 Support for additional agent harness formats (Codex, Cursor, Windsurf, Copilot)
  • 🐧 Linux & 🪟 Windows desktop packaging

📄 License

This project is licensed under the MIT License. See LICENSE for details.

🙏 Acknowledgments


探索相关项目

加载中…