{"id":47809042,"url":"https://github.com/flyingrobots/graft","last_synced_at":"2026-05-01T08:01:22.276Z","repository":{"id":348785269,"uuid":"1199115508","full_name":"flyingrobots/graft","owner":"flyingrobots","description":"Replay-safe structural reads for coding agents","archived":false,"fork":false,"pushed_at":"2026-04-03T03:58:30.000Z","size":212,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-03T06:55:29.255Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flyingrobots.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-02T04:05:05.000Z","updated_at":"2026-04-03T00:22:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/flyingrobots/graft","commit_stats":null,"previous_names":["flyingrobots/graft"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/flyingrobots/graft","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyingrobots%2Fgraft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyingrobots%2Fgraft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyingrobots%2Fgraft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyingrobots%2Fgraft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flyingrobots","download_url":"https://codeload.github.com/flyingrobots/graft/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyingrobots%2Fgraft/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31368156,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T17:53:18.093Z","status":"ssl_error","status_checked_at":"2026-04-03T17:53:17.617Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-03T18:01:31.915Z","updated_at":"2026-05-01T08:01:22.269Z","avatar_url":"https://github.com/flyingrobots.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Graft\n\nA context governor for coding agents. Graft enforces read policy so agents consume the smallest structurally correct view of a codebase instead of dumping raw files into their context window.\n\nGraft is designed for the operator who demands precision and the architect who needs a stable foundation for agentic work. It scales from simple policy-aware reads to high-fidelity causal provenance tracking across multi-session worktrees.\n\n[![npm version](https://img.shields.io/npm/v/@flyingrobots/graft)](https://www.npmjs.com/package/@flyingrobots/graft)\n\n![Graft demo](./docs/assets/graft.svg)\n\n## Why Graft?\n\nUnlike simple file-scraping tools, Graft treats the repository as a layered worldline of code structure and causal activity.\n\n- **Policy-Enforced Reads**: Automatically degrades large files to structural outlines and jump tables. Refuses binaries, secrets, and lockfiles with machine-readable reasons.\n- **Machine-Readable Contracts**: Responses carry versioned `_schema` metadata and decision receipts so agents can reason about outcomes without scraping prose.\n- **Structural Memory**: Uses WARP (Structural Worldline Memory) to track AST evolution across Git commits. Query what changed structurally without reading a single byte of source code.\n- **Causal Provenance**: Tracks the *why* behind structural changes by logging read, stage, and transition activity into strand-scoped causal workspaces.\n- **Industrial-Grade Daemon**: A same-user local runtime that manages multi-repo authorization, background indexing, and shared-machine worker pools.\n\n## Quick Start\n\nGraft has three official entry points:\n\n- **API** for direct in-process integration\n- **CLI** for operator and debugging workflows\n- **MCP** for agent transport integration\n\n### 1. Bootstrap a Repo\nScaffold `.graftignore`, setup git hooks, and seed agent instructions.\n```bash\nnpx @flyingrobots/graft init --write-claude-hooks --write-codex-mcp\n```\n\n### 2. Repo-Local Stdio MCP\nThis is the simplest per-repo path for most clients. The current\ncheckout is the authority, and there is no separate workspace binding\nstep.\n```bash\nnpx @flyingrobots/graft serve\n```\n\n### 3. Standalone CLI\nEnforce policy on a single read or inspect structural history.\n```bash\nnpx @flyingrobots/graft read safe src/app.ts\nnpx @flyingrobots/graft struct since HEAD~3\n```\n\n### 4. Direct Library API\nEmbed Graft in-process when you want direct access without MCP transport\nor CLI process orchestration.\n```ts\nimport { createRepoLocalGraft, callGraftTool } from \"@flyingrobots/graft\";\n\nconst graft = createRepoLocalGraft({ cwd: process.cwd() });\nconst outline = await callGraftTool(graft, \"file_outline\", { path: \"src/app.ts\" });\n```\n\nThis uses the same repo-local core as the CLI and MCP server, but it\nlets host tools call Graft directly inside the same process.\n\nWhen you want a direct repo-local read surface instead of tool receipts,\nuse the workspace API:\n```ts\nimport { createRepoWorkspace } from \"@flyingrobots/graft\";\n\nconst workspace = await createRepoWorkspace({ cwd: process.cwd() });\nconst first = await workspace.safeRead({ path: \"src/app.ts\" });\nconst second = await workspace.safeRead({ path: \"src/app.ts\" });\nconst outline = await workspace.fileOutline({ path: \"src/app.ts\" });\n```\n\nThis exposes the same governed repo-local read behavior that the MCP\nsurface uses for `safe_read`, `file_outline`, `read_range`, and\n`changed_since`, but without going through MCP receipts at all.\n\nFor close editor integration, use the buffer-native surface directly:\n```ts\nimport { createProjectionBundle, createStructuredBuffer } from \"@flyingrobots/graft\";\n\nconst buffer = createStructuredBuffer(\"src/app.tsx\", liveEditorText, {\n  basis: { kind: \"editor_head\", headId: \"head-42\", tick: 17 },\n});\nconst spans = buffer.syntaxSpans({\n  viewport: {\n    start: { row: 0, column: 0 },\n    end: { row: 80, column: 0 },\n  },\n});\nconst context = buffer.nodeAt({ row: 24, column: 12 });\nconst rename = buffer.renamePreview({\n  position: { row: 24, column: 12 },\n  nextName: \"nextValue\",\n});\n\n// Every warm result now carries the basis it was derived from.\nconsole.log(spans.basis);\n\nconst bundle = createProjectionBundle(\"src/app.tsx\", liveEditorText, {\n  basis: { kind: \"editor_head\", headId: \"head-42\", tick: 17 },\n  viewport: {\n    start: { row: 0, column: 0 },\n    end: { row: 80, column: 0 },\n  },\n});\n\nconsole.log(bundle.parseStatus.status);\n```\n\n### 5. Shared Daemon Runtime\nStart the same-user execution authority for multi-session or multi-repo\nwork.\n```bash\nnpx @flyingrobots/graft daemon\n```\n\nDaemon sessions start `unbound`. If your client connects through the\ndaemon instead of repo-local stdio, the first repo-scoped flow is:\n\n1. `workspace_authorize` for the target repo/worktree\n2. `workspace_bind` for the active daemon session\n3. then use repository-scoped tools such as `safe_read`\n\nUse [docs/SETUP.md](./docs/SETUP.md) for the exact client bootstrap and\ndaemon control-plane posture.\n\n## Documentation\n\n- **[Guide](./GUIDE.md)**: Orientation, the fast path, and agent bootstrap.\n- **[Setup Guide](./docs/SETUP.md)**: Client-specific MCP setup, daemon posture, and workspace binding.\n- **[Advanced Guide](./ADVANCED_GUIDE.md)**: Deep dives into the pipeline, worldlines, and daemon mechanics.\n- **[Architecture](./ARCHITECTURE.md)**: The authoritative structural reference (Ports, Adapters, WARP).\n- **[Public API Contract](./docs/public-api.md)**: The semver-public root import surface and stability policy.\n- **[Repo Topology](./docs/repo-topology.md)**: Where API, CLI, MCP, and the core live in the source tree.\n- **[Three-Surface Capability Matrix](./docs/three-surface-capability-matrix.md)**: Current API / CLI / MCP baseline and peer posture.\n- **[Security Model](./docs/strategy/security-model.md)**: Same-user daemon trust boundaries, authz, and observability posture.\n- **[Causal Provenance](./docs/strategy/causal-provenance.md)**: Transport sessions, causal workspaces, strands, and handoff truth.\n- **[Vision](./docs/VISION.md)**: Core tenets and the provenance-aware mission.\n- **[Method](./METHOD.md)**: Repo work doctrine and the cycle loop.\n\n---\nBuilt with precision by [FLYING ROBOTS](https://github.com/flyingrobots)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflyingrobots%2Fgraft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflyingrobots%2Fgraft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflyingrobots%2Fgraft/lists"}