feat(manager): add apm manager for Agent Package Manager#44390
Conversation
|
|
Add a new `apm` manager that updates git-pinned dependencies in APM (Agent Package Manager) `apm.yml` manifests, as requested in renovatebot#42507. The manager parses the string entries under `dependencies.apm` and `devDependencies.apm` (`[host/]owner/repo[/subpath]#<ref>`) and selects the datasource dynamically from the git host, reusing the existing github-tags, gitlab-tags and git-tags datasources. MCP entries carry no pinnable version and are ignored. When an `apm.lock.yaml` lockfile is present, it is refreshed by running `apm install` via a new `apm` tool constraint (pypi `apm-cli`). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vfjt3BpqDriiVsvwqVe9M9
APM ships self-contained binaries as GitHub release assets (apm-linux-<arch>.tar.gz under vX.Y.Z tags), not as the PyPI apm-cli wheel. Point the apm tool constraint at the github-releases datasource so the version Renovate resolves matches the artifact that actually gets installed, stripping the leading `v` from the tag. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vfjt3BpqDriiVsvwqVe9M9
The APM project's canonical home is github.com/microsoft/apm (originally danielmeppiel/apm). Update the manager URL and readme accordingly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vfjt3BpqDriiVsvwqVe9M9
3ff6c7b to
9cc5d88
Compare
|
(sorry about the force-push, it was necessary to solve the CLA issue, i.e. committing properly as myself) |
| return { | ||
| ...base, | ||
| currentValue, | ||
| skipReason: 'invalid-dependency-specification' as SkipReason, |
|
|
||
| if (!currentValue) { | ||
| // Unpinned dependency (no `#ref`) - nothing for Renovate to update. | ||
| return { ...base, skipReason: 'unspecified-version' as SkipReason }; |
| return null; | ||
| } | ||
|
|
||
| const manifest = parsed as ApmManifest; |
There was a problem hiding this comment.
dont cast as such, instead create a zod schema and use with parseSingleYaml as such
parseSingleYaml(content, { customSchema })
| depType: string, | ||
| ): PackageDependency[] { | ||
| const result: PackageDependency[] = []; | ||
| if (!deps || !Array.isArray(deps.apm)) { |
There was a problem hiding this comment.
You already import from @sindresorhus/is;
is.array(deps.apm) is more consistent with the rest of the file.
There was a problem hiding this comment.
Thanks for the review! Addressed all four points in 3fdb4cf:
- Zod schema — added
schema.tswith anApmManifestschema and switched toparseSingleYaml(content, { customSchema: ApmManifest }), dropping theas ApmManifestcast. as SkipReasoncasts — both removed; the literals infer fine.is.array(deps.apm)— resolved structurally rather than with theis.arrayswap: the schema now models the section asLooseArray(z.string()), so it keeps only the string entries and drops MCP objects / non-string / non-array values during parsing. That means the manualArray.isArray+is.stringguards are gone entirely —extractSectionjust maps a typedstring[]. Let me know if you'd prefer the explicit runtime check kept instead.
Also removed the now-unused types.ts. Coverage stays at 100% on the module and type-check passes.
Address review feedback on the apm manager:
- parse `apm.yml` with a dedicated zod schema via
`parseSingleYaml(content, { customSchema })` instead of casting the
parsed YAML to `ApmManifest`
- `LooseArray(z.string())` keeps only the string dependency entries, so
MCP objects and other non-string values are dropped by the schema and
the manual `Array.isArray`/`is.string` guards are no longer needed
- drop the `as SkipReason` casts now that the literals are inferred
- remove the now-unused `types.ts`
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UbMAQBiMRNkCNxc8EGQw1C
Changes
Adds a new
apmmanager that keeps APM (Agent Package Manager) dependencies up to date, as requested in discussion #42507.APM projects declare git-pinned agent dependencies (skills, plugins, agents, full packages) in an
apm.ymlmanifest and pin the resolved tree in anapm.lock.yamllockfile. Nothing currently bumps those refs.The new manager:
dependencies.apmanddevDependencies.apm, of the form[host/]owner/repo[/subpath]#<ref>.detectPlatform, which also honorshostRules) — no new datasource is required:github.com(and self-hosted GitHub) →github-tagsgitlab.com(and self-hosted GitLab) →gitlab-tagsgit-tags#<ref>; unpinned entries are skipped.apm.lock.yaml(when present) by runningapm install, wired through a newapmtool constraint that resolves the CLI frommicrosoft/apmGitHub releases.MCP server entries under
dependencies.mcpare intentionally not managed: they are identified by an MCP registry name (e.g.io.github.github/github-mcp-server) and carry no version to pin, so there is nothing for Renovate to update.Lock file maintenance note
Renovate's adding-a-package-manager guide prefers a
<tool> updatecommand over delete-then-<tool> install, since the latter can lose platform-specific lock data. APM does not provide anupdatecommand, so:apm installto syncapm.lock.yamlto the updated manifest (no delete).apm.lock.yamland runsapm installto regenerate it. APM's lockfile records resolved sources and content hashes (no platform-specific fields), so a full regeneration is deterministic and safe here.Category
I omitted a manager
categoryto keep the diff self-contained (avoiding a change to the sharedcategoriesconstant). I'm happy to add one if preferred — would maintainers like a newaicategory (APM targets AI coding agents), or is leaving it uncategorized better?Depends on
...which adds
install-tool apmto the base image. Theapm installlockfile step only works once that PR is merged and a new base image is released; the manager’s unit tests mock exec, so this PR’s CI is green independently.Context
Please select one of the following:
The New Package Manager Questionnaire is completed in discussion #42507.
AI assistance disclosure
Did you use AI tools to create any part of this pull request?
The manager code, unit tests, and documentation were drafted with Claude (via Claude Code) and reviewed before submission.
Documentation (please check one with an [x])
How I've tested my work (please select one)
I have verified these changes via:
100% test coverage on the new files (
pnpm vitest run lib/modules/manager/apm), pluspnpm check --allandpnpm type-checkpassing.Additionally verified with a local extraction dry-run against a representative
apm.yml, confirming correct datasource/packageName resolution across hosts:microsoft/apm-sample-package#v1.0.0github-tagsmicrosoft/apm-sample-packagev1.0.0anthropics/skills/skills/frontend-design#v0.24.0github-tagsanthropics/skillsv0.24.0gitlab.com/acme/agents#v2.3.0gitlab-tagsacme/agentsv2.3.0bitbucket.org/acme/tools#v1.1.0git-tagshttps://bitbucket.org/acme/toolsv1.1.0danielmeppiel/design-guide(unpinned)unspecified-version)owner/repo#v1.2.3(devDependencies)github-tagsowner/repov1.2.3MCP entries under
dependencies.mcpwere correctly ignored.The public repository: https://github.com/microsoft/apm