agent-trellis 0.20.0 → 0.22.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 (54) hide show
  1. package/dist/adapters/claude-code.js +2 -2
  2. package/dist/adapters/codex.js +3 -3
  3. package/dist/adapters/jsonMcp.d.ts +1 -1
  4. package/dist/adapters/jsonMcp.js +2 -2
  5. package/dist/adapters/kimi-code.js +2 -2
  6. package/dist/adapters/kiro.js +11 -9
  7. package/dist/adapters/mcpPlan.d.ts +3 -1
  8. package/dist/adapters/mcpPlan.js +65 -15
  9. package/dist/adapters/pi.js +5 -5
  10. package/dist/adapters/zcode.d.ts +1 -1
  11. package/dist/adapters/zcode.js +6 -6
  12. package/dist/cli.js +9 -6
  13. package/dist/commands/doctor.d.ts +1 -1
  14. package/dist/commands/doctor.js +5 -5
  15. package/dist/commands/mcp.js +1 -1
  16. package/dist/commands/mcpAuth.js +1 -1
  17. package/dist/commands/mcpGateway.d.ts +2 -2
  18. package/dist/commands/mcpGateway.js +4 -4
  19. package/dist/commands/mcpImport.js +2 -1
  20. package/dist/commands/migrate.js +11 -1
  21. package/dist/commands/remoteSkill.js +18 -1
  22. package/dist/commands/secretsAudit.d.ts +1 -1
  23. package/dist/commands/secretsAudit.js +49 -13
  24. package/dist/commands/skill.d.ts +11 -6
  25. package/dist/commands/skill.js +85 -32
  26. package/dist/commands/sync.d.ts +1 -0
  27. package/dist/commands/sync.js +3 -1
  28. package/dist/core/canonical.d.ts +1 -2
  29. package/dist/core/canonical.js +16 -9
  30. package/dist/core/types.d.ts +8 -7
  31. package/dist/lib/envVarNames.d.ts +5 -1
  32. package/dist/lib/envVarNames.js +22 -2
  33. package/dist/lib/mcpConnect.d.ts +1 -1
  34. package/dist/lib/mcpConnect.js +35 -10
  35. package/dist/lib/mcpMigrateRead.js +14 -2
  36. package/dist/lib/secretEnv.d.ts +57 -8
  37. package/dist/lib/secretEnv.js +108 -16
  38. package/dist/lib/skillScope.d.ts +14 -0
  39. package/dist/lib/skillScope.js +40 -0
  40. package/dist/lib/tomlSection.js +3 -2
  41. package/dist/lib/workspace.js +7 -2
  42. package/dist/lib/workspaceDoctor.d.ts +1 -1
  43. package/dist/lib/workspaceDoctor.js +8 -4
  44. package/dist/lib/workspaceMcp.d.ts +1 -1
  45. package/dist/lib/workspaceMcp.js +5 -5
  46. package/dist/pi-bridge/bundle.js +42424 -2793
  47. package/dist/pi-bridge/index.js +2 -2
  48. package/docs/architecture.md +27 -7
  49. package/docs/getting-started.md +29 -9
  50. package/docs/research.md +17 -1
  51. package/package.json +2 -1
  52. package/schema/scope.example.yaml +15 -3
  53. package/schema/secrets.policy.example.yaml +5 -0
  54. package/schema/servers.example.yaml +11 -1
@@ -24,7 +24,7 @@ import { toParametersSchema, toPiContent } from "./schemaTranslate.js";
24
24
  * extraction changed nothing it could observe. */
25
25
  export { withTimeout };
26
26
  const CLIENT_INFO = { name: "trellis-mcp-bridge", version: "0.0.0" };
27
- function listServerTools(client, timeoutMs) {
27
+ async function listServerTools(client, timeoutMs) {
28
28
  return withTimeout(client.listTools(), timeoutMs, `listTools timed out after ${timeoutMs}ms`).then((result) => result.tools);
29
29
  }
30
30
  /**
@@ -43,7 +43,7 @@ export default async function trellisMcpBridge(pi, homeDir = homedir(), connectT
43
43
  // independent of whether `trellis onboard` was ever run to add pi to
44
44
  // managed.yaml. managedAgents governs static config-file writes; this
45
45
  // is pi reading canonical directly at its own runtime, P4's own concern.
46
- const { desired } = resolveMcpPlan("pi", canonical.mcp, ALL_AGENTS, canonical.secretsPolicy);
46
+ const { desired } = await resolveMcpPlan("pi", canonical.mcp, ALL_AGENTS, canonical.secretsPolicy);
47
47
  const clients = new Set();
48
48
  const registry = new McpToolRegistry();
49
49
  const closeClient = async (client) => {
@@ -43,7 +43,7 @@ Aligned to the `.agents Protocol` draft, extended where the draft is silent:
43
43
  ├── mcp/servers.yaml # single MCP source, values are var-name
44
44
  │ # references only, never literals
45
45
  ├── memories/*.md # shared memory entries (server-memory backed)
46
- ├── scope.yaml # exceptions to "shared with all agents" —
46
+ ├── scope.yaml # skill compatibility registry; agent/memory scope
47
47
  │ # see "Private / agent-specific capabilities"
48
48
  └── secrets.policy.yaml # which var names are allowed, nothing else
49
49
 
@@ -132,12 +132,14 @@ one `trellis rollback` restores originals and removes generated
132
132
 
133
133
  Not everything belongs to all six agents. A skill built around Claude
134
134
  Code's Task-based subagent delegation has no equivalent to delegate to on
135
- Codex; an MCP server might only make sense for one agent's workflow. Every
136
- scopable item — skill, subagent profile, memory entry, MCP server —
137
- defaults to "shared with all managed agents," and can be restricted with an explicit
138
- `scope` (skills/agents/memories) or inline `agents:` (MCP servers, see
139
- below). Restriction is the exception you declare, not something you
140
- configure for the common case.
135
+ Codex; an MCP server might only make sense for one agent's workflow.
136
+ Every custom skill must register applicable agents in `scope.yaml`.
137
+ Missing, empty or invalid skill scope pauses Trellis distribution and Runtime
138
+ access; sync removes only Trellis-owned links. `skill scope --all` records
139
+ the current managed set, so adding another agent never silently expands
140
+ compatibility. Package-owned built-ins retain their package-defined policy.
141
+ Subagent profiles, memory entries and MCP servers retain their existing
142
+ all-managed default and explicit restrictions.
141
143
 
142
144
  **Skills, subagent profiles, and memory entries declare scope in
143
145
  `.trellis/scope.yaml`, never inside the artifact file itself.** This
@@ -150,6 +152,18 @@ portable file exactly as its target agent's own spec expects; Trellis's
150
152
  own bookkeeping lives next to it, not inside it. See
151
153
  `schema/scope.example.yaml`.
152
154
 
155
+ Compatibility is explicit: Claude-specific workflows list `claude-code`,
156
+ Codex-specific workflows list `codex`, and portable workflows list each
157
+ reviewed agent. Publisher provenance does not prove compatibility. Hermes
158
+ skills belong to Hermes's own curator/review/archive lifecycle; Trellis
159
+ never manages or writes its skill directory.
160
+
161
+ Workspace skills use `.agents/scope.yaml` for Trellis-managed delivery and
162
+ Runtime access. Agents that discover `.agents/skills` natively can still
163
+ read that shared source directly; per-agent Trellis registration does not
164
+ override a native agent's own discovery. Keep agent-specific skills in the
165
+ global canonical store when native discovery must be isolated.
166
+
153
167
  **MCP servers are the one exception** — `agents:` is declared inline per
154
168
  server in `mcp/servers.yaml` (see `schema/servers.example.yaml`), because
155
169
  that file is Trellis's own format and is never handed to an agent
@@ -629,6 +643,12 @@ acceptance criteria already describes this shape ("point at a scratch
629
643
  section exists to make it a project-wide rule that every later phase's
630
644
  acceptance criteria must follow, not a detail specific to P1.
631
645
 
646
+ CLI fixtures must isolate the working directory as well as HOME. Running
647
+ from the real checkout with only HOME changed can make ancestor discovery
648
+ mistake the developer's `~/.agents/` for a workspace. Run the CLI by absolute
649
+ path from the scratch directory; otherwise read-only parity checks can
650
+ compare different layers and write tests can reach real project artifacts.
651
+
632
652
  This is also why P0 needing to resolve pi's actual skill-discovery path
633
653
  (§D5 in `openspec/changes/trellis-doctor-p0/design.md`) is investigated
634
654
  directly against a real pi installation *as a read-only observation*, and
@@ -465,9 +465,10 @@ $ trellis migrate --from codex --only instructions
465
465
  | `skip-case-broken` | Found as `skill.md` instead of `SKILL.md` — fix the case on the source agent first. |
466
466
  | `skip-unsupported` | The source capability can't be safely represented (including native memory without a supported adapter); nothing was written for it. |
467
467
 
468
- Migrate never overwrites a genuine conflict, and never scopes a migrated
469
- skill (or MCP server) to just the source agent — once in canonical, it's
470
- visible to every agent by default (see `sync`, below). If migrate reports
468
+ Migrate never overwrites a genuine conflict. A newly migrated skill is
469
+ registered only for its source agent; review its compatibility before
470
+ sharing it through `trellis skill scope <name> --agents <ids>`.
471
+ MCP servers retain their existing scope behavior. If migrate reports
471
472
  a `conflict`, open the two files/entries it names and decide by hand
472
473
  which content should actually be canonical, then re-run.
473
474
 
@@ -663,10 +664,10 @@ remains the command for a local directory:
663
664
  npx trellis add mattpocock/skills --list
664
665
 
665
666
  # Fetch and inspect the exact plan without writing canonical or Agent files.
666
- npx trellis add mattpocock/skills --skill loop-me --dry-run
667
+ npx trellis add mattpocock/skills --skill loop-me --agent codex --dry-run
667
668
 
668
669
  # Import to the user-level canonical store, then sync to every managed Agent.
669
- npx trellis add mattpocock/skills --skill loop-me --yes
670
+ npx trellis add mattpocock/skills --skill loop-me --agent '*' --yes
670
671
  ```
671
672
 
672
673
  The source may be `owner/repository` or a credential-free HTTPS
@@ -678,10 +679,11 @@ dependencies, or write into `.agents/skills`, `~/.agents/skills`, or any
678
679
  Agent-specific Skill directory during import. Review the imported
679
680
  `SKILL.md` before relying on it in an Agent session.
680
681
 
681
- By default the imported Skill is unscoped, which means every Agent currently
682
- listed in `~/.trellis/managed.yaml` receives it on sync. Restrict delivery to
683
- managed Agents with `--agent`; comma-separated values and repeated flags are
684
- accepted. `--agent '*'` writes the current managed set as an explicit scope.
682
+ Imports require an explicit choice of applicable agents. Interactive terminals
683
+ offer a selection with no agents preselected; noninteractive/JSON calls must
684
+ supply `--agent`. Comma-separated values and repeated flags are accepted.
685
+ `--agent '*'` records the current managed set; `--agent none` imports a paused
686
+ skill. A newly managed agent does not receive existing skills automatically.
685
687
  An Agent that is installed but unmanaged is refused before any canonical or
686
688
  native write. Add it to Trellis's managed boundary first:
687
689
 
@@ -785,6 +787,24 @@ the first place (see `mcp sync`'s own explanation of `env` vs.
785
787
  All four of `skill add`/`skill remove`/`mcp add`/`mcp remove` support
786
788
  `--dry-run` and `--json`, same convention as every other command.
787
789
 
790
+ Local imports use the same compatibility rule:
791
+
792
+ ```sh
793
+ trellis skill add review --from ./skills/review --agents claude-code,codex
794
+ trellis skill add pending --from ./skills/pending --none
795
+ trellis skill list --agent codex --json
796
+ trellis skill scope review --all
797
+ ```
798
+
799
+ Every custom skill needs a `skills.<name>: [agent ids]` entry in
800
+ `~/.trellis/scope.yaml` (or `.agents/scope.yaml` for workspace delivery).
801
+ Unregistered skills pause until reviewed; sync removes only their
802
+ Trellis-owned links and leaves independent files untouched. `skill list
803
+ --agent` shows scoped skills with `linked`, `missing`, `conflict` or `runtime`
804
+ delivery status. Codex's global delivery root is `~/.agents/skills`.
805
+ Use `trellis sync skills --dry-run` before converging an older installation.
806
+ Hermes maintains its own skills; Trellis never writes its skill store.
807
+
788
808
  ## `trellis sync`
789
809
 
790
810
  Distributes canonical skills and instructions to every **managed** agent
package/docs/research.md CHANGED
@@ -221,7 +221,23 @@ real incidents during development (a GitLab PAT stored under the wrong
221
221
  variable name, and three divergent values of the same router token, one of
222
222
  which was silently invalid). Trellis's contribution here is `trellis secrets
223
223
  audit` — a linter that fails a build if any adapter output contains a raw
224
- credential — not a new secret store.
224
+ credential — not a new secret store. The concrete reference form is
225
+ `mxenv://<profile>/<KEY>` (mx-env-secret-source): written in `servers.yaml`
226
+ `env`/`envAliases`, or inline in a header template such as
227
+ `Authorization: Bearer ${mxenv://legacy/SERVICE_TOKEN}`, resolved from the
228
+ mxenv profile at consumption time. Env references are delivered under the
229
+ `KEY` segment; header references are substituted in memory and retain their
230
+ profile identity even when two profiles use the same key. Missing keys,
231
+ unknown profiles and malformed header references fail explicitly, without
232
+ printing provider output or substituting an empty credential. Bare `${VAR}`
233
+ headers retain their existing env-file/process-env behavior.
234
+
235
+ Header references require Trellis gateway/runtime delivery (or pi's bridge),
236
+ which resolves them independently of the GUI or shell's inherited environment.
237
+ Native clients do not understand `mxenv://`; direct native sync reports a
238
+ conflict with instructions to enable gateway/runtime, rather than writing an
239
+ unusable reference or persisting its resolved value. The canonical server
240
+ still uses `transport: http`/`sse`; no third-party stdio shim is needed.
225
241
 
226
242
  A third real incident during migrate-in: a source config's `${VAR}`
227
243
  reference doesn't always name itself (`OPENAPI_MCP_HEADERS:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-trellis",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "description": "A unified Code Agent Runtime for Skills, MCP, Memory, and shared instructions across Claude Code, Codex, Kiro, pi, Kimi Code, and ZCode.",
5
5
  "license": "MIT",
6
6
  "author": "Paul Leo",
@@ -69,6 +69,7 @@
69
69
  "@modelcontextprotocol/client": "^2.3.1",
70
70
  "@modelcontextprotocol/sdk": "^1.30.0",
71
71
  "@modelcontextprotocol/server": "^2.3.1",
72
+ "@morphixai/mxenv-core": "^0.12.2",
72
73
  "smol-toml": "^1.9.1",
73
74
  "yaml": "^2.9.1",
74
75
  "zod": "^4.6.5"
@@ -1,6 +1,8 @@
1
- # .trellis/scope.yaml — exceptions only. Anything NOT listed here is
2
- # shared with all managed agents — that's the default Trellis exists for.
3
- # Only write an entry when a capability should NOT go everywhere.
1
+ # .trellis/scope.yaml — every custom skill must register applicable agents.
2
+ # Missing/invalid skill entries are PAUSED. [] explicitly pauses a skill.
3
+ # Lists name known compatible agents; managing another agent does not expand
4
+ # an existing skill's list. `skill scope <name> --all` records today's set.
5
+ # Subagent profiles and memories retain their all-managed default.
4
6
  #
5
7
  # Why this lives in its own file instead of inside each SKILL.md/agent.md:
6
8
  # Codex validates SKILL.md frontmatter against an allow-list of known keys
@@ -15,11 +17,21 @@
15
17
  # instead of here — see schema/servers.example.yaml.
16
18
 
17
19
  skills:
20
+ shared-workflow: [claude-code, codex, kiro, pi]
21
+ codex-workflow: [codex]
22
+ pending-review: []
18
23
  # This skill only makes sense for Claude Code's tool surface (e.g. it
19
24
  # references the Task tool for subagent delegation, which the other
20
25
  # three agents don't have an equivalent of).
21
26
  claude-subagent-dispatch: [claude-code]
22
27
 
28
+ # Keep publisher provenance separate from compatibility: a Claude-only or
29
+ # Codex-only upstream skill still needs the matching list above. Portable
30
+ # skills list every reviewed target. Never add a Trellis-only `agents`
31
+ # field to upstream SKILL.md files.
32
+ # Hermes skills are autonomous (curator/review/archive); Trellis does not
33
+ # deliver, overwrite, link, or manage ~/.hermes/skills.
34
+
23
35
  agents:
24
36
  # Subagent profiles are implicitly Claude-Code-only today — Codex has no
25
37
  # persistent subagent concept, Kiro/pi unconfirmed (see docs/research.md).
@@ -12,6 +12,11 @@
12
12
  # whose own native MCP client resolves `${VAR}` in its own process), so it
13
13
  # already has to read a value into memory to hand to that subprocess.
14
14
  #
15
+ # Prefer `mxenv://<profile>/<KEY>` references in servers.yaml `env` /
16
+ # `envAliases` entries where possible: they resolve from the encrypted
17
+ # mxenv store at consumption time and need neither ambient env nor a
18
+ # plaintext env_file (mx-env-secret-source).
19
+ #
15
20
  # env_file (optional) narrows *where* the bridge reads those values from —
16
21
  # a dotenv-format file (KEY=VALUE per line, no quoting/interpolation), never
17
22
  # merged with ambient process env once set: a name absent from it resolves
@@ -1,7 +1,17 @@
1
1
  # .trellis/mcp/servers.yaml — canonical MCP server definitions.
2
2
  #
3
3
  # Rules (see docs/architecture.md and docs/research.md §"Secrets"):
4
- # - `env` values are variable NAMES only. Never a literal secret.
4
+ # - `env` values are variable NAMES only, or `mxenv://<profile>/<KEY>`
5
+ # references resolved from the mxenv store at consumption time and
6
+ # delivered under the `KEY` segment (mx-env-secret-source). A
7
+ # reference gives this file value-free, machine-independent
8
+ # provenance; prefer it over relying on ambient process env.
9
+ # - HTTP/SSE headers accept inline references, e.g.
10
+ # Authorization: "Bearer ${mxenv://legacy/SERVICE_TOKEN}"
11
+ # Use Trellis gateway/runtime delivery (or pi's bridge) for these:
12
+ # values resolve in memory without depending on the launching shell.
13
+ # Missing/invalid references fail explicitly. Native direct sync
14
+ # refuses these references because native clients cannot resolve them.
5
15
  # - Real values come from whatever already populates process env
6
16
  # (a plain `.env`-style file, 1Password's `op run`, etc.) — Trellis
7
17
  # does not store or transport secret values itself.