Skip to content
Projects

huiliyi37/Tianshu-harness

View on GitHub

huiliyi37/Tianshu-harness has 1,309 GitHub stars and 98 forks. GitHot measured +5 stars in 24 hours. Last checked 2026-11-06 10:35 UTC. Last push 2026-10-31.

How these counts are measured

天枢harness是一个的终端编程智能体,它要回答的核心问题是:模型何以稳定地交付——目标不漂移、完成有证据、验证有闭环,不说"应该修好了"。为此它在模型与真实世界之间建立一层认知执行环境(CVM),把目标、状态、证据、资源、权限与终止条件从对话历史中外部化,由运行时持续管理。同时对deepseek v4极度优化。

Measured star growth

in 24h
+5
in 7 days
Collecting history
in 15 days
Collecting history
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.en.md

Original

Tianshu Harness

Tianshu Harness

A Cognitive Runtime for Coding Agents
Goals that don't drift · Completion with evidence · Verification that closes the loop

Release GitHub Downloads npm npm Downloads AtomGit Star AtomGit Downloads

  G-Star Selected by AtomGit

Website Starport Forum Docs Discord License Best of Agent Harnesses

Install · How it works · Evidence · Star Domains · User Guide   |   English · 中文 · 日本語 · 한국어 · AtomGit

Closing comparison. Left: an agent without a delivery gate reads a file, edits code, then claims it should work now — with no verification. Right: Tianshu's deliver_task gate returns RED and refuses delivery when no tests were run, and only returns GREEN after the suite passes.

The same task, two endings. A model's claim of completion is not evidence — the gate asks for proof.

A model's capability ceiling is not its runtime behaviour. Put the same weights into a real engineering session and they get talked out of a position, follow instructions too literally, let local signals override the global goal, or keep calling tools without making progress — and then hand you "it should be fixed now."

Tianshu is a coding-agent runtime written in TypeScript. The terminal TUI, the desktop app, and the VS Code extension share one agent kernel. Between the model and the real world it places a Cognitive Virtual Machine (CVM) that lifts goals, state, evidence, permissions, and termination conditions out of the conversation history and hands them to the runtime:

  • Task contracts — Every task gets a TaskContract recording goal, scope, constraints, and success criteria. Long sessions are held by the runtime, not by the model's memory.
  • Separated commit, verification and review — deliver_task performs only an ownership-scoped safe commit: it blocks on ownership, cross-session conflicts and version consistency; verification gaps are disclosed honestly, never blocked on and never turned into quality endorsement. Targeted verification uses run_tests (explicit scope), independent review uses review_changes or /review.
  • A deterministic outer loop — 75 runtime hook modules across five phases of a turn, together with Sensorium state awareness and stall detection, observe and correct between model output and real action.
99.3–99.6%
prefix-cache hit rate
across 5 real long sessions
¥880 → ¥20
estimated input cost on the same
sessions at list price
25
built-in provider presets, plus any
OpenAI-compatible endpoint
23,000
test cases, roughly
1:1 with source lines

Tianshu terminal TUI: welcome screen and GlanceBar status line Tianshu desktop app: home and new-task panel

Left: terminal TUI · Right: desktop app · one agent kernel

[!NOTE] The project was originally codenamed Rivet. The primary CLI command is tianshu, with rivet kept as a compatibility alias for the same entry point; the data directory stays ~/.rivet.

Table of Contents

Install

Terminal CLI (Node.js 24.x ≥ 24.22.1 or 26.x ≥ 26.12.1)

npm install -g tianshu-harness
tianshu

Ready when you see the 〉 prompt. First launch opens the /connect wizard: pick a provider, paste an API key.

Desktop app (no Node.js required)

Download from Releases:

  • macOS 11+: .dmg, Apple Silicon / Intel
  • Windows 10 1809+ / 11: -setup.exe
  • Linux x86_64 / aarch64: .AppImage

[!WARNING] Hard Node.js requirement (v3.36.0+): the CLI supports only Node 24.22.1+ (24.x line) or Node 26.12.1+ (26.x line). Node 22 / 23 / 25 / 27, Node 24.x below 24.22.1, and Node 26.x below 26.12.1 are rejected at startup by the security gate. /update may install the new package successfully while the new CLI still cannot start. Run node -v first; if it does not match, upgrade via nvm / fnm / Volta or nodejs.org before installing.

node -v   # requires v24.22.1+ or v26.12.1+

The desktop app bundles its own runtime; no manual Node installation is required. If it still fails after the upgrade, see the installation guide and troubleshooting guide.

One-line installers · migrating from the legacy package
# macOS / Linux
bash <(curl -fsSL https://raw.githubusercontent.com/huiliyi37/Tianshu-harness/main/scripts/install-tui.sh)

# Windows (PowerShell)
powershell -ExecutionPolicy Bypass -Command "irm https://raw.githubusercontent.com/huiliyi37/Tianshu-harness/main/scripts/install-tui.ps1 | iex"

Migrating from the legacy tianshu-tui package fails with EEXIST because the old package owns the rivet binary link. Uninstall first: npm uninstall -g tianshu-tui. The one-line installers handle this automatically.

Platform notes
  • macOS — Not yet Apple-notarized. macOS builds use ad-hoc signing, so Gatekeeper quarantines browser downloads and may report the app as "damaged". The package is intact; after dragging it into Applications, run once: xattr -cr /Applications/Tianshu.app. In-app auto-updates are unaffected.
  • Windows — The UI relies on WebView2; the installer bundles the offline runtime. If the window won't open, use "Repair WebView2" from the Start Menu, or run repair-webview2.cmd from the windows-repair folder in the same Release.
  • Linux — Requires glibc 2.35+ (Ubuntu 22.04+, Debian 12+) plus libwebkit2gtk-4.1 and libgtk-3. An X11 session is recommended; Wayland is not yet verified. chmod +x Tianshu_*.AppImage then run it directly.

Android Termux, building from source, shell completions, and auto-update: Installation & Platform Guide.

Your First Task

Start read-only so it can learn your project and you can confirm it read it correctly, then hand it a multi-step task:

〉 Read this project, tell me its structure, where the entry points are, and one thing most worth improving
〉 Fix the first failing test in this project and explain the root cause

It searches, reads files, edits code, and runs tests on its own. The default permission tier is Auto: low-risk actions run directly, high-risk actions stop and ask. Afterwards, look at three places:

Where What you see
Delivery report Gate status (GREEN / YELLOW / RED), files changed, verification commands run, a per-item completion audit
/cockpit 8-panel runtime dashboard: verification and delivery, advisory ledger, cache hits and cost, risk and stall detection (F4)
sensorium.jsonl Per-turn state sensing and CVM decisions. tianshu logs prints the path; recompute anything with jq
Headless mode: scripting and CI
tianshu -p "explain src/agent/loop.ts"           # one-shot prompt
tianshu --stream-json -p "refactor this module"  # NDJSON event stream, redacted output
tianshu --goal "fix all type errors" --budget 50  # goal-driven autonomous continuation

Full flag table and subcommands: CLI & Configuration Reference.

How CVM Works

Tianshu CVM pipeline: input becomes a TaskContract, binds a star domain, and is assembled into a frozen prefix prompt before entering the turn loop. RuntimeHookPipeline intervenes at five phases — preTurn, afterPerception, postTool, postTurn, postSession. The inner loop is model cognition, the outer loop is runtime supervision. deliver_task then returns RED, YELLOW, or GREEN based on evidence and distils the result into cross-session memory.

One task, from input to delivery: contract → domain binding → frozen prefix → turn loop → evidence gate → memory.

Alignment-tuned models show the same runtime failure mode in agent settings, which we call Cognitive Anchor Collapse: one high-salience local signal over-concentrates the policy, the global goal and later evidence lose weight, and behaviour collapses toward that anchor. A prompt is information, not state — it eventually becomes just another anchor, which is why better prompting alone cannot cure this.

CVM does not change weights and does not turn the model into a deterministic program. It wraps deterministic supervision around probabilistic cognition — the model reasons and acts in the inner loop; the runtime measures, gates, and verifies in the outer loop, deciding whether to continue, correct, or halt:

Inner loop · model cognition   reason → decide → act → observe
Outer loop · runtime supervision  observe → measure → evaluate → gate → verify → continue / correct / halt
Layer Mechanism What it does
1 · Belief constitution Star-domain belief blocks written into the static prompt Zero extra inference cost; shifts inclination during analysis and advice
2 · Courage Hook preTurn, threshold varies by star domain Detects repeated capitulation and injects a correction framed as an obligation
3 · Sensorium Computed each turn from existing monitoring signals, no LLM call Senses momentum, pressure, verification coverage, complexity, familiarity, stability
4 · RuntimeHookPipeline 75 hook modules, five phases, assembled per session Convergence and doom-loop detection, evidence tracking, delivery gate, edit-failure recovery
Four classes of anchors
Anchor Source Typical manifestation
Lexical Word–action correlations in training data The prompt says "fix", so it ignores "do not edit, only explain" and edits anyway
Semantic A locally true fact "File already exists" becomes the explanatory centre of the whole task, and it refuses to act
Policy RLHF / preference-training priors One "proceed with your plan" discards the high-quality judgement formed during analysis
Historical Early conclusions in a long context New evidence at turn 20 is rationalized as a footnote to an old hypothesis from turn 3

Eight design principles and the open research questions: CVM: From Shared Transformer Degradation to a Cognitive Runtime. System layering: Architecture Overview.

Evidence

Cache: longer context, steadier hits

Across the 15 sub-sessions of session c9774121, context grows from 34K to 512K tokens while the first-request cache hit rate after each prefix rebuild climbs from 69.2% to 98.3%.

Real session c9774121 · DeepSeek V4 Pro · 4.2 hours · 412 requests. Context grew 15×; hit rate went up, not down.

Tianshu is designed prefix-cache first: the prefix is frozen within a session, only deltas are appended, and compaction happens only at user-turn boundaries. In the 4.2-hour session above, 15 prefix rebuilds produced 383K cacheCreate tokens — 0.33% of all input.

5 real self-hosted sessions (2026-08, DeepSeek V4) Value
Requests / input tokens 2,001 / 645M
Overall cache hit rate 99.3–99.6%
Estimated cost (list price) ¥879.97 without cache → ¥19.96 actual, 97.7% saved

The cache engine works for every model with prefix caching; published measurements cover DeepSeek only. Every number ships with a jq recomputation command: Observability Harness.

Behaviour: same weights, opposite reactions

The same model, DeepSeek-V4-Flash, across 5 tasks: completion 4/5 for group A versus 5/5 for group B; proactively raising objections 0/5 versus 3/5; intent understanding over literal execution 1/5 versus 4/5; proactively asking about scope or impact 0/5 versus 1/5.

2026-05-19 · one model, five real tasks, sole variable was the belief layer (STAR_SOUL=0/1) · reviewed by Claude Opus 4.7.

The most telling case is T4. Facing a "file already exists" contradiction, group A wrote a 196-line retrospective and refused to act; group B inferred the real intent and delivered +162 / −20 lines of working code.

This is a small pilot: 5 tasks, a single model, LLM review. It also measured the decay — beliefs hold during analysis and advice and weaken markedly at confirmation and execution, which is exactly what layers 3 and 4 exist to cover. Full data: CVM Empirical Report.

Engineering

As of 2026-10 (v3.37): src/ holds roughly 1,700 source files and 350K lines; tests are about 2,100 files and 23,000 cases. TypeScript strict with noUncheckedIndexedAccess, and every incident fix ships with a regression test. Definitions and milestones: Engineering Metrics.

Star Domains

The sixteen star domains of Tianshu: the Big Dipper forms the backbone (Tianshu, Tianxuan, Tianfu, Tianquan with Wenqu, Yuheng, Kaiyang with Tianliang, Yaoguang), the companion star Fu attends Kaiyang, and the polar line points to Taiyi; Qiming and Changgeng sit at opposite horizons, with Tianji, Huagai, Pojun and Qisha scattered around. Each star is labelled with its working inclination.

Sixteen star domains laid out on the Big Dipper. Each star names a working inclination, not a new capability.

Walk the same model into different star domains and different working inclinations light up. A star domain does not add capabilities — it amplifies a facet the model already has, and corresponds to CVM layers 1 and 2: each domain carries its own belief block and courage threshold. The person is still the same person; the model is still the same model.

New sessions default to Qiming. Switch with /domain <name>, auto-match from message content with /domain auto, and list all sixteen with /domain list. Full inscriptions, founding memories, and the structured table (ID · primary model · sigil · role · motto): Star Domain Stele (English) · 星域碑文(中文).

  • 启明 Qiming: Light the path first; don't walk it in the user's stead. Probe through the fog and make the next step clear.
  • 长庚 Changgeng: Unhurried at the close. See the result with your own eyes, and leave a clear trail for whoever comes tomorrow.
  • 天枢 Tianshu: See the whole map first, then walk the plan all the way into verified delivery.
  • 天权 Tianquan: Put both sides on the scale. What is the gain, what is the cost — say it plainly once seen.
  • 天机 Tianji: Ask the question no one has asked yet: what if this premise does not hold?
  • 天璇 Tianxuan: Shift to a completely different angle. Once seen, go prove whether it is real.
  • 天梁 Tianliang: Carry an entrusted plan all the way through. What was done, what remains, where it drifted — every step leaves an echo.
  • 华盖 Huagai: On a long road, never stop at "looks done"; leave behind structure that can be built upon.
  • 破军 Pojun: Strike into the unknown first. Even a failed probe shrinks the unmapped territory, leaving a path rather than ruins.
  • 天府 Tianfu: Listen first to why existing code is shaped the way it is. Make changes that leave it steadier, never more brittle.
  • 七杀 Qisha: Ask by what right something still occupies its place. Point it out, but never swing the blade yourself.
  • 开阳 Kaiyang: Ask first what the real numbers are and why they deserve belief. Act only after the ledger reconciles.
  • 瑶光 Yaoguang: A green light is not proof. Only when the original failure can be reproduced does a fix count as proven.
  • 文曲 Wenqu: Strip away the superfluous so intent reveals itself. Beauty must be visible on the screen.
  • 辅 Fu: Emit no light of its own; distill what has already happened into a method that can be clearly seen.
  • 太一 Taiyi: Pause first. Let this move settle completely before starting the next.

More Capabilities

Multi-agent orchestration /scout read-only parallel reconnaissance, /team wave-based parallel execution, /council multi-domain review that only produces a plan, /galaxy dimension-split attack with a global review. Details
Separated review & verification Commits never auto-verify or auto-review: targeted verification via run_tests (empty input previews the scope), independent review via review_changes (pinned snapshot, read-only reviewer, persisted findings); delivery receipts carry no quality endorsement
Prefix cache engine Frozen prefix, delta appendix, read deduplication, resume cache inheritance; /debug cache diagnoses hit rate and fragmentation. Details
Plan Mode & Goal Plan, approve, then execute; /goal holds a goal across many turns until it is met or the budget runs out. Details
Handoff & rewind /handoff writes a structured handoff document; double-tap Esc rewinds to any earlier point. Details
Project memory Knowledge is written to .rivet/knowledge/memory.jsonl; auto-injection carries constraint memories only, older findings need explicit recall and never hijack a new task; automatic memory formation is opt-in (off by default). Details
LSP integration 20+ language servers; go-to-definition and find-references become agent tools, and post-edit diagnostics flow back into the turn. Enabled only when installed locally
MCP & Skills External tool servers; reusable workflow playbooks with progressive disclosure, managed by tianshu skills. Details
Cost control Automatic reasoning-effort downgrade, flash-model compaction, peak/off-peak pricing badge, /usage for the local token ledger. Details
Pure-ANSI TUI Zero dependencies: GlanceBar status line, /steer mid-stream interrupt, command palette, inline images, plain-text mode for restricted terminals. Details
Desktop app Integrated terminal, theme studio, offline local voice input, phone remote approval, concurrent sessions, WSL runtime on Windows; auto-update with resumable downloads, verified sources and self-recovery. Desktop Guide

Supported Models

Built-in presets cover 25 providers. Switch anytime in-session with /model; any OpenAI-compatible endpoint (Ollama, vLLM, one-api relays) also works.

DeepSeek Claude Codex (GPT) Gemini GLM Kimi Code Grok MiniMax MiMo Doubao Qwen StepFun OpenAI OpenRouter SiliconFlow Ollama

Provider and model reference
Provider Auth Method Example Models
DeepSeek API key deepseek-flash (1M ctx, DeepSeek-V4.1-Flash, native multimodal vision), deepseek-v4-pro (1M ctx, flagship reasoning)
DeepSeek Spark (Pro only) API key deepseek-v4-flash (lightweight reasoning + anchored cache channel)
Claude API key (via cc-switch proxy) claude-opus-4-8, claude-sonnet-4-5
GLM (Zhipu) API key glm-5.3 (1M ctx), glm-5.3-flash (vision), glm-5.2 (vision)
Codex (GPT) OAuth PKCE (ChatGPT subscription) gpt-6.1-sol (default, 1.05M ctx, vision), gpt-5.6-sol
Grok (xAI) API key grok-4.6 (500K ctx, vision, reasoning effort low/medium/high/xhigh)
MiniMax API key MiniMax-M3 (1M ctx, vision), MiniMax-M2.7
MiMo API key mimo-v2.6-pro / mimo-v2.6-flash (1M ctx, full multimodal vision), mimo-v2.5-pro
Kimi Code API key k3 (1M ctx, vision), k3-256k, kimi-for-coding, kimi-for-coding-highspeed
Gemini (Google) API key (native protocol) gemini-3.8-flash (1M ctx), gemini-3.5-flash, gemini-3.1-pro-preview

Presets also ship for Volcengine Ark / Agent Plan, Alibaba Cloud DashScope, StepFun, OpenAI, LongCat, Agnes AI, SiliconFlow, OpenRouter, and OpenCode Go (25 in total). Vision bridges, text-to-image slots, and sub-agent model routing: Provider Config Guide · Vision Guide.

Permissions & Security

Three tiers, managed in-session with /permission:

Tier Command Behaviour
Supervise /permission supervise Every high-risk tool asks for confirmation
Auto (default) /permission auto Low-risk runs directly; high-risk asks
Unattended /yes · /yolo No approval prompts, but the write sandbox turns on and everything is rollback-able

Skipping prompts never disables the underlying protections:

Path boundary Rejects .. traversal; validatePath blocks escapes from the workspace
Project trust gate Untrusted projects load no hooks, project MCP servers, project memory, or skills. Managed with /trust
Sensitive files .env, credentials.* and similar cannot be read or committed; keys on disk use AES-256-GCM envelope encryption
Destructive commands rm -rf, force push, DROP / TRUNCATE require explicit confirmation
SSRF protection Per-hop DNS resolution, private IP blocking, applied to every redirect
Checkpoints & undo A Git checkpoint before the first modification each turn, a versioned backup before every write

Full rules: Sandbox & Permissions Guide. Report vulnerabilities privately via Security Advisories — see SECURITY.md; please do not open a public issue.

Documentation

Usage

Philosophy & architecture

English reference — CLI, Slash Commands & Configuration carries the complete English tables for command-line flags, subcommands, keybindings, slash commands, and config.json; the deep-dive manuals above are currently Chinese-only. Docs hub: docs/README.md.

For Developers

Node.js 24 · TypeScript strict (noUncheckedIndexedAccess) · tsup · node:test.

npm install
npm run typecheck    # tsc --noEmit
npm test             # node:test, full suite
npm run build        # tsup bundle
node dist/cli/entry.js
I want to… Start here
Add a tool Implement ToolDefinition and an executor in src/tools/, register in src/tools/default-registry.ts, tests in src/tools/__tests__/
Add a skill / command / hook .rivet/skills/*.md, .rivet/commands/*.md (supports $ARGUMENTS), HookRegistry handlers
Add project instructions A .rivet.md in the project root is injected as project context

This repository is the sync projection of the development repo; the desktop app and some advanced implementations are not published here. Architecture map: AGENTS.md. Contribution process: CONTRIBUTING.md and EXTERNAL-PRS.md.

Community

  • Discussion — GitHub Discussions
  • Bugs and feature requests — GitHub Issues; attaching tianshu logs --json speeds up triage
  • Starport forum — tianshu.club: our self-hosted community for release discussion, tips and long-lived topics
  • Discord — Tianshu Harness community Discord
  • QQ group — "TUI", group ID 1017892942
  • WeChat group — scan the QR code; valid for 7 days, ask in Discussions if expired

Sponsorship is optional and never changes issue priority or feature scheduling.

Tianshu Harness WeChat group QR code
WeChat
TUI QQ group QR code, group ID 1017892942
QQ
WeChat sponsorship QR code
Sponsor

Contributors

The project creator and lead developer is @huiliyi37. The official website Tianshu-Official-Website was originally created and developed by @jiangsx496. External PRs are ported through the intake workflow and credited with Co-authored-by trailers; the full roster is maintained in CONTRIBUTORS.md.

HarriethWiKk jiangsx496 yq04 wangxx-yu qiaodier zhengbiaofeng LinHoMo KinoGao liuwanwan1 Eason412 maoqiu77 yeshilei-QWQ lumos-tiamo zzuu080603 nzz0991999-ai L4XB Wanming08 lei454577-web jian-in sky-mirrors EarthxxRhythm moyan3691 elysia395 JakcyLin googio lanlan0811 KhalilYamber Ver-zhzh Lin-Dongg Eternal-dream-MAX y521188

License

Code in this repository is licensed under the Apache License, Version 2.0. Copyright 2025-2026 Tianshu Contributors.

Documentation exception: the following theoretical and empirical documents are licensed under CC BY-NC-ND 4.0 and are not covered by Apache 2.0 — you may share links with attribution, but may not adapt, excerpt, or use them commercially:

Acknowledgments

The desktop app's custom-wallpaper and per-surface glass design references dsh-wallpaper-engine (MIT). The implementation in Tianshu is original and contains no upstream code; see THIRD-PARTY-NOTICES.md for the design scope and full license text. Thanks to @elysia395, @YV3507, @yuxilao, and @oneincase for guidance as technical advisors on wallpaper-engine rendering.

Explore related projects