Skip to content

feat(marketplace): inherit description/version from local-path apm.yml#1581

Draft
imbabamba wants to merge 2 commits into
microsoft:mainfrom
imbabamba:feat/local-metadata-inherit-description
Draft

feat(marketplace): inherit description/version from local-path apm.yml#1581
imbabamba wants to merge 2 commits into
microsoft:mainfrom
imbabamba:feat/local-metadata-inherit-description

Conversation

@imbabamba
Copy link
Copy Markdown

@imbabamba imbabamba commented Jun 2, 2026

TL;DR

apm pack now auto-fills description and version in
marketplace.json from each local-path package's own apm.yml --
the same fallback the remote source path has used since #1061.
A curator-side value under marketplace.packages still wins when
set, and the local read is path-traversal-guarded against the
project root. Validated against the full unit suite (15837 tests)
with 13 new tests covering the local fallback path.

Problem (WHY)

The remote branch in ClaudeMarketplaceMapper.compose already reads
description and version from each resolved package's own
apm.yml when the curator entry omits them; _fetch_remote_metadata
populates that lookup over HTTPS.

The local branch had no such fallback. It emitted only what the
curator wrote in root apm.yml's marketplace.packages[]. A stale
comment in _prefetch_metadata even claimed "Local-path packages are
skipped (they carry their own metadata)" -- but the local code path
never read any metadata at all.

For a monorepo marketplace using source: ./plugins/<name> entries,
that gap leaves producers with two options:

  • Duplicate the description between root apm.yml's
    marketplace.packages[] and each plugins/<name>/apm.yml. The
    two copies drift over time -- the producer edits one and forgets
    the other.
  • Run custom sync tooling outside apm pack to keep them aligned.

Remote sources do not have this gap. This PR closes it for local
sources by mirroring the existing remote behavior exactly.

Approach (WHAT)

Layer Before After
builder._prefetch_metadata Filtered out local packages. Returned {} under --offline. Reads local packages from disk first (always), then remote concurrently (still skipped under --offline). Returns one dict the mapper consumes the same way regardless of source kind.
builder._fetch_local_metadata Did not exist. New method. Reads <project_root>/<subdir>/apm.yml, extracts description and version. Path-traversal-guarded via ensure_path_within. Skips a source that resolves to the project root itself.
output_mappers.ClaudeMarketplaceMapper.compose (is_local branch) Emitted curator-side fields only. No fallback. Same hierarchy as the remote branch: curator wins; otherwise fall back to package-manifest meta. Verbose diagnostic on divergence.
docs/reference/manifest-schema.md description row read "Pass-through to marketplace.json" with no mention of the fallback. One-paragraph note after the marketplace.packages table covers the fallback for both source kinds.

Remote-source override semantics are unchanged, including the
verbose diagnostic that logs divergence between curator and package
manifest. Local sources log the equivalent diagnostic with
(package: ...) instead of (remote: ...).

Implementation (HOW)

File What changed
src/apm_cli/marketplace/builder.py New _fetch_local_metadata(pkg), mirroring the _fetch_remote_metadata shape -- reads pkg.subdir from disk, validates path containment, returns dict or None. _prefetch_metadata rewritten to process local packages serially first (no thread pool needed), then remote concurrently. Stale "Local-path packages are skipped" comment removed.
src/apm_cli/marketplace/output_mappers.py is_local branch in ClaudeMarketplaceMapper.compose reads meta = remote_metadata.get(pkg.name, {}) and applies the same curator-wins-else-meta hierarchy as the remote branch. Verbose diagnostic on divergence.
tests/unit/marketplace/test_builder.py New TestFetchLocalMetadata class -- 8 tests: happy path (description + version), description-only, missing apm.yml, missing subdir, path-escape, project-root edge, malformed YAML, empty subdir field.
tests/unit/marketplace/test_local_path_compose.py 5 new compose-level tests: description inherited from package manifest, version inherited, curator override wins, missing per-package apm.yml omits both fields, project-root edge does not read the marketplace's own apm.yml.
docs/src/content/docs/reference/manifest-schema.md One-paragraph note after the marketplace.packages table covering the fallback rule.

Edge cases handled

  • Missing per-package apm.yml: returns None; no key emitted.
  • Malformed YAML: returns None; error logged at debug level;
    the build continues.
  • Source escapes project root: ensure_path_within raises;
    _fetch_local_metadata catches and returns None.
  • Source resolves to the project root itself: explicit check;
    returns None so the marketplace's own apm.yml is never read
    as a package manifest.
  • Empty subdir on the ResolvedPackage: defensive early
    return.
  • --offline: local reads always run (filesystem, no network);
    remote reads are still skipped.

Validation evidence

$ uv run --extra dev ruff check src/ tests/            # All checks passed!
$ uv run --extra dev ruff format --check src/ tests/   # 1158 files already formatted

Tests: 15837 passed, 1 skipped, 21 xfailed (full tests/unit +
tests/test_console.py, ~1:25). 1418 passed across
tests/unit/marketplace, including the 13 new tests added in this
PR.

Follow-up to #1061

#1061 added the remote-source fallback (_fetch_remote_metadata)
to close the "remote-source pass-through metadata dropped" gap.
The same gap existed for local sources. This PR closes it.

Local-path packages (`source: ./...`) now use the same fallback as
remote sources when the curator entry under `marketplace.packages`
omits `description` or `version`: `apm pack` reads the field from
the package's own `apm.yml` and writes it to `marketplace.json`. A
curator-side value still wins when set. Path resolution is constrained
to the project root, and a source that resolves to the marketplace's
own `apm.yml` is skipped.

Follow-up to microsoft#1061, which added the same behavior for remote sources.
@imbabamba imbabamba force-pushed the feat/local-metadata-inherit-description branch from 246ac18 to 023c1be Compare June 2, 2026 10:24
@microsoft-github-policy-service
Copy link
Copy Markdown

@imbabamba please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"
Contributor License Agreement

Contribution License Agreement

This Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
and conveys certain license rights to Microsoft Corporation and its affiliates (“Microsoft”) for Your
contributions to Microsoft open source projects. This Agreement is effective as of the latest signature
date below.

  1. Definitions.
    “Code” means the computer software code, whether in human-readable or machine-executable form,
    that is delivered by You to Microsoft under this Agreement.
    “Project” means any of the projects owned or managed by Microsoft and offered under a license
    approved by the Open Source Initiative (www.opensource.org).
    “Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any
    Project, including but not limited to communication on electronic mailing lists, source code control
    systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of
    discussing and improving that Project, but excluding communication that is conspicuously marked or
    otherwise designated in writing by You as “Not a Submission.”
    “Submission” means the Code and any other copyrightable material Submitted by You, including any
    associated comments and documentation.
  2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any
    Project. This Agreement covers any and all Submissions that You, now or in the future (except as
    described in Section 4 below), Submit to any Project.
  3. Originality of Work. You represent that each of Your Submissions is entirely Your original work.
    Should You wish to Submit materials that are not Your original work, You may Submit them separately
    to the Project if You (a) retain all copyright and license information that was in the materials as You
    received them, (b) in the description accompanying Your Submission, include the phrase “Submission
    containing materials of a third party:” followed by the names of the third party and any licenses or other
    restrictions of which You are aware, and (c) follow any other instructions in the Project’s written
    guidelines concerning Submissions.
  4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else
    for whom You are acting in making Your Submission, e.g. as a contractor, vendor, or agent. If Your
    Submission is made in the course of Your work for an employer or Your employer has intellectual
    property rights in Your Submission by contract or applicable law, You must secure permission from Your
    employer to make the Submission before signing this Agreement. In that case, the term “You” in this
    Agreement will refer to You and the employer collectively. If You change employers in the future and
    desire to Submit additional Submissions for the new employer, then You agree to sign a new Agreement
    and secure permission from the new employer before Submitting those Submissions.
  5. Licenses.
  • Copyright License. You grant Microsoft, and those who receive the Submission directly or
    indirectly from Microsoft, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license in the
    Submission to reproduce, prepare derivative works of, publicly display, publicly perform, and distribute
    the Submission and such derivative works, and to sublicense any or all of the foregoing rights to third
    parties.
  • Patent License. You grant Microsoft, and those who receive the Submission directly or
    indirectly from Microsoft, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license under
    Your patent claims that are necessarily infringed by the Submission or the combination of the
    Submission with the Project to which it was Submitted to make, have made, use, offer to sell, sell and
    import or otherwise dispose of the Submission alone or with the Project.
  • Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement.
    No additional licenses or rights whatsoever (including, without limitation, any implied licenses) are
    granted by implication, exhaustion, estoppel or otherwise.
  1. Representations and Warranties. You represent that You are legally entitled to grant the above
    licenses. You represent that each of Your Submissions is entirely Your original work (except as You may
    have disclosed under Section 3). You represent that You have secured permission from Your employer to
    make the Submission in cases where Your Submission is made in the course of Your work for Your
    employer or Your employer has intellectual property rights in Your Submission by contract or applicable
    law. If You are signing this Agreement on behalf of Your employer, You represent and warrant that You
    have the necessary authority to bind the listed employer to the obligations contained in this Agreement.
    You are not expected to provide support for Your Submission, unless You choose to do so. UNLESS
    REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, AND EXCEPT FOR THE WARRANTIES
    EXPRESSLY STATED IN SECTIONS 3, 4, AND 6, THE SUBMISSION PROVIDED UNDER THIS AGREEMENT IS
    PROVIDED WITHOUT WARRANTY OF ANY KIND, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY OF
    NONINFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
  2. Notice to Microsoft. You agree to notify Microsoft in writing of any facts or circumstances of which
    You later become aware that would make Your representations in this Agreement inaccurate in any
    respect.
  3. Information about Submissions. You agree that contributions to Projects and information about
    contributions may be maintained indefinitely and disclosed publicly, including Your name and other
    information that You submit with Your Submission.
  4. Governing Law/Jurisdiction. This Agreement is governed by the laws of the State of Washington, and
    the parties consent to exclusive jurisdiction and venue in the federal courts sitting in King County,
    Washington, unless no federal subject matter jurisdiction exists, in which case the parties consent to
    exclusive jurisdiction and venue in the Superior Court of King County, Washington. The parties waive all
    defenses of lack of personal jurisdiction and forum non-conveniens.
  5. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and
    supersedes any and all prior agreements, understandings or communications, written or oral, between
    the parties relating to the subject matter hereof. This Agreement may be assigned by Microsoft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant