Repository navigation
fix(git-sync): ignore .claude/plugins/ so plugin caches aren't auto-committed (#1702) - #1705
Merged
Merged
Conversation
…ommitted (#1702) `_GITIGNORE_PATTERNS` ignored six `.claude/*` runtime dirs but not `.claude/plugins/`. Claude Code installs marketplace plugins into `~/.claude/plugins/cache/<plugin>@<version>/` (a full copy: skills, agents, hooks). Because an agent's HOME *is* its git repo root, that cache lands in the working tree and the 15-min sync loop commits it — and every plugin update commits another copy. Same repo-bloat class as #1596, different writer; and a path users are actively steered onto (`/plugin marketplace add abilityai/abilities`, `/trinity:onboard`). - Added `.claude/plugins/` to the "Claude Code runtime" block of `_GITIGNORE_PATTERNS`. Existing agents pick it up through the idempotent gitignore merge on the next Push, and any already-committed cache is untracked via the `git rm --cached` step `_migrate_workspace_gitignore` already runs (#1596) — stops future churn, doesn't rewrite history. - Kept `docs/TRINITY_COMPATIBLE_AGENT_GUIDE.md`'s gitignore block in sync (the `test_doc_and_constant_in_sync` guard requires every `_GITIGNORE_PATTERNS` entry to appear there). Open question (AC) resolved: `~/.claude.json` (the plugin install manifest) is also gitignored, so a recreated agent loses its plugins today. The cache is re-installable and does NOT belong in git either way, so this keeps it ignored and tracks the persistence gap separately as #1704 (do not un-ignore the cache). Verified: `.claude/plugins/` in the tuple + the doc block (doc-sync green); `git check-ignore` confirms `.claude/plugins/cache/<x>` is ignored in a real repo; git_service.py parses. (No live agent currently has a plugin installed — the ignore semantics + the #1596 merge/untrack mechanism are the proof.) Related to #1702
vybe
approved these changes
Jul 20, 2026
vybe
left a comment
Contributor
There was a problem hiding this comment.
Validated via /validate-pr: one-line addition to the fleet-wide gitignore + the matching doc block, which the existing test_github_init_gitignore.py parity test enforces as a pair. All checks green.
vybe
pushed a commit
that referenced
this pull request
Aug 16, 2026
…#2225) * feat(#1704): declare + materialize agent plugin manifest (backend seam) Add a template-declared `plugins:` block that materializes a committed, secret-free `~/.trinity/plugins.yaml` manifest — the agent-local half of the incubating global plugin-management model (trinity-enterprise#192). - services/template_plugins.py: tolerant, total reader (never raises) mirroring the ent#89 schedules reader. Charset-validates marketplace/plugin names and the marketplace `source` (the dangerous arg), refuses `user:token@` URLs, drops `enabledPlugins:false`, sorts+dedupes for byte-stability. - git_service.materialize_plugins(): nested YAML (sort_keys=True) via the shared injection-safe heredoc writer (_write_trinity_yaml_file, extracted from materialize_trinity_yaml_list). Opt-in no-op when empty. - _TRINITY_AUTHORED_PATHS += .trinity/plugins.yaml: yields both the #2070 `!` re-include and the rm-cached exemption, so the manifest is committed while .claude.json and .claude/plugins/ stay gitignored (#1705 intact). Co-Authored-By: Claude Opus 4.8 <[email protected]> * feat(#1704): wire declared plugins through the create path - template_service: surface normalized `plugins` + `plugin_errors` in both catalog builders (_build_template, _build_local_template), mirroring the ent#89 schedules surface. - crud: add `_TemplateResolution.declared_plugins` fed by all three resolver branches (github source metadata, local template_data, copy snapshot), and materialize it in _materialize_agent_files (opt-in, ghost-skipped, non-fatal inside the rollback fence). declared_plugins comes from the resolver, not template_data, since the github: path never populates the latter. Co-Authored-By: Claude Opus 4.8 <[email protected]> * feat(#1704): re-install declared plugins at container boot (agent side) - agent_server/plugins_reinstall.py: runnable `python3 -m` module (mirrors mcp_template.py). Hardened-parses the untrusted ~/.trinity/plugins.yaml (AliasPolicy.REJECT), re-validates names + the marketplace source (rejects userinfo/flags/traversal), reads current state via `claude plugin [marketplace] list --json` and re-installs only what is missing (`marketplace add`, `install --yes`). Subprocess arg-lists, hard timeout + stdin=DEVNULL so a no-TTY prompt cannot hang, GH_TOKEN seeded from GITHUB_PAT env (never the manifest), non-fatal, one observability summary line. Zero subprocesses when the declared set is already present. - startup.sh: guarded hook AFTER credential injection + .mcp.json.template render (a private marketplace needs a git credential at install time). Base-image change → old images silently skip the hook (release-note ordering); existing agents keep working (volume persists plugins) until recreated onto the new image. Co-Authored-By: Claude Opus 4.8 <[email protected]> * docs(#1704): plugin manifest — requirements, architecture, feature-flow, agent guide - requirements/content-files.md §42: reframe + FRs + security + honest scope. - architecture.md: new subsystem block, .trinity/ layout diagram, plugins.yaml in the _TRINITY_AUTHORED_PATHS enumeration. - feature-flows/agent-plugin-manifest.md (new) + index row. - TRINITY_COMPATIBLE_AGENT_GUIDE.md: 'Declaring Plugins' section + schema block. Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(#1704): restore template_plugins imports stripped by autoflake The pre-commit autoflake hook removed `from services.template_plugins import ...` from crud.py and template_service.py at the moment they were added (momentarily unused before the call sites landed), leaving a NameError on the catalog + create paths. Now that the usages are present the imports are stable. Co-Authored-By: Claude Opus 4.8 <[email protected]> * test(#1704): plugin manifest — reader, materialize, commit seam, boot hook, wiring - test_1704_template_plugins.py: normalizer (accept/reject/security/determinism/bounds). - test_1704_git_service_plugins.py: materialize_plugins nested YAML + byte-stability + no-op + authored-path/re-include/rm-cached exemption + #1705 intact (cache + .claude.json stay gitignored, not re-included). - test_1704_plugins_reinstall.py: agent-side reconcile (zero installs when present, fresh volume add+install --yes, timeout/arg-list/DEVNULL, non-fatal, untrusted-parse validation). - test_1704_crud_materialize_plugins.py: both resolver branches populate declared_plugins, materialize call + ghost-skip + non-fatal, catalog builders surface plugins + errors. - test_2070: .trinity/plugins.yaml added to the real-git authored-path survival sweep. Co-Authored-By: Claude Opus 4.8 <[email protected]> * chore(#1704): sync .gitignore ratchet for the new authored path Adding .trinity/plugins.yaml to _TRINITY_AUTHORED_PATHS added !.trinity/plugins.yaml to _GITIGNORE_PATTERNS. Mirror it in the agent guide's canonical gitignore block (test_doc_and_constant_in_sync) and regenerate the 14 bundled templates' .gitignore (test_1908 byte-identity), via the #1908 regenerator. Co-Authored-By: Claude Opus 4.8 <[email protected]> * docs(#1704): note the declared plugins: block in template-processing flow Co-Authored-By: Claude Opus 4.8 <[email protected]> * style(#1704): strip local black-hook reformatting, keep only logical changes The local pre-commit black hook (Andrii's, not repo CI — the base files carry long import lines black would wrap) reformatted ~550 unrelated lines in crud.py and large swaths of git_service.py/template_service.py across earlier commits. Re-applied ONLY the #1704 logical changes via targeted edits, so the diff-vs-base is minimal: git_service +90/-8, template_service +38/-0, crud +59/-3. Behaviour identical (165 unit tests green); no new ruff violations (git_service fully clean; the F401/F841 in template_service/crud are pre-existing on base). * style(#1704): strip black-hook reformatting from test_2070 (one-line add only) Co-Authored-By: Claude Opus 4.8 <[email protected]> * feat(#1704): boot hook falls back to template.yaml for source-mode agents Closes the Cornelius/source-mode survival gap the plan flagged (§5): a tokenless agent can't push a materialized .trinity/plugins.yaml back to git, so on a fresh reconstitution load_manifest falls back to the re-cloned template.yaml's `plugins:` block (same nested shape; BUDGET alias policy since template.yaml may legitimately anchor, vs REJECT for the simple manifest). The committed manifest still wins when present. startup.sh's guard widened to fire on the manifest OR a top-level `plugins:` key (cheap grep pre-check; the module does the real parse), so the fallback is actually reachable. +4 tests (fallback, manifest-wins, anchors-tolerated). Docs corrected: the hook READS template.yaml, it does not re-materialize the manifest. Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(#1704): agent marketplace-source validator is https-only, matching backend The agent-side `plugins_reinstall._is_source` gate — the SOLE validator on the untrusted `template.yaml` fallback a source-mode agent's clone carries, re-run at boot before any `claude plugin marketplace add` — accepted any `scheme://` (ftp/file/ssh/data), while the backend writer `template_plugins._validate_source` accepts only `https://`. The looser copy was the one gating untrusted input. Re-implemented (not byte-for-byte vendored) policies across the backend↔agent boundary have no parity test, so the two silently diverged. Tighten the agent gate to https-only and pin cross-boundary agreement with a shared accept/reject table run against BOTH copies (test_1704_source_validator_parity.py), encoding the safety invariant: the untrusted-input gate must be at least as strict as the writer (agent_accepts ⊆ backend_accepts). Docs: architecture.md validator description now states https-only + the parity guard; learnings.md records the re-implemented-cross-boundary-policy drift class. Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
_GITIGNORE_PATTERNSingit_service.pyignored six.claude/*runtime dirs but not.claude/plugins/. Claude Code installs marketplace plugins into~/.claude/plugins/cache/<plugin>@<version>/(a full copy — skills, agents, hooks). Since an agent'sHOMEis its git repo root, that cache lands in the working tree and the 15-min sync loop auto-commits it — and every plugin update commits another copy. Same repo-bloat class as #1596, different writer, on a path users are steered onto (/plugin marketplace add abilityai/abilities,/trinity:onboard).Change
.claude/plugins/to the "Claude Code runtime" block of_GITIGNORE_PATTERNS.git rm --cachedstep_migrate_workspace_gitignorealready runs (bug: git-sync agent workspaces grow unboundedly — auto-committed data churn bloats .git (44GB observed on one agent) #1596) — stops future churn, doesn't shrink history.docs/TRINITY_COMPATIBLE_AGENT_GUIDE.mdin sync — thetest_doc_and_constant_in_syncguard fails CI if any_GITIGNORE_PATTERNSentry is missing from the doc.Open question (AC) — resolved
Yes, and it's lost today.
~/.claude.json(the plugin manifest) is also gitignored, so a recreated agent silently loses its plugins. The right resolution per the AC: keep the cache ignored (it's re-installable and doesn't belong in git either way) and track the persistence gap separately → filed as #1704. This PR does not un-ignore anything.Verification
.claude/plugins/is present in both the_GITIGNORE_PATTERNStuple and the doc'sgitignoreblock →test_doc_and_constant_in_syncpasses (46 patterns, none missing).git check-ignorein a real repo confirms.claude/plugins/cache/[email protected]/skills/x.mdis ignored.S-006uses a hardcoded subset that doesn't includeplugins, so its_GOOD_GITIGNOREfixture is unaffected (no test churn); the auto-fix still adds the pattern sincefixes.pyreuses_GITIGNORE_PATTERNS.git_service.pyparses.(No live agent currently has a plugin installed, so the "plugin still loads" half of the AC's live check wasn't reproducible here — but the ignore semantics are proven and the merge/untrack mechanism is the same one #1596 runs in production for the sibling
.claude/*patterns.)Related to #1702 · follow-up #1704
🤖 Generated with Claude Code
Fixes #1702