From 0fb106b73185072c637d32861adafb8f7bbfa3e9 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Wed, 2 Dec 2026 11:35:09 +0000 Subject: [PATCH] fix(kyberforge): run the repo-pinned apm from apm-workflow apm-workflow spelled every command as bare apm, which in a repo that pins apm with uv runs whatever is on PATH, possibly an apm that refuses the repo's lockfile. Add a step that checks for the pin and runs uv run --frozen apm there, and the PATH apm otherwise. apm-orchestrate's version check now probes the same apm. Bring the references level with apm 0.39.3: the Copilot marketplace output profile, get_effective_type() still ignoring the declared type, plain apm audit's exit codes, the uv form of the CI example, and audit --ci needing an apm at least as new as the lock's writer. Bump metadata.version to 1.0.4. Refs: #273 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi --- .../.apm/agents/apm-orchestrate.agent.md | 4 +-- .../.apm/skills/apm-workflow/SKILL.md | 16 +++++++-- .../skills/apm-workflow/references/audit.md | 9 ++++- .../skills/apm-workflow/references/compile.md | 5 +-- .../apm-workflow/references/configure.md | 3 +- .../apm-workflow/references/marketplace.md | 3 +- .../skills/apm-workflow/references/sources.md | 34 ++++++++++++++++++- 7 files changed, 63 insertions(+), 11 deletions(-) diff --git a/plugins/kyberforge/.apm/agents/apm-orchestrate.agent.md b/plugins/kyberforge/.apm/agents/apm-orchestrate.agent.md index 7cd26ee..1ada386 100644 --- a/plugins/kyberforge/.apm/agents/apm-orchestrate.agent.md +++ b/plugins/kyberforge/.apm/agents/apm-orchestrate.agent.md @@ -13,7 +13,7 @@ You are the orchestrator for apm package/marketplace operations. Your one job is You resolve the package root once per dispatched operation (the directory containing that package's `apm.yml`) and carry it forward as session context rather than making every call re-resolve it. -**Scope:** this orchestrator routes `apm-workflow`'s five concerns only — configure/scaffold, marketplace, install, compile/pack/publish, audit. It does not route `apm-install` (binary install, agent-runtime setup) — that's a one-time machine bootstrap, not a per-package, fan-out-able operation, and has no orchestrator counterpart. Confirm `apm --version` succeeds before dispatching any operation; if it fails, tell the caller to run `apm-install` first rather than attempting recovery here. +**Scope:** this orchestrator routes `apm-workflow`'s five concerns only — configure/scaffold, marketplace, install, compile/pack/publish, audit. It does not route `apm-install` (binary install, agent-runtime setup) — that's a one-time machine bootstrap, not a per-package, fan-out-able operation, and has no orchestrator counterpart. Confirm the repo's apm answers `--version` before dispatching any operation: `uv run --frozen apm --version` in a repo that pins apm with uv, `apm --version` otherwise (`apm-workflow` Step 2 says how to tell). If it fails, tell the caller to run `apm-install` first rather than attempting recovery here. ## Hard rules @@ -43,7 +43,7 @@ These are non-negotiable regardless of `confirm` or any skill-local override: 1. Validate the request structure and check if `operation` is known 2. Check the request against the Hard rules above (publish confirmation, marketplace-add direction, `type:` delegation, audit-vs-audit-ci, registries precondition) — refuse outright on violation, independent of `confirm` 3. If `operation` is `publish`: require `confirm: true`, dispatch `--dry-run -v` first regardless, surface that output, else fail with structured "requires explicit confirmation" error -4. Verify `apm --version` succeeds; if not, fail with a diagnostic pointing to `apm-install` +4. Verify the repo's apm answers `--version` (pinned: `uv run --frozen apm --version`); if not, fail with a diagnostic pointing to `apm-install` 5. Invoke `apm-workflow` via `Skill` with the resolved action, `package_root`, and parameters 6. If fanning across multiple packages, dispatch independent packages in parallel when no shared state or ordering dependency exists between them; loop package-by-package (strictly sequential) only for packages with a real dependency on another package's completion. Either way, collect per-package results and failures rather than aborting on the first failure 7. Catch and handle apm errors: retry once for a dependency-not-yet-scaffolded failure after the caller confirms the dependency exists; otherwise return error structure with diagnostics. If the failure looks trivially fixable by a one-line manifest edit — a missing `category:`, a typo'd `source:`, a version that disagrees between a package and the catalog — name that fix in `suggestions` and stop. Do not apply it yourself and do not self-dispatch an `edit-config` to apply it diff --git a/plugins/kyberforge/.apm/skills/apm-workflow/SKILL.md b/plugins/kyberforge/.apm/skills/apm-workflow/SKILL.md index 7dbf603..0a790bc 100644 --- a/plugins/kyberforge/.apm/skills/apm-workflow/SKILL.md +++ b/plugins/kyberforge/.apm/skills/apm-workflow/SKILL.md @@ -5,10 +5,11 @@ description: > the dependencies it declares, or an apm marketplace — even when the user does not say "apm". Not the apm binary or an agent runtime -> `apm-install`. metadata: - version: "1.0.3" + version: "1.0.4" category: apm source_keys: - context7-microsoft-apm + - apm-cli-0-39-3-uv-experiments --- ## Gotchas @@ -29,6 +30,15 @@ metadata: Read the reference file matching the resolved flow — it carries that flow's own traps, and names a sibling file wherever one flow genuinely depends on another's detail. -## Step 2 — Execute +## Step 2 — Choose the apm command -Follow the matched reference file's instructions. Report back which `apm` command(s) were run (or drafted, if the user asked for a plan rather than execution) and their outcome. +The references spell every command as bare `apm`. Before running one, check whether the repo pins apm: a `pyproject.toml` at the repo root naming `apm-cli` in a dependency group, with a `uv.lock` beside it. + +- **Pinned:** run each command as `uv run --frozen apm `, adding `--project ` from a subdirectory. Run `uv sync --frozen` once per checkout first; the first sync needs the network. A bare `apm` there runs whatever is on `PATH`, which may be older than the repo's pin and refuse its lockfile. +- **Not pinned:** use the `apm` on `PATH`. If it is missing, or refuses the repo's lockfile as too new, hand off to `apm-install`. + +Installing apm, or adding or moving the pin, belongs to `apm-install`. + +## Step 3 — Execute + +Follow the matched reference file's instructions. Report back which `apm` command(s) were run (or drafted, if the user asked for a plan rather than execution), spelled as invoked, and their outcome. diff --git a/plugins/kyberforge/.apm/skills/apm-workflow/references/audit.md b/plugins/kyberforge/.apm/skills/apm-workflow/references/audit.md index 48eeda4..7223c9b 100644 --- a/plugins/kyberforge/.apm/skills/apm-workflow/references/audit.md +++ b/plugins/kyberforge/.apm/skills/apm-workflow/references/audit.md @@ -4,6 +4,9 @@ source_keys: - context7-microsoft-apm - context7-websites-code-claude - claude-code-plugins-docs + - apm-v0-39-3-source + - apm-v0-39-3-docs + - apm-cli-0-39-3-uv-experiments --- ## `apm audit` @@ -14,7 +17,7 @@ apm audit --ci # CI gate: lockfile consistency + drift replay + pol apm audit --file # standalone: scan an arbitrary file ``` -Exit code `0` on success, `1` on any violation — composes as a normal CI gate step. It does not replace general lint/test/security-scan CI steps, it sits alongside them. +`apm audit --ci` exits `0` when every check passes and `1` when any fails, so it composes as a normal CI gate step. Plain `apm audit` exits `0` when clean, `1` on a critical finding and `2` on warnings only. It does not replace general lint/test/security-scan CI steps, it sits alongside them. ## Policy checks @@ -46,6 +49,10 @@ jobs: `-f sarif --output ` emits SARIF for GitHub Code Scanning's inline PR annotations. +In a repo that pins apm with uv, replace the `pip install` step with `uv sync --frozen` and run each apm step as `uv run --frozen apm …`, so CI runs the repo's own apm. + +The apm that runs `apm audit --ci` must be at least as new as the newest apm that wrote `apm.lock.yaml`: it fails on lockfile fields it does not know, where plain `apm audit` only warns. + ## Frozen installs `apm install --frozen` fails instead of silently re-resolving if the lockfile is out of date — the CI equivalent of `npm ci` vs `npm install`. Use in any CI job that must not be allowed to drift the lockfile. diff --git a/plugins/kyberforge/.apm/skills/apm-workflow/references/compile.md b/plugins/kyberforge/.apm/skills/apm-workflow/references/compile.md index 8118d26..143bd5a 100644 --- a/plugins/kyberforge/.apm/skills/apm-workflow/references/compile.md +++ b/plugins/kyberforge/.apm/skills/apm-workflow/references/compile.md @@ -2,6 +2,7 @@ topic: compile source_keys: - context7-microsoft-apm + - apm-cli-0-39-3-experiments --- ## Compile @@ -12,7 +13,7 @@ apm compile --clean # zero-write sanity check; use for skill/agent-o apm compile --clean --dry-run # pure preview, no writes ``` -Compiles `.apm/instructions/` + `.apm/agents/*.agent.md` primitives into consumer-side context files (AGENTS.md/CLAUDE.md CONTEXT files) for the deployment target, per the `compilation:` block in `apm.yml`. This is the consumer/deployment side — it is NOT the producer of `plugin.json`/`marketplace.json`; that's `apm pack`'s job (below). Run `apm compile` after any change to `.apm/instructions/`/`.apm/agents/` content or to `compilation:`/`targets:` in `apm.yml`. To author an instructions file, use `instructions-author` — it covers which fields each target drops. `apm compile` never reads `.apm/prompts/`; to author a prompt file, use `prompt-author` — verification there is a throwaway `apm install`. +Compiles `.apm/instructions/` + `.apm/agents/*.agent.md` primitives into consumer-side context files (AGENTS.md/CLAUDE.md CONTEXT files) for the deployment target, per the `compilation:` block in `apm.yml`. For the `claude` target, apm 0.38 and later write the instructions into `AGENTS.md` and a `CLAUDE.md` that only imports it (`@AGENTS.md`). This is the consumer/deployment side — it is NOT the producer of `plugin.json`/`marketplace.json`; that's `apm pack`'s job (below). Run `apm compile` after any change to `.apm/instructions/`/`.apm/agents/` content or to `compilation:`/`targets:` in `apm.yml`. To author an instructions file, use `instructions-author` — it covers which fields each target drops. `apm compile` never reads `.apm/prompts/`; to author a prompt file, use `prompt-author` — verification there is a throwaway `apm install`. ## Pack @@ -63,5 +64,5 @@ Executes a named script defined under `scripts:` in `apm.yml`, with `--param` su ## Gotchas -- Plain `apm compile` HARD-FAILS with exit 1 and `No instruction files found in .apm/ directory` on any package that has skills/agents but no `.apm/instructions/` content — the common case for a skill-only or skill+agent package. Use `apm compile --clean` as the zero-write sanity-check substitute: it sets `allow_empty=True` internally and exits 0 cleanly with zero writes; add `--dry-run` for a pure preview. `compile` ≠ `pack` — see above. +- Plain `apm compile` HARD-FAILS with exit 1 and `No instruction files found in .apm/ directory` (re-run on apm 0.39.3) on any package that has skills/agents but no `.apm/instructions/` content — the common case for a skill-only or skill+agent package. Use `apm compile --clean` as the zero-write sanity-check substitute: it sets `allow_empty=True` internally and exits 0 cleanly with zero writes; add `--dry-run` for a pure preview. `compile` ≠ `pack` — see above. - `claude plugin validate --strict` auto-scans every `.md` file directly under a compiled plugin's `agents/` directory and treats it as an agent definition requiring frontmatter, independent of any manifest declaration (an empirically observed Claude Code platform behavior, not an `apm` mechanic). A non-agent `.md` file (notes, provenance record, README) that ends up under `.apm/agents/` in the source tree will still fail validation once compiled to the `claude` target. Keep such files outside `.apm/agents/` (e.g. at the package root), regardless of what `apm.yml` declares. diff --git a/plugins/kyberforge/.apm/skills/apm-workflow/references/configure.md b/plugins/kyberforge/.apm/skills/apm-workflow/references/configure.md index c8fd5a8..2a37378 100644 --- a/plugins/kyberforge/.apm/skills/apm-workflow/references/configure.md +++ b/plugins/kyberforge/.apm/skills/apm-workflow/references/configure.md @@ -2,6 +2,7 @@ topic: configure source_keys: - context7-microsoft-apm + - apm-v0-39-3-source --- ## Scaffolding a new package @@ -90,6 +91,6 @@ apm config set registry.corp-main.default true ## Gotchas -- `apm.yml`'s `type:` field validates nothing about `.apm/`. It selects processing: `instructions` compiles to AGENTS.md only, `skill` installs a native skill only, `prompts` emits commands only, `hybrid` does both (see `apm_cli/models/validation.py`, `PackageContentType`). apm checks only that the value parses to one of those four strings; no check anywhere compares it against the primitives actually on disk, and no mismatch diagnostic exists. A package declaring `type: instructions` while shipping `.apm/skills/` therefore raises no error — the mismatch resolves silently, either by omitting that primitive from the install/compile output or, in apm 0.28.0 where `get_effective_type()` routes off the on-disk layout and never reads the declared field, by ignoring the declared value outright. Both directions are silent: `apm install` and `apm compile` can exit 0 having shipped none of the primitives you expected. Set `type:` to cover every primitive the package ships, and confirm the deployed output rather than the exit code. +- `apm.yml`'s `type:` field validates nothing about `.apm/`. It selects processing: `instructions` compiles to AGENTS.md only, `skill` installs a native skill only, `prompts` emits commands only, `hybrid` does both (see `apm_cli/models/validation.py`, `PackageContentType`). apm checks only that the value parses to one of those four strings; no check anywhere compares it against the primitives actually on disk, and no mismatch diagnostic exists. A package declaring `type: instructions` while shipping `.apm/skills/` therefore raises no error — the mismatch resolves silently, either by omitting that primitive from the install/compile output or, in apm 0.28.0 and still in 0.39.3, where `get_effective_type()` routes off the detected package layout and never reads the declared field, by ignoring the declared value outright. Both directions are silent: `apm install` and `apm compile` can exit 0 having shipped none of the primitives you expected. Set `type:` to cover every primitive the package ships, and confirm the deployed output rather than the exit code. - `apm experimental enable registries` must run before any `registry.*` config takes effect. Declaring a `registries:` block or running `apm config set registry.*` without it silently does nothing — no error, no warning. - `apm plugin init ` run with a positional name argument, from inside a directory already named ``, creates a wrongly-nested `//` subdirectory — it treats the positional arg as "create a new project directory named X," not "confirm the current directory is X." Fix: omit the positional argument entirely when already cd'd into the target package directory — run `apm plugin init --yes --target claude,copilot` instead. diff --git a/plugins/kyberforge/.apm/skills/apm-workflow/references/marketplace.md b/plugins/kyberforge/.apm/skills/apm-workflow/references/marketplace.md index a14443a..a0cfbd2 100644 --- a/plugins/kyberforge/.apm/skills/apm-workflow/references/marketplace.md +++ b/plugins/kyberforge/.apm/skills/apm-workflow/references/marketplace.md @@ -5,6 +5,7 @@ source_keys: - context7-websites-code-claude - claude-code-plugins-docs - apm-github-repo + - apm-v0-39-3-source --- ## Building a marketplace from a producer repo @@ -114,6 +115,6 @@ hook. ## Gotchas - `apm marketplace add` and `apm marketplace package add` point in opposite directions and are easy to conflate: `add` registers someone else's catalog for you to *consume*; `package add` registers a package by remote reference (`owner/repo`, host URL, or full URL) into a marketplace you are *building*. `package add` does not accept a local path — register a local package by hand-editing `marketplace.packages[]`, as above. -- Only `claude` and `codex` marketplace output profiles exist in apm 0.28.0 — confirmed via source (`apm_cli/marketplace/output_profiles.py`: `MARKETPLACE_OUTPUTS = {claude: ..., codex: ...}`, nothing else). There is no native Copilot marketplace output; `apm pack` will not generate one. A repo needing a Copilot-consumable marketplace manifest must maintain it separately by other means. +- The marketplace output profiles depend on the apm version. apm 0.39.3 has three, `claude` (`.claude-plugin/marketplace.json`), `codex` (`.agents/plugins/marketplace.json`) and `copilot` (`.github/plugin/marketplace.json`), confirmed in `apm_cli/marketplace/output_profiles.py`. apm 0.28.0 had only `claude` and `codex`, so an older apm cannot emit a Copilot marketplace manifest. Add the output under `marketplace.outputs` only once every apm that packs the repo has it. - A package/plugin `name` compiling to the `claude` target must avoid Claude Code's reserved name prefixes/values — `anthropic-*`, `claude-*`, `agent-skills`, `official-claude-plugins` — otherwise the compiled `.claude-plugin/marketplace.json` is rejected by Claude Code's validator. This is a Claude Code platform constraint, independent of how the manifest gets authored. - Removing a package from `marketplace.packages[]` in `apm.yml` and re-packing changes the public/consumed catalog. Confirm with the user in conversation before removing the entry and running `apm pack` — this is a normal `apm.yml` edit (not a distinct apm-orchestrate operation with its own gate), so the confirmation is conversational, the same as any other consequential manifest edit. diff --git a/plugins/kyberforge/.apm/skills/apm-workflow/references/sources.md b/plugins/kyberforge/.apm/skills/apm-workflow/references/sources.md index 6d97c7b..af8b43b 100644 --- a/plugins/kyberforge/.apm/skills/apm-workflow/references/sources.md +++ b/plugins/kyberforge/.apm/skills/apm-workflow/references/sources.md @@ -11,7 +11,7 @@ ## apm-github-repo - **URL:** https://github.com/microsoft/apm -- **Description:** APM's own Python source (`src/apm_cli/`), read directly for schema and compile-mapping ground truth where Context7's doc snippets were thin. Backs the marketplace output-profile claim (`apm_cli/marketplace/output_profiles.py` — only `claude` and `codex` profiles exist, so there is no native Copilot marketplace output) and the `apm pack --check-clean`/`--check-versions` semantics. +- **Description:** APM's own Python source (`src/apm_cli/`), read directly for schema and compile-mapping ground truth where Context7's doc snippets were thin. Backs the `apm pack --check-clean`/`--check-versions` semantics, and the 0.28.0 marketplace output profiles (`claude` and `codex` only). - **Research doc:** plugins/kyberforge/docs/research/docs/microsoft-apm/sources.md - **Contributing files:** references/marketplace.md - **Status:** `extracted` @@ -39,3 +39,35 @@ - **Research doc:** plugins/kyberforge/docs/research/docs/claude-code-plugins/sources.md - **Contributing files:** (none) - **Status:** `referenced` + +## apm-v0-39-3-source + +- **URL:** https://github.com/microsoft/apm/tree/v0.39.3/src/apm_cli +- **Description:** apm source at tag v0.39.3, read from the pinned install: the three marketplace output profiles in `marketplace/output_profiles.py`, `get_effective_type()` in `integration/skill_package_routing.py` still routing off the detected package layout, and the `apm audit` exit codes. +- **Research doc:** plugins/kyberforge/docs/research/docs/microsoft-apm/sources.md (digest: plugins/kyberforge/docs/research/docs/microsoft-apm/cli-reference.md) +- **Contributing files:** references/marketplace.md, references/configure.md, references/audit.md +- **Status:** `extracted` + +## apm-v0-39-3-docs + +- **URL:** https://github.com/microsoft/apm/tree/v0.39.3/docs/src/content/docs +- **Description:** apm docs at tag v0.39.3: `apm audit --ci` refusing lockfile fields it does not know, so the auditing apm must be at least as new as the lock's writer. +- **Research doc:** plugins/kyberforge/docs/research/docs/microsoft-apm/sources.md (digest: plugins/kyberforge/docs/research/docs/microsoft-apm/lockfile-and-compatibility.md) +- **Contributing files:** references/audit.md +- **Status:** `extracted` + +## apm-cli-0-39-3-uv-experiments + +- **URL:** https://pypi.org/project/apm-cli/0.39.3/ +- **Description:** Throwaway uv projects pinning apm-cli 0.39.3. Grounds the pinned invocation `uv run --frozen apm` in `SKILL.md` Step 2 and in the CI note, and the need for one online `uv sync --frozen` per machine. +- **Research doc:** plugins/kyberforge/docs/research/docs/microsoft-apm/sources.md (digest: plugins/kyberforge/docs/research/docs/microsoft-apm/installation.md) +- **Contributing files:** SKILL.md, references/audit.md +- **Status:** `extracted` + +## apm-cli-0-39-3-experiments + +- **URL:** https://pypi.org/project/apm-cli/0.39.3/ +- **Description:** The repo-pinned apm-cli 0.39.3 run in throwaway packages outside the repo (holocron#273): the Claude compile writing a `CLAUDE.md` that imports `AGENTS.md`, and a skills-only package's plain compile still exiting 1 while `--clean` exits 0. +- **Research doc:** plugins/kyberforge/docs/research/docs/microsoft-apm/sources.md (digest: plugins/kyberforge/docs/research/docs/microsoft-apm/instructions-gotchas.md) +- **Contributing files:** references/compile.md +- **Status:** `extracted`