Compare commits
51
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db34dfa728 | ||
|
|
66443e7458 | ||
|
|
b80c26e064 | ||
|
|
386ab7ec5d | ||
|
|
01fe1fb767 | ||
|
|
7e63f22bf8 | ||
|
|
c2ba7f01bf | ||
|
|
126831e96f | ||
|
|
b0977d4073 | ||
|
|
045e43f0f8 | ||
|
|
5089856c0d | ||
|
|
0696ce31e7 | ||
|
|
dca0b5823b | ||
|
|
615d3dd881 | ||
|
|
a48f0fdf5b | ||
|
|
e87bd67c1f | ||
|
|
5842be70cc | ||
|
|
7291b46271 | ||
|
|
d15688ee99 | ||
|
|
e1a99a7291 | ||
|
|
feef6d8307 | ||
|
|
45d740eef1 | ||
|
|
367cc1c259 | ||
|
|
1fb8cc797b | ||
|
|
0ad15c80bc | ||
|
|
5ca2056046 | ||
|
|
a0997cbcf7 | ||
|
|
e17237a9e2 | ||
|
|
389b5cc425 | ||
|
|
276fd1f099 | ||
|
|
b4a452b690 | ||
|
|
0abe97270b | ||
|
|
1e1c2c1ce2 | ||
|
|
3b0dcc32d4 | ||
|
|
c4bee9e3b9 | ||
|
|
fe0e297f98 | ||
|
|
99054c8cd2 | ||
|
|
6638385a51 | ||
|
|
bc04eaaed5 | ||
|
|
0d99a41a57 | ||
|
|
bfe096b64d | ||
|
|
43a42ce9f6 | ||
|
|
3414c039a8 | ||
|
|
219a084c25 | ||
|
|
e31e8686b9 | ||
|
|
cf875e6e1a | ||
|
|
b7747d27b6 | ||
|
|
b98340d432 | ||
|
|
1a887a750e | ||
|
|
1a2b63e2cb | ||
|
|
ffaf1678da |
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "holocron",
|
"name": "holocron",
|
||||||
"description": "AI development skills for Claude Code, and for GitHub Copilot through apm — factory, design, implement, review, and cross-cutting workflows.",
|
"description": "AI development skills for Claude Code, and for GitHub Copilot through apm — factory, design, implement, review, and cross-cutting workflows.",
|
||||||
"version": "0.9.0",
|
"version": "0.9.1",
|
||||||
"owner": {
|
"owner": {
|
||||||
"name": "Mortis",
|
"name": "Mortis",
|
||||||
"url": "https://git.rkdr.net/Mortis/"
|
"url": "https://git.rkdr.net/Mortis/"
|
||||||
@@ -10,14 +10,14 @@
|
|||||||
{
|
{
|
||||||
"name": "kyberforge",
|
"name": "kyberforge",
|
||||||
"description": "Skills and agents for creating, maintaining, and managing an apm plugin marketplace for Claude Code and GitHub Copilot.",
|
"description": "Skills and agents for creating, maintaining, and managing an apm plugin marketplace for Claude Code and GitHub Copilot.",
|
||||||
"version": "2.2.1",
|
"version": "2.3.0",
|
||||||
"category": "Developer Tools",
|
"category": "Developer Tools",
|
||||||
"source": "./plugins/kyberforge"
|
"source": "./plugins/kyberforge"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "bin",
|
"name": "bin",
|
||||||
"description": "Skills for everyday AI-assisted development work that is not tied to a single tool, forge or language, and has not yet been split into a focused plugin.",
|
"description": "Skills for everyday AI-assisted development work that is not tied to a single tool, forge or language, and has not yet been split into a focused plugin.",
|
||||||
"version": "4.0.0",
|
"version": "5.0.0",
|
||||||
"category": "Utilities",
|
"category": "Utilities",
|
||||||
"source": "./plugins/bin"
|
"source": "./plugins/bin"
|
||||||
},
|
},
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
{
|
{
|
||||||
"name": "plan",
|
"name": "plan",
|
||||||
"description": "Turning a ticket or idea into a validated, researched spec and agent-ready tickets, with the user in the loop; temporarily also ships /ship to execute a plan.",
|
"description": "Turning a ticket or idea into a validated, researched spec and agent-ready tickets, with the user in the loop; temporarily also ships /ship to execute a plan.",
|
||||||
"version": "0.3.0",
|
"version": "0.5.0",
|
||||||
"category": "Productivity",
|
"category": "Productivity",
|
||||||
"source": "./plugins/plan"
|
"source": "./plugins/plan"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
{
|
{
|
||||||
"type": "command",
|
"type": "command",
|
||||||
"command": "\"${CLAUDE_PROJECT_DIR}/.claude/hooks/kyberforge/.apm/hooks/check-apm-current.sh\"",
|
"command": "\"${CLAUDE_PROJECT_DIR}/.claude/hooks/kyberforge/.apm/hooks/check-apm-current.sh\"",
|
||||||
"timeout": 380
|
"timeout": 400
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_apm_source": "Mortis/Holocron/plugins/kyberforge"
|
"_apm_source": "Mortis/Holocron/plugins/kyberforge"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
{
|
{
|
||||||
"type": "command",
|
"type": "command",
|
||||||
"command": "\"${CLAUDE_PROJECT_DIR}/.claude/hooks/kyberforge/.apm/hooks/check-apm-current.sh\"",
|
"command": "\"${CLAUDE_PROJECT_DIR}/.claude/hooks/kyberforge/.apm/hooks/check-apm-current.sh\"",
|
||||||
"timeout": 380
|
"timeout": 400
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-3
@@ -48,16 +48,16 @@ apm_modules/
|
|||||||
.claude/hooks/
|
.claude/hooks/
|
||||||
|
|
||||||
# `apm pack` bundle output. The pre-push gate runs pack with --dry-run, so this
|
# `apm pack` bundle output. The pre-push gate runs pack with --dry-run, so this
|
||||||
# only appears after a bare `apm pack` during a release; it is not repo content.
|
# only appears after a non-dry-run `apm pack` during a release; it is not repo content.
|
||||||
build/
|
build/
|
||||||
|
|
||||||
# `apm pack`'s manifest for the *root* package. Emitted beside the marketplace
|
# `apm pack`'s manifest for the *root* package. Emitted beside the marketplace
|
||||||
# manifest by a bare `apm pack`, and never tracked on any branch — the repo's
|
# manifest by `apm pack` run with no flags, and never tracked on any branch — the repo's
|
||||||
# own paths hide it, since the apm-pack-check-clean pre-push hook, the only
|
# own paths hide it, since the apm-pack-check-clean pre-push hook, the only
|
||||||
# thing that runs pack here, passes --dry-run. It is NOT write-only output:
|
# thing that runs pack here, passes --dry-run. It is NOT write-only output:
|
||||||
# pack reads an existing copy back in preference to apm.yml and only rewrites
|
# pack reads an existing copy back in preference to apm.yml and only rewrites
|
||||||
# it with --force, so a stale copy leaks an old version and config into every
|
# it with --force, so a stale copy leaks an old version and config into every
|
||||||
# bundle. Pack releases with `apm pack --force`, or delete this file first. Scoped
|
# bundle. Pack releases with `uv run --frozen apm pack --force`, or delete this file first. Scoped
|
||||||
# to the file, not the directory: the sibling .claude-plugin/marketplace.json is
|
# to the file, not the directory: the sibling .claude-plugin/marketplace.json is
|
||||||
# compiled output that IS committed and must stay tracked.
|
# compiled output that IS committed and must stay tracked.
|
||||||
/.claude-plugin/plugin.json
|
/.claude-plugin/plugin.json
|
||||||
@@ -66,3 +66,7 @@ build/
|
|||||||
# apm copies the whole hooks directory, so a stray cache would deploy with it.
|
# apm copies the whole hooks directory, so a stray cache would deploy with it.
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|
||||||
|
# uv's project environment for the repo-pinned apm (ADR-0034). Created by
|
||||||
|
# `uv sync --frozen` from the committed uv.lock; machine-local, never content.
|
||||||
|
.venv/
|
||||||
+31
-21
@@ -71,7 +71,7 @@ repos:
|
|||||||
|
|
||||||
- id: check-executables-allow-sync
|
- id: check-executables-allow-sync
|
||||||
name: Check executables allow keys sync
|
name: Check executables allow keys sync
|
||||||
description: Verify root apm.yml's executables.allow carries a "<name>#<version>" key matching the apm.yml version of every plugin that ships executables (plugins/<name>/.apm/hooks/ or bin/), reporting every out-of-sync package in one run. apm's grant is version-blind, so a stale key still deploys; this is a record-keeping gate that fails a version bump made without the matching key edit, keeping each key an accurate record of what was approved (see ADR-0019's 2026-09-19 correction and docs/spec/gates.md)
|
description: Verify root apm.yml's executables.allow carries a "<host>/<owner>/<repo>/plugins/<name>#<version>" key -- the full package identity apm 0.39 matches on, derived from root apm.yml's git+path dependency entry for the plugin, plus the plugin's apm.yml version -- for every plugin that ships executables (plugins/<name>/.apm/hooks/ or bin/), reporting every out-of-sync package in one run. A bare "<name>#<version>" key fails, because apm 0.39 parks the hooks under it while root `apm audit --ci` stays green (spike #269). The version half is version-blind to apm, so a stale version still deploys; that half is a record-keeping gate that fails a version bump made without the matching key edit (see ADR-0019's 2026-09-19 correction and docs/spec/gates.md). It also fails when apm.lock.yaml records any gated_* exec_status, a parked executable that root `apm audit --ci` lets through
|
||||||
entry: bash scripts/check-executables-allow-sync.sh
|
entry: bash scripts/check-executables-allow-sync.sh
|
||||||
language: system
|
language: system
|
||||||
stages: [pre-push]
|
stages: [pre-push]
|
||||||
@@ -80,41 +80,48 @@ repos:
|
|||||||
|
|
||||||
- id: apm-audit-ci
|
- id: apm-audit-ci
|
||||||
name: apm audit --ci
|
name: apm audit --ci
|
||||||
description: Run apm's producer-side CI gate over the root manifest AND each plugin package, via scripts/apm-audit-ci.sh. On the root manifest it runs ten checks -- lockfile-exists, ref-consistency, deployment-ledger-owners, deployed-files-present, no-orphaned-packages, skill-subset-consistency, config-consistency, content-integrity, includes-consent, drift -- so it is both a hidden-Unicode scan and a drift gate that replays the install and diffs it. In a plugin package it runs one, lockfile-exists, which the script waives when that package declares dependencies, because a package is not an install root (ADR-0026). The waiver never applies to the root and never covers a second failing check. It does NOT enforce an org policy; see the comment below for why. Reference:plugins/kyberforge/.apm/skills/apm-workflow/references/audit.md
|
description: Run apm's producer-side CI gate over the root manifest AND each plugin package, via scripts/apm-audit-ci.sh. On the root manifest apm 0.39.3 runs fifteen checks -- lockfile-exists, ref-consistency, deployment-ledger-owners, deployed-files-present, no-orphaned-packages, lockfile-targets-current, skill-subset-consistency, config-consistency, native-mcp-ownership, content-integrity, local-bundle-hooks, hook-approval-pins, exec-status-current, includes-consent, drift -- so it is both a hidden-Unicode scan and a drift gate that replays the install and diffs it. In a plugin package it runs two, lockfile-exists and a content-integrity row that scans no package source; the script waives lockfile-exists when that package declares dependencies, because a package is not an install root (ADR-0026). The waiver never applies to the root and never covers a second failing check. It does NOT enforce an org policy; see the comment below for why. Reference:plugins/kyberforge/.apm/skills/apm-workflow/references/audit.md
|
||||||
entry: scripts/apm-audit-ci.sh
|
entry: scripts/apm-audit-ci.sh
|
||||||
language: system
|
language: system
|
||||||
stages: [pre-push]
|
stages: [pre-push]
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
always_run: true
|
always_run: true
|
||||||
# What this hook actually runs, read off apm 0.28.0's own compliance
|
# What this hook actually runs, read off apm 0.39.3's own compliance
|
||||||
# table by invoking `apm audit --ci` at the repo root and in
|
# table by invoking `apm audit --ci` at the repo root and in
|
||||||
# plugins/lint/. Long form in docs/spec/gates.md, "apm-audit-ci".
|
# plugins/lint/ (holocron#272; first done on 0.28.0, which ran ten
|
||||||
|
# root checks and one plugin check). Long form in docs/spec/gates.md,
|
||||||
|
# "apm-audit-ci".
|
||||||
#
|
#
|
||||||
# * ROOT MANIFEST -- ten checks: lockfile-exists, ref-consistency,
|
# * ROOT MANIFEST -- fifteen checks: lockfile-exists, ref-consistency,
|
||||||
# deployment-ledger-owners, deployed-files-present,
|
# deployment-ledger-owners, deployed-files-present,
|
||||||
# no-orphaned-packages, skill-subset-consistency, config-consistency,
|
# no-orphaned-packages, lockfile-targets-current,
|
||||||
# content-integrity, includes-consent, drift. It is a drift gate: it
|
# skill-subset-consistency, config-consistency, native-mcp-ownership,
|
||||||
|
# content-integrity, local-bundle-hooks, hook-approval-pins,
|
||||||
|
# exec-status-current, includes-consent, drift. It is a drift gate: it
|
||||||
# replays the install cache-only and diffs the scratch result against
|
# replays the install cache-only and diffs the scratch result against
|
||||||
# the working tree. Root lockfile-exists is not vacuous -- the root
|
# the working tree. Root lockfile-exists is not vacuous -- the root
|
||||||
# declares dependencies, so it reports `Lockfile present`.
|
# declares dependencies, so it reports `Lockfile present`.
|
||||||
# * PLUGIN MANIFESTS -- one check: lockfile-exists. Conditional, and
|
# * PLUGIN MANIFESTS -- two checks: lockfile-exists, and a
|
||||||
|
# content-integrity row that scans no package source (it passed with
|
||||||
|
# a planted bidi override). lockfile-exists is conditional, and
|
||||||
# vacuous while every plugin apm.yml declares
|
# vacuous while every plugin apm.yml declares
|
||||||
# `dependencies: {apm: [], mcp: []}`: it reports `No dependencies
|
# `dependencies: {apm: [], mcp: []}`: it reports `No dependencies
|
||||||
# declared -- lockfile not required` and arms itself the moment one
|
# declared -- lockfile not required` and arms itself the moment one
|
||||||
# does not (verified by adding a git dependency to
|
# does not (verified by adding a git dependency to
|
||||||
# plugins/lint/apm.yml). Everything else above is root-only, because
|
# plugins/lint/apm.yml). Everything else in the root list is
|
||||||
|
# root-only, because
|
||||||
# only the root install has a lockfile, a deployment ledger and
|
# only the root install has a lockfile, a deployment ledger and
|
||||||
# deployed files to check. Running every plugin package is what
|
# deployed files to check. Running every plugin package is what
|
||||||
# makes lockfile-exists reachable for them at all -- the root-only
|
# makes lockfile-exists reachable for them at all -- the root-only
|
||||||
# invocation audits the root manifest and nothing else.
|
# invocation audits the root manifest and nothing else.
|
||||||
# THAT ARMING NOW HAPPENS: plugins/mattpocock declares real dependencies,
|
# THAT ARMING NOW HAPPENS: plugins/mattpocock declares real dependencies,
|
||||||
# and there is no green state for it -- without a package lockfile
|
# and there is no green state for it -- without a package lockfile
|
||||||
# lockfile-exists fails, and with one it passes and arms the other
|
# lockfile-exists fails, and with one it passes and arms the rest of
|
||||||
# nine, where drift then demands the dependency's skills be deployed
|
# the root set, where drift then demands the dependency's skills be deployed
|
||||||
# INSIDE the package. A package is not an install root, so
|
# INSIDE the package. A package is not an install root, so
|
||||||
# scripts/apm-audit-ci.sh waives that single check for a package and
|
# scripts/apm-audit-ci.sh waives that single check for a package and
|
||||||
# nothing else (ADR-0026). Dropping --ci for packages would have been
|
# nothing else (ADR-0026). Dropping --ci for packages would have been
|
||||||
# smaller and is wrong: verified on apm 0.28.0, plain `apm audit`
|
# smaller and is wrong: verified on apm 0.28.0 and 0.39.3, plain `apm audit`
|
||||||
# exits 0 on a dependency entry missing its git/path/registry field
|
# exits 0 on a dependency entry missing its git/path/registry field
|
||||||
# while --ci exits 1 naming it, and malformed-dependency detection is
|
# while --ci exits 1 naming it, and malformed-dependency detection is
|
||||||
# the whole reason packages are audited.
|
# the whole reason packages are audited.
|
||||||
@@ -125,13 +132,14 @@ repos:
|
|||||||
# check. Both claims were wrong. What is true is that the STANDALONE
|
# check. Both claims were wrong. What is true is that the STANDALONE
|
||||||
# mode differs: plain `apm audit` (--ci refuses to combine with
|
# mode differs: plain `apm audit` (--ci refuses to combine with
|
||||||
# --file/--strip/--dry-run/PACKAGE) run in a plugin directory reports
|
# --file/--strip/--dry-run/PACKAGE) run in a plugin directory reports
|
||||||
# `No apm.lock.yaml found -- nothing to scan` and exits 0, because
|
# `No recognized deployed primitives found -- nothing to scan` on
|
||||||
# only the root has a lockfile.
|
# 0.39.3 (`No apm.lock.yaml found -- nothing to scan` on 0.28.0) and
|
||||||
# * MANIFEST-PARSE IS NOT A CHECK in apm 0.28.0's table, and an earlier
|
# exits 0, because only the root has a lockfile.
|
||||||
# revision of this comment named it as one. Parsing is still
|
# * MANIFEST-PARSE IS A ROW ON 0.39.3, not on 0.28.0. A dependency entry
|
||||||
# enforced -- a dependency entry missing its git/path/registry field
|
# missing its git/path/registry field now yields a one-row table with
|
||||||
# fails with `Cannot parse apm.yml` -- but it fails the invocation
|
# a failing manifest-parse row (`Cannot parse apm.yml: ...`); 0.28.0
|
||||||
# before the table is built, so it never appears as a row.
|
# failed the invocation before building the table. A parsable
|
||||||
|
# manifest gets no such row.
|
||||||
# * POLICY IS NOT ENFORCED. `apm audit --ci` discovers an org policy
|
# * POLICY IS NOT ENFORCED. `apm audit --ci` discovers an org policy
|
||||||
# from the git remote, and apm's discovery only understands
|
# from the git remote, and apm's discovery only understands
|
||||||
# github.com and Azure DevOps. This repo's remote is a self-hosted
|
# github.com and Azure DevOps. This repo's remote is a self-hosted
|
||||||
@@ -146,8 +154,10 @@ repos:
|
|||||||
# serve one. A gate that can never go green is not a gate. Revisit if
|
# serve one. A gate that can never go green is not a gate. Revisit if
|
||||||
# this repo ever gains a policy source apm can actually reach.
|
# this repo ever gains a policy source apm can actually reach.
|
||||||
#
|
#
|
||||||
# Costs ~0.5s per package. Needs no network ONCE `apm install` has
|
# Takes 70-90 s for the root plus every plugin through `uv run` on
|
||||||
# populated apm_modules/ -- the root marketplace has no remote package
|
# apm 0.39.3 (about 0.5 s per package on 0.28.0). Needs no network ONCE
|
||||||
|
# `uv sync --frozen` and `uv run --frozen apm install` have each run
|
||||||
|
# once -- the root marketplace has no remote package
|
||||||
# entries, so the install replay is cache-only. On a FRESH CLONE there
|
# entries, so the install replay is cache-only. On a FRESH CLONE there
|
||||||
# is no cache: deployed-files-present fails outright, and drift and
|
# is no cache: deployed-files-present fails outright, and drift and
|
||||||
# config-consistency clone from the holocron remote. See README.md's
|
# config-consistency clone from the holocron remote. See README.md's
|
||||||
|
|||||||
@@ -28,9 +28,10 @@ Fall back to raw shell only when no skill covers it.
|
|||||||
## Session rules
|
## Session rules
|
||||||
|
|
||||||
- **Do not add repo-owned keys to `.claude/settings.json`.** apm treats it as its own deployed artifact and `apm audit --ci` replays the install and diffs, so anything apm would not have written is permanent drift that fails the `apm-audit-ci` pre-push hook. A hook you want here is authored in `plugins/<name>/.apm/hooks/` and deployed by apm, never hand-written into that file. The `SessionStart` entry already in it is exactly that: kyberforge authors it in `plugins/kyberforge/.apm/hooks/hooks.json` and apm merges it in, so it is apm's own output, it is what the replay expects, and it belongs in the commit — do not strip it (ADR-0019). Machine-specific settings go in the gitignored `.claude/settings.local.json`; shared enforcement goes in `.pre-commit-config.yaml`.
|
- **Do not add repo-owned keys to `.claude/settings.json`.** apm treats it as its own deployed artifact and `apm audit --ci` replays the install and diffs, so anything apm would not have written is permanent drift that fails the `apm-audit-ci` pre-push hook. A hook you want here is authored in `plugins/<name>/.apm/hooks/` and deployed by apm, never hand-written into that file. The `SessionStart` entry already in it is exactly that: kyberforge authors it in `plugins/kyberforge/.apm/hooks/hooks.json` and apm merges it in, so it is apm's own output, it is what the replay expects, and it belongs in the commit — do not strip it (ADR-0019). Machine-specific settings go in the gitignored `.claude/settings.local.json`; shared enforcement goes in `.pre-commit-config.yaml`.
|
||||||
- **`apm.lock.yaml` turning up modified is expected, not a bug.** kyberforge's `SessionStart` hook keeps the install current on launch and rewrites the lock in the process (ADR-0019). On `main`, commit or discard it deliberately. On a feature branch, discard it (`git checkout -- apm.lock.yaml`, then `apm install`). This keeps unrelated lock churn out of the branch diff and keeps `apm pack --check-clean` consistent with the committed lock. The session then runs the older `main` that the lock records, which is accepted on a branch, and the next session start refreshes again.
|
- **Run apm only as `uv run --frozen apm …`.** The root `pyproject.toml` and `uv.lock` pin apm 0.39.3 (ADR-0034). A bare `apm` reaches whatever is on `PATH`, possibly an older apm that refuses the v4 `apm.lock.yaml`.
|
||||||
- **A `.apm/` edit is not live until it is on the remote's `main`.** Root `apm.yml`'s first-party dependencies resolve from the holocron remote, unpinned against the default branch, so pushing a feature branch does not deploy it (ADR-0019). `apm install` deploys from the lock; `apm update` is what re-resolves refs.
|
- **`apm.lock.yaml` turning up modified is expected, not a bug.** kyberforge's `SessionStart` hook keeps the install current on launch: it runs `uv run --frozen apm update --yes` and rewrites the lock in the process (ADR-0019). On `main`, commit or discard it deliberately. On a feature branch, discard it (`git checkout -- apm.lock.yaml`, then `uv run --frozen apm install`). This keeps unrelated lock churn out of the branch diff and keeps `apm pack --check-clean` consistent with the committed lock. The session then runs the older `main` that the lock records, which is accepted on a branch, and the next session start refreshes again. A checkout that apm 0.28 deployed or populated needs one-time migration steps, and its first session-start rewrite of the lock can be wrong: see `docs/spec/gates.md`, "apm-audit-ci".
|
||||||
- **No pre-push hook needs the network — once `apm install` has run.** Root `apm.yml`'s marketplace has no remote package entries, so every hook resolves locally. The guarantee is a property of a populated `apm_modules/`, not of the hook set: on a fresh clone `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` install-replays have no cache to replay from and clone from the remote. Run `apm install` once on a new checkout and the offline guarantee holds from then on (`docs/spec/gates.md`, "Pushing without a network").
|
- **A `.apm/` edit is not live until it is on the remote's `main`.** Root `apm.yml`'s first-party dependencies resolve from the holocron remote, unpinned against the default branch, so pushing a feature branch does not deploy it (ADR-0019). `uv run --frozen apm install` deploys from the lock; `uv run --frozen apm update` is what re-resolves refs.
|
||||||
|
- **No pre-push hook needs the network — once the two one-time online steps have run.** A new checkout runs `uv sync --frozen`, then `uv run --frozen apm install`, each online once. Root `apm.yml`'s marketplace has no remote package entries, so every hook then resolves locally. The guarantee is a property of a synced `.venv/` and a populated `apm_modules/`, not of the hook set: on a fresh clone `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` install-replays have no cache to replay from and clone from the remote. (`docs/spec/gates.md`, "Pushing without a network").
|
||||||
- **A plugin `version:` bump that has merged to `main` gets its release tag.** Run `git fetch origin --tags`, then `scripts/tag-plugin-releases.sh`; exit 1 means a tag is missing, and `--apply` creates it locally and prints the push command. The script reads local tags only, so OK means present locally, not published: confirm with `git ls-remote --tags origin '<plugin>-v*'` before calling it done. A tag push is an irreversible publish, not a free Propose-tier push (ADR-0032): show the maintainer the exact tags and that command, and only on their explicit yes in this conversation run exactly it yourself (named tags, never `--tags` or other refs). Agents cut release tags only with the script, which never moves or deletes one; exit 2 means stop and report it to the maintainer, never hand-fix, move or delete a tag (ADR-0033).
|
- **A plugin `version:` bump that has merged to `main` gets its release tag.** Run `git fetch origin --tags`, then `scripts/tag-plugin-releases.sh`; exit 1 means a tag is missing, and `--apply` creates it locally and prints the push command. The script reads local tags only, so OK means present locally, not published: confirm with `git ls-remote --tags origin '<plugin>-v*'` before calling it done. A tag push is an irreversible publish, not a free Propose-tier push (ADR-0032): show the maintainer the exact tags and that command, and only on their explicit yes in this conversation run exactly it yourself (named tags, never `--tags` or other refs). Agents cut release tags only with the script, which never moves or deletes one; exit 2 means stop and report it to the maintainer, never hand-fix, move or delete a tag (ADR-0033).
|
||||||
- **This repo and Gitea are the only source of truth.** All project state, decisions, and working conventions live here. Do not use an external memory system for this project — cached state diverges from the repo and you get a split brain. Before answering any design or architecture question, check `docs/adr/` for an existing decision.
|
- **This repo and Gitea are the only source of truth.** All project state, decisions, and working conventions live here. Do not use an external memory system for this project — cached state diverges from the repo and you get a split brain. Before answering any design or architecture question, check `docs/adr/` for an existing decision.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -154,4 +154,4 @@ Under the `run-tests` pre-push hook, git exported `GIT_DIR` to the hook, so a ba
|
|||||||
|
|
||||||
## 2026-11-26 — A hook's GIT_DIR leaks through any tool that runs git
|
## 2026-11-26 — A hook's GIT_DIR leaks through any tool that runs git
|
||||||
|
|
||||||
#204: pushing from a linked worktree left the shared `.git/config` with `core.bare=true` and the worktree on a detached HEAD at the lock-pinned commit. git exports an absolute `GIT_DIR` to hooks run from a linked worktree. `apm-audit-ci` ran `apm audit --ci`, and its drift replay (apm 0.28.0) runs `git init` and `git checkout` in a temp dir with an env copied from `os.environ`. The inherited `GIT_DIR` won, so both operations hit this repo instead of the temp dir. The 2026-11-13 fix did not cover this: it scrubbed the env only inside `tests/run-tests.sh`, and the apm hooks never pass through that file. Fix: `scripts/lib/clean-git-env.sh` unsets the repo-locating vars, and both `scripts/apm-audit-ci.sh` and the new `scripts/apm-pack-check-clean.sh` source it before calling apm. `tests/test-apm-hooks-git-env.sh` reproduces the leak with a stub `apm`. Rule: any hook that shells out to a tool that runs git must scrub `GIT_*` first. Scrubbing one entry point does not protect the others.
|
#204: pushing from a linked worktree left the shared `.git/config` with `core.bare=true` and the worktree on a detached HEAD at the lock-pinned commit. git exports an absolute `GIT_DIR` to hooks run from a linked worktree. `apm-audit-ci` ran `apm audit --ci`, and its drift replay (apm 0.28.0) runs `git init` and `git checkout` in a temp dir with an env copied from `os.environ`. The inherited `GIT_DIR` won, so both operations hit this repo instead of the temp dir. The 2026-11-13 fix did not cover this: it scrubbed the env only inside `tests/run-tests.sh`, and the apm hooks never pass through that file. Fix: `scripts/lib/clean-git-env.sh` unsets the repo-locating vars, and both `scripts/apm-audit-ci.sh` and the new `scripts/apm-pack-check-clean.sh` source it before calling apm. `tests/test-apm-hooks-git-env.sh` reproduces the leak with a stub `apm`. Rule: any hook that shells out to a tool that runs git must scrub `GIT_*` first. Scrubbing one entry point does not protect the others. *2026-12-02 (#272):* apm 0.39.3's `apm_cli/utils/git_env.py` provides `git_subprocess_env`, which strips `GIT_DIR` and the other repo-locating vars. The leak was not re-tested on 0.39.3, and the scrub stays, because the rule is about the hook, not about one tool version.
|
||||||
@@ -27,8 +27,8 @@ The plugins:
|
|||||||
- **ansible** — authoring, testing and dry-running Ansible playbooks, roles and collections
|
- **ansible** — authoring, testing and dry-running Ansible playbooks, roles and collections
|
||||||
- **gitops** — authoring, auditing and diagnosing a Flux GitOps repository, including the secrets sealed into it
|
- **gitops** — authoring, auditing and diagnosing a Flux GitOps repository, including the secrets sealed into it
|
||||||
- **k8s** — read-only diagnosis of workloads on a Kubernetes cluster
|
- **k8s** — read-only diagnosis of workloads on a Kubernetes cluster
|
||||||
- **plan** — turning a ticket or idea into a validated, researched spec and agent-ready tickets; ships the `/next` and `/ship` prompts, `research-docs`, and Matt Pocock's planning skills (grilling, research, domain modelling, codebase design, wayfinder, spec, tickets, triage) at a pinned release
|
- **plan** — turning a ticket or idea into a validated, researched spec and agent-ready tickets; ships the `/plan`, `/next` and `/ship` prompts, the `plan-*` agents, `plan-track`, `research-docs` and `write-docs` (documentation), and Matt Pocock's planning skills (grilling, research, domain modelling, codebase design, wayfinder, spec, tickets, triage) at a pinned release
|
||||||
- **bin** — cross-cutting workflow skills not yet split into a focused plugin: documentation, diagnosis, compressed output (`caveman`), and re-orienting mid-task (`zoom-out`)
|
- **bin** — cross-cutting workflow skills not yet split into a focused plugin: diagnosis, compressed output (`caveman`), and re-orienting mid-task (`zoom-out`)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ Install all of these before setting up. Each one is a hard dependency of a git h
|
|||||||
|
|
||||||
| Tool | Why | Install |
|
| Tool | Why | Install |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `apm` CLI | Two pre-push hooks shell out to it (`apm-audit-ci` and `apm-pack-check-clean`) | The `apm-install` skill, or `curl -sSL https://aka.ms/apm-unix \| sh`. Verify with `apm --version` |
|
| `uv` | Runs this repo's pinned apm. The root `pyproject.toml` pins `apm-cli==0.39.3` and `uv.lock` locks it (ADR-0034); the `apm-audit-ci` and `apm-pack-check-clean` pre-push hooks run it as `uv run --frozen apm` through `scripts/lib/apm.sh`, and fail below apm 0.39.2 | https://docs.astral.sh/uv/getting-started/installation/. A global `apm` is not needed and not used: a bare `apm` here may be an older one that refuses the v4 `apm.lock.yaml` |
|
||||||
| `python3` + PyYAML | Required by `scripts/skill-size-check.sh` (the `skill-size-check` pre-commit hook) and `scripts/check-skill-version-bump.sh` (the `check-skill-version-bump` pre-push hook), which both parse YAML frontmatter | `python3` is usually present — pre-commit is itself a Python application. `pip install pyyaml` if the hook reports PyYAML missing |
|
| `python3` + PyYAML | Required by `scripts/skill-size-check.sh` (the `skill-size-check` pre-commit hook) and `scripts/check-skill-version-bump.sh` (the `check-skill-version-bump` pre-push hook), which both parse YAML frontmatter | `python3` is usually present — pre-commit is itself a Python application. `pip install pyyaml` if the hook reports PyYAML missing |
|
||||||
| `vale` | Required by the `vale-audit-prefilter-skill` / `-agent` pre-commit hooks, and by the `test-vale-wrap.sh` suite that `run-tests --strict` runs at pre-push | `brew install vale` (macOS), `snap install vale` (Linux), `choco install vale` (Windows), or https://vale.sh/docs/vale-cli/installation/ |
|
| `vale` | Required by the `vale-audit-prefilter-skill` / `-agent` pre-commit hooks, and by the `test-vale-wrap.sh` suite that `run-tests --strict` runs at pre-push | `brew install vale` (macOS), `snap install vale` (Linux), `choco install vale` (Windows), or https://vale.sh/docs/vale-cli/installation/ |
|
||||||
| `claude` CLI | Required by the `validate-marketplace` pre-push hook | Claude Code |
|
| `claude` CLI | Required by the `validate-marketplace` pre-push hook | Claude Code |
|
||||||
@@ -51,25 +51,36 @@ Two notes worth reading before you skip one:
|
|||||||
Run these in order, from the repo root.
|
Run these in order, from the repo root.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 1. Deploy this repo's own skills and agents
|
# 1. Install the pinned apm into .venv/ (gitignored)
|
||||||
apm install
|
uv sync --frozen
|
||||||
|
|
||||||
# 2. Install the git hooks — all three stages
|
# 2. Deploy this repo's own skills and agents
|
||||||
|
uv run --frozen apm install
|
||||||
|
|
||||||
|
# 3. Install the git hooks — all three stages
|
||||||
pre-commit install -t pre-commit -t commit-msg -t pre-push
|
pre-commit install -t pre-commit -t commit-msg -t pre-push
|
||||||
```
|
```
|
||||||
|
|
||||||
**`apm install`** deploys the plugins root `apm.yml` lists into `.claude/skills/` and `.claude/agents/`. Both are gitignored install output, *not* authoring source — `plugins/<name>/.apm/` remains the only place to edit. It needs the network and materializes `apm_modules/` (which stays gitignored).
|
**`uv sync --frozen`** installs the apm that `uv.lock` pins into `.venv/`.
|
||||||
|
|
||||||
|
**`uv run --frozen apm install`** deploys the plugins root `apm.yml` lists into `.claude/skills/` and `.claude/agents/`. Both are gitignored install output, *not* authoring source — `plugins/<name>/.apm/` remains the only place to edit. Steps 1 and 2 each need the network once per checkout; the first apm 0.39 install also records commit-reachability verdicts. The install materializes `apm_modules/` (which stays gitignored).
|
||||||
|
|
||||||
|
**Run apm only through `uv run --frozen apm`.** A bare `apm` reaches whatever is on `PATH`, possibly an older apm that refuses the v4 `apm.lock.yaml`. The global pipx apm 0.28.0 some machines carry is not used in this repo.
|
||||||
|
|
||||||
|
**An existing checkout deployed by apm 0.28 needs one more step before step 2.** Move `.claude/skills`, `.claude/agents` and `.claude/commands` aside (or delete them if they hold no edits), then run `uv run --frozen apm install`. Without that, apm 0.39 refuses to replace the 0.28-deployed files with "no trustworthy local deployment baseline", because 0.28 recorded no deployment evidence for them. apm's own message suggests a bare `apm install`; use the `uv run --frozen` form instead.
|
||||||
|
|
||||||
|
**Writing the lock from a checkout whose `apm_modules/` apm 0.28 populated needs a clean cache first.** Before any 0.39 command that writes `apm.lock.yaml` (`uv run --frozen apm update`, or an install that changes the lock), move `apm_modules/` aside and run `uv run --frozen apm install`. Otherwise apm reuses the 0.28-era third-party copies and writes a lock without their `carried_licenses` entries, which a fresh install then contradicts. kyberforge's `SessionStart` hook is such a writer: it runs `uv run --frozen apm update --yes` at session start, so it can write the bad lock before you read this. To recover, discard it with `git checkout -- apm.lock.yaml`, move `apm_modules/` aside, then run `uv run --frozen apm install`. Consuming the committed lock is unaffected and needs only the two setup steps above.
|
||||||
|
|
||||||
**Git hooks** must be wired for **all three stages**. This repo's `.pre-commit-config.yaml` has no `default_install_hook_types`, so a plain `pre-commit install` silently skips `commit-msg` (Conventional Commits) and `pre-push` (the full gate) — the `-t` flags above are not optional. The `pc-run` skill handles this and the troubleshooting around it, if you would rather not remember the flags.
|
**Git hooks** must be wired for **all three stages**. This repo's `.pre-commit-config.yaml` has no `default_install_hook_types`, so a plain `pre-commit install` silently skips `commit-msg` (Conventional Commits) and `pre-push` (the full gate) — the `-t` flags above are not optional. The `pc-run` skill handles this and the troubleshooting around it, if you would rather not remember the flags.
|
||||||
|
|
||||||
## Keeping the install current
|
## Keeping the install current
|
||||||
|
|
||||||
The first-party dependencies in root `apm.yml` are unpinned against the default branch, so deployed skills go stale whenever anyone merges. kyberforge's `SessionStart` hook keeps the install current automatically on launch, rewriting `apm.lock.yaml` in the process — an unexplained modification to it after opening a session is expected, not a bug. On `main`, commit or discard it deliberately. On a feature branch, discard it (`git checkout -- apm.lock.yaml`, then `apm install`). The committed lock records a `main` commit too, just an older one. Discarding keeps lock churn unrelated to the branch out of its diff, and keeps the deployed tree consistent with the committed lock that `apm pack --check-clean` reads. The trade-off: the session then runs the older `main` the lock records, which is accepted on a feature branch. The discard also lasts only until the next session start, when the hook finds the lock behind `main` and refreshes again. Mechanism and rationale: `docs/adr/0019-session-start-hook-keeps-the-apm-install-current.md`.
|
The first-party dependencies in root `apm.yml` are unpinned against the default branch, so deployed skills go stale whenever anyone merges. kyberforge's `SessionStart` hook keeps the install current automatically on launch, rewriting `apm.lock.yaml` in the process — an unexplained modification to it after opening a session is expected, not a bug. On `main`, commit or discard it deliberately. On a feature branch, discard it (`git checkout -- apm.lock.yaml`, then `uv run --frozen apm install`). The committed lock records a `main` commit too, just an older one. Discarding keeps lock churn unrelated to the branch out of its diff, and keeps the deployed tree consistent with the committed lock that `apm pack --check-clean` reads. The trade-off: the session then runs the older `main` the lock records, which is accepted on a feature branch. The discard also lasts only until the next session start, when the hook finds the lock behind `main` and refreshes again. Mechanism and rationale: `docs/adr/0019-session-start-hook-keeps-the-apm-install-current.md`.
|
||||||
|
|
||||||
Note the difference between the two commands:
|
Note the difference between the two commands:
|
||||||
|
|
||||||
- `apm install` deploys from `apm.lock.yaml`. It does **not** pick up remote changes.
|
- `uv run --frozen apm install` deploys from `apm.lock.yaml`. It does **not** pick up remote changes.
|
||||||
- `apm update` re-resolves refs. This is the command that pulls in a merged `.apm/` edit.
|
- `uv run --frozen apm update` re-resolves refs. This is the command that pulls in a merged `.apm/` edit.
|
||||||
|
|
||||||
## Running tests
|
## Running tests
|
||||||
|
|
||||||
@@ -92,7 +103,7 @@ pre-commit run --hook-stage pre-push --all-files
|
|||||||
|
|
||||||
See [`docs/spec/gates.md`](docs/spec/gates.md) for what each hook enforces and why.
|
See [`docs/spec/gates.md`](docs/spec/gates.md) for what each hook enforces and why.
|
||||||
|
|
||||||
**Offline?** No pre-push hook needs the network **once `apm install` has populated `apm_modules/`**. Root `apm.yml`'s marketplace has no remote package entries (the last one, `mattpocock-skills`, was removed), so `apm-pack-check-clean` resolves everything from local sources, and `apm-audit-ci`'s install-replay is cache-only against a populated install. On a **fresh clone** there is no cache: `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` checks clone from the holocron remote. The offline guarantee is a property of a populated `apm_modules/`, not of the hook set — run `apm install` once on a new checkout and it holds from then on.
|
**Offline?** No pre-push hook needs the network **once `uv sync --frozen` and `uv run --frozen apm install` have each run once, online** (ADR-0034). Root `apm.yml`'s marketplace has no remote package entries (the last one, `mattpocock-skills`, was removed), so `apm-pack-check-clean` resolves everything from local sources, and `apm-audit-ci`'s install-replay is cache-only against a populated install. On a **fresh clone** there is no cache: `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` checks clone from the holocron remote. The offline guarantee is a property of a synced `.venv/` and a populated `apm_modules/`, not of the hook set — run `uv sync --frozen` and `uv run --frozen apm install` once on a new checkout and it holds from then on.
|
||||||
|
|
||||||
## Editing plugin content
|
## Editing plugin content
|
||||||
|
|
||||||
@@ -111,7 +122,39 @@ An agent may run all four steps, but it runs step 4 only after the maintainer ex
|
|||||||
|
|
||||||
## For external consumers
|
## For external consumers
|
||||||
|
|
||||||
Consume the packages through apm, the way this repo does — declare them as `dependencies.apm` git+path entries against the holocron remote and run `apm install`. apm is the only supported install path.
|
Consume the packages through apm, the way this repo does. apm is the only supported install path.
|
||||||
|
|
||||||
|
### Pinning a plugin to a release
|
||||||
|
|
||||||
|
Each plugin is released as a git tag `<plugin>-v<x.y.z>`, for example `git-v1.3.9`
|
||||||
|
([ADR-0033](docs/adr/0033-plugin-releases-are-tagged-plugin-v-version.md)). Pin one with apm's
|
||||||
|
object form, keys in this order (the planned Renovate rule matches only this order):
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
dependencies:
|
||||||
|
apm:
|
||||||
|
- git: https://git.rkdr.net/Mortis/Holocron.git
|
||||||
|
path: plugins/git
|
||||||
|
ref: git-v1.3.9
|
||||||
|
```
|
||||||
|
|
||||||
|
Then run `apm install` in your own repo. Without `ref:`, the entry tracks the default branch. To list a plugin's
|
||||||
|
releases, run `git ls-remote --tags https://git.rkdr.net/Mortis/Holocron.git '<plugin>-v*'`;
|
||||||
|
`apm outdated` also reports newer `<plugin>-v<x.y.z>` tags.
|
||||||
|
|
||||||
|
### Do not use the shorthand form
|
||||||
|
|
||||||
|
The shorthand `git.rkdr.net/Mortis/Holocron/plugins/<name>#<plugin>-v<x.y.z>` does not work on this
|
||||||
|
host. apm reads `plugins/<name>` as part of the repository path, so a real install tries to clone
|
||||||
|
`.../Holocron/plugins/<name>.git` and fails because no such repository exists (on apm 0.39.3:
|
||||||
|
"Repository Mortis/Holocron/plugins/<name> not found on git.rkdr.net"). `apm install --dry-run` does not catch
|
||||||
|
this. Use the object form.
|
||||||
|
|
||||||
|
### Automated updates
|
||||||
|
|
||||||
|
Renovate's `apm` manager cannot update these pins: it reads only the shorthand form and drops
|
||||||
|
object-form entries. A Renovate regex manager on the `ref:` line is planned but untested, so bump
|
||||||
|
`ref:` by hand until a verified rule is published here. See ADR-0033 consequence 3.
|
||||||
|
|
||||||
## Where to go next
|
## Where to go next
|
||||||
|
|
||||||
|
|||||||
+1213
-79
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,5 @@
|
|||||||
name: holocron
|
name: holocron
|
||||||
version: 0.9.0
|
version: 0.9.1
|
||||||
description: AI development skills for Claude Code, and for GitHub Copilot through apm — factory, design, implement, review, and cross-cutting workflows.
|
description: AI development skills for Claude Code, and for GitHub Copilot through apm — factory, design, implement, review, and cross-cutting workflows.
|
||||||
license: MIT
|
license: MIT
|
||||||
|
|
||||||
@@ -58,26 +58,32 @@ dependencies:
|
|||||||
# verified: `apm approve --list` reports "Executable-trust gate disabled -- all
|
# verified: `apm approve --list` reports "Executable-trust gate disabled -- all
|
||||||
# executables deploy" until an `executables:` block exists.
|
# executables deploy" until an `executables:` block exists.
|
||||||
#
|
#
|
||||||
|
# Keys are the FULL package identity apm 0.39 matches on,
|
||||||
|
# <host>/<owner>/<repo>/<path>#<version>, as `apm approve --list` prints it.
|
||||||
|
# The bare `kyberforge#<version>` form 0.28 accepted no longer matches: under
|
||||||
|
# 0.39.3 it parks both hooks, writes `.claude/settings.json` back to `{}`, and
|
||||||
|
# root `apm audit --ci` still passes (spike #269, on #268). The `#<version>`
|
||||||
|
# suffix is stripped before matching, so the grant is version-blind and a
|
||||||
|
# plugin bump alone does not park the hook; the suffix is a repo convention
|
||||||
|
# that `scripts/check-executables-allow-sync.sh`, a pre-push hook, holds level
|
||||||
|
# with each plugin's apm.yml `version:`.
|
||||||
|
#
|
||||||
|
# The grants are type-level (`hooks: true`), not content-pinned. Every install
|
||||||
|
# warns that they are not pinned to content; that is accepted, because a
|
||||||
|
# content pin parks the hook on every edit to its scripts until someone re-runs
|
||||||
|
# `apm approve`. Do not run `apm approve` here: it rewrites this block, adds
|
||||||
|
# content pins and strips these comments.
|
||||||
|
#
|
||||||
# kyberforge ships the SessionStart hook that keeps this install level with the
|
# kyberforge ships the SessionStart hook that keeps this install level with the
|
||||||
# remote (ADR-0019). The `#2.0.0` suffix below is cosmetic as far as apm is
|
# remote (ADR-0019).
|
||||||
# concerned: grants are version-BLIND in apm 0.28.0. `_map_grants`
|
|
||||||
# (apm_cli/security/executables.py) matches the exact key, the version-blind
|
|
||||||
# name, or any stored key sharing that name, and `materialize_exec_map` also
|
|
||||||
# stores the version-blind name — so approving `kyberforge` covers
|
|
||||||
# `kyberforge#2.0.0` and vice-versa, and a kyberforge version bump does NOT
|
|
||||||
# make this entry stop matching or stop the hook deploying. Do not delete the
|
|
||||||
# suffix anyway: `scripts/check-executables-allow-sync.sh` is a repo-authored
|
|
||||||
# pre-push hook that asserts this key carries the version in
|
|
||||||
# plugins/kyberforge/apm.yml, so a bump here is a repo convention to keep, not
|
|
||||||
# an apm mechanic.
|
|
||||||
executables:
|
executables:
|
||||||
allow:
|
allow:
|
||||||
kyberforge#2.2.1:
|
git.rkdr.net/Mortis/Holocron/plugins/kyberforge#2.3.0:
|
||||||
hooks: true
|
hooks: true
|
||||||
bin: true
|
bin: true
|
||||||
# delivery ships the guard hook (ADR-0032 enforcement layer 2). Same
|
# delivery ships the guard hook (ADR-0032 enforcement layer 2). Same
|
||||||
# version-in-key convention as above, kept by the same sync check.
|
# full-identity, version-in-key convention as above, kept by the same check.
|
||||||
delivery#0.8.0:
|
git.rkdr.net/Mortis/Holocron/plugins/delivery#0.8.0:
|
||||||
hooks: true
|
hooks: true
|
||||||
|
|
||||||
marketplace:
|
marketplace:
|
||||||
@@ -86,7 +92,7 @@ marketplace:
|
|||||||
# top-level apm.yml description:/version: above are NOT inherited into the
|
# top-level apm.yml description:/version: above are NOT inherited into the
|
||||||
# compiled output despite being used elsewhere (e.g. by `apm audit`).
|
# compiled output despite being used elsewhere (e.g. by `apm audit`).
|
||||||
description: AI development skills for Claude Code, and for GitHub Copilot through apm — factory, design, implement, review, and cross-cutting workflows.
|
description: AI development skills for Claude Code, and for GitHub Copilot through apm — factory, design, implement, review, and cross-cutting workflows.
|
||||||
version: 0.9.0
|
version: 0.9.1
|
||||||
owner:
|
owner:
|
||||||
name: Mortis
|
name: Mortis
|
||||||
url: https://git.rkdr.net/Mortis/
|
url: https://git.rkdr.net/Mortis/
|
||||||
|
|||||||
@@ -10,6 +10,12 @@ accurate about how Claude Code's installer works; what changed is that nothing c
|
|||||||
they governed; the symlink amendment's underlying gap is not — see ADR-0024's consequences. This
|
they governed; the symlink amendment's underlying gap is not — see ADR-0024's consequences. This
|
||||||
ADR's content is kept below as the historical record; it is no longer the current model.
|
ADR's content is kept below as the historical record; it is no longer the current model.
|
||||||
|
|
||||||
|
*Amended 2026-12-02 (holocron#272): the apm 0.28.0 mechanism under Considered options holds on apm
|
||||||
|
0.39.3, checked in source. `build_plugin_manifest` still strips `("agents", "skills", "commands",
|
||||||
|
"instructions")`, and `synthesize_plugin_json_from_apm_yml` still emits only identity fields. One
|
||||||
|
addition: for the `codex` ecosystem only, 0.39.3 adds `skills` and `mcpServers` pointers after the
|
||||||
|
strip.*
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
This ADR is a follow-on correction to ADR-0015 (Microsoft APM replaces hand-authored
|
This ADR is a follow-on correction to ADR-0015 (Microsoft APM replaces hand-authored
|
||||||
|
|||||||
@@ -7,6 +7,16 @@ and nothing detects it.
|
|||||||
|
|
||||||
**Status: accepted (2026-08-14).**
|
**Status: accepted (2026-08-14).**
|
||||||
|
|
||||||
|
*Amended 2026-12-01 (holocron#265): the hook resolves apm through the contract in ADR-0034 (a
|
||||||
|
repo-pinned `uv run --frozen` apm, else `PATH` apm, else exit 0) instead of a bare `command -v apm`.
|
||||||
|
The "0.28.0" claims below (the correction near line 80, the `apm outdated` prose at about line 143,
|
||||||
|
and the sidecar reproduction at about line 217) are pending re-verification on 0.39.3 under #265.*
|
||||||
|
|
||||||
|
*Amended 2026-12-02 (holocron#272): those claims are re-checked on apm 0.39.3, and the results sit
|
||||||
|
beside each claim. The version-blind matching holds, but the key's name half is now the full
|
||||||
|
package identity (#271). The `apm outdated` prose holds. The sidecar reproduction was not re-run.
|
||||||
|
In this repo every apm command named below runs as `uv run --frozen apm ...` (ADR-0034).*
|
||||||
|
|
||||||
## Context
|
## Context
|
||||||
|
|
||||||
The pre-existing answer was `scripts/git-hooks/post-push`, which pulled the marketplace clone and
|
The pre-existing answer was `scripts/git-hooks/post-push`, which pulled the marketplace clone and
|
||||||
@@ -87,6 +97,18 @@ question is only what catches a missed edit.
|
|||||||
> justified by this repo's own requirement that the key track `plugins/kyberforge/apm.yml`'s
|
> justified by this repo's own requirement that the key track `plugins/kyberforge/apm.yml`'s
|
||||||
> `version:`, not by an apm-level failure mode. `docs/spec/gates.md` carries the same correction.
|
> `version:`, not by an apm-level failure mode. `docs/spec/gates.md` carries the same correction.
|
||||||
|
|
||||||
|
> **Amendment (2026-12-02, holocron#272) — the key is now the full package identity.** The
|
||||||
|
> version-blind matching in the correction above holds on apm 0.39.3: `is_package_approved`,
|
||||||
|
> `materialize_exec_map` and `_map_grants` keep the same roles in its source. The bare
|
||||||
|
> `kyberforge#<version>` key described above no longer matches on 0.39. apm 0.39 matches a grant on
|
||||||
|
> the package identity `apm approve --list` prints, so the key is
|
||||||
|
> `git.rkdr.net/Mortis/Holocron/plugins/kyberforge#<version>` (#271). A bare key leaves the hook
|
||||||
|
> parked: the first 0.39 install drops it from `.claude/settings.json`, and root `apm audit --ci`
|
||||||
|
> still passes (spike #269). `scripts/check-executables-allow-sync.sh` therefore derives each
|
||||||
|
> expected key from root `apm.yml`'s `git:` + `path:` entry for the plugin, fails a bare key, and
|
||||||
|
> fails any `gated_*` `exec_status` in `apm.lock.yaml`. The `#<version>` half is still a repo-level
|
||||||
|
> record. `docs/spec/gates.md`, "check-executables-allow-sync", has the details.
|
||||||
|
|
||||||
A comment in the `executables:` block is not enough: this repo gates generated-content drift,
|
A comment in the `executables:` block is not enough: this repo gates generated-content drift,
|
||||||
marketplace mirror drift and vale style drift deterministically, and a silent-staleness failure is
|
marketplace mirror drift and vale style drift deterministically, and a silent-staleness failure is
|
||||||
strictly worse than any of them. So `scripts/check-executables-allow-sync.sh` runs at pre-push,
|
strictly worse than any of them. So `scripts/check-executables-allow-sync.sh` runs at pre-push,
|
||||||
@@ -139,6 +161,11 @@ value to be larger — so changing either side without the other fails the suite
|
|||||||
> Re-measured: ~24–26 s for the same six-behind refresh, warm, on a LAN remote — well inside the
|
> Re-measured: ~24–26 s for the same six-behind refresh, warm, on a LAN remote — well inside the
|
||||||
> 380 s above.
|
> 380 s above.
|
||||||
|
|
||||||
|
> **Amendment (2026-12-02, holocron#270) — the budget is now 375 s and the host timeout 400 s.** The
|
||||||
|
> hook also reads `apm --version` under a 15 s bound before the outdated check (ADR-0034), and calls
|
||||||
|
> `timeout` or `gtimeout` through a variable, which the budget test parses too. The current numbers
|
||||||
|
> and their breakdown live in `plugins/kyberforge/docs/hooks.md`.
|
||||||
|
|
||||||
**Reading a human-readable CLI for a control decision cost a silent failure, again.** `apm outdated`
|
**Reading a human-readable CLI for a control decision cost a silent failure, again.** `apm outdated`
|
||||||
has no `--json` or other machine-readable flag (confirmed against 0.28.0), so the hook must match
|
has no `--json` or other machine-readable flag (confirmed against 0.28.0), so the hook must match
|
||||||
its prose. The first attempt matched `outdated dependencies found` — plural only. apm emits
|
its prose. The first attempt matched `outdated dependencies found` — plural only. apm emits
|
||||||
@@ -148,6 +175,10 @@ silently and no refresh ran. With six packages merging independently, one-behind
|
|||||||
case rather than an edge, which means the mechanism failed most often in exactly the situation it
|
case rather than an edge, which means the mechanism failed most often in exactly the situation it
|
||||||
exists for. The match is now `outdated dependenc(y|ies) found`.
|
exists for. The match is now `outdated dependenc(y|ies) found`.
|
||||||
|
|
||||||
|
> **Amendment (2026-12-02, holocron#272) — holds on apm 0.39.3.** `apm outdated --help` still lists
|
||||||
|
> no `--json` or other machine-readable flag, and `apm_cli/commands/outdated.py` still picks
|
||||||
|
> `dependency` or `dependencies` by count.
|
||||||
|
|
||||||
The deeper lesson is the one `post-push` already taught and this repeated: every assertion about the
|
The deeper lesson is the one `post-push` already taught and this repeated: every assertion about the
|
||||||
hook mocked `apm`, so the suite was green while the hook could not detect the common case. Mocks
|
hook mocked `apm`, so the suite was green while the hook could not detect the common case. Mocks
|
||||||
verify the code against its author's belief about the interface, never the interface. The suite now
|
verify the code against its author's belief about the interface, never the interface. The suite now
|
||||||
@@ -218,6 +249,12 @@ protecting, that nothing repo-authored goes in that file, is unchanged.
|
|||||||
> is apm output like the settings entry it describes, so it is committed for the same reason and
|
> is apm output like the settings entry it describes, so it is committed for the same reason and
|
||||||
> changes only when the owning package is renamed or moved. `.claude/hooks/` stays ignored.
|
> changes only when the owning package is renamed or moved. `.claude/hooks/` stays ignored.
|
||||||
|
|
||||||
|
> **Amendment (2026-12-02, holocron#272) — not re-run on apm 0.39.3.** The sidecar is still
|
||||||
|
> committed, and with it root `apm audit --ci` passes all 15 checks on 0.39.3. The 0.28.0 failure
|
||||||
|
> without the sidecar was not reproduced. apm 0.38 and later refuse to replace managed files that
|
||||||
|
> lack deployment evidence, so the failure without it may now look different. That was not
|
||||||
|
> established.
|
||||||
|
|
||||||
**Native consumers are protected by a guard, not by the gate.** A host installing holocron through
|
**Native consumers are protected by a guard, not by the gate.** A host installing holocron through
|
||||||
`claude plugin install` auto-discovers `hooks/hooks.json` and does not consult apm's trust gate at
|
`claude plugin install` auto-discovers `hooks/hooks.json` and does not consult apm's trust gate at
|
||||||
all. The script therefore exits silently when there is no `apm.lock.yaml` in the working directory,
|
all. The script therefore exits silently when there is no `apm.lock.yaml` in the working directory,
|
||||||
|
|||||||
@@ -118,6 +118,12 @@ result against the working tree, and `content-integrity` scans for hidden Unicod
|
|||||||
the finding: both gates compare bytes, neither reads the `description` key for sense, so propagation
|
the finding: both gates compare bytes, neither reads the `description` key for sense, so propagation
|
||||||
is still not verification.
|
is still not verification.
|
||||||
|
|
||||||
|
*Amended 2026-12-02 (holocron#272): on apm 0.39.3, root `apm audit --ci` runs fifteen checks, not
|
||||||
|
ten. It adds `lockfile-targets-current`, `native-mcp-ownership`, `local-bundle-hooks`,
|
||||||
|
`hook-approval-pins` and `exec-status-current`. A plugin package runs two, with `content-integrity`
|
||||||
|
added to `lockfile-exists`. None of the new checks reads the `description` key for sense, so the
|
||||||
|
finding stands. The current list is in `docs/spec/gates.md`, "apm-audit-ci".*
|
||||||
|
|
||||||
**And the obligation is unbounded.** Under enumeration, adding one skill to `bin`, `git` or `gitea`
|
**And the obligation is unbounded.** Under enumeration, adding one skill to `bin`, `git` or `gitea`
|
||||||
means editing two copies of a prose string on top of the version bumps and regeneration any skill
|
means editing two copies of a prose string on top of the version bumps and regeneration any skill
|
||||||
addition already owes under this repo's release policy
|
addition already owes under this repo's release policy
|
||||||
|
|||||||
@@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
**Status:** Accepted (2026-09-20)
|
**Status:** Accepted (2026-09-20)
|
||||||
|
|
||||||
|
*Amended 2026-12-02 (holocron#272): re-verified on apm 0.39.3 in a scratch copy of
|
||||||
|
`plugins/mattpocock`. Without a package lock, the same line and `1 of 1 check(s) failed` appear, so
|
||||||
|
the waiver is unchanged. With one from `apm lock`, the rest of the root set arms (fourteen more
|
||||||
|
checks, not nine), and `drift` fails on 74 unintegrated files under `.agents/skills/`. Two details
|
||||||
|
below changed. A plugin package whose `lockfile-exists` passes now runs two checks, with
|
||||||
|
`content-integrity` added. Plain `apm audit` now prints `No recognized deployed primitives found --
|
||||||
|
nothing to scan`. The malformed-entry case still separates `--ci` (exit 1, now a failing
|
||||||
|
`manifest-parse` row) from plain `apm audit` (exit 0), so the rejection of dropping `--ci` stands.*
|
||||||
|
|
||||||
`plugins/onedev` is the first plugin package in this repo to declare a real dependency. It pins
|
`plugins/onedev` is the first plugin package in this repo to declare a real dependency. It pins
|
||||||
`code.onedev.io/onedev/tod#v4.3.4` so that a consumer installing `onedev` from the holocron
|
`code.onedev.io/onedev/tod#v4.3.4` so that a consumer installing `onedev` from the holocron
|
||||||
marketplace picks up OneDev's eight TOD skills transitively — a `marketplace.packages` entry takes a
|
marketplace picks up OneDev's eight TOD skills transitively — a `marketplace.packages` entry takes a
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ are packages and already resolve through the `path:` branch. The name is a conve
|
|||||||
it assumes apm deploys the skill under the subpath's last segment, which it does today (verified on
|
it assumes apm deploys the skill under the subpath's last segment, which it does today (verified on
|
||||||
apm 0.28.0 for `wayfinder`), and a rename upstream is caught by the pin, not by this gate.
|
apm 0.28.0 for `wayfinder`), and a rename upstream is caught by the pin, not by this gate.
|
||||||
|
|
||||||
|
*Amended 2026-12-02 (holocron#272): holds on apm 0.39.3. A `uv run --frozen apm install` deploys
|
||||||
|
`mattpocock/skills/skills/engineering/wayfinder#v1.3.2` to `.claude/skills/wayfinder/`.*
|
||||||
|
|
||||||
**Rejected: rewording the four clauses out of route notation.** Cheap, but it turns real routing
|
**Rejected: rewording the four clauses out of route notation.** Cheap, but it turns real routing
|
||||||
checks into SUGGESTIONs for exactly the skills most likely to be renamed upstream.
|
checks into SUGGESTIONs for exactly the skills most likely to be renamed upstream.
|
||||||
|
|
||||||
|
|||||||
@@ -45,5 +45,6 @@ approved) are human-set tracker state. `mattpocock`'s thinking tools (`wayfinder
|
|||||||
`research-docs` moved there too. `setup-matt-pocock-skills` is pinned in both packages, at one
|
`research-docs` moved there too. `setup-matt-pocock-skills` is pinned in both packages, at one
|
||||||
upstream tag that is bumped in both together. `delivery` keeps its `mattpocock` dependency, but
|
upstream tag that is bumped in both together. `delivery` keeps its `mattpocock` dependency, but
|
||||||
references none of the moved skills, so it does not depend on `plan`.*
|
references none of the moved skills, so it does not depend on `plan`.*
|
||||||
|
- *Amended 2026-11-29: bin's `write-docs` moves to `plan` too, alongside `research-docs`.*
|
||||||
- Infra applies happen by merge (GitOps for Flux, Ansible and OpenTofu alike), so the PR gate is the
|
- Infra applies happen by merge (GitOps for Flux, Ansible and OpenTofu alike), so the PR gate is the
|
||||||
apply gate; the operator verifies and opens revert PRs, never reverting on its own.
|
apply gate; the operator verifies and opens revert PRs, never reverting on its own.
|
||||||
@@ -2,6 +2,19 @@
|
|||||||
|
|
||||||
**Status: accepted (2026-11-27).**
|
**Status: accepted (2026-11-27).**
|
||||||
|
|
||||||
|
*Amended 2026-12-01 (holocron#265): the 0.28.0 claims in this ADR (the `apm outdated` tag-pattern
|
||||||
|
check in Context and the apm behaviour in consequence 3) are pending re-verification on 0.39.3 under
|
||||||
|
#265, once apm is pinned per repo (ADR-0034). The Decision is unchanged.*
|
||||||
|
|
||||||
|
> **Amendment (2026-12-02, holocron#272) — the 0.28.0 claims re-checked on apm 0.39.3.**
|
||||||
|
> - The tag pattern holds in source: `apm_cli/marketplace/tag_pattern.py` still lists
|
||||||
|
> `{name}-v{version}`. The synthetic-repo `apm outdated` run was not repeated.
|
||||||
|
> - Consequence 3's shorthand failure holds. A scratch install of
|
||||||
|
> `git.rkdr.net/Mortis/Holocron/plugins/lint#<tag>` fails with `Repository
|
||||||
|
> Mortis/Holocron/plugins/lint not found on git.rkdr.net`. The tag in that run did not exist, but
|
||||||
|
> the failure comes at repository resolution, before any ref is read.
|
||||||
|
> - The `rstrip(".git")` bug is fixed in 0.39.3, which uses `removesuffix(".git")`.
|
||||||
|
|
||||||
## Context
|
## Context
|
||||||
|
|
||||||
Issue #223. Consumers that pin a holocron package need a git tag per package version. Two consumers
|
Issue #223. Consumers that pin a holocron package need a git tag per package version. Two consumers
|
||||||
@@ -9,6 +22,9 @@ are known, and both read the same tag shape:
|
|||||||
|
|
||||||
- **Renovate's `apm` manager** (≥ 44.153.0) looks up a dependency on a `plugins/<name>` subpath
|
- **Renovate's `apm` manager** (≥ 44.153.0) looks up a dependency on a `plugins/<name>` subpath
|
||||||
through the `git-tags` datasource. It considers only tags of the form `<prefix>-v<x.y.z>`.
|
through the `git-tags` datasource. It considers only tags of the form `<prefix>-v<x.y.z>`.
|
||||||
|
*Amended 2026-11-29 (holocron#235, #236): this is wrong for Holocron consumers. The manager reads
|
||||||
|
only the shorthand form, which apm cannot install for a Gitea subpath, so it does not serve them
|
||||||
|
today. See consequence 3.*
|
||||||
- **`apm outdated`** matches the tag pattern `{name}-v{version}`. This was verified with apm 0.28.0
|
- **`apm outdated`** matches the tag pattern `{name}-v{version}`. This was verified with apm 0.28.0
|
||||||
against a synthetic repo, and `apm_cli/marketplace/tag_pattern.py` lists `{name}-v{version}`
|
against a synthetic repo, and `apm_cli/marketplace/tag_pattern.py` lists `{name}-v{version}`
|
||||||
among its patterns.
|
among its patterns.
|
||||||
@@ -159,20 +175,29 @@ cuts the same tags on the same commits.
|
|||||||
**2. The root catalogue's version is not tagged per plugin.** Only the `plugins/<name>/apm.yml`
|
**2. The root catalogue's version is not tagged per plugin.** Only the `plugins/<name>/apm.yml`
|
||||||
versions get `<plugin>-v*` tags. The marketplace catalogue's own version is out of scope.
|
versions get `<plugin>-v*` tags. The marketplace catalogue's own version is out of scope.
|
||||||
|
|
||||||
**3. Renovate consumers on this Gitea need an `overridePackageName` rule until upstream fixes
|
**3. Consumers pin with the object form; the `apm` manager does not update them.** *Amended
|
||||||
it.** On hosts other than GitHub and GitLab, Renovate's apm manager does not strip `/plugins/<name>`
|
2026-11-29 (holocron#235, #236); this replaces the original consequence 3, an `overridePackageName`
|
||||||
from the package URL (`lib/modules/manager/apm/extract.ts`, `resolveRepoPath`), so its `git-tags`
|
`packageRules` entry, which is withdrawn.* It was untested and cannot work, for any form:
|
||||||
lookup targets a repo that does not exist. A consumer-side `packageRules` entry along these lines
|
|
||||||
rewrites it. **It is untested.**
|
|
||||||
|
|
||||||
```json
|
- On a generic git host such as this Gitea, apm (0.28.0, and still on `main` at 0.39.1) cannot
|
||||||
{
|
resolve a plugin subdirectory from the shorthand form. `<host>/Mortis/Holocron/plugins/<name>#ref`
|
||||||
"matchManagers": ["apm"],
|
folds `plugins/<name>` into the repo path, and an install clones `.../plugins/<name>.git` and
|
||||||
"matchDatasources": ["git-tags"],
|
fails with "Not found". The separate `rstrip(".git")` parse bug (0.28.0) is already fixed upstream
|
||||||
"matchPackageNames": ["/\\/plugins\\/[^/]+$/"],
|
(microsoft/apm#3715, PR #3767).
|
||||||
"overridePackageName": "{{{replace '/plugins/[^/]+$' '' packageName}}}"
|
- The object form (`git:` + `path:` + `ref:`) is the only working way to pin a Holocron plugin.
|
||||||
}
|
Consumers set `ref: <plugin>-v<x.y.z>`.
|
||||||
```
|
- Renovate's `apm` manager (schema `apm: LooseArray(z.string())`) extracts only shorthand strings and
|
||||||
|
silently drops object-form entries. No `apm.yml` entry is both installable by apm and updatable by
|
||||||
|
that manager for a Gitea subpath, so no `packageRules` entry can fix it.
|
||||||
|
|
||||||
|
The planned route is a Renovate `customManagers` regex manager on the object-form `ref:` line: the
|
||||||
|
`git-tags` datasource, a `currentValue` capturing only the version after `<plugin>-v`, an
|
||||||
|
`extractVersion` scoped to that plugin's own prefix, and automerge off. **This is planned and
|
||||||
|
untested, and no snippet is given.** The verified rule goes in a later amendment, after a live
|
||||||
|
consumer proof. Two upstream reports are to be filed: an apm issue for generic-host subpath folding,
|
||||||
|
and a Renovate Discussion for object-form extraction.
|
||||||
|
|
||||||
|
The Decision, the tag shape `<plugin>-v<version>`, is unchanged by this amendment.
|
||||||
|
|
||||||
**4. For a maintainer, Gitea's `create_tag` is an equivalent way to cut a tag**, provided
|
**4. For a maintainer, Gitea's `create_tag` is an equivalent way to cut a tag**, provided
|
||||||
`git cat-file -t <tag>` reports `tag` after fetching. That confirms it is annotated; the script
|
`git cat-file -t <tag>` reports `tag` after fetching. That confirms it is annotated; the script
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
# apm is pinned per repo with uv
|
||||||
|
|
||||||
|
**Status: accepted (2026-12-01).**
|
||||||
|
|
||||||
|
*Amended 2026-12-02 (holocron#270): the hook's test seam is a `PATH` stub of `uv`, not an `APM`
|
||||||
|
environment override. `tests/test-apm-current-hook.sh` puts a fake `uv` first on a `PATH` that
|
||||||
|
excludes the machine's real `uv` and `apm`. The fake records every invocation and reaches the pinned
|
||||||
|
fake apm only through `uv run`, so the shipped hook carries no test-only override. The `APM` variable
|
||||||
|
under Invocation still applies to repo scripts, not to the hook. The hook also passes `--no-sync` and
|
||||||
|
`--offline` to `uv run`. A plain `uv run --frozen` syncs the environment before running, which is the
|
||||||
|
uv sync and the network access this contract forbids.*
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
Issue #265. apm is installed once per machine with pipx, at 0.28.0, and every repo and the
|
||||||
|
`SessionStart` hook (ADR-0019) call whatever `apm` is on `PATH`. Three things now fail against that:
|
||||||
|
|
||||||
|
- **Lockfile format.** apm 0.37 and later write lockfile v4, and apm 0.36.1 and earlier refuse it. A
|
||||||
|
lock written by 0.39.2 is in turn refused by 0.37.0 through 0.39.1.
|
||||||
|
- **Command keys.** apm 0.39.0 and later keep Claude command keys such as `disable-model-invocation`
|
||||||
|
(#245). Earlier versions drop them, so a deployed command silently loses the setting.
|
||||||
|
- **Machine-global drift.** One shared binary means every checkout's behaviour depends on what was
|
||||||
|
last installed on that machine. apm has no minimum-version field in `apm.yml`, and upstream's advice
|
||||||
|
is to pin a minimum in CI. This repo has no CI (ADR-0024), so the pin has to live in the repo.
|
||||||
|
|
||||||
|
## Decision
|
||||||
|
|
||||||
|
**Each repo pins its own apm with uv. This repo needs apm 0.39.2 or later and is pinned to 0.39.3.**
|
||||||
|
|
||||||
|
- **Pin.** The root `pyproject.toml` has no build system, sets `[tool.uv] package = false` and
|
||||||
|
`requires-python = ">=3.11"`, and declares `[dependency-groups] dev = ["apm-cli==0.39.3"]`. A
|
||||||
|
committed `uv.lock` fixes the transitive dependencies. `.venv/` is gitignored.
|
||||||
|
- **Invocation.** Repo scripts run apm as `uv run --project <repo root> --frozen apm`. An `APM`
|
||||||
|
environment variable overrides the command, as a seam for tests.
|
||||||
|
- **Minimum version, 0.39.2.** It is the lowest version that reads and writes lockfile v4 and is
|
||||||
|
read back by later versions, and it is at or above 0.39.0, which keeps the Claude command keys.
|
||||||
|
Inside this repo the `==` pin enforces it. Where apm comes from `PATH` (a consumer repo that does
|
||||||
|
not pin), an explicit version check enforces it.
|
||||||
|
- **uv only pins apm itself.** ADR-0024 stands: apm is the only supported install path for plugin
|
||||||
|
content. uv installs the tool, never plugins, skills or agents.
|
||||||
|
- **Hook first.** The kyberforge `SessionStart` hook change ships first, with a kyberforge version
|
||||||
|
bump and its release tag (ADR-0033). The cutover (the v4 lock, `pyproject.toml`, `uv.lock`, the
|
||||||
|
scripts and their tests) follows as one PR. The order matters because the deployed hook comes from
|
||||||
|
the `main` commit that `apm.lock.yaml` records. If the v4 lock landed first, the old hook would run
|
||||||
|
`PATH` apm 0.28.0, which refuses the lock, and staleness detection would be lost with no error.
|
||||||
|
The cost of this order: between the hook landing and the cutover, this repo has no pin, so the hook
|
||||||
|
runs `PATH` apm 0.28.0 and prints the fixed too-old notice at every session start. Auto-refresh
|
||||||
|
is paused here until the #271 cutover adds the pin.
|
||||||
|
- **The cutover PR commits a lock rewrite (v1 to v4) on purpose.** It is the one sanctioned exception
|
||||||
|
to the rule that `apm.lock.yaml` churn is discarded on feature branches (ADR-0019).
|
||||||
|
- **Consumer hook contract.** The shipped hook (`check-apm-current.sh`) resolves apm in this order:
|
||||||
|
1. `uv run --frozen --no-sync --offline`, when the project pins `apm-cli` (a quoted `apm-cli`
|
||||||
|
requirement in `pyproject.toml` plus a `uv.lock`) and uv exists. If the project environment
|
||||||
|
(`$UV_PROJECT_ENVIRONMENT`, else `<root>/.venv`) does not exist, the hook prints a fixed "not
|
||||||
|
synced, run `uv sync --frozen`" notice and never calls uv, because even `--no-sync` creates an
|
||||||
|
empty `.venv`.
|
||||||
|
2. `apm` on `PATH`.
|
||||||
|
3. Neither: exit 0. So does a machine with no `timeout` or `gtimeout`, on every path.
|
||||||
|
|
||||||
|
It never triggers a uv sync, and on a cold cache it must not touch the network inside the
|
||||||
|
`SessionStart` timeout. It never reports "up to date" when it ran on an apm older than 0.39.2. Its
|
||||||
|
advice strings are fixed and name the chosen binary, with no interpolation of command output.
|
||||||
|
- **Global apm 0.28.0 stays.** It stays installed and on `PATH`, because ansible still uses it
|
||||||
|
(Defame1297/ansible-homelab-mono#1078). It is not upgraded. Whichever of that issue and
|
||||||
|
Mortis/Kamino#499 lands last uninstalls it: the last mover deletes.
|
||||||
|
- **New setup step.** The offline pre-push guarantee of ADR-0019 now needs `uv sync --frozen` once
|
||||||
|
and `apm install` once per checkout. The first apm 0.39 install also needs the network, to record
|
||||||
|
commit verdicts.
|
||||||
|
|
||||||
|
## Considered options
|
||||||
|
|
||||||
|
**Global pipx apm, as today (rejected).** It is the drift described above, and it cannot enforce a
|
||||||
|
minimum version.
|
||||||
|
|
||||||
|
**Upgrade the global apm (rejected).** It would fix this repo and break ansible, which still depends
|
||||||
|
on 0.28.0 behaviour, and it would leave the next repo with the same shared-binary problem.
|
||||||
|
|
||||||
|
**`uvx` (rejected).** It has no lock, so apm's transitive dependencies float between runs and the
|
||||||
|
pin only covers the top-level package.
|
||||||
|
|
||||||
|
**`uv tool install` (rejected).** It is machine-global state, the same drift as pipx under a
|
||||||
|
different name.
|
||||||
|
|
||||||
|
## Consequences
|
||||||
|
|
||||||
|
1. **A bare `apm` instruction fails closed.** Any leftover `apm` call in this repo that resolves to
|
||||||
|
the global 0.28.0 refuses the v4 lock instead of rewriting it. That is the intended failure, but it
|
||||||
|
will surprise whoever hits it; the fix is the `uv run` form.
|
||||||
|
2. **The network is needed on first sync.** A fresh checkout needs it for `uv sync --frozen` and again
|
||||||
|
for the first `apm install`. After both, the offline guarantee holds.
|
||||||
|
3. **uv becomes a prerequisite** of working in this repo. A consumer without uv falls back to `PATH`
|
||||||
|
apm and the version check.
|
||||||
|
4. **Re-verification is pending.** ADR-0019 and ADR-0033 state facts verified against apm 0.28.0.
|
||||||
|
They are re-checked on 0.39.3 under #265, and each carries a note saying so.
|
||||||
|
*Amended 2026-12-02 (holocron#272): done. ADRs 0017, 0019, 0021, 0026, 0029 and 0033 carry
|
||||||
|
dated notes with the 0.39.3 result for each claim.*
|
||||||
|
|
||||||
|
Related: ADR-0019, ADR-0024, ADR-0033; #245, #265; Defame1297/ansible-homelab-mono#1078;
|
||||||
|
Mortis/Kamino#499.
|
||||||
@@ -28,6 +28,10 @@ How the `wayfinder` skill's map and tickets map onto Gitea, which has native iss
|
|||||||
- **Frontier query**: open issues in the map's milestone with no assignee, then drop any whose `get_blocked_by` lists an open issue.
|
- **Frontier query**: open issues in the map's milestone with no assignee, then drop any whose `get_blocked_by` lists an open issue.
|
||||||
- **Research findings**: committed on a `research/<name>` branch that is pushed but never merged; the ticket's resolution comment links it.
|
- **Research findings**: committed on a `research/<name>` branch that is pushed but never merged; the ticket's resolution comment links it.
|
||||||
|
|
||||||
|
## Spec milestones
|
||||||
|
|
||||||
|
On `/plan`'s spec-and-tickets track, `/plan` creates one milestone titled `Spec: <spec issue title>` and assigns every ticket filed from that spec to it. The milestone is created through `gitea-labels-milestones` and the assignment is made through `gitea-issues`. This sits beside the `Map: <name>` milestone above and follows the same one-milestone-per-parent shape. Spec tickets that carry acceptance criteria get `Status/Ready for Agent`; ones without do not.
|
||||||
|
|
||||||
## PRs as a request surface
|
## PRs as a request surface
|
||||||
|
|
||||||
Off. Only issues feed the triage queue; PRs are not triaged as requests.
|
Off. Only issues feed the triage queue; PRs are not triaged as requests.
|
||||||
@@ -19,7 +19,7 @@ project repo (local overrides)
|
|||||||
- **Executables** (`DEPLOY_EXECUTABLES`): `providers/claude-code/statusline-command.sh` → `~/.claude/statusline-command.sh` (with `+x`)
|
- **Executables** (`DEPLOY_EXECUTABLES`): `providers/claude-code/statusline-command.sh` → `~/.claude/statusline-command.sh` (with `+x`)
|
||||||
- **Directories** (`DEPLOY_DIRS`): `core/` → `~/.claude/core/` (destination fully replaced on each deploy)
|
- **Directories** (`DEPLOY_DIRS`): `core/` → `~/.claude/core/` (destination fully replaced on each deploy)
|
||||||
|
|
||||||
Skills are **not** deployed by `install.sh`. They are distributed as plugins and installed separately — in this repo by `apm install` against the `dependencies.apm` entries in the root `apm.yml`, which lands them in `.claude/skills/` and `.claude/agents/` (ADR-0018). A consuming repo installs them the same way — apm is the only supported install path.
|
Skills are **not** deployed by `install.sh`. They are distributed as plugins and installed separately — in this repo by `uv run --frozen apm install` (the repo-pinned apm, ADR-0034) against the `dependencies.apm` entries in the root `apm.yml`, which lands them in `.claude/skills/` and `.claude/agents/` (ADR-0018). A consuming repo installs them the same way — apm is the only supported install path.
|
||||||
|
|
||||||
`~/.claude/CLAUDE.md` is a thin adapter, not a content source. It imports `~/.agents/AGENTS.md` (always-on rules) and `governance.md` (always-on governance) and carries nothing else — the content index of on-demand instruction files sits in `core/AGENTS.md`, deployed to `~/.agents/AGENTS.md` and imported by it. All always-on content lives in `AGENTS.md` files so other providers can import the same source without duplication.
|
`~/.claude/CLAUDE.md` is a thin adapter, not a content source. It imports `~/.agents/AGENTS.md` (always-on rules) and `governance.md` (always-on governance) and carries nothing else — the content index of on-demand instruction files sits in `core/AGENTS.md`, deployed to `~/.agents/AGENTS.md` and imported by it. All always-on content lives in `AGENTS.md` files so other providers can import the same source without duplication.
|
||||||
|
|
||||||
|
|||||||
+141
-52
@@ -1162,46 +1162,71 @@ plugin packages under `plugins/` — because the root-only invocation audits the
|
|||||||
**nothing else**, and `apm-pack-check-clean` does not parse plugin `dependencies:` blocks either.
|
**nothing else**, and `apm-pack-check-clean` does not parse plugin `dependencies:` blocks either.
|
||||||
Verified: a malformed dependency entry passes
|
Verified: a malformed dependency entry passes
|
||||||
`apm pack --check-versions --check-clean --dry-run` and fails `apm audit --ci` in that package's
|
`apm pack --check-versions --check-clean --dry-run` and fails `apm audit --ci` in that package's
|
||||||
directory. Costs ~0.5s per package.
|
directory. The whole hook, the root plus every plugin package, takes 70-90 s through `uv run` on
|
||||||
|
apm 0.39.3, about 20 s of it the root audit. On apm 0.28.0 it cost about 0.5 s per package.
|
||||||
|
|
||||||
**apm runs with git's repo-locating env scrubbed.** Both apm hooks source
|
**Both apm hooks run the repo-pinned apm.** They source `scripts/lib/apm.sh`, the one place the
|
||||||
`scripts/lib/clean-git-env.sh` before calling `apm`, which unsets `GIT_DIR`, `GIT_WORK_TREE`,
|
invocation is spelled: `uv run --project <repo root> --frozen apm` (ADR-0034). `--project` comes
|
||||||
|
from the helper's own location, so it names the repo root even when apm runs inside
|
||||||
|
`plugins/<name>/`. Each hook first checks the resolved apm's version and fails, naming
|
||||||
|
`uv sync --frozen` as the fix, below 0.39.2. The gates keep plain `--frozen`, without the
|
||||||
|
SessionStart hook's `--no-sync --offline`: once `uv sync --frozen` has run, the sync it implies is a
|
||||||
|
no-op that needs no network, and after a pull that moves the pin it brings `.venv/` to the new pin
|
||||||
|
instead of letting a gate certify the tree with a stale apm. `tests/test-apm-gate-invocation.sh`
|
||||||
|
pins the command, the `--project` root, the scrub and the version floor with a fake `uv`.
|
||||||
|
|
||||||
|
**apm runs with git's repo-locating env scrubbed.** Sourcing `scripts/lib/apm.sh` also sources
|
||||||
|
`scripts/lib/clean-git-env.sh` before anything calls `apm`, which unsets `GIT_DIR`, `GIT_WORK_TREE`,
|
||||||
`GIT_INDEX_FILE`, `GIT_OBJECT_DIRECTORY`, `GIT_COMMON_DIR`, `GIT_PREFIX` and
|
`GIT_INDEX_FILE`, `GIT_OBJECT_DIRECTORY`, `GIT_COMMON_DIR`, `GIT_PREFIX` and
|
||||||
`GIT_IMPLICIT_WORK_TREE`. It deliberately keeps the config-passing vars (`GIT_CONFIG_PARAMETERS`,
|
`GIT_IMPLICIT_WORK_TREE`. It deliberately keeps the config-passing vars (`GIT_CONFIG_PARAMETERS`,
|
||||||
`GIT_CONFIG_COUNT`), because they carry `git -c` overrides apm's remote clones may need. The reason: `git push` from a **linked worktree** exports an
|
`GIT_CONFIG_COUNT`), because they carry `git -c` overrides apm's remote clones may need. The reason:
|
||||||
absolute `GIT_DIR=<main>/.git/worktrees/<name>` to its hooks, and from the main checkout it exports
|
`git push` from a **linked worktree** exports an absolute `GIT_DIR=<main>/.git/worktrees/<name>` to
|
||||||
none. `drift`'s install replay (apm 0.28.0) runs `git init` and `git checkout` in a temp dir with an
|
its hooks, and from the main checkout it exports none. `drift`'s install replay (apm 0.28.0) runs
|
||||||
env copied from `os.environ`, so the inherited `GIT_DIR` wins. The `init` wrote `core.bare=true` into
|
`git init` and `git checkout` in a temp dir with an env copied from `os.environ`, so the inherited
|
||||||
the shared `.git/config`, and the `checkout` moved the worktree's HEAD to the lock-pinned commit
|
`GIT_DIR` wins. The `init` wrote `core.bare=true` into the shared `.git/config`, and the `checkout`
|
||||||
(issue #204). Pre-commit runs hooks from the worktree root, so once the vars are gone plain
|
moved the worktree's HEAD to the lock-pinned commit (issue #204). Pre-commit runs hooks from the
|
||||||
discovery finds the right repo. `tests/test-apm-hooks-git-env.sh` pins this for both hooks.
|
worktree root, so once the vars are gone plain discovery finds the right repo. *2026-12-02
|
||||||
|
(holocron#272):* apm 0.39.3's `apm_cli/utils/git_env.py` provides `git_subprocess_env`, which strips
|
||||||
|
`GIT_DIR` and the other repo-locating vars. The leak was not re-tested on 0.39.3, and the scrub
|
||||||
|
stays as defence in depth. `tests/test-apm-hooks-git-env.sh` pins this for both hooks.
|
||||||
|
|
||||||
**What it actually runs is asymmetric**, and the two manifest classes are not comparable. Verified by
|
**What it actually runs is asymmetric**, and the two manifest classes are not comparable. Verified by
|
||||||
running `apm audit --ci` (apm 0.28.0) at the repo root and in `plugins/lint/`, reading the check
|
running `apm audit --ci` (apm 0.39.3, holocron#272; first done on 0.28.0) at the repo root and in
|
||||||
names straight off its own compliance table:
|
`plugins/lint/`, reading the check names straight off its own compliance table:
|
||||||
|
|
||||||
On the **root** manifest, **10 checks**: `lockfile-exists`, `ref-consistency`,
|
On the **root** manifest, **15 checks**: `lockfile-exists`, `ref-consistency`,
|
||||||
`deployment-ledger-owners`, `deployed-files-present`, `no-orphaned-packages`,
|
`deployment-ledger-owners`, `deployed-files-present`, `no-orphaned-packages`,
|
||||||
`skill-subset-consistency`, `config-consistency`, `content-integrity`, `includes-consent`, `drift`.
|
`lockfile-targets-current`, `skill-subset-consistency`, `config-consistency`,
|
||||||
|
`native-mcp-ownership`, `content-integrity`, `local-bundle-hooks`, `hook-approval-pins`,
|
||||||
|
`exec-status-current`, `includes-consent`, `drift`. apm 0.28.0 ran ten of these; the five it lacked
|
||||||
|
are `lockfile-targets-current`, `native-mcp-ownership`, `local-bundle-hooks`, `hook-approval-pins`
|
||||||
|
and `exec-status-current`.
|
||||||
|
|
||||||
On each **plugin** manifest, **1 check**: `lockfile-exists`. Conditional, and vacuous while every
|
On each **plugin** manifest, **2 checks**: `lockfile-exists` and `content-integrity` (0.28.0 ran
|
||||||
plugin `apm.yml` declared `dependencies: {apm: [], mcp: []}` — it reports `No dependencies declared
|
only `lockfile-exists`). The plugin-level `content-integrity` row scans no package source: on 0.39.3
|
||||||
-- lockfile not required`. An earlier revision of this section said it would arm the moment one did
|
it still passed with a bidi override planted in a scratch copy of `plugins/lint`. When
|
||||||
not. **It has armed.** `plugins/onedev` was the first plugin package to declare a real dependency — it
|
`lockfile-exists` fails, the table holds that one row alone. `lockfile-exists` is conditional, and
|
||||||
pinned `code.onedev.io/onedev/tod#v4.3.4` — and was removed on 2026-11-11; `plugins/mattpocock`
|
vacuous while every plugin `apm.yml` declared `dependencies: {apm: [], mcp: []}` — it reports `No
|
||||||
carries the same shape (pinned third-party skills, no primitives of its own) and the check fires on
|
dependencies declared -- lockfile not required`. An earlier revision of this section said it would
|
||||||
it for real. Everything else in the list above is root-only, because it is the
|
arm the moment one did not. **It has armed.** `plugins/onedev` was the first plugin package to
|
||||||
root install that has a lockfile, a deployment ledger and deployed files to check.
|
declare a real dependency — it pinned `code.onedev.io/onedev/tod#v4.3.4` — and was removed on
|
||||||
|
2026-11-11; `plugins/mattpocock` carries the same shape (pinned third-party skills, no primitives of
|
||||||
|
its own) and the check fires on it for real. Everything else in the root list is root-only, because
|
||||||
|
it is the root install that has a lockfile, a deployment ledger and deployed files to check.
|
||||||
|
|
||||||
**A plugin package that declares dependencies has no green state, so the hook waives exactly one
|
**A plugin package that declares dependencies has no green state, so the hook waives exactly one
|
||||||
failure.** Verified against apm 0.28.0 in `plugins/onedev/` (since removed; the behaviour is the same for any package that declares dependencies):
|
failure.** Verified against apm 0.28.0 in `plugins/onedev/` (since removed; the behaviour is the
|
||||||
|
same for any package that declares dependencies), and again on apm 0.39.3 in a scratch copy of
|
||||||
|
`plugins/mattpocock` (holocron#272):
|
||||||
|
|
||||||
- **Without a package `apm.lock.yaml`**, `lockfile-exists` fails — `apm.yml declares dependencies but
|
- **Without a package `apm.lock.yaml`**, `lockfile-exists` fails — `apm.yml declares dependencies but
|
||||||
apm.lock.yaml is absent` — reported as `1 of 1 check(s) failed`.
|
apm.lock.yaml is absent` — reported as `1 of 1 check(s) failed`. Unchanged on 0.39.3.
|
||||||
- **With one**, generated by `apm lock` in the package directory, `lockfile-exists` passes and
|
- **With one**, generated by `apm lock` in the package directory, `lockfile-exists` passes and
|
||||||
thereby arms the other nine checks; `drift` then fails reporting **8 unintegrated files** at
|
thereby arms the rest of the root check set; `drift` then fails reporting unintegrated files at
|
||||||
`.agents/skills/<name>/SKILL.md`, i.e. demanding the dependency's skills be *deployed inside the
|
`.agents/skills/<name>/...`, i.e. demanding the dependency's skills be *deployed inside the
|
||||||
package*. `apm lock` also leaves an `apm_modules/` tree inside the package.
|
package*. On 0.28.0 that was nine more checks and 8 files from onedev; on 0.39.3 it is fourteen
|
||||||
|
more checks and 74 files from mattpocock. `apm lock` also leaves an `apm_modules/` tree inside the
|
||||||
|
package.
|
||||||
|
|
||||||
The cause is that apm treats any directory holding both `apm.yml` and `apm.lock.yaml` as an **install
|
The cause is that apm treats any directory holding both `apm.yml` and `apm.lock.yaml` as an **install
|
||||||
root**, and a plugin package is not one. `scripts/apm-audit-ci.sh` therefore waives `lockfile-exists`
|
root**, and a plugin package is not one. `scripts/apm-audit-ci.sh` therefore waives `lockfile-exists`
|
||||||
@@ -1209,27 +1234,52 @@ and nothing else, and only for a non-root manifest: it asserts the string `1 of
|
|||||||
so any second failing check changes the count and the run fails normally, and output it does not
|
so any second failing check changes the count and the run fails normally, and output it does not
|
||||||
recognise fails closed. The root manifest is never waived. Recorded as ADR-0026.
|
recognise fails closed. The root manifest is never waived. Recorded as ADR-0026.
|
||||||
|
|
||||||
**Dropping `--ci` for package directories was considered and rejected.** It is the smaller change and
|
**Dropping `--ci` for package directories was considered and rejected.** It is the smaller change
|
||||||
it is wrong. Verified on apm 0.28.0 against a scratch package whose dependency entry carried no
|
and it is wrong. Verified on apm 0.28.0, and again on 0.39.3 (holocron#272), against a scratch
|
||||||
`git`/`path`/`registry` field: `apm audit --ci` exits 1 naming the field, while plain `apm audit`
|
package whose dependency entry carried no `git`/`path`/`registry` field: `apm audit --ci` exits 1
|
||||||
prints `No apm.lock.yaml found -- nothing to scan` and exits 0. Malformed-dependency detection is the
|
naming the field, while plain `apm audit` exits 0. Plain `apm audit` printed `No apm.lock.yaml found
|
||||||
reason this section gives for auditing packages at all, and a package *with* dependencies is the only
|
-- nothing to scan` on 0.28.0 and prints `No recognized deployed primitives found -- nothing to
|
||||||
kind that can carry a malformed dependency entry — so dropping `--ci` would discard the check
|
scan` on 0.39.3. Malformed-dependency detection is the reason this section gives for auditing
|
||||||
precisely where it earns its keep.
|
packages at all, and a package *with* dependencies is the only kind that can carry a malformed
|
||||||
|
dependency entry — so dropping `--ci` would discard the check precisely where it earns its keep.
|
||||||
|
|
||||||
**Known weak point: the waiver matches on apm's stdout.** An apm upgrade that rewords either line
|
**Known weak point: the waiver matches on apm's stdout.** An apm upgrade that rewords either line
|
||||||
turns the waiver off. That fails the push rather than hiding a defect; re-verify against the new
|
turns the waiver off. That fails the push rather than hiding a defect; re-verify against the new
|
||||||
output and update the patterns rather than widening them.
|
output and update the patterns rather than widening them.
|
||||||
|
|
||||||
**`manifest-parse` is not a named check** in apm 0.28.0's output, and an earlier revision of this
|
**`manifest-parse` is a named check on apm 0.39.3, and was not one on 0.28.0.** On 0.28.0 a
|
||||||
section listed it as one. Parsing is still enforced — a dependency entry missing its
|
dependency entry missing its `git`/`path`/`registry` field failed the invocation with `Cannot parse
|
||||||
`git`/`path`/`registry` field fails with `Cannot parse apm.yml` — but it fails the invocation before
|
apm.yml` before the table was built. On 0.39.3 the same entry produces a one-row table, a failing
|
||||||
the table is built rather than appearing as a row in it.
|
`manifest-parse` row reading `Cannot parse apm.yml: Invalid APM dependency ...`, and `1 of 1
|
||||||
|
check(s) failed` (holocron#272). The waiver does not cover it: that row lacks the `declares
|
||||||
|
dependencies but apm.lock.yaml is absent` line the waiver also requires. A parsable manifest gets no
|
||||||
|
`manifest-parse` row, which is why it is missing from both lists above.
|
||||||
|
|
||||||
**The hook needs a completed `apm install`.** `deployed-files-present` checks the install output on
|
**The hook needs a completed `apm install`.** `deployed-files-present` checks the install output on
|
||||||
disk, so on a fresh clone it fails with `303 deployed file(s) missing` and takes the push with it.
|
disk, so on a fresh clone it fails with `<N> deployed file(s) missing` (303 on 0.28.0; the count
|
||||||
That is not a defect in the gate; it is the gate correctly reporting that nothing has been installed
|
follows the lock) and takes the push with it. That is not a defect in the gate; it is the gate
|
||||||
yet. Run `apm install` before the first push from a new checkout.
|
correctly reporting that nothing has been installed yet. Before the first push from a new checkout,
|
||||||
|
run `uv sync --frozen` and then `uv run --frozen apm install`, each once and online. Without the
|
||||||
|
first, the hooks' plain `uv run --frozen` performs that sync itself, which needs the network. An
|
||||||
|
older checkout whose `.claude/skills`, `.claude/agents` and `.claude/commands` were deployed by apm
|
||||||
|
0.28 moves those three directories aside before that first 0.39 install. Otherwise apm refuses to
|
||||||
|
replace the files with `no trustworthy local deployment baseline`, because 0.28 recorded no
|
||||||
|
deployment evidence for them. apm's message suggests a bare `apm install`; run the `uv run --frozen`
|
||||||
|
form instead.
|
||||||
|
|
||||||
|
**A lock written over a 0.28-populated `apm_modules/` is wrong, and this gate family catches it
|
||||||
|
late.** Before any 0.39 command that writes `apm.lock.yaml` (`uv run --frozen apm update`, or an
|
||||||
|
install that changes the lock) in a checkout whose `apm_modules/` apm 0.28 populated, move
|
||||||
|
`apm_modules/` aside and run `uv run --frozen apm install`. Otherwise apm reuses the 0.28-era
|
||||||
|
third-party copies and writes a lock without their `carried_licenses` entries. A fresh install then
|
||||||
|
adds the LICENSE files, the cached content hash no longer matches the lock, and
|
||||||
|
`apm-pack-check-clean` fails with `does not match the content hash recorded in apm.lock.yaml`
|
||||||
|
(found under #272, fixed on #271 by regenerating the lock from a fresh install). Only writing the
|
||||||
|
lock is affected: consuming the committed lock needs only the two setup steps. kyberforge's
|
||||||
|
`SessionStart` hook is such a writer: it runs `uv run --frozen apm update --yes` at session start,
|
||||||
|
so in a checkout apm 0.28 populated it can write the bad lock before anyone reads this. To recover,
|
||||||
|
discard it with `git checkout -- apm.lock.yaml`, move `apm_modules/` aside, then run
|
||||||
|
`uv run --frozen apm install`.
|
||||||
|
|
||||||
It does **not** enforce an org policy. apm discovers one from the git remote and only understands
|
It does **not** enforce an org policy. apm discovers one from the git remote and only understands
|
||||||
github.com and Azure DevOps, so against this repo's self-hosted Gitea remote it prints:
|
github.com and Azure DevOps, so against this repo's self-hosted Gitea remote it prints:
|
||||||
@@ -1249,13 +1299,46 @@ that can never go green is not a gate. Revisit only if this repo gains a policy
|
|||||||
or hash drift detected` — so the root invocation already covers it and nothing needs adding. What
|
or hash drift detected` — so the root invocation already covers it and nothing needs adding. What
|
||||||
remains true is that the *standalone* mode is different: plain `apm audit` (`--ci` refuses to combine
|
remains true is that the *standalone* mode is different: plain `apm audit` (`--ci` refuses to combine
|
||||||
with `--file`/`--strip`/`--dry-run`/`PACKAGE`) run in a plugin directory reports
|
with `--file`/`--strip`/`--dry-run`/`PACKAGE`) run in a plugin directory reports
|
||||||
`No apm.lock.yaml found -- nothing to scan` and exits 0, because only the root has a lockfile.
|
`No recognized deployed primitives found -- nothing to scan` on 0.39.3 (`No apm.lock.yaml found --
|
||||||
Plugin manifests get `lockfile-exists` and nothing else; they are not Unicode-scanned. That holds
|
nothing to scan` on 0.28.0) and exits 0, because only the root has a lockfile and deployed files.
|
||||||
because no package carries an `apm.lock.yaml` — one would arm the other nine checks, `content-integrity`
|
Plugin manifests are not Unicode-scanned. 0.39.3 does add a `content-integrity` row in a plugin
|
||||||
among them, which is the state ADR-0026 rules out rather than a second scan worth having.
|
directory, but it scans no package source (see above). That holds because no package carries an
|
||||||
|
`apm.lock.yaml`. One would arm the rest of the root check set, a scanning `content-integrity` among
|
||||||
|
them, which is the state ADR-0026 rules out rather than a second scan worth having.
|
||||||
|
|
||||||
### `check-executables-allow-sync`
|
### `check-executables-allow-sync`
|
||||||
|
|
||||||
|
**Keys are full package identities (apm 0.39, #271).** apm 0.39.3 matches a grant on the package
|
||||||
|
identity `<host>/<owner>/<repo>/<path>`, as `apm approve --list` prints it, e.g.
|
||||||
|
`git.rkdr.net/Mortis/Holocron/plugins/kyberforge`. The bare `kyberforge#<version>` key that 0.28.0
|
||||||
|
matched no longer matches: the first 0.39 install parks the hooks, rewrites `.claude/settings.json`
|
||||||
|
without them, and root `apm audit --ci` still passes (spike #269, on #268). So the gate now derives
|
||||||
|
each expected key from root `apm.yml`'s own `git:` + `path:` dependency entry for the plugin (URL
|
||||||
|
without scheme, user or `.git`, then the path), appends `#<version>`, and fails a bare key with a
|
||||||
|
message saying why. A shipping plugin with no such entry fails, since no key can be derived, and so
|
||||||
|
does one whose `git:` URL names a port, because how apm writes a port into the identity is
|
||||||
|
unverified. Only an https URL on a lowercase host was checked against `apm approve --list`; the
|
||||||
|
scp-like and `ssh://` forms follow the same rule unchecked, and the host's case is kept as written. The
|
||||||
|
`#<version>` suffix is still stripped before apm matches, so the grant stays version-blind and the
|
||||||
|
version half stays a repo-level record. The grants are type-level (`hooks: true`), not
|
||||||
|
content-pinned: `apm approve` would pin content, strip the block's comments, and park the hook on
|
||||||
|
every script edit until someone approves again.
|
||||||
|
|
||||||
|
**It also fails on a parked executable in `apm.lock.yaml`** (spike #269, section 7.3). apm records
|
||||||
|
each dependency's executables decision as `exec_status:` in the lock, `deployed` or a `gated_*`
|
||||||
|
value such as `gated_pending_approval`. Root `apm audit --ci` passes with executables parked,
|
||||||
|
because `exec-status-current` only checks that the lock agrees with the gate. So the gate scans the
|
||||||
|
lock's `dependencies:` and fails on any `gated_*` entry, naming its identity and status, with
|
||||||
|
`apm approve --list` as the first step of the fix. It runs even when no plugin here ships
|
||||||
|
executables, since a third-party dependency can be parked too. A missing lock is left to
|
||||||
|
`apm-audit-ci`'s `lockfile-exists`. It is a line scan of the shape apm writes, not a YAML parse.
|
||||||
|
|
||||||
|
The rest of this section describes the 0.28.0 matching that the version-blind behaviour comes from.
|
||||||
|
*2026-12-02 (holocron#272):* the functions it names are still in apm 0.39.3's source with the same
|
||||||
|
roles. `materialize_exec_map` still stores each key under its version-blind name, and `_map_grants`
|
||||||
|
documents ordinary grants as version-blind. What changed is the name half of the key, which is now
|
||||||
|
the full identity described above.
|
||||||
|
|
||||||
apm gates a package's `hooks/` and `bin/` on root `apm.yml`'s `executables.allow`
|
apm gates a package's `hooks/` and `bin/` on root `apm.yml`'s `executables.allow`
|
||||||
(`apm_cli/security/executables.py`). `is_package_approved` is itself an exact dictionary lookup, but
|
(`apm_cli/security/executables.py`). `is_package_approved` is itself an exact dictionary lookup, but
|
||||||
it is never called with a single key: `install/exec_gate.py` builds a candidate list that includes
|
it is never called with a single key: `install/exec_gate.py` builds a candidate list that includes
|
||||||
@@ -1276,10 +1359,10 @@ It covers every plugin that ships executables, not one named package. The script
|
|||||||
`plugins/*/` and treats a plugin as shipping executables when `plugins/<name>/.apm/hooks/` or
|
`plugins/*/` and treats a plugin as shipping executables when `plugins/<name>/.apm/hooks/` or
|
||||||
`plugins/<name>/bin/` exists — kyberforge ships both, delivery ships a guard hook. For each one it
|
`plugins/<name>/bin/` exists — kyberforge ships both, delivery ships a guard hook. For each one it
|
||||||
reads `name:` and `version:` from `plugins/<name>/apm.yml` and asserts root `apm.yml` carries the
|
reads `name:` and `version:` from `plugins/<name>/apm.yml` and asserts root `apm.yml` carries the
|
||||||
`<name>#<version>` key under `executables.allow`. Keys use the package name, so a `name:` that
|
`<identity>#<version>` key under `executables.allow`. The `name:` must equal the directory name, so
|
||||||
differs from the directory name fails rather than being guessed at. Every failing package is
|
one that differs fails rather than being guessed at. Every failing package is
|
||||||
reported in one run, each with its own Why/Fix block; a stale `<name>#<other-version>` key is quoted
|
reported in one run, each with its own Why/Fix block; a stale `<identity>#<other-version>` key, or a
|
||||||
back as "found instead". It also fails on a shipping plugin with no `apm.yml`, a missing `version:`,
|
bare `<name>#...` key, is quoted back as "found instead". It also fails on a shipping plugin with no `apm.yml`, a missing `version:`,
|
||||||
a missing root `apm.yml`, or no `executables.allow` mapping. A repo with no executable-shipping
|
a missing root `apm.yml`, or no `executables.allow` mapping. A repo with no executable-shipping
|
||||||
plugin at all is the one no-op, and a plugin with neither directory needs no key.
|
plugin at all is the one no-op, and a plugin with neither directory needs no key.
|
||||||
|
|
||||||
@@ -1327,7 +1410,11 @@ drift after the fact, not by a derived gate.
|
|||||||
|
|
||||||
## Pushing without a network
|
## Pushing without a network
|
||||||
|
|
||||||
No pre-push hook needs the network **once `apm install` has populated `apm_modules/`**. Every entry
|
No pre-push hook needs the network **once two one-time online steps have run in this checkout**:
|
||||||
|
`uv sync --frozen`, which installs the apm that `uv.lock` pins into `.venv/`, then
|
||||||
|
`uv run --frozen apm install`, which populates `apm_modules/` and the deployed tree. Every apm
|
||||||
|
call in the hooks goes through the pinned invocation in `scripts/lib/apm.sh` (ADR-0034); after the
|
||||||
|
first sync, its implied `uv` sync is a no-op that needs no network. Every entry
|
||||||
in root `apm.yml`'s `marketplace.packages[]` resolves from a local `./plugins/<name>` path, so
|
in root `apm.yml`'s `marketplace.packages[]` resolves from a local `./plugins/<name>` path, so
|
||||||
`apm-pack-check-clean` never calls `git ls-remote`.
|
`apm-pack-check-clean` never calls `git ls-remote`.
|
||||||
|
|
||||||
@@ -1337,8 +1424,10 @@ replay the install to diff scratch against the working tree, and that replay is
|
|||||||
`[>] Replaying install (cache-only)` — which is exactly why it costs no network here. On a **fresh
|
`[>] Replaying install (cache-only)` — which is exactly why it costs no network here. On a **fresh
|
||||||
clone** there is no cache to replay from, so the replay clones from the holocron remote and those two
|
clone** there is no cache to replay from, so the replay clones from the holocron remote and those two
|
||||||
checks fail offline, with `deployed-files-present` already failing for the same reason (see
|
checks fail offline, with `deployed-files-present` already failing for the same reason (see
|
||||||
`apm-audit-ci` above). The offline guarantee is a property of a populated `apm_modules/`, not of the
|
`apm-audit-ci` above). The offline guarantee is a property of a synced `.venv/` and a populated
|
||||||
hook set: run `apm install` once on a new checkout and it holds from then on.
|
`apm_modules/`, not of the hook set: run `uv sync --frozen` and `uv run --frozen apm install` once
|
||||||
|
on a new checkout and it holds from then on. Run apm only in that pinned form here: a bare `apm`
|
||||||
|
reaches whatever is on `PATH`, possibly an older apm that refuses the v4 `apm.lock.yaml`.
|
||||||
|
|
||||||
## Plugin release tags are not a gate
|
## Plugin release tags are not a gate
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ Then:
|
|||||||
apm install
|
apm install
|
||||||
```
|
```
|
||||||
|
|
||||||
The entry above is unpinned and tracks the remote's default branch — add `ref: <tag>` to pin a release. Registering the catalogue instead (`apm marketplace add https://git.rkdr.net/Mortis/Holocron.git --name holocron`) gets you the `bin@holocron` short name, but writes to `~/.apm/marketplaces.json` at user scope; the git+path object needs nothing beyond the manifest.
|
The entry above is unpinned and tracks the remote's default branch. To pin a release, add `ref: bin-v<x.y.z>` after `path:`; see [Pinning a plugin to a release](../../README.md#pinning-a-plugin-to-a-release). Registering the catalogue instead (`apm marketplace add https://git.rkdr.net/Mortis/Holocron.git --name holocron`) gets you the `bin@holocron` short name, but writes to `~/.apm/marketplaces.json` at user scope; the git+path object needs nothing beyond the manifest.
|
||||||
|
|
||||||
**Native plugin installs do not work.** This package ships no per-plugin manifest and no flat content directories, so a host that installs it natively gets zero skills — and Claude Code raises no error while doing it (ADR-0024).
|
**Native plugin installs do not work.** This package ships no per-plugin manifest and no flat content directories, so a host that installs it natively gets zero skills — and Claude Code raises no error while doing it (ADR-0024).
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
name: bin
|
name: bin
|
||||||
version: 4.0.0
|
version: 5.0.0
|
||||||
description: Skills for everyday AI-assisted development work that is not tied to a single tool, forge or language, and has not yet been split into a focused plugin.
|
description: Skills for everyday AI-assisted development work that is not tied to a single tool, forge or language, and has not yet been split into a focused plugin.
|
||||||
author:
|
author:
|
||||||
name: Mortis
|
name: Mortis
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ Then:
|
|||||||
apm install
|
apm install
|
||||||
```
|
```
|
||||||
|
|
||||||
The entry above is unpinned and tracks the remote's default branch — add `ref: <tag>` to pin a release. Registering the catalogue instead (`apm marketplace add https://git.rkdr.net/Mortis/Holocron.git --name holocron`) gets you the `core@holocron` short name, but writes to `~/.apm/marketplaces.json` at user scope; the git+path object needs nothing beyond the manifest.
|
The entry above is unpinned and tracks the remote's default branch. To pin a release, add `ref: core-v<x.y.z>` after `path:`; see [Pinning a plugin to a release](../../README.md#pinning-a-plugin-to-a-release). Registering the catalogue instead (`apm marketplace add https://git.rkdr.net/Mortis/Holocron.git --name holocron`) gets you the `core@holocron` short name, but writes to `~/.apm/marketplaces.json` at user scope; the git+path object needs nothing beyond the manifest.
|
||||||
|
|
||||||
**Native plugin installs do not work.** This package ships no per-plugin manifest and no flat content directories, so a host that installs it natively gets zero skills — and Claude Code raises no error while doing it (ADR-0024).
|
**Native plugin installs do not work.** This package ships no per-plugin manifest and no flat content directories, so a host that installs it natively gets zero skills — and Claude Code raises no error while doing it (ADR-0024).
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ Then:
|
|||||||
apm install
|
apm install
|
||||||
```
|
```
|
||||||
|
|
||||||
The entry above is unpinned and tracks the remote's default branch — add `ref: <tag>` to pin a release. Registering the catalogue instead (`apm marketplace add https://git.rkdr.net/Mortis/Holocron.git --name holocron`) gets you the `git@holocron` short name, but writes to `~/.apm/marketplaces.json` at user scope; the git+path object needs nothing beyond the manifest.
|
The entry above is unpinned and tracks the remote's default branch. To pin a release, add `ref: git-v<x.y.z>` after `path:`; see [Pinning a plugin to a release](../../README.md#pinning-a-plugin-to-a-release). Registering the catalogue instead (`apm marketplace add https://git.rkdr.net/Mortis/Holocron.git --name holocron`) gets you the `git@holocron` short name, but writes to `~/.apm/marketplaces.json` at user scope; the git+path object needs nothing beyond the manifest.
|
||||||
|
|
||||||
**Native plugin installs do not work.** This package ships no per-plugin manifest and no flat content directories, so a host that installs it natively gets zero skills and zero agents — and Claude Code raises no error while doing it (ADR-0024).
|
**Native plugin installs do not work.** This package ships no per-plugin manifest and no flat content directories, so a host that installs it natively gets zero skills and zero agents — and Claude Code raises no error while doing it (ADR-0024).
|
||||||
|
|
||||||
|
|||||||
@@ -24,26 +24,49 @@ project_dir="${CLAUDE_PROJECT_DIR:-$PWD}"
|
|||||||
# No lockfile means nothing was installed through apm here — e.g. a host that
|
# No lockfile means nothing was installed through apm here — e.g. a host that
|
||||||
# installed this plugin natively. Say nothing and cost nothing.
|
# installed this plugin natively. Say nothing and cost nothing.
|
||||||
[[ -f "$project_dir/apm.lock.yaml" ]] || exit 0
|
[[ -f "$project_dir/apm.lock.yaml" ]] || exit 0
|
||||||
command -v apm > /dev/null 2>&1 || exit 0
|
|
||||||
|
|
||||||
# Every apm call below must see the same directory the guard just checked —
|
# Every apm call below is bounded, and stock macOS ships no `timeout`; Homebrew
|
||||||
# `apm outdated` and `apm update` both resolve the lockfile from the cwd.
|
# coreutils installs it as `gtimeout`. Without either, nothing can be bounded,
|
||||||
cd "$project_dir" || exit 0
|
# so the hook stays silent on every path rather than risk holding the session
|
||||||
|
# open — or misreporting an apm whose version it could not read. It is chosen
|
||||||
|
# before the apm, so no notice is printed either. The budget test in
|
||||||
|
# tests/test-apm-current-hook.sh sums every `"$to" N` and `timeout N` here.
|
||||||
|
if command -v timeout > /dev/null 2>&1; then
|
||||||
|
to=timeout
|
||||||
|
elif command -v gtimeout > /dev/null 2>&1; then
|
||||||
|
to=gtimeout
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# `apm outdated` exits 0 whether or not anything is stale, so the answer has to
|
# Choose the apm once, and use it for every call below (ADR-0034):
|
||||||
# come from its output. ~0.7s against six remote refs; a hung remote must not
|
# 1. the repo's own pin, run as `uv run`, when the project pins apm-cli AND
|
||||||
# hold the session open.
|
# uv is on PATH;
|
||||||
|
# 2. otherwise the `apm` on PATH;
|
||||||
|
# 3. otherwise nothing: exit silently.
|
||||||
#
|
#
|
||||||
# There is no --json/machine-readable flag on `apm outdated` (verified against
|
# "Pins apm-cli" means a pyproject.toml whose text carries a quoted apm-cli
|
||||||
# apm 0.28.0), so the phrase match is forced rather than chosen. Note the
|
# requirement (`"apm-cli==0.39.3"`, `'apm_cli>=0.39'`, ...) AND a uv.lock next
|
||||||
# singular: apm prints "1 outdated dependency found" when exactly one package is
|
# to it. It is a text match, not a TOML parse: the hook must not depend on a
|
||||||
# behind, so matching only "dependencies" would silently miss a one-package
|
# Python being on PATH, and a quoted `apm-cli` requirement string has no other
|
||||||
# drift. tests/test-apm-current-hook.sh pins both spellings against the real apm.
|
# plausible meaning in a pyproject.toml. The uv.lock is required because
|
||||||
outdated_output="$(timeout 60 apm outdated 2>&1)" || exit 0
|
# `--frozen` runs from the lock and has nothing to run without one; a pin with
|
||||||
grep -qE 'outdated dependenc(y|ies) found' <<< "$outdated_output" || exit 0
|
# no lock falls through to PATH apm and its version check.
|
||||||
|
#
|
||||||
stale_count="$(grep -oE '[0-9]+ outdated dependenc(y|ies) found' <<< "$outdated_output" | grep -oE '^[0-9]+' || true)"
|
# uv is only ever invoked as `uv run`, and with `--no-sync`: a plain `uv run`
|
||||||
[[ "$stale_count" =~ ^[0-9]+$ ]] || stale_count="some"
|
# syncs the environment first, which installs packages and can reach the
|
||||||
|
# network, and a SessionStart hook must do neither. `--offline` closes the
|
||||||
|
# remaining gap (uv fetching a Python). Even `--no-sync` creates an empty
|
||||||
|
# .venv when none exists, so a project environment that is missing altogether
|
||||||
|
# (`$UV_PROJECT_ENVIRONMENT`, else <root>/.venv) gets a fixed "not synced"
|
||||||
|
# notice and uv is never called. One that exists but was never synced has no
|
||||||
|
# apm of its own, so `uv run` falls through to whatever apm is on PATH, and the
|
||||||
|
# version check below catches an old one and tells the reader to sync.
|
||||||
|
#
|
||||||
|
# apm_label names the chosen binary in advice text. It selects between fixed
|
||||||
|
# literals and is never built from command output. apm_cmd is never seeded
|
||||||
|
# empty: every branch below either sets it or exits, which keeps its expansions
|
||||||
|
# safe under `set -u` on bash 3.2 (tests/test-vale-wrap.sh scans for this).
|
||||||
|
|
||||||
# Only ever emit fixed text plus a digit-checked count — never interpolate
|
# Only ever emit fixed text plus a digit-checked count — never interpolate
|
||||||
# command output into the JSON, which would need escaping this cannot do safely.
|
# command output into the JSON, which would need escaping this cannot do safely.
|
||||||
@@ -51,6 +74,83 @@ emit() {
|
|||||||
printf '{"hookSpecificOutput":{"hookEventName":"SessionStart","reloadSkills":%s,"additionalContext":"%s"}}\n' "$1" "$2"
|
printf '{"hookSpecificOutput":{"hookEventName":"SessionStart","reloadSkills":%s,"additionalContext":"%s"}}\n' "$1" "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apm_label=""
|
||||||
|
if [[ -f "$project_dir/pyproject.toml" && -f "$project_dir/uv.lock" ]] \
|
||||||
|
&& grep -qiE "[\"']apm[-_.]cli[^a-z0-9_.-]" "$project_dir/pyproject.toml" 2> /dev/null \
|
||||||
|
&& command -v uv > /dev/null 2>&1; then
|
||||||
|
uv_env="${UV_PROJECT_ENVIRONMENT:-$project_dir/.venv}"
|
||||||
|
[[ "$uv_env" == /* ]] || uv_env="$project_dir/$uv_env"
|
||||||
|
if [[ ! -d "$uv_env" ]]; then
|
||||||
|
emit false "This project pins apm with uv but its environment has not been synced, so the apm install was not checked for staleness. Run: uv sync --frozen"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
apm_cmd=(uv run --project "$project_dir" --frozen --no-sync --offline apm)
|
||||||
|
apm_label="uv"
|
||||||
|
elif command -v apm > /dev/null 2>&1; then
|
||||||
|
apm_cmd=(apm)
|
||||||
|
apm_label="path"
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Every apm call below must see the same directory the guard just checked —
|
||||||
|
# `apm outdated` and `apm update` both resolve the lockfile from the cwd.
|
||||||
|
cd "$project_dir" || exit 0
|
||||||
|
|
||||||
|
# apm older than 0.39.2 refuses a lockfile v4 and would then report it as up to
|
||||||
|
# date, so its `outdated` verdict is worthless (ADR-0034). Below the minimum, or
|
||||||
|
# when the version cannot be read at all, say so in a fixed line and skip the
|
||||||
|
# check: a silent pass here is exactly the false "up to date" to avoid. Only the
|
||||||
|
# first dotted triple is taken, and only its digits are compared.
|
||||||
|
#
|
||||||
|
# Returns 0 when new enough, 1 when the version was read and is too old, and 2
|
||||||
|
# when it could not be read (the call failed or timed out, or printed no
|
||||||
|
# version), so the notice can say which.
|
||||||
|
version_ok() {
|
||||||
|
local version_output version
|
||||||
|
version_output="$("$to" 15 "${apm_cmd[@]}" --version 2> /dev/null)" || return 2
|
||||||
|
version="$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+' <<< "$version_output" | head -n 1)"
|
||||||
|
[[ "$version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]] || return 2
|
||||||
|
local -a have=("${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[3]}") need=(0 39 2)
|
||||||
|
local i
|
||||||
|
for i in 0 1 2; do
|
||||||
|
((10#${have[i]} > need[i])) && return 0
|
||||||
|
((10#${have[i]} < need[i])) && return 1
|
||||||
|
done
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
version_ok
|
||||||
|
version_status=$?
|
||||||
|
if [[ $version_status -ne 0 ]]; then
|
||||||
|
if [[ "$apm_label" == "uv" && $version_status -eq 1 ]]; then
|
||||||
|
emit false "\`uv run apm\` is older than apm 0.39.2, so the apm install was not checked for staleness (older apm refuses lockfile v4 and would report it as up to date). The project environment is probably not synced to its pin. Run: uv sync --frozen"
|
||||||
|
elif [[ "$apm_label" == "uv" ]]; then
|
||||||
|
emit false "Could not read the version of \`uv run apm\` (it failed or timed out), so the apm install was not checked for staleness. Check that this works: uv run apm --version, or run: uv sync --frozen"
|
||||||
|
elif [[ $version_status -eq 1 ]]; then
|
||||||
|
emit false "\`apm\` on PATH is older than apm 0.39.2, so the apm install was not checked for staleness (older apm refuses lockfile v4 and would report it as up to date). Upgrade the apm on PATH to 0.39.2 or later, or pin apm-cli in this project with uv."
|
||||||
|
else
|
||||||
|
emit false "Could not read the version of \`apm\` on PATH (it failed or timed out), so the apm install was not checked for staleness. Check that this works: apm --version"
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# `apm outdated` exits 0 whether or not anything is stale, so the answer has to
|
||||||
|
# come from its output. Measured ~0.7s against six remote refs on apm 0.28.0
|
||||||
|
# from PATH, and ~3.6s through `uv run` on 0.39.3; a hung remote must not hold
|
||||||
|
# the session open.
|
||||||
|
#
|
||||||
|
# There is no --json/machine-readable flag on `apm outdated` (verified against
|
||||||
|
# apm 0.28.0 and 0.39.3), so the phrase match is forced rather than chosen. Note the
|
||||||
|
# singular: apm prints "1 outdated dependency found" when exactly one package is
|
||||||
|
# behind, so matching only "dependencies" would silently miss a one-package
|
||||||
|
# drift. tests/test-apm-current-hook.sh pins both spellings against the real apm.
|
||||||
|
outdated_output="$("$to" 60 "${apm_cmd[@]}" outdated 2>&1)" || exit 0
|
||||||
|
grep -qE 'outdated dependenc(y|ies) found' <<< "$outdated_output" || exit 0
|
||||||
|
|
||||||
|
stale_count="$(grep -oE '[0-9]+ outdated dependenc(y|ies) found' <<< "$outdated_output" | grep -oE '^[0-9]+' || true)"
|
||||||
|
[[ "$stale_count" =~ ^[0-9]+$ ]] || stale_count="some"
|
||||||
|
|
||||||
# What to do with the rewritten lock depends on the branch (ADR-0019): on the
|
# What to do with the rewritten lock depends on the branch (ADR-0019): on the
|
||||||
# default branch it is a real update to commit or discard; on a feature branch it
|
# default branch it is a real update to commit or discard; on a feature branch it
|
||||||
# is churn unrelated to the branch and should be discarded. The branch name only
|
# is churn unrelated to the branch and should be discarded. The branch name only
|
||||||
@@ -73,14 +173,21 @@ if [[ -n "$current_branch" && -n "$default_branch" ]]; then
|
|||||||
if [[ "$current_branch" == "$default_branch" ]]; then
|
if [[ "$current_branch" == "$default_branch" ]]; then
|
||||||
lock_advice="this is the default branch, so commit it or discard it deliberately."
|
lock_advice="this is the default branch, so commit it or discard it deliberately."
|
||||||
else
|
else
|
||||||
lock_advice="this is a feature branch, so discard it: git checkout -- apm.lock.yaml && apm install"
|
if [[ "$apm_label" == "uv" ]]; then
|
||||||
|
lock_advice="this is a feature branch, so discard it: git checkout -- apm.lock.yaml && uv run apm install"
|
||||||
|
else
|
||||||
|
lock_advice="this is a feature branch, so discard it: git checkout -- apm.lock.yaml && apm install"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if timeout 300 apm update --yes > /dev/null 2>&1; then
|
manual_update="apm update --yes"
|
||||||
|
[[ "$apm_label" == "uv" ]] && manual_update="uv run apm update --yes"
|
||||||
|
|
||||||
|
if "$to" 300 "${apm_cmd[@]}" update --yes > /dev/null 2>&1; then
|
||||||
emit true "apm install was ${stale_count} package(s) behind the remote default branch and has been refreshed automatically; skills and agents were redeployed and re-scanned. apm.lock.yaml has been rewritten and is now a modified file in the working tree - ${lock_advice}"
|
emit true "apm install was ${stale_count} package(s) behind the remote default branch and has been refreshed automatically; skills and agents were redeployed and re-scanned. apm.lock.yaml has been rewritten and is now a modified file in the working tree - ${lock_advice}"
|
||||||
else
|
else
|
||||||
emit false "apm install is ${stale_count} package(s) behind the remote default branch and the automatic refresh failed. Deployed skills and agents may be stale. Run: apm update --yes"
|
emit false "apm install is ${stale_count} package(s) behind the remote default branch and the automatic refresh failed. Deployed skills and agents may be stale. Run: ${manual_update}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
"hooks": [
|
"hooks": [
|
||||||
{
|
{
|
||||||
"command": "${CLAUDE_PLUGIN_ROOT}/.apm/hooks/check-apm-current.sh",
|
"command": "${CLAUDE_PLUGIN_ROOT}/.apm/hooks/check-apm-current.sh",
|
||||||
"timeout": 380,
|
"timeout": 400,
|
||||||
"type": "command"
|
"type": "command"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -28,7 +28,21 @@ fill() {
|
|||||||
"$1"
|
"$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# In this repo apm is the one pinned in pyproject.toml/uv.lock, run through
|
||||||
|
# scripts/lib/apm.sh as `uv run --project <repo root> --frozen apm` (ADR-0034),
|
||||||
|
# so these tests exercise 0.39.3 and never whatever apm is on PATH. The pin is
|
||||||
|
# a declared dependency here, so a missing uv or an apm below the helper's
|
||||||
|
# minimum FAILS rather than skips: a skip would let `run-tests.sh --strict` go
|
||||||
|
# green without running these tests. Outside this repo (no helper) the PATH
|
||||||
|
# apm is used, and its absence still skips.
|
||||||
need_apm() {
|
need_apm() {
|
||||||
|
if [[ -f "$REPO_ROOT/scripts/lib/apm.sh" ]]; then
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source "$REPO_ROOT/scripts/lib/apm.sh"
|
||||||
|
require_apm_version || fail "the repo-pinned apm is unavailable; run 'uv sync --frozen' at $REPO_ROOT"
|
||||||
|
apm() { run_apm "$@"; }
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
command -v apm >/dev/null 2>&1 || skip "apm CLI not installed"
|
command -v apm >/dev/null 2>&1 || skip "apm CLI not installed"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,10 +187,14 @@ need_apm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# apm behaviour the skill's gotchas rest on (verified against apm 0.28.0)
|
# apm behaviour the skill's gotchas rest on. Verified against apm 0.28.0, then
|
||||||
|
# re-pinned to the repo's 0.39.3 (#271), where three behaviours changed: compile
|
||||||
|
# --target claude writes a CLAUDE.md that imports AGENTS.md, an unquoted applyTo
|
||||||
|
# fails install closed, and compile warns when applyTo matches no file. The
|
||||||
|
# skill's own text still describes 0.28.0 in places; see #271's report.
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
@test "filled scaffold compiles for the Claude target into CLAUDE.md without the description" {
|
@test "filled scaffold compiles for the Claude target: CLAUDE.md imports AGENTS.md, which drops the description" {
|
||||||
need_apm
|
need_apm
|
||||||
make_package
|
make_package
|
||||||
bash "$SCRIPT" my-rule "$ROOT"
|
bash "$SCRIPT" my-rule "$ROOT"
|
||||||
@@ -185,9 +203,11 @@ need_apm() {
|
|||||||
run apm compile --target claude
|
run apm compile --target claude
|
||||||
assert_success
|
assert_success
|
||||||
assert [ -f "$ROOT/CLAUDE.md" ]
|
assert [ -f "$ROOT/CLAUDE.md" ]
|
||||||
run grep -F 'Use type hints.' "$ROOT/CLAUDE.md"
|
run grep -Fx '@AGENTS.md' "$ROOT/CLAUDE.md"
|
||||||
assert_success
|
assert_success
|
||||||
run grep -F 'Python style rules' "$ROOT/CLAUDE.md"
|
run grep -F 'Use type hints.' "$ROOT/AGENTS.md"
|
||||||
|
assert_success
|
||||||
|
run grep -F 'Python style rules' "$ROOT/AGENTS.md"
|
||||||
assert_failure
|
assert_failure
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,17 +241,16 @@ need_apm() {
|
|||||||
assert [ ! -f "$ROOT/CLAUDE.md" ]
|
assert [ ! -f "$ROOT/CLAUDE.md" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "an unquoted applyTo still installs, as a rule with no paths:" {
|
@test "an unquoted applyTo fails install closed and deploys no rule" {
|
||||||
need_apm
|
need_apm
|
||||||
make_package
|
make_package
|
||||||
mkdir -p "$ROOT/.apm/instructions"
|
mkdir -p "$ROOT/.apm/instructions"
|
||||||
printf -- '---\ndescription: x\napplyTo: **/*.py\n---\n# T\n\n- a\n' > "$ROOT/.apm/instructions/bad.instructions.md"
|
printf -- '---\ndescription: x\napplyTo: **/*.py\n---\n# T\n\n- a\n' > "$ROOT/.apm/instructions/bad.instructions.md"
|
||||||
cd "$ROOT"
|
cd "$ROOT"
|
||||||
run apm install
|
run apm install
|
||||||
assert_success
|
|
||||||
assert [ -f "$ROOT/.claude/rules/bad.md" ]
|
|
||||||
run grep -F 'paths:' "$ROOT/.claude/rules/bad.md"
|
|
||||||
assert_failure
|
assert_failure
|
||||||
|
assert_output --partial "Rejected frontmatter in bad.instructions.md"
|
||||||
|
assert [ ! -f "$ROOT/.claude/rules/bad.md" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "compile --validate exits 0 and hides the warnings a real compile prints" {
|
@test "compile --validate exits 0 and hides the warnings a real compile prints" {
|
||||||
@@ -259,5 +278,8 @@ need_apm() {
|
|||||||
assert_success
|
assert_success
|
||||||
assert_output --partial "dry-run"
|
assert_output --partial "dry-run"
|
||||||
refute_output --partial "Failed to parse"
|
refute_output --partial "Failed to parse"
|
||||||
refute_output --partial "Warning"
|
# 0.39 warns when applyTo matches no file, which an empty package always
|
||||||
|
# does; any other warning is a parse or validation finding.
|
||||||
|
run grep -F "Warning" <<< "$(grep -vF "matched no files" <<< "$output")"
|
||||||
|
assert_failure
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,7 @@ Then:
|
|||||||
apm install
|
apm install
|
||||||
```
|
```
|
||||||
|
|
||||||
The entry above is unpinned and tracks the remote's default branch — add `ref: <tag>` to pin a release. Registering the catalogue instead (`apm marketplace add https://git.rkdr.net/Mortis/Holocron.git --name holocron`) gets you the `kyberforge@holocron` short name, but writes to `~/.apm/marketplaces.json` at user scope; the git+path object needs nothing beyond the manifest.
|
The entry above is unpinned and tracks the remote's default branch. To pin a release, add `ref: kyberforge-v<x.y.z>` after `path:`; see [Pinning a plugin to a release](../../README.md#pinning-a-plugin-to-a-release). Registering the catalogue instead (`apm marketplace add https://git.rkdr.net/Mortis/Holocron.git --name holocron`) gets you the `kyberforge@holocron` short name, but writes to `~/.apm/marketplaces.json` at user scope; the git+path object needs nothing beyond the manifest.
|
||||||
|
|
||||||
**Native plugin installs do not work.** This package ships no per-plugin manifest and no flat content directories, so a host that installs it natively gets zero skills, agents and hooks — and Claude Code raises no error while doing it (ADR-0024).
|
**Native plugin installs do not work.** This package ships no per-plugin manifest and no flat content directories, so a host that installs it natively gets zero skills, agents and hooks — and Claude Code raises no error while doing it (ADR-0024).
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: kyberforge
|
name: kyberforge
|
||||||
version: 2.2.1
|
version: 2.3.0
|
||||||
description: Skills and agents for creating, maintaining, and managing an apm plugin marketplace for Claude Code and GitHub Copilot.
|
description: Skills and agents for creating, maintaining, and managing an apm plugin marketplace for Claude Code and GitHub Copilot.
|
||||||
author:
|
author:
|
||||||
name: Mortis
|
name: Mortis
|
||||||
|
|||||||
@@ -87,6 +87,39 @@ and if anything is behind, runs `apm update --yes` and returns `reloadSkills: tr
|
|||||||
session picks up the redeployed content. Rationale, measurements, and the failure modes are in
|
session picks up the redeployed content. Rationale, measurements, and the failure modes are in
|
||||||
ADR-0019.
|
ADR-0019.
|
||||||
|
|
||||||
|
**Which apm it runs.** The hook picks one apm and uses it for every call (ADR-0034):
|
||||||
|
|
||||||
|
1. `uv run --project <root> --frozen --no-sync --offline apm`, when the project pins apm and `uv` is
|
||||||
|
on `PATH`. A pin is a `pyproject.toml` carrying a quoted `apm-cli` requirement plus a `uv.lock`
|
||||||
|
beside it. It is matched as text so the hook needs no Python.
|
||||||
|
2. Otherwise the `apm` on `PATH`.
|
||||||
|
3. Otherwise nothing: it exits 0 silently.
|
||||||
|
|
||||||
|
uv is only ever called as `uv run`, with `--no-sync`, so the hook never installs into the environment
|
||||||
|
and never reaches the network through uv. Even `--no-sync` creates an empty `.venv` when none exists,
|
||||||
|
so before taking the uv path the hook checks that the project environment exists. That is
|
||||||
|
`$UV_PROJECT_ENVIRONMENT` when set, else `<root>/.venv`. If it is missing, the hook prints a fixed
|
||||||
|
"not synced, run `uv sync --frozen`" notice and never calls uv. An environment that exists but was
|
||||||
|
never synced has no apm of its own. `uv run` then falls through to the `PATH` apm, and the version
|
||||||
|
check below catches an old one.
|
||||||
|
|
||||||
|
**It needs `timeout` or `gtimeout`.** Every apm call is bounded. Stock macOS ships no `timeout`, and
|
||||||
|
Homebrew coreutils installs it as `gtimeout`, so the hook uses whichever exists. With neither, it
|
||||||
|
exits 0 silently on every path, before choosing an apm, rather than run an unbounded call.
|
||||||
|
|
||||||
|
**apm older than 0.39.2 is not trusted.** Before the outdated check the hook reads `--version`. If the
|
||||||
|
chosen apm is older than 0.39.2, or its version cannot be read, the hook prints a fixed notice that
|
||||||
|
names the chosen binary and skips the check. The reason is that an older apm refuses a lockfile v4 and
|
||||||
|
would then report the install as up to date. "Too old" and "could not read the version" are separate
|
||||||
|
notices. On the uv path, too old says to run `uv sync --frozen`, and unreadable (the call failed or
|
||||||
|
timed out) says to check `uv run apm --version` or to run `uv sync --frozen`. On the `PATH` path, too old says to upgrade or pin
|
||||||
|
apm, and unreadable says to check `apm --version`.
|
||||||
|
|
||||||
|
**Advice text is fixed.** Every notice is a literal string, and the only variable part is a
|
||||||
|
digit-checked package count. The commands it names follow the chosen binary: `uv run apm install` or
|
||||||
|
`apm install`, and `uv run apm update --yes` or `apm update --yes`. No command output is ever
|
||||||
|
interpolated.
|
||||||
|
|
||||||
**Where it looks for the lockfile.** The hook resolves a project directory as `${CLAUDE_PROJECT_DIR}`
|
**Where it looks for the lockfile.** The hook resolves a project directory as `${CLAUDE_PROJECT_DIR}`
|
||||||
when the host exports it (Claude Code does, for SessionStart hooks) and the current directory
|
when the host exports it (Claude Code does, for SessionStart hooks) and the current directory
|
||||||
otherwise, then exits silently unless that directory holds an `apm.lock.yaml` — which is what makes
|
otherwise, then exits silently unless that directory holds an `apm.lock.yaml` — which is what makes
|
||||||
@@ -97,14 +130,14 @@ Keep the cwd fallback: a host that sets no `CLAUDE_PROJECT_DIR` must still get i
|
|||||||
behaviour, not an unset-variable error.
|
behaviour, not an unset-variable error.
|
||||||
|
|
||||||
**The `timeout` in `hooks.json` must exceed the script's own budget.** The script spends at most
|
**The `timeout` in `hooks.json` must exceed the script's own budget.** The script spends at most
|
||||||
`timeout 60 apm outdated` plus `timeout 300 apm update`; the hook entry declares `timeout: 380`, the
|
15s on `apm --version`, 60s on `apm outdated` and 300s on `apm update`, 375s in all. The hook entry
|
||||||
sum plus a buffer. Set it lower and a slow remote gets the hook SIGKILLed mid-`apm update`, leaving a
|
declares `timeout: 400`, the sum plus a buffer. Set it lower and a slow remote gets the hook
|
||||||
partially redeployed `.claude/skills/` and emitting no notice — precisely the silent failure the hook
|
SIGKILLed mid-`apm update`, leaving a partially redeployed `.claude/skills/` and emitting no notice —
|
||||||
exists to prevent. `tests/test-apm-current-hook.sh` pins the relationship (host timeout > sum of the
|
precisely the silent failure the hook exists to prevent. `tests/test-apm-current-hook.sh` pins the relationship (host timeout > sum of the
|
||||||
script's internal timeouts) rather than the literal, so raising either side alone fails the suite.
|
script's internal timeouts) rather than the literal, so raising either side alone fails the suite.
|
||||||
|
|
||||||
**Staleness is detected by matching apm's summary line, and both spellings count.** `apm outdated`
|
**Staleness is detected by matching apm's summary line, and both spellings count.** `apm outdated`
|
||||||
has no `--json` or otherwise machine-readable output (verified against apm 0.28.0), so the hook
|
has no `--json` or otherwise machine-readable output (verified against apm 0.28.0 and 0.39.3), so the hook
|
||||||
greps its text. apm prints `1 outdated dependency found` in the singular when exactly one package is
|
greps its text. apm prints `1 outdated dependency found` in the singular when exactly one package is
|
||||||
behind and `N outdated dependencies found` otherwise; matching only the plural silently misses a
|
behind and `N outdated dependencies found` otherwise; matching only the plural silently misses a
|
||||||
one-package drift. Because a mocked `apm` would keep a reworded release invisible, the test suite
|
one-package drift. Because a mocked `apm` would keep a reworded release invisible, the test suite
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
---
|
||||||
|
topic: approvals-and-executables
|
||||||
|
source_keys:
|
||||||
|
- apm-v0-39-3-source
|
||||||
|
- apm-v0-39-3-changelog
|
||||||
|
- apm-v0-39-3-docs
|
||||||
|
---
|
||||||
|
|
||||||
|
How apm 0.39.3 decides whether a package's executables may be deployed. Executables means hooks, MCP servers, `bin`, LSP servers, canvas extensions and native plugins. This also covers what `apm approve` writes and which `apm audit --ci` checks enforce it. Read from the v0.39.3 source, CHANGELOG and docs, and not run. Claims are marked **source** or **doc**.
|
||||||
|
|
||||||
|
## The gate and its opt-in
|
||||||
|
|
||||||
|
- **Source:** the executables gate is on when the project `apm.yml` has an `executables:` block (even `{}`) or the deprecated `allowExecutables:` block. **Doc:** a non-empty `executables:` block in org policy also turns it on.
|
||||||
|
- **Doc:** without an opt-in, executables deploy unconditionally. The first project approval prompts that it turns the gate on. A `--user` approval never turns it on.
|
||||||
|
- **Source:** `allowExecutables:` is still read as an alias of `executables.allow`, warned once per run, and migrated on the next approve or deny write.
|
||||||
|
|
||||||
|
## Store shape
|
||||||
|
|
||||||
|
`apm approve` writes the project `apm.yml` under `executables: {allow, deny}` by default. `--user` writes `$APM_HOME/config.json` instead.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
executables:
|
||||||
|
allow:
|
||||||
|
acme/agent-kit:
|
||||||
|
hooks: { .apm/hooks/lint-on-save.json: sha256:<64 hex> }
|
||||||
|
mcp: { kit-docs: sha256:<64 hex> }
|
||||||
|
acme/tools: { bin: true }
|
||||||
|
deny:
|
||||||
|
evil/pkg: { hooks: true, mcp: true, bin: true, canvas: true, lsp: true }
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Source:** each package key is a version-blind identity, such as `owner/repo`, `./pkgs/x` or `local:pkgs/leaf`.
|
||||||
|
- **Source:** values by type:
|
||||||
|
- `hooks` and `mcp` are maps of `item: sha256:<64 hex>`. The item is the package-relative hook file path, or the MCP server name.
|
||||||
|
- `bin`, `lsp` and `canvas` are `true`.
|
||||||
|
- A native plugin gets a single `plugin: sha256:<hex>`.
|
||||||
|
- **Source:** deny entries stay booleans.
|
||||||
|
- **Source:** malformed pins are rejected. A pinned item set to `true`, or a short digest, fails with `expected 'sha256:<64 hex>'`.
|
||||||
|
|
||||||
|
## Grants are version-blind
|
||||||
|
|
||||||
|
- **Source:** an ordinary grant key has its `#version` suffix stripped before matching. So `owner/repo#1.2.0` matches any installed version of `owner/repo`, and `apm approve` folds such keys into the bare identity. This was already true in 0.28.0.
|
||||||
|
- **Source:** the one exception is content-bound local-bundle keys of the form `name#version@sha256:<digest>`, which match only exactly.
|
||||||
|
|
||||||
|
## Type-level versus content-pinned grants
|
||||||
|
|
||||||
|
- **Source/doc:** type-level `hooks: true` and `mcp: true` still deploy any content. Each install warns once: `N executable approval(s) not pinned to content: <pkg> (<type>) ... Upstream changes deploy without review.`
|
||||||
|
- **Source/doc:** `mcp: true` never admits a transitive MCP server.
|
||||||
|
- **Source/doc:** re-running `apm approve <pkg>` converts a type-level grant to pins.
|
||||||
|
- **Source:** a pinned item whose bytes change is parked as `definition-changed` and not deployed. A project pin decides alone; a user pin applies only when the project has none for that item.
|
||||||
|
- **Source (0.38.0, #4688):** a hook pin covers everything the hook deploys:
|
||||||
|
- the hook JSON;
|
||||||
|
- every script it references;
|
||||||
|
- every file the hook-bundle copier deploys from those script roots, such as helpers and nested `package.json`;
|
||||||
|
- the Node module type.
|
||||||
|
|
||||||
|
It does not cover code the hook downloads at run time. Pins written before 0.38 show as changed once, so re-run `apm approve <pkg>`.
|
||||||
|
- **Source:** pinned approvals need apm 0.37 or later on every machine. The first pinned approval prints `Teammates need APM 0.37 or later to read pinned approvals.`, and older clients reject the item form and fail closed.
|
||||||
|
- **Doc (0.39.3):** re-run `apm approve <package>` after reinstalling a package.
|
||||||
|
|
||||||
|
## Transitive MCP servers
|
||||||
|
|
||||||
|
- **Source:** `--trust-transitive-mcp` still exists in 0.39.3 as a per-run install flag that is never saved. **Doc:** it never overrides a deny or a mismatched pin.
|
||||||
|
- **Doc (0.37.0, #3918):** the durable replacement is `apm approve <pkg>`, with `apm.yml` committed.
|
||||||
|
- **Doc (0.39.0):** a server trusted in 0.38 only via the flag is parked and removed on the first plain 0.39 install. Approve it to keep it.
|
||||||
|
|
||||||
|
## Audit checks that enforce approvals (doc)
|
||||||
|
|
||||||
|
| Check | Fails when |
|
||||||
|
|---|---|
|
||||||
|
| `config-consistency` | The lock admits an MCP server that `apm.yml` does not approve: `admitted in apm.lock.yaml but not approved in apm.yml (<reason>); run 'apm approve <pkg>' and re-run 'apm install'`. Admission is re-evaluated from `apm.yml` and org policy only, never from the lock or the user store. |
|
||||||
|
| `hook-approval-pins` | A recorded deployed hook file no longer matches its pin; or an unrecorded file sits at a withheld package's hook path; or a merged-config entry matches such a package's hook with no ownership record. |
|
||||||
|
| `exec-status-current` | A recorded `exec_status` differs from the current gate decision. Claude `settings.json` hooks are included. Not evaluated under `--no-policy`. |
|
||||||
|
| `local-bundle-hooks` | A local-bundle hook entry was edited or is unrecorded. Needs the `.claude/apm-hooks.json` record. |
|
||||||
|
|
||||||
|
`apm install --frozen` fails on the same pin mismatches.
|
||||||
|
|
||||||
|
## `apm approve` and `apm deny`
|
||||||
|
|
||||||
|
- **Doc:** flags are `--pending`, `--all`, `--recommended`, `--list`, `--user`/`-g`.
|
||||||
|
- **Doc:** it exits 1 when:
|
||||||
|
- a requested package is not installed or is refused;
|
||||||
|
- the first-approval prompt is declined;
|
||||||
|
- a blocking org policy applies;
|
||||||
|
- installed files differ from `apm.lock.yaml`.
|
||||||
|
- **Source:** `apm deny [PACKAGES] --user/-g` writes deny entries.
|
||||||
@@ -2,35 +2,151 @@
|
|||||||
topic: cli-reference
|
topic: cli-reference
|
||||||
source_keys:
|
source_keys:
|
||||||
- context7-microsoft-apm
|
- context7-microsoft-apm
|
||||||
|
- apm-v0-39-3-source
|
||||||
|
- apm-v0-39-3-docs
|
||||||
---
|
---
|
||||||
|
|
||||||
|
The command surface as of apm 0.39.3, read from source (`cli.py` and `commands/`) and the reference docs. Version-specific changes are summarized in `migration-0-28-to-0-39.md`.
|
||||||
|
|
||||||
|
## Command list (0.39.3, source)
|
||||||
|
|
||||||
|
`approve`, `audit`, `auth`, `cache`, `compile`, `config`, `deny`, `deps`, `doctor`, `experimental`, `export-patch`, `find`, `init`, `install`, `lifecycle`, `list`, `lock`, `marketplace`, `mcp`, `outdated`, `pack`, `plugin`, `policy`, `preview`, `prune`, `publish`, `run`, `runtime`, `search`, `self-update`, `targets`, `uninstall`, `unpack`, `update`, `view`.
|
||||||
|
|
||||||
|
There are also two hidden entries: `discover` (use the documented `apm init --discover` form) and `info`, an alias of `view`.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
apm install [PACKAGE_REF...] [OPTIONS]
|
apm install [PACKAGE_REF...] [OPTIONS]
|
||||||
```
|
```
|
||||||
|
|
||||||
With no arguments, resolves and installs everything declared in `apm.yml` against `apm.lock.yaml`. Explicit `PACKAGE_REF` arguments (e.g. `acme/internal-tools#^1.0.0`) install and add that dependency. `apm install --update` re-resolves and accepts new upstream content even when it doesn't match the recorded lockfile hash (see troubleshooting). `apm install --target agent-skills` generates a vendor-neutral output directory for IDE-agnostic tool support instead of a harness-specific one.
|
- With no arguments, apm installs everything declared in `apm.yml` against `apm.lock.yaml`.
|
||||||
|
- Naming a `PACKAGE_REF` installs that package and adds it as a dependency.
|
||||||
|
- `--update` re-resolves the dependencies and accepts new upstream content.
|
||||||
|
- `--target agent-skills` produces a vendor-neutral output directory.
|
||||||
|
|
||||||
|
Frozen-install behaviour is in `lockfile-and-compatibility.md`.
|
||||||
|
|
||||||
|
Options (doc):
|
||||||
|
|
||||||
|
| Group | Options |
|
||||||
|
|---|---|
|
||||||
|
| Resolution and lockfile | `--update`, `--frozen/--no-frozen`, `--refresh`, `--accept-ref-change` |
|
||||||
|
| Run control | `--dry-run`, `--force`, `-v`, `--dev` |
|
||||||
|
| Scope and targets | `--root DIR`, `-t/--target`, `--runtime`, `--exclude`, `--only apm\|mcp`, `-g/--global`, `--legacy-skill-paths` |
|
||||||
|
| Policy and security | `--policy SOURCE`, `--no-policy`, `--audit off\|warn\|block`, `--no-audit` |
|
||||||
|
| Trust | `--trust-transitive-mcp`, `--trust-bin/--no-trust-bin` |
|
||||||
|
| Network and transport | `--allow-insecure`, `--allow-insecure-host`, `--parallel-downloads N`, `--ssh`, `--https`, `--allow-protocol-fallback`, `--auth-first` |
|
||||||
|
| Skill selection | `--skill`, `--as` |
|
||||||
|
| MCP | `--mcp`, `--transport`, `--url`, `--env`, `--header`, `--mcp-version`, `--registry` |
|
||||||
|
|
||||||
|
Exit codes (doc):
|
||||||
|
|
||||||
|
| Code | Meaning |
|
||||||
|
|---|---|
|
||||||
|
| 0 | Success or preview |
|
||||||
|
| 1 | Install failure. This includes frozen violations, and any reported error even with `--force`. |
|
||||||
|
| 2 | Usage error: no target detectable, `--ssh` with `--https`, `--frozen` with `--update`, or `--root` with `--global`. |
|
||||||
|
|
||||||
|
## Update and outdated
|
||||||
|
|
||||||
|
```bash
|
||||||
|
apm update [PACKAGES] [--yes] [--dry-run] [--verbose] [--global] [--force] [--target ...]
|
||||||
|
apm outdated [-g] [-v] [-j N]
|
||||||
|
```
|
||||||
|
|
||||||
|
**`apm update`** (source):
|
||||||
|
- `--check` is deprecated (doc). Use `--dry-run`, or `self-update --check` instead.
|
||||||
|
- Run outside an `apm.yml` project, bare `apm update` forwards to `self-update` with a warning (doc).
|
||||||
|
- `apm deps update` is deprecated in favour of `apm update`.
|
||||||
|
|
||||||
|
**`apm outdated`** (source):
|
||||||
|
- Options are `--global`, `--verbose` and `--parallel-checks/-j N` (default 4; 0 means sequential).
|
||||||
|
- There is no `--json` and no package filter.
|
||||||
|
- **Output:** a "Dependency Status" table with columns Package, Current, Wanted (only when registry rows exist), Latest, Status and Source.
|
||||||
|
- The summary line is `<N> outdated dependency found` or `<N> outdated dependencies found`, or `Some dependencies could not be checked`.
|
||||||
|
- Statuses in code are `up-to-date`, `outdated`, `unknown`, `origin-conflict`, `access-denied` and `not-comparable`.
|
||||||
|
- With `-v`, the table adds the newer tags.
|
||||||
|
- **Exit codes:** 1 on `origin-conflict` or `access-denied` (source); the docs also give 1 for no lockfile in scope. Outdated or unknown rows still exit 0.
|
||||||
|
- Local and Artifactory dependencies are skipped, and the command is read-only.
|
||||||
|
|
||||||
|
## Audit
|
||||||
|
|
||||||
|
```bash
|
||||||
|
apm audit # scan deployed files for hidden Unicode
|
||||||
|
apm audit --ci # CI gate: lockfile consistency, approvals, drift replay, policy
|
||||||
|
apm audit --file <path> # scan an arbitrary file
|
||||||
|
apm audit --ci -f json -o r.json
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Options:** `--file`, `--strip`, `--dry-run`, `--no-drift`, `-v`, `--ci`, `--policy`, `--no-policy`, `--no-cache`, `--no-fail-fast`, `-f/--format text|json|sarif|markdown`, `-o/--output PATH`.
|
||||||
|
- When `-o` is given without `-f`, the format is inferred from the file extension.
|
||||||
|
- `markdown` is not allowed with `--ci`.
|
||||||
|
- **Exit codes in content-scan mode** (source docstring): 0 clean, 1 critical, 2 warnings only. The docs add 3 for configuration or infrastructure errors.
|
||||||
|
- **Exit codes in `--ci` mode:** 0 when every check passes, 1 when any fails.
|
||||||
|
- **Text output in `--ci` mode** (source):
|
||||||
|
- On success: `All <M> check(s) passed`.
|
||||||
|
- On failure: `<N> of <M> check(s) failed`, with each failure as `<check>: <message>` followed by detail lines.
|
||||||
|
- M varies with which checks apply; the list is in `migration-0-28-to-0-39.md`.
|
||||||
|
- **Lockfile message** (source): when `apm.yml` declares dependencies but there is no lock, the detail reads `apm.yml declares dependencies but apm.lock.yaml is absent`.
|
||||||
|
- Fail-fast is the default.
|
||||||
|
|
||||||
|
See `testing-and-validation.md` for CI wiring.
|
||||||
|
|
||||||
|
## Approve, deny and export-patch
|
||||||
|
|
||||||
|
```bash
|
||||||
|
apm approve [PACKAGES] [--pending|--all|--recommended|--list] [--user|-g]
|
||||||
|
apm deny [PACKAGES] [--user|-g]
|
||||||
|
apm export-patch [--out DIR] [--dry-run] [-v]
|
||||||
|
```
|
||||||
|
|
||||||
|
- Approvals are covered in `approvals-and-executables.md`.
|
||||||
|
- **`export-patch` (doc):**
|
||||||
|
- It writes one `patches/<pkg>@<ref>.patch` per package, ready for `git apply`, covering only files that were deployed verbatim.
|
||||||
|
- It needs a lockfile and a populated `apm_modules/`, and it runs cache-only.
|
||||||
|
- It exits 0 on success, including when there is nothing to export. It exits 1 on a missing manifest or lock, a cold cache, or an invalid `--out`.
|
||||||
|
|
||||||
## Compile
|
## Compile
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
apm compile
|
apm compile [-t TARGET|--all] [--root DIR] [-o PATH] [--clean] [--validate] [--dry-run] [--watch] [-g]
|
||||||
```
|
```
|
||||||
|
|
||||||
Generates per-target output (Claude, Copilot, etc.) from the vendor-neutral `.apm/` primitive source tree, per the `compilation:` block in `apm.yml`.
|
- `apm compile` generates root context files (`AGENTS.md`, `CLAUDE.md`, `GEMINI.md`) from instructions.
|
||||||
|
- Other options: `--single-agents`, `--chatmode`, `--no-links`, `--with-constitution/--no-constitution`, `--local-only`, `--force-instructions` (alias `--no-dedup`) and `--legacy-skill-paths`.
|
||||||
|
- It exits 1 when org policy blocks a recorded package.
|
||||||
|
- A hand-authored root `CLAUDE.md` or `AGENTS.md` is never overwritten (source). For the 0.38/0.39 Claude layout, see `instructions-target-mapping.md`.
|
||||||
|
|
||||||
## Pack
|
## Pack
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
apm pack --dry-run # resolve and print; do not write
|
apm pack --dry-run # resolve and print; do not write
|
||||||
apm pack --offline # cached refs only
|
apm pack --check-versions --check-clean --dry-run
|
||||||
apm pack --include-prerelease # allow pre-release tags
|
apm pack --format plugin # Claude Code plugin bundle (alias)
|
||||||
apm pack -v # per-entry resolution detail
|
apm pack --marketplace=claude --json
|
||||||
apm pack --marketplace=claude --json # JSON output for CI pipelines
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Bundles a producer package into a distributable artifact.
|
- **Options (source):**
|
||||||
|
- `--claude-plugin`
|
||||||
|
- `--format plugin|agent-plugin|claude|claude-plugin|apm`. With no flag the default is `claude-plugin`. `plugin` is an alias for the Claude Code plugin bundle.
|
||||||
|
- `--target/-t`, which is deprecated and informational only.
|
||||||
|
- `--archive` (default `.zip`) with `--archive-format zip|tar.gz`.
|
||||||
|
- `-o`, `--dry-run`, `--force`, `-v`, `--offline`, `--include-prerelease`.
|
||||||
|
- `--check-versions`, `--check-clean`, `--strict-metadata`.
|
||||||
|
- `-m/--marketplace`, `--marketplace-path FORMAT=PATH`, `--json`, `--legacy-skill-paths`.
|
||||||
|
- **Exit codes (source):**
|
||||||
|
|
||||||
|
| Code | Meaning |
|
||||||
|
|---|---|
|
||||||
|
| 0 | Success |
|
||||||
|
| 1 | Build or runtime error |
|
||||||
|
| 2 | Usage error |
|
||||||
|
| 3 | `--check-versions` misalignment |
|
||||||
|
| 4 | `--check-clean` drift |
|
||||||
|
| 5 | `--strict-metadata` failure |
|
||||||
|
|
||||||
|
- `--check-clean` is read-only.
|
||||||
|
|
||||||
## Publish
|
## Publish
|
||||||
|
|
||||||
@@ -39,17 +155,17 @@ apm publish --package acme/my-skill --dry-run -v
|
|||||||
apm publish --package acme/my-skill
|
apm publish --package acme/my-skill
|
||||||
```
|
```
|
||||||
|
|
||||||
Publishes a producer package (root containing `apm.yml`, `.apm/`, and optionally a `registries:` block) to a registry. Always dry-run with `-v` first to see resolution detail before publishing for real.
|
`apm publish` sends a producer package to a registry. Always dry-run with `-v` first.
|
||||||
|
|
||||||
## Runtime management
|
## Runtime management
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
apm runtime setup copilot # install with APM defaults
|
apm runtime setup copilot
|
||||||
apm runtime setup codex --version 0.20.0 # pinned version
|
apm runtime setup codex --version 0.20.0
|
||||||
apm runtime setup llm --vanilla # skip APM-managed config
|
apm runtime setup llm --vanilla
|
||||||
apm runtime list # what's installed
|
apm runtime list
|
||||||
apm runtime status # which runtime `apm run` will pick
|
apm runtime status
|
||||||
apm runtime remove gemini -y # uninstall without prompting
|
apm runtime remove gemini -y
|
||||||
```
|
```
|
||||||
|
|
||||||
## Run
|
## Run
|
||||||
@@ -58,42 +174,28 @@ apm runtime remove gemini -y # uninstall without prompting
|
|||||||
apm run <script> [--param key=value]
|
apm run <script> [--param key=value]
|
||||||
```
|
```
|
||||||
|
|
||||||
Executes a named script defined under `scripts:` in `apm.yml`, with `--param` substituting values into the script's parameters (used, for example, when the script wraps a Gemini CLI invocation).
|
`apm run` executes a named script from `scripts:` in `apm.yml`. It is experimental.
|
||||||
|
|
||||||
## Audit (validation)
|
## Marketplace and plugin scaffolding
|
||||||
|
|
||||||
```bash
|
|
||||||
apm audit # local: scan deployed files for hidden Unicode
|
|
||||||
apm audit --ci # CI gate: lockfile consistency + drift replay + policy
|
|
||||||
apm audit --file <path> # standalone: scan an arbitrary file
|
|
||||||
```
|
|
||||||
|
|
||||||
See `testing-and-validation.md` for CI wiring and exit-code behavior.
|
|
||||||
|
|
||||||
## Marketplace
|
|
||||||
|
|
||||||
```bash
|
|
||||||
apm marketplace init # add the marketplace: block to apm.yml
|
|
||||||
apm marketplace check # validate every listed package ref resolves
|
|
||||||
apm marketplace package add <path> --name <n> # register a local package into the marketplace
|
|
||||||
apm marketplace add <source> [--name <n>] # register a marketplace as a consumer (see marketplace-and-registries.md for source forms)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Plugin scaffolding
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
apm marketplace init
|
||||||
|
apm marketplace check
|
||||||
|
apm marketplace package add <path> --name <n>
|
||||||
|
apm marketplace add <source> [--name <n>]
|
||||||
apm plugin init <name> --yes
|
apm plugin init <name> --yes
|
||||||
```
|
```
|
||||||
|
|
||||||
Scaffolds a new package's `apm.yml` + `.apm/` skeleton in the current directory.
|
- Marketplace subcommands (source): `add`, `list`, `browse`, `update`, `remove`, `validate`, `init`, `migrate`, `check`, `audit`, `outdated`, and `package add|set|remove`.
|
||||||
|
- `plugin` has only `init`.
|
||||||
|
- `apm init --plugin` and `apm init --marketplace` were removed in 0.37 and exit 2.
|
||||||
|
|
||||||
## Config
|
## Config
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
apm config set <key> <value>
|
apm config set <key> <value>
|
||||||
apm config get <key>
|
apm config get <key>
|
||||||
|
apm config list
|
||||||
apm config unset <key>
|
apm config unset <key>
|
||||||
apm experimental enable registries # required before registry.* config takes effect
|
apm experimental enable registries
|
||||||
```
|
```
|
||||||
|
|
||||||
Used for workstation-level settings such as private registry URLs/tokens (see `marketplace-and-registries.md`).
|
|
||||||
@@ -3,6 +3,9 @@ topic: hooks-primitive-schema
|
|||||||
source_keys:
|
source_keys:
|
||||||
- context7-microsoft-apm
|
- context7-microsoft-apm
|
||||||
- apm-github-repo
|
- apm-github-repo
|
||||||
|
- apm-v0-39-3-source
|
||||||
|
- apm-v0-39-3-changelog
|
||||||
|
- apm-v0-39-3-docs
|
||||||
---
|
---
|
||||||
|
|
||||||
## File location, naming, and format — confirmed `.json`, not assumed
|
## File location, naming, and format — confirmed `.json`, not assumed
|
||||||
@@ -57,3 +60,25 @@ Differences from the Claude/source shape: flat arrays (no nested matcher-group w
|
|||||||
- **Dropping a target from `apm.yml`'s `targets:` list does not auto-clean its merged hook entries** unless `apm install`/reconcile logic explicitly walks the complement set (`reconcile_dropped_targets`) — a real, documented gap the code works around rather than a design guarantee; relying on "just remove the target and hooks disappear" is not safe without a fresh `apm install`.
|
- **Dropping a target from `apm.yml`'s `targets:` list does not auto-clean its merged hook entries** unless `apm install`/reconcile logic explicitly walks the complement set (`reconcile_dropped_targets`) — a real, documented gap the code works around rather than a design guarantee; relying on "just remove the target and hooks disappear" is not safe without a fresh `apm install`.
|
||||||
- **Event-casing mismatches are warnings, not errors** — a hook authored with the wrong casing for a target and no applicable rename mapping will silently not fire at runtime; APM only logs a warning at install time, it does not block the install or refuse to deploy the file.
|
- **Event-casing mismatches are warnings, not errors** — a hook authored with the wrong casing for a target and no applicable rename mapping will silently not fire at runtime; APM only logs a warning at install time, it does not block the install or refuse to deploy the file.
|
||||||
- **No dedicated `Hook`/`HookPrimitive` validation dataclass** exists comparable to `Instruction.validate()` — validation is distributed across `_validate_copilot_payload` (Copilot-shape-specific) and general JSON-parseability checks, not a single primitive-level contract. This mirrors the same "no independent validation model" gap already documented for the agent primitive.
|
- **No dedicated `Hook`/`HookPrimitive` validation dataclass** exists comparable to `Instruction.validate()` — validation is distributed across `_validate_copilot_payload` (Copilot-shape-specific) and general JSON-parseability checks, not a single primitive-level contract. This mirrors the same "no independent validation model" gap already documented for the agent primitive.
|
||||||
|
|
||||||
|
## Changes through 0.39.3 (source, CHANGELOG and docs; not run)
|
||||||
|
|
||||||
|
The sections above were written against 0.28.0. The merge into `.claude/settings.json` is still the mechanism in 0.39.3. The following changed:
|
||||||
|
|
||||||
|
- **Filename routing is gone (0.36.0, #3613).** Filenames such as `*-<target>-hooks.json` and `hooks-<target>.json` no longer send a hook to one target only, so every hook file reaches every targeted harness.
|
||||||
|
- To limit a hook to Claude, ship it in a package whose `apm.yml` sets `targets: [claude]`, or narrow the dependency with object-form `targets:`.
|
||||||
|
- If dropping the routing would hand a target a file the old name kept from it, install fails for that package and names the file.
|
||||||
|
- **Event names.** `SessionStart` and `sessionStart` both map to `SessionStart` for Claude. Copilot events that have a Claude equivalent are written to `.claude/settings.json` under the Claude name. For Copilot, `SessionStart` becomes `sessionStart`.
|
||||||
|
- **Where ownership is recorded.** apm marks its entries with `_apm_source` while it works. On write, it moves those markers into a sidecar, `.claude/apm-hooks.json`, so `settings.json` itself carries no apm markers. On reinstall the markers are read back from the sidecar.
|
||||||
|
- **Edited entries are kept (0.38.1, 0.39.0).**
|
||||||
|
- When a user edits a deployed entry, apm keeps the edited copy and writes the deployed entry beside it, with a warning. A byte-identical user copy does not count as an edit.
|
||||||
|
- Install exits 1 when an edited hook file or script blocks new content.
|
||||||
|
- Uninstall refuses when a package's entry was edited or its sidecar record is missing.
|
||||||
|
- **Ordering.** Entries merge in full-install order. Do not rely on order across packages. Your own entries never move.
|
||||||
|
- **Approval.** When the executables gate is on, a hook deploys only under a grant: type-level `hooks: true`, or a per-file content pin. A pin covers the hook JSON and every file deployed with it. See `approvals-and-executables.md`.
|
||||||
|
- **Command safety (0.39.0, #5600).** Only hook commands that stay inside the package and use no shell expansion are deployed. Shell expansion means `$(...)`, backticks, `eval`, here-docs and subshells.
|
||||||
|
- **Settings-file lifecycle.**
|
||||||
|
- A `.claude/settings.json` that apm created is deleted once its last entry leaves.
|
||||||
|
- An emptied one that apm has no creation record for is kept, with a warning.
|
||||||
|
- A hook config that is not valid JSON is never rewritten. A merge into it exits 1; a cleanup-only run warns and exits 0.
|
||||||
|
- **Audit.** These checks cover merged Claude hook entries: `hook-approval-pins`, `exec-status-current`, `local-bundle-hooks`, `content-integrity` and `drift`. `drift` compares only apm-owned entries. `apm install --frozen` also fails when an apm-managed merged entry was edited.
|
||||||
@@ -2,32 +2,85 @@
|
|||||||
topic: installation
|
topic: installation
|
||||||
source_keys:
|
source_keys:
|
||||||
- context7-microsoft-apm
|
- context7-microsoft-apm
|
||||||
|
- apm-v0-39-3-docs
|
||||||
|
- apm-v0-39-3-source
|
||||||
|
- pypi-apm-cli
|
||||||
|
- apm-cli-0-39-3-uv-experiments
|
||||||
---
|
---
|
||||||
|
|
||||||
## Quick install (recommended)
|
## Install methods (0.39.3 docs)
|
||||||
|
|
||||||
A one-line install script auto-detects the platform, downloads the latest binary, and configures the system `PATH`:
|
- Quick install script. It auto-detects the platform, downloads the release binary and configures `PATH`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -sSL https://aka.ms/apm-unix | sh
|
curl -sSL https://aka.ms/apm-unix | sh
|
||||||
|
```
|
||||||
|
|
||||||
|
On Windows use `irm https://aka.ms/apm-windows | iex`.
|
||||||
|
- Homebrew: `brew install apm`, from the core formula. The old `microsoft/apm` tap is migrated.
|
||||||
|
- WinGet: `winget install --id Microsoft.APM --exact --source winget`.
|
||||||
|
- Scoop: `scoop install apm`.
|
||||||
|
- pip: `python3 -m pip install apm-cli`. Since 0.36.0 this needs Python 3.11 or later, and the same floor applies to any Python-based install.
|
||||||
|
- Manual binary: download the release archive and put the binary on `PATH`. Prebuilt binaries cover macOS, Linux and Windows on x86_64 and ARM64.
|
||||||
|
|
||||||
|
The installation doc mentions neither pipx nor uv. If no prebuilt binary fits, the installer script falls back to `pip install --user apm-cli`.
|
||||||
|
|
||||||
|
`apm self-update` upgrades a script install. The installer refuses to overwrite a copy owned by Homebrew or pip.
|
||||||
|
|
||||||
|
The docs give glibc 2.28 as the Linux minimum for the binary, but the 0.32.0 installer notes say 2.38. This conflict is unresolved; use pip if in doubt.
|
||||||
|
|
||||||
|
## Package facts (PyPI and source)
|
||||||
|
|
||||||
|
- The package is `apm-cli`, and its console entry point is `apm = apm_cli.entrypoint:main`. It needs Python 3.11 or later.
|
||||||
|
- 0.39.3 was released 2026-12-01 as a wheel and an sdist, and 0.39.2 on 2026-11-30. Neither is yanked.
|
||||||
|
- Runtime dependencies:
|
||||||
|
- click, colorama, pyyaml, requests, truststore
|
||||||
|
- python-frontmatter, llm, llm-github-models
|
||||||
|
- toml, tomlkit, rich, rich-click
|
||||||
|
- watchdog, GitPython, ruamel.yaml, filelock
|
||||||
|
- websockets (below 17)
|
||||||
|
|
||||||
|
A full resolve came to about 63 packages.
|
||||||
|
|
||||||
|
## Pinning a version
|
||||||
|
|
||||||
|
- Script: `curl -sSL https://aka.ms/apm-unix | sh -s -- @v1.2.3`, or set `VERSION=v1.2.3`. On Windows, set `$env:VERSION` before the `irm` line.
|
||||||
|
- pip: `pip install apm-cli==0.39.3`.
|
||||||
|
- GitHub Action: `microsoft/apm-action@v1` with `setup-only: 'true'` and `apm-version: '<version>'`.
|
||||||
|
- The docs give no pinning method for Homebrew, WinGet or Scoop.
|
||||||
|
- Upstream advice: pin a **minimum** apm in CI rather than an exact one. Choose a release that reads your lockfile format, which means 0.39.2 or later for v4 locks rewritten by 0.39.2. apm has no manifest field that enforces a minimum. See `lockfile-and-compatibility.md`.
|
||||||
|
|
||||||
|
## Per-project pin with uv (tested, not upstream-documented)
|
||||||
|
|
||||||
|
apm's docs do not cover this. It was tested with uv 0.11.24 in a throwaway project outside any repo.
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[project]
|
||||||
|
name = "<project>"
|
||||||
|
version = "0.0.0"
|
||||||
|
requires-python = ">=3.11"
|
||||||
|
dependencies = []
|
||||||
|
|
||||||
|
[tool.uv]
|
||||||
|
package = false
|
||||||
|
|
||||||
|
[dependency-groups]
|
||||||
|
dev = ["apm-cli==0.39.3"]
|
||||||
```
|
```
|
||||||
|
|
||||||
On Windows, the installer adds both the current directory and the bin directory to `PATH`, so it works from native shells, Git Bash, and process APIs alike.
|
- With no `[build-system]`, uv installs only the dependencies and never builds the project. `package = false` keeps it that way even if a build system is added later. `uv sync` installs the `dev` group by default.
|
||||||
|
- `uv run apm --version` reported 0.39.3. The committed `uv.lock` hashes apm-cli and every transitive dependency.
|
||||||
## Customizing the install
|
- **Offline behaviour:**
|
||||||
|
- `uv run --frozen --offline apm ...` worked once the uv cache was warm, even with no `.venv`.
|
||||||
- **Pin a specific version**: append `@vX.Y.Z` to the piped script arguments, e.g. `curl -sSL https://aka.ms/apm-unix | sh -s -- @v1.2.3`.
|
- It failed with an empty cache, because wheels cannot be downloaded offline.
|
||||||
- **Custom install directory**: set `APM_INSTALL_DIR` on the piped script's command, e.g. `curl -sSL https://aka.ms/apm-unix | APM_INSTALL_DIR=$HOME/.local/bin sh`.
|
- So the first sync on a machine needs the network.
|
||||||
- **Air-gapped / GitHub Enterprise mirror**: set `GITHUB_URL` and `VERSION` env vars against a local `install.sh`, e.g. `GITHUB_URL=https://github.corp.com VERSION=v1.2.3 sh install.sh`.
|
- **Rejected alternatives:**
|
||||||
|
- `uvx apm-cli@<v>` pins only apm-cli: transitive dependencies float and nothing is locked. A cache warmed by `uv add` also did not satisfy `uvx --offline`.
|
||||||
## Alternative install methods
|
- `uv tool install` is machine-global, the same drift problem as pipx.
|
||||||
|
|
||||||
- **pip**: `pip install apm-cli` — requires Python 3.10 or higher.
|
|
||||||
- **Manual binary**: download the platform-specific archive from the GitHub releases page, extract it, move the binary to a permanent directory, and add that directory to `PATH`.
|
|
||||||
|
|
||||||
## Installing agent runtimes
|
## Installing agent runtimes
|
||||||
|
|
||||||
APM itself doesn't execute agents, but it can install and manage the runtimes that do, via `apm runtime setup <name>`:
|
apm does not run agents itself, but it can install and manage the runtimes that do:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
apm runtime setup copilot # recommended default
|
apm runtime setup copilot # recommended default
|
||||||
@@ -36,4 +89,4 @@ apm runtime setup gemini
|
|||||||
apm runtime setup llm
|
apm runtime setup llm
|
||||||
```
|
```
|
||||||
|
|
||||||
Installing GitHub Copilot CLI through APM pulls it from the public npm registry and requires Node.js v22+ and npm v10+; no authentication is needed for the install step itself. Use `apm runtime list` to see which runtimes are currently installed and which one `apm run` will pick by default.
|
Installing the GitHub Copilot CLI through apm pulls it from the public npm registry. It needs Node.js 22 or later and npm 10 or later. `apm runtime list` shows which runtimes are installed and which one `apm run` picks.
|
||||||
@@ -6,6 +6,7 @@ source_keys:
|
|||||||
- claude-code-memory-docs
|
- claude-code-memory-docs
|
||||||
- cursor-rules-docs
|
- cursor-rules-docs
|
||||||
- github-copilot-custom-instructions-docs
|
- github-copilot-custom-instructions-docs
|
||||||
|
- apm-v0-39-3-changelog
|
||||||
---
|
---
|
||||||
|
|
||||||
Surprising behaviours and source contradictions for the instructions primitive. "Verified" means observed with the installed apm 0.28.0 in a throwaway directory outside the repo. Everything else is stated as sourced or inferred.
|
Surprising behaviours and source contradictions for the instructions primitive. "Verified" means observed with the installed apm 0.28.0 in a throwaway directory outside the repo. Everything else is stated as sourced or inferred.
|
||||||
@@ -78,7 +79,7 @@ An earlier version of this topic's schema file described missing `description` a
|
|||||||
- Runtime behaviour of Windsurf, Kiro and Antigravity on the emitted frontmatter; no downstream docs were fetched.
|
- Runtime behaviour of Windsurf, Kiro and Antigravity on the emitted frontmatter; no downstream docs were fetched.
|
||||||
- Windsurf user-scope global rules.
|
- Windsurf user-scope global rules.
|
||||||
- The Context7 step was unavailable (invalid API key), so the registry carries no fresh Context7 pull. Doc pages were summarised by a smaller model before reaching this file and can be lossy.
|
- The Context7 step was unavailable (invalid API key), so the registry carries no fresh Context7 pull. Doc pages were summarised by a smaller model before reaching this file and can be lossy.
|
||||||
- Apm versions other than 0.28.0 were not tested.
|
- Apm versions other than 0.28.0 were not tested. 0.38.0 and 0.39.0 changed the Claude layout, moving `**`- and directory-scoped rules into `AGENTS.md` once compiled. The `.claude/rules/` items above may therefore not hold on 0.39.x. See `instructions-target-mapping.md`, "Claude layout in 0.38 and later", and `migration-0-28-to-0-39.md`.
|
||||||
|
|
||||||
## What belongs in an instruction body
|
## What belongs in an instruction body
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,27 @@ source_keys:
|
|||||||
- claude-code-memory-docs
|
- claude-code-memory-docs
|
||||||
- github-copilot-custom-instructions-docs
|
- github-copilot-custom-instructions-docs
|
||||||
- cursor-rules-docs
|
- cursor-rules-docs
|
||||||
|
- apm-v0-39-3-source
|
||||||
|
- apm-v0-39-3-changelog
|
||||||
|
- apm-v0-39-3-docs
|
||||||
---
|
---
|
||||||
|
|
||||||
What each target receives from an instruction file, at install time (native per-file deploy) and at compile time (folded into a root context file). Verified against apm 0.28.0 source and throwaway installs unless marked otherwise. Field syntax of the source file is in `instructions-primitive-schema.md`.
|
What each target receives from an instruction file, at install time (native per-file deploy) and at compile time (folded into a root context file). Verified against apm 0.28.0 source and throwaway installs unless marked otherwise. Field syntax of the source file is in `instructions-primitive-schema.md`.
|
||||||
|
|
||||||
|
## Claude layout in 0.38 and later (source and CHANGELOG; not run)
|
||||||
|
|
||||||
|
The install table below is the 0.28.0 behaviour, where every Claude instruction went to `.claude/rules/`. Two later releases changed that.
|
||||||
|
|
||||||
|
- **0.38.0:** Claude instructions scoped to `**`, unscoped, scoped to `**/*`, or scoped to exactly one literal `dir/**` glob move into `AGENTS.md`, which `CLAUDE.md` imports. Run `apm install` and then `apm compile`. Any other glob stays a path-scoped rule in `.claude/rules/`, including file-type globs, wildcard directories and lists.
|
||||||
|
- **0.39.0 (#5394):** install-only projects keep the 0.37 `.claude/rules/` layout. A routed instruction is dropped from `.claude/rules/` only once a compiled `AGENTS.md` that Claude loads already carries its exact scope and body. Until then, install keeps the rule and asks for `apm compile`.
|
||||||
|
- **Blockers.** These keep every instruction in `.claude/rules/`, with a warning:
|
||||||
|
- a hand-authored root `CLAUDE.md` without an `@AGENTS.md` (or `@./AGENTS.md`) import;
|
||||||
|
- a hand-authored root `AGENTS.md` without `compilation.agents_md.mode: managed_section` and a single pair of `<!-- apm:start -->`/`<!-- apm:end -->` markers;
|
||||||
|
- a symlinked root `AGENTS.md`.
|
||||||
|
- **Hand-authored files are protected.** A root `AGENTS.md`, `CLAUDE.md` or `GEMINI.md` without the apm-generated marker near the top is never overwritten. `--clean` never deletes an unmarked `CLAUDE.md`, and a compile with no primitives writes nothing. The one opt-in exception is `managed_section` mode, which writes only between the markers. If the user's `CLAUDE.md` already imports `@AGENTS.md`, compile leaves it untouched.
|
||||||
|
- **Scope limits.** User scope (`-g`) and a home-rooted project never route to `AGENTS.md`.
|
||||||
|
- **Claude Code version.** The source notes that Claude Code 2.1.277 and later read `AGENTS.md` natively, but only while no `CLAUDE.md` exists or the `CLAUDE.md` imports `@AGENTS.md`.
|
||||||
|
|
||||||
## Two separate output paths
|
## Two separate output paths
|
||||||
|
|
||||||
`apm install` writes native files, one per instruction, into each target's own rules directory. `apm compile` writes root context files (`CLAUDE.md`, `AGENTS.md`, `GEMINI.md`) that concatenate instruction bodies. The two overlap, which is why compile has a dedup rule (below). A skill author should treat install as the primary path for Claude Code and Copilot, and compile as the path for targets that have no native instructions directory.
|
`apm install` writes native files, one per instruction, into each target's own rules directory. `apm compile` writes root context files (`CLAUDE.md`, `AGENTS.md`, `GEMINI.md`) that concatenate instruction bodies. The two overlap, which is why compile has a dedup rule (below). A skill author should treat install as the primary path for Claude Code and Copilot, and compile as the path for targets that have no native instructions directory.
|
||||||
@@ -80,4 +97,4 @@ Keys: `target`, `strategy` (`distributed` or `single-file`), `single_file`, `out
|
|||||||
|
|
||||||
### Relevant compile flags
|
### Relevant compile flags
|
||||||
|
|
||||||
`--validate` (parse only; see schema file for why it is a weak check), `--dry-run`, `--clean` (removes orphaned generated files, never hand-authored ones), `--target`, `--all`, `--root`, `-g`, `--local-only`, `--single-agents`, `--no-links`, `--with-constitution`, `--force-instructions`. Documented exit codes: 0 success, 1 error, 2 conflicting flags. A compile with no instruction primitives at all exits 0 in 0.28.0.
|
`--validate` (parse only; see schema file for why it is a weak check), `--dry-run`, `--clean` (removes orphaned generated files, never hand-authored ones), `--target`, `--all`, `--root`, `-g`, `--local-only`, `--single-agents`, `--no-links`, `--with-constitution`, `--force-instructions`. Documented exit codes: 0 success, 1 error, 2 conflicting flags. A compile with no instruction primitives at all exits 0 in 0.28.0. In 0.39.3 it also exits 1 when org policy blocks a recorded package.
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
---
|
||||||
|
topic: lockfile-and-compatibility
|
||||||
|
source_keys:
|
||||||
|
- apm-v0-39-3-source
|
||||||
|
- apm-v0-39-3-changelog
|
||||||
|
- apm-v0-39-3-docs
|
||||||
|
---
|
||||||
|
|
||||||
|
Lockfile format, cross-version compatibility, frozen installs and ref resolution as of apm 0.39.3. Read from the v0.39.3 source, its CHANGELOG and its docs. Nothing here was run against a real project. Each claim is marked **source** (read in code) or **doc** (docs or CHANGELOG only).
|
||||||
|
|
||||||
|
## Lockfile versions
|
||||||
|
|
||||||
|
- **Source:** the supported versions are `"1"` to `"4"`. Anything else is refused before any file changes, with `Unsupported lockfile version '<v>'; supported versions: 1, 2, 3, 4` plus a `apm self-update` hint.
|
||||||
|
- **Doc:** the bump depends on content:
|
||||||
|
- `"4"` when any package records a `content_hash`;
|
||||||
|
- else `"3"` when a root `replacements` table exists;
|
||||||
|
- else `"2"` for registry or semver evidence;
|
||||||
|
- else `"1"`.
|
||||||
|
- **Doc:** v4 adds no fields. It only changes how `content_hash` is computed. Each file, in sorted path order, contributes its path, a NUL byte and the SHA-256 of its raw bytes; v1-v3 keep the older stream. **Source:** both digests exist and are selected per lock version.
|
||||||
|
- **Doc:** 0.37+ verifies a v1-v3 lock as written:
|
||||||
|
- A writable `apm install` promotes the lock to `"4"` once every package re-hashes from verified bytes.
|
||||||
|
- `apm install --frozen`, `apm audit` and other read-only commands never promote or rewrite it.
|
||||||
|
- **Doc:** a lockfile with invalid YAML, a non-mapping root or malformed rows fails closed.
|
||||||
|
- **Doc (0.39.0):** the lock is parsed with libyaml, so a hand-edited lockfile with nonstandard YAML may now be rejected. Regenerate it with `apm install`.
|
||||||
|
|
||||||
|
## Which apm reads which lock
|
||||||
|
|
||||||
|
| Lock | Refused by | Read by |
|
||||||
|
|---|---|---|
|
||||||
|
| v1-v3 written by 0.28.0 | nothing current | 0.37+ reads as written; a writable install promotes to v4 |
|
||||||
|
| v4 written by 0.37.0-0.39.1 | 0.36.1 and older | 0.37.0+ |
|
||||||
|
| v4 rewritten by 0.39.2+ | 0.36.1 and older, and 0.37.0-0.39.1 (they refuse any lock from a newer apm) | 0.39.2+ |
|
||||||
|
|
||||||
|
Practical rule: once a lock written by 0.39.2 or later is committed, every machine that runs install or audit on it needs 0.39.2 or later. Upgrade CI and update bots first.
|
||||||
|
|
||||||
|
## The 0.39.2 compatibility promise (doc, warning text confirmed in source)
|
||||||
|
|
||||||
|
From 0.39.2, the `lockfile_version` decides compatibility, not `apm_version`.
|
||||||
|
|
||||||
|
- A lock written by a newer apm in a format this apm reads runs normally. The only difference is one `[!]` line on stderr per process: `apm.lock.yaml was written by APM <x>, newer than this APM <y>. Its format (lockfile_version 4) is supported, so APM continues and keeps fields it does not know.`
|
||||||
|
- Unknown fields survive a rewrite, with exceptions:
|
||||||
|
- A dependency row's unknown fields are dropped when its commit, hash, version, `content_hash` or `source_digest` changed.
|
||||||
|
- A deployment row's unknown fields are dropped when its `content_hash` or owner changed.
|
||||||
|
- Top-level unknown fields are dropped when any dependency changed.
|
||||||
|
- `x-*` top-level keys are always kept.
|
||||||
|
- Refused with exit 1 before any change:
|
||||||
|
- an unsupported `lockfile_version`;
|
||||||
|
- an unknown deployment `kind`;
|
||||||
|
- an unknown value in a known enum field (`exec_status`, `host_type`);
|
||||||
|
- a duplicated `apm_version` or `lockfile_version` key.
|
||||||
|
- No-op runs leave the lockfile byte-identical, and apm never switches its own version.
|
||||||
|
- Read support for a new format ships at least eight weeks before any release writes it.
|
||||||
|
|
||||||
|
**`apm audit --ci` is stricter than install.** It fails with exit 1 when the lock records fields this apm does not know (other than `x-` keys): `'apm audit --ci' cannot certify apm.lock.yaml: it was written by APM <x>, newer than this APM <y>, and it records fields this APM does not know: <names>. Nothing was changed.` In JSON or SARIF output this is a failed check named `lockfile-fields-certifiable`. Plain `apm audit` only warns. Consequence: the apm that runs `audit --ci` must be at least as new as the newest apm that writes the lock.
|
||||||
|
|
||||||
|
## Minimum-version advice (doc)
|
||||||
|
|
||||||
|
apm has no manifest field for a required or minimum apm version. The upstream advice is to "pin a minimum APM in CI, not an exact one". The minimum should be a release that reads the lock format: 0.39.2 or later in the docs' own example. Version pinning therefore lives outside `apm.yml`, in whatever installs apm.
|
||||||
|
|
||||||
|
## `apm install --frozen`
|
||||||
|
|
||||||
|
- **Doc:** requires `apm.lock.yaml`, replays its pins, and never writes the lock (since 0.34.0).
|
||||||
|
- **Doc:** in CI (env `CI` set to anything but empty, `0` or `false`), `apm install` with a committed lock behaves like `--frozen` (0.37.0). `--no-frozen` opts out, and is the recommended form for update bots.
|
||||||
|
- **Doc:** mutually exclusive with `--update`, positional package additions and `--mcp`. Passing `--frozen --update` is a usage error (exit 2).
|
||||||
|
- **Doc:** fails (exit 1) before the pipeline on:
|
||||||
|
- a missing lock (a no-op when nothing is declared);
|
||||||
|
- a direct dependency missing from the lock;
|
||||||
|
- changed refs or commit pins;
|
||||||
|
- a host, provider or transport mismatch;
|
||||||
|
- MCP declaration mismatches;
|
||||||
|
- an MCP server the lock admits but `apm.yml` does not approve;
|
||||||
|
- hook approval pin mismatches.
|
||||||
|
- **Doc:** hash enforcement:
|
||||||
|
- Since 0.36.0, every deployed file is compared with its locked hash, and since 0.37.0 this happens before anything deploys. A mismatch exits 1.
|
||||||
|
- Since 0.39.x, it also fails when an apm-managed entry inside a merged hook config, such as `.claude/settings.json`, was edited.
|
||||||
|
- Recovery: restore or delete the edited file or entry, run `apm install` without `--frozen`, and commit. To keep edits made to a dependency's files, export them first with `apm export-patch`.
|
||||||
|
- **Doc:** after the pipeline, `--frozen` also checks for unrecorded files, missing files, a stale executables decision, and hash drift. `generated_at` and `apm_version` are excluded from the comparison.
|
||||||
|
|
||||||
|
## Exact dependency refs (0.39.0, #4970)
|
||||||
|
|
||||||
|
- **Source:** a dependency `ref` resolves only to `refs/heads/<ref>` or `refs/tags/<ref>`, or to itself when spelled out in full under one of those. There is no tail match and no fallback, so a ref that only partly matches a branch or tag name is refused.
|
||||||
|
- When a ref names both a branch and a tag, the error says it is ambiguous; spell it as `refs/heads/<name>` or `refs/tags/<name>`.
|
||||||
|
- When it names neither: `it is not a branch or tag of the origin`.
|
||||||
|
- An abbreviated SHA the host cannot expand is refused. Use the full 40 characters.
|
||||||
|
- **Source:** a pinned commit, whether a `#sha` ref or a locked commit, is admitted only if an origin branch or tag reaches it. A commit reachable only from a PR or a fork is refused.
|
||||||
|
- The fast path is a branch or tag tip, found with one `ls-remote`. Otherwise apm does a commits-only fetch of heads and tags.
|
||||||
|
- The verdict is cached in local state, never in the lockfile, so later replays work offline.
|
||||||
|
- **Source/doc:** the first install of a pinned commit needs the network. Offline, it fails closed with `the first install of a pinned commit needs network access once`.
|
||||||
|
- **Source:** Artifactory routes are exempt and resolve by name.
|
||||||
|
|
||||||
|
## Commit verdicts after an upgrade (0.39.0, #5173)
|
||||||
|
|
||||||
|
**Source:** reachability verdicts live in a new cache namespace (`verified-v2`), and verdicts recorded by earlier builds are never read. After upgrading, run each install online once before relying on offline or locked replays.
|
||||||
|
|
||||||
|
## Helper tools resolve from PATH (0.39.0)
|
||||||
|
|
||||||
|
**Doc:** apm's helper tools (`git`, `az`, `npm` and others) and the setup scripts it runs resolve programs only from PATH entries outside the project. This does not affect your own scripts.
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
---
|
||||||
|
topic: migration-0-28-to-0-39
|
||||||
|
source_keys:
|
||||||
|
- apm-v0-39-3-changelog
|
||||||
|
- apm-v0-39-3-source
|
||||||
|
- apm-v0-39-3-docs
|
||||||
|
---
|
||||||
|
|
||||||
|
This page lists the breaking and behaviour-changing items between apm 0.28.0, the version the rest of this reference set was first verified on, and 0.39.3. Use it to decide which "verified on 0.28.0" claims elsewhere need re-checking. Every item comes from the CHANGELOG, with source confirmation where it says **source**. None of it was run against a real project.
|
||||||
|
|
||||||
|
## Versions and runtime
|
||||||
|
|
||||||
|
- **0.36.0:** pip, pipx and uv installs need Python 3.11 or later. Standalone binaries are unaffected.
|
||||||
|
- **0.37.0:** the lockfile moves to format v4. 0.36.1 and older refuse it. See `lockfile-and-compatibility.md`.
|
||||||
|
- **0.39.2:** 0.37.0-0.39.1 refuse a lock that 0.39.2 rewrites. From 0.39.2, a lock written by a newer apm in a supported format only warns. 0.39.2 is therefore the practical minimum.
|
||||||
|
|
||||||
|
## Manifest and targets
|
||||||
|
|
||||||
|
- **0.29.0:** a plugin's `skills` declaration exclusively controls which skills deploy. `"skills": []` deploys none, and removing the key keeps conventional `skills/` discovery.
|
||||||
|
- **0.31.0:** a non-dry-run `apm install` exits 1 when Agent Plugins v1 target exclusion leaves no package deployed.
|
||||||
|
- **0.32.0:** `apm install` rejects bare `.` or `..` aliases and unsafe symlink destinations.
|
||||||
|
- **0.37.0:**
|
||||||
|
- The `vscode` target is deprecated in favour of `copilot`.
|
||||||
|
- The singular `target:` key is replaced by `targets:`, and `compilation.target` is ignored. Both still work, with warnings.
|
||||||
|
- Copilot project MCP servers move to a root `.mcp.json`.
|
||||||
|
- The `auto-integrate` config key is removed.
|
||||||
|
- With `default_host:` set, shorthand dependencies resolve against it.
|
||||||
|
- **Source:** `KNOWN_TARGETS` has 17 keys: agent-skills, antigravity, claude, codex, copilot, copilot-app, copilot-cowork, cursor, gemini, grok-bot, grok-build, grok-cloud, hermes, kiro, openclaw, opencode and windsurf. `vscode` is not among them.
|
||||||
|
- **0.39.0 (#4970):** a dependency `ref` must exactly name an origin branch or tag, and pinned commits must be reachable from one. See `lockfile-and-compatibility.md`.
|
||||||
|
|
||||||
|
## Install, lockfile and audit
|
||||||
|
|
||||||
|
- **0.34.0:** `apm install --frozen` no longer writes the lock.
|
||||||
|
- **0.36.0 (#3654):** `--frozen` verifies every deployed file against its locked hash. Before reinstalling, export your edits with `apm export-patch`.
|
||||||
|
- **0.37.0:**
|
||||||
|
- In CI, `apm install` with a committed lock verifies like `--frozen`. Use `--no-frozen` to opt out.
|
||||||
|
- `--frozen` fails before deploying on any edited deployed file.
|
||||||
|
- **0.38.0:** a failed or interrupted install restores every file it wrote. Install refuses managed files that lack deployment evidence.
|
||||||
|
- **0.39.0:**
|
||||||
|
- The lock is parsed with libyaml.
|
||||||
|
- Reachability verdicts are recorded anew, so run one online install after upgrading.
|
||||||
|
- Helper tools resolve only from PATH entries outside the project.
|
||||||
|
- **0.39.2:** `apm audit --ci` fails on lock fields this apm does not know.
|
||||||
|
- **0.39.3:** outside CI, the first `apm install --frozen` after an `apm install` takes a verified fast path.
|
||||||
|
- **Audit checks:** the baseline set has grown, so the total behind `N of M check(s) failed` is not fixed (**source**).
|
||||||
|
- Baseline: `manifest-parse`, `manifest-missing`, `lockfile-exists`, `ref-consistency`, `deployment-ledger-owners`, `deployed-files-present`, `exec-status-current`, `no-orphaned-packages`, `lockfile-targets-current`, `skill-subset-consistency`, `config-consistency`, `native-mcp-ownership`.
|
||||||
|
- Conditional: `native-mcp-drift` and `kept-mcp-entries`.
|
||||||
|
- Always on: `content-integrity`, `local-bundle-hooks`, `hook-approval-pins`, `includes-consent` (advisory), and `drift`.
|
||||||
|
|
||||||
|
## Executables and approvals
|
||||||
|
|
||||||
|
- **0.37.0 (#3918):** `apm audit --ci` fails MCP servers the lock admits but `apm.yml` does not approve. Use `apm approve <pkg>` instead of `--trust-transitive-mcp`.
|
||||||
|
- **0.37.0:** approvals can be pinned to content. Older clients reject pinned approvals.
|
||||||
|
- **0.38.0 (#4688):** a hook pin covers every file deployed with the hook. Re-approve hook packages once.
|
||||||
|
- **0.38.1:** `apm audit --ci` fails on merged hook entries that match a denied or unapproved package's hook and have no ownership evidence.
|
||||||
|
- **Ordinary grants stay version-blind (source).** A `hooks: true` grant keyed `pkg#1.2.3` still matches any version. See `approvals-and-executables.md`.
|
||||||
|
|
||||||
|
## Hooks
|
||||||
|
|
||||||
|
- **0.36.0 (#3613):** hook filenames no longer route hooks to targets, so every hook file reaches every targeted harness. To limit a hook to one target, declare `targets:` in the package `apm.yml`, or narrow the dependency with object-form `targets:`. When the old routing kept a target from a file, install fails for that package and names the file.
|
||||||
|
- **0.36.0:** Copilot hook events that have a Claude equivalent are written to `.claude/settings.json` under the Claude name.
|
||||||
|
- **0.38.1 and 0.39.0:**
|
||||||
|
- Edited hook entries and scripts are kept. Install exits 1 when an edited one blocks new content.
|
||||||
|
- A `.claude/settings.json` that apm created is deleted when its last entry leaves. One that apm did not create is kept, with a warning.
|
||||||
|
- Hooks merge in full-install order.
|
||||||
|
- **0.39.0 (#5600):** only hook commands that stay inside the package and use no shell expansion are deployed. Shell expansion means `$(...)`, backticks, `eval`, here-docs and subshells.
|
||||||
|
|
||||||
|
## Prompts and commands
|
||||||
|
|
||||||
|
- **0.39.0 (#4910 and others):** on the Claude target, apm keeps Claude Code command keys:
|
||||||
|
- `when_to_use`, `disable-model-invocation`, `user-invocable`, `disallowed-tools`, `effort`;
|
||||||
|
- `context`, `agent`, `background`, `shell`.
|
||||||
|
|
||||||
|
`hooks` is still withheld, with a warning. In 0.28.0 only `description`, `allowed-tools`, `model`, `argument-hint` and `input` survived. See `prompt-primitive-schema.md`.
|
||||||
|
- **0.39.0:** the dropped-keys message is shown only with `--verbose`. It is an info message, not a warning.
|
||||||
|
|
||||||
|
## Instructions and root context files
|
||||||
|
|
||||||
|
- **0.38.0:** Claude instructions scoped to `**` or to a directory move from `.claude/rules/` into `AGENTS.md`, which `CLAUDE.md` imports. A hand-authored `CLAUDE.md` needs `@AGENTS.md`.
|
||||||
|
- **0.39.0 (#5394):** install-only projects keep the 0.37 `.claude/rules/` layout. A hand-authored root `CLAUDE.md` without the import, or a hand-authored `AGENTS.md` without managed-section markers, keeps every instruction in `.claude/rules/`, with a warning. See `instructions-target-mapping.md`.
|
||||||
|
|
||||||
|
## CLI
|
||||||
|
|
||||||
|
- **0.36.0:** `apm export-patch` is added.
|
||||||
|
- **0.37.0:** `apm init --plugin` and `apm init --marketplace` exit 2. Use `apm plugin init` or `apm marketplace init` instead.
|
||||||
|
- **0.37.0:** approvals are pinned to content, and `apm approve` and `apm deny` manage them.
|
||||||
|
- **`apm outdated`:** still has no `--json`. Its summary line `<N> outdated dependency/dependencies found` is unchanged in source. Its columns are Package, Current, Wanted (registry rows only), Latest, Status and Source.
|
||||||
|
- **`apm audit`:** supports `-f text|json|sarif|markdown` and `-o PATH`. JSON is the stable machine format. `markdown` is not allowed with `--ci`.
|
||||||
@@ -7,11 +7,13 @@ source_keys:
|
|||||||
- apm-docs-cli-run
|
- apm-docs-cli-run
|
||||||
- apm-docs-cli-compile
|
- apm-docs-cli-compile
|
||||||
- apm-cli-0-28-0-prompt-experiments
|
- apm-cli-0-28-0-prompt-experiments
|
||||||
|
- apm-v0-39-3-source
|
||||||
|
- apm-v0-39-3-changelog
|
||||||
---
|
---
|
||||||
|
|
||||||
## What this covers
|
## What this covers
|
||||||
|
|
||||||
Constraints that surprise a prompt author. Items are marked **observed** when they were reproduced on the installed apm 0.28.0 in a throwaway project with local-path packages, and **doc** when they come only from the published docs. Where an observation disagrees with a doc statement, the observation wins and the disagreement is noted. Claude Code, Cursor and Gemini runtime behaviour on the emitted files was not tested.
|
Constraints that surprise a prompt author. **Version note:** every **observed** item below was observed on apm 0.28.0 and has not been re-run on 0.39.x. The changes known from the 0.39.3 source and CHANGELOG are listed under "Changed in 0.39.x" at the end. Items are marked **observed** when they were reproduced on the installed apm 0.28.0 in a throwaway project with local-path packages, and **doc** when they come only from the published docs. Where an observation disagrees with a doc statement, the observation wins and the disagreement is noted. Claude Code, Cursor and Gemini runtime behaviour on the emitted files was not tested.
|
||||||
|
|
||||||
## Discovery
|
## Discovery
|
||||||
|
|
||||||
@@ -72,3 +74,15 @@ Parameters are interpolated into any `.prompt.md` the script references and are
|
|||||||
## Not tested
|
## Not tested
|
||||||
|
|
||||||
The experimental targets (hermes, openclaw, copilot-cowork, grok-cloud, copilot-app), because enabling them writes global config. Claude Code, Cursor and Gemini runtime handling of the emitted files.
|
The experimental targets (hermes, openclaw, copilot-cowork, grok-cloud, copilot-app), because enabling them writes global config. Claude Code, Cursor and Gemini runtime handling of the emitted files.
|
||||||
|
|
||||||
|
## Changed in 0.39.x (from source and CHANGELOG, not observed)
|
||||||
|
|
||||||
|
- On the `claude` target the Claude-native command keys are kept rather than dropped:
|
||||||
|
- `when_to_use`, `disable-model-invocation`, `user-invocable`, `disallowed-tools`, `effort`;
|
||||||
|
- `context`, `agent`, `background`, `shell`.
|
||||||
|
|
||||||
|
So the 0.28.0 drop list above (which named `agent`) no longer holds for Claude. Cursor, OpenCode, Windsurf and grok-build still drop these keys. See `prompt-primitive-schema.md`.
|
||||||
|
- The dropped-keys message is an info line shown only with `--verbose`, so a default install no longer reports dropped keys at all.
|
||||||
|
- Frontmatter `hooks` on a command is withheld with a warning.
|
||||||
|
- A non-string frontmatter key (for example `1:`) skips that one command with a warning, and the other commands still install.
|
||||||
|
- Hidden-Unicode, collision and stale-cleanup behaviour were not re-checked. 0.38 and 0.39 changed how edited deployed files are kept (see `migration-0-28-to-0-39.md`), so the "hand-edited file is silently overwritten" item above is likely stale.
|
||||||
@@ -5,9 +5,26 @@ source_keys:
|
|||||||
- apm-github-repo
|
- apm-github-repo
|
||||||
- apm-docs-author-prompts
|
- apm-docs-author-prompts
|
||||||
- apm-docs-llms-full
|
- apm-docs-llms-full
|
||||||
|
- apm-v0-39-3-source
|
||||||
|
- apm-v0-39-3-changelog
|
||||||
---
|
---
|
||||||
|
|
||||||
Per-target output, key survival and the doc inconsistencies are in `prompt-target-mapping.md` and `prompt-gotchas.md`. The published "Author a prompt" page lists five preserved keys: `description`, `input`, `allowed-tools`, `model`, `argument-hint`. Where the section below says four keys are preserved, read that as four plus `input`, which is consumed into `arguments:` on Claude. Both the page and the installed 0.28.0 source agree on this set.
|
Per-target output, key survival and the doc inconsistencies are in `prompt-target-mapping.md` and `prompt-gotchas.md`.
|
||||||
|
|
||||||
|
**Version note.** This file was first verified on apm 0.28.0. The Claude key set changed in 0.39.0; the section "Claude command keys in 0.39.x" below is the current behaviour, read from the v0.39.3 source. In 0.28.0 the shared set was five keys: `description`, `input`, `allowed-tools`, `model`, `argument-hint`, where `input` is consumed into `arguments:` on Claude. Every other key was dropped on every Claude-family target.
|
||||||
|
|
||||||
|
## Claude command keys in 0.39.x
|
||||||
|
|
||||||
|
- **Shared keys, kept on every Claude-family target:** `description`, `allowed-tools` (alias `allowedTools`), `model`, `argument-hint` (alias `argumentHint`), `input`.
|
||||||
|
- **Claude-native keys, kept only when the target is `claude`:**
|
||||||
|
- `when_to_use`, `disable-model-invocation`, `user-invocable`, `disallowed-tools`, `effort`;
|
||||||
|
- `context`, `agent`, `background`, `shell`.
|
||||||
|
|
||||||
|
Cursor, OpenCode, Windsurf and the other targets that reuse the command transformer still drop them.
|
||||||
|
- **`arguments`:** an authored `arguments` is kept verbatim only on Claude, and only when the file has no `input` key at all. An `input` key always wins, even when it is empty or every name in it was rejected.
|
||||||
|
- **`hooks`:** withheld on purpose. The command is deployed without its hooks, and install warns `frontmatter hooks withheld`. apm does not yet run command hooks through its executable-approval gate.
|
||||||
|
- **Other keys:** still dropped. The dropped-keys message is now an info line shown only with `--verbose`, no longer an always-on warning.
|
||||||
|
- **Consequence:** a prompt with `disable-model-invocation: true` deploys with that key to `.claude/commands/<name>.md` on 0.39.0 and later. 0.28.0 silently stripped it.
|
||||||
|
|
||||||
## File location, naming, and frontmatter
|
## File location, naming, and frontmatter
|
||||||
|
|
||||||
@@ -33,7 +50,7 @@ There is no single closed frontmatter schema — APM's P1 "no invented primitive
|
|||||||
**Claude Code target — real reconstruction into a slash command, with field-dropping.** There is no `prompts:` key at all in Claude's `TargetProfile.primitives` dict; instead prompts route through the shared `CommandIntegrator`, which transforms `.prompt.md` → Claude custom slash command markdown. `CommandIntegrator._transform_prompt_to_command()`:
|
**Claude Code target — real reconstruction into a slash command, with field-dropping.** There is no `prompts:` key at all in Claude's `TargetProfile.primitives` dict; instead prompts route through the shared `CommandIntegrator`, which transforms `.prompt.md` → Claude custom slash command markdown. `CommandIntegrator._transform_prompt_to_command()`:
|
||||||
|
|
||||||
- Strips the `.prompt.md` suffix from the filename to derive `command_name`.
|
- Strips the `.prompt.md` suffix from the filename to derive `command_name`.
|
||||||
- Builds an entirely new frontmatter object containing **only** these preserved keys: `description`, `allowed-tools` (accepts `allowedTools` alias), `model`, `argument-hint` (accepts `argumentHint` alias).
|
- Builds an entirely new frontmatter object containing **only** the preserved keys. In 0.28.0 these were `description`, `allowed-tools` (alias `allowedTools`), `model` and `argument-hint` (alias `argumentHint`). From 0.39.0 the `claude` target also keeps the Claude-native keys listed above.
|
||||||
- Maps APM's `input:` list to Claude's `arguments:` list, and synthesizes `argument-hint` from it if not already set.
|
- Maps APM's `input:` list to Claude's `arguments:` list, and synthesizes `argument-hint` from it if not already set.
|
||||||
- Rewrites body placeholders `${input:name}` / `${{input:name}}` to Claude's native `$name` syntax via regex substitution.
|
- Rewrites body placeholders `${input:name}` / `${{input:name}}` to Claude's native `$name` syntax via regex substitution.
|
||||||
- Computes `dropped_keys = source_frontmatter_keys - preserved_keys` and surfaces it as an install-time diagnostic warning — so `author`, `mcp`, `parameters`, and any other non-listed key are silently dropped from the compiled output but *not* silently dropped from the user's awareness (a warning fires).
|
- Computes `dropped_keys = source_frontmatter_keys - preserved_keys` and surfaces it as an install-time diagnostic warning — so `author`, `mcp`, `parameters`, and any other non-listed key are silently dropped from the compiled output but *not* silently dropped from the user's awareness (a warning fires).
|
||||||
@@ -44,7 +61,7 @@ There is no single closed frontmatter schema — APM's P1 "no invented primitive
|
|||||||
| Target | Output path | Transform |
|
| Target | Output path | Transform |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| Copilot CLI | `.github/prompts/<name>.prompt.md` | Verbatim byte copy (links resolved) |
|
| Copilot CLI | `.github/prompts/<name>.prompt.md` | Verbatim byte copy (links resolved) |
|
||||||
| Claude Code | `.claude/commands/<name>.md` | Reconstructed: only `description`/`allowed-tools`/`model`/`argument-hint`/`arguments` survive; `input:` → `arguments:`; `${input:x}` → `$x` |
|
| Claude Code | `.claude/commands/<name>.md` | Reconstructed. In 0.28.0 only `description`/`allowed-tools`/`model`/`argument-hint`/`arguments` survive; from 0.39.0 the Claude-native keys survive too. `input:` → `arguments:`; `${input:x}` → `$x` |
|
||||||
|
|
||||||
Invocation surface differs correspondingly: Copilot exposes it via the prompts picker UI (select by name); Claude exposes it as `/<name> <args>` (same pattern Cursor, OpenCode, Gemini CLI, and Windsurf's workflows menu use for their own compiled copies).
|
Invocation surface differs correspondingly: Copilot exposes it via the prompts picker UI (select by name); Claude exposes it as `/<name> <args>` (same pattern Cursor, OpenCode, Gemini CLI, and Windsurf's workflows menu use for their own compiled copies).
|
||||||
|
|
||||||
@@ -52,6 +69,6 @@ Invocation surface differs correspondingly: Copilot exposes it via the prompts p
|
|||||||
|
|
||||||
- **Input-name validation is real, not just documentation.** `_extract_input_names()` enforces `[A-Za-z][\w-]{0,63}` on every name pulled from `input:`; anything that fails is dropped from `arguments:` and reported as a warning listing up to 5 rejected names (`input: rejected N invalid name(s) ... `). A malformed `input:` entry does not fail the install — it silently loses that one argument.
|
- **Input-name validation is real, not just documentation.** `_extract_input_names()` enforces `[A-Za-z][\w-]{0,63}` on every name pulled from `input:`; anything that fails is dropped from `arguments:` and reported as a warning listing up to 5 rejected names (`input: rejected N invalid name(s) ... `). A malformed `input:` entry does not fail the install — it silently loses that one argument.
|
||||||
- **Filename-derived identity is security-checked.** `integrate_commands_for_target` calls `validate_path_segments(base_name, context="command filename")` specifically to reject a package shipping a `.prompt.md` file with a manipulated relative name (e.g. `../../evil.prompt.md`) that would otherwise escape the target commands directory.
|
- **Filename-derived identity is security-checked.** `integrate_commands_for_target` calls `validate_path_segments(base_name, context="command filename")` specifically to reject a package shipping a `.prompt.md` file with a manipulated relative name (e.g. `../../evil.prompt.md`) that would otherwise escape the target commands directory.
|
||||||
- **The dropped-key warning is the only signal a Claude-only author gets** that Cursor-specific frontmatter (`author`, `mcp`, `parameters`) never reached the deployed file — there is no error, no hard failure, and no config flag to preserve those keys for Claude; the shared transformer's preserved-key list is fixed in code (`_PRESERVED_COMMAND_KEYS`), not configurable per package.
|
- **The dropped-key message is the only signal a Claude-only author gets** that Cursor-specific frontmatter (`author`, `mcp`, `parameters`) never reached the deployed file. There is no error, no hard failure, and no config flag to preserve those keys. The preserved-key lists are fixed in code (`_PRESERVED_COMMAND_KEYS`, and `_CLAUDE_NATIVE_COMMAND_KEYS` from 0.39.0); a package cannot configure them. From 0.39.0 the message appears only with `--verbose`.
|
||||||
- **No dedicated `Prompt`/`PromptPrimitive` validation class exists** in `apm_cli/models/validation.py` or `apm_cli/primitives/models.py` — same gap pattern documented for the agent primitive. `apm.yml`'s `type: prompts` package-content-type ("Commands/prompts only, no instructions or skills") is validated at the package-type-detection level, not the individual-prompt level.
|
- **No dedicated `Prompt`/`PromptPrimitive` validation class exists** in `apm_cli/models/validation.py` or `apm_cli/primitives/models.py` — same gap pattern documented for the agent primitive. `apm.yml`'s `type: prompts` package-content-type ("Commands/prompts only, no instructions or skills") is validated at the package-type-detection level, not the individual-prompt level.
|
||||||
- Slash commands and prompts share one source directory and one glob (`.apm/prompts/*.prompt.md`) — there is no separate `.apm/commands/` primitive; "command" is purely a per-target compiled *name* for the same source file, not a distinct authoring primitive.
|
- Slash commands and prompts share one source directory and one glob (`.apm/prompts/*.prompt.md`) — there is no separate `.apm/commands/` primitive; "command" is purely a per-target compiled *name* for the same source file, not a distinct authoring primitive.
|
||||||
@@ -6,12 +6,15 @@ source_keys:
|
|||||||
- apm-docs-producer-ramp
|
- apm-docs-producer-ramp
|
||||||
- apm-github-repo
|
- apm-github-repo
|
||||||
- apm-cli-0-28-0-prompt-experiments
|
- apm-cli-0-28-0-prompt-experiments
|
||||||
|
- apm-v0-39-3-source
|
||||||
---
|
---
|
||||||
|
|
||||||
## Scope and confidence
|
## Scope and confidence
|
||||||
|
|
||||||
This file maps one `.apm/prompts/<name>.prompt.md` source to what each apm target receives. The paths and transforms below were **observed** on apm 0.28.0 using local-path packages in a throwaway project, and cross-checked against the published docs and the installer source. Where docs and observation disagree, the observation is used and `prompt-gotchas.md` records the disagreement. Runtime behaviour in the receiving tools was not tested.
|
This file maps one `.apm/prompts/<name>.prompt.md` source to what each apm target receives. The paths and transforms below were **observed** on apm 0.28.0 using local-path packages in a throwaway project, and cross-checked against the published docs and the installer source. Where docs and observation disagree, the observation is used and `prompt-gotchas.md` records the disagreement. Runtime behaviour in the receiving tools was not tested.
|
||||||
|
|
||||||
|
**Version note:** the output paths below are unchanged in the 0.39.3 source. What changed is which frontmatter keys the `claude` row keeps. From 0.39.0 it keeps the Claude-native command keys, `disable-model-invocation` among them. See `prompt-primitive-schema.md`.
|
||||||
|
|
||||||
## Output per target
|
## Output per target
|
||||||
|
|
||||||
| Target | Output path | Form |
|
| Target | Output path | Form |
|
||||||
|
|||||||
@@ -92,3 +92,63 @@ Note: `releasing.md`'s `--check-clean`/`--check-versions` scope, `apm pack` exit
|
|||||||
- **Description:** The installed apm-cli 0.28.0 exercised with local-path throwaway packages in a scratchpad outside the repo: root-level and nested prompt discovery, manifest `type:` values, compile on prompts-only packages, per-target install output and dropped-key warnings, input-name and YAML edge cases, collision, stale-cleanup and hand-edit behaviour, hidden-Unicode scanning and audit, and `apm pack --format plugin`. Source files `command_integrator.py`, `prompt_integrator.py` and `plugin_exporter.py` were read to cross-check. Experimental targets and `apm run` were not exercised.
|
- **Description:** The installed apm-cli 0.28.0 exercised with local-path throwaway packages in a scratchpad outside the repo: root-level and nested prompt discovery, manifest `type:` values, compile on prompts-only packages, per-target install output and dropped-key warnings, input-name and YAML edge cases, collision, stale-cleanup and hand-edit behaviour, hidden-Unicode scanning and audit, and `apm pack --format plugin`. Source files `command_integrator.py`, `prompt_integrator.py` and `plugin_exporter.py` were read to cross-check. Experimental targets and `apm run` were not exercised.
|
||||||
- **Contributing files:** prompt-target-mapping.md, prompt-gotchas.md
|
- **Contributing files:** prompt-target-mapping.md, prompt-gotchas.md
|
||||||
- **Status:** `extracted`
|
- **Status:** `extracted`
|
||||||
|
|
||||||
|
## 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 a local clone that `git describe` confirmed as v0.39.3, covering:
|
||||||
|
- **lockfile and audit:** lockfile versions and hashing, the compatibility warning and `audit --ci` certification, `exact_branch_or_tag_sha`, commit reachability, libyaml loading, the audit baseline checks and output strings, and `apm outdated` options and output;
|
||||||
|
- **approvals:** executables grants and pins, trust, and the hook fingerprint;
|
||||||
|
- **integrators:** hook, command, agent and skill;
|
||||||
|
- **instructions:** `claude_agents_md` and root-context protection;
|
||||||
|
- **CLI:** the command table, init, pack, update, approve and export-patch;
|
||||||
|
- **package metadata:** `pyproject.toml`.
|
||||||
|
- **Contributing files:** lockfile-and-compatibility.md, approvals-and-executables.md, migration-0-28-to-0-39.md, cli-reference.md, installation.md, prompt-primitive-schema.md, prompt-gotchas.md, prompt-target-mapping.md, hooks-primitive-schema.md, instructions-target-mapping.md
|
||||||
|
- **Status:** `extracted`
|
||||||
|
|
||||||
|
## apm-v0-39-3-changelog
|
||||||
|
|
||||||
|
- **URL:** https://github.com/microsoft/apm/blob/v0.39.3/CHANGELOG.md
|
||||||
|
- **Description:** CHANGELOG entries from 0.29.0 to 0.39.3. They cover breaking changes and upgrade notes on lockfile v4, the 0.39.2 lock refusal, `--frozen` hashes, exact refs, commit verdicts, approvals and hook pins, hook filename routing, the Claude command keys, the AGENTS.md instruction layout, targets and CLI removals.
|
||||||
|
- **Contributing files:** lockfile-and-compatibility.md, approvals-and-executables.md, migration-0-28-to-0-39.md, prompt-primitive-schema.md, prompt-gotchas.md, hooks-primitive-schema.md, instructions-target-mapping.md, instructions-gotchas.md
|
||||||
|
- **Status:** `extracted`
|
||||||
|
|
||||||
|
## apm-v0-39-3-docs
|
||||||
|
|
||||||
|
- **URL:** https://github.com/microsoft/apm/tree/v0.39.3/docs/src/content/docs
|
||||||
|
- **Description:** the docs source behind https://microsoft.github.io/apm/, read at tag v0.39.3 from the same clone. Pages used:
|
||||||
|
- **reference:** lockfile-spec, compatibility and baseline-checks;
|
||||||
|
- **CLI reference:** install, audit, outdated, approve, export-patch, compile, pack, marketplace and uninstall;
|
||||||
|
- **consumer:** run-in-ci and update-and-refresh;
|
||||||
|
- **producer:** write-primitives;
|
||||||
|
- **getting started:** installation;
|
||||||
|
- **spec:** the OpenAPM spec.
|
||||||
|
|
||||||
|
The published installation page was also fetched, and it matched.
|
||||||
|
- **Contributing files:** lockfile-and-compatibility.md, approvals-and-executables.md, migration-0-28-to-0-39.md, cli-reference.md, installation.md, hooks-primitive-schema.md, instructions-target-mapping.md
|
||||||
|
- **Status:** `extracted`
|
||||||
|
|
||||||
|
## pypi-apm-cli
|
||||||
|
|
||||||
|
- **URL:** https://pypi.org/pypi/apm-cli/json
|
||||||
|
- **Description:** PyPI metadata for apm-cli: the 0.39.2 and 0.39.3 release dates, wheel and sdist availability, yank status, `requires_python >=3.11` and `requires_dist`.
|
||||||
|
- **Contributing files:** installation.md
|
||||||
|
- **Status:** `extracted`
|
||||||
|
|
||||||
|
## apm-cli-0-39-3-uv-experiments
|
||||||
|
|
||||||
|
- **URL:** https://pypi.org/project/apm-cli/0.39.3/
|
||||||
|
- **Description:** throwaway uv projects built in a scratchpad outside any repo with uv 0.11.24. They tested:
|
||||||
|
- `uv add --dev apm-cli==0.39.3` and `uv run apm --version`;
|
||||||
|
- the `[tool.uv] package = false` form;
|
||||||
|
- `uv run --frozen --offline` with a warm cache and with a cold cache;
|
||||||
|
- `uvx --offline` against a cache warmed by `uv add`.
|
||||||
|
- **Contributing files:** installation.md
|
||||||
|
- **Status:** `extracted`
|
||||||
|
|
||||||
|
## context7-microsoft-apm-0-39-3
|
||||||
|
|
||||||
|
- **URL:** context7:/microsoft/apm
|
||||||
|
- **Description:** a Context7 query for apm 0.39.3 made during this refresh. It returned "Invalid API key", so no Context7 content informs the 0.39.3 material.
|
||||||
|
- **Contributing files:** none
|
||||||
|
- **Status:** `no content extracted`
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
name: plan-gate
|
||||||
|
description: >
|
||||||
|
Use when the plan prompt needs the step-1 gate run on a ticket or idea: duplicate, already done, contradicts
|
||||||
|
an ADR, or out of scope. Read-only. Not deep feasibility validation -> `plan-validator`.
|
||||||
|
model: sonnet
|
||||||
|
disallowedTools: Edit, Write, NotebookEdit
|
||||||
|
---
|
||||||
|
|
||||||
|
You run the cheap gate before any grilling. You are read-only: never call a write tool.
|
||||||
|
|
||||||
|
## Input
|
||||||
|
|
||||||
|
A ticket number or the idea as free text.
|
||||||
|
|
||||||
|
## Checks
|
||||||
|
|
||||||
|
1. **Duplicate**: an open issue or PR covers the same thing (`gitea-issues`, `gitea-prs`).
|
||||||
|
2. **Already done**: the repo already does it.
|
||||||
|
3. **Contradicts an ADR**: a decision in `docs/adr/` rules it out.
|
||||||
|
4. **Out of scope**: it falls outside `docs/VISION.md`.
|
||||||
|
|
||||||
|
## Output
|
||||||
|
|
||||||
|
One line per check: `<check> | pass/hit | evidence (link or file:line)`, then `verdict: go` or
|
||||||
|
`verdict: stop: <reason>`.
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
name: plan-recorder
|
||||||
|
description: >
|
||||||
|
Use when the plan prompt has an agreed plan and needs step 7: the decisions recorded in a docs PR
|
||||||
|
(AGENTS.md, GLOSSARY.md, ADRs). Not writing the spec or tickets -> `to-spec`.
|
||||||
|
model: sonnet
|
||||||
|
---
|
||||||
|
|
||||||
|
You record agreed decisions in the repo's docs and open one docs PR. You change docs only, never
|
||||||
|
code.
|
||||||
|
|
||||||
|
## Input
|
||||||
|
|
||||||
|
The agreed plan and the list of decisions it made.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
1. Create a branch `docs/plan-<slug>` from the default branch.
|
||||||
|
2. Record each decision where it belongs: an ADR or glossary term with `domain-modeling`, an
|
||||||
|
AGENTS.md change with `agentsmd-author`.
|
||||||
|
3. Commit with `git-commits`, push, and open the PR with `gitea-prs`.
|
||||||
|
|
||||||
|
## Output
|
||||||
|
|
||||||
|
The PR link and one line per decision naming the file it landed in.
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
name: plan-researcher
|
||||||
|
description: >
|
||||||
|
Use when the plan prompt needs step-3 research on an agreed intent and track, in the repo or online.
|
||||||
|
Read-only; returns cited findings. Not a findings file in the repo -> `research`.
|
||||||
|
model: sonnet
|
||||||
|
disallowedTools: Edit, NotebookEdit
|
||||||
|
---
|
||||||
|
|
||||||
|
You research one question for `/plan`. Never edit repo files; the only place you may write is the
|
||||||
|
session scratchpad.
|
||||||
|
|
||||||
|
## Input
|
||||||
|
|
||||||
|
The intent, the recommended track, and a scope: `repo` or `web`.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
- **repo**: current practices, rules, patterns and conventions — AGENTS.md, `GLOSSARY.md`,
|
||||||
|
`docs/adr/`, `docs/spec/` and the code the intent touches.
|
||||||
|
- **web**: tools, documentation, best practices, examples and standards. Use Context7 for library
|
||||||
|
docs; prefer primary sources.
|
||||||
|
|
||||||
|
## Output
|
||||||
|
|
||||||
|
Findings as bullets, each with its source (file:line or URL) and marked `verified` or `inferred`.
|
||||||
|
End with open questions, if any.
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
name: plan-validator
|
||||||
|
description: >
|
||||||
|
Use when the plan prompt needs step-4 deep validation: is the researched intent feasible and does it fit
|
||||||
|
the repo as it is now. Read-only. Not the cheap pre-grilling gate -> `plan-gate`.
|
||||||
|
model: opus
|
||||||
|
disallowedTools: Edit, Write, NotebookEdit
|
||||||
|
---
|
||||||
|
|
||||||
|
You validate one intent against the repo as it is now. You are read-only: never call a write tool.
|
||||||
|
|
||||||
|
## Input
|
||||||
|
|
||||||
|
The intent, the track, and the research findings.
|
||||||
|
|
||||||
|
## Checks
|
||||||
|
|
||||||
|
- Feasible with the repo's current structure, tools and conventions.
|
||||||
|
- Consistent with ADRs, AGENTS.md and `GLOSSARY.md`.
|
||||||
|
- Nothing it relies on is missing.
|
||||||
|
|
||||||
|
## Output
|
||||||
|
|
||||||
|
Each finding tagged `contradiction`, `missing`, `infeasible` or `risk`, with evidence, then
|
||||||
|
`verdict: fits`, `verdict: regrill: <point>` or `verdict: stop: <reason>`.
|
||||||
@@ -206,5 +206,5 @@ decisions instead.
|
|||||||
issue, pushing tags, or setting up infrastructure).
|
issue, pushing tags, or setting up infrastructure).
|
||||||
7. Open decisions that need me. Do not decide these yourself.
|
7. Open decisions that need me. Do not decide these yourself.
|
||||||
|
|
||||||
End with: "Run `/ship` to build this." If I reply go, tell me to run `/ship`: it cannot be
|
End with: "Run `/ship` to build this, or `/plan` to spec it first." If I reply go, tell me
|
||||||
invoked for me. Do not build inline.
|
to run `/ship`: it cannot be invoked for me. Do not build inline.
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
---
|
||||||
|
description: Turn a ticket or idea into a validated plan, a spec and agent-ready tickets, with me in the loop
|
||||||
|
argument-hint: "[#N | idea as free text] (empty: the issue picked by /next in this conversation)"
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
Input (raw, verbatim):
|
||||||
|
$ARGUMENTS
|
||||||
|
|
||||||
|
You are the orchestrator. Delegate the reading to subagents and keep only their conclusions. Speak
|
||||||
|
to me only to ask, to present, or to report. Every command you ask me to run goes in a code block
|
||||||
|
I can copy.
|
||||||
|
|
||||||
|
## 0. Entry
|
||||||
|
|
||||||
|
- `#N`: read the issue and its comments with `gitea-issues`.
|
||||||
|
- Free text: that is the idea.
|
||||||
|
- Empty: use the issue picked by `/next` earlier in this conversation. None → ask me for one.
|
||||||
|
|
||||||
|
## 1. Gate
|
||||||
|
|
||||||
|
Dispatch `plan-gate`. `verdict: stop` → tell me why and stop.
|
||||||
|
|
||||||
|
## 2–6. Discovery loop
|
||||||
|
|
||||||
|
Repeat until I agree. Count loops per point; after two loops on the same point, ask me whether to
|
||||||
|
park the idea instead.
|
||||||
|
|
||||||
|
2. **Grill** with `grilling`, only if the intent is unclear, and load `domain-modeling` to challenge
|
||||||
|
terms. Override: make no `GLOSSARY.md` or ADR edits during grilling; collect candidate terms and
|
||||||
|
ADRs for step 7 instead. This equals `grill-with-docs` minus the writing during grilling. Then
|
||||||
|
recommend a track with `plan-track`. `track: wayfinder` → ask me with AskUserQuestion to
|
||||||
|
confirm. On yes, give me this, filled in, and stop:
|
||||||
|
|
||||||
|
```
|
||||||
|
/wayfinder <intent> — <grilling answers>
|
||||||
|
```
|
||||||
|
|
||||||
|
On no, ask me which of the other two tracks to take, then continue to step 3.
|
||||||
|
|
||||||
|
3. **Research**: dispatch `plan-researcher` twice in parallel, scope `repo` and scope `web`. Ask
|
||||||
|
each to flag when lasting reference docs for an external tool or library are needed. Nothing is
|
||||||
|
written.
|
||||||
|
4. **Validate**: dispatch `plan-validator` with the findings. `regrill` → back to 2. `stop` → tell
|
||||||
|
me why and stop.
|
||||||
|
5. **Offer a plan**: options, considerations, recommendation, impact, expected results, and the
|
||||||
|
track. Use `codebase-design` only when the options change module or interface shape. List the
|
||||||
|
repo docs downstream agents need: `write-docs` targets and `research-docs` topics.
|
||||||
|
6. **Agreement**: ask me with AskUserQuestion to agree and confirm the track, or send it back to
|
||||||
|
grilling or research. Say in the question that agreeing also approves step 7's docs branch,
|
||||||
|
push and PR.
|
||||||
|
|
||||||
|
## 7. Record decisions
|
||||||
|
|
||||||
|
Dispatch `plan-recorder` with the agreed plan, its decisions, and the candidate terms and ADRs from
|
||||||
|
step 2. My agreement in step 6 authorizes its branch, commit, push and docs PR. Keep the PR link.
|
||||||
|
|
||||||
|
If step 5 listed docs: if it listed `research-docs` topics, ask me for the `research-docs` output
|
||||||
|
path. Then tell me the docs branch name (from the PR) and to run these on it, only the lines that
|
||||||
|
apply, and push to the same PR:
|
||||||
|
|
||||||
|
```
|
||||||
|
/write-docs <target>
|
||||||
|
/research-docs <topic> <path>
|
||||||
|
```
|
||||||
|
|
||||||
|
Wait for me.
|
||||||
|
|
||||||
|
## 8. Spec (spec and tickets track only)
|
||||||
|
|
||||||
|
`to-spec` is hand-invoked, so you cannot call it. Tell me to run:
|
||||||
|
|
||||||
|
```
|
||||||
|
/to-spec <agreed plan summary> — link the docs PR <link>
|
||||||
|
```
|
||||||
|
|
||||||
|
My running it is my approval of the spec. Wait for it. `to-spec` sets `Status/Ready for Agent` on
|
||||||
|
the spec issue; if present, resolve its label ID with `gitea-labels-milestones` and remove it with
|
||||||
|
`gitea-issues`.
|
||||||
|
|
||||||
|
## 9–10. Tickets
|
||||||
|
|
||||||
|
`to-tickets` is hand-invoked, so you cannot call it. Tell me to run it on the spec (or on this
|
||||||
|
conversation, on the tickets-only track):
|
||||||
|
|
||||||
|
```
|
||||||
|
/to-tickets <spec issue link | this conversation> — docs PR <link>
|
||||||
|
```
|
||||||
|
|
||||||
|
It proposes the breakdown, and my approval inside it covers the whole batch. It files the tickets
|
||||||
|
and sets `Status/Ready for Agent`; a ticket without acceptance criteria must not carry it. If the
|
||||||
|
breakdown shows a gap in the spec, tell me to rerun step 8's `/to-spec` block first.
|
||||||
|
|
||||||
|
After it files them, read each filed ticket with `gitea-issues`. Resolve the label IDs with
|
||||||
|
`gitea-labels-milestones`, remove `Status/Ready for Agent` from any ticket with no acceptance
|
||||||
|
criteria, and list those tickets for me.
|
||||||
|
|
||||||
|
Spec track: create one milestone `Spec: <spec issue title>` with `gitea-labels-milestones`, and
|
||||||
|
assign every filed ticket to it with `gitea-issues`.
|
||||||
|
|
||||||
|
## Report
|
||||||
|
|
||||||
|
Links to the docs PR, the spec, the milestone and the tickets.
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
name: plan-track
|
||||||
|
description: >-
|
||||||
|
Use when planning must recommend or confirm a track for a ticket or idea: spec and tickets,
|
||||||
|
ticket(s) only, or wayfinder. Not writing the spec -> `to-spec`. Not breaking work into
|
||||||
|
tickets -> `to-tickets`.
|
||||||
|
metadata:
|
||||||
|
version: "0.2.0"
|
||||||
|
category: planning
|
||||||
|
---
|
||||||
|
|
||||||
|
# Plan track
|
||||||
|
|
||||||
|
Recommend one track, with a one-sentence reason.
|
||||||
|
|
||||||
|
## Tracks
|
||||||
|
|
||||||
|
- **Spec and tickets**: a spec issue in the tracker, broken down into tickets.
|
||||||
|
- **Ticket(s) only**: one or more tickets with no spec.
|
||||||
|
- **Wayfinder**: a map of the work, explored ticket by ticket. The user runs `/wayfinder`
|
||||||
|
themselves; never invoke it.
|
||||||
|
|
||||||
|
## Pick wayfinder when any holds
|
||||||
|
|
||||||
|
- The work is too large for one agent session.
|
||||||
|
- It has decisions that cannot be settled yet.
|
||||||
|
|
||||||
|
## Otherwise, pick spec and tickets when any holds
|
||||||
|
|
||||||
|
- The work needs more than one ticket that depends on another.
|
||||||
|
- It makes a decision that downstream tickets must share.
|
||||||
|
- It touches more than one plugin or subsystem.
|
||||||
|
|
||||||
|
Otherwise pick ticket(s) only.
|
||||||
|
|
||||||
|
## Output
|
||||||
|
|
||||||
|
`track: <spec-and-tickets|tickets-only|wayfinder> | reason: <one sentence>`
|
||||||
File renamed without changes.
@@ -1,5 +1,5 @@
|
|||||||
name: plan
|
name: plan
|
||||||
version: 0.3.0
|
version: 0.5.0
|
||||||
description: Turning a ticket or idea into a validated, researched spec and agent-ready tickets, with the user in the loop; temporarily also ships /ship to execute a plan.
|
description: Turning a ticket or idea into a validated, researched spec and agent-ready tickets, with the user in the loop; temporarily also ships /ship to execute a plan.
|
||||||
author:
|
author:
|
||||||
name: Mortis
|
name: Mortis
|
||||||
@@ -13,6 +13,7 @@ keywords:
|
|||||||
- tickets
|
- tickets
|
||||||
- research
|
- research
|
||||||
- grilling
|
- grilling
|
||||||
|
- documentation
|
||||||
|
|
||||||
# Constrains what .apm/ may contain: instructions, skill, hybrid, or prompts
|
# Constrains what .apm/ may contain: instructions, skill, hybrid, or prompts
|
||||||
type: hybrid
|
type: hybrid
|
||||||
|
|||||||
+138
-14
@@ -1,8 +1,7 @@
|
|||||||
# plan plugin — outline
|
# plan plugin — outline
|
||||||
|
|
||||||
Status: outline only, refined in a first grilling round. This is the maintainer's intent for the
|
Status: outline, refined in a first grilling round, with a bare-bones MVP built (see "What ships
|
||||||
plugin. Nothing below is built yet except the `next` and `ship` prompts. Both are the existing
|
today"). This is the maintainer's intent for the plugin.
|
||||||
personal commands, moved into the plugin unchanged.
|
|
||||||
|
|
||||||
The plugin is set up on its own, separate from `delivery`, and is meant to grow on its own first.
|
The plugin is set up on its own, separate from `delivery`, and is meant to grow on its own first.
|
||||||
How the two connect is deliberately left open (see "Open for later").
|
How the two connect is deliberately left open (see "Open for later").
|
||||||
@@ -29,13 +28,18 @@ The goal is to optimise:
|
|||||||
|
|
||||||
## Tracks
|
## Tracks
|
||||||
|
|
||||||
The work takes one of two tracks:
|
The work takes one of three tracks:
|
||||||
|
|
||||||
- **Spec and tickets**: a spec issue in the tracker, broken down into tickets.
|
- **Spec and tickets**: a spec issue in the tracker, broken down into tickets.
|
||||||
- **Ticket(s) only**: one or more tickets with no spec.
|
- **Ticket(s) only**: one or more tickets with no spec.
|
||||||
|
- **Wayfinder**: work too large for one agent session, or with decisions that cannot be settled
|
||||||
|
yet.
|
||||||
|
|
||||||
The plugin recommends a track, with its reason, after the initial grilling (step 2). The user
|
The plugin recommends a track, with its reason, after the initial grilling (step 2). For the first
|
||||||
confirms it at agreement (step 6), because the plan can change the size of the work.
|
two tracks the user confirms it at agreement (step 6), because the plan can change the size of the
|
||||||
|
work. Wayfinder is different: it is confirmed right after step 2. `/plan` then gives the user a
|
||||||
|
copyable `/wayfinder` command (hand-invoked) carrying the intent and the grilling answers, and
|
||||||
|
stops. Steps 3-10 are skipped.
|
||||||
|
|
||||||
## Interaction flow
|
## Interaction flow
|
||||||
|
|
||||||
@@ -46,25 +50,40 @@ confirms it at agreement (step 6), because the plan can change the size of the w
|
|||||||
1. **Gate.** A cheap check before any grilling: is it a duplicate of an open issue or PR, is it
|
1. **Gate.** A cheap check before any grilling: is it a duplicate of an open issue or PR, is it
|
||||||
already done, does it contradict an ADR, or is it outside the repo's scope (`docs/VISION.md`)?
|
already done, does it contradict an ADR, or is it outside the repo's scope (`docs/VISION.md`)?
|
||||||
If any of these is true, stop.
|
If any of these is true, stop.
|
||||||
2. **Initial grilling**, only if required, to explore the ticket's or idea's intention. It ends
|
2. **Initial grilling**, only if required, to explore the ticket's or idea's intention. It uses
|
||||||
with a recommended track.
|
`grilling`, plus `domain-modeling` to challenge terms only. GLOSSARY.md and the ADRs are not
|
||||||
3. **Research** in the repo and online, scoped to the recommended track.
|
edited during grilling: candidates are collected and written in step 7. This equals
|
||||||
|
`grill-with-docs` minus the writing during grilling (`grill-me` and `grill-with-docs` are
|
||||||
|
hand-invoked wrappers). It ends with a recommended track.
|
||||||
|
3. **Research** in the repo and online, scoped to the recommended track. Researchers flag when
|
||||||
|
lasting reference docs for an external tool or library are needed. Nothing is written in this
|
||||||
|
step.
|
||||||
4. **Deep validation.** Check that the work is feasible and fits the repo as it is now. If it does
|
4. **Deep validation.** Check that the work is feasible and fits the repo as it is now. If it does
|
||||||
not, go back to grilling (step 2) or stop.
|
not, go back to grilling (step 2) or stop.
|
||||||
5. **Offer a plan** with options, considerations, recommendations, impact, expected results and
|
5. **Offer a plan** with options, considerations, recommendations, impact, expected results and
|
||||||
the track.
|
the track. `codebase-design` is used only when the options change module or interface shape.
|
||||||
|
The plan also lists the repo docs needed for downstream context.
|
||||||
6. **Agreement.** The user agrees and confirms the track, or the flow goes back to grilling or
|
6. **Agreement.** The user agrees and confirms the track, or the flow goes back to grilling or
|
||||||
research.
|
research.
|
||||||
7. **Record decisions.** Open a docs PR that updates AGENTS.md, GLOSSARY.md, the ADRs and any
|
7. **Record decisions.** Open a docs PR that updates AGENTS.md, GLOSSARY.md, the ADRs and any
|
||||||
other relevant docs with what was decided. The spec links to it, so tickets point at decisions
|
other relevant docs with what was decided. The spec links to it, so tickets point at decisions
|
||||||
that are already written down rather than pending.
|
that are already written down rather than pending. After `plan-recorder` opens the docs PR,
|
||||||
|
if step 5 listed docs, `/plan` gives copyable `/write-docs` and `/research-docs` commands,
|
||||||
|
only the ones that apply, for the user to run on the docs branch and push to the same PR. When
|
||||||
|
`research-docs` topics were listed, `/plan` first asks the user for its output path. Both need
|
||||||
|
the user in the loop, so they cannot run inside a subagent.
|
||||||
8. **Write the spec** as an issue in the tracker (Gitea included). This step runs on the spec and
|
8. **Write the spec** as an issue in the tracker (Gitea included). This step runs on the spec and
|
||||||
tickets track only.
|
tickets track only. The spec issue never carries `Status/Ready for Agent`; `/plan` strips the
|
||||||
|
one `/to-spec` sets.
|
||||||
9. **Propose a breakdown** into tickets. If the breakdown shows a gap in the spec, go back to
|
9. **Propose a breakdown** into tickets. If the breakdown shows a gap in the spec, go back to
|
||||||
step 8.
|
step 8.
|
||||||
10. **Approval and filing.** One explicit approval covers the whole batch. The plugin files the
|
10. **Approval and filing.** One explicit approval covers the whole batch. The plugin files the
|
||||||
tickets and sets `Status/Ready for Agent` on the ones that carry acceptance criteria. A
|
tickets and sets `Status/Ready for Agent` on the ones that carry acceptance criteria. A
|
||||||
ticket without acceptance criteria is never set ready.
|
ticket without acceptance criteria is never set ready. `gitea-labels-milestones` resolves the
|
||||||
|
label IDs for the Ready-for-Agent strip. On the spec track it also creates the
|
||||||
|
`Spec: <title>` milestone, and `gitea-issues` assigns the filed tickets to it.
|
||||||
|
|
||||||
|
Every command `/plan` asks the user to run is presented as a copyable code block.
|
||||||
|
|
||||||
### Loops
|
### Loops
|
||||||
|
|
||||||
@@ -74,9 +93,97 @@ The flow is a loop, not a straight line. The named loop-backs are:
|
|||||||
- disagreement → grilling or research (step 6 back to 2 or 3);
|
- disagreement → grilling or research (step 6 back to 2 or 3);
|
||||||
- breakdown → spec (step 9 back to 8).
|
- breakdown → spec (step 9 back to 8).
|
||||||
|
|
||||||
|
Wayfinder is an early exit rather than a loop: it ends the flow after step 2.
|
||||||
|
|
||||||
After two loops on the same point, the plugin asks whether to park the idea instead of
|
After two loops on the same point, the plugin asks whether to park the idea instead of
|
||||||
circling.
|
circling.
|
||||||
|
|
||||||
|
### Sequence diagram
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
sequenceDiagram
|
||||||
|
autonumber
|
||||||
|
actor U as User
|
||||||
|
participant P as plan (orchestrator)
|
||||||
|
participant R as Repo<br/>(AGENTS.md, ADRs, VISION, code)
|
||||||
|
participant W as Web / docs
|
||||||
|
participant T as Tracker (Gitea)
|
||||||
|
|
||||||
|
%% Step 0 — Entry
|
||||||
|
alt existing ticket
|
||||||
|
U->>P: ticket #N
|
||||||
|
P->>T: read issue
|
||||||
|
else new idea
|
||||||
|
U->>P: free text
|
||||||
|
else via /next
|
||||||
|
U->>P: /next [metric]
|
||||||
|
P->>T: rank open issues
|
||||||
|
P-->>U: ranked list
|
||||||
|
U->>P: pick one
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Step 1 — Gate
|
||||||
|
P->>T: duplicate open issue/PR? already done?
|
||||||
|
P->>R: contradicts an ADR? outside VISION scope?
|
||||||
|
opt any gate hit
|
||||||
|
P-->>U: stop, with reason
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Steps 2–6 — the discovery loop
|
||||||
|
loop until agreed (after 2 loops on one point, offer to park)
|
||||||
|
opt intent unclear
|
||||||
|
P->>U: grilling questions (step 2)
|
||||||
|
U-->>P: answers
|
||||||
|
end
|
||||||
|
P-->>U: recommended track + reason
|
||||||
|
opt track = wayfinder (confirmed here, not at step 6)
|
||||||
|
U->>P: confirm wayfinder
|
||||||
|
P-->>U: copyable /wayfinder command (intent + grilling answers)
|
||||||
|
Note over P,U: stop, steps 3-10 skipped
|
||||||
|
end
|
||||||
|
|
||||||
|
par Research (step 3), scoped to track
|
||||||
|
P->>R: practices, patterns, conventions
|
||||||
|
and
|
||||||
|
P->>W: tools, docs, standards, examples
|
||||||
|
end
|
||||||
|
|
||||||
|
P->>R: deep validation: feasible, fits repo now? (step 4)
|
||||||
|
alt doesn't fit
|
||||||
|
P-->>U: back to grilling, or stop
|
||||||
|
else fits
|
||||||
|
P-->>U: plan: options, impact, results, track (step 5)
|
||||||
|
alt user agrees and confirms track (step 6)
|
||||||
|
U->>P: agree + track
|
||||||
|
else disagreement
|
||||||
|
U->>P: back to grilling or research
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Step 7 — Record decisions
|
||||||
|
P->>T: open docs PR (AGENTS.md, GLOSSARY, ADRs)
|
||||||
|
P-->>U: copyable /write-docs and /research-docs commands
|
||||||
|
U->>T: run on the docs branch, push to the same PR
|
||||||
|
|
||||||
|
%% Steps 8–9 — Spec and breakdown
|
||||||
|
loop until breakdown shows no spec gap
|
||||||
|
opt track = spec + tickets
|
||||||
|
P->>T: write/update spec issue, link docs PR (step 8)
|
||||||
|
end
|
||||||
|
P-->>U: proposed ticket breakdown (step 9)
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Step 10 — Approval and filing
|
||||||
|
U->>P: one approval for the whole batch
|
||||||
|
opt track = spec + tickets
|
||||||
|
P->>T: create milestone "Spec: <title>"
|
||||||
|
end
|
||||||
|
P->>T: file tickets (assigned to the milestone on the spec track)
|
||||||
|
P->>T: set Status/Ready for Agent<br/>(only tickets with acceptance criteria)
|
||||||
|
P-->>U: links to spec, tickets, docs PR
|
||||||
|
```
|
||||||
|
|
||||||
## What ships today
|
## What ships today
|
||||||
|
|
||||||
- `.apm/prompts/next.prompt.md`: the `/next` command. It ranks open issues by a metric, lets the
|
- `.apm/prompts/next.prompt.md`: the `/next` command. It ranks open issues by a metric, lets the
|
||||||
@@ -87,13 +194,30 @@ circling.
|
|||||||
temporary.** Implementation does not belong in this plugin long term. It ships here so `/next`
|
temporary.** Implementation does not belong in this plugin long term. It ships here so `/next`
|
||||||
has a working handoff until implementation has a home.
|
has a working handoff until implementation has a home.
|
||||||
|
|
||||||
|
- `.apm/prompts/plan.prompt.md`: the `/plan` command, the MVP orchestrator for steps 0–10. It
|
||||||
|
dispatches the agents below and wires in existing skills at the step where each fits: `grilling`
|
||||||
|
with `domain-modeling` (no edits during grilling) and `plan-track` in step 2, including the
|
||||||
|
wayfinder early exit; `codebase-design` in step 5; and `gitea-labels-milestones` and
|
||||||
|
`gitea-issues` in steps 8–10 for the Ready-for-Agent strip and the `Spec:` milestone with ticket
|
||||||
|
assignment. Hand-invoked commands (`/wayfinder`, `/to-spec`, `/to-tickets`) and user-run ones
|
||||||
|
(`/write-docs`, `/research-docs`) are given to the user as copyable code blocks, and the user
|
||||||
|
running them is the approval.
|
||||||
|
- `.apm/agents/`: `plan-gate` (step 1), `plan-researcher` (step 3), `plan-validator` (step 4),
|
||||||
|
read-only (the researcher may write only to the scratchpad), and `plan-recorder` (step 7, the docs PR).
|
||||||
|
- `.apm/skills/plan-track/`: the track criteria for all three tracks, `wayfinder` included.
|
||||||
|
|
||||||
|
All of these are minimal stubs, to be built out. The prompt and agents route to `gitea-issues`,
|
||||||
|
`gitea-labels-milestones`, `gitea-prs`, `git-commits` and `agentsmd-author`, which `plan` does not
|
||||||
|
declare as dependencies: it assumes the `gitea`, `git` and `core` packages are installed.
|
||||||
|
`research-docs` and `write-docs` both ship in `plan`. `write-docs` moved from `bin` in `plan`
|
||||||
|
0.5.0 (`bin` 4.0.0 to 5.0.0).
|
||||||
|
|
||||||
## Open for later
|
## Open for later
|
||||||
|
|
||||||
- How plan hands off to `delivery`, and how the two plugins relate. Today `delivery` says only a
|
- How plan hands off to `delivery`, and how the two plugins relate. Today `delivery` says only a
|
||||||
human sets `Status/Ready for Agent`, while plan may set it (step 10). When the two meet, one
|
human sets `Status/Ready for Agent`, while plan may set it (step 10). When the two meet, one
|
||||||
of those rules has to change.
|
of those rules has to change.
|
||||||
- Templates for the spec and tickets. Plan will own them.
|
- Templates for the spec and tickets. Plan will own them.
|
||||||
- How epics are represented and tickets linked (milestones, map issues, dependency edges).
|
|
||||||
- Where research output goes: folded into the spec, or kept as findings files.
|
- Where research output goes: folded into the spec, or kept as findings files.
|
||||||
- Whether the tracker issue carries the session's state, so planning can be resumed across
|
- Whether the tracker issue carries the session's state, so planning can be resumed across
|
||||||
sessions.
|
sessions.
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# Pins this repo's apm with uv (ADR-0034). Not a Python package: there is no
|
||||||
|
# build system, and uv only installs the dev group below. Run apm as
|
||||||
|
# `uv run --frozen apm ...`; the repo's gate scripts spell that once in
|
||||||
|
# scripts/lib/apm.sh. uv pins the apm tool only, never plugin content
|
||||||
|
# (ADR-0024).
|
||||||
|
[project]
|
||||||
|
name = "holocron-tooling"
|
||||||
|
version = "0.0.0"
|
||||||
|
requires-python = ">=3.11"
|
||||||
|
dependencies = []
|
||||||
|
|
||||||
|
[tool.uv]
|
||||||
|
package = false
|
||||||
|
|
||||||
|
[dependency-groups]
|
||||||
|
dev = ["apm-cli==0.39.3"]
|
||||||
+23
-13
@@ -22,21 +22,26 @@
|
|||||||
# * no apm.lock.yaml in the package -> `lockfile-exists` fails with
|
# * no apm.lock.yaml in the package -> `lockfile-exists` fails with
|
||||||
# "apm.yml declares dependencies but apm.lock.yaml is absent"
|
# "apm.yml declares dependencies but apm.lock.yaml is absent"
|
||||||
# * an apm.lock.yaml in the package -> `lockfile-exists` passes and thereby
|
# * an apm.lock.yaml in the package -> `lockfile-exists` passes and thereby
|
||||||
# arms the other nine checks, and `drift` then fails demanding the
|
# arms the rest of the root check set (nine more on apm 0.28.0, fourteen
|
||||||
|
# on 0.39.3), and `drift` then fails demanding the
|
||||||
# dependency's skills be DEPLOYED inside the package
|
# dependency's skills be DEPLOYED inside the package
|
||||||
# (plugins/<pkg>/.agents/skills/...), which is meaningless for a package
|
# (plugins/<pkg>/.agents/skills/...), which is meaningless for a package
|
||||||
# and additionally litters it with an apm_modules/ tree
|
# and additionally litters it with an apm_modules/ tree
|
||||||
#
|
#
|
||||||
# So this hook waives exactly one failure: a plugin package whose ONLY failing
|
# So this hook waives exactly one failure: a plugin package whose ONLY failing
|
||||||
# check is `lockfile-exists`. Verified against apm 0.28.0.
|
# check is `lockfile-exists`. Verified against apm 0.28.0, and re-verified
|
||||||
|
# against 0.39.3 (spike #269, on #268): both matched strings below are unchanged,
|
||||||
|
# and no other check fails in any plugin directory.
|
||||||
#
|
#
|
||||||
# WHAT IS DELIBERATELY NOT WAIVED
|
# WHAT IS DELIBERATELY NOT WAIVED
|
||||||
#
|
#
|
||||||
# Dropping `--ci` in package directories would have been the smaller change and
|
# Dropping `--ci` in package directories would have been the smaller change and
|
||||||
# is WRONG. Verified on apm 0.28.0 against a scratch package whose dependency
|
# is WRONG. Verified on apm 0.28.0, and again on 0.39.3 (#272), against a
|
||||||
# entry carried no git/path/registry field: `apm audit --ci` exits 1 naming the
|
# scratch package whose dependency entry carried no git/path/registry field:
|
||||||
# field, while plain `apm audit` prints "No apm.lock.yaml found -- nothing to
|
# `apm audit --ci` exits 1 naming the field (a failing manifest-parse row on
|
||||||
# scan" and exits 0. Malformed-dependency detection is the reason gates.md gives
|
# 0.39.3), while plain `apm audit` exits 0 with "nothing to scan" ("No
|
||||||
|
# recognized deployed primitives found" on 0.39.3, "No apm.lock.yaml found"
|
||||||
|
# on 0.28.0). Malformed-dependency detection is the reason gates.md gives
|
||||||
# for auditing packages at all, and a package WITH dependencies is the only kind
|
# for auditing packages at all, and a package WITH dependencies is the only kind
|
||||||
# that can carry a malformed dependency entry -- so the check would have been
|
# that can carry a malformed dependency entry -- so the check would have been
|
||||||
# discarded precisely where it earns its keep.
|
# discarded precisely where it earns its keep.
|
||||||
@@ -55,12 +60,17 @@
|
|||||||
|
|
||||||
set -uo pipefail
|
set -uo pipefail
|
||||||
|
|
||||||
# Scrub git's repo-locating env before apm runs: pushed from a linked worktree,
|
# apm is the repo-pinned one, run through scripts/lib/apm.sh as
|
||||||
# the hook inherits an absolute GIT_DIR, and apm's drift replay runs `git init`
|
# `uv run --project <repo root> --frozen apm` (ADR-0034). Sourcing the helper
|
||||||
# / `git checkout` in a temp dir with it -- flipping core.bare=true and moving
|
# also scrubs git's repo-locating env before apm runs: pushed from a linked
|
||||||
# the worktree's HEAD (issue #204). See the helper for the full account.
|
# worktree, the hook inherits an absolute GIT_DIR, and apm's drift replay runs
|
||||||
# shellcheck source=scripts/lib/clean-git-env.sh
|
# `git init` / `git checkout` in a temp dir with it -- flipping core.bare=true
|
||||||
source "$(dirname "${BASH_SOURCE[0]}")/lib/clean-git-env.sh"
|
# and moving the worktree's HEAD (issue #204). See clean-git-env.sh for the
|
||||||
|
# full account.
|
||||||
|
# shellcheck source=scripts/lib/apm.sh
|
||||||
|
source "$(dirname "${BASH_SOURCE[0]}")/lib/apm.sh"
|
||||||
|
|
||||||
|
require_apm_version || exit 1
|
||||||
|
|
||||||
readonly WAIVED_CHECK='declares dependencies but apm.lock.yaml is absent'
|
readonly WAIVED_CHECK='declares dependencies but apm.lock.yaml is absent'
|
||||||
readonly SOLE_FAILURE='1 of 1 check(s) failed'
|
readonly SOLE_FAILURE='1 of 1 check(s) failed'
|
||||||
@@ -68,7 +78,7 @@ readonly SOLE_FAILURE='1 of 1 check(s) failed'
|
|||||||
status=0
|
status=0
|
||||||
|
|
||||||
for manifest_dir in . plugins/*/; do
|
for manifest_dir in . plugins/*/; do
|
||||||
output="$(cd "$manifest_dir" && apm audit --ci 2>&1)"
|
output="$(cd "$manifest_dir" && run_apm audit --ci 2>&1)"
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
|
|
||||||
if [ "$exit_code" -eq 0 ]; then
|
if [ "$exit_code" -eq 0 ]; then
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# apm-pack-check-clean pre-push hook: `apm pack --check-versions --check-clean
|
# apm-pack-check-clean pre-push hook: `apm pack --check-versions --check-clean
|
||||||
# --dry-run`, run with git's repo-locating env scrubbed first. A script rather
|
# --dry-run`, run through scripts/lib/apm.sh. That helper runs the repo-pinned
|
||||||
# than a bare `apm ...` entry only so it can source that scrub -- see
|
# apm as `uv run --project <repo root> --frozen apm` (ADR-0034), fails clearly
|
||||||
|
# below the minimum version, and scrubs git's repo-locating env first -- see
|
||||||
# scripts/lib/clean-git-env.sh and issue #204, and docs/spec/gates.md,
|
# scripts/lib/clean-git-env.sh and issue #204, and docs/spec/gates.md,
|
||||||
# "apm-audit-ci", the "apm runs with git's repo-locating env scrubbed" paragraph.
|
# "apm-audit-ci", the "apm runs with git's repo-locating env scrubbed" paragraph.
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# shellcheck source=scripts/lib/clean-git-env.sh
|
# shellcheck source=scripts/lib/apm.sh
|
||||||
source "$(dirname "${BASH_SOURCE[0]}")/lib/clean-git-env.sh"
|
source "$(dirname "${BASH_SOURCE[0]}")/lib/apm.sh"
|
||||||
|
|
||||||
exec apm pack --check-versions --check-clean --dry-run
|
require_apm_version || exit 1
|
||||||
|
# The guarded expansion keeps bash 3.2 happy under `set -u`: the helper seeds
|
||||||
|
# APM_CMD empty, and require_apm_version has already refused an empty one.
|
||||||
|
exec ${APM_CMD[@]+"${APM_CMD[@]}"} pack --check-versions --check-clean --dry-run
|
||||||
@@ -1,22 +1,37 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Fails the push when root apm.yml's executables.allow stops naming the actual
|
# Fails the push when root apm.yml's executables.allow stops naming the full
|
||||||
# version of every plugin that ships executables. A plugin ships executables
|
# identity and actual version of every plugin that ships executables. A plugin
|
||||||
# when plugins/<name>/.apm/hooks/ or plugins/<name>/bin/ exists; each one needs
|
# ships executables when plugins/<name>/.apm/hooks/ or plugins/<name>/bin/
|
||||||
# a '<name>#<version>' key, where <name> and <version> come from its own
|
# exists; each one needs a '<identity>#<version>' key:
|
||||||
# apm.yml (and <name> must equal the directory name, since keys use the
|
|
||||||
# package name). Every failing package is reported in one run.
|
|
||||||
#
|
#
|
||||||
# The grant itself is version-blind — apm matches the version-less name
|
# * <identity> is the package identity apm 0.39 matches grants on,
|
||||||
# alongside '<package>#<version>' (exec_gate.py builds the candidate list,
|
# <host>/<owner>/<repo>/<path>, e.g. git.rkdr.net/Mortis/Holocron/plugins/kyberforge.
|
||||||
# _map_grants matches it) — so a stale key keeps granting the package's hooks/
|
# It is derived from root apm.yml's own `git:` + `path:` dependency entry
|
||||||
# and bin/ and deployment does not break. What this gate buys is repo-level,
|
# for plugins/<name>, the same fields apm builds it from: the URL loses its
|
||||||
# not apm-level: a version bump without the matching key edit fails this
|
# scheme, any user@ and a trailing .git, and the path is appended. Verified
|
||||||
# repo's own pre-push, so each key stays an accurate record of what was
|
# against `apm approve --list` on apm 0.39.3 for a git+path entry on a
|
||||||
# approved. See ADR-0019's 2026-09-19 correction and docs/spec/gates.md,
|
# self-hosted host. A plugin with no such entry fails, because no key can be
|
||||||
# "check-executables-allow-sync"; nothing else in the pre-push gate compares
|
# derived for it.
|
||||||
# these files.
|
# * <version> comes from plugins/<name>/apm.yml (whose name: must equal the
|
||||||
|
# directory name).
|
||||||
|
#
|
||||||
|
# Every failing package is reported in one run.
|
||||||
|
#
|
||||||
|
# Under apm 0.28 a bare '<name>#<version>' key matched. Under 0.39.3 it does
|
||||||
|
# not: the hooks are parked, .claude/settings.json is rewritten without them,
|
||||||
|
# and root `apm audit --ci` still passes (spike #269, on #268). So a bare key is
|
||||||
|
# now a real deployment failure that nothing else catches, and this gate names
|
||||||
|
# it as one.
|
||||||
|
#
|
||||||
|
# The '#<version>' suffix is stripped before apm matches, so the grant is
|
||||||
|
# version-blind and a stale version keeps granting the package's hooks/ and
|
||||||
|
# bin/. What the version half buys is repo-level, not apm-level: a version bump
|
||||||
|
# without the matching key edit fails this repo's own pre-push, so each key
|
||||||
|
# stays an accurate record of what was approved. See ADR-0019's 2026-09-19
|
||||||
|
# correction and docs/spec/gates.md, "check-executables-allow-sync"; nothing
|
||||||
|
# else in the pre-push gate compares these files.
|
||||||
#
|
#
|
||||||
# Run from repo root or pass REPO_ROOT as arg.
|
# Run from repo root or pass REPO_ROOT as arg.
|
||||||
|
|
||||||
@@ -49,13 +64,64 @@ for plugin_dir in "$REPO_ROOT"/plugins/*/; do
|
|||||||
done
|
done
|
||||||
shopt -u nullglob
|
shopt -u nullglob
|
||||||
|
|
||||||
# Only a repo with no executable-shipping plugin at all is a legitimate no-op —
|
FAILED=0
|
||||||
# there is no version to pin and no hook to deploy.
|
|
||||||
if [[ ${#PLUGINS[@]} -eq 0 ]]; then
|
# ---------------------------------------------------------------------------
|
||||||
exit 0
|
# Parked executables in the lock (spike #269, on #268, section 7.3)
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# apm records each dependency's executables decision as `exec_status:` in
|
||||||
|
# apm.lock.yaml: `deployed`, or a `gated_*` value (for example
|
||||||
|
# `gated_pending_approval`) when the trust gate parked its hooks, bin or MCP
|
||||||
|
# servers. Root `apm audit --ci` passes in that state, because its
|
||||||
|
# exec-status-current check only asserts the lock agrees with the gate. So a
|
||||||
|
# wrong key, or a content-pinned hook whose script changed, would leave the
|
||||||
|
# SessionStart hook or the delivery guard silently uninstalled with every
|
||||||
|
# other gate green. This fails the push instead. Runs whether or not any
|
||||||
|
# plugin here ships executables: a third-party dependency can be parked too.
|
||||||
|
# A missing lock is not this check's concern (apm-audit-ci's lockfile-exists).
|
||||||
|
#
|
||||||
|
# A line scan, not a YAML parse: apm writes the lock with libyaml in one fixed
|
||||||
|
# shape, with `- repo_url:` opening each dependency and its fields at 2 spaces.
|
||||||
|
LOCKFILE="$REPO_ROOT/apm.lock.yaml"
|
||||||
|
if [[ -f "$LOCKFILE" ]]; then
|
||||||
|
GATED="$(awk '
|
||||||
|
/^[^ -]/ { in_deps = ($0 ~ /^dependencies:/); next }
|
||||||
|
!in_deps { next }
|
||||||
|
/^- / { host = ""; repo = ""; vpath = "" }
|
||||||
|
{
|
||||||
|
line = $0
|
||||||
|
sub(/^- /, " ", line)
|
||||||
|
if (line !~ /^ [a-z_]+: /) next
|
||||||
|
key = line; sub(/^ /, "", key); sub(/: .*/, "", key)
|
||||||
|
val = line; sub(/^ [a-z_]+: /, "", val); gsub(/["\047]/, "", val)
|
||||||
|
if (key == "host") host = val
|
||||||
|
else if (key == "repo_url") repo = val
|
||||||
|
else if (key == "virtual_path") vpath = val
|
||||||
|
else if (key == "exec_status" && val ~ /^gated_/) {
|
||||||
|
id = (host != "" ? host "/" : "") repo (vpath != "" ? "/" vpath : "")
|
||||||
|
printf "%s: %s\n", id, val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
' "$LOCKFILE")"
|
||||||
|
if [[ -n "$GATED" ]]; then
|
||||||
|
echo "FAIL: apm.lock.yaml records executables apm did not deploy:" >&2
|
||||||
|
while IFS= read -r line; do echo " $line" >&2; done <<< "$GATED"
|
||||||
|
echo " Why: a gated_* exec_status means the trust gate parked that package's hooks, bin or" >&2
|
||||||
|
echo " MCP servers: no executables.allow key matches it, or a content pin no longer" >&2
|
||||||
|
echo " does. Root 'apm audit --ci' still passes in that state (spike #269), so without" >&2
|
||||||
|
echo " this check a parked SessionStart hook or guard goes unnoticed." >&2
|
||||||
|
echo " Fix: run 'uv run --frozen apm approve --list' to see why each is parked, correct its" >&2
|
||||||
|
echo " executables.allow key in root apm.yml, then 'uv run --frozen apm install' and" >&2
|
||||||
|
echo " commit the rewritten apm.lock.yaml." >&2
|
||||||
|
FAILED=1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FAILED=0
|
# Only a repo with no executable-shipping plugin at all is a legitimate no-op
|
||||||
|
# for the key checks below — there is no version to pin and no hook to deploy.
|
||||||
|
if [[ ${#PLUGINS[@]} -eq 0 ]]; then
|
||||||
|
exit "$FAILED"
|
||||||
|
fi
|
||||||
|
|
||||||
# "hooks/ and bin/", "hooks/" or "bin/" — what the plugin actually ships, so a
|
# "hooks/ and bin/", "hooks/" or "bin/" — what the plugin actually ships, so a
|
||||||
# message never claims a package has a bin/ it does not.
|
# message never claims a package has a bin/ it does not.
|
||||||
@@ -110,6 +176,8 @@ fi
|
|||||||
# e<TAB><plugin dir><TAB><message> zero or more — the plugin's facts are unusable
|
# e<TAB><plugin dir><TAB><message> zero or more — the plugin's facts are unusable
|
||||||
# a<TAB>present|absent exactly once — is executables.allow a mapping?
|
# a<TAB>present|absent exactly once — is executables.allow a mapping?
|
||||||
# k<TAB><allow key> zero or more
|
# k<TAB><allow key> zero or more
|
||||||
|
# d<TAB><path><TAB><git url> zero or more — a root dependencies.apm entry
|
||||||
|
# carrying both git: and path:
|
||||||
#
|
#
|
||||||
# python3 + PyYAML is preferred where importable; the fallback below is not a
|
# python3 + PyYAML is preferred where importable; the fallback below is not a
|
||||||
# YAML parser, it recognises only the shapes these manifests use. PyYAML stays
|
# YAML parser, it recognises only the shapes these manifests use. PyYAML stays
|
||||||
@@ -167,6 +235,14 @@ if isinstance(allow, dict):
|
|||||||
print("k\t%s" % key)
|
print("k\t%s" % key)
|
||||||
else:
|
else:
|
||||||
print("a\tabsent")
|
print("a\tabsent")
|
||||||
|
|
||||||
|
dependencies = root.get("dependencies")
|
||||||
|
apm_deps = dependencies.get("apm") if isinstance(dependencies, dict) else None
|
||||||
|
for entry in apm_deps if isinstance(apm_deps, list) else []:
|
||||||
|
if isinstance(entry, dict):
|
||||||
|
git, path = entry.get("git"), entry.get("path")
|
||||||
|
if isinstance(git, str) and isinstance(path, str):
|
||||||
|
print("d\t%s\t%s" % (path, git))
|
||||||
PY
|
PY
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,6 +269,16 @@ top_level_scalar() {
|
|||||||
|
|
||||||
read_facts_bash() {
|
read_facts_bash() {
|
||||||
local line allow_state="absent" in_executables=0 in_allow=0 key plugin manifest
|
local line allow_state="absent" in_executables=0 in_allow=0 key plugin manifest
|
||||||
|
local in_deps=0 in_apm_deps=0 dep_git="" dep_path=""
|
||||||
|
|
||||||
|
# Emits the dependency entry collected so far, if it carried both fields.
|
||||||
|
flush_dep() {
|
||||||
|
if [[ -n "$dep_git" && -n "$dep_path" ]]; then
|
||||||
|
printf 'd\t%s\t%s\n' "$dep_path" "$dep_git"
|
||||||
|
fi
|
||||||
|
dep_git=""
|
||||||
|
dep_path=""
|
||||||
|
}
|
||||||
|
|
||||||
for plugin in ${READABLE[@]+"${READABLE[@]}"}; do
|
for plugin in ${READABLE[@]+"${READABLE[@]}"}; do
|
||||||
manifest="$REPO_ROOT/plugins/$plugin/apm.yml"
|
manifest="$REPO_ROOT/plugins/$plugin/apm.yml"
|
||||||
@@ -208,12 +294,38 @@ read_facts_bash() {
|
|||||||
# A top-level key (column 0) closes whatever block was open. Checked before
|
# A top-level key (column 0) closes whatever block was open. Checked before
|
||||||
# anything else so `marketplace:` after `executables:` cannot leak keys in.
|
# anything else so `marketplace:` after `executables:` cannot leak keys in.
|
||||||
if [[ "$line" != [[:space:]]* ]]; then
|
if [[ "$line" != [[:space:]]* ]]; then
|
||||||
if [[ "$line" == executables:* ]]; then
|
flush_dep
|
||||||
in_executables=1
|
in_executables=0
|
||||||
else
|
in_deps=0
|
||||||
in_executables=0
|
case "$line" in
|
||||||
fi
|
executables:*) in_executables=1 ;;
|
||||||
|
dependencies:*) in_deps=1 ;;
|
||||||
|
esac
|
||||||
in_allow=0
|
in_allow=0
|
||||||
|
in_apm_deps=0
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# dependencies: -> apm: -> a list of `- git: ...` / ` path: ...` items at
|
||||||
|
# 4-space indent, fields at 6 (or on the dash line itself).
|
||||||
|
if [[ $in_deps -eq 1 ]]; then
|
||||||
|
if [[ "$line" =~ ^\ \ [^[:space:]#] ]]; then
|
||||||
|
flush_dep
|
||||||
|
in_apm_deps=0
|
||||||
|
[[ "$line" =~ ^\ \ apm: ]] && in_apm_deps=1
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
[[ $in_apm_deps -eq 1 ]] || continue
|
||||||
|
if [[ "$line" =~ ^\ \ \ \ -\ * ]]; then
|
||||||
|
flush_dep
|
||||||
|
line=" ${line#*- }"
|
||||||
|
fi
|
||||||
|
if [[ "$line" =~ ^\ \ \ \ \ \ (git|path):(.*)$ ]]; then
|
||||||
|
if [[ "${BASH_REMATCH[1]}" == git ]]; then
|
||||||
|
dep_git="$(unquote "${BASH_REMATCH[2]}")"
|
||||||
|
else
|
||||||
|
dep_path="$(unquote "${BASH_REMATCH[2]}")"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
[[ $in_executables -eq 1 ]] || continue
|
[[ $in_executables -eq 1 ]] || continue
|
||||||
@@ -236,6 +348,7 @@ read_facts_bash() {
|
|||||||
printf 'k\t%s\n' "$key"
|
printf 'k\t%s\n' "$key"
|
||||||
fi
|
fi
|
||||||
done < "$ROOT_MANIFEST"
|
done < "$ROOT_MANIFEST"
|
||||||
|
flush_dep
|
||||||
|
|
||||||
printf 'a\t%s\n' "$allow_state"
|
printf 'a\t%s\n' "$allow_state"
|
||||||
}
|
}
|
||||||
@@ -263,11 +376,69 @@ fact() {
|
|||||||
ALLOW_STATE="$(printf '%s\n' "$FACTS" | sed -n 's/^a\t//p')"
|
ALLOW_STATE="$(printf '%s\n' "$FACTS" | sed -n 's/^a\t//p')"
|
||||||
ALLOW_KEYS="$(printf '%s\n' "$FACTS" | sed -n 's/^k\t//p')"
|
ALLOW_KEYS="$(printf '%s\n' "$FACTS" | sed -n 's/^k\t//p')"
|
||||||
|
|
||||||
|
# Strips one leading ./ and any trailing / from a dependency path.
|
||||||
|
norm_path() {
|
||||||
|
local path="${1#./}"
|
||||||
|
printf '%s' "${path%/}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# dep_url <plugin dir> — the git: URL of root apm.yml's git+path dependency
|
||||||
|
# entry for plugins/<plugin dir>; empty when it has none.
|
||||||
|
dep_url() {
|
||||||
|
local want="plugins/$1" tag path url
|
||||||
|
while IFS=$'\t' read -r tag path url; do
|
||||||
|
[[ "$tag" == d && "$(norm_path "$path")" == "$want" ]] || continue
|
||||||
|
printf '%s' "$url"
|
||||||
|
return
|
||||||
|
done <<< "$FACTS"
|
||||||
|
}
|
||||||
|
|
||||||
|
# url_has_port <url> — true when a scheme URL names a port (host:port).
|
||||||
|
url_has_port() {
|
||||||
|
local rest
|
||||||
|
[[ "$1" == *://* ]] || return 1
|
||||||
|
rest="${1#*://}"
|
||||||
|
rest="${rest%%/*}"
|
||||||
|
rest="${rest#*@}"
|
||||||
|
[[ "$rest" == *:* ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
# identity <plugin dir> — <host>/<owner>/<repo>/<path> from that entry; empty
|
||||||
|
# when there is none.
|
||||||
|
#
|
||||||
|
# Verified against apm 0.39.3 (`apm approve --list`) for an https URL on a
|
||||||
|
# lowercase host only. The scp-like (user@host:owner/repo) and ssh:// forms are
|
||||||
|
# derived by the same rule but were not checked against apm, and the host's
|
||||||
|
# case is kept as written, also unchecked. A URL with a port is refused before
|
||||||
|
# this runs (see the per-package checks): where apm puts a port in the
|
||||||
|
# identity is unknown, so a derived key could be wrong while looking right.
|
||||||
|
identity() {
|
||||||
|
local want="plugins/$1" url
|
||||||
|
url="$(dep_url "$1")"
|
||||||
|
[[ -n "$url" ]] || return 0
|
||||||
|
if [[ "$url" == *://* ]]; then
|
||||||
|
url="${url#*://}"
|
||||||
|
elif [[ "$url" == *:* ]]; then
|
||||||
|
url="${url/://}" # scp-like user@host:owner/repo
|
||||||
|
fi
|
||||||
|
url="${url#*@}"
|
||||||
|
url="${url%/}"
|
||||||
|
url="${url%.git}"
|
||||||
|
printf '%s/%s' "$url" "$want"
|
||||||
|
}
|
||||||
|
|
||||||
|
# expected_key <plugin dir> — '<identity>#<version>'.
|
||||||
|
expected_key() {
|
||||||
|
printf '%s#%s' "$(identity "$1")" "$(fact v "$1")"
|
||||||
|
}
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Per-package checks
|
# Per-package checks
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# EXPECTED: plugin dir names whose manifest is usable; the key each needs is
|
# EXPECTED: plugin dir names whose manifest is usable; the key each needs is
|
||||||
# '<dir>#<version>' because a usable manifest's name: equals its dir name.
|
# '<identity>#<version>'. The dir name is what finds the identity: it is
|
||||||
|
# matched against the `path: plugins/<dir>` of a root dependency entry, which
|
||||||
|
# is why a usable manifest's name: must equal it.
|
||||||
EXPECTED=()
|
EXPECTED=()
|
||||||
for plugin in ${READABLE[@]+"${READABLE[@]}"}; do
|
for plugin in ${READABLE[@]+"${READABLE[@]}"}; do
|
||||||
error="$(fact e "$plugin")"
|
error="$(fact e "$plugin")"
|
||||||
@@ -285,8 +456,9 @@ for plugin in ${READABLE[@]+"${READABLE[@]}"}; do
|
|||||||
|
|
||||||
if [[ "$name" != "$plugin" ]]; then
|
if [[ "$name" != "$plugin" ]]; then
|
||||||
echo "FAIL: plugins/$plugin/apm.yml declares name: '${name}', which does not match its directory '$plugin'." >&2
|
echo "FAIL: plugins/$plugin/apm.yml declares name: '${name}', which does not match its directory '$plugin'." >&2
|
||||||
echo " Why: executables.allow keys use the package name; with the two disagreeing this gate" >&2
|
echo " Why: the '<identity>#<version>' key is found through the directory name, which this gate" >&2
|
||||||
echo " cannot tell which '<name>#<version>' key root apm.yml should carry." >&2
|
echo " matches against root apm.yml's 'path: plugins/<dir>' entry; with name: disagreeing" >&2
|
||||||
|
echo " it cannot tell which package the key should be for." >&2
|
||||||
echo " Fix: make plugins/$plugin/apm.yml's name: equal '$plugin', or rename the directory (read by $READER)." >&2
|
echo " Fix: make plugins/$plugin/apm.yml's name: equal '$plugin', or rename the directory (read by $READER)." >&2
|
||||||
FAILED=1
|
FAILED=1
|
||||||
continue
|
continue
|
||||||
@@ -294,20 +466,42 @@ for plugin in ${READABLE[@]+"${READABLE[@]}"}; do
|
|||||||
|
|
||||||
if [[ -z "$version" ]]; then
|
if [[ -z "$version" ]]; then
|
||||||
echo "FAIL: plugins/$plugin/apm.yml declares no version:, so no allow key can be checked against it." >&2
|
echo "FAIL: plugins/$plugin/apm.yml declares no version:, so no allow key can be checked against it." >&2
|
||||||
echo " Why: the executables.allow key is '<package>#<version>'; with no version there is" >&2
|
echo " Why: the executables.allow key is '<identity>#<version>'; with no version there is" >&2
|
||||||
echo " nothing for root apm.yml's key to stay in sync with." >&2
|
echo " nothing for root apm.yml's key to stay in sync with." >&2
|
||||||
echo " Fix: give plugins/$plugin/apm.yml a top-level version: (read by $READER)." >&2
|
echo " Fix: give plugins/$plugin/apm.yml a top-level version: (read by $READER)." >&2
|
||||||
FAILED=1
|
FAILED=1
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$(identity "$plugin")" ]]; then
|
||||||
|
echo "FAIL: root apm.yml has no dependencies.apm entry with git: and path: plugins/$plugin, so the" >&2
|
||||||
|
echo " identity apm approves $plugin's $(ships "$plugin") under cannot be derived." >&2
|
||||||
|
echo " Why: apm 0.39 matches executables.allow on the full identity <host>/<owner>/<repo>/<path>," >&2
|
||||||
|
echo " built from that entry; this gate builds the expected key from the same fields." >&2
|
||||||
|
echo " Fix: declare plugins/$plugin in root apm.yml as a '- git: <url>' / 'path: plugins/$plugin'" >&2
|
||||||
|
echo " dependency (read by $READER)." >&2
|
||||||
|
FAILED=1
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if url_has_port "$(dep_url "$plugin")"; then
|
||||||
|
echo "FAIL: root apm.yml's dependency entry for plugins/$plugin uses a git: URL with a port," >&2
|
||||||
|
echo " '$(dep_url "$plugin")', so its executables.allow key cannot be derived reliably." >&2
|
||||||
|
echo " Why: this gate derives the full package identity apm 0.39 approves under from that URL," >&2
|
||||||
|
echo " and how apm writes a port into the identity was never verified." >&2
|
||||||
|
echo " Fix: use the URL without a port if the host allows it; otherwise read the identity from" >&2
|
||||||
|
echo " 'uv run --frozen apm approve --list' and extend this check to match it." >&2
|
||||||
|
FAILED=1
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
EXPECTED+=("$plugin")
|
EXPECTED+=("$plugin")
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ ${#EXPECTED[@]} -gt 0 && "$ALLOW_STATE" != "present" ]]; then
|
if [[ ${#EXPECTED[@]} -gt 0 && "$ALLOW_STATE" != "present" ]]; then
|
||||||
summary=""
|
summary=""
|
||||||
for plugin in ${EXPECTED[@]+"${EXPECTED[@]}"}; do
|
for plugin in ${EXPECTED[@]+"${EXPECTED[@]}"}; do
|
||||||
summary+="${summary:+, }$plugin#$(fact v "$plugin")"
|
summary+="${summary:+, }$(expected_key "$plugin")"
|
||||||
done
|
done
|
||||||
echo "FAIL: root apm.yml has no executables.allow mapping, but these packages ship executables: $summary." >&2
|
echo "FAIL: root apm.yml has no executables.allow mapping, but these packages ship executables: $summary." >&2
|
||||||
echo " Why: without an allow entry apm refuses to deploy a package's hooks/ and bin/ — for" >&2
|
echo " Why: without an allow entry apm refuses to deploy a package's hooks/ and bin/ — for" >&2
|
||||||
@@ -317,7 +511,7 @@ if [[ ${#EXPECTED[@]} -gt 0 && "$ALLOW_STATE" != "present" ]]; then
|
|||||||
echo " executables:" >&2
|
echo " executables:" >&2
|
||||||
echo " allow:" >&2
|
echo " allow:" >&2
|
||||||
for plugin in ${EXPECTED[@]+"${EXPECTED[@]}"}; do
|
for plugin in ${EXPECTED[@]+"${EXPECTED[@]}"}; do
|
||||||
echo " $plugin#$(fact v "$plugin"):" >&2
|
echo " $(expected_key "$plugin"):" >&2
|
||||||
if [[ -d "$REPO_ROOT/plugins/$plugin/.apm/hooks" ]]; then echo " hooks: true" >&2; fi
|
if [[ -d "$REPO_ROOT/plugins/$plugin/.apm/hooks" ]]; then echo " hooks: true" >&2; fi
|
||||||
if [[ -d "$REPO_ROOT/plugins/$plugin/bin" ]]; then echo " bin: true" >&2; fi
|
if [[ -d "$REPO_ROOT/plugins/$plugin/bin" ]]; then echo " bin: true" >&2; fi
|
||||||
done
|
done
|
||||||
@@ -325,18 +519,30 @@ if [[ ${#EXPECTED[@]} -gt 0 && "$ALLOW_STATE" != "present" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
for plugin in ${EXPECTED[@]+"${EXPECTED[@]}"}; do
|
for plugin in ${EXPECTED[@]+"${EXPECTED[@]}"}; do
|
||||||
expected_key="$plugin#$(fact v "$plugin")"
|
expected_key="$(expected_key "$plugin")"
|
||||||
if grep -qxF -- "$expected_key" <<< "$ALLOW_KEYS"; then
|
if grep -qxF -- "$expected_key" <<< "$ALLOW_KEYS"; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Keys for the right identity at another version, and bare '<name>#...' keys,
|
||||||
|
# which apm 0.28 matched and 0.39 does not.
|
||||||
stale_keys=()
|
stale_keys=()
|
||||||
|
bare_keys=()
|
||||||
while IFS= read -r key; do
|
while IFS= read -r key; do
|
||||||
if [[ -n "$key" && "$key" == "$plugin#"* ]]; then stale_keys+=("$key"); fi
|
[[ -n "$key" ]] || continue
|
||||||
|
if [[ "$key" == "$(identity "$plugin")#"* ]]; then stale_keys+=("$key"); fi
|
||||||
|
if [[ "$key" == "$plugin" || "$key" == "$plugin#"* ]]; then bare_keys+=("$key"); fi
|
||||||
done <<< "$ALLOW_KEYS"
|
done <<< "$ALLOW_KEYS"
|
||||||
|
|
||||||
echo "FAIL: root apm.yml's executables.allow has no '$expected_key' key, but that is $plugin's version." >&2
|
echo "FAIL: root apm.yml's executables.allow has no '$expected_key' key, but that is $plugin's identity and version." >&2
|
||||||
if [[ ${#stale_keys[@]} -gt 0 ]]; then
|
if [[ ${#bare_keys[@]} -gt 0 ]]; then
|
||||||
|
echo " Found instead:" >&2
|
||||||
|
printf ' %s\n' ${bare_keys[@]+"${bare_keys[@]}"} ${stale_keys[@]+"${stale_keys[@]}"} >&2
|
||||||
|
echo " Why: apm 0.39 matches grants on the full package identity. A bare '$plugin#...' key" >&2
|
||||||
|
echo " matches nothing, so $plugin's $(ships "$plugin") are parked, .claude/settings.json" >&2
|
||||||
|
echo " loses its entries, and root 'apm audit --ci' still passes (spike #269, on #268)." >&2
|
||||||
|
echo " Fix: rename the key in root apm.yml to '$expected_key:'." >&2
|
||||||
|
elif [[ ${#stale_keys[@]} -gt 0 ]]; then
|
||||||
echo " Found instead:" >&2
|
echo " Found instead:" >&2
|
||||||
printf ' %s\n' ${stale_keys[@]+"${stale_keys[@]}"} >&2
|
printf ' %s\n' ${stale_keys[@]+"${stale_keys[@]}"} >&2
|
||||||
echo " Why: nothing is broken right now — apm's grant is version-blind, so a key naming another" >&2
|
echo " Why: nothing is broken right now — apm's grant is version-blind, so a key naming another" >&2
|
||||||
|
|||||||
@@ -0,0 +1,110 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# The one place this repo spells how its scripts run apm (ADR-0034).
|
||||||
|
#
|
||||||
|
# Source it, call `require_apm_version || exit 1` once, then run apm as
|
||||||
|
# `run_apm <args>`. Sourcing also applies scripts/lib/clean-git-env.sh, so every
|
||||||
|
# gate that reaches apm through this helper runs it with git's repo-locating env
|
||||||
|
# scrubbed (issue #204).
|
||||||
|
#
|
||||||
|
# THE COMMAND
|
||||||
|
#
|
||||||
|
# uv run --project <repo root> --frozen apm
|
||||||
|
#
|
||||||
|
# * The pin is the dev group in the root pyproject.toml, locked by uv.lock. A
|
||||||
|
# bare `apm` would be whatever is on PATH, which on this machine is the global
|
||||||
|
# pipx 0.28.0 that refuses the v4 apm.lock.yaml (ADR-0034, consequence 1).
|
||||||
|
# * --project is the repo root, derived from this file's own location, never
|
||||||
|
# from the cwd. apm-audit-ci.sh runs apm from inside each plugins/<name>/, and
|
||||||
|
# uv's project discovery would otherwise start there. --project does not
|
||||||
|
# change the cwd, so apm still reads the manifest of the directory it runs in.
|
||||||
|
# * --frozen runs from uv.lock as committed and never re-resolves it. It does
|
||||||
|
# still sync the environment to that lock before running, and that is
|
||||||
|
# deliberate for gates, unlike the SessionStart hook, which adds --no-sync
|
||||||
|
# --offline (ADR-0034's 2026-12-02 amendment). A gate runs after the one-time
|
||||||
|
# `uv sync --frozen`, where that sync is a no-op that needs no network; and if
|
||||||
|
# the pin moves (a pull that bumps apm-cli), the sync brings the environment
|
||||||
|
# to the new pin instead of letting the gate certify the tree with a stale
|
||||||
|
# apm. The hook cannot afford that sync inside its timeout; a push gate can.
|
||||||
|
#
|
||||||
|
# APM overrides the command, as a seam for tests (ADR-0034, "Invocation"). It is
|
||||||
|
# split on whitespace, so it can name a stub or a full command line. The
|
||||||
|
# minimum-version check applies to it too, and an APM that holds only
|
||||||
|
# whitespace fails that check rather than silently running the default.
|
||||||
|
#
|
||||||
|
# Not meant to be executed directly.
|
||||||
|
|
||||||
|
# shellcheck source=scripts/lib/clean-git-env.sh
|
||||||
|
source "$(dirname "${BASH_SOURCE[0]}")/clean-git-env.sh"
|
||||||
|
|
||||||
|
APM_REPO_ROOT="$(CDPATH='' cd -- "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||||
|
# 0.39.2 is the lowest apm that reads and writes lockfile v4 in a form later
|
||||||
|
# versions accept, and it is above 0.39.0, which keeps Claude command keys such
|
||||||
|
# as disable-model-invocation (ADR-0034, "Minimum version").
|
||||||
|
APM_MIN_VERSION="0.39.2"
|
||||||
|
|
||||||
|
APM_CMD=()
|
||||||
|
if [[ -n "${APM:-}" ]]; then
|
||||||
|
read -r -a APM_CMD <<<"$APM"
|
||||||
|
else
|
||||||
|
APM_CMD=(uv run --project "$APM_REPO_ROOT" --frozen apm)
|
||||||
|
fi
|
||||||
|
|
||||||
|
run_apm() {
|
||||||
|
${APM_CMD[@]+"${APM_CMD[@]}"} "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Fails, with a message naming the fix, when the apm this helper resolves is
|
||||||
|
# missing, unreadable, or below APM_MIN_VERSION. Returns 0 when it is new enough.
|
||||||
|
require_apm_version() {
|
||||||
|
local output version stderr_file
|
||||||
|
if [[ ${#APM_CMD[@]} -eq 0 ]]; then
|
||||||
|
echo "FAIL: APM is set but holds only whitespace, so there is no apm command to run." >&2
|
||||||
|
echo " Fix: unset APM to run the repo-pinned apm, or set it to a command." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [[ -z "${APM:-}" ]] && ! command -v uv >/dev/null 2>&1; then
|
||||||
|
echo "FAIL: uv is not on PATH, and this repo runs apm as 'uv run --frozen apm' (ADR-0034)." >&2
|
||||||
|
echo " Fix: install uv, then run 'uv sync --frozen' at the repo root." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
# stdout only. uv writes its own lines to stderr when `uv run` syncs first
|
||||||
|
# (`Using CPython 3.14.6`, `Installed 62 packages`), and a merged stream
|
||||||
|
# would hand the parser uv's numbers instead of apm's. stderr is kept aside
|
||||||
|
# and shown only when the check fails.
|
||||||
|
stderr_file="$(mktemp)"
|
||||||
|
if ! output="$(run_apm --version 2>"$stderr_file")"; then
|
||||||
|
cat "$stderr_file" >&2
|
||||||
|
printf '%s\n' "$output" >&2
|
||||||
|
rm -f "$stderr_file"
|
||||||
|
echo "FAIL: could not run '${APM_CMD[*]} --version', so the apm version is unknown." >&2
|
||||||
|
echo " Fix: run 'uv sync --frozen' at the repo root, then retry." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
# Anchored to apm's banner, `Agent Package Manager (APM) CLI version X.Y.Z`,
|
||||||
|
# so no other version-like text on stdout can be taken for apm's version.
|
||||||
|
version="$(grep -oE 'CLI version [0-9]+\.[0-9]+\.[0-9]+' <<<"$output" | head -n 1 || true)"
|
||||||
|
version="${version#CLI version }"
|
||||||
|
if [[ ! "$version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
|
||||||
|
cat "$stderr_file" >&2
|
||||||
|
rm -f "$stderr_file"
|
||||||
|
echo "FAIL: '${APM_CMD[*]} --version' printed no 'CLI version X.Y.Z' banner, so the apm version is unknown." >&2
|
||||||
|
echo " Fix: run 'uv sync --frozen' at the repo root, then retry." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
rm -f "$stderr_file"
|
||||||
|
local -a have=("${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[3]}")
|
||||||
|
local -a need
|
||||||
|
IFS=. read -r -a need <<<"$APM_MIN_VERSION"
|
||||||
|
local i
|
||||||
|
for i in 0 1 2; do
|
||||||
|
((10#${have[i]} > 10#${need[i]})) && return 0
|
||||||
|
if ((10#${have[i]} < 10#${need[i]})); then
|
||||||
|
echo "FAIL: apm $version is below $APM_MIN_VERSION, the minimum this repo needs (ADR-0034)." >&2
|
||||||
|
echo " Why: apm before 0.39.2 cannot read this repo's lockfile v4 apm.lock.yaml in a form" >&2
|
||||||
|
echo " later versions accept, and before 0.39.0 it drops Claude command keys." >&2
|
||||||
|
echo " Fix: run 'uv sync --frozen' at the repo root so '${APM_CMD[*]}' resolves the pinned apm." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 0
|
||||||
|
}
|
||||||
+2
-1
@@ -40,7 +40,8 @@ fi
|
|||||||
# mirror's deletion reaches the default branch and `apm update` runs, apm
|
# mirror's deletion reaches the default branch and `apm update` runs, apm
|
||||||
# deploys from `.apm/` directly, `tests/` dirs and all. Nothing in apm filters
|
# deploys from `.apm/` directly, `tests/` dirs and all. Nothing in apm filters
|
||||||
# them -- its deploy-time copytree ignore callback (`ignore_non_content()` in
|
# them -- its deploy-time copytree ignore callback (`ignore_non_content()` in
|
||||||
# apm_cli/security/gate.py, 0.28.0) drops symlinks and the .apm-pin marker and
|
# apm_cli/security/gate.py, 0.28.0; still so on 0.39.3, which also drops
|
||||||
|
# generated Python bytecode) drops symlinks and the .apm-pin marker and
|
||||||
# nothing else. Every `<skill>/tests/*.bats` file under plugins/ would then
|
# nothing else. Every `<skill>/tests/*.bats` file under plugins/ would then
|
||||||
# land at .claude/skills/<name>/tests/ and be discovered and run a second time,
|
# land at .claude/skills/<name>/tests/ and be discovered and run a second time,
|
||||||
# which is ADR-0024 consequence 2 arriving here. Keeping the exclusion now is
|
# which is ADR-0024 consequence 2 arriving here. Keeping the exclusion now is
|
||||||
|
|||||||
+453
-13
@@ -2,9 +2,11 @@
|
|||||||
# Tests for plugins/kyberforge/.apm/hooks/check-apm-current.sh — the SessionStart
|
# Tests for plugins/kyberforge/.apm/hooks/check-apm-current.sh — the SessionStart
|
||||||
# hook that keeps an apm-consumed install level with its remote.
|
# hook that keeps an apm-consumed install level with its remote.
|
||||||
#
|
#
|
||||||
# `apm` is mocked throughout: the hook's contract is "read `apm outdated`, decide,
|
# `apm` and `uv` are mocked throughout (seam A: fake binaries first on PATH,
|
||||||
# emit SessionStart JSON", and that is testable without a network or a real
|
# asserting on exit code and stdout, plus the fakes' own call logs): the hook's
|
||||||
# install.
|
# contract is "pick the apm, read `apm outdated`, decide, emit SessionStart
|
||||||
|
# JSON", and that is testable without a network or a real install. The real
|
||||||
|
# apm appears once, at the end, to pin the phrase the hook greps for.
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
@@ -31,12 +33,15 @@ GIT_CEILING_DIRECTORIES="$(dirname "$WORK")"
|
|||||||
# `apm update`. Sentinel files record whether update was actually invoked and
|
# `apm update`. Sentinel files record whether update was actually invoked and
|
||||||
# which directory the calls ran in — the hook must run them against the same
|
# which directory the calls ran in — the hook must run them against the same
|
||||||
# directory its lockfile guard checked, not the session's cwd.
|
# directory its lockfile guard checked, not the session's cwd.
|
||||||
|
# `apm --version` answers 0.39.3 unless $3 says otherwise: the hook skips the
|
||||||
|
# outdated check on anything older than 0.39.2 (ADR-0034).
|
||||||
make_apm() {
|
make_apm() {
|
||||||
local outdated_line="$1" update_exit="$2"
|
local outdated_line="$1" update_exit="$2" version="${3:-0.39.3}"
|
||||||
cat > "$FAKE_BIN/apm" << EOF
|
cat > "$FAKE_BIN/apm" << EOF
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
pwd > "$WORK/apm-cwd"
|
pwd > "$WORK/apm-cwd"
|
||||||
case "\$1" in
|
case "\$1" in
|
||||||
|
--version) echo "Agent Package Manager (APM) CLI version $version"; exit 0 ;;
|
||||||
outdated) echo "$outdated_line"; exit 0 ;;
|
outdated) echo "$outdated_line"; exit 0 ;;
|
||||||
update) touch "$WORK/update-was-called"; exit $update_exit ;;
|
update) touch "$WORK/update-was-called"; exit $update_exit ;;
|
||||||
esac
|
esac
|
||||||
@@ -291,6 +296,414 @@ out="$(run_hook_in "$ELSEWHERE" "$ELSEWHERE")"; rc=$?
|
|||||||
&& pass "does not run apm update when there is no lockfile anywhere" \
|
&& pass "does not run apm update when there is no lockfile anywhere" \
|
||||||
|| fail "must not touch a project that does not use apm"
|
|| fail "must not touch a project that does not use apm"
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "--- which apm: repo-pinned uv, else PATH, else nothing (ADR-0034) ---"
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Seam A: every binary the hook may call is a fake first on a PATH that holds
|
||||||
|
# nothing else of interest. The machine's real uv and apm must not leak into
|
||||||
|
# these cases — a real uv would make "pin but no uv" untestable — so PATH is
|
||||||
|
# built from a whitelist of the system tools the hook and the fakes need.
|
||||||
|
TOOLS="$(mktemp -d)"
|
||||||
|
UV_BIN="$(mktemp -d)"
|
||||||
|
PIN_BIN="$(mktemp -d)"
|
||||||
|
PATH_APM_BIN="$(mktemp -d)"
|
||||||
|
PINNED="$(mktemp -d)"
|
||||||
|
trap 'rm -rf "$FAKE_BIN" "$WORK" "$TOOLS" "$UV_BIN" "$PIN_BIN" "$PATH_APM_BIN" "$PINNED" "${PROBE:-}"' EXIT
|
||||||
|
for tool in bash grep git cat touch head; do
|
||||||
|
src="$(command -v "$tool" || true)"
|
||||||
|
[[ -n "$src" ]] && ln -s "$src" "$TOOLS/$tool"
|
||||||
|
done
|
||||||
|
# A fake `timeout` that drops its duration and runs the command unbounded, so
|
||||||
|
# the suite does not need coreutils (stock macOS has no `timeout`). The real
|
||||||
|
# bound is the hook's business; these cases only need it to resolve one.
|
||||||
|
TIMEOUT_SHIM="$TOOLS/timeout"
|
||||||
|
printf '#!/usr/bin/env bash\nshift\nexec "$@"\n' > "$TIMEOUT_SHIM"
|
||||||
|
chmod +x "$TIMEOUT_SHIM"
|
||||||
|
|
||||||
|
# A fake apm at $1 that records, under $2, which phases ran. $3 is the
|
||||||
|
# `apm outdated` line, $4 the `apm update` exit code, $5 the version string.
|
||||||
|
make_fake_apm() {
|
||||||
|
local bin_dir="$1" tag="$2" outdated_line="$3" update_exit="$4" version="$5"
|
||||||
|
cat > "$bin_dir/apm" << EOF
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
echo "\$*" >> "$WORK/$tag-calls"
|
||||||
|
case "\$1" in
|
||||||
|
--version) printf '%s\n' "$version"; exit 0 ;;
|
||||||
|
outdated) cat "$WORK/$tag-outdated.txt"; exit 0 ;;
|
||||||
|
update) exit $update_exit ;;
|
||||||
|
esac
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
printf '%s\n' "$outdated_line" > "$WORK/$tag-outdated.txt"
|
||||||
|
chmod +x "$bin_dir/apm"
|
||||||
|
}
|
||||||
|
|
||||||
|
# The fake uv logs every invocation verbatim and only knows `run`: anything
|
||||||
|
# else exits 2. For `run` it skips uv's own options up to the `apm` argument
|
||||||
|
# and execs the pinned fake apm, which is NOT on PATH — so the pinned apm is
|
||||||
|
# reachable only through `uv run`.
|
||||||
|
cat > "$UV_BIN/uv" << EOF
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
printf '%s\n' "\$*" >> "$WORK/uv-calls"
|
||||||
|
[[ "\${1:-}" == run ]] || exit 2
|
||||||
|
[[ -f "$WORK/uv-run-fails" ]] && exit 1
|
||||||
|
shift
|
||||||
|
while [[ \$# -gt 0 && "\$1" != apm ]]; do
|
||||||
|
case "\$1" in --project) shift 2 ;; *) shift ;; esac
|
||||||
|
done
|
||||||
|
[[ "\${1:-}" == apm ]] || exit 2
|
||||||
|
shift
|
||||||
|
exec "$PIN_BIN/apm" "\$@"
|
||||||
|
EOF
|
||||||
|
chmod +x "$UV_BIN/uv"
|
||||||
|
|
||||||
|
# The pin: a pyproject.toml naming apm-cli plus a uv.lock, as ADR-0034 lays out.
|
||||||
|
cat > "$PINNED/pyproject.toml" << 'EOF'
|
||||||
|
[project]
|
||||||
|
name = "consumer"
|
||||||
|
version = "0"
|
||||||
|
requires-python = ">=3.11"
|
||||||
|
|
||||||
|
[tool.uv]
|
||||||
|
package = false
|
||||||
|
|
||||||
|
[dependency-groups]
|
||||||
|
dev = ["apm-cli==0.39.3"]
|
||||||
|
EOF
|
||||||
|
touch "$PINNED/uv.lock" "$PINNED/apm.lock.yaml"
|
||||||
|
# A synced project environment. Without one the hook must not call uv at all.
|
||||||
|
mkdir -p "$PINNED/.venv"
|
||||||
|
|
||||||
|
STALE="[!] 4 outdated dependencies found"
|
||||||
|
CURRENT="[*] All dependencies are up-to-date"
|
||||||
|
V_NEW="Agent Package Manager (APM) CLI version 0.39.3"
|
||||||
|
|
||||||
|
reset_calls() { rm -f "$WORK"/uv-calls "$WORK"/pin-calls "$WORK"/path-calls; }
|
||||||
|
calls_of() { cat "$WORK/$1-calls" 2>/dev/null || true; }
|
||||||
|
|
||||||
|
# $1: space-separated PATH components drawn from uv, apm. Always ends in TOOLS.
|
||||||
|
run_pinned() {
|
||||||
|
local p="" part
|
||||||
|
for part in $1; do
|
||||||
|
case "$part" in
|
||||||
|
uv) p+="$UV_BIN:" ;;
|
||||||
|
apm) p+="$PATH_APM_BIN:" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
(cd "$PINNED" && env -u CLAUDE_PROJECT_DIR -u UV_PROJECT_ENVIRONMENT PATH="${p}${RUN_TOOLS:-$TOOLS}" bash "$HOOK" 2>/dev/null)
|
||||||
|
}
|
||||||
|
ctx_of() { json_field additionalContext <<< "$1" 2>/dev/null || true; }
|
||||||
|
|
||||||
|
# Every recorded uv call must be `uv run` against the project, frozen, and with
|
||||||
|
# syncing off: a SessionStart hook must never install into the environment.
|
||||||
|
assert_uv_calls_run_only() {
|
||||||
|
local label="$1" n=0 bad=0 line
|
||||||
|
while IFS= read -r line; do
|
||||||
|
[[ -n "$line" ]] || continue
|
||||||
|
n=$((n + 1))
|
||||||
|
[[ "$line" == "run "* ]] || bad=1
|
||||||
|
[[ " $line " == *" sync "* ]] && bad=1
|
||||||
|
[[ " $line " == *" --frozen "* && " $line " == *" --no-sync "* && " $line " == *" --offline "* ]] || bad=1
|
||||||
|
[[ " $line " == *" --project $PINNED "* ]] || bad=1
|
||||||
|
done < <(calls_of uv)
|
||||||
|
if [[ $n -eq 0 ]]; then
|
||||||
|
fail "$label: expected uv to be called at least once, it was not"
|
||||||
|
elif [[ $bad -eq 0 ]]; then
|
||||||
|
pass "$label: all $n uv call(s) are \`uv run --project <root> --frozen --no-sync --offline\`, none is a sync"
|
||||||
|
else
|
||||||
|
fail "$label: uv was called with something other than a frozen no-sync \`run\`: $(tr '\n' '|' <<< "$(calls_of uv)")"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- pin plus uv: uses `uv run`, for both the check and the update ---
|
||||||
|
make_fake_apm "$PIN_BIN" pin "$STALE" 1 "$V_NEW"
|
||||||
|
make_fake_apm "$PATH_APM_BIN" path "$STALE" 1 "$V_NEW"
|
||||||
|
reset_calls
|
||||||
|
out="$(run_pinned "uv apm")"; rc=$?
|
||||||
|
[[ $rc -eq 0 ]] && pass "pin + uv: exits 0" || fail "pin + uv: exit $rc"
|
||||||
|
grep -q "^outdated" <<< "$(calls_of pin)" && grep -q "^update" <<< "$(calls_of pin)" \
|
||||||
|
&& pass "pin + uv: runs the outdated check and the update through \`uv run\`" \
|
||||||
|
|| fail "pin + uv: the pinned apm should see outdated and update, saw: $(calls_of pin | tr '\n' '|')"
|
||||||
|
[[ -z "$(calls_of path)" ]] && pass "pin + uv: never touches the PATH apm" \
|
||||||
|
|| fail "pin + uv: PATH apm was called: $(calls_of path | tr '\n' '|')"
|
||||||
|
grep -qF "Run: uv run apm update --yes" <<< "$(ctx_of "$out")" \
|
||||||
|
&& pass "pin + uv: the failed-refresh advice names \`uv run apm\`" \
|
||||||
|
|| fail "pin + uv: advice should name uv run apm: $(ctx_of "$out")"
|
||||||
|
assert_uv_calls_run_only "pin + uv, stale"
|
||||||
|
|
||||||
|
# --- stale and current on the uv path ---
|
||||||
|
make_fake_apm "$PIN_BIN" pin "$STALE" 0 "$V_NEW"
|
||||||
|
reset_calls
|
||||||
|
out="$(run_pinned "uv")"
|
||||||
|
[[ "$(json_field reloadSkills <<< "$out" 2>/dev/null)" == "True" ]] \
|
||||||
|
&& grep -q "4 package" <<< "$(ctx_of "$out")" \
|
||||||
|
&& pass "uv path, stale: refreshes and reports the count" \
|
||||||
|
|| fail "uv path, stale: expected a successful-refresh notice, got: $out"
|
||||||
|
assert_uv_calls_run_only "uv path, stale"
|
||||||
|
|
||||||
|
make_fake_apm "$PIN_BIN" pin "$CURRENT" 0 "$V_NEW"
|
||||||
|
reset_calls
|
||||||
|
out="$(run_pinned "uv")"; rc=$?
|
||||||
|
[[ $rc -eq 0 && -z "$out" ]] && pass "uv path, current: silent, exit 0" \
|
||||||
|
|| fail "uv path, current: expected silence, got rc=$rc: $out"
|
||||||
|
grep -q "^update" <<< "$(calls_of pin)" && fail "uv path, current: must not update" \
|
||||||
|
|| pass "uv path, current: does not update"
|
||||||
|
assert_uv_calls_run_only "uv path, current"
|
||||||
|
|
||||||
|
# A feature branch's discard advice names the binary that will reinstall.
|
||||||
|
git -C "$PINNED" init -q -b main
|
||||||
|
git -C "$PINNED" -c user.email=[email protected] -c user.name=probe commit -q --allow-empty -m init
|
||||||
|
git -C "$PINNED" update-ref refs/remotes/origin/main HEAD
|
||||||
|
git -C "$PINNED" symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
|
||||||
|
git -C "$PINNED" checkout -q -b feature/y
|
||||||
|
make_fake_apm "$PIN_BIN" pin "$STALE" 0 "$V_NEW"
|
||||||
|
reset_calls
|
||||||
|
out="$(run_pinned "uv")"
|
||||||
|
grep -qF "git checkout -- apm.lock.yaml && uv run apm install" <<< "$(ctx_of "$out")" \
|
||||||
|
&& pass "uv path, feature branch: the discard advice names \`uv run apm install\`" \
|
||||||
|
|| fail "uv path, feature branch: advice should name uv run apm install: $(ctx_of "$out")"
|
||||||
|
rm -rf "$PINNED/.git"
|
||||||
|
|
||||||
|
# --- pinned apm too old (an unsynced env falls through to an old apm) ---
|
||||||
|
make_fake_apm "$PIN_BIN" pin "$CURRENT" 0 "Agent Package Manager (APM) CLI version 0.28.0"
|
||||||
|
reset_calls
|
||||||
|
out="$(run_pinned "uv")"; rc=$?
|
||||||
|
[[ $rc -eq 0 ]] && pass "uv path, apm 0.28.0: exits 0" || fail "uv path, apm 0.28.0: exit $rc"
|
||||||
|
grep -q "^outdated" <<< "$(calls_of pin)" && fail "uv path, apm 0.28.0: ran the outdated check on a too-old apm" \
|
||||||
|
|| pass "uv path, apm 0.28.0: runs no outdated check"
|
||||||
|
grep -qF "\`uv run apm\` is older than apm 0.39.2" <<< "$(ctx_of "$out")" \
|
||||||
|
&& grep -qF "Run: uv sync --frozen" <<< "$(ctx_of "$out")" \
|
||||||
|
&& pass "uv path, apm 0.28.0: prints the fixed too-old line naming \`uv run apm\`" \
|
||||||
|
|| fail "uv path, apm 0.28.0: expected the uv too-old line, got: $out"
|
||||||
|
assert_uv_calls_run_only "uv path, too old"
|
||||||
|
|
||||||
|
# --- pin but no uv: falls back to the PATH apm ---
|
||||||
|
make_fake_apm "$PIN_BIN" pin "$STALE" 0 "$V_NEW"
|
||||||
|
make_fake_apm "$PATH_APM_BIN" path "$STALE" 1 "$V_NEW"
|
||||||
|
reset_calls
|
||||||
|
out="$(run_pinned "apm")"; rc=$?
|
||||||
|
[[ $rc -eq 0 ]] && pass "pin, no uv: exits 0" || fail "pin, no uv: exit $rc"
|
||||||
|
grep -q "^outdated" <<< "$(calls_of path)" && grep -q "^update" <<< "$(calls_of path)" \
|
||||||
|
&& pass "pin, no uv: falls back to the PATH apm for the check and the update" \
|
||||||
|
|| fail "pin, no uv: PATH apm should run, saw: $(calls_of path | tr '\n' '|')"
|
||||||
|
[[ -z "$(calls_of pin)" ]] && pass "pin, no uv: the pinned apm is not reached" \
|
||||||
|
|| fail "pin, no uv: pinned apm ran without uv"
|
||||||
|
ctx="$(ctx_of "$out")"
|
||||||
|
grep -qF "Run: apm update --yes" <<< "$ctx" && ! grep -qF "uv run" <<< "$ctx" \
|
||||||
|
&& pass "pin, no uv: advice names the bare \`apm\`, not \`uv run apm\`" \
|
||||||
|
|| fail "pin, no uv: advice should name apm only: $ctx"
|
||||||
|
|
||||||
|
# --- pin declared but no uv.lock: `--frozen` has nothing to run from ---
|
||||||
|
rm -f "$PINNED/uv.lock"
|
||||||
|
reset_calls
|
||||||
|
out="$(run_pinned "uv apm")"
|
||||||
|
[[ -z "$(calls_of uv)" ]] && grep -q "^outdated" <<< "$(calls_of path)" \
|
||||||
|
&& pass "pin without uv.lock: does not call uv, uses the PATH apm" \
|
||||||
|
|| fail "pin without uv.lock: expected PATH apm only, uv saw: $(calls_of uv | tr '\n' '|')"
|
||||||
|
touch "$PINNED/uv.lock"
|
||||||
|
|
||||||
|
# --- no pin, with a PATH apm: uv on PATH is ignored ---
|
||||||
|
mv "$PINNED/pyproject.toml" "$PINNED/pyproject.toml.off"
|
||||||
|
make_fake_apm "$PATH_APM_BIN" path "$STALE" 0 "$V_NEW"
|
||||||
|
reset_calls
|
||||||
|
out="$(run_pinned "uv apm")"
|
||||||
|
[[ -z "$(calls_of uv)" ]] && pass "no pin: never calls uv even when it is on PATH" \
|
||||||
|
|| fail "no pin: uv was called: $(calls_of uv | tr '\n' '|')"
|
||||||
|
grep -q "^update" <<< "$(calls_of path)" && [[ "$(json_field reloadSkills <<< "$out" 2>/dev/null)" == "True" ]] \
|
||||||
|
&& pass "no pin, PATH path, stale: refreshes through the PATH apm" \
|
||||||
|
|| fail "no pin, PATH path, stale: expected a refresh via PATH apm, got: $out"
|
||||||
|
|
||||||
|
make_fake_apm "$PATH_APM_BIN" path "$CURRENT" 0 "$V_NEW"
|
||||||
|
reset_calls
|
||||||
|
out="$(run_pinned "uv apm")"; rc=$?
|
||||||
|
[[ $rc -eq 0 && -z "$out" ]] && ! grep -q "^update" <<< "$(calls_of path)" \
|
||||||
|
&& pass "no pin, PATH path, current: silent, no update" \
|
||||||
|
|| fail "no pin, PATH path, current: expected silence, got rc=$rc: $out"
|
||||||
|
|
||||||
|
# A pyproject.toml that does not mention apm-cli is not a pin.
|
||||||
|
printf '[project]\nname = "other"\ndependencies = ["apm-client-lib>=1"]\n' > "$PINNED/pyproject.toml"
|
||||||
|
make_fake_apm "$PATH_APM_BIN" path "$CURRENT" 0 "$V_NEW"
|
||||||
|
reset_calls
|
||||||
|
run_pinned "uv apm" > /dev/null
|
||||||
|
[[ -z "$(calls_of uv)" ]] && pass "a pyproject.toml without apm-cli is not read as a pin" \
|
||||||
|
|| fail "apm-client-lib was mistaken for an apm-cli pin"
|
||||||
|
rm -f "$PINNED/pyproject.toml"
|
||||||
|
mv "$PINNED/pyproject.toml.off" "$PINNED/pyproject.toml"
|
||||||
|
|
||||||
|
# --- no apm at all (the pin is present, uv and apm are not): silent, exit 0 ---
|
||||||
|
reset_calls
|
||||||
|
out="$(run_pinned "")"; rc=$?
|
||||||
|
[[ $rc -eq 0 && -z "$out" ]] && pass "no uv, no apm: silent, exit 0" \
|
||||||
|
|| fail "no uv, no apm: expected silence, got rc=$rc: $out"
|
||||||
|
|
||||||
|
# --- PATH apm below 0.39.2: fixed too-old line, no outdated check ---
|
||||||
|
for v in 0.28.0 0.39.1 "no version here"; do
|
||||||
|
make_fake_apm "$PATH_APM_BIN" path "$STALE" 0 "Agent Package Manager (APM) CLI version $v"
|
||||||
|
want="\`apm\` on PATH is older than apm 0.39.2"
|
||||||
|
if [[ "$v" == "no version here" ]]; then
|
||||||
|
make_fake_apm "$PATH_APM_BIN" path "$STALE" 0 "$v"
|
||||||
|
want="Could not read the version of \`apm\` on PATH"
|
||||||
|
fi
|
||||||
|
reset_calls
|
||||||
|
out="$(run_pinned "apm")"; rc=$?
|
||||||
|
ctx="$(ctx_of "$out")"
|
||||||
|
if [[ $rc -eq 0 ]] && ! grep -qE "^(outdated|update)" <<< "$(calls_of path)" \
|
||||||
|
&& grep -qF "$want" <<< "$ctx" \
|
||||||
|
&& [[ "$(json_field reloadSkills <<< "$out" 2>/dev/null)" == "False" ]]; then
|
||||||
|
pass "PATH apm reporting '$v': fixed notice ($want), no outdated check, no update"
|
||||||
|
else
|
||||||
|
fail "PATH apm reporting '$v': expected the too-old line and no outdated call; rc=$rc calls=$(calls_of path | tr '\n' '|') out=$out"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
grep -qF "uv run" <<< "$ctx" && fail "PATH too-old line must not name uv run: $ctx" \
|
||||||
|
|| pass "PATH too-old line names the bare apm only"
|
||||||
|
|
||||||
|
# The boundary is inclusive: 0.39.2 is new enough, and so is a later minor.
|
||||||
|
for v in 0.39.2 0.40.0 1.0.0; do
|
||||||
|
make_fake_apm "$PATH_APM_BIN" path "$STALE" 0 "Agent Package Manager (APM) CLI version $v"
|
||||||
|
reset_calls
|
||||||
|
run_pinned "apm" > /dev/null
|
||||||
|
grep -q "^outdated" <<< "$(calls_of path)" \
|
||||||
|
&& pass "PATH apm $v: new enough, runs the outdated check" \
|
||||||
|
|| fail "PATH apm $v: should be accepted as new enough"
|
||||||
|
done
|
||||||
|
|
||||||
|
# --- pin and uv, but no project environment: never call uv ---
|
||||||
|
# `uv run --no-sync` would create an empty .venv in the consumer's repo.
|
||||||
|
rm -rf "$PINNED/.venv"
|
||||||
|
make_fake_apm "$PIN_BIN" pin "$STALE" 0 "$V_NEW"
|
||||||
|
make_fake_apm "$PATH_APM_BIN" path "$STALE" 0 "$V_NEW"
|
||||||
|
reset_calls
|
||||||
|
out="$(run_pinned "uv apm")"; rc=$?
|
||||||
|
[[ $rc -eq 0 ]] && grep -qF "its environment has not been synced" <<< "$(ctx_of "$out")" \
|
||||||
|
&& grep -qF "Run: uv sync --frozen" <<< "$(ctx_of "$out")" \
|
||||||
|
&& pass "pin + uv, no .venv: prints the fixed not-synced notice" \
|
||||||
|
|| fail "pin + uv, no .venv: expected the not-synced notice, got rc=$rc: $out"
|
||||||
|
[[ -z "$(calls_of uv)" && -z "$(calls_of path)" ]] \
|
||||||
|
&& pass "pin + uv, no .venv: calls neither uv nor the PATH apm" \
|
||||||
|
|| fail "pin + uv, no .venv: uv saw '$(calls_of uv | tr '\n' '|')', PATH apm saw '$(calls_of path | tr '\n' '|')'"
|
||||||
|
[[ ! -e "$PINNED/.venv" ]] && pass "pin + uv, no .venv: creates no .venv" \
|
||||||
|
|| fail "pin + uv, no .venv: a .venv appeared in the project"
|
||||||
|
|
||||||
|
# UV_PROJECT_ENVIRONMENT relocates the environment; an existing one there counts.
|
||||||
|
ALT_ENV="$WORK/alt-env"
|
||||||
|
mkdir -p "$ALT_ENV"
|
||||||
|
reset_calls
|
||||||
|
out="$(cd "$PINNED" && env -u CLAUDE_PROJECT_DIR UV_PROJECT_ENVIRONMENT="$ALT_ENV" PATH="$UV_BIN:$TOOLS" bash "$HOOK" 2>/dev/null)"
|
||||||
|
grep -q "^outdated" <<< "$(calls_of pin)" \
|
||||||
|
&& pass "UV_PROJECT_ENVIRONMENT pointing at an existing env: takes the uv path" \
|
||||||
|
|| fail "UV_PROJECT_ENVIRONMENT should satisfy the environment check, got: $out"
|
||||||
|
reset_calls
|
||||||
|
out="$(cd "$PINNED" && env -u CLAUDE_PROJECT_DIR UV_PROJECT_ENVIRONMENT="$WORK/no-such-env" PATH="$UV_BIN:$TOOLS" bash "$HOOK" 2>/dev/null)"
|
||||||
|
[[ -z "$(calls_of uv)" ]] && grep -qF "has not been synced" <<< "$(ctx_of "$out")" \
|
||||||
|
&& pass "UV_PROJECT_ENVIRONMENT pointing at nothing: not-synced notice, no uv call" \
|
||||||
|
|| fail "UV_PROJECT_ENVIRONMENT pointing at nothing should not call uv, got: $out"
|
||||||
|
mkdir -p "$PINNED/.venv"
|
||||||
|
|
||||||
|
# --- pin and uv, but `uv run` itself fails ---
|
||||||
|
for how in "uv run exits non-zero" "no pinned apm to exec"; do
|
||||||
|
make_fake_apm "$PIN_BIN" pin "$STALE" 0 "$V_NEW"
|
||||||
|
if [[ "$how" == "uv run exits non-zero" ]]; then touch "$WORK/uv-run-fails"; else rm -f "$PIN_BIN/apm"; fi
|
||||||
|
reset_calls
|
||||||
|
out="$(run_pinned "uv")"; rc=$?
|
||||||
|
ctx="$(ctx_of "$out")"
|
||||||
|
[[ $rc -eq 0 ]] && grep -qF "Could not read the version of \`uv run apm\` (it failed or timed out)" <<< "$ctx" \
|
||||||
|
&& grep -qF "or run: uv sync --frozen" <<< "$ctx" \
|
||||||
|
&& ! grep -qF "not synced" <<< "$ctx" \
|
||||||
|
&& pass "pin + uv, $how: exits 0 with the fixed unreadable-version notice, not the not-synced one" \
|
||||||
|
|| fail "pin + uv, $how: expected the unreadable-version notice, got rc=$rc: $out"
|
||||||
|
assert_uv_calls_run_only "pin + uv, $how"
|
||||||
|
rm -f "$WORK/uv-run-fails"
|
||||||
|
done
|
||||||
|
|
||||||
|
# --- no timeout binary: nothing can be bounded, so stay silent ---
|
||||||
|
NO_TO="$WORK/tools-no-timeout"
|
||||||
|
G_TO="$WORK/tools-gtimeout"
|
||||||
|
mkdir -p "$NO_TO" "$G_TO"
|
||||||
|
for tool in bash grep git cat touch head; do
|
||||||
|
[[ -e "$TOOLS/$tool" ]] && ln -s "$(readlink "$TOOLS/$tool")" "$NO_TO/$tool" && ln -s "$(readlink "$TOOLS/$tool")" "$G_TO/$tool"
|
||||||
|
done
|
||||||
|
ln -s "$TIMEOUT_SHIM" "$G_TO/gtimeout"
|
||||||
|
make_fake_apm "$PATH_APM_BIN" path "$STALE" 0 "$V_NEW"
|
||||||
|
reset_calls
|
||||||
|
out="$(RUN_TOOLS="$NO_TO" run_pinned "apm")"; rc=$?
|
||||||
|
[[ $rc -eq 0 && -z "$out" && -z "$(calls_of path)" ]] \
|
||||||
|
&& pass "no timeout or gtimeout on PATH: silent, exit 0, apm not called" \
|
||||||
|
|| fail "no timeout binary: expected silence and no apm call, got rc=$rc calls=$(calls_of path | tr '\n' '|') out=$out"
|
||||||
|
# Chosen before the apm, so the uv path stays silent too: a pin with uv and no
|
||||||
|
# project environment would otherwise print its not-synced notice.
|
||||||
|
rm -rf "$PINNED/.venv"
|
||||||
|
reset_calls
|
||||||
|
out="$(RUN_TOOLS="$NO_TO" run_pinned "uv apm")"; rc=$?
|
||||||
|
[[ $rc -eq 0 && -z "$out" && -z "$(calls_of uv)" ]] \
|
||||||
|
&& pass "no timeout or gtimeout, pin + uv without .venv: still silent, uv not called" \
|
||||||
|
|| fail "no timeout binary on the uv path: expected silence, got rc=$rc out=$out"
|
||||||
|
mkdir -p "$PINNED/.venv"
|
||||||
|
reset_calls
|
||||||
|
out="$(RUN_TOOLS="$G_TO" run_pinned "apm")"
|
||||||
|
grep -q "^update" <<< "$(calls_of path)" && [[ "$(json_field reloadSkills <<< "$out" 2>/dev/null)" == "True" ]] \
|
||||||
|
&& pass "only gtimeout on PATH (Homebrew coreutils on macOS): uses it and refreshes" \
|
||||||
|
|| fail "gtimeout should stand in for timeout, got calls=$(calls_of path | tr '\n' '|') out=$out"
|
||||||
|
|
||||||
|
# --- PATH apm whose `--version` exits non-zero: unreadable, not too old ---
|
||||||
|
make_fake_apm "$PATH_APM_BIN" path "$STALE" 0 "$V_NEW"
|
||||||
|
cat > "$PATH_APM_BIN/apm" << EOF
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
echo "\$*" >> "$WORK/path-calls"
|
||||||
|
case "\$1" in
|
||||||
|
--version) echo "$V_NEW"; exit 1 ;;
|
||||||
|
outdated) cat "$WORK/path-outdated.txt"; exit 0 ;;
|
||||||
|
esac
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
reset_calls
|
||||||
|
mv "$PINNED/pyproject.toml" "$PINNED/pyproject.toml.off"
|
||||||
|
out="$(run_pinned "apm")"; rc=$?
|
||||||
|
ctx="$(ctx_of "$out")"
|
||||||
|
[[ $rc -eq 0 ]] && grep -qF "Could not read the version of \`apm\` on PATH (it failed or timed out)" <<< "$ctx" \
|
||||||
|
&& ! grep -qF "older than" <<< "$ctx" && ! grep -q "^outdated" <<< "$(calls_of path)" \
|
||||||
|
&& pass "PATH apm --version exits 1: unreadable-version notice, no outdated check" \
|
||||||
|
|| fail "PATH apm --version exits 1: expected the unreadable notice, got rc=$rc calls=$(calls_of path | tr '\n' '|') out=$out"
|
||||||
|
mv "$PINNED/pyproject.toml.off" "$PINNED/pyproject.toml"
|
||||||
|
|
||||||
|
# --- hostile command output never reaches the advice text ---
|
||||||
|
# Every advice string is a fixed literal; only a digit-checked count is
|
||||||
|
# spliced in. Output stuffed with ANSI escapes, command substitutions,
|
||||||
|
# backticks, separators and quotes must leave no trace in what is emitted.
|
||||||
|
HOSTILE=$'\e[31m[!] 7 outdated dependencies found\e[0m $(touch '"$WORK"'/pwned) `touch '"$WORK"'/pwned2`; rm -rf / ; "}]}\\ \x01'
|
||||||
|
for route in uv apm; do
|
||||||
|
if [[ "$route" == uv ]]; then
|
||||||
|
make_fake_apm "$PIN_BIN" pin "$HOSTILE" 1 "$V_NEW"$'\n\e[0m$(id) `id`;'
|
||||||
|
else
|
||||||
|
mv "$PINNED/pyproject.toml" "$PINNED/pyproject.toml.off"
|
||||||
|
make_fake_apm "$PATH_APM_BIN" path "$HOSTILE" 1 "$V_NEW"$'\n\e[0m$(id) `id`;'
|
||||||
|
fi
|
||||||
|
reset_calls
|
||||||
|
out="$(run_pinned "$route")"; rc=$?
|
||||||
|
ctx="$(ctx_of "$out")"
|
||||||
|
if [[ $rc -eq 0 ]] && echo "$out" | python3 -m json.tool > /dev/null 2>&1 && [[ -n "$ctx" ]]; then
|
||||||
|
pass "hostile output via $route: still exits 0 with valid JSON"
|
||||||
|
else
|
||||||
|
fail "hostile output via $route: rc=$rc, output not valid JSON: $(cat -v <<< "$out")"
|
||||||
|
fi
|
||||||
|
leaked=""
|
||||||
|
for needle in $'\e' '$(' 'pwned' 'rm -rf' '\\' $'\x01' '}]}' 'id`'; do
|
||||||
|
grep -qF -- "$needle" <<< "$out" && leaked+="[$needle]"
|
||||||
|
done
|
||||||
|
[[ -z "$leaked" ]] && pass "hostile output via $route: none of it reaches the emitted text" \
|
||||||
|
|| fail "hostile output via $route: leaked $(cat -v <<< "$leaked") into: $(cat -v <<< "$out")"
|
||||||
|
[[ ! -e "$WORK/pwned" && ! -e "$WORK/pwned2" ]] && pass "hostile output via $route: nothing in it was executed" \
|
||||||
|
|| fail "hostile output via $route: a substitution in apm's output was executed"
|
||||||
|
expected="apm install is 7 package(s) behind the remote default branch and the automatic refresh failed. Deployed skills and agents may be stale. Run: apm update --yes"
|
||||||
|
[[ "$route" == uv ]] && expected="${expected%apm update --yes}uv run apm update --yes"
|
||||||
|
[[ "$ctx" == "$expected" ]] \
|
||||||
|
&& pass "hostile output via $route: the notice is exactly the fixed literal plus the digit-checked count" \
|
||||||
|
|| fail "hostile output via $route: notice differs from the fixed literal: $(cat -v <<< "$ctx")"
|
||||||
|
[[ -f "$PINNED/pyproject.toml.off" ]] && mv "$PINNED/pyproject.toml.off" "$PINNED/pyproject.toml"
|
||||||
|
done
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "--- hooks.json wiring ---"
|
echo "--- hooks.json wiring ---"
|
||||||
@@ -317,7 +730,8 @@ matcher="$(python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); print(d[
|
|||||||
# literal, so raising either internal `timeout` without raising the host budget
|
# literal, so raising either internal `timeout` without raising the host budget
|
||||||
# fails here instead of reintroducing the gap quietly.
|
# fails here instead of reintroducing the gap quietly.
|
||||||
#
|
#
|
||||||
# Every `timeout N` in the script counts, comments included: a stray "timeout
|
# Every `timeout N` or `"$to" N` in the script counts (the hook resolves
|
||||||
|
# `timeout` or `gtimeout` into $to), comments included: a stray "timeout
|
||||||
# 300" in prose only makes this stricter, which is the safe direction.
|
# 300" in prose only makes this stricter, which is the safe direction.
|
||||||
script_budget=0
|
script_budget=0
|
||||||
timeout_count=0
|
timeout_count=0
|
||||||
@@ -325,12 +739,12 @@ while read -r n; do
|
|||||||
[[ -n "$n" ]] || continue
|
[[ -n "$n" ]] || continue
|
||||||
script_budget=$((script_budget + n))
|
script_budget=$((script_budget + n))
|
||||||
timeout_count=$((timeout_count + 1))
|
timeout_count=$((timeout_count + 1))
|
||||||
done < <(grep -oE '\btimeout [0-9]+\b' "$HOOK" | grep -oE '[0-9]+')
|
done < <(grep -oE '(\btimeout|"\$to") [0-9]+\b' "$HOOK" | grep -oE '[0-9]+$')
|
||||||
|
|
||||||
hook_timeout="$(python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); print(d["hooks"]["SessionStart"][0]["hooks"][0]["timeout"])' "$HOOKS_JSON")"
|
hook_timeout="$(python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); print(d["hooks"]["SessionStart"][0]["hooks"][0]["timeout"])' "$HOOKS_JSON")"
|
||||||
|
|
||||||
if [[ $timeout_count -eq 0 ]]; then
|
if [[ $timeout_count -eq 0 ]]; then
|
||||||
fail "found no 'timeout N' in $HOOK — the budget assertion below would be vacuous"
|
fail "found no 'timeout N' or '\"\$to\" N' in $HOOK — the budget assertion below would be vacuous"
|
||||||
else
|
else
|
||||||
pass "parsed $timeout_count internal timeout(s) totalling ${script_budget}s from the hook script"
|
pass "parsed $timeout_count internal timeout(s) totalling ${script_budget}s from the hook script"
|
||||||
[[ $hook_timeout -gt $script_budget ]] \
|
[[ $hook_timeout -gt $script_budget ]] \
|
||||||
@@ -345,8 +759,8 @@ echo "--- the greped phrase, against the real apm ---"
|
|||||||
|
|
||||||
# Everything above mocks `apm`, so an apm release that reworded its summary line
|
# Everything above mocks `apm`, so an apm release that reworded its summary line
|
||||||
# would revert this hook to its pre-fix behaviour with a fully green suite.
|
# would revert this hook to its pre-fix behaviour with a fully green suite.
|
||||||
# `apm outdated` has no --json/machine-readable flag (verified against 0.28.0),
|
# `apm outdated` has no --json/machine-readable flag (verified against 0.28.0
|
||||||
# so the phrase match cannot be replaced — it can only be pinned.
|
# and 0.39.3), so the phrase match cannot be replaced — it can only be pinned.
|
||||||
#
|
#
|
||||||
# The probe stages a genuinely outdated dependency with no network: a local git
|
# The probe stages a genuinely outdated dependency with no network: a local git
|
||||||
# repo stands in for the upstream, reached through `url.<path>.insteadOf`
|
# repo stands in for the upstream, reached through `url.<path>.insteadOf`
|
||||||
@@ -359,13 +773,30 @@ echo "--- the greped phrase, against the real apm ---"
|
|||||||
# The genuine output is then replayed into the real hook through the mock, so
|
# The genuine output is then replayed into the real hook through the mock, so
|
||||||
# what is asserted is the hook's own matching logic against real apm text —
|
# what is asserted is the hook's own matching logic against real apm text —
|
||||||
# no pattern is duplicated here to drift out of sync.
|
# no pattern is duplicated here to drift out of sync.
|
||||||
|
#
|
||||||
|
# "The real apm" is this repo's pinned one, run through scripts/lib/apm.sh as
|
||||||
|
# `uv run --project <repo root> --frozen apm` (ADR-0034), never whatever apm is
|
||||||
|
# on PATH: that may be an older global install whose wording is not what this
|
||||||
|
# repo ships against. Sourced in a subshell so the helper's git-env scrub and
|
||||||
|
# its functions stay out of this suite's shell. The probe is skipped only when
|
||||||
|
# that apm cannot be run at all (no uv, or `uv sync --frozen` never ran).
|
||||||
|
probe_apm() {
|
||||||
|
(
|
||||||
|
# shellcheck source=scripts/lib/apm.sh
|
||||||
|
source "$REPO_ROOT/scripts/lib/apm.sh"
|
||||||
|
run_apm "$@"
|
||||||
|
)
|
||||||
|
}
|
||||||
SKIP_REASON=""
|
SKIP_REASON=""
|
||||||
if ! command -v apm > /dev/null 2>&1 || ! command -v git > /dev/null 2>&1; then
|
if ! command -v git > /dev/null 2>&1 \
|
||||||
SKIP_REASON="SKIP: apm and git are both required to verify the hook's phrase match against real \`apm outdated\` output — everything above ran, this axis did not"
|
|| ! ( source "$REPO_ROOT/scripts/lib/apm.sh" && require_apm_version ) > /dev/null 2>&1; then
|
||||||
|
SKIP_REASON="SKIP: git and the repo-pinned apm (uv sync --frozen) are both required to verify the hook's phrase match against real \`apm outdated\` output — everything above ran, this axis did not"
|
||||||
echo " $SKIP_REASON"
|
echo " $SKIP_REASON"
|
||||||
else
|
else
|
||||||
PROBE="$(mktemp -d)"
|
PROBE="$(mktemp -d)"
|
||||||
trap 'rm -rf "$FAKE_BIN" "$WORK" "$PROBE"' EXIT
|
UV_REAL_CACHE="${UV_CACHE_DIR:-$(uv cache dir 2> /dev/null || true)}"
|
||||||
|
UV_REAL_PYTHONS="${UV_PYTHON_INSTALL_DIR:-$(uv python dir 2> /dev/null || true)}"
|
||||||
|
trap 'rm -rf "$FAKE_BIN" "$WORK" "$TOOLS" "$UV_BIN" "$PIN_BIN" "$PATH_APM_BIN" "$PINNED" "$PROBE"' EXIT
|
||||||
|
|
||||||
UPSTREAM="$PROBE/upstream.git"
|
UPSTREAM="$PROBE/upstream.git"
|
||||||
git init -q "$UPSTREAM"
|
git init -q "$UPSTREAM"
|
||||||
@@ -407,13 +838,21 @@ else
|
|||||||
done
|
done
|
||||||
echo "deployments: []"
|
echo "deployments: []"
|
||||||
} > "$PROBE/consumer/apm.lock.yaml"
|
} > "$PROBE/consumer/apm.lock.yaml"
|
||||||
|
# env cannot run a shell function, so probe_apm is re-declared in a child bash.
|
||||||
|
# HOME moves to an empty dir, so uv's cache and its managed Pythons (both
|
||||||
|
# under HOME by default) are pinned to the real ones resolved before the
|
||||||
|
# move, and UV_OFFLINE forbids any fetch: the probe runs the already-synced
|
||||||
|
# pin and never needs the network.
|
||||||
(
|
(
|
||||||
cd "$PROBE/consumer" &&
|
cd "$PROBE/consumer" &&
|
||||||
env HOME="$PROBE/home" \
|
env HOME="$PROBE/home" \
|
||||||
|
UV_CACHE_DIR="$UV_REAL_CACHE" \
|
||||||
|
UV_PYTHON_INSTALL_DIR="$UV_REAL_PYTHONS" \
|
||||||
|
UV_OFFLINE=1 \
|
||||||
GIT_CONFIG_GLOBAL="$PROBE/gitconfig" \
|
GIT_CONFIG_GLOBAL="$PROBE/gitconfig" \
|
||||||
GIT_CONFIG_NOSYSTEM=1 \
|
GIT_CONFIG_NOSYSTEM=1 \
|
||||||
GIT_TERMINAL_PROMPT=0 \
|
GIT_TERMINAL_PROMPT=0 \
|
||||||
apm outdated 2>&1
|
bash -c "$(declare -f probe_apm); REPO_ROOT=\"\$1\"; probe_apm outdated" _ "$REPO_ROOT" 2>&1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,6 +870,7 @@ else
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
pwd > "$WORK/apm-cwd"
|
pwd > "$WORK/apm-cwd"
|
||||||
case "\$1" in
|
case "\$1" in
|
||||||
|
--version) echo "Agent Package Manager (APM) CLI version 0.39.3"; exit 0 ;;
|
||||||
outdated) cat "$PROBE/genuine-$want.txt"; exit 0 ;;
|
outdated) cat "$PROBE/genuine-$want.txt"; exit 0 ;;
|
||||||
update) touch "$WORK/update-was-called"; exit 0 ;;
|
update) touch "$WORK/update-was-called"; exit 0 ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Executable
+234
@@ -0,0 +1,234 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Tests how the apm pre-push gates invoke apm (ADR-0034, issue #271).
|
||||||
|
#
|
||||||
|
# Seam B: a fake `uv` and a stub `apm` sit first on a PATH that excludes the
|
||||||
|
# machine's real uv and any global apm. The fake uv records its cwd, its argv
|
||||||
|
# and the GIT_DIR it inherited, accepts only the `run --project <root> --frozen
|
||||||
|
# apm ...` shape, and hands the rest to the stub. The stub answers --version
|
||||||
|
# with $STUB_APM_VERSION and records every other call. Nothing here runs a real
|
||||||
|
# apm or touches the repo this suite lives in.
|
||||||
|
#
|
||||||
|
# It proves, for both scripts/apm-audit-ci.sh and scripts/apm-pack-check-clean.sh:
|
||||||
|
# * the command is `uv run --project <repo root> --frozen apm`, and --project
|
||||||
|
# names the repo root even when apm runs from a plugin directory;
|
||||||
|
# * git's repo-locating env is still scrubbed before apm runs (issue #204);
|
||||||
|
# * an apm below 0.39.2 fails with a clear message before any gate work runs.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
AUDIT="$REPO_ROOT/scripts/apm-audit-ci.sh"
|
||||||
|
PACK="$REPO_ROOT/scripts/apm-pack-check-clean.sh"
|
||||||
|
PASS=0
|
||||||
|
FAIL=0
|
||||||
|
|
||||||
|
pass() { echo " PASS: $1"; PASS=$((PASS + 1)); }
|
||||||
|
fail() { echo " FAIL: $1"; FAIL=$((FAIL + 1)); }
|
||||||
|
|
||||||
|
# The test must never inherit an override or the caller's repo.
|
||||||
|
unset APM GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_COMMON_DIR
|
||||||
|
|
||||||
|
TMP="$(mktemp -d)"
|
||||||
|
trap 'rm -rf "$TMP"' EXIT
|
||||||
|
|
||||||
|
BIN="$TMP/bin"
|
||||||
|
mkdir -p "$BIN"
|
||||||
|
UV_LOG="$TMP/uv.log"
|
||||||
|
APM_LOG="$TMP/apm.log"
|
||||||
|
|
||||||
|
cat > "$BIN/uv" << EOF
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
{
|
||||||
|
printf 'cwd=%s\n' "\$PWD"
|
||||||
|
printf 'git_dir=%s\n' "\${GIT_DIR-<unset>}"
|
||||||
|
printf 'git_work_tree=%s\n' "\${GIT_WORK_TREE-<unset>}"
|
||||||
|
printf 'argv=%s\n' "\$*"
|
||||||
|
} >> "$UV_LOG"
|
||||||
|
if [[ "\${1:-}" != run || "\${2:-}" != --project || "\${4:-}" != --frozen || "\${5:-}" != apm ]]; then
|
||||||
|
echo "fake uv: unexpected argv: \$*" >&2
|
||||||
|
exit 97
|
||||||
|
fi
|
||||||
|
shift 5
|
||||||
|
# What a real \`uv run --frozen\` prints on stderr when it syncs first, plus a
|
||||||
|
# decoy shaped exactly like apm's banner. The version check must parse apm's
|
||||||
|
# stdout only: a parser reading the merged stream takes 0.0.1 from the decoy
|
||||||
|
# and fails a current apm (review rounds 1 and 2 of #271).
|
||||||
|
echo "Using CPython 3.14.6" >&2
|
||||||
|
echo "uv CLI version 0.0.1" >&2
|
||||||
|
exec "$BIN/apm" "\$@"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > "$BIN/apm" << EOF
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
if [[ "\${1:-}" == --version ]]; then
|
||||||
|
printf '%s\n' "\${STUB_APM_OUTPUT:-Agent Package Manager (APM) CLI version \${STUB_APM_VERSION:-0.39.3}}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
printf 'cwd=%s args=%s\n' "\$PWD" "\$*" >> "$APM_LOG"
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
chmod +x "$BIN/uv" "$BIN/apm"
|
||||||
|
|
||||||
|
# A PATH with the fakes first and only system directories after them: no
|
||||||
|
# /usr/local/bin (the real uv) and no ~/.local/bin (the global pipx apm).
|
||||||
|
FAKE_PATH="$BIN:/usr/bin:/bin"
|
||||||
|
NO_UV_PATH="/usr/bin:/bin"
|
||||||
|
for tool in uv apm; do
|
||||||
|
if PATH="$NO_UV_PATH" command -v "$tool" > /dev/null 2>&1; then
|
||||||
|
echo "SKIP: a real $tool is on $NO_UV_PATH, so the fake cannot be isolated"
|
||||||
|
exit 77
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# A fixture tree for apm-audit-ci.sh's per-manifest loop: a root and one
|
||||||
|
# plugin package. The script iterates `. plugins/*/` relative to its cwd.
|
||||||
|
FIXTURE="$TMP/fixture"
|
||||||
|
mkdir -p "$FIXTURE/plugins/demo"
|
||||||
|
|
||||||
|
reset_logs() { : > "$UV_LOG"; : > "$APM_LOG"; }
|
||||||
|
|
||||||
|
# run_gate <cwd> <script> [VAR=value ...] — sets RC and OUT (stdout+stderr).
|
||||||
|
RC=0
|
||||||
|
OUT=""
|
||||||
|
run_gate() {
|
||||||
|
local cwd="$1" script="$2"
|
||||||
|
shift 2
|
||||||
|
RC=0
|
||||||
|
OUT="$(cd "$cwd" && env PATH="$FAKE_PATH" "$@" bash "$script" 2>&1)" || RC=$?
|
||||||
|
}
|
||||||
|
|
||||||
|
# Every uv call names the repo root as --project and uses --frozen.
|
||||||
|
check_project_root() {
|
||||||
|
local label="$1" n bad
|
||||||
|
n="$(grep -c '^argv=' "$UV_LOG" || true)"
|
||||||
|
if [[ "$n" -eq 0 ]]; then
|
||||||
|
fail "$label: uv was never called"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
bad="$(grep '^argv=' "$UV_LOG" | grep -vF "argv=run --project $REPO_ROOT --frozen apm " || true)"
|
||||||
|
if [[ -z "$bad" ]]; then
|
||||||
|
pass "$label: all $n uv call(s) are 'run --project <repo root> --frozen apm'"
|
||||||
|
else
|
||||||
|
fail "$label: uv called with another shape: $bad"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "--- apm-pack-check-clean: the command, run from a plugin directory ---"
|
||||||
|
reset_logs
|
||||||
|
run_gate "$REPO_ROOT/plugins/kyberforge" "$PACK"
|
||||||
|
[[ $RC -eq 0 ]] && pass "exits 0 when the pinned apm passes" || fail "exited $RC: $OUT"
|
||||||
|
check_project_root "apm-pack-check-clean from plugins/kyberforge"
|
||||||
|
grep -qxF "cwd=$REPO_ROOT/plugins/kyberforge args=pack --check-versions --check-clean --dry-run" "$APM_LOG" \
|
||||||
|
&& pass "runs 'pack --check-versions --check-clean --dry-run' in the caller's cwd" \
|
||||||
|
|| fail "unexpected apm calls: $(cat "$APM_LOG")"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "--- apm-audit-ci: --project stays the repo root inside each plugin dir ---"
|
||||||
|
reset_logs
|
||||||
|
run_gate "$FIXTURE" "$AUDIT"
|
||||||
|
[[ $RC -eq 0 ]] && pass "exits 0 when every audit passes" || fail "exited $RC: $OUT"
|
||||||
|
check_project_root "apm-audit-ci"
|
||||||
|
grep -qxF "cwd=$FIXTURE/plugins/demo args=audit --ci" "$APM_LOG" \
|
||||||
|
&& pass "audits plugins/demo from inside that directory" \
|
||||||
|
|| fail "no audit ran in plugins/demo: $(cat "$APM_LOG")"
|
||||||
|
grep -qxF "cwd=$FIXTURE args=audit --ci" "$APM_LOG" \
|
||||||
|
&& pass "audits the root manifest" || fail "no root audit: $(cat "$APM_LOG")"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "--- the git-env scrub still applies ---"
|
||||||
|
for pair in "apm-audit-ci:$AUDIT" "apm-pack-check-clean:$PACK"; do
|
||||||
|
label="${pair%%:*}"
|
||||||
|
script="${pair#*:}"
|
||||||
|
reset_logs
|
||||||
|
run_gate "$FIXTURE" "$script" GIT_DIR="$TMP/elsewhere/.git" GIT_WORK_TREE="$TMP/elsewhere"
|
||||||
|
[[ $RC -eq 0 ]] || fail "$label: exited $RC with GIT_DIR exported: $OUT"
|
||||||
|
if grep -q '^git_dir=' "$UV_LOG" && ! grep -q '^git_dir=[^<]' "$UV_LOG" \
|
||||||
|
&& ! grep -q '^git_work_tree=[^<]' "$UV_LOG"; then
|
||||||
|
pass "$label: uv (and so apm) saw no GIT_DIR or GIT_WORK_TREE"
|
||||||
|
else
|
||||||
|
fail "$label: git env leaked: $(grep '^git_' "$UV_LOG" | sort -u | tr '\n' ' ')"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "--- the minimum-version check ---"
|
||||||
|
for pair in "apm-audit-ci:$AUDIT" "apm-pack-check-clean:$PACK"; do
|
||||||
|
label="${pair%%:*}"
|
||||||
|
script="${pair#*:}"
|
||||||
|
for old in 0.39.1 0.28.0; do
|
||||||
|
reset_logs
|
||||||
|
run_gate "$FIXTURE" "$script" STUB_APM_VERSION="$old"
|
||||||
|
[[ $RC -ne 0 ]] && pass "$label: fails on apm $old" || fail "$label: apm $old must fail"
|
||||||
|
grep -qF "apm $old is below 0.39.2" <<< "$OUT" && grep -qF "uv sync --frozen" <<< "$OUT" \
|
||||||
|
&& pass "$label: says $old is below 0.39.2 and names the fix" \
|
||||||
|
|| fail "$label: unclear message for $old: $OUT"
|
||||||
|
[[ ! -s "$APM_LOG" ]] && pass "$label: ran no gate work on apm $old" \
|
||||||
|
|| fail "$label: ran apm past the version check: $(cat "$APM_LOG")"
|
||||||
|
done
|
||||||
|
for ok in 0.39.2 0.39.10 1.0.0; do
|
||||||
|
reset_logs
|
||||||
|
run_gate "$FIXTURE" "$script" STUB_APM_VERSION="$ok"
|
||||||
|
[[ $RC -eq 0 ]] && pass "$label: accepts apm $ok" || fail "$label: apm $ok must pass: $OUT"
|
||||||
|
done
|
||||||
|
reset_logs
|
||||||
|
run_gate "$FIXTURE" "$script" STUB_APM_OUTPUT="apm, version unknown"
|
||||||
|
[[ $RC -ne 0 ]] && grep -qF "printed no 'CLI version X.Y.Z' banner" <<< "$OUT" \
|
||||||
|
&& pass "$label: fails when the version cannot be read" \
|
||||||
|
|| fail "$label: an unreadable version must fail clearly (rc=$RC): $OUT"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "--- the version is read from apm's stdout banner, nothing else ---"
|
||||||
|
# The fake uv writes a banner-shaped `uv CLI version 0.0.1` to stderr on every
|
||||||
|
# call, so these fail if stderr reaches the parser.
|
||||||
|
reset_logs
|
||||||
|
run_gate "$FIXTURE" "$PACK" STUB_APM_VERSION=0.39.3
|
||||||
|
[[ $RC -eq 0 ]] && pass "stdout only: apm 0.39.3 passes despite a 0.0.1 decoy on uv's stderr" \
|
||||||
|
|| fail "stdout only: 0.39.3 must pass, the stderr decoy was parsed: $OUT"
|
||||||
|
reset_logs
|
||||||
|
run_gate "$FIXTURE" "$PACK" STUB_APM_VERSION=0.28.0
|
||||||
|
[[ $RC -ne 0 ]] && grep -qF "apm 0.28.0 is below 0.39.2" <<< "$OUT" \
|
||||||
|
&& pass "stdout only: apm 0.28.0 still fails" || fail "stdout only: 0.28.0 must fail: $OUT"
|
||||||
|
|
||||||
|
# Other version-like text on stdout, before the banner, is not the version.
|
||||||
|
reset_logs
|
||||||
|
run_gate "$FIXTURE" "$PACK" \
|
||||||
|
STUB_APM_OUTPUT=$'reads lockfile version 0.40.0\nAgent Package Manager (APM) CLI version 0.28.0'
|
||||||
|
[[ $RC -ne 0 ]] && grep -qF "apm 0.28.0 is below 0.39.2" <<< "$OUT" \
|
||||||
|
&& pass "banner anchor: a 'version 0.40.0' line before the banner does not rescue 0.28.0" \
|
||||||
|
|| fail "banner anchor: the decoy line was taken for the version (rc=$RC): $OUT"
|
||||||
|
reset_logs
|
||||||
|
run_gate "$FIXTURE" "$PACK" \
|
||||||
|
STUB_APM_OUTPUT=$'reads lockfile version 0.40.0\nAgent Package Manager (APM) CLI version 0.39.3'
|
||||||
|
[[ $RC -eq 0 ]] && pass "banner anchor: the banner's 0.39.3 is the version read" \
|
||||||
|
|| fail "banner anchor: 0.39.3 behind a decoy line must pass (rc=$RC): $OUT"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "--- no uv, and the APM override ---"
|
||||||
|
RC=0
|
||||||
|
OUT="$(cd "$FIXTURE" && env PATH="$NO_UV_PATH" bash "$PACK" 2>&1)" || RC=$?
|
||||||
|
[[ $RC -ne 0 ]] && grep -qF "uv is not on PATH" <<< "$OUT" \
|
||||||
|
&& pass "fails clearly when uv is missing" || fail "missing uv must fail clearly (rc=$RC): $OUT"
|
||||||
|
|
||||||
|
reset_logs
|
||||||
|
RC=0
|
||||||
|
OUT="$(cd "$FIXTURE" && env PATH="$NO_UV_PATH" APM="$BIN/apm" bash "$PACK" 2>&1)" || RC=$?
|
||||||
|
[[ $RC -eq 0 && ! -s "$UV_LOG" ]] && grep -qF "args=pack" "$APM_LOG" \
|
||||||
|
&& pass "APM overrides the command and bypasses uv" \
|
||||||
|
|| fail "APM override not honoured (rc=$RC): $OUT"
|
||||||
|
|
||||||
|
RC=0
|
||||||
|
OUT="$(cd "$FIXTURE" && env PATH="$FAKE_PATH" APM=" " bash "$PACK" 2>&1)" || RC=$?
|
||||||
|
[[ $RC -ne 0 ]] && grep -qF "holds only whitespace" <<< "$OUT" \
|
||||||
|
&& pass "a whitespace-only APM fails clearly" \
|
||||||
|
|| fail "a whitespace-only APM must fail clearly (rc=$RC): $OUT"
|
||||||
|
|
||||||
|
reset_logs
|
||||||
|
RC=0
|
||||||
|
OUT="$(cd "$FIXTURE" && env PATH="$NO_UV_PATH" APM="$BIN/apm" STUB_APM_VERSION=0.28.0 bash "$PACK" 2>&1)" || RC=$?
|
||||||
|
[[ $RC -ne 0 ]] && grep -qF "below 0.39.2" <<< "$OUT" \
|
||||||
|
&& pass "the version check applies to an APM override too" \
|
||||||
|
|| fail "an old apm via APM must fail (rc=$RC): $OUT"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Results: $PASS passed, $FAIL failed"
|
||||||
|
[[ "$FAIL" -eq 0 ]]
|
||||||
@@ -7,16 +7,24 @@
|
|||||||
# drift replay runs `git init` / `git checkout` in a temp dir with an env copied
|
# drift replay runs `git init` / `git checkout` in a temp dir with an env copied
|
||||||
# from os.environ, so the inherited GIT_DIR wins: `git init` wrote
|
# from os.environ, so the inherited GIT_DIR wins: `git init` wrote
|
||||||
# core.bare=true into the shared .git/config, and a later checkout moved the
|
# core.bare=true into the shared .git/config, and a later checkout moved the
|
||||||
# worktree's HEAD to the lock-pinned commit.
|
# worktree's HEAD to the lock-pinned commit. apm 0.39.3's
|
||||||
|
# apm_cli/utils/git_env.py provides git_subprocess_env, which strips GIT_DIR
|
||||||
|
# and the other repo-locating vars; the leak was not re-tested on 0.39.3, and
|
||||||
|
# this suite keeps the hooks' own scrub pinned as defence in depth (#272).
|
||||||
#
|
#
|
||||||
# The stub `apm` below reproduces that pattern -- record GIT_DIR, then `git init`
|
# The stub `apm` below reproduces that pattern -- record GIT_DIR, then `git init`
|
||||||
# and `git checkout` inside a fresh `mktemp -d` -- and each hook script is run
|
# and `git checkout` inside a fresh `mktemp -d` -- and each hook script is run
|
||||||
# from a linked worktree of a throwaway repo with GIT_DIR exported the way git
|
# from a linked worktree of a throwaway repo with GIT_DIR exported the way git
|
||||||
# exports it. Nothing here touches the repo this suite lives in.
|
# exports it. Nothing here touches the repo this suite lives in.
|
||||||
|
#
|
||||||
|
# The hooks run apm as `uv run --project <repo root> --frozen apm` (ADR-0034,
|
||||||
|
# scripts/lib/apm.sh), so a fake `uv` sits beside the stub and hands everything
|
||||||
|
# after `apm` to it. tests/test-apm-gate-invocation.sh pins that command shape;
|
||||||
|
# this suite only needs the call to land on the stub.
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# This suite builds its own repos; it must never inherit the caller's.
|
# This suite builds its own repos; it must never inherit the caller's.
|
||||||
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_COMMON_DIR
|
unset APM GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_COMMON_DIR
|
||||||
export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1
|
export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1
|
||||||
|
|
||||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
@@ -34,7 +42,8 @@ g() { git -c user.name=fixture -c [email protected] "$@"; }
|
|||||||
|
|
||||||
# Builds <dir>/main (two commits on `main`) and <dir>/wt, a linked worktree on
|
# Builds <dir>/main (two commits on `main`) and <dir>/wt, a linked worktree on
|
||||||
# branch `feature`, with a plugins/demo/ package dir so the audit script's
|
# branch `feature`, with a plugins/demo/ package dir so the audit script's
|
||||||
# per-package loop has something to iterate. Also writes <dir>/bin/apm, the stub.
|
# per-package loop has something to iterate. Also writes <dir>/bin/apm, the stub,
|
||||||
|
# and <dir>/bin/uv, the fake that reaches it.
|
||||||
make_fixture() {
|
make_fixture() {
|
||||||
local dir="$1"
|
local dir="$1"
|
||||||
mkdir -p "$dir/bin"
|
mkdir -p "$dir/bin"
|
||||||
@@ -51,8 +60,18 @@ make_fixture() {
|
|||||||
local locked
|
local locked
|
||||||
locked="$(g -C "$dir/main" rev-parse HEAD~1)"
|
locked="$(g -C "$dir/main" rev-parse HEAD~1)"
|
||||||
|
|
||||||
|
cat > "$dir/bin/uv" <<EOF
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
[[ "\${1:-}" == run && "\${5:-}" == apm ]] || { echo "fake uv: unexpected argv: \$*" >&2; exit 97; }
|
||||||
|
shift 5
|
||||||
|
exec "$dir/bin/apm" "\$@"
|
||||||
|
EOF
|
||||||
|
chmod +x "$dir/bin/uv"
|
||||||
|
|
||||||
|
# --version answers above the gates' 0.39.2 floor and records nothing.
|
||||||
cat > "$dir/bin/apm" <<EOF
|
cat > "$dir/bin/apm" <<EOF
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
if [[ "\${1:-}" == --version ]]; then echo "Agent Package Manager (APM) CLI version 0.39.3"; exit 0; fi
|
||||||
printf '%s\n' "\${GIT_DIR-<unset>}" >> "$dir/apm-saw-git-dir"
|
printf '%s\n' "\${GIT_DIR-<unset>}" >> "$dir/apm-saw-git-dir"
|
||||||
tmp="\$(mktemp -d)"
|
tmp="\$(mktemp -d)"
|
||||||
( cd "\$tmp" && git init -q . >/dev/null 2>&1; git checkout -q --detach $locked >/dev/null 2>&1 ) || true
|
( cd "\$tmp" && git init -q . >/dev/null 2>&1; git checkout -q --detach $locked >/dev/null 2>&1 ) || true
|
||||||
|
|||||||
@@ -46,12 +46,18 @@ make_fixture() {
|
|||||||
echo "description: fixture"
|
echo "description: fixture"
|
||||||
} > "$dir/plugins/kyberforge/apm.yml"
|
} > "$dir/plugins/kyberforge/apm.yml"
|
||||||
|
|
||||||
|
# Both plugins are declared the way the real root apm.yml declares them, as
|
||||||
|
# git + path entries: the gate derives each key's identity from these.
|
||||||
{
|
{
|
||||||
echo "name: ai-development"
|
echo "name: ai-development"
|
||||||
echo "version: 0.0.1"
|
echo "version: 0.0.1"
|
||||||
echo "dependencies:"
|
echo "dependencies:"
|
||||||
echo " apm:"
|
echo " apm:"
|
||||||
echo " - name: kyberforge"
|
echo " - git: https://git.example.invalid/Owner/Repo.git"
|
||||||
|
echo " path: plugins/kyberforge"
|
||||||
|
echo " - git: https://git.example.invalid/Owner/Repo.git"
|
||||||
|
echo " path: plugins/delivery"
|
||||||
|
echo " mcp: []"
|
||||||
[[ -n "$executables_block" ]] && printf '%s\n' "$executables_block"
|
[[ -n "$executables_block" ]] && printf '%s\n' "$executables_block"
|
||||||
# A top-level key after the block: the fallback reader must stop collecting
|
# A top-level key after the block: the fallback reader must stop collecting
|
||||||
# allow keys here rather than reading on into the next section.
|
# allow keys here rather than reading on into the next section.
|
||||||
@@ -74,40 +80,50 @@ add_plugin() {
|
|||||||
} > "$dir/apm.yml"
|
} > "$dir/apm.yml"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# The identity apm 0.39 matches on: <host>/<owner>/<repo>/<path>.
|
||||||
|
ID=git.example.invalid/Owner/Repo/plugins
|
||||||
|
|
||||||
MATCHING_BLOCK='executables:
|
MATCHING_BLOCK='executables:
|
||||||
allow:
|
allow:
|
||||||
kyberforge#1.5.0:
|
git.example.invalid/Owner/Repo/plugins/kyberforge#1.5.0:
|
||||||
hooks: true
|
hooks: true
|
||||||
bin: true'
|
bin: true'
|
||||||
|
|
||||||
STALE_BLOCK='executables:
|
STALE_BLOCK='executables:
|
||||||
allow:
|
allow:
|
||||||
kyberforge#1.4.0:
|
git.example.invalid/Owner/Repo/plugins/kyberforge#1.4.0:
|
||||||
hooks: true
|
hooks: true
|
||||||
bin: true'
|
bin: true'
|
||||||
|
|
||||||
TWO_MATCHING_BLOCK='executables:
|
TWO_MATCHING_BLOCK='executables:
|
||||||
allow:
|
allow:
|
||||||
kyberforge#1.5.0:
|
git.example.invalid/Owner/Repo/plugins/kyberforge#1.5.0:
|
||||||
hooks: true
|
hooks: true
|
||||||
bin: true
|
bin: true
|
||||||
# delivery ships a guard hook; an indented comment must not read as a key.
|
# delivery ships a guard hook; an indented comment must not read as a key.
|
||||||
delivery#0.1.0:
|
git.example.invalid/Owner/Repo/plugins/delivery#0.1.0:
|
||||||
hooks: true'
|
hooks: true'
|
||||||
|
|
||||||
TWO_STALE_BLOCK='executables:
|
TWO_STALE_BLOCK='executables:
|
||||||
allow:
|
allow:
|
||||||
kyberforge#1.4.0:
|
git.example.invalid/Owner/Repo/plugins/kyberforge#1.4.0:
|
||||||
hooks: true
|
hooks: true
|
||||||
bin: true
|
bin: true
|
||||||
delivery#0.0.9:
|
git.example.invalid/Owner/Repo/plugins/delivery#0.0.9:
|
||||||
hooks: true'
|
hooks: true'
|
||||||
|
|
||||||
OTHER_PACKAGE_BLOCK='executables:
|
OTHER_PACKAGE_BLOCK='executables:
|
||||||
allow:
|
allow:
|
||||||
git#1.0.0:
|
git.example.invalid/Owner/Repo/plugins/git#1.0.0:
|
||||||
hooks: true'
|
hooks: true'
|
||||||
|
|
||||||
|
# The bare '<name>#<version>' form apm 0.28 matched and 0.39 does not.
|
||||||
|
BARE_BLOCK='executables:
|
||||||
|
allow:
|
||||||
|
kyberforge#1.5.0:
|
||||||
|
hooks: true
|
||||||
|
bin: true'
|
||||||
|
|
||||||
# run_gate <fixture> — echoes combined output, sets GATE_RC.
|
# run_gate <fixture> — echoes combined output, sets GATE_RC.
|
||||||
GATE_RC=0
|
GATE_RC=0
|
||||||
run_gate() {
|
run_gate() {
|
||||||
@@ -281,6 +297,39 @@ run_gate "$F"
|
|||||||
[[ $GATE_RC -ne 0 ]] && pass "refuses an unquoted 2-component version" \
|
[[ $GATE_RC -ne 0 ]] && pass "refuses an unquoted 2-component version" \
|
||||||
|| fail "a float version must fail rather than be compared in reader-invented form"
|
|| fail "a float version must fail rather than be compared in reader-invented form"
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "--- the key is the full package identity apm 0.39 matches on ---"
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# The 0.28-era bare key: apm 0.39.3 parks the hooks under it while root
|
||||||
|
# `apm audit --ci` stays green (spike #269), so this gate is what catches it.
|
||||||
|
F="$(make_fixture "version: 1.5.0" "$BARE_BLOCK")"
|
||||||
|
run_gate "$F"
|
||||||
|
[[ $GATE_RC -ne 0 ]] && pass "fails on a bare '<name>#<version>' key" \
|
||||||
|
|| fail "a bare key no longer matches under apm 0.39 and must fail"
|
||||||
|
OUT="$(bash "$SCRIPT" "$F" 2>&1 || true)"
|
||||||
|
grep -qF "$ID/kyberforge#1.5.0" <<< "$OUT" && pass "names the full-identity key to use" \
|
||||||
|
|| fail "the failure must state the full-identity key, got: $OUT"
|
||||||
|
grep -qF "full package identity" <<< "$OUT" && pass "says why a bare key no longer matches" \
|
||||||
|
|| fail "the failure must explain the bare key, got: $OUT"
|
||||||
|
|
||||||
|
# No git+path dependency entry for the plugin means no identity to derive.
|
||||||
|
F="$(make_fixture "version: 1.5.0" "$MATCHING_BLOCK")"
|
||||||
|
# python3, not `sed -i`, whose in-place syntax differs between GNU and BSD sed.
|
||||||
|
python3 - "$F/apm.yml" << 'PY2'
|
||||||
|
import sys
|
||||||
|
path = sys.argv[1]
|
||||||
|
lines = open(path).read().splitlines(keepends=True)
|
||||||
|
open(path, "w").write("".join(l for l in lines if "path: plugins/kyberforge" not in l))
|
||||||
|
PY2
|
||||||
|
run_gate "$F"
|
||||||
|
[[ $GATE_RC -ne 0 ]] && pass "fails when root apm.yml has no git+path entry for the plugin" \
|
||||||
|
|| fail "with no dependency entry the identity cannot be derived; must fail"
|
||||||
|
OUT="$(bash "$SCRIPT" "$F" 2>&1 || true)"
|
||||||
|
grep -qF "cannot be derived" <<< "$OUT" && pass "says the identity cannot be derived" \
|
||||||
|
|| fail "the failure must say why, got: $OUT"
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "--- the fallback reader agrees with the PyYAML reader ---"
|
echo "--- the fallback reader agrees with the PyYAML reader ---"
|
||||||
@@ -338,6 +387,126 @@ run_fallback "$F"
|
|||||||
run_fallback "$REPO_ROOT"
|
run_fallback "$REPO_ROOT"
|
||||||
[[ $GATE_RC -eq 0 ]] && pass "fallback passes the real repo" || fail "fallback disagrees with PyYAML on the real repo"
|
[[ $GATE_RC -eq 0 ]] && pass "fallback passes the real repo" || fail "fallback disagrees with PyYAML on the real repo"
|
||||||
|
|
||||||
|
# Dependency entry shapes that name the same identity: no .git suffix, path
|
||||||
|
# first, quoted values, ./ prefix and trailing slash, and an scp-like URL. Each
|
||||||
|
# must pass under both readers.
|
||||||
|
identity_variant() {
|
||||||
|
local label="$1" entry="$2" f
|
||||||
|
f="$(make_fixture "version: 1.5.0" "$MATCHING_BLOCK")"
|
||||||
|
python3 - "$f/apm.yml" "$entry" << 'PY2'
|
||||||
|
import sys
|
||||||
|
path, entry = sys.argv[1], sys.argv[2]
|
||||||
|
text = open(path).read()
|
||||||
|
old = " - git: https://git.example.invalid/Owner/Repo.git\n path: plugins/kyberforge\n"
|
||||||
|
assert old in text
|
||||||
|
open(path, "w").write(text.replace(old, entry + "\n"))
|
||||||
|
PY2
|
||||||
|
run_gate "$f"
|
||||||
|
[[ $GATE_RC -eq 0 ]] && pass "PyYAML reader derives the identity: $label" \
|
||||||
|
|| fail "PyYAML reader: $label should pass, got: $(bash "$SCRIPT" "$f" 2>&1 | head -2 || true)"
|
||||||
|
run_fallback "$f"
|
||||||
|
[[ $GATE_RC -eq 0 ]] && pass "fallback reader derives the identity: $label" \
|
||||||
|
|| fail "fallback reader: $label should pass"
|
||||||
|
}
|
||||||
|
|
||||||
|
identity_variant "no .git suffix" " - git: https://git.example.invalid/Owner/Repo
|
||||||
|
path: plugins/kyberforge"
|
||||||
|
identity_variant "path before git" " - path: plugins/kyberforge
|
||||||
|
git: https://git.example.invalid/Owner/Repo.git"
|
||||||
|
identity_variant "quoted values, ./ and trailing /" " - git: \"https://git.example.invalid/Owner/Repo.git\"
|
||||||
|
path: './plugins/kyberforge/'"
|
||||||
|
identity_variant "scp-like URL" " - git: [email protected]:Owner/Repo.git
|
||||||
|
path: plugins/kyberforge"
|
||||||
|
|
||||||
|
F="$(make_fixture "version: 1.5.0" "$BARE_BLOCK")"
|
||||||
|
run_fallback "$F"
|
||||||
|
[[ $GATE_RC -ne 0 ]] && pass "fallback fails a bare key" || fail "fallback missed a bare key"
|
||||||
|
|
||||||
|
# A URL with a port: where apm puts the port in the identity is unverified, so
|
||||||
|
# the gate refuses to derive a key rather than derive a plausible wrong one.
|
||||||
|
for port_url in "ssh://[email protected]:2222/Owner/Repo.git" "https://git.example.invalid:8443/Owner/Repo.git"; do
|
||||||
|
F="$(make_fixture "version: 1.5.0" "$MATCHING_BLOCK")"
|
||||||
|
python3 - "$F/apm.yml" "$port_url" << 'PY2'
|
||||||
|
import sys
|
||||||
|
path, url = sys.argv[1], sys.argv[2]
|
||||||
|
text = open(path).read()
|
||||||
|
old = " - git: https://git.example.invalid/Owner/Repo.git\n path: plugins/kyberforge\n"
|
||||||
|
assert old in text
|
||||||
|
open(path, "w").write(text.replace(old, " - git: %s\n path: plugins/kyberforge\n" % url))
|
||||||
|
PY2
|
||||||
|
OUT="$(bash "$SCRIPT" "$F" 2>&1)" && rc=0 || rc=$?
|
||||||
|
[[ $rc -ne 0 ]] && grep -qF "URL with a port" <<< "$OUT" \
|
||||||
|
&& pass "refuses a git: URL with a port: $port_url" \
|
||||||
|
|| fail "a URL with a port must fail clearly ($port_url), got rc=$rc: $OUT"
|
||||||
|
run_fallback "$F"
|
||||||
|
[[ $GATE_RC -ne 0 ]] && pass "fallback refuses a git: URL with a port: $port_url" \
|
||||||
|
|| fail "fallback must refuse a URL with a port ($port_url)"
|
||||||
|
done
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "--- a parked executable recorded in apm.lock.yaml fails ---"
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# write_lock <fixture> <kyberforge exec_status> — a lock in the shape apm 0.39.3
|
||||||
|
# writes: `- repo_url:` opens each dependency, fields at 2 spaces, host after
|
||||||
|
# repo_url, exec_status last, then a top-level deployments: section.
|
||||||
|
write_lock() {
|
||||||
|
{
|
||||||
|
echo "lockfile_version: '4'"
|
||||||
|
echo "apm_version: 0.39.3"
|
||||||
|
echo "dependencies:"
|
||||||
|
echo "- repo_url: Owner/Repo"
|
||||||
|
echo " name: kyberforge"
|
||||||
|
echo " host: git.example.invalid"
|
||||||
|
echo " virtual_path: plugins/kyberforge"
|
||||||
|
echo " deployed_files:"
|
||||||
|
echo " - .claude/hooks/kyberforge/x.sh"
|
||||||
|
echo " exec_status: $2"
|
||||||
|
echo "- repo_url: Owner/Repo"
|
||||||
|
echo " name: docs"
|
||||||
|
echo " host: git.example.invalid"
|
||||||
|
echo " virtual_path: plugins/docs"
|
||||||
|
echo "deployments:"
|
||||||
|
echo "- exec_status: gated_pending_approval"
|
||||||
|
} > "$1/apm.lock.yaml"
|
||||||
|
}
|
||||||
|
|
||||||
|
F="$(make_fixture "version: 1.5.0" "$MATCHING_BLOCK")"
|
||||||
|
write_lock "$F" deployed
|
||||||
|
run_gate "$F"
|
||||||
|
[[ $GATE_RC -eq 0 ]] && pass "passes a lock whose executables are deployed" \
|
||||||
|
|| fail "exec_status: deployed must pass, got: $(bash "$SCRIPT" "$F" 2>&1 | head -3 || true)"
|
||||||
|
|
||||||
|
F="$(make_fixture "version: 1.5.0" "$MATCHING_BLOCK")"
|
||||||
|
write_lock "$F" gated_pending_approval
|
||||||
|
run_gate "$F"
|
||||||
|
[[ $GATE_RC -ne 0 ]] && pass "fails a lock that records gated_pending_approval" \
|
||||||
|
|| fail "a parked executable in the lock must fail the push"
|
||||||
|
OUT="$(bash "$SCRIPT" "$F" 2>&1 || true)"
|
||||||
|
grep -qF "git.example.invalid/Owner/Repo/plugins/kyberforge: gated_pending_approval" <<< "$OUT" \
|
||||||
|
&& pass "names the parked package by identity and its status" \
|
||||||
|
|| fail "the failure must name the package and status, got: $OUT"
|
||||||
|
grep -q "Why:" <<< "$OUT" && grep -qF "apm approve --list" <<< "$OUT" \
|
||||||
|
&& pass "carries Why: and a Fix: naming apm approve --list" || fail "message must carry Why/Fix: $OUT"
|
||||||
|
grep -qF "plugins/docs" <<< "$OUT" && fail "a dependency with no exec_status must not be reported" \
|
||||||
|
|| pass "reports only the gated dependency, not the next one or the deployments: section"
|
||||||
|
|
||||||
|
F="$(make_fixture "version: 1.5.0" "$MATCHING_BLOCK")"
|
||||||
|
write_lock "$F" gated_definition_changed
|
||||||
|
run_fallback "$F"
|
||||||
|
[[ $GATE_RC -ne 0 ]] && pass "fails any gated_* status, without PyYAML too" \
|
||||||
|
|| fail "gated_definition_changed must fail under the fallback reader"
|
||||||
|
|
||||||
|
# A third-party dependency can be parked in a repo whose own plugins ship no
|
||||||
|
# executables, so the check runs before the no-plugin no-op.
|
||||||
|
F="$(mktemp -d "$RUN_TMP/fx.XXXXXX")"
|
||||||
|
echo "name: someone-else" > "$F/apm.yml"
|
||||||
|
write_lock "$F" gated_pending_approval
|
||||||
|
run_gate "$F"
|
||||||
|
[[ $GATE_RC -ne 0 ]] && pass "fails a parked executable even with no executable-shipping plugin" \
|
||||||
|
|| fail "the lock check must run before the no-plugin no-op"
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "--- wired into the pre-push gate ---"
|
echo "--- wired into the pre-push gate ---"
|
||||||
|
|||||||
Reference in new issue
Block a user