MoonshotAI / MoonshotAI/kimi-code

feat(plugins): support monorepo subdirectory sources in the marketplace

Open
#2,945 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.5k
Forks
1.2k
Avg merge
11h 53m
Merged PRs (30d)
350

Description

Problem

The plugin marketplace cannot install a plugin that lives in a monorepo subdirectory.

resolveInstallSource (packages/agent-core-v2/src/app/plugin/source.ts:63) joins every path segment after /tree/ into the git ref:

if (head === 'tree' && rest.length >= 2) {
  const refValue = decodeRefSegments(rest.slice(1)); // all segments -> ref
  ...
}

So https://github.com/owner/repo/tree/main/path/to/plugin resolves to ref main/path/to/plugin, and codeload fetches the wrong archive instead of checking out main and extracting path/to/plugin. Confirmed by the Codex review on #2944.

Why it matters

Any plugin hosted in a monorepo subdirectory (common when one plugin is shared across several agent hosts) cannot be listed without forking it into a standalone repo, which fragments a single source of truth. This affects monorepo-hosted plugins generally.

Proposal: encode the subdirectory in the source string (following pip / go-getter)

The established convention for "repo + subdirectory + ref" encodes the subdir in the source string with an explicit delimiter, avoiding the ref-vs-subdir ambiguity (a branch name can contain slashes, which is why the current code joins the whole tail as the ref):

  • pip / PEP 508: git+https://github.com/owner/repo@ref#subdirectory=path (pip docs)
  • Terraform / go-getter: github.com/owner/repo//modules/vpc?ref=v1.2.0 (Terraform module sources)

For Kimi's GitHub web-URL source form, the pip-style #subdirectory= fragment is the cleanest fit because it rides on the existing new URL() parse with no change to ref handling:

https://github.com/mem0ai/mem0/tree/main#subdirectory=integrations/mem0-plugin

Implementation:

  • source.ts: parseGithubUrl already builds a URL, so read url.hash (#subdirectory=<path>) and carry an optional subdir on the github ResolvedSource. The existing /tree/<ref> parsing is unchanged (url.pathname still yields ref main).
  • manager.ts (after extractZip): sourceRoot = path.join(sourceRoot, subdir) before parseManifest, and persist subdir on the plugin record so updates reuse it.

The marketplace entry stays a single source field:

{ "id": "mem0", "tier": "curated", "source": "https://github.com/mem0ai/mem0/tree/main#subdirectory=integrations/mem0-plugin" }

This keeps source a single string (consistent with the existing local-path / zip-url / github-url handling), matches a widely used convention, and is unambiguous. (A separate subdir entry field would also work, but the URL-encoded form is more consistent with the single-string source model.)

Offer

Happy to contribute the PR (source.ts + manager.ts + tests + docs + changeset). Relates to #2944 (adding a monorepo-hosted plugin to the marketplace). Which syntax do you prefer before I open it?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with parseGithubUrl and resolveInstallSource in packages/agent-core-v2/src/app/plugin/source.ts, then inspect manager.ts around extractZip and parseManifest. Check the existing plugin-source tests and record shape before deciding how the optional subdirectory is carried through. Done means a GitHub tree URL can target a monorepo subdirectory while preserving the ref and update behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.