fix(kyberforge): apply the #273 review to the apm 0.39.3 refresh

- apm-workflow and apm-orchestrate always pass --project to uv run,
  because uv run outside the project silently runs the PATH apm. The
  agent now checks that the reported version equals the pin, or is
  0.39.2 or later where nothing pins it, not only that it exits 0.
- A pin is a quoted apm-cli or apm_cli requirement plus a uv.lock,
  matching the SessionStart hook, in apm-install, uv-pin.md and
  apm-workflow.
- uv-pin.md spells the hook's exact invocation and its environment
  check, and says scripts always pass --project.
- instructions-author and its research note: a Claude rule leaves
  .claude/rules/ only when compile actually wrote it into AGENTS.md;
  install-then-compile dedups it.
- prompt-author: Kiro strips every key with a warning, not silently.
- Record the 0.39.3 executables findings in approvals-and-executables.md
  and the output-profile and type-routing facts in cli-reference.md, and
  cite those digests.
- forge's routing table notes that Kiro gets the body only.

Refs: #273

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
Defame1297andClaude Opus 5.5 committed 2026-12-02 12:35:19 +00:00
1 parent c68b67301a
commit e6d680a4c5
14 files changed
+49 -26

No files matched your search

@@ -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 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.
**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 reports a usable version before dispatching any operation: `uv run --project <repo root> --frozen apm --version` in a repo that pins apm with uv, `apm --version` otherwise (`apm-workflow` Step 2 says how to tell). Always pass `--project`: `uv run` outside the project silently falls back to the `PATH` apm. Exit 0 is not enough. The version must equal the repo's pin, or be 0.39.2 or later where nothing pins it, because an older apm refuses a v4 lockfile. If the check 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 the repo's apm answers `--version` (pinned: `uv run --frozen apm --version`); if not, fail with a diagnostic pointing to `apm-install`
4. Verify the repo's apm version (pinned: `uv run --project <repo root> --frozen apm --version`, which must equal the pin; otherwise `apm --version`, which must be 0.39.2 or later); 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
@@ -24,7 +24,7 @@ metadata:
| Condition | Method | Where |
|---|---|---|
| The repo pins apm: `pyproject.toml` names `apm-cli` in a dependency group, beside a `uv.lock` | Per-repo pin. Use or upgrade it, never the global apm | `references/uv-pin.md` |
| The repo pins apm: `pyproject.toml` has a quoted `apm-cli` or `apm_cli` requirement, beside a `uv.lock` | Per-repo pin. Use or upgrade it, never the global apm | `references/uv-pin.md` |
| The user wants apm fixed per repo, and uv is available | Per-repo pin. Set it up | `references/uv-pin.md` |
| Anything else: a machine-wide apm, a CI image, no uv | Global install | Step 2 |
@@ -60,7 +60,7 @@ Default:
apm runtime setup copilot
```
Other targets: `apm runtime setup codex`, `apm runtime setup gemini`, `apm runtime setup llm`. In a repo that pins apm, spell each of these as `uv run --frozen apm runtime …`.
Other targets: `apm runtime setup codex`, `apm runtime setup gemini`, `apm runtime setup llm`. In a repo that pins apm, spell each of these as `uv run --project <repo root> --frozen apm runtime …`.
- `apm runtime list` — show installed runtimes.
- `apm runtime status` — show which runtime `apm run` will pick by default.
@@ -41,21 +41,22 @@ this method. It was tested with uv 0.11.24 and apm-cli 0.39.3.
apm-cli and every transitive dependency.
3. On each checkout, run `uv sync --frozen` once. The first sync on a machine needs the network,
because a cold uv cache cannot download wheels offline.
4. Run `uv run --frozen apm install`. The first install with apm 0.39 or later also needs the
4. Run `uv run --project . --frozen apm install` from the repo root. The first install with apm 0.39 or later also needs the
network once, to record commit verdicts.
5. Check the version with `uv run --frozen apm --version`.
5. Check the version with `uv run --project . --frozen apm --version`.
## Run it
- Spell every apm command in the repo as `uv run --frozen apm <args>`. `--frozen` runs from
- Spell every apm command in the repo as `uv run --project <repo root> --frozen apm <args>`. `--frozen` runs from
`uv.lock` as committed and never re-resolves it. It still syncs the environment to the lock
first. After the one-time sync that costs nothing, and when a pull moves the pin it brings the
environment up to the new version.
- In a script that may run from a subdirectory, add `--project <repo root>`.
- Offline, `uv run --frozen --offline apm …` works once the uv cache is warm, even with no
- Scripts always pass `--project <repo root>`. Without it, `uv run` from a directory outside the repo finds no project and silently runs the `PATH` apm. The same happens under a nested `pyproject.toml`.
- Offline, `uv run --project <repo root> --frozen --offline apm …` works once the uv cache is warm, even with no
`.venv`. With a cold cache it fails.
- A hook with a short timeout must never sync. Use `--no-sync --offline`, and check first that
`.venv` exists, because even `--no-sync` creates an empty one.
- A hook with a short timeout must never sync. kyberforge's SessionStart hook runs
`uv run --project <root> --frozen --no-sync --offline apm`, after checking that
`${UV_PROJECT_ENVIRONMENT:-<root>/.venv}` exists, because even `--no-sync` creates an empty one.
## Upgrade the pin
@@ -79,10 +80,11 @@ uv installs the apm tool and nothing else. Packages, skills and agents still com
**Repo A pins apm.** The user asks to install the repo's apm dependencies. The root
`pyproject.toml` has `dev = ["apm-cli==0.39.3"]`, and `uv.lock` sits beside it.
1. Detect the pin: `grep -q '"apm-cli' pyproject.toml && test -f uv.lock`.
1. Detect the pin: a quoted `apm-cli` or `apm_cli` requirement in `pyproject.toml`, and a `uv.lock` beside it:
`grep -Eq "[\"']apm[-_]cli" pyproject.toml && test -f uv.lock`.
2. Run `uv sync --frozen`, the first time on this checkout.
3. Run `uv run --frozen apm --version`. It prints 0.39.3.
4. Run `uv run --frozen apm install`.
3. Run `uv run --project . --frozen apm --version`. It prints 0.39.3.
4. Run `uv run --project . --frozen apm install`.
Wrong moves: a bare `apm install`, because the `PATH` apm may be 0.28.0, which refuses the v4 lock.
`pipx upgrade apm-cli`, because that changes every repo on the machine. `uvx apm-cli@0.39.3
@@ -16,6 +16,7 @@ metadata:
- MCP server secrets in `apm.yml` (headers, env vars) must use `${VAR}` indirection, never literal values, so they resolve at install or runtime and are never committed.
- `apm experimental enable registries` must run before a `registries:` block or `registry.*` config takes effect anywhere — configure, install or publish. Without it, declaring one silently does nothing: no error, no warning.
- `uv run` outside the uv project silently runs the `PATH` apm instead: from outside the repo it reported 0.28.0 where the repo pinned 0.39.3. Hence `--project` in Step 2.
- `apm.yml`'s `type:` selects which primitives are processed and is never checked against what `.apm/` holds, so `apm install` and `apm compile` can exit 0 having shipped none of the ones you expected. Set it to cover every primitive the package ships, and confirm the deployed output, not the exit code. Mechanics: `references/configure.md`.
## Step 1 — Dispatch
@@ -32,9 +33,9 @@ Read the reference file matching the resolved flow — it carries that flow's ow
## Step 2 — Choose the apm command
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.
The references spell every command as bare `apm`. Before running one, check whether the repo pins apm: a `pyproject.toml` at the repo root carrying a quoted `apm-cli` or `apm_cli` requirement, with a `uv.lock` beside it.
- **Pinned:** run each command as `uv run --frozen apm <args>`, adding `--project <repo root>` 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.
- **Pinned:** run each command as `uv run --project <repo root> --frozen apm <args>`. 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`.
@@ -49,7 +49,7 @@ jobs:
`-f sarif --output <file>` 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.
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 --project . --frozen apm …` from the checkout root, 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.
@@ -59,7 +59,7 @@
## 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.
- **Description:** Throwaway uv projects pinning apm-cli 0.39.3. Grounds the pinned invocation `uv run --project <repo root> --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`
@@ -37,7 +37,7 @@ place only where its single-file, multi-target shape is the point.
| The content is | Route |
|---|---|
| A single-file command that should also reach Copilot, Cursor, Gemini or OpenCode | Prompt file (`prompt-author`) |
| A single-file command that should also reach Copilot, Cursor, Gemini or OpenCode (Kiro gets the body only) | Prompt file (`prompt-author`) |
| A command that needs `references/` or `scripts/`, or that other skills or the model must be able to call | Skill (`skill-author`), declared hand-invoked |
| A Claude-only command with no such need | Skill (`skill-author`), because the vendor steers new commands there |
@@ -21,7 +21,7 @@ metadata:
- Claude Code drops `description`; only Copilot, grok-build and Cursor keep it. Write a body that explains itself.
- Quote every `applyTo`. An unquoted `**/*.py` is a YAML alias error: `apm install` exits 1 and deploys nothing, while `apm compile` drops the file and still exits 0.
- On Claude a rule can leave `.claude/rules/`: after a compile, unscoped and single-directory rules move into `AGENTS.md`, which `CLAUDE.md` imports. Where a rule loads from is in `references/target-mapping.md`.
- On Claude a rule leaves `.claude/rules/` only once a compile has actually written it into `AGENTS.md`, which `CLAUDE.md` imports. Install-then-compile dedups it, so it stays. Where a rule loads from is in `references/target-mapping.md`.
## Step 1 — Dispatch
@@ -36,9 +36,9 @@ At user scope Cursor, Windsurf and Antigravity do not deploy, and Kiro and the r
apm 0.38 and later split Claude's instructions between the two.
- Install deploys every instruction to `.claude/rules/` first.
- Compile writes the bodies into `AGENTS.md` and a `CLAUDE.md` that holds only `@AGENTS.md`.
- Once a compiled `AGENTS.md` carries an unscoped rule, the next install deletes its `.claude/rules/` copy ("Retired ... AGENTS.md now carries it"). The source also routes a rule scoped to `**`, `**/*` or exactly one literal `dir/**` this way. File-type globs such as `**/*.py`, wildcard directories and lists stay in `.claude/rules/`.
- Install deploys each instruction to `.claude/rules/`, unless a compiled `AGENTS.md` already carries it.
- Compile writes the bodies into `AGENTS.md` and a `CLAUDE.md` that holds only `@AGENTS.md`, leaving out any instruction already in `.claude/rules/`.
- A rule moves out of `.claude/rules/` only when compile actually wrote it into `AGENTS.md`: compile ran before install, `--force-instructions` was passed, or the compile also served a target with no dedup. The next install then deletes the `.claude/rules/` copy ("Retired ... AGENTS.md now carries it"). Install-then-compile dedups every deployed rule, so they all stay in `.claude/rules/`, and compile-then-install never deploys the unscoped rule there. The source also routes a rule scoped to `**`, `**/*` or exactly one literal `dir/**` this way. File-type globs such as `**/*.py`, wildcard directories and lists stay in `.claude/rules/`.
- From the source, not run: these keep every instruction in `.claude/rules/`, with a warning: a hand-authored root `CLAUDE.md` without an `@AGENTS.md` import; a hand-authored root `AGENTS.md` without `compilation.agents_md.mode: managed_section` and one pair of `<!-- apm:start -->`/`<!-- apm:end -->` markers; a symlinked `AGENTS.md`. Compile never overwrites a hand-authored root file. User scope never routes to `AGENTS.md`.
## Field survival
@@ -22,7 +22,7 @@ metadata:
## Gotchas
- `apm compile` never reads prompt files, and `--validate` ignores them even when malformed. A prompt file is verified only by a throwaway `apm install`.
- Unsupported frontmatter keys are dropped without a word: the Claude family names them only under `apm install --verbose`, Gemini keeps only `description`, and Kiro keeps no frontmatter. Codex and Antigravity deploy nothing and print nothing.
- Unsupported frontmatter keys are dropped quietly: the Claude family names them only under `apm install --verbose`, and Gemini keeps only `description` and says nothing. Kiro strips every key, with a warning naming them. Codex and Antigravity deploy nothing and print nothing.
- `input:` descriptions are discarded: only the names survive, as `arguments:`. Duplicate names are not caught.
## Step 1 — Dispatch