RepoTrending
Về bảng xếp hạng
GitHubAI AgentTypeScript

NanoNets/Graft

Tăng tốc Claude Code, Cursor, Codex, Gemini và mọi tác nhân mã hóa: nhanh hơn, rẻ hơn, với khả năng hiểu ngữ cảnh cụ thể cho cơ sở mã của bạn.

4.8k sao423 fork

README

Trail-code (previously graft), by Trail. A map of a codebase, with one team decision pinned to it: keep retries at 4.

The self-learning context layer for coding agents.

Trail-code gives Claude Code, Cursor, Codex and other coding agents a map of your code, and what your team has learned about it.

Code map (previously graft) Learnings
Nó là gì? An index of your code: every function and who calls it, so your agent sees what a change can break What you, your agents and your team have learned and decided
What does it do for your agent? Takes it straight to the right files Lets it pick up where you and your team left off
Where does it come from? Your code, read on your machine Your conversations, as you work

trailhq/Trail-Code | Trendshift

46% fewer tool calls, 60% less time, and more real issues solved.

Cold agent Agent with the graft map
Tool calls, 162 runs đường cơ sở 46% fewer
Uncached input tokens, 162 runs đường cơ sở 42% fewer
Time, 162 runs đường cơ sở Giảm 60%
SWE-bench Verified, 50 real issues 27 solved (54%) 33 solved (66%)
npm install -g @trailhq/trail-code && trail init

[!LƯU Ý] Graft is now Trail-code. Graft lives on as the graft map, and every graft command still works. What's new is learnings. What changed

Without Trail: each task starts a new session with an agent that has no memory. It searches blind, opens the wrong files, guesses how the code is wired, ships the task, and the context is lost. This repeats for every task and every teammate's agent. With Trail, your agent already knows your code: trail init builds the graft map, a hook points the agent to it before each session, the agent reads the graph with its impact radius, gets precise context, ships the task, then saves learnings. One graph, every agent, up to 4x tokens saved.


What changes in your agent

Without Trail-code With Trail-code
Greps and opens file after file to find the code it needs Gets the right files and functions with your prompt
Re-explores code a teammate already figured out last week Starts from their learning: what they decided, what they ruled out, what to watch out for
Undoes a teammate's decision, because it never knew about it trail check flags it before the PR, quoting who decided it and why
Finds out at merge time that a teammate changed the same code Says so right after it edits code a teammate's open branch also changes, and whether the two clash
Has to be told the same things every session Starts from what you've told it before: trail init finds what you said more than once in your past sessions
You write and update Claude.md by hand Learnings are saved from your conversations, in files you can read

Same model, more tasks solved. On SWE-bench Verified (real GitHub issues, graded by the maintainers' own tests), Claude Sonnet 5 solved 33 of 50 issues with the graft map and 27 of 50 without it, using 23% fewer tokens. Chi tiết

Cheaper and faster. Across 162 runs of the same agent on the same tasks: 32% lower cost, 42% fewer uncached input tokens, 60% less time, and the same share of correct answers. On PocketBase, 15 real tasks ran 21% cheaper và 14% faster. Chi tiết


Nội dung


Nó hoạt động như thế nào

Trail-code has two parts. Both run on your machine.

  1. The graft map: your code. trail init parses your repo with tree-sitter into a map of every file, function and who calls what. No model, no API key. It refreshes itself when the code changes, uncommitted edits included. Your agent gets pointers to the matching files and functions with each prompt, and sees what depends on a file right after it edits it.
  2. Learnings: what you, your agents and your team know. When a session works something out, or you correct how something is done, your agent saves it as a learning. The next session on that code, yours or a teammate's, starts from it instead of digging again. Learnings about the code are committed with the code; learnings about you stay on your machine. On day one, trail init starts you off with what you told Claude more than once in your past sessions, and what reviewers flagged on more than one of the repo's merged PRs.

The graft map tells your agent ở đâu things are. Learnings tell it tại sao they are that way, and làm thế nào the work gets done here.


Bắt đầu nhanh

npm install -g @trailhq/trail-code   # install the CLI, once
trail init                      # in your repo: build the graft map, set up .trail/, wire your agents

[!MẸO] npm install -g says EACCES? Your Node's global folder needs sudo. Skip sudo, or every upgrade will need it too: run mkdir -p ~/.npm-global && npm config set prefix ~/.npm-global, thêm ~/.npm-global/bin đến của bạn PATH, open a new terminal and install again. Trail needs Node 22.3 or newer (20.16 works too).

Đó là toàn bộ thiết lập. trail init asks which of your coding agents to wire up, builds the graft map from your code, creates .trail/ for the repo's learnings, and adds a statusline and hooks to Claude Code. It also reads your past Claude Code sessions in the repo, once, for what you told Claude more than once, and saves those as learnings. Your own Claude Code does that reading, in about a minute. Then work the way you always do. No daemon, no server, nothing to babysit: it is all files.

On a repo whose team hasn't set up trail yet, trail init asks who it's for. My team, which enter picks, sets it up for you to commit once, as below. Just me keeps all of it out of git for your clone only (in .git/info/exclude) and your learnings in ~/.trail, so there is nothing to commit and nothing asks you to share. Run trail init --team when you want your team on it.

Commit the setup so your teammates get it too. The graft map itself, in graft/, is a local cache like node_modules and is added to .gitignore, so it stays out of the commit:

git add .claude .mcp.json .trail .gitignore .ignore && git commit -m "set up Trail-code"

Teammates' Claude Code reads the learnings in .trail/ even before they install anything, and tells them once how to get the rest.

trail init --dry-run shows the agent wiring it would write. trail init --agents claude wires Claude Code and removes Trail-code's wiring for every other agent, including user-level files by default. Pass every agent you use; add --no-global to leave user-level files alone.

Coming from graft?

Nothing breaks. The code map you know is now called the graft map, and it is one of Trail-code's two parts.

trước đây Hiện nay
Tên graft Trail-code
The code map graft the graft map (same thing)
Lệnh graft trail (graft still works)
Gói @nanonets/graft @trailhq/trail-code (the old one still works)
Learnings không có New, see Phần 2

graft và @nanonets/graft run the same code as trail, and print what they always printed.

Already have graft? graft upgrade adds the trail command next to it.

Repos that graft set up move to trail on their own: once the trail command is installed, each one moves the first time you open Claude Code in it. To move one right away, run trail init in it. Commit what changes so your teammates move too.


Part 1: The graft map

Without a map, your coding agent starts every task blind. It greps a term, opens a file, follows an import, backs out and tries again, rebuilding a picture of a codebase it mapped an hour ago and threw away. That rediscovery burns most of a run's tool calls, tokens and time. People onboard to a codebase once. Agents onboard every single time.

The graft map builds that understanding once, and keeps it current:

  • Every file, function and caller. Parsed with tree-sitter into a graph of symbols and who calls what. Deterministic, no model, no network, 24 languages.
  • The right code with every prompt. In Claude Code, hooks add the matching files and functions to each prompt, and show what depends on a file right after your agent edits it (the "blast radius"). Codex and Pi get the same hook events; Cursor and the other agents get the same map through MCP tools and their instruction files.
  • Always fresh. Every query checks the working tree first (a few tens of milliseconds when nothing moved) and rebuilds only what changed, so answers describe the code as it is right now, uncommitted edits included.
  • Plain files you can read. Linked markdown nodes your agent opens and greps like any other file. No embeddings, no index to keep warm.
  • Summaries if you want them. trail build --deep adds plain-English summaries of each part of the system, written by the model provider you choose, under your own key.
Cold agent Agent with the graft map
SWE-bench Verified, 50 real issues 27 solved 33 solved (+12 pts)
Our benchmark, 162 runs đường cơ sở 32% lower cost, 42% fewer uncached input tokens, 60% less time
PocketBase, 15 real tasks đường cơ sở 21% cheaper, 14% faster

How it is measured: Điểm chuẩn, Đã xác minh băng ghế dự bị SWE và Tested on popular repos. How it is built: the reference.


Part 2: Learnings

Your agent forgets everything when a session ends. Next week, it digs through the same code again, or worse, undoes a decision it never knew was made. Your teammates' agents do the same.

Trail-code keeps what your agent works out as learnings, saved from your conversations as you work. The next session starts from what you, your agents and your team already know. You don't have to write any of it by hand.

Learnings and skills, three places

Everything Trail keeps has a place (who it is for): just you, this repo, or your team.

Three places:

Place What goes there Where it lives Who sees it
cá nhân About you and your machine: your setup, your habits ~/.trail/ Only you. Never committed, never uploaded
Repo About the code: why it is the way it is, how work gets done in it the repo's .trail/, committed with the change Everyone who clones the repo, even before they install Trail-code
đội What your whole team has learned, across repos a Trail workspace (soon) Your team, on the team page

Your agent picks between personal and repo: something about your own setup stays personal ("saved just for you"); something about the code goes in the repo ("added to this repo"). The team place will gather the repo learnings of every repo in your workspace, so your team sees them together.

What it keeps:

Ví dụ cá nhân Repo đội
Learnings: what your agent follows by default; you can say otherwise in the moment "Keep retries at 4. Ruled out 10: one call could block for over an hour." "Use pnpm, not npm." Saved when you correct your agent, and found in your past sessions by trail init. ✅ ✅ soon
Always follow: a mark on a learning your agent won't go against, even if asked. It stops and names the learning and who added it "Store money in integer cents." Saved with trail note --always-follow, only when you say so. ✅ ✅ soon
Kỹ năng: how a job is done here, its steps and files, with the learnings taught on it "Read rotation with page.Rotation(), never pdfcpu: it drops /Rotate." soon soon soon

One decision, two teammates

A real test: two people, two clones of hashicorp/go-retryablehttp, headless Claude Code sessions.

1. Maya works out why the retry count is 4. Before committing, the agent saves what it found as a learning, and commits it with the change:

✓ added to this repo · .trail/learnings/2026-10-09-keep-the-default-retry-count-at-maya.md

The reply ends with 📝 Committed · Kumar works in this part of the codebase, and their agents now get a 27k-token head start.

2. Kumar pulls and asks about the same code. Kumar's Claude reads Maya's learning before exploring, answers from it in 11 seconds for $0.10, and ends with a line saying where the answer came from, like:

📝 Started from Maya's learning · saved ~27k tokens

3. Kumar raises the retry count to 10 anyway. Before the PR, trail check compares the change with the learnings in the repo, and Kumar's own:

checking 1 changed file against 1 learning and 0 skills

✗ client.go:51
  changes defaultRetryMax from 4 to 10
  Maya · Oct 9: Keep defaultRetryMax = 4: ten retries with the
  default backoff can hold one Do() call for over an hour.

· 1 conflict · fix it, or say why in the commit message or PR description

Kumar's Claude explains the override in the commit.

4. Maya edits the same constant. Kumar's branch isn't merged yet. Right after the edit, Maya's Claude reads Kumar's change and says something like:

🔀 trail · Kumar is also changing defaultRetryMax on kumar/retry. He raises it to 10 and you're lowering it, so the two clash.

None of this needs a server. Learnings travel through git, like the code they are about.

A learning is a file

A learning is a short markdown file in .trail/learnings/, reviewed in the pull request like any other change:

---
title: Keep the default retry count at 4
author: Maya
date: 2026-10-09
cost: { tokens: 27400 }
touches:
  - client.go
---

## Decided
- Keep defaultRetryMax = 4: ten retries with the default backoff can hold one Do() call for over an hour.

## Tried and ruled out
- Raising the default to 10 for one customer: worst case, a single Do() call blocks for over an hour.

## Watch out
- RetryWaitMax caps each wait at 30s, not the total: the waits add up with every retry.

touches is how the next session on client.go finds it. A learning also records what the session spent working it out, in minutes and tokens. That is where "saved ~27k tokens" comes from: what the learning took to work out, less what it costs to read.

Where everything lives:

your-repo/
├── .trail/learnings/          learnings about this repo's code (commit them)
└── graft/                     the graft map, a local cache (gitignored)

~/.trail/                      your personal learnings, on this machine only

Your agent does the saving

Your agent uses learnings on its own, and saves one when you ask, at these moments:

  • On day one, what you told Claude before. trail init reads your own messages in the repo's past Claude Code sessions, leaving out tool output, pasted text and headless runs. It keeps only what you said in two or more sessions, and scrubs secrets.
  • When you ask, a learning. Say "save this as a learning" after a decision, something you ruled out, or a correction to how something is done here, and your agent saves it: what was decided, what was ruled out, what to watch out for. A summary, never a transcript, and nothing secret. It never saves one on its own, and doesn't offer to.
  • Before each task, the learnings on it. Each session starts with the learnings that apply to all work in the repo. Each prompt brings in the ones earlier sessions left on that code, above the code itself. A teammate's learning says whose it is.
  • Before a PR, the check. Your agent is told to run trail check before it commits, pushes or opens a pull request.
  • Never rewrites history. Your agent never edits an existing learning. When it goes against one, it says why in the commit, and saves a new one only when you say so.

The commands, if you want them:

trail note --title "<what it was about>"   # save a learning (the text on stdin); --personal keeps it in ~/.trail
trail check                                # check your branch against this repo's learnings and yours
trail team                                 # what the team learned this week, and where work overlaps
trail status                               # the graft map, learnings and tokens saved, on one screen

Your team

Learnings reach your teammates through git, with no server: commit .trail/, and every clone has them. Learnings on a teammate's pushed branch show up before it merges, marked "pushed and not merged yet", with only their first lines.

trail team shows the last 7 days in your terminal: what the team learned and where work overlaps.

trail team                     # this week's learnings and overlaps

Coming soon: a Trail workspace, for your team's view across repos. A team page will show who is learning what, how often learnings were reused, and where work overlaps.


What stays on your machine

  • Your code. The graft map is built on your machine with tree-sitter. No model, no network. The optional trail build --deep summaries go to the model provider you choose, under your own key.
  • Personal learnings. Kept in ~/.trail. Never committed, never uploaded.
  • Repo learnings. Files in your repo, shared through git like any other file.
  • Your past sessions. trail init reads your own messages from Claude Code's transcripts for the repo, on your machine. Your own Claude Code does the reading, with Claude Sonnet under your login, so your messages go only to Anthropic, and it counts toward your Claude usage. None of it goes to Trail.
  • Your PR reviews. Khi nào gh is installed and signed in, trail init reads the review comments on the repo's last 50 merged PRs with it, under your GitHub login. Anything that looks like a secret is taken out, and your own Claude Code reads them the same way. None of it goes to Trail.
  • If you connect a Trail workspace. No learning goes to Trail until you do, and the sign-in link tells Trail only the repo it was offered in. Once connected, the learnings committed in the repos you added go to Trail, including those on teammates' pushed branches. An edit you haven't committed, or a file git doesn't track, stays on your machine. Each search and check that used them sends which learnings were shown and whose they are, never what you typed or which files you were in. That is how the team page counts reuse.
  • Anonymous usage stats. Buckets and fixed labels only, never the title, text or paths of a learning. TELEMETRY.md lists every field. Turn it off with trail telemetry disable hoặc DO_NOT_TRACK=1.

Điểm chuẩn

An agent that reads the graft map should be cheaper and faster without getting more answers wrong. That's the whole claim, so we measured it instead of asserting it.

The harness ran three variants of the same agent loop on Claude Sonnet 5, with the same file tools: lạnh (khám phá từ con số 0), push (một trail ask --source bundle up front), and kéo (cái trail_find_code và trail_file_api tools, nothing injected, context paid for only when asked). An Opus 4.8 judge scored correctness with a required-keyword floor, so a fast but wrong answer couldn't win by being fast. Cost is cache-aware: reads ≈0.1×, writes 1.25×, the billing model agents actually run under.

162 runs, two repos (this one and a real Node/Express auth service), 3 trials each, tasks split between single-file and multi-file questions.

Số liệu (trung bình/nhiệm vụ) Cold agent Agent with the graft map (push)
Cost ($) 0.0429 0.0292 (32% lower)
Uncached input tokens 8,070 4,650 (42% fewer)
Tool calls 4.2 2.3 (46% fewer)
Latency (s) 39.8 15.8 (60% less)
Tính đúng đắn 93% 93% (bằng)

Push, the column above, gave up 3 correctness points on one corpus for its savings. The pull variant never answered worse than cold on any corpus, and gave up most of that speed for something bigger: correctness jumped to 98%, 5 points over cold, the strongest single result in the sweep. Push when speed is what you need; pull when being right matters more.


Đã xác minh băng ghế dự bị SWE

The sweep above is our harness measuring our mechanism. So we ran the industry-standard one too: Đã xác minh băng ghế dự bị SWE, số phát hành GitHub thực từ kho lưu trữ thực, được chính thức chấm điểm swebench khai thác. Không có mô hình đánh giá, không có điểm tương đồng: bản vá của bạn được áp dụng, các bài kiểm tra riêng của người bảo trì được chạy và bạn lật bài kiểm tra thất bại mà không phá vỡ các bài kiểm tra đạt hoặc bạn không làm như vậy.

50 trường hợp, the same model on both arms (Claude Bài sonnet 5), the same Docker images, the same turn limits. The only difference is whether the graft map is wired in.

Tính đúng đắn và hiệu quả Lạnh Claude Code Claude Code with the graft map Cải tiến
Tính đúng đắn 27 / 50 (54%) 33 / 50 (66%) +12 điểm
Tokens 142,0M 109,4 triệu 23% fewer
Chi phí $52.34 $42.43 19% lower
Tool calls 1,370 1,031 25% fewer
API requests 2,455 1,875 24% fewer
Đồng hồ treo tường 13.094 giây 8,922 giây 32% less

The graft map resolved 33 trên 50 trường hợp against cold Claude Code's 27, with 25% fewer tool calls, 23% fewer tokens and 32% less wall-clock time. Every correctness win has the same shape: the baseline patches one file and misses its siblings. On django-11532 it patched 1 of the 5 files the fix requires and broke 18 previously passing tests, twice over. On django-16263 it patched 1 of 4 and scored 102 / 103. The graft map found the rest, and on django-16263 đã làm điều đó với một nửa số token và một nửa thời gian.

Two harnesses, two claims: the controlled sweep says the graft map is cheaper and faster, SWE-bench says it's also more correct.

Tính đúng đắn trong mọi trường hợp; mã thông báo, chi phí và lệnh gọi trong các trường hợp cả hai nhóm đều được giải quyết, để so sánh tương tự. Hình ảnh được xác minh chính thức của SWE-bench swebench Học sinh lớp 4.1.0, x86_64 gốc.


Tested on popular repos

các điểm chuẩn measure the mechanism. The real test is whether the graft map helps an agent tàu thay đổi thực sự trên mã mọi người thực sự chạy chứ không chỉ trả lời các câu hỏi. Vì vậy, chúng tôi đánh giá nó trên các kho lưu trữ nguồn mở phổ biến: Mỗi nhiệm vụ 15, 10 câu hỏi thực sự dành cho nhà phát triển 5 nhiệm vụ triển khai thực tế (real merged pull requests, each re-implemented from its base commit and scored against the files the maintainers actually changed). Same agent (Claude Opus), same file tools; the only difference is whether the graft map is wired in.

On PocketBase the graft map ran 21% cheaper and 14% faster across the 15 tasks, and 2.6× cheaper on the hardest cross-file question, with no loss of correctness: it reproduced the real merged PRs by touching the same files the maintainers did.

PocketBase (Đi, ~350 tệp)

Tổng hợp hơn 15 nhiệm vụ Tiêu chuẩn Claude Code With the graft map
Chi phí $13.91 $11.02 (−21%)
Đồng hồ treo tường 2.044 giây 1.762 giây (−14%)
PR được sao chép 5 / 5 5/5 (cùng tệp với người bảo trì)

Cheaper and faster with no loss of correctness: the graft map reproduced all five merged PRs, touching the same files the maintainers did. The gap is widest on cross-file understanding: "how does auth work across OAuth2 providers" dropped from $2.19 to $0.84.

10 câu hỏi chúng tôi đã hỏi
  1. định hướng: Give me a map of PocketBase's architecture: the main subsystems and how an HTTP request flows through to the database.
  2. Dấu vết điểm vào: Trace end-to-end what happens when a client creates a record via the REST API, from route handler to database write.
  3. Vị trí đặc trưng: I want to add a brand-new collection field type. Where do I hook it in, and which pieces must change?
  4. Bản địa hóa lỗi: Realtime subscriptions silently stop delivering events after a while. Where would you start looking, and why?
  5. Bán kính vụ nổ: If I change the signature of the record-validation logic, what depends on it and what could break?
  6. Tổng hợp tập tin chéo: How does auth work across OAuth2 providers: where are tokens issued, validated, stored, and refreshed?
  7. Khả năng mở rộng: How do I use PocketBase as a Go framework to register a custom route plus an on-record-create hook?
  8. Khám phá bảo mật: Where is user input validated, and where are collection API access rules enforced before a query runs?
  9. Công khai API: As an external app, how do I authenticate and then list and filter records over the REST API?
  10. Kiểm tra xác minh: Where are the tests for the record CRUD API, and what do they assert about access rules?
5 PR sáp nhập chúng tôi đã triển khai lại

Each PR was reset to its base commit; the agent's diff was scored against the files the merged PR changed.

quan hệ công chúng Loại Nó làm gì Tập tin mà người bảo trì đã chạm vào
#6744 kỳ tích Tạo và phục vụ hình thu nhỏ WebP apis/file.go, tools/filesystem/filesystem.go
#6947 sửa chữa Phân phối char thống nhất trong chuỗi ngẫu nhiên biểu thức chính quy tools/security/random_by_regex.go
#6690 tái cấu trúc Patreon OAuth2 để sử dụng x/oauth2/endpoints tools/auth/patreon.go
#2726 hoàn hảo Bỏ truy vấn số lượng quản trị viên dư thừa vào đường dẫn phần mềm trung gian nóng apis/middlewares.go
#3192 sửa chữa Khôi phục các quy tắc API trước đó về khôi phục tự động di chuyển plugins/migratecmd/templates.go
phương pháp

Hai bản sao của PocketBase ở cùng một cam kết: một bản có dây với graft init, one untouched and verified to have no graft map in it. Each task run headless (claude -p, Claude Opus) with an empty MCP config. Understanding questions were graded by whether the answer pointed to the right files and functions; PR tasks were scored on whether the agent's diff touched the same files as the merged PR. Every transcript was audited to confirm the graft map was actually used in one arm and absent from the other.


Câu hỏi thường gặp

Is this graft? Yes. Trail-code is graft's new name, and graft lives on inside it as the graft map. The command is trail and the package is @trailhq/trail-code; graft và @nanonets/graft run the same code, print what they always printed, and keep working.

How is this different from Claude.md or AGENTS.md? You write those by hand, keep them current by hand, and your agent can skip them. Trail-code saves learnings from your conversations, brings in only the ones about the code you're working on, checks your changes against them before a PR, and adds a map of your code. It works next to your instruction files: trail init never touches your CLAUDE.md.

Will it fill up my context window? No. Each prompt gets only pointers to the matching code, and the learnings that match it, and a teammate's unmerged learnings show only their first lines. In our benchmark, uncached input tokens went down 42%.

Do I need an API key? No. The graft map, the hooks, learnings and trail check all work without one. A key only adds the written summaries from trail build --deep.

Do I need to sign in? No. Everything above works on your machine, and learnings reach your team through git. A Trail workspace, coming soon, is only for the team page across repos.

Which agents does it work with? Claude Code gets the deepest setup: hooks, statusline, and learnings with every prompt. Trail-code also wires Cursor, Codex and other AGENTS.md readers, Gemini CLI, GitHub Copilot, Windsurf, Kiro, Antigravity, Grok, Hermes and AdaL, and serves any agent that speaks MCP.

What if it learns something wrong? A repo learning is a file in your pull request, so it gets reviewed like the code it is about. Delete or edit the file to drop it. Personal learnings are files in ~/.trail, just as easy to change.

Does it work in monorepos? Yes: one repo with many packages, submodules, and folders of separate repos. See Monorepos.

What does it cost? The CLI is free and open source under the MIT license.


Cách đồ thị được xây dựng

The graft map is built in layers. Tier 1 is tree-sitter: every symbol and call edge, no model, no key. trail build --deep adds two language-model passes on top:

  1. Đọc từng tập tin. Mỗi tệp nguồn được tóm tắt một lần thành một mô tả ngắn gọn về chức năng của nó.
  2. Nhóm thành các nút. Those summaries are grouped into a curated set of nodes (subsystems, key files, and concepts) with typed links between them. The graft map chooses the right level of detail for you instead of making one node per file, so a big repo becomes a few dozen readable nodes.
flowchart LR
    S[Source files] --> T["Tier 1: tree-sitter<br/>no model, no key"]
    S --> P1["Pass 1: LLM summarizes<br/>each file (--deep)"]
    T --> W["graft/.graph/wiring.json<br/>per-symbol code graph"]
    P1 --> P2["Pass 2: group into nodes<br/>+ typed links"]
    P2 --> N["graft/*.md<br/>markdown node graph"]

Every pass is cached by content hash, the LLM ones and the tree-sitter parse alike. Re-running only touches the files that changed, so the second build is fast and cheap (on this repo, 312 files: about 5s cold, about 0.6s after one edited file or with nothing changed). trail build --no-reuse buộc phải phân tích lại lạnh.

Sự rẻ tiền đó là điều cho phép mọi truy vấn đều làm mới biểu đồ trước khi trả lời. A retrieval call stats the tree against the last build's fingerprint (about 50ms on this repo), and rebuilds only if something moved, so ask/grep/callers/skeleton/map describe the code as it is right now, including edits that are unsaved to git: uncommitted, unstaged, or staged all look the same to the graft map. Git determines the visible file set; freshness compares the working-tree bytes rather than commit or index state. The refresh is structural and $0; nó không bao giờ gọi LLM. Tắt nó theo lệnh với --no-refresh, hoặc ở mọi nơi với GRAFT_NO_REFRESH=1.

Bên cạnh biểu đồ đánh dấu, trail build xây dựng graft/.graph/wiring.json (a per-symbol code graph) plus a per-file wiring card mirroring your source tree. Tier 1 is pure tree-sitter (every function, class, and call edge; deterministic, no model, no network), which is why plain trail build không cần chìa khóa. các --deep pass thêm một bản tóm tắt một dòng và đoạn trích mấu chốt cho mỗi ký hiệu, được lưu trữ bằng hàm băm nội dung.


Ngôn ngữ được hỗ trợ

The graft map parses with tree-sitter at two levels of fidelity, plus an optional compiler-grade layer, all $0 và xác định (không có mô hình, không có khóa):

  • Độ trung thực hoàn toàn: hand-written extractors with scope-aware, cross-file call and import resolution: TypeScript / JavaScript (bao gồm JSX & TSX), Python, Đi, Java, Kotlin, PHP, Swift (các lớp, cấu trúc, enum, tác nhân, giao thức; thành viên mở rộng đính kèm với loại mở rộng), R (.R/.r: plain functions, S3/S4/R6 classes and methods, roxygen @export, library()/source() nhập khẩu).

  • Rộng: symbols (functions, classes, methods, types, …) plus name-resolved call edges via a generic tree-sitter extractor, one grammar per language: Rust, C, C++, C#, Ruby, Scala, Elixir, Solidity, Dart, Clojure, Nix, Lua, Gleam, Julia, PowerShellvà OCaml, Zig, GLSL (symbols only for now, no call edges). Bash (.sh, .bash) also uses this tier for function symbols; Bash call edges and extensionless shell scripts are not yet supported.

  • Single-file components: Vue (.vue), Svelte (.svelte) và Astro (.astro). The wrapper grammar only locates the <script> block (and Astro's --- frontmatter); the code inside goes through the full-fidelity TypeScript extractor, so a call from a component into a .ts module resolves to a real edge.

  • Các cạnh cấp trình biên dịch (chọn tham gia): trail build --lsp thêm chính xác lsp_resolved gọi các cạnh (thành viên gọi pass tĩnh không thể gõ) khi có máy chủ ngôn ngữ trên máy của bạn PATH: máy phân tích Rust (Rust), clangd (C/C++), gopls (Đi), quyền (Python), TypeScript-ngôn ngữ-máy chủ (TS/JS). Mixed-language repos use each applicable installed server, restricted to its own files. It's best-effort: a missing or failed server leaves those languages on the AST graph while the other servers still run.

Twenty-eight languages, plus Vue, Svelte and Astro single-file components. A file whose language isn't listed is skipped, not indexed. Adding a broad-tier language is a small contribution; see CREDITS.md dành cho những người đã thêm bộ hiện tại.


Có gì trong một nút

A node is a single markdown file. Most code maps stop at an address: this thing lives in that file, on that line. That tells an agent where to look, not what it will find, so it still has to open the source and read. A graft map node holds the meaning inline, so the agent learns what it needs up front and opens the file only when it wants more.

Mỗi nút giữ:

phần Nó chứa cái gì
Tóm tắt Giải thích bằng tiếng Anh đơn giản về chức năng của mã, được viết bởi mô hình và được lưu vào bộ nhớ đệm. Ở đó mã có từng được ghi lại hay không và nó được tạo lại khi nguồn thay đổi.
mấu chốt Một số dòng thực sự mang logic: bảo vệ, điều kiện bỏ qua, thay đổi trạng thái. Được lấy trực tiếp từ nguồn và được lưu trữ nội tuyến để tổng đài viên có thể nhìn thấy làm thế nào nó hoạt động, không chỉ những gì.
Nguồn The exact files the node is built from, each tracked by a content hash, so the graft map can tell precisely when a node has gone stale.
Liên kết Đã nhập kết nối đến các nút khác (depends_on, part_of, uses, implements, produces), được viết là [[wikilinks]] đại lý của bạn có thể làm theo.
Your text Bất cứ điều gì bạn viết bên dưới khối được tạo. Nó được bảo tồn qua các lần tái tạo, vì vậy ngữ cảnh của riêng bạn không bao giờ bị ghi đè.

Đó là ba độ sâu trong một tệp: bản tóm tắt cho biết cái gì mã có, điểm mấu chốt cho thấy làm thế nào, and the sources point to the rest if the agent needs it. A plain index makes it read a whole file to learn one thing. A graft map node hands it the answer inline, and the follow-up read often never happens.

Điểm mấu chốt được lưu trữ dưới dạng chính mã chứ không phải dưới dạng phạm vi dòng. Số dòng trôi đi bất cứ khi nào mã không liên quan phía trên chúng dịch chuyển, nhưng các dòng quan trọng thì không. Giữ văn bản chứ không phải số, có nghĩa là điểm mấu chốt vẫn chính xác ngay cả khi tệp xung quanh nó di chuyển.

Summary, sources, links, and your text ship today in markdown nodes. The crux ships per-symbol in the code graph (trail build --deep); tiếp theo là nội tuyến nó vào các nút đánh dấu.


Cái gì chạy đi đâu

  • Trên máy của bạn, không có chìa khóa, không có mạng: đồ thị mã cấu trúc. trail build (biểu đồ nối dây + thẻ trên mỗi tệp), trail build --check, trail ask, learnings and trail check are deterministic. They never call a model.
  • Thông qua khóa nhà cung cấp của bạn: the LLM-written parts. trail build --deep adds the concept nodes (file summaries + node synthesis) and the per-symbol summaries and cruxes. The graft map is vendor-neutral: set GRAFT_PROVIDER (openai đối với mọi điểm cuối tương thích với OpenAI, anthropic cho API gốc, hoặc litellm / orcarouter đối với cổng có định dạng tương thích với OpenAI), bạn GRAFT_API_KEY, GRAFT_MODEL, and, for the openai wire format, GRAFT_BASE_URL để trỏ tới OpenRouter, Fireworks, Groq, proxy LiteLLM, máy chủ cục bộ hoặc chính OpenAI. Hoặc vượt qua --provider/--model/--api-key/--base-url trên dòng lệnh. (OPENROUTER_API_KEY vẫn hoạt động như một phương án dự phòng không được dùng nữa và ORCAROUTER_API_KEY như cái thứ hai.)
  • Through Trail, only if you connect a workspace: the learnings committed in the repos you added, and which of them each search and check showed. See What stays on your machine.
  • Anonymous usage stats: a daily npm version check and one batched usage ping. The ping carries buckets and fixed labels only: never your code, file paths, repo name, symbols, queries, learnings or error messages. TELEMETRY.md là danh sách đầy đủ và trail telemetry debug prints exactly what your machine would send. DO_NOT_TRACK=1 disables both network calls; trail telemetry disable or unchecking the box in trail init disables only the usage ping. The ping is off in CI and in any build from source.

Settings keep their GRAFT_ names. See .env.example for the full list (model, base URL, graph directory).


Tích hợp đại lý

One command wires Trail-code into the coding agents you use:

npm install -g @trailhq/trail-code && trail init
# detects your agents and writes each one's native instruction file;
# Claude Code additionally gets the live statusline + hooks below

Trên một thiết bị đầu cuối, init shows you every agent it knows about, flags the ones it detected (via their config directories), lists the exact files each would write, and wires only the ones you select. Claude Code is pre-selected; nothing else is. Selected agents get a marker-fenced Trail-code section in their shared instruction file (AGENTS.md for Codex, OpenCode and other CLIs that read it, GEMINI.md, .github/copilot-instructions.md), or a wholly-owned rule or skill file for the agents that use one, such as .claude/skills/trail/SKILL.md và .cursor/rules/trail.mdc. Claude Code thuộc nhóm thứ hai: init ghi tập tin kỹ năng của riêng mình và không bao giờ chạm vào CLAUDE.md. For selected agents, re-running updates only Trail-code's own section (or replaces the owned file) and never touches the rest of your content.

Selection replaces the previous set; it is not additive. init removes Trail-code's wiring for unselected agents, including their user-level files by default. Those removals affect every repo you use with that agent, not just this one. Pass every agent you want to keep (for example, trail init --agents claude hermes), or add --no-global to leave user-level files alone while changing this repo's wiring.

In Claude Code, the committed skill file is also how a teammate without Trail-code installed gets your learnings: it tells their agent where .trail/learnings/ is, to read it before exploring, and to tell them once how to install the rest.

With no TTY to prompt on (CI, a Dockerfile, a piped shell), init viết không có gì và in lệnh để chạy thay thế. Vượt qua --agents <ids> hoặc --yes để làm cho việc chạy theo kịch bản trở nên rõ ràng.

Cờ Hiệu ứng
--agents <ids...> wire these and remove Trail-code's wiring for all unlisted agents, including user-level files (unless --no-global); pass every agent you use; no prompt; ids: agents, adal, cursor, gemini, grok, hermes, antigravity, copilot, kiro, windsurf, claude
--yes, -y bỏ qua lời nhắc và nối dây mỗi phát hiện đại lý
--dry-run print the agent wiring init would write, then exit without writing
--just-me trail just for you in this repo: git sees none of it and your learnings stay in ~/.trail
--team share trail with your team: commit .trail/ và .claude/settings.json một lần
--all-agents ghi tập tin hướng dẫn cho mọi tác nhân đã biết, được phát hiện hay không
--no-agents chỉ nối dây Claude Code; bỏ qua các đại lý khác
--list-agents in id tác nhân đã biết và thoát
--no-mcp skip MCP registration for agents other than Claude Code
--no-hooks skip hook installation for agents other than Claude Code
--no-statusline bỏ qua việc viết Claude Code statusLine (giống như GRAFT_NO_STATUSLINE=1)
--no-global skip writes and removals outside this repo (the user-level files below)

Viết bên ngoài repo

Some agents also get cấp độ người dùng files, so the wiring follows you into worktrees and folders the repo's files don't reach:

đại lý Đường dẫn Những thay đổi gì
Claude Code ~/.claude/settings.json SessionStart, UserPromptSubmit, PreToolUse (on Bash), PostToolUse và Stop móc
Claude Code ~/.claude/helpers/graft-hooks.cjs the hooks shim they call
Claude Code ~/.claude.json cái trail máy chủ MCP
Codex (agents), when ~/.codex/ exists ~/.codex/config.toml cái trail máy chủ MCP
Codex ~/.codex/hooks.json the same five hook events, matching apply_patch|Write|Edit|MultiEdit after edits
Codex ~/.codex/hooks/graft/graft-hooks.cjs the hooks shim
Pi ~/.pi/agent/extensions/graft-hooks.ts the same four hook events as an extension (session_start, before_agent_start, tool_result, agent_end)
Pi ~/.pi/hooks/graft/graft-hooks.cjs the hooks shim it spawns
phản trọng lực ~/.gemini/config/mcp_config.json cái trail máy chủ MCP
phản trọng lực ~/.gemini/skills/trail/SKILL.md its skill file

These apply to mỗi repo you open with that agent, not just this one. The picker labels them machine-wide, --dry-run liệt kê chúng trong phần riêng của họ, và --no-global skips them all while still wiring the repo's own files.

máy chủ MCP

trail init also registers the Trail-code MCP server with agents that support it, so these six tools appear natively, no shell required. Claude Code gets this too: trail init ghi máy chủ vào dự án .mcp.json (restart Claude Code to load it). Run it by hand with trail mcp [dir].

Công cụ Mất Nó dùng để làm gì
trail_find_code một câu hỏi Ranked nodes with file:line, source inlined; usually the full answer, no follow-up read needed.
trail_file_api một đường dẫn tập tin Every signature in that file, no bodies: the API surface for a tenth of the tokens.
trail_trace_calls một biểu tượng Ai phụ thuộc vào nó, hoặc nó phụ thuộc vào cái gì direction: out, N cấp độ sâu cho bán kính vụ nổ.
trail_find_all một biểu thức chính quy Mỗi lần truy cập, được nhóm theo biểu tượng kèm theo, được xếp hạng theo mức độ liên kết của biểu tượng đó.
trail_repo_map không có gì Cái nhìn đầu tiên về một kho lưu trữ xa lạ: cụm thư mục, trung tâm, điểm phát sóng.
trail_check_freshness không có gì Biểu đồ cục bộ có bị lệch khỏi mã hay không.

The same server still answers the old graft_* tool names. Register it by hand if your agent needs it explicit:

{ "mcpServers": { "trail": { "command": "npx", "args": ["-y", "@trailhq/trail-code", "mcp"] } } }

Trong đó tác nhân CLI hỗ trợ cấp người dùng hooks.json, as Codex does, init also installs Trail-code's hooks there: session start, context with each prompt, blast radius and a $0 graph re-sync after edits, and the end-of-turn sync (skip with --no-hooks).

Claude Code (tích hợp sâu)

When Claude Code is selected (it is by default), it gets more than the skill file above. From then on, any Claude Code session opened in the repo gets:

  • một dòng trạng thái trực tiếp: the folder you're in, the graft map's size, how many learnings the repo has, and a ⚠ N stale warning when the code has moved ahead of the map
  • tự động đồng bộ hóa: every query brings the graph up to date first, so an answer always describes the code as it is right now, uncommitted edits included. A query refreshes only what it reads; the markdown under graft/ được làm mới bằng cách xây dựng lại nền ở cuối lượt chạm vào mã. Cả hai đều có cấu trúc và $0; auto-sync never calls the LLM on its own
  • bối cảnh trên máy: each prompt pulls in the matching nodes and the learnings left on that code; editing a file surfaces what depends on it ("blast radius"); new sessions start with the repo map and how many learnings there are
  • learnings when you ask: say "save this as a learning" and Claude saves one; it never asks to on its own
  • overlap with teammates: at session start, and every few minutes, it reads what teammates' open branches change, skipping any already merged or closed; when Claude edits a function or constant one of them also changes, it reads their change and tells you whether the two clash

The post-edit hook: editing node-file.ts prints its blast radius (who depends on it) inline, the statusline flips stale → syncing → synced on its own, and the same dependents light up in the viewer
edit a file → blast radius appears inline → graph auto-resyncs → confirmed in the viewer

trail init là bình thường và không bao giờ làm hỏng hiện tại của bạn .claude/settings.json: it merges its blocks and leaves the rest alone. A statusLine that is not Trail-code's, in ~/.claude/settings.json or the repo's own settings, is kept, and Trail-code adds its own only where you have none; re-running init refreshes Trail-code's own helper command if it is already installed. Pass --no-statusline (hoặc GRAFT_NO_STATUSLINE=1) to skip installing one at all. Want the LLM summaries too? Run trail build --deep (có chìa khóa) bất cứ khi nào bạn muốn; tự động đồng bộ hóa sẽ không bao giờ làm điều đó cho bạn.


CLI

trail --help lists the commands in four groups. Every graft command still works too.

# find code · your agent runs these
trail ask "<task>" [dir]             # the matching code and learnings: ranked nodes + exact file:line (no LLM, no key)
trail ask "<task>" --json            # machine-readable result
trail ask "<task>" --in <scope>      # narrow to one sub-project of a monorepo/multi-repo folder (see below)

trail grep "<regex>" [dir]           # exhaustive regex search over indexed files, grouped by enclosing symbol (no LLM, no key)
trail grep "<regex>" --in <path>     # narrow to files at or under this path prefix
trail grep "<regex>" -i --fixed      # case-insensitive; treat the pattern as a literal string, not a regex

trail skeleton <file> [dir]          # every signature in one file, no bodies: the API surface for ~1/10th the tokens (no LLM, no key)

trail callers <symbol> [dir]         # who calls/references/imports/implements/extends a symbol (no LLM, no key)
trail callers <symbol> --direction out  # the reverse: what the symbol itself calls/references
trail callers <symbol> -d N          # walk transitively out to depth N: full blast radius

trail map [dir]                      # token-budgeted repo orientation: dir clusters, hubs, hotspots (no LLM, no key)
trail map --max-dirs N               # raise/lower the number of directories shown

# ask / skeleton / callers / grep / map / blast all refresh the graph first if the working tree moved:
#   --no-refresh                     # answer from the graph exactly as it is on disk
#   GRAFT_NO_REFRESH=1               # same, for every command
#   GRAFT_REFRESH=hash               # hash every file instead of trusting size+mtime

# learnings
trail note --title "<about>" [dir]   # save a learning: what this session decided, tried and ruled out (the text on stdin)
trail note --always-follow           # mark it always follow: your agent won't go against it, even if asked
trail note --personal                # about your own setup, not the code: keep it in ~/.trail, out of the repo
trail check [dir]                    # check your branch's diff against the repo's learnings, yours and your skills (exit 1 on a conflict)
trail check --base origin/main       # compare against this base instead of origin's default branch
trail team [dir]                     # what the team learned this week, who's working on what, and where work overlaps
trail skills [--json]                # your skills: scope, status, uses; held ones; jobs Trail is counting; offers
trail skills off | on [<name>]       # skills are on by default: turn them off, or back on (only you, in your own terminal); or one skill
trail skills offers on | off [--here] # skill offers everywhere, or just this repo (only you turn them on)
trail skills show <name>             # print a skill and its status
trail skills keep <name>             # keep a skill Trail held because nobody said yes (only you)
trail forget <name>                  # forget a skill; trail skills restore <name> brings it back

# setup
trail init [dir]                     # pick which agents to wire (prompts on a terminal; writes nothing until you choose)
trail init --dry-run                 # list the agent wiring it would write, then exit
trail init --agents cursor kiro      # replace the selection; remove other agents' wiring, including user-level files
                                     # pass every agent you use; --no-global leaves user-level files alone
trail init --yes                     # no prompt; wire every detected agent
trail init --no-global               # skip writes and removals outside this repo (~/.claude, ~/.claude.json, ~/.codex, ~/.gemini)
trail init --no-statusline           # skip Claude Code statusLine (same as GRAFT_NO_STATUSLINE=1)
trail init --no-build                # wire the files only; don't build the graph
trail init --all-agents              # wire every known agent, detected or not
trail init --list-agents             # list known agent ids and exit

trail build [dir]                    # build the graft map in graft/: wiring graph + per-file cards (no LLM, no key)
trail build --deep                   # add the LLM layer: concept nodes + per-symbol summary/crux (cached)
trail build --check                  # build nothing: fail (exit 1) if graft/ has drifted from the code, for CI
trail build -e .ts .py               # only index these extensions (also limits --deep summaries)
trail build --no-reuse               # re-parse every file instead of replaying unchanged ones from cache
trail build --follow-submodules      # include initialized submodules; persist the choice for builds + MCP refresh
trail build --no-follow-submodules   # exclude submodules again and persist that choice (the default)
trail build --follow-nested-repos    # include nested git clones the index doesn't track; persist the choice
trail build --no-follow-nested-repos # exclude nested clones again and persist that choice (the default)

trail status [dir]                   # the graft map, learnings and tokens saved, on one screen
trail upgrade                        # npm install -g the latest published version
                                     # a new version is announced automatically (checked once a day);
                                     # after upgrading, the next session refreshes this repo's wiring itself
trail uninstall [dir]                # remove every file and config entry it wrote here (the inverse of init)
trail uninstall -y                   # actually remove (without -y it prints what it would remove and exits)
trail uninstall --keep-cache         # wiring only; leave graft/ and the .gitignore entry
trail uninstall --no-global          # leave out-of-repo files alone (~/.claude, ~/.claude.json, ~/.codex, ~/.gemini)
trail telemetry [status|enable|disable|debug]   # anonymous usage stats; debug prints exactly what would be sent

# CI
trail blast [dir]                    # blast radius of a diff: what depends on the lines this change touched (no LLM, no key)
trail blast --base origin/main       # diff against the merge base with HEAD (what a PR job runs)
trail blast --format markdown        # a PR comment: the areas a change can reach, per-symbol detail collapsed under it
trail blast --base origin/main --name  # name those areas with one cached LLM call, instead of a full --deep build
trail blast --export-viz site/       # also write the interactive page for this radius (what a PR comment links to)
trail blast --no-owners              # skip "who to tag" (by default, git history names the people behind each area)
trail blast --depth all --format json  # the full transitive closure, machine-readable

# not listed in --help, still there
trail viz [dir]                      # see the graph: serves an interactive viewer on localhost
trail viz --export site/ --title "PR #12"  # one self-contained index.html for CI, GitHub Pages, or a build artifact
trail mcp [dir]                      # run the MCP server by hand

# global
trail --dir <path>                   # use a context dir other than <repo>/graft
trail --version, -v                  # print the installed version and exit

Extension selections also apply to automatic refreshes. Run an explicit trail build không có -e to index all supported extensions again.

Method calls resolve through the receiver's type, using constructor assignments (self.router = APIRouter()) and type annotations, not just the call-site name, so callers/grep --in trả về các cuộc gọi được liên kết với đúng loại trên mã nặng phương thức, không phải mọi phương thức ở bất kỳ đâu có tên đó.

Tìm kiếm & định hướng (trail grep / trail map)

trail grep "<regex>" đầy đủ đối với mọi tệp được lập chỉ mục và nhóm các lượt truy cập bằng ký hiệu kèm theo, được xếp hạng theo cùng một khớp nối trong cạnh trail map uses. It's built for "every occurrence of this pattern" tasks where trail askđược xếp hạng top-N là không đủ:

"NEEDLE" — 2 hits in 2 symbols across 1 files (searched 1 indexed files)

heavilyCalled · function · src/a.ts:L1-L3 · 3 in-edges
  L2: console.log("NEEDLE hit in heavilyCalled");

rarelyCalled · function · src/a.ts:L4-L6 · 0 in-edges
  L5: console.log("NEEDLE hit in rarelyCalled");

trail map is a token-budgeted first look at a repo: directory clusters with file/symbol counts, each dir's local hubs, and the global hotspots, all ranked by in-degree, no LLM, no key:

repo map — 313 files · 2349 symbols · 8148 edges · javascript, typescript

src/                157 files · 1804 symbols   hubs: wiringPath (write.ts, 48←), cmd (brand.ts, 45←), buildGraph (build.ts, 39←)
test/               144 files · 467 symbols   hubs: tmpRepo (helpers.ts, 46←), fetch (app-identity.test.ts, 7←), fakeProviders (helpers.ts, 5←)
viewer/             5 files · 71 symbols   hubs: $ (main.ts, 9←), cvar (data.ts, 6←), activeGraph (main.ts, 5←)
scripts/            7 files · 7 symbols   hubs: bump (graph-quality.mjs, 1←), defaultTranscriptDir (tally-audit.mjs, 1←), flush (tally-audit.mjs, 1←)

hotspots: wiringPath · function · src/graph/write.ts:L20-L22 · 48←  tmpRepo · function · test/helpers.ts:L30-L32 · 46←  cmd · function · src/brand.ts:L63-L70 · 45←  ...

Monorepos, mô-đun con và thư mục đa repo

The graft map supports these layouts:

  • Một monorepo với một .git (một pnpm-workspace.yaml/package.json workspaceshoặc mỗi gói go.mod/pyproject.toml/Cargo.toml): trail build khám phá từng tiểu dự án như một phạm vi xếp hạng. ask/map xếp hạng mọi phạm vi theo cách riêng của nó và tổng hợp các kết quả, để tiểu dự án lớn nhất không thể nhấn chìm một tiểu dự án nhỏ; lượt truy cập mang theo [scope/] nhãn và trail map nhóm các cụm thư mục của nó theo phạm vi trước tiên.
  • Siêu dự án Git với các mô-đun con được khởi tạo: submodules stay excluded by default. Run trail build --follow-submodules để gấp các liên kết git đã khởi tạo vào một biểu đồ, thêm tiền tố vào các đường dẫn con (ví dụ: deps/parser/src/index.ts) trong khi tôn trọng các quy tắc bỏ qua Git của mỗi mô-đun con. Các tập tin không bị theo dõi có thể nhìn thấy cũng được bao gồm; các mô-đun con chưa được khởi tạo vẫn vắng mặt cho đến khi git submodule update --init kiểm tra chúng. Lựa chọn được lưu vào .graft/config.json, do đó, các bản dựng không gắn cờ sau này và các lần làm mới tự động MCP sẽ hoạt động theo cách tương tự. Chạy trail build --no-follow-submodules để khôi phục và duy trì ranh giới mặc định.
  • Một repo git với các repo khác được sao chép bên trong nó (no gitlink, no index entry): the shape multi-repo manifest tools like west, repo, gclient và tsrc kiểm tra các phần phụ thuộc và hình dạng bạn có được bằng cách sao chép ngược dòng vào cây để vá cục bộ. --follow-submodules không thể đạt được những điều này: họ không có 160000 mục nhập chỉ mục để theo dõi. Chạy trail build --follow-nested-repos để xếp chúng thành một biểu đồ, thêm tiền tố vào các đường dẫn con (ví dụ: external/parser/src/index.ts) trong khi tôn trọng các quy tắc bỏ qua Git của mỗi bản sao. Một bản sao ở đường dẫn bị bỏ qua git sẽ không xuất hiện vì Git không bao giờ báo cáo nó. Lựa chọn được lưu vào .graft/config.json và độc lập với --follow-submodules; neither flag implies the other. Run trail build --no-follow-nested-repos để khôi phục và duy trì ranh giới mặc định. Ưu tiên điều này hơn cách phân chia nhiều repo bên dưới khi các repo lồng nhau nhập từ nhau và bạn muốn các cạnh đó trong một biểu đồ; thích sự phân chia hơn khi bạn muốn mỗi repo được ghi điểm và làm mới riêng.
  • Một thư mục chứa các kho git riêng biệt (không .git at the top): trail build tự động phân chia: mỗi đứa trẻ có một phần riêng (bỏ qua git) graft/, và cha mẹ nhận được một graft/workspace.json chỉ số. Các truy vấn từ liên kết gốc đối với mọi thành phần con, luôn được gắn nhãn <child>/. Chạy trail build bên trong một đứa trẻ để làm việc trên kho lưu trữ đó.

Trong mọi cách bố trí, hãy thu hẹp vào một tiểu dự án với trail ask "<task>" --in <scope>/ một khi bạn biết bạn đang làm việc ở đâu.

trail init ở phần gốc của dây thư mục multi-repo mỗi repo con cũng vậy, not just the parent. An agent session opens at a repo root and reads its instruction files from there, so each child needs its own. A session started in the parent gets the federated view; one started in a child sees that repo alone.

Các lệnh cũng tìm thấy biểu đồ từ thư mục con: không có [dir] tranh luận họ đi đến nơi gần nhất graft/, vậy trail ask hoạt động từ src/deep/inside/ không có cd vào thư mục gốc repo.

Hãy hình dung nó (trail viz)

trail viz opens a local, interactive view of both graphs. No install, no dev server; the viewer ships prebuilt inside the package.

The graph viewer: searching a symbol and jumping to it lights up its dependency graph: amber edges are what it depends on, indigo is what depends on it
tìm kiếm → chuyển đến một nút → biểu đồ phụ thuộc sáng lên

  • Bối cảnh tab: the architecture graph from graft/*.md. Các nút được tô màu theo loại, kích thước theo mức độ kết nối.
  • Code tab: the per-symbol graph from graft/.graph/wiring.json (chạy trail build đầu tiên).
  • phác thảo tab: the file → class → method hierarchy as a collapsible tree.

Các cạnh nói ngôn ngữ của mã. Mỗi liên kết là một trong những tập hợp động từ đóng, mỗi liên kết trả lời một câu hỏi mà ai đó đang xây dựng hoặc xem lại mã thực sự hỏi:

Động từ Câu hỏi nó trả lời
part_of / contains cái này sống ở đâu?
uses / calls / imports / depends_on điều gì sẽ xảy ra nếu tôi thay đổi điều này?
produces đầu ra này đến từ đâu?
configures điều gì thay đổi hành vi của nó mà không thay đổi mã?
validates những gì kiểm tra hoặc đánh giá điều này? (kiểm tra, kiểm tra độ trôi, tính điểm)
extends / implements hợp đồng này phải tôn trọng những gì?
references what names this without calling it? (drawn as faint dots)

Chọn một nút và các cạnh của nó có hướng: amber = what it depends on, indigo = what depends on it, with the verb written on each highlighted edge. Chips above the canvas filter by verb; edges the parser resolved exactly draw solid, while edges matched by name alone, or inferred by the model, draw dashed. The viewer live-reloads when graft/ những thay đổi trên đĩa. Các biểu đồ cũ hơn với các động từ mơ hồ (influences, supports) are normalized on load, so no regeneration is needed.


Phát triển

git clone https://github.com/trailhq/Trail-Code.git && cd Trail-Code
npm install
npm run build
npm test

npm run cli -- build --deep .      # run the CLI from source

Giấy phép

MIT. Nhìn thấy GIẤY PHÉP.

Dự án cùng danh mục

morluto/rea

Reverse engineer anything with agents, from app behavior down to native binaries.

474k116k14 phút trước
GitHubAI AgentTypeScript

openclaw/openclaw

AI thực sự làm được mọi việc. Bất kỳ hệ điều hành nào. Bất kỳ nền tảng nào. Cách tôm hùm. 🦞

395k83k15 phút trước
GitHubAI AgentTypeScript

mattpocock/skills

Kỹ năng dành cho kỹ sư thực sự. Trực tiếp từ thư mục .agents của tôi.

331k28k3 ngày trước
GitHubAI AgentShell

affaan-m/ECC

Hệ thống tối ưu hóa hiệu suất khai thác tác nhân. Kỹ năng, bản năng, trí nhớ, bảo mật và sự phát triển ưu tiên nghiên cứu cho Claude Code, Codex, Opencode, Cursor và hơn thế nữa.

309k45k25 phút trước
GitHubAI AgentJavaScript

deepseek-ai/deepseek-harness

DeepSeek Khai thác: Mọi thứ đều là Plugin.

286k36k18 giờ trước
GitHubAI AgentTypeScript

NousResearch/hermes-agent

Đại lý phát triển cùng bạn

265k60k23 phút trước
GitHubAI AgentPython
NanoNets/Graft — Repo Trending