agent-trellis 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +97 -38
  2. package/dist/adapters/claude-code.js +3 -2
  3. package/dist/adapters/codex.js +3 -2
  4. package/dist/adapters/jsonMcp.d.ts +3 -1
  5. package/dist/adapters/jsonMcp.js +18 -4
  6. package/dist/adapters/kimi-code.d.ts +21 -0
  7. package/dist/adapters/kimi-code.js +107 -0
  8. package/dist/adapters/kiro.js +3 -2
  9. package/dist/adapters/mcpPlan.d.ts +6 -1
  10. package/dist/adapters/mcpPlan.js +106 -8
  11. package/dist/adapters/pi.js +22 -3
  12. package/dist/adapters/symlinkPlan.d.ts +7 -0
  13. package/dist/adapters/symlinkPlan.js +16 -7
  14. package/dist/cli.js +121 -21
  15. package/dist/commands/doctor.d.ts +7 -2
  16. package/dist/commands/doctor.js +38 -2
  17. package/dist/commands/init.d.ts +4 -2
  18. package/dist/commands/init.js +26 -13
  19. package/dist/commands/kimi.d.ts +16 -0
  20. package/dist/commands/kimi.js +64 -0
  21. package/dist/commands/manage.d.ts +39 -0
  22. package/dist/commands/manage.js +126 -0
  23. package/dist/commands/mcp.d.ts +22 -1
  24. package/dist/commands/mcp.js +65 -2
  25. package/dist/commands/mcpGateway.d.ts +6 -0
  26. package/dist/commands/mcpGateway.js +34 -14
  27. package/dist/commands/mcpImport.d.ts +27 -0
  28. package/dist/commands/mcpImport.js +336 -0
  29. package/dist/commands/memory.d.ts +5 -3
  30. package/dist/commands/memory.js +12 -8
  31. package/dist/commands/migrate.d.ts +16 -5
  32. package/dist/commands/migrate.js +90 -17
  33. package/dist/commands/onboard.d.ts +74 -2
  34. package/dist/commands/onboard.js +458 -71
  35. package/dist/commands/rollback.js +4 -1
  36. package/dist/commands/skill.d.ts +17 -0
  37. package/dist/commands/skill.js +47 -2
  38. package/dist/commands/sync.js +2 -0
  39. package/dist/core/canonical.d.ts +15 -7
  40. package/dist/core/canonical.js +101 -13
  41. package/dist/core/capabilitySelection.d.ts +45 -0
  42. package/dist/core/capabilitySelection.js +124 -0
  43. package/dist/core/types.d.ts +25 -2
  44. package/dist/core/types.js +7 -0
  45. package/dist/lib/backup.d.ts +2 -0
  46. package/dist/lib/backup.js +4 -0
  47. package/dist/lib/builtinSkills.d.ts +2 -0
  48. package/dist/lib/builtinSkills.js +4 -0
  49. package/dist/lib/cliMetadata.d.ts +1 -0
  50. package/dist/lib/cliMetadata.js +14 -0
  51. package/dist/lib/gatewayBackend.d.ts +28 -0
  52. package/dist/lib/gatewayBackend.js +72 -1
  53. package/dist/lib/installAgent.d.ts +7 -5
  54. package/dist/lib/installAgent.js +4 -3
  55. package/dist/lib/mcpConnect.js +5 -1
  56. package/dist/lib/mcpMigrateRead.d.ts +1 -0
  57. package/dist/lib/mcpMigrateRead.js +3 -0
  58. package/dist/lib/mcpRuntime.d.ts +46 -0
  59. package/dist/lib/mcpRuntime.js +185 -0
  60. package/dist/lib/mcpStatusProvider.d.ts +10 -0
  61. package/dist/lib/mcpStatusProvider.js +25 -0
  62. package/dist/lib/mcpToolRegistry.d.ts +18 -0
  63. package/dist/lib/mcpToolRegistry.js +107 -14
  64. package/dist/lib/memoryGraph.d.ts +1 -1
  65. package/dist/lib/memoryGraph.js +9 -3
  66. package/dist/lib/memoryProvider.d.ts +58 -0
  67. package/dist/lib/memoryProvider.js +175 -0
  68. package/dist/lib/memoryStatus.d.ts +17 -0
  69. package/dist/lib/memoryStatus.js +88 -0
  70. package/dist/lib/nativeMemory.d.ts +19 -0
  71. package/dist/lib/nativeMemory.js +129 -0
  72. package/dist/lib/runtimeControlProvider.d.ts +16 -0
  73. package/dist/lib/runtimeControlProvider.js +168 -0
  74. package/dist/lib/secretEnv.d.ts +2 -1
  75. package/dist/lib/secretEnv.js +6 -2
  76. package/dist/lib/skillProvider.d.ts +13 -0
  77. package/dist/lib/skillProvider.js +210 -0
  78. package/dist/lib/taskProvider.d.ts +7 -0
  79. package/dist/lib/taskProvider.js +43 -0
  80. package/dist/lib/taskStore.d.ts +46 -0
  81. package/dist/lib/taskStore.js +156 -0
  82. package/dist/lib/terminalPicker.d.ts +23 -49
  83. package/dist/lib/terminalPicker.js +53 -218
  84. package/dist/pi-bridge/bundle.js +475 -37
  85. package/dist/pi-bridge/index.js +42 -21
  86. package/dist/pi-bridge/schemaTranslate.d.ts +4 -8
  87. package/dist/pi-bridge/schemaTranslate.js +4 -8
  88. package/dist/probes/kimi-code.d.ts +12 -0
  89. package/dist/probes/kimi-code.js +55 -0
  90. package/dist/sdk.d.ts +1 -1
  91. package/docs/architecture.md +224 -26
  92. package/docs/assets/agent-trellis-architecture-horizontal.svg +80 -0
  93. package/docs/assets/agent-trellis-architecture-vertical.svg +82 -0
  94. package/docs/assets/trellis-mark.svg +12 -0
  95. package/docs/getting-started.md +328 -35
  96. package/docs/overview.md +131 -0
  97. package/docs/overview.zh-CN.md +100 -0
  98. package/docs/research.md +59 -0
  99. package/docs/roadmap.md +9 -5
  100. package/package.json +3 -2
  101. package/schema/builtin-skills/trellis-runtime/SKILL.md +117 -0
  102. package/schema/capability-selection.example.yaml +23 -0
  103. package/schema/scope.example.yaml +1 -1
  104. package/schema/servers.example.yaml +15 -1
@@ -0,0 +1,82 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1080 1440" role="img" aria-labelledby="title desc">
2
+ <title id="title">Agent Trellis — Unified Code Agent Runtime</title>
3
+ <desc id="desc">A vertical architecture diagram showing one canonical source and Runtime foundation supporting multiple Code Agents through Skills, MCP, Memory, and Instructions.</desc>
4
+ <defs>
5
+ <linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
6
+ <stop offset="0" stop-color="#0b1118"/>
7
+ <stop offset="1" stop-color="#111c24"/>
8
+ </linearGradient>
9
+ <linearGradient id="base" x1="0" y1="0" x2="0" y2="1">
10
+ <stop offset="0" stop-color="#293943"/>
11
+ <stop offset="1" stop-color="#17232c"/>
12
+ </linearGradient>
13
+ <filter id="shadow" x="-20%" y="-20%" width="140%" height="160%">
14
+ <feDropShadow dx="0" dy="16" stdDeviation="14" flood-color="#000" flood-opacity=".35"/>
15
+ </filter>
16
+ <style>
17
+ .sans { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
18
+ .mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
19
+ .title { fill: #f5efe3; font-size: 54px; font-weight: 750; letter-spacing: -1px; }
20
+ .sub { fill: #a9efd2; font-size: 22px; font-weight: 650; letter-spacing: 1px; }
21
+ .label { fill: #f5efe3; font-size: 25px; font-weight: 700; }
22
+ .small { fill: #a4b2ba; font-size: 17px; }
23
+ .tiny { fill: #7f919d; font-size: 14px; }
24
+ </style>
25
+ </defs>
26
+ <rect width="1080" height="1440" fill="url(#bg)"/>
27
+ <path d="M0 230H1080M0 1240H1080" stroke="#263640" stroke-width="1"/>
28
+
29
+ <g class="sans">
30
+ <text x="80" y="118" class="title">Agent Trellis</text>
31
+ <text x="82" y="158" class="sub">UNIFIED CODE AGENT RUNTIME</text>
32
+ <text x="80" y="208" class="small">一套 Runtime,统一托管 Code Agent 的运行能力</text>
33
+
34
+ <g transform="translate(80 274)">
35
+ <rect width="920" height="180" rx="22" fill="#101a22" stroke="#374852"/>
36
+ <text x="42" y="50" class="small">解决三个问题</text>
37
+ <text x="42" y="93" class="label">多 Agent,配置分散</text>
38
+ <text x="42" y="130" class="label">MCP 重复,难以管理</text>
39
+ <text x="42" y="167" class="label">Memory 与上下文割裂</text>
40
+ <circle cx="850" cy="52" r="9" fill="#f2b35b"/>
41
+ <circle cx="850" cy="90" r="9" fill="#a9efd2"/>
42
+ <circle cx="850" cy="128" r="9" fill="#f2b35b"/>
43
+ </g>
44
+
45
+ <path d="M540 476V530" stroke="#a9efd2" stroke-width="3"/>
46
+ <text x="540" y="520" text-anchor="middle" class="tiny">统一托管</text>
47
+
48
+ <g filter="url(#shadow)">
49
+ <rect x="80" y="548" width="920" height="300" rx="26" fill="url(#base)" stroke="#f2b35b" stroke-width="2"/>
50
+ <rect x="110" y="580" width="860" height="72" rx="16" fill="#0e1820" stroke="#53636c"/>
51
+ <rect x="110" y="668" width="860" height="72" rx="16" fill="#0e1820" stroke="#53636c"/>
52
+ <rect x="110" y="756" width="860" height="58" rx="14" fill="#0e1820" stroke="#53636c"/>
53
+ </g>
54
+ <text x="540" y="618" text-anchor="middle" class="label">Agent Trellis Runtime</text>
55
+ <text x="540" y="642" text-anchor="middle" class="tiny">canonical source · policy · adapters · providers</text>
56
+ <text x="270" y="713" text-anchor="middle" class="label">Skills</text>
57
+ <text x="540" y="713" text-anchor="middle" class="label">MCP</text>
58
+ <text x="810" y="713" text-anchor="middle" class="label">Memory</text>
59
+ <text x="540" y="791" text-anchor="middle" class="label">Instructions</text>
60
+
61
+ <path d="M540 848V904" stroke="#f2b35b" stroke-width="3"/>
62
+ <rect x="180" y="920" width="720" height="76" rx="18" fill="#101a22" stroke="#53636c"/>
63
+ <text x="540" y="953" text-anchor="middle" class="label">Canonical Source</text>
64
+ <text x="540" y="980" text-anchor="middle" class="mono small">~/.trellis</text>
65
+
66
+ <path d="M540 996V1052" stroke="#a9efd2" stroke-width="3"/>
67
+ <text x="540" y="1038" text-anchor="middle" class="tiny">运行在其上的 Code Agents</text>
68
+ <g filter="url(#shadow)">
69
+ <rect x="80" y="1070" width="280" height="80" rx="16" fill="#17242c" stroke="#a9efd2" stroke-width="2"/>
70
+ <rect x="400" y="1070" width="280" height="80" rx="16" fill="#17242c" stroke="#f2b35b" stroke-width="2"/>
71
+ <rect x="720" y="1070" width="280" height="80" rx="16" fill="#17242c" stroke="#a9efd2" stroke-width="2"/>
72
+ <rect x="240" y="1170" width="280" height="80" rx="16" fill="#17242c" stroke="#a9efd2" stroke-width="2"/>
73
+ <rect x="560" y="1170" width="280" height="80" rx="16" fill="#17242c" stroke="#a9efd2" stroke-width="2"/>
74
+ </g>
75
+ <text x="220" y="1120" text-anchor="middle" class="label">Claude Code</text>
76
+ <text x="540" y="1120" text-anchor="middle" class="label">Codex</text>
77
+ <text x="860" y="1120" text-anchor="middle" class="label">Kimi Code</text>
78
+ <text x="380" y="1220" text-anchor="middle" class="label">Kiro</text>
79
+ <text x="700" y="1220" text-anchor="middle" class="label">pi</text>
80
+ <text x="540" y="1340" text-anchor="middle" class="mono small">one source · one runtime · many agents</text>
81
+ </g>
82
+ </svg>
@@ -0,0 +1,12 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" role="img" aria-labelledby="title desc">
2
+ <title id="title">Trellis</title>
3
+ <desc id="desc">A four-node runtime mark around a central control plane.</desc>
4
+ <rect width="96" height="96" rx="24" fill="#0b1219"/>
5
+ <path d="M48 20v56M20 48h56M28 28l40 40M68 28 28 68" stroke="#31404a" stroke-width="3" stroke-linecap="round"/>
6
+ <rect x="35" y="35" width="26" height="26" rx="7" transform="rotate(45 48 48)" fill="#101c24" stroke="#f2b35b" stroke-width="3"/>
7
+ <circle cx="48" cy="48" r="6" fill="#a9efd2"/>
8
+ <circle cx="20" cy="48" r="6" fill="#f2b35b"/>
9
+ <circle cx="76" cy="48" r="6" fill="#f2b35b"/>
10
+ <circle cx="48" cy="20" r="6" fill="#a9efd2"/>
11
+ <circle cx="48" cy="76" r="6" fill="#a9efd2"/>
12
+ </svg>
@@ -15,8 +15,8 @@ npm install -g agent-trellis
15
15
  $ trellis onboard
16
16
  ```
17
17
 
18
- Runs `init`, detects which of Claude Code/Codex/Kiro/pi are on this machine,
19
- then resolves two interactive choices and two flag-only ones before running
18
+ Runs `init`, detects which of Claude Code/Codex/Kiro/pi/Kimi Code are on this machine,
19
+ then resolves two styled interactive choices and two flag-only ones before running
20
20
  `migrate`, `sync`, `mcp sync`, `memory sync`, `secrets audit`, and a final
21
21
  health scan — the whole onboarding path, no follow-up commands to type by
22
22
  hand, and no need to run `trellis doctor` separately to know whether it
@@ -39,27 +39,43 @@ that.
39
39
  prompt entirely. Which *categories* to bring in from that source
40
40
  (skills, instructions, mcp) is its own checkbox, shown only when the
41
41
  source has real content in two or more of them — with just one, that
42
- one is migrated unprompted.
42
+ one is migrated unprompted. On a real terminal this uses a colored
43
+ selector; it shows aggregate counts, not every skill name.
43
44
  2. **Managed set** — zero or more agents to actually write to. Always an
44
45
  explicit choice: pass `--manage <ids>` (comma-separated, e.g. `--manage
45
46
  pi,codex`) or `--manage none`, or answer the interactive checkbox prompt
46
- (Space to toggle, Enter to confirm — same numbered fallback as above).
47
+ (arrow keys to move, Space to toggle, Enter to confirm — same numbered
48
+ fallback as above when a raw TTY is unavailable).
47
49
  **The source is not included by default** — migrating from Claude Code
48
50
  doesn't mean Trellis starts managing Claude Code too, unless you say so.
49
51
  Selecting an agent that isn't installed yet is itself the authorization to
50
52
  install it (one confirmation, then a real `npm install -g <package>`);
51
53
  Kiro has no CLI package and is refused with its download URL instead.
52
- 3. **MCP mode** — direct (the default), hub, or gateway. Flag-only, never
53
- prompted: pass `--mcp-mode direct|hub|gateway` to change it (`--hub-url
54
- <url>` is required with `hub`; `--gateway-agents <ids>` is optional with
55
- `gateway`, omitted meaning every managed agent). Omitting `--mcp-mode`
54
+ Onboarding is intentionally additive: an agent already managed remains
55
+ managed if a later onboarding run omits it. Use the explicit `trellis
56
+ manage` lifecycle commands below when you intend to detach one.
57
+ 3. **MCP mode** — direct, gateway, or hub. In the interactive route picker,
58
+ **Gateway is recommended for local Trellis hosting**: Trellis runs the
59
+ local MCP entry and manages upstream connections for the Agent session;
60
+ no extra service is needed. Choose **Direct** when each Agent should
61
+ connect to MCP servers independently. Choose **Hub only when an external
62
+ MCP Hub is already running**: each Agent connects to one external HTTP
63
+ endpoint, and the Hub owns the upstream server list. Trellis does not
64
+ deploy the Hub. The non-interactive mode is flag-only: pass
65
+ `--mcp-mode direct|hub|gateway` to change it (`--hub-url <url>` is required
66
+ with `hub`; `--gateway-agents <ids>` is optional with `gateway`, omitted
67
+ meaning every managed agent). Omitting `--mcp-mode`
56
68
  entirely leaves whatever's already configured untouched — on a fresh
57
69
  machine that's direct, on one you've already switched that's whatever
58
70
  you last set — so a plain `trellis onboard` re-run never resets it. This
59
71
  is the only supported way to turn gateway or hub mode on or off; there's
60
72
  no reason to hand-edit `~/.trellis/mcp/servers.yaml`'s `hub`/`gateway`
61
73
  keys directly.
62
- 4. **The shared memory server** — off by default. Pass `--memory on` to add
74
+ 4. **Existing memory migration** — independent from the shared backend. Pass
75
+ `--memory-migrate on` to import supported native Markdown memory, or
76
+ `--memory-migrate off` to skip it. Unsupported Kimi/pi session stores are
77
+ reported and left untouched.
78
+ 5. **The shared memory server** — off by default. Pass `--memory on` to add
63
79
  the default `@modelcontextprotocol/server-memory` definition (refused if
64
80
  a host on this machine already injects a connector named `memory` — see
65
81
  [`trellis memory sync`](#trellis-memory-sync) below) or
@@ -134,6 +150,14 @@ a re-plan against canonical can. If a write somehow didn't hold (a
134
150
  filesystem permission problem, a race), it surfaces in the verdict as its
135
151
  own `blocked` item, separate from whatever the write's own stage reported.
136
152
 
153
+ Onboarding treats a mode change as a route transition, not a reset: canonical
154
+ Skills, MCP definitions, memories, and secrets policy stay in place. When an
155
+ interactive run changes mode, it shows the current mode, target mode, and
156
+ affected managed Agents before asking for confirmation. A blocking failure in
157
+ the transaction automatically restores canonical and native files together;
158
+ the backup remains available in `~/.trellis/backups/` for inspection or a
159
+ later explicit rollback.
160
+
137
161
  **The health scan is `trellis doctor` itself**, run at the end against
138
162
  every agent (not just the ones this run manages) — so a genuinely new
139
163
  problem this run happened to create or reveal shows up without a separate
@@ -151,6 +175,23 @@ happens. It never appears on stdout, so `trellis onboard > report.txt`
151
175
  still captures exactly the report and verdict, nothing else; it's silent
152
176
  entirely under `--json` or when stdout isn't a real terminal.
153
177
 
178
+ Interactive choices use a compact colored prompt UI with clear success,
179
+ warning, and blocking states. The prompt UI is written to stderr, while the
180
+ report and JSON output stay on stdout.
181
+
182
+ For repeatable item-level selection, pass a YAML/JSON file:
183
+
184
+ ```
185
+ $ trellis onboard --agent kiro --manage codex \
186
+ --selection ./schema/capability-selection.example.yaml
187
+ ```
188
+
189
+ The file can select individual `skills`, `mcp_servers`, and `memories`, plus
190
+ per-agent `mcp_routes` with `direct`, `gateway`, or `hub` mode. It can also
191
+ set `runtime_delivery` per agent to `native`, `mcp`, or `both`; omitted agents
192
+ remain native. Existing
193
+ `--mcp-mode` and category flags remain valid shortcuts.
194
+
154
195
  Add `--dry-run` to preview the entire chain — init/migrate/sync/mcp
155
196
  sync/memory sync, including what would be written to
156
197
  `~/.trellis/managed.yaml` and to `servers.yaml`'s mode/memory keys — with
@@ -174,9 +215,117 @@ The rest of this page is the same flow broken into its individual steps —
174
215
  useful if you want more control over any one part, or just want to
175
216
  understand what `onboard` did.
176
217
 
218
+ ## `trellis manage` — change the write boundary explicitly
219
+
220
+ The managed set is Trellis's hard outer authorization boundary. Use the
221
+ standalone lifecycle command when you need to inspect, replace, extend, or
222
+ narrow it without running migration or sync:
223
+
224
+ ```
225
+ trellis manage list
226
+ trellis manage set claude-code,pi --dry-run
227
+ trellis manage set claude-code,pi
228
+ trellis manage add codex
229
+ trellis manage remove kiro
230
+ trellis manage set none
231
+ ```
232
+
233
+ `set` is exact; `add` unions; `remove` subtracts. Every real change to
234
+ `managed.yaml` is recorded under `~/.trellis/backups/` and can be reversed by
235
+ `trellis rollback`. A dry run or no-op creates no backup.
236
+
237
+ Detaching only prevents future Trellis writes. It never deletes or rewrites
238
+ the detached agent's existing skills, instructions, MCP entries, extensions,
239
+ or login state. Cleanup, if desired, is a separate explicit decision.
240
+
241
+ This differs deliberately from `onboard --manage`: onboarding remains
242
+ additive so an omitted checkbox cannot silently revoke management.
243
+
244
+ ## Kimi Code Runtime-first
245
+
246
+ Kimi Code is supported as `kimi-code`. For Runtime-first delivery, configure
247
+ the capability selection with `runtime_delivery: { kimi-code: mcp }`, then
248
+ sync MCP and launch Kimi through Trellis:
249
+
250
+ ```
251
+ trellis manage add kimi-code --dry-run
252
+ trellis mcp sync --dry-run
253
+ trellis kimi -p "search the Trellis skills for the onboarding workflow"
254
+ ```
255
+
256
+ Runtime-only Kimi receives one `trellis` entry in
257
+ `~/.kimi-code/mcp.json`. `trellis kimi` passes an empty `--skills-dir` for
258
+ that mode, so Kimi does not also discover the shared `~/.agents/skills`
259
+ directory. The canonical SkillProvider and RuntimeMemoryProvider remain the
260
+ source of Skill/Memory content, while selected upstream MCP servers are
261
+ mounted through the same Runtime/Gateway edge.
262
+
263
+ Kimi's `deferred` MCP field is enabled on the owned Runtime entry to reduce
264
+ initial tool-list context when Kimi's experimental tool-select capability is
265
+ enabled. Runtime correctness does not depend on that optimization. Native
266
+ Kimi delivery remains available with `native` or `both`; those modes do not
267
+ use the empty Skill-root launcher.
268
+
269
+ ## Trellis Runtime Skill
270
+
271
+ `trellis-runtime` is the built-in operating guide that Trellis installs into
272
+ the canonical source. It deliberately has two phases:
273
+
274
+ ### Phase 1: before takeover
275
+
276
+ Use it as a checklist for the operator-assisted migration flow:
277
+
278
+ 1. Run `trellis doctor` and `trellis onboard --dry-run` to inspect the current
279
+ machine without changing Agent files.
280
+ 2. Choose one migration source with `--agent` and an explicit managed boundary
281
+ with `--manage`. Migrating from an Agent does not automatically authorize
282
+ Trellis to write back to that Agent.
283
+ 3. Review the selected Skills, MCP servers, Memory, per-Agent routes, and
284
+ delivery mode. Use `--selection` when the choice must be repeatable.
285
+ 4. Apply only after reviewing the dry-run. `onboard` performs migration,
286
+ native/runtime sync, Memory sync, secrets audit, and health verification in
287
+ one transaction.
288
+ 5. Resolve OAuth interactively with `trellis mcp auth <server>`. Never place a
289
+ token in this Skill, `servers.yaml`, tests, or demonstration configuration.
290
+ 6. If the verdict blocks, follow its remediation. Do not delete an unknown
291
+ file or bypass ownership protection; every real write has a backup and can
292
+ be inspected with `trellis rollback --list`.
293
+
294
+ ### Phase 2: after takeover
295
+
296
+ The Agent consumes the same Skill regardless of its native adapter:
297
+
298
+ | Delivery | How the Skill is consumed |
299
+ | --- | --- |
300
+ | `native` | A Trellis-owned symlink points the Agent's native Skill root at the canonical Skill. |
301
+ | `mcp` | `SkillProvider` exposes the canonical Skill through the `trellis` Runtime; Kimi is launched with `trellis kimi` so its native Skill root does not duplicate the Runtime. |
302
+ | `both` | Native discovery and the Runtime are both available when a deliberate compatibility transition requires it. |
303
+
304
+ Once the Agent is running, start with the current Runtime status, then use
305
+ progressive disclosure:
306
+
307
+ 1. `runtime_status` — Agent identity, delivery mode, provider readiness, and
308
+ counts.
309
+ 2. `skills_search` → `skills_read` — locate and read only the Skill needed for
310
+ the current task.
311
+ 3. `memory_search` → `memory_read` — consume shared canonical Memory.
312
+ 4. `instructions_read` — inspect canonical global instructions when context is
313
+ needed.
314
+ 5. `mcp_status` — diagnose missing, unauthorized, or unavailable MCP servers
315
+ and show the user the supported remediation.
316
+ 6. `agents_list` and `tasks_list`/`tasks_read` — inspect the managed boundary
317
+ and handoff work. Mutating tasks requires explicit confirmation.
318
+
319
+ These are Trellis's portable names. A client may add a namespace such as
320
+ `mcp__trellis__skills_search`; never hardcode that client-generated prefix in a
321
+ Skill. The Runtime's built-in Skill and Memory providers are read-only. Shared
322
+ Memory writes come from the configured Memory MCP backend, and importing graph
323
+ content back into canonical Markdown remains an explicit
324
+ `trellis memory extract` operation.
325
+
177
326
  ## Two starting points
178
327
 
179
- **You already use one or more of Claude Code, Codex, Kiro, or pi** and have
328
+ **You already use one or more of Claude Code, Codex, Kiro, pi, or Kimi Code** and have
180
329
  real skills/instructions in them today. Go to
181
330
  [Migrating from an existing agent](#migrating-from-an-existing-agent).
182
331
 
@@ -204,7 +353,7 @@ Creates `~/.trellis/` with:
204
353
  `~/.trellis/` that already exists just fills in whatever's still missing —
205
354
  safe to run again any time, including after you've hand-edited things.
206
355
 
207
- It then prints which of the four supported agents it found on this machine.
356
+ It then prints which of the five supported agents it found on this machine.
208
357
  For each one **not** found, it prints that agent's real install command or
209
358
  download link — `trellis init` never runs an installer itself; a global
210
359
  package install or an IDE download is your call to make, not a silent side
@@ -225,7 +374,7 @@ migrate --from claude-code
225
374
  [conflict] instructions — canonical agents.md already has different real content — resolve by hand
226
375
  ```
227
376
 
228
- `--from` accepts `claude-code`, `codex`, `kiro`, or `pi`. Run it once per
377
+ `--from` accepts `claude-code`, `codex`, `kiro`, `pi`, or `kimi-code`. Run it once per
229
378
  agent you actually use — it's independent per agent, order doesn't matter.
230
379
 
231
380
  Add `--dry-run` to see the plan without writing anything:
@@ -234,7 +383,7 @@ Add `--dry-run` to see the plan without writing anything:
234
383
  $ trellis migrate --from codex --dry-run
235
384
  ```
236
385
 
237
- Add `--only skills`, `--only instructions`, or `--only mcp` to migrate
386
+ Add `--only skills`, `--only instructions`, `--only mcp`, or `--only memory` to migrate
238
387
  just one category — useful when you only want part of it brought in
239
388
  right now. Omit it to migrate all three, exactly as above:
240
389
 
@@ -251,7 +400,7 @@ $ trellis migrate --from codex --only instructions
251
400
  | `conflict` | Canonical already has *different* real content — **left untouched**, resolve by hand. |
252
401
  | `skip-symlink` | That agent's own copy is itself a symlink (already shared in from elsewhere) — nothing of that agent's own to import. |
253
402
  | `skip-case-broken` | Found as `skill.md` instead of `SKILL.md` — fix the case on the source agent first. |
254
- | `skip-unsupported` | MCP servers only — that agent's real definition can't be safely represented (see below); nothing was written for it. |
403
+ | `skip-unsupported` | The source capability can't be safely represented (including native memory without a supported adapter); nothing was written for it. |
255
404
 
256
405
  Migrate never overwrites a genuine conflict, and never scopes a migrated
257
406
  skill (or MCP server) to just the source agent — once in canonical, it's
@@ -259,6 +408,31 @@ visible to every agent by default (see `sync`, below). If migrate reports
259
408
  a `conflict`, open the two files/entries it names and decide by hand
260
409
  which content should actually be canonical, then re-run.
261
410
 
411
+ Memory migration is deliberately separate from enabling the shared Memory
412
+ MCP:
413
+
414
+ ```text
415
+ trellis onboard --memory-migrate on --memory off
416
+ ```
417
+
418
+ The initial native-memory adapter supports Claude Code's exact current-
419
+ workspace Markdown memory directory. Kimi Code and pi session logs are
420
+ reported as unsupported and are not inspected. Imported files receive
421
+ deterministic names and provenance headers under `~/.trellis/memories/`; a
422
+ conflict is left untouched and the onboarding transaction can roll back the
423
+ import.
424
+
425
+ Codex is also supported when its documented local Memory directory contains
426
+ Markdown files:
427
+
428
+ ```text
429
+ trellis migrate --from codex --only memory --dry-run
430
+ ```
431
+
432
+ Trellis resolves `CODEX_HOME` when set, otherwise `~/.codex`, and reads only
433
+ the Memory directory. `AGENTS.md`, `session_index.jsonl`, sessions,
434
+ credentials, and plugin state are never treated as memory.
435
+
262
436
  **MCP servers** (claude-code, kiro, codex — not pi, which has no static
263
437
  MCP config to read at all) migrate the same way, into
264
438
  `~/.trellis/mcp/servers.yaml`:
@@ -402,6 +576,16 @@ then auto-removes the now-stale symlink on every agent that had it (skills
402
576
  carry their own ownership marker — the symlink itself — so this
403
577
  propagates automatically, unlike MCP servers below).
404
578
 
579
+ The package-owned Runtime Skill is refreshed explicitly with:
580
+
581
+ ```
582
+ trellis skill update-builtin --dry-run
583
+ trellis skill update-builtin
584
+ ```
585
+
586
+ The update is backed up and updates the canonical file in place; native Agent
587
+ symlinks and Runtime providers then consume the same refreshed content.
588
+
405
589
  ```
406
590
  $ trellis mcp list
407
591
  tanka (http) — codex, pi
@@ -417,16 +601,46 @@ removed MCP server "local-server" from canonical source.
417
601
 
418
602
  `mcp add` takes `--transport stdio|http|sse`; stdio requires `--command`
419
603
  (plus optional `--args a,b`, `--env NAME,...`, `--static-env k=v,...`),
420
- http/sse require `--url` (plus optional `--headers k=v,...`, values
604
+ http/sse require `--url` (plus optional `--auth oauth`, `--headers k=v,...`, values
421
605
  expected as `${VAR}` references, never literal secrets). Both accept
422
606
  `--agents id,...` (scope) and `--enabled true|false`. Same no-overwrite
423
607
  conflict posture as `skill add` — there is no `--force`.
424
608
 
425
- `mcp remove` is **canonical-only** — it does not remove the server from
426
- any agent that already has it from an earlier `mcp sync` (the same
427
- no-automatic-removal gap `mcp sync` itself has — see
428
- [README's Known limitations](../README.md#status)); remove it by hand on
429
- each agent in the meantime.
609
+ For a standard JSON export with a top-level `mcpServers` object, use the
610
+ credential-aware importer instead of repeating `mcp add` by hand:
611
+
612
+ ```
613
+ trellis mcp import ~/Desktop/mcp-servers.json --dry-run
614
+ trellis mcp import ~/Desktop/mcp-servers.json
615
+ ```
616
+
617
+ The source file is read-only. The importer de-duplicates semantically
618
+ identical servers, preserves existing canonical definitions, reports same-name
619
+ conflicts, and skips unavailable absolute paths. A recognized `mcp-remote`
620
+ Basic Authorization export is converted to native HTTP MCP; other credentials
621
+ embedded in command arguments, URLs, or headers are rejected. Credential-like values in an exported
622
+ `env` map are moved to the ignored local file
623
+ `~/.trellis/mcp/servers.local.env`; canonical stores only a prefixed variable
624
+ reference through `env_aliases`:
625
+
626
+ ```yaml
627
+ env_aliases:
628
+ SUPABASE_ACCESS_TOKEN: TRELLIS_SUPABASE_DB_SUPABASE_ACCESS_TOKEN
629
+ ```
630
+
631
+ The actual value is never printed in the plan, JSON report, canonical YAML, or
632
+ shell arguments. Re-importing is idempotent; an existing local secret with a
633
+ different value is a conflict and is never overwritten. OAuth sessions are not
634
+ imported — authorize the resulting remote MCP explicitly with
635
+ `trellis mcp auth <name>`.
636
+
637
+ Use `trellis mcp set <name> --auth oauth` to keep a known OAuth MCP direct
638
+ when its Agent uses gateway mode; use `--auth none` to clear the marker.
639
+ Trellis does not infer OAuth from a URL or an authentication failure.
640
+
641
+ `mcp remove` changes canonical state only. The next `trellis mcp sync` removes
642
+ the old native entry when the ownership ledger proves Trellis still owns it;
643
+ hand-edited native entries are preserved and reported as conflicts.
430
644
 
431
645
  `mcp list` never resolves or prints a secret value: `env` names are shown
432
646
  as bare names (the actual value is never read from your shell), and
@@ -485,10 +699,9 @@ known-host-injected collision avoidance, hub mode, and gateway mode
485
699
  $ trellis mcp sync
486
700
  ```
487
701
 
488
- Create/repair only — if you remove a server from `servers.yaml`, `mcp sync`
489
- does not remove it from any agent's native config yet (see
490
- [README's Known limitations](../README.md#status)). Remove it by hand on
491
- each agent in the meantime.
702
+ `mcp sync` also removes an entry deleted from canonical when the ownership
703
+ ledger proves the current native definition is exactly what Trellis last
704
+ wrote. Hand-edited entries are left untouched and reported as conflicts.
492
705
 
493
706
  Every native-config file this rewrites in place is snapshotted first,
494
707
  automatically — see
@@ -547,8 +760,14 @@ agent spawns it like any other stdio MCP server; it connects out to your
547
760
  servers, and exits when the session ends. There is nothing to start,
548
761
  stop, or monitor.
549
762
 
550
- Your servers' tools appear to the agent as `<server>__<tool>` — the
551
- `gitlab` server's `search` becomes `gitlab__search`.
763
+ Long unambiguous upstream tools stay compact. Generic short names such as
764
+ `search` receive source context even when unique; if both GitHub and GitLab
765
+ expose `search`, they become `github__search` and `gitlab__search`. A tool that
766
+ already contains its source prefix is not repeated. Agent-facing names are
767
+ normalized to `[A-Za-z0-9_-]` and
768
+ bounded to 64 characters; long names receive a deterministic hash suffix.
769
+ Extremely rare normalized-name collisions receive a deterministic suffix
770
+ rather than being dropped, while calls still route to the original MCP name.
552
771
 
553
772
  Add `agents: [claude-code, codex]` under `gateway:` to narrow it, leaving
554
773
  the rest in direct mode. Gateway mode and `hub` are independent; both can
@@ -557,12 +776,14 @@ be set, and gateway wins for any agent it covers.
557
776
  Two things stop being problems in gateway mode. Codex can normally only
558
777
  express a single `Authorization: Bearer ${VAR}` header, so a server
559
778
  needing more than one was refused for Codex — in gateway mode Codex never
560
- sees any server's headers, so it just works. And remote servers requiring
561
- real OAuth become reachable from every agent, including pi.
779
+ sees any ordinary server's headers, so it just works. OAuth-marked servers
780
+ stay direct while ordinary remote servers remain shared through the gateway.
562
781
 
563
782
  ### `trellis mcp auth <server-name>`
564
783
 
565
- For a remote (`http`/`sse`) server that uses OAuth, authorize it once:
784
+ For a remote (`http`/`sse`) server marked `auth: oauth`, native Agents should
785
+ use their own login command. Pi's direct bridge path can be authorized once
786
+ through Trellis:
566
787
 
567
788
  ```
568
789
  $ trellis mcp auth notion-remote
@@ -574,15 +795,22 @@ This opens your browser, completes the flow, and stores the result 0600
574
795
  under `~/.trellis/mcp/oauth/` — never in `servers.yaml`, so canonical
575
796
  stays safe to read, diff, and commit.
576
797
 
577
- Run it once per server. After that the gateway refreshes the token
578
- silently whenever it expires; it never opens a browser and never prompts,
579
- because it is spawned by an agent with no terminal attached. Re-running
798
+ Run it once per server when Pi's direct bridge owns the OAuth connection.
799
+ After that the bridge refreshes the token silently whenever it expires; it
800
+ never opens a browser and never prompts, because it is spawned by an agent
801
+ with no terminal attached. Re-running
580
802
  this command when the stored token is still valid does nothing (`--force`
581
803
  overrides); when it has expired but is renewable, it refreshes without a
582
804
  browser.
583
805
 
584
- If a server has no stored credential, the gateway skips that one server
585
- and keeps serving every other — it does not fail to start.
806
+ If a Pi direct OAuth server has no stored credential, the bridge skips that
807
+ one server and keeps serving every other — it does not fail to start. Native
808
+ Agents report the same direct entry as requiring their own authorization.
809
+
810
+ An Agent can call the read-only `trellis.mcp.status` Runtime tool to explain
811
+ this partial state to the user. It reports unavailable or authorization-
812
+ required servers and gives the next safe action, such as `trellis mcp auth
813
+ figma`, without exposing tokens or opening a browser from the Agent process.
586
814
 
587
815
  This command only applies to `http`/`sse` servers. stdio servers get
588
816
  their credentials from `env`/`env_aliases` as described above; running
@@ -590,6 +818,17 @@ their credentials from `env`/`env_aliases` as described above; running
590
818
 
591
819
  ## `trellis memory sync`
592
820
 
821
+ Canonical memories can also be consumed directly through the Trellis MCP
822
+ Runtime when an agent's runtime delivery is `mcp` or `both`. Runtime exposes
823
+ read-only `trellis.memory.search` and `trellis.memory.read` tools plus
824
+ `trellis://memories/<name>.md` resources. Results are filtered through the
825
+ memory's `scope.yaml` entry and the managed-agent boundary on every request.
826
+
827
+ This Runtime path reads `~/.trellis/memories/*.md` directly. It does not need
828
+ the separate `memory` MCP server below, and it does not expose write/delete
829
+ tools. `memory sync` remains the bridge from canonical Markdown into the
830
+ mutable shared graph used by `@modelcontextprotocol/server-memory`.
831
+
593
832
  Ingests `~/.trellis/memories/*.md` into the actual on-disk file
594
833
  `@modelcontextprotocol/server-memory` reads at its own startup — closing
595
834
  the gap between "memory entries exist in canonical" and "the running
@@ -651,6 +890,24 @@ entities' names would slug to the same filename. Not wired into
651
890
  deliberate, occasional action you run, the same posture `migrate` already
652
891
  has.
653
892
 
893
+ For a shared Kimi Code + pi setup, enable the backend through onboarding
894
+ instead of editing either Agent's config by hand:
895
+
896
+ ```text
897
+ trellis onboard --memory on --mcp-mode gateway --manage pi,kimi-code
898
+ ```
899
+
900
+ This writes one canonical `memory` server, syncs the Gateway route to both
901
+ Agents, and runs `memory sync` in the same transaction. Runtime status reports
902
+ `backendConfigured`, `graphReady`, `canonicalCount`, write authority, and the
903
+ managed Agents receiving the shared route. It distinguishes an unconfigured
904
+ backend from an empty but writable graph.
905
+
906
+ Agent-created graph content is external Memory context. It is not imported
907
+ back into canonical automatically; run `trellis memory extract` explicitly
908
+ when you want durable, reviewable Markdown. Native/private Agent memory
909
+ stores are not scraped or guessed.
910
+
654
911
  **Note:** this is unrelated to any project-level "auto memory" feature an
655
912
  agent may have of its own (e.g. Claude Code's own per-project memory
656
913
  files) — those are a different, agent-specific mechanism entirely, not
@@ -682,7 +939,7 @@ periodically regardless.
682
939
  $ trellis doctor
683
940
  ```
684
941
 
685
- Read-only. Scans all four agents' current state and reports drift —
942
+ Read-only. Scans all five agents' current state and reports drift —
686
943
  mismatched skill content across agents, wrong-case skill files, and (with
687
944
  `--probe-mcp`) whether each configured MCP server actually handshakes.
688
945
  Safe to run any time; nothing here writes anything.
@@ -691,6 +948,42 @@ Safe to run any time; nothing here writes anything.
691
948
  stdio MCP server (some reaching real external services) — not something a
692
949
  "just check my config" command should do by default.
693
950
 
951
+ ## 在 Linux sandbox 中验证真实 agent
952
+
953
+ Trellis 提供一个独立的 agent image,用于安装真实的 Codex、Claude Code、
954
+ Kiro CLI 和 pi,而不是只使用 fake CLI。它使用 `runtime-home` 作为只读
955
+ fixture,并把内容复制到容器内的隔离 `$HOME`;不会挂载宿主机的 agent
956
+ 目录或登录态:
957
+
958
+ ```
959
+ scripts/agent-sandbox.sh
960
+ ```
961
+
962
+ 未登录时,Codex 和 Claude Code 可以验证自己是否识别 Trellis 写入的
963
+ `trellis` MCP entry;Kiro CLI 会在 `mcp list` 前要求登录,这
964
+ 是 Kiro 的真实授权边界。
965
+
966
+ 如需实际授权,使用单独的 Docker volume 保存 sandbox 登录态:
967
+
968
+ ```
969
+ scripts/agent-sandbox.sh --login codex
970
+ scripts/agent-sandbox.sh --login claude
971
+ scripts/agent-sandbox.sh --login kiro
972
+ ```
973
+
974
+ 登录过程在终端中显示设备授权或浏览器流程。登录完成后,可以检查:
975
+
976
+ ```
977
+ scripts/agent-sandbox.sh --status codex
978
+ scripts/agent-sandbox.sh --status claude
979
+ scripts/agent-sandbox.sh --status kiro
980
+ ```
981
+
982
+ 默认 volume 名称为 `trellis-agent-auth-home`,可通过
983
+ `TRELLIS_AGENT_AUTH_VOLUME` 覆盖。它只保存在 OrbStack/Docker 中,不进
984
+ Git,也不会自动读取或删除宿主机凭据。清理时请明确执行
985
+ `docker volume rm <volume-name>`。
986
+
694
987
  ## `trellis rollback` — undoing a `sync`/`mcp sync`/`onboard` run
695
988
 
696
989
  Every real write those three commands perform is recorded, before it