Compare commits
3 Commits
bff9662c52
...
7c3c867e00
| Author | SHA1 | Date | |
|---|---|---|---|
| 7c3c867e00 | |||
| 4003c6a273 | |||
| 9c140efa2e |
@@ -65,7 +65,7 @@ repos:
|
|||||||
- id: check-plugin-content-sync
|
- id: check-plugin-content-sync
|
||||||
name: Check plugin content sync
|
name: Check plugin content sync
|
||||||
description: Verify each plugin's flat skills/agents/commands/hooks.json mirror is in sync with .apm/ -- Claude Code has no .apm/ awareness so this compiled mirror must stay current (see issue #90)
|
description: Verify each plugin's flat skills/agents/commands/hooks.json mirror is in sync with .apm/ -- Claude Code has no .apm/ awareness so this compiled mirror must stay current (see issue #90)
|
||||||
entry: bash scripts/sync-plugin-content.sh --check plugins/bin plugins/core plugins/git plugins/gitea plugins/kyberforge plugins/lint
|
entry: bash scripts/sync-plugin-content.sh --check --all
|
||||||
language: system
|
language: system
|
||||||
stages: [pre-push]
|
stages: [pre-push]
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
|
|||||||
@@ -72,9 +72,9 @@ A standalone, repo-agnostic plugin (`plugins/lint/`) for configuring and running
|
|||||||
### Vale audit prefilter (skill-audit / agent-audit)
|
### Vale audit prefilter (skill-audit / agent-audit)
|
||||||
Wiring Vale as a deterministic prefilter for `skill-audit`/`agent-audit`'s Description dimension (ADR motivation: issue #84) is repo-specific, not part of the generic `lint` plugin, so it doesn't live in `plugins/lint/` — but per ADR-0014 it also doesn't live at the repo root anymore. Two copies live inside `plugins/kyberforge/`, one per skill, since a plugin's cache-install only copies each skill's own files (no cross-skill sharing): `plugins/kyberforge/.apm/skills/agent-audit/assets/vale/` is canonical (`.vale.ini` plus a custom `Kyberforge` style covering description-opener banning ("This skill/agent..."), vague-capability wording ("helps with", "utilize", ...), and generic "see references/ for details" padding — and a `KyberforgeCopilot` style scoped only to `.agent.md` files for the Copilot-only "Use proactively has no effect" check), and `plugins/kyberforge/.apm/skills/skill-audit/assets/vale/` is a smaller duplicate (`Kyberforge` only, scoped to `SKILL.md`) kept in sync by `scripts/check-vale-style-sync.sh` (pre-push). A root-level `.pre-commit-hooks.yaml` exposes both copies (plus `skill-size-check`) so any external repo can enforce the same rules via `repo: <this-repo-url>, rev: <tag>` in its own `.pre-commit-config.yaml` — pre-commit clones the pinned rev into its own cache, independent of whether Claude Code or the `kyberforge` plugin is installed at all, and the same mechanism covers CI (`pre-commit run --all-files`). This repo's own `vale-audit-prefilter-skill`/`-agent` pre-commit hooks consume the identical plugin-bundled copies via `repo: local` (not a third root copy, and not a pinned self-reference — a pinned self-reference would lint working-tree edits against the last tagged release rather than the change being made). Every rule is `level: error` and every alert is a FAIL — no ignorable tier, same as shellcheck, the test suite, and conventional-pre-commit. Graded severities do not work here: Vale's exit code keys on `error` alerts alone, so `warning`/`suggestion` rules exit 0 and pre-commit swallows the output of a passing hook, leaving them invisible and blocking nothing. `MinAlertLevel` and `--minAlertLevel` are correspondingly absent from `.vale.ini` and the hook, being no-ops under this model. Vale covers the pattern-matchable sub-checks named in issue #84 (imperative opener, vague filler, `Use proactively`, generic reference-pointer padding) plus, per ADR-0013, one body-wide prose-pattern check ("There is/are" sentence openers) — everything else about body discipline (defaults-vs-menus, why-rationale, non-pattern-matchable judgment calls), near-miss exclusion strength, and control calibration stays LLM judgment.
|
Wiring Vale as a deterministic prefilter for `skill-audit`/`agent-audit`'s Description dimension (ADR motivation: issue #84) is repo-specific, not part of the generic `lint` plugin, so it doesn't live in `plugins/lint/` — but per ADR-0014 it also doesn't live at the repo root anymore. Two copies live inside `plugins/kyberforge/`, one per skill, since a plugin's cache-install only copies each skill's own files (no cross-skill sharing): `plugins/kyberforge/.apm/skills/agent-audit/assets/vale/` is canonical (`.vale.ini` plus a custom `Kyberforge` style covering description-opener banning ("This skill/agent..."), vague-capability wording ("helps with", "utilize", ...), and generic "see references/ for details" padding — and a `KyberforgeCopilot` style scoped only to `.agent.md` files for the Copilot-only "Use proactively has no effect" check), and `plugins/kyberforge/.apm/skills/skill-audit/assets/vale/` is a smaller duplicate (`Kyberforge` only, scoped to `SKILL.md`) kept in sync by `scripts/check-vale-style-sync.sh` (pre-push). A root-level `.pre-commit-hooks.yaml` exposes both copies (plus `skill-size-check`) so any external repo can enforce the same rules via `repo: <this-repo-url>, rev: <tag>` in its own `.pre-commit-config.yaml` — pre-commit clones the pinned rev into its own cache, independent of whether Claude Code or the `kyberforge` plugin is installed at all, and the same mechanism covers CI (`pre-commit run --all-files`). This repo's own `vale-audit-prefilter-skill`/`-agent` pre-commit hooks consume the identical plugin-bundled copies via `repo: local` (not a third root copy, and not a pinned self-reference — a pinned self-reference would lint working-tree edits against the last tagged release rather than the change being made). Every rule is `level: error` and every alert is a FAIL — no ignorable tier, same as shellcheck, the test suite, and conventional-pre-commit. Graded severities do not work here: Vale's exit code keys on `error` alerts alone, so `warning`/`suggestion` rules exit 0 and pre-commit swallows the output of a passing hook, leaving them invisible and blocking nothing. `MinAlertLevel` and `--minAlertLevel` are correspondingly absent from `.vale.ini` and the hook, being no-ops under this model. Vale covers the pattern-matchable sub-checks named in issue #84 (imperative opener, vague filler, `Use proactively`, generic reference-pointer padding) plus, per ADR-0013, one body-wide prose-pattern check ("There is/are" sentence openers) — everything else about body discipline (defaults-vs-menus, why-rationale, non-pattern-matchable judgment calls), near-miss exclusion strength, and control calibration stays LLM judgment.
|
||||||
|
|
||||||
Both skills' Step 1, and the `vale-audit-prefilter-skill`/`-agent` pre-commit hooks, call each copy's own `scripts/vale-wrap.sh` rather than `vale` directly — a workaround for a confirmed Vale 3.15.2 limitation (see `vale-config`'s Gotchas): `text.frontmatter.description` silently stops matching on most — not all — multi-line descriptions. Verified by reproduction, not assumed: `>` folded scalars, plain (unquoted) continuation lines, and single- or double-quoted multi-line scalars all yield 0 alerts and exit 0 on a deliberately-bad fixture, while a `|` literal block spanning the same 2+ lines lints normally (alerts fire, exit 1). The wrapper flattens those three broken forms to one physical line in a scratch copy (padding with blank lines so every other line number is unchanged) before handing off to real `vale`; `|` literal blocks and single-line descriptions pass through untouched, already linting correctly. The plain and quoted forms previously passed silently — unflattened and unmatched — so a bad description in either sailed through the prefilter. Handed no `--config` at all, the wrapper falls back to its own sibling `assets/vale/.vale.ini`, located from `${BASH_SOURCE[0]}` rather than from the cwd — which is why both manifests' `entry:` is now the bare script path with no argument after it. pre-commit prefixes only `entry[0]` with the hook-repo clone path (`cmd = (prefix.path(cmd[0]), *cmd[1:])`), so every later argument resolves against the *consuming* repo's root: a `--config` in `.pre-commit-hooks.yaml` pointed at a path no consumer has and hard-failed every external run with `E100 [--config] Runtime error`. `.pre-commit-config.yaml` drops the argument too, deliberately keeping the two entries identical — the local `repo: local` hook resolved its `--config` correctly only because the consuming repo *was* this repo, and that divergence is why three review rounds exercised a path no external consumer takes and missed the defect. An explicit `--config` still wins, in all three argv forms (`--config X`, `--config=/abs`, `--config=rel`), and a relative one still resolves against the caller's cwd, matching bare `vale`, not the repo root. Both audit skills' Step 1 now passes no `--config` either: it resolves the script relative to the skill's own directory so the call works from an installed plugin cache, but a relative `--config` alongside it would still resolve against the cwd, yielding `E100 Runtime error ... does not exist` and exit 2 — which both skills' fallback misreads as "vale unavailable" and silently downgrades to full LLM judgment. `tests/test-vale-wrap.sh` regression-tests this against skill-audit's copy specifically (its fixtures are all `SKILL.md`-shaped, and only skill-audit's `.vale.ini` has that glob section). Each `.vale.ini`'s section globs are path-agnostic (`[**/SKILL.md]` for skill-audit's copy; `[**/agents/*.md]`/`[**/*.agent.md]` for agent-audit's) and do no scoping on their own: Vale's `*` crosses `/`. Scoping comes from each pre-commit hook's own `files:` regex and from the audit skills passing one explicit file per invocation. The two manifests scope differently on purpose: this repo's `.pre-commit-config.yaml` pins its own layout — `^plugins/[^/]+/skills/[^/]+/SKILL\.md$` for `-skill`, `^plugins/[^/]+/agents/[^/]+\.md$` for `-agent` — while the shipped `.pre-commit-hooks.yaml` stays layout-agnostic for external consumers whose skills live anywhere, using `(^|/)SKILL\.md$` and `(^|/)agents/[^/]+\.md$|\.agent\.md$`. Both manifests split the prefilter into two hooks precisely because one combined hook pointed at only one copy would silently 0-file-skip the other file type. A `SKILL.md` outside `plugins/` (e.g. project-scope `.claude/skills/foo/SKILL.md`) still matches `[**/SKILL.md]` and gets linted normally — the globs constrain filename shape, not location. Vale reports 0 files only when the path it is handed matches no glob section at all: a differently-named file, or a directory argument holding nothing that matches. That run prints `✔ 0 errors ... in 0 files.` and exits 0, indistinguishable from a clean pass, so both audits treat a 0-file Vale run as NOT RUN and fall back to full LLM judgment.
|
Both skills' Step 1, and the `vale-audit-prefilter-skill`/`-agent` pre-commit hooks, call each copy's own `scripts/vale-wrap.sh` rather than `vale` directly — a workaround for a confirmed Vale 3.15.2 limitation (see `vale-config`'s Gotchas): `text.frontmatter.description` silently stops matching on most — not all — multi-line descriptions. Verified by reproduction, not assumed: `>` folded scalars, plain (unquoted) continuation lines, and single- or double-quoted multi-line scalars all yield 0 alerts and exit 0 on a deliberately-bad fixture, while a `|` literal block spanning the same 2+ lines lints normally (alerts fire, exit 1). The wrapper flattens those three broken forms to one physical line in a scratch copy (padding with blank lines so every other line number is unchanged) before handing off to real `vale`; `|` literal blocks and single-line descriptions pass through untouched, already linting correctly. The plain and quoted forms previously passed silently — unflattened and unmatched — so a bad description in either sailed through the prefilter. Handed no `--config` at all, the wrapper falls back to its own sibling `assets/vale/.vale.ini`, located from `${BASH_SOURCE[0]}` rather than from the cwd — which is why both manifests' `entry:` is now the bare script path with no argument after it. pre-commit prefixes only `entry[0]` with the hook-repo clone path (`cmd = (prefix.path(cmd[0]), *cmd[1:])`), so every later argument resolves against the *consuming* repo's root: a `--config` in `.pre-commit-hooks.yaml` pointed at a path no consumer has and hard-failed every external run with `E100 [--config] Runtime error`. `.pre-commit-config.yaml` drops the argument too, deliberately keeping the two entries identical — the local `repo: local` hook resolved its `--config` correctly only because the consuming repo *was* this repo, and that divergence is why three review rounds exercised a path no external consumer takes and missed the defect. An explicit `--config` still wins, in all three argv forms (`--config X`, `--config=/abs`, `--config=rel`), and a relative one still resolves against the caller's cwd, matching bare `vale`, not the repo root. Both audit skills' Step 1 now passes no `--config` either: it resolves the script relative to the skill's own directory so the call works from an installed plugin cache, but a relative `--config` alongside it would still resolve against the cwd, yielding `E100 Runtime error ... does not exist` and exit 2 — which both skills' fallback misreads as "vale unavailable" and silently downgrades to full LLM judgment. `tests/test-vale-wrap.sh` regression-tests this against skill-audit's copy specifically (its fixtures are all `SKILL.md`-shaped, and only skill-audit's `.vale.ini` has that glob section). Each `.vale.ini`'s section globs are path-agnostic (`[**/SKILL.md]` for skill-audit's copy; `[**/agents/*.md]`/`[**/*.agent.md]` for agent-audit's) and do no scoping on their own: Vale's `*` crosses `/`. Scoping comes from each pre-commit hook's own `files:` regex and from the audit skills passing one explicit file per invocation. The two manifests scope differently on purpose: this repo's `.pre-commit-config.yaml` pins its own layout — `^plugins/[^/]+/\.apm/skills/[^/]+/SKILL\.md$` for `-skill`, `^plugins/[^/]+/\.apm/agents/[^/]+\.agent\.md$` for `-agent` — while the shipped `.pre-commit-hooks.yaml` stays layout-agnostic for external consumers whose skills live anywhere, using `(^|/)SKILL\.md$` and `(^|/)agents/[^/]+\.md$|\.agent\.md$`. Both manifests split the prefilter into two hooks precisely because one combined hook pointed at only one copy would silently 0-file-skip the other file type. A `SKILL.md` outside `plugins/` (e.g. project-scope `.claude/skills/foo/SKILL.md`) still matches `[**/SKILL.md]` and gets linted normally — the globs constrain filename shape, not location. Vale reports 0 files only when the path it is handed matches no glob section at all: a differently-named file, or a directory argument holding nothing that matches. That run prints `✔ 0 errors ... in 0 files.` and exits 0, indistinguishable from a clean pass, so both audits treat a 0-file Vale run as NOT RUN and fall back to full LLM judgment.
|
||||||
|
|
||||||
This scope expands per ADR-0013: one cherry-picked low-noise `write-good`/`alex` rule landed in `styles/Kyberforge`, `Kyberforge.SentenceOpenerThereIs` (22 held-out hits, both in-corpus hits clean rewrites, zero suppressions). A second, `Kyberforge.VagueQualifier`, was cherry-picked and then deleted: 2 hits across the 41 skill/agent files, one marginal and one an unfixable false positive (`caveman/SKILL.md` quotes `of course` as an example of filler — a mention, not a use) that forced the repo's only Vale suppression comments. Also new is a sibling pre-commit hook, `skill-size-check` (`scripts/skill-size-check.sh`), enforcing agentskills.io's `SKILL.md` ceiling as two blocking gates: `MAX_LINES=500` and `MAX_WORDS=2770` (a word-count proxy for the 5,000-token limit, calibrated to the densest prose measured in this repo — 1.81 tokens per word — so even a worst-case `SKILL.md` at the ceiling stays under 5,000 tokens). Both are inclusive, and `skill-audit/scripts/validate.sh` checks the same pair on the same terms, so a `SKILL.md` can no longer pass its own audit yet be blocked by the commit hook. Scoped to `^plugins/[^/]+/skills/[^/]+/SKILL\.md$` only, same as `vale-audit-prefilter-skill`, so it never lints `docs/research/examples/` reference skills. It's also exposed in the root-level `.pre-commit-hooks.yaml` as `kyberforge-skill-size-check` — it has no external asset dependency, so it needed no relocation, only exposure to external consumers. File scope (`SKILL.md` + agent files) and enforcement model (rules land directly in `styles/Kyberforge`, blocking immediately, no trial tier) stay unchanged; governance.md/CONTROLS.md were evaluated and excluded as rule sources (nothing prose-pattern-matchable to mine). House convention: banned phrasing that must be mentioned rather than used goes in backticks or a fenced code block — Vale skips code spans and fences, so no suppression is needed; inline `<!-- vale Rule = NO -->` (HTML-comment form; the MDX `{/* */}` form does not work in plain Markdown) is the fallback only where backticking is impossible.
|
This scope expands per ADR-0013: one cherry-picked low-noise `write-good`/`alex` rule landed in `styles/Kyberforge`, `Kyberforge.SentenceOpenerThereIs` (22 held-out hits, both in-corpus hits clean rewrites, zero suppressions). A second, `Kyberforge.VagueQualifier`, was cherry-picked and then deleted: 2 hits across the 41 skill/agent files, one marginal and one an unfixable false positive (`caveman/SKILL.md` quotes `of course` as an example of filler — a mention, not a use) that forced the repo's only Vale suppression comments. Also new is a sibling pre-commit hook, `skill-size-check` (`scripts/skill-size-check.sh`), enforcing agentskills.io's `SKILL.md` ceiling as two blocking gates: `MAX_LINES=500` and `MAX_WORDS=2770` (a word-count proxy for the 5,000-token limit, calibrated to the densest prose measured in this repo — 1.81 tokens per word — so even a worst-case `SKILL.md` at the ceiling stays under 5,000 tokens). Both are inclusive, and `skill-audit/scripts/validate.sh` checks the same pair on the same terms, so a `SKILL.md` can no longer pass its own audit yet be blocked by the commit hook. Scoped to `^plugins/[^/]+/\.apm/skills/[^/]+/SKILL\.md$` only, same as `vale-audit-prefilter-skill`, so it never lints `docs/research/examples/` reference skills. It's also exposed in the root-level `.pre-commit-hooks.yaml` as `kyberforge-skill-size-check` — it has no external asset dependency, so it needed no relocation, only exposure to external consumers. File scope (`SKILL.md` + agent files) and enforcement model (rules land directly in `styles/Kyberforge`, blocking immediately, no trial tier) stay unchanged; governance.md/CONTROLS.md were evaluated and excluded as rule sources (nothing prose-pattern-matchable to mine). House convention: banned phrasing that must be mentioned rather than used goes in backticks or a fenced code block — Vale skips code spans and fences, so no suppression is needed; inline `<!-- vale Rule = NO -->` (HTML-comment form; the MDX `{/* */}` form does not work in plain Markdown) is the fallback only where backticking is impossible.
|
||||||
|
|
||||||
### LESSONS.md
|
### LESSONS.md
|
||||||
Long-loop feedback log for patterns observed across sessions. Three or more entries on the same pattern graduate to the relevant standing file (e.g. a coding convention, a governance rule). Updated by the session-handoff skill or directly by the human. Lives at the repo root.
|
Long-loop feedback log for patterns observed across sessions. Three or more entries on the same pattern graduate to the relevant standing file (e.g. a coding convention, a governance rule). Updated by the session-handoff skill or directly by the human. Lives at the repo root.
|
||||||
|
|||||||
@@ -107,6 +107,37 @@ source and scans directories; it does not execute a package manager's build comm
|
|||||||
Copying the relevant subset back to the stable `plugins/<name>/` path — where `marketplace.json`
|
Copying the relevant subset back to the stable `plugins/<name>/` path — where `marketplace.json`
|
||||||
already points — needed no change to the marketplace source model at all.
|
already points — needed no change to the marketplace source model at all.
|
||||||
|
|
||||||
|
## Amendment (2026-08-13): `mcpServers` is narrowly reinjected into Copilot's `plugin.json`
|
||||||
|
|
||||||
|
PR #95's review (a follow-on to this same issue #90 workstream) found a second field apm's
|
||||||
|
compiler strips for the Copilot ecosystem: `build_plugin_manifest` unconditionally removes
|
||||||
|
`mcpServers` from every Copilot-ecosystem `plugin.json`, its docstring stating the field is "not
|
||||||
|
part of the Copilot plugin manifest schema." That claim is contradicted by this repo's own
|
||||||
|
researched documentation — `plugins/kyberforge/docs/research/docs/github-copilot-plugins/
|
||||||
|
configuration.md:49` documents `mcpServers` as a valid, optional `plugin.json` field for Copilot.
|
||||||
|
|
||||||
|
This is not the same situation "Considered options" above rejected. That rejection concerned
|
||||||
|
fields apm strips *correctly*, on a stable and accurate premise: convention directories
|
||||||
|
(`skills/`, `agents/`, `commands/`) are host-auto-discovered, so an explicit pointer is redundant
|
||||||
|
by design. Here, apm's own stated justification for stripping `mcpServers` is factually wrong
|
||||||
|
against documented Copilot behavior — there is no host-auto-discovery mechanism that makes an
|
||||||
|
explicit `mcpServers` declaration redundant, the way there is for skills/agents/commands. Applying
|
||||||
|
the same "don't fight a stable, intentional apm code path" reasoning here would mean shipping a
|
||||||
|
plugin manifest known to be missing a field Copilot actually reads.
|
||||||
|
|
||||||
|
Given that, `scripts/sync-plugin-content.sh`'s `reinject_mcp_servers()` (line 190, called from
|
||||||
|
`sync_one()` at line 269, real syncs only) narrowly re-injects `mcpServers` into
|
||||||
|
`.github/plugin/plugin.json` after a real sync, sourced from the plugin's own `.mcp.json`, and
|
||||||
|
only when it declares at least one server — matching apm's own Claude-ecosystem builder, which
|
||||||
|
omits the field entirely rather than emitting `mcpServers: {}`. This is scoped to one field found
|
||||||
|
to be incorrectly stripped, not a reversal of the broader position above: the rejection of
|
||||||
|
patching `skills`/`agents`/`commands`/`hooks` pointers still holds, since apm's premise for
|
||||||
|
stripping those remains accurate.
|
||||||
|
|
||||||
|
Consequence: if a future apm release corrects the Copilot `mcpServers` omission, `reinject_mcp_servers()`
|
||||||
|
and its call site become dead code and should be deleted — nothing else in this ADR depends on the
|
||||||
|
reinjection existing beyond working around this specific upstream gap.
|
||||||
|
|
||||||
## Consequences
|
## Consequences
|
||||||
|
|
||||||
- Git now tracks real, visible duplication: `.apm/skills/<name>/SKILL.md` and
|
- Git now tracks real, visible duplication: `.apm/skills/<name>/SKILL.md` and
|
||||||
|
|||||||
12
plugins/bin/.github/plugin/plugin.json
vendored
12
plugins/bin/.github/plugin/plugin.json
vendored
@@ -16,5 +16,15 @@
|
|||||||
"prototyping",
|
"prototyping",
|
||||||
"tdd",
|
"tdd",
|
||||||
"research"
|
"research"
|
||||||
]
|
],
|
||||||
|
"mcpServers": {
|
||||||
|
"obsidian": {
|
||||||
|
"args": [
|
||||||
|
"@bitbonsai/mcpvault@latest",
|
||||||
|
"docs/"
|
||||||
|
],
|
||||||
|
"command": "npx",
|
||||||
|
"type": "stdio"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,20 @@ set -euo pipefail
|
|||||||
# refreshes both files from current apm.yml/.apm/ content -- apm pack silently skips
|
# refreshes both files from current apm.yml/.apm/ content -- apm pack silently skips
|
||||||
# regenerating an existing plugin.json otherwise ("already exists; skipping plugin.json
|
# regenerating an existing plugin.json otherwise ("already exists; skipping plugin.json
|
||||||
# generation"), which would let them go stale after a name/version/description edit.
|
# generation"), which would let them go stale after a name/version/description edit.
|
||||||
# --check does NOT pass --force (it must not mutate the plugin root), so plugin.json
|
#
|
||||||
# staleness is not currently detected by --check -- only fixed by the next real sync.
|
# apm's Copilot-ecosystem plugin.json builder omits mcpServers entirely -- its own
|
||||||
|
# docstring calls it out-of-schema for Copilot, but this repo's researched Copilot
|
||||||
|
# plugin schema docs (plugins/kyberforge/docs/research/docs/github-copilot-plugins/
|
||||||
|
# configuration.md) document mcpServers as valid there. Real-mode syncs re-inject it
|
||||||
|
# into .github/plugin/plugin.json from the plugin's own .mcp.json after apm pack runs
|
||||||
|
# (see reinject_mcp_servers below); staleness there, like the rest of plugin.json, is
|
||||||
|
# only fixed by the next real sync, not detected by --check.
|
||||||
|
#
|
||||||
|
# apm pack also writes .claude-plugin/plugin.json and .github/plugin/plugin.json into
|
||||||
|
# cwd whenever those files don't already exist yet -- regardless of --force -- so
|
||||||
|
# --check (which must never mutate the real plugin root) never cds into plugin_dir
|
||||||
|
# directly. It packs a throwaway copy instead (see sync_one's pack_cwd); only that
|
||||||
|
# copy's manifest files, never the real ones, can get created as a first-write.
|
||||||
#
|
#
|
||||||
# hooks.json is only synced when .apm/hooks/ actually produces one -- a plugin with
|
# hooks.json is only synced when .apm/hooks/ actually produces one -- a plugin with
|
||||||
# no .apm/hooks/ content is left alone even if a root-level hooks.json already exists
|
# no .apm/hooks/ content is left alone even if a root-level hooks.json already exists
|
||||||
@@ -37,7 +49,7 @@ set -euo pipefail
|
|||||||
# the duplicate and double-running the original under any repo-wide bats/test discovery.
|
# the duplicate and double-running the original under any repo-wide bats/test discovery.
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $0 [--check] <plugin-dir> [<plugin-dir> ...]" >&2
|
echo "Usage: $0 [--check] (--all | <plugin-dir> [<plugin-dir> ...])" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,13 +58,29 @@ if [[ "${1:-}" == "--check" ]]; then
|
|||||||
CHECK=1
|
CHECK=1
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ALL=0
|
||||||
|
if [[ "${1:-}" == "--all" ]]; then
|
||||||
|
ALL=1
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$ALL" -eq 1 ]]; then
|
||||||
|
[[ $# -eq 0 ]] || usage
|
||||||
|
else
|
||||||
[[ $# -ge 1 ]] || usage
|
[[ $# -ge 1 ]] || usage
|
||||||
|
fi
|
||||||
|
|
||||||
if ! command -v apm &>/dev/null; then
|
if ! command -v apm &>/dev/null; then
|
||||||
echo "Error: apm is required but not installed (see kyberforge:apm-install)" >&2
|
echo "Error: apm is required but not installed (see kyberforge:apm-install)" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! command -v jq &>/dev/null; then
|
||||||
|
echo "Error: jq is required but not installed" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Convention subdirectories apm's plugin exporter can populate from .apm/.
|
# Convention subdirectories apm's plugin exporter can populate from .apm/.
|
||||||
MIRROR_DIRS=(agents skills commands instructions extensions)
|
MIRROR_DIRS=(agents skills commands instructions extensions)
|
||||||
|
|
||||||
@@ -60,6 +88,52 @@ FAIL=0
|
|||||||
SCRATCH_ROOT="$(mktemp -d)"
|
SCRATCH_ROOT="$(mktemp -d)"
|
||||||
trap 'rm -rf "$SCRATCH_ROOT"' EXIT
|
trap 'rm -rf "$SCRATCH_ROOT"' EXIT
|
||||||
|
|
||||||
|
if [[ "$ALL" -eq 1 ]]; then
|
||||||
|
# Derives the plugin list from marketplace.json the same way
|
||||||
|
# scripts/check-manifests.sh does, instead of hand-maintaining a duplicate list
|
||||||
|
# at every call site (see .pre-commit-config.yaml's check-plugin-content-sync).
|
||||||
|
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
||||||
|
MARKETPLACE="$REPO_ROOT/.claude-plugin/marketplace.json"
|
||||||
|
if [[ ! -f "$MARKETPLACE" ]]; then
|
||||||
|
echo "Error: --all requires $MARKETPLACE" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
declare -a plugin_dirs=()
|
||||||
|
plugin_count="$(jq '.plugins | length' "$MARKETPLACE")"
|
||||||
|
for ((i = 0; i < plugin_count; i++)); do
|
||||||
|
source_type="$(jq -r ".plugins[$i].source | type" "$MARKETPLACE")"
|
||||||
|
# Remote sources (github, git, npm objects) have no local directory to sync.
|
||||||
|
[[ "$source_type" == "string" ]] || continue
|
||||||
|
source="$(jq -r ".plugins[$i].source" "$MARKETPLACE")"
|
||||||
|
source="${source#./}"
|
||||||
|
plugin_dirs+=("$REPO_ROOT/$source")
|
||||||
|
done
|
||||||
|
else
|
||||||
|
declare -a plugin_dirs=("$@")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fail fast on a basename collision rather than letting two plugin_dir arguments
|
||||||
|
# silently share (and corrupt) the same $name.log/$name.status/$name.checkcopy
|
||||||
|
# scratch paths below.
|
||||||
|
declare -a seen_names=()
|
||||||
|
for plugin_dir in "${plugin_dirs[@]}"; do
|
||||||
|
name="$(basename "${plugin_dir%/}")"
|
||||||
|
for seen in ${seen_names[@]+"${seen_names[@]}"}; do
|
||||||
|
if [[ "$seen" == "$name" ]]; then
|
||||||
|
echo "Error: duplicate plugin basename '$name' among arguments -- scratch paths would collide" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
seen_names+=("$name")
|
||||||
|
done
|
||||||
|
|
||||||
|
normalize_trailing_newline() {
|
||||||
|
# apm's bundle exporter writes hooks.json without a trailing newline, which
|
||||||
|
# end-of-file-fixer (pre-commit) would flag on every regeneration -- normalize
|
||||||
|
# instead of fighting that hook on every sync.
|
||||||
|
printf '%s\n' "$(cat "$1")" >"$2"
|
||||||
|
}
|
||||||
|
|
||||||
sync_dir() {
|
sync_dir() {
|
||||||
local plugin_dir="$1" bundle_dir="$2" d="$3"
|
local plugin_dir="$1" bundle_dir="$2" d="$3"
|
||||||
local src="$bundle_dir/$d" dst="$plugin_dir/$d"
|
local src="$bundle_dir/$d" dst="$plugin_dir/$d"
|
||||||
@@ -98,14 +172,10 @@ sync_hooks_json() {
|
|||||||
# No .apm/hooks/ content -- hooks.json (if any) is out of scope for this script.
|
# No .apm/hooks/ content -- hooks.json (if any) is out of scope for this script.
|
||||||
[[ -f "$src" ]] || return 0
|
[[ -f "$src" ]] || return 0
|
||||||
|
|
||||||
# apm's bundle exporter writes hooks.json without a trailing newline, which
|
|
||||||
# end-of-file-fixer (pre-commit) would flag on every regeneration -- normalize both
|
|
||||||
# sides of the comparison (and the real write) to exactly one trailing newline
|
|
||||||
# instead of fighting that hook on every sync.
|
|
||||||
if [[ "$CHECK" -eq 1 ]]; then
|
if [[ "$CHECK" -eq 1 ]]; then
|
||||||
local normalized_src
|
local normalized_src
|
||||||
normalized_src="$(mktemp)"
|
normalized_src="$(mktemp)"
|
||||||
printf '%s\n' "$(cat "$src")" >"$normalized_src"
|
normalize_trailing_newline "$src" "$normalized_src"
|
||||||
if [[ ! -f "$dst" ]] || ! diff -q "$normalized_src" "$dst" >/dev/null 2>&1; then
|
if [[ ! -f "$dst" ]] || ! diff -q "$normalized_src" "$dst" >/dev/null 2>&1; then
|
||||||
echo "DRIFT $dst: out of sync with .apm/hooks/" >&2
|
echo "DRIFT $dst: out of sync with .apm/hooks/" >&2
|
||||||
FAIL=1
|
FAIL=1
|
||||||
@@ -114,7 +184,25 @@ sync_hooks_json() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf '%s\n' "$(cat "$src")" >"$dst"
|
normalize_trailing_newline "$src" "$dst"
|
||||||
|
}
|
||||||
|
|
||||||
|
reinject_mcp_servers() {
|
||||||
|
local plugin_dir="$1"
|
||||||
|
local mcp_src="$plugin_dir/.mcp.json" dst="$plugin_dir/.github/plugin/plugin.json"
|
||||||
|
[[ -f "$mcp_src" ]] || return 0
|
||||||
|
[[ -f "$dst" ]] || return 0
|
||||||
|
|
||||||
|
# Match apm's own Claude-ecosystem plugin.json builder: mcpServers is omitted
|
||||||
|
# entirely when the plugin declares none, not written out as an empty object.
|
||||||
|
local count
|
||||||
|
count="$(jq '(.mcpServers // {}) | length' "$mcp_src")"
|
||||||
|
[[ "$count" -gt 0 ]] || return 0
|
||||||
|
|
||||||
|
local tmp
|
||||||
|
tmp="$(mktemp)"
|
||||||
|
jq --slurpfile mcp "$mcp_src" '.mcpServers = $mcp[0].mcpServers' "$dst" >"$tmp"
|
||||||
|
mv "$tmp" "$dst"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Runs entirely inside a backgrounded subshell (see the dispatch loop below), so
|
# Runs entirely inside a backgrounded subshell (see the dispatch loop below), so
|
||||||
@@ -125,22 +213,36 @@ sync_one() {
|
|||||||
local apm_dir="$plugin_dir/.apm"
|
local apm_dir="$plugin_dir/.apm"
|
||||||
FAIL=0
|
FAIL=0
|
||||||
|
|
||||||
|
if [[ ! -d "$plugin_dir" ]]; then
|
||||||
|
echo "FAIL $plugin_dir: plugin directory does not exist" >&2
|
||||||
|
FAIL=1
|
||||||
|
echo "$FAIL" >"$status_file"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ ! -d "$apm_dir" ]]; then
|
if [[ ! -d "$apm_dir" ]]; then
|
||||||
echo "SKIP $plugin_dir: no .apm/ directory" >&2
|
echo "SKIP $plugin_dir: no .apm/ directory" >&2
|
||||||
echo "$FAIL" >"$status_file"
|
echo "$FAIL" >"$status_file"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local name scratch bundle_dir pack_log
|
local name scratch bundle_dir pack_log pack_cwd
|
||||||
name="$(basename "$plugin_dir")"
|
name="$(basename "$plugin_dir")"
|
||||||
scratch="$SCRATCH_ROOT/$name"
|
scratch="$SCRATCH_ROOT/$name"
|
||||||
mkdir -p "$scratch"
|
mkdir -p "$scratch"
|
||||||
pack_log="$(mktemp)"
|
pack_log="$(mktemp)"
|
||||||
|
|
||||||
local force_flag=()
|
local force_flag=()
|
||||||
[[ "$CHECK" -eq 0 ]] && force_flag=(--force)
|
if [[ "$CHECK" -eq 0 ]]; then
|
||||||
|
force_flag=(--force)
|
||||||
|
pack_cwd="$plugin_dir"
|
||||||
|
else
|
||||||
|
pack_cwd="$SCRATCH_ROOT/$name.checkcopy"
|
||||||
|
mkdir -p "$pack_cwd"
|
||||||
|
cp -a "$plugin_dir/." "$pack_cwd/"
|
||||||
|
fi
|
||||||
|
|
||||||
if ! (cd "$plugin_dir" && apm pack --format plugin "${force_flag[@]}" -o "$scratch") >"$pack_log" 2>&1; then
|
if ! (cd "$pack_cwd" && apm pack --format plugin "${force_flag[@]}" -o "$scratch") >"$pack_log" 2>&1; then
|
||||||
echo "FAIL $plugin_dir: apm pack failed:" >&2
|
echo "FAIL $plugin_dir: apm pack failed:" >&2
|
||||||
sed 's/^/ /' "$pack_log" >&2
|
sed 's/^/ /' "$pack_log" >&2
|
||||||
rm -f "$pack_log"
|
rm -f "$pack_log"
|
||||||
@@ -163,6 +265,9 @@ sync_one() {
|
|||||||
sync_dir "$plugin_dir" "$bundle_dir" "$d"
|
sync_dir "$plugin_dir" "$bundle_dir" "$d"
|
||||||
done
|
done
|
||||||
sync_hooks_json "$plugin_dir" "$bundle_dir"
|
sync_hooks_json "$plugin_dir" "$bundle_dir"
|
||||||
|
if [[ "$CHECK" -eq 0 ]]; then
|
||||||
|
reinject_mcp_servers "$plugin_dir"
|
||||||
|
fi
|
||||||
echo "$FAIL" >"$status_file"
|
echo "$FAIL" >"$status_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,10 +276,22 @@ sync_one() {
|
|||||||
# than paying that startup cost N times serially. Output is buffered per plugin
|
# than paying that startup cost N times serially. Output is buffered per plugin
|
||||||
# (not streamed) so concurrent DRIFT/FAIL messages from different plugins never
|
# (not streamed) so concurrent DRIFT/FAIL messages from different plugins never
|
||||||
# interleave; it's flushed in stable $@ order once every job has finished.
|
# interleave; it's flushed in stable $@ order once every job has finished.
|
||||||
declare -a plugin_dirs=("$@")
|
#
|
||||||
|
# Batched (not a rolling pool) because a bounded rolling pool needs `wait -n`,
|
||||||
|
# which is bash 4.3+ -- tests/run-tests.sh and tests/run-bats.sh in this same repo
|
||||||
|
# are explicitly bash-3.2-safe, so this script matches their pattern for
|
||||||
|
# consistency. `getconf` over `nproc` for the same reason: `nproc` doesn't exist
|
||||||
|
# on macOS.
|
||||||
|
JOBS_LIMIT="$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 4)"
|
||||||
|
running=0
|
||||||
for plugin_dir in "${plugin_dirs[@]}"; do
|
for plugin_dir in "${plugin_dirs[@]}"; do
|
||||||
name="$(basename "${plugin_dir%/}")"
|
name="$(basename "${plugin_dir%/}")"
|
||||||
(sync_one "$plugin_dir" "$SCRATCH_ROOT/$name.status") >"$SCRATCH_ROOT/$name.log" 2>&1 &
|
(sync_one "$plugin_dir" "$SCRATCH_ROOT/$name.status") >"$SCRATCH_ROOT/$name.log" 2>&1 &
|
||||||
|
running=$((running + 1))
|
||||||
|
if [[ $running -ge $JOBS_LIMIT ]]; then
|
||||||
|
wait
|
||||||
|
running=0
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
wait
|
wait
|
||||||
|
|
||||||
@@ -187,7 +304,11 @@ done
|
|||||||
|
|
||||||
if [[ "$FAIL" -ne 0 ]]; then
|
if [[ "$FAIL" -ne 0 ]]; then
|
||||||
if [[ "$CHECK" -eq 1 ]]; then
|
if [[ "$CHECK" -eq 1 ]]; then
|
||||||
|
if [[ "$ALL" -eq 1 ]]; then
|
||||||
|
echo "Plugin content mirror is out of sync with .apm/. Fix: bash scripts/sync-plugin-content.sh --all" >&2
|
||||||
|
else
|
||||||
echo "Plugin content mirror is out of sync with .apm/. Fix: bash scripts/sync-plugin-content.sh $*" >&2
|
echo "Plugin content mirror is out of sync with .apm/. Fix: bash scripts/sync-plugin-content.sh $*" >&2
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -39,11 +39,12 @@ fi
|
|||||||
SCRATCH_ROOT="$(mktemp -d)"
|
SCRATCH_ROOT="$(mktemp -d)"
|
||||||
trap 'rm -rf "$SCRATCH_ROOT"' EXIT
|
trap 'rm -rf "$SCRATCH_ROOT"' EXIT
|
||||||
|
|
||||||
# A failing test is the normal case a CI runner must handle, and a failing
|
# Batches (not a rolling pool) because a bounded rolling pool needs `wait -n`,
|
||||||
# background job makes `wait`/`wait -n` return non-zero -- under `set -e` that
|
# which is bash 4.3+ and this script is explicitly bash-3.2-safe like
|
||||||
# would abort the script right here, before the per-file report below ever
|
# run-tests.sh; plain `wait` -- waiting for every job in the current batch --
|
||||||
# runs. Every wait in this dispatcher is therefore explicitly guarded.
|
# is available since ancient bash. `getconf` over `nproc` for the same
|
||||||
JOBS="$(nproc 2>/dev/null || echo 4)"
|
# reason: `nproc` doesn't exist on macOS.
|
||||||
|
JOBS="$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 4)"
|
||||||
running=0
|
running=0
|
||||||
i=0
|
i=0
|
||||||
for f in "${TEST_FILES[@]}"; do
|
for f in "${TEST_FILES[@]}"; do
|
||||||
@@ -51,11 +52,11 @@ for f in "${TEST_FILES[@]}"; do
|
|||||||
( "$BATS" "$f" >"$SCRATCH_ROOT/$i.log" 2>&1; echo $? >"$SCRATCH_ROOT/$i.status" ) &
|
( "$BATS" "$f" >"$SCRATCH_ROOT/$i.log" 2>&1; echo $? >"$SCRATCH_ROOT/$i.status" ) &
|
||||||
running=$((running + 1))
|
running=$((running + 1))
|
||||||
if [[ "$running" -ge "$JOBS" ]]; then
|
if [[ "$running" -ge "$JOBS" ]]; then
|
||||||
wait -n || true
|
wait
|
||||||
running=$((running - 1))
|
running=0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
wait || true
|
wait
|
||||||
|
|
||||||
FAIL=0
|
FAIL=0
|
||||||
TOTAL_OK=0
|
TOTAL_OK=0
|
||||||
|
|||||||
@@ -61,11 +61,56 @@ EOF
|
|||||||
echo "$dir"
|
echo "$dir"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Same base fixture, but with a copilot target (so apm pack produces
|
||||||
|
# .github/plugin/plugin.json) and a caller-supplied .mcp.json -- for exercising
|
||||||
|
# reinject_mcp_servers().
|
||||||
|
make_fixture_with_mcp() {
|
||||||
|
local mcp_json="$1" dir
|
||||||
|
dir="$(mktemp -d)"
|
||||||
|
mkdir -p "$dir/.apm/skills/hello" "$dir/.apm/agents"
|
||||||
|
cat > "$dir/apm.yml" <<'YAML'
|
||||||
|
name: fixture
|
||||||
|
version: 0.0.1
|
||||||
|
description: fixture
|
||||||
|
license: MIT
|
||||||
|
type: hybrid
|
||||||
|
targets:
|
||||||
|
- claude
|
||||||
|
- copilot
|
||||||
|
dependencies:
|
||||||
|
apm: []
|
||||||
|
mcp: []
|
||||||
|
includes: auto
|
||||||
|
devDependencies:
|
||||||
|
apm: []
|
||||||
|
scripts: {}
|
||||||
|
YAML
|
||||||
|
cat > "$dir/.apm/skills/hello/SKILL.md" <<'EOF'
|
||||||
|
---
|
||||||
|
name: hello
|
||||||
|
description: hello
|
||||||
|
---
|
||||||
|
Hello.
|
||||||
|
EOF
|
||||||
|
cat > "$dir/.apm/agents/foo.agent.md" <<'EOF'
|
||||||
|
---
|
||||||
|
name: foo
|
||||||
|
description: foo
|
||||||
|
---
|
||||||
|
Foo.
|
||||||
|
EOF
|
||||||
|
printf '%s' "$mcp_json" > "$dir/.mcp.json"
|
||||||
|
echo "$dir"
|
||||||
|
}
|
||||||
|
|
||||||
|
CLEANUP_DIRS=()
|
||||||
|
trap 'rm -rf "${CLEANUP_DIRS[@]}"' EXIT
|
||||||
|
track() { CLEANUP_DIRS+=("$1"); }
|
||||||
|
|
||||||
# --- 1. --check reports drift before any sync has run ---
|
# --- 1. --check reports drift before any sync has run ---
|
||||||
echo ""
|
echo ""
|
||||||
echo "--- --check reports drift on an unsynced fixture ---"
|
echo "--- --check reports drift on an unsynced fixture ---"
|
||||||
FIXTURE="$(make_fixture)"
|
FIXTURE="$(make_fixture)"; track "$FIXTURE"
|
||||||
trap 'rm -rf "$FIXTURE"' EXIT
|
|
||||||
if bash "$SCRIPT" --check "$FIXTURE" > /dev/null 2>&1; then
|
if bash "$SCRIPT" --check "$FIXTURE" > /dev/null 2>&1; then
|
||||||
fail "exited 0 on an unsynced fixture — expected drift (exit 1)"
|
fail "exited 0 on an unsynced fixture — expected drift (exit 1)"
|
||||||
else
|
else
|
||||||
@@ -128,14 +173,69 @@ fi
|
|||||||
# --- 6. A plugin dir with no .apm/ is skipped cleanly, not treated as an error ---
|
# --- 6. A plugin dir with no .apm/ is skipped cleanly, not treated as an error ---
|
||||||
echo ""
|
echo ""
|
||||||
echo "--- a plugin dir with no .apm/ is skipped, not failed ---"
|
echo "--- a plugin dir with no .apm/ is skipped, not failed ---"
|
||||||
NO_APM="$(mktemp -d)"
|
NO_APM="$(mktemp -d)"; track "$NO_APM"
|
||||||
trap 'rm -rf "$NO_APM"' EXIT
|
|
||||||
if bash "$SCRIPT" "$NO_APM" > /dev/null 2>&1 && bash "$SCRIPT" --check "$NO_APM" > /dev/null 2>&1; then
|
if bash "$SCRIPT" "$NO_APM" > /dev/null 2>&1 && bash "$SCRIPT" --check "$NO_APM" > /dev/null 2>&1; then
|
||||||
pass "a plugin dir with no .apm/ exits 0 in both real and --check mode"
|
pass "a plugin dir with no .apm/ exits 0 in both real and --check mode"
|
||||||
else
|
else
|
||||||
fail "a plugin dir with no .apm/ should exit 0 (skip), not fail"
|
fail "a plugin dir with no .apm/ should exit 0 (skip), not fail"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# --- 7. A plugin dir that doesn't exist at all is a hard failure, not a skip ---
|
||||||
|
echo ""
|
||||||
|
echo "--- a plugin dir that does not exist fails, distinct from an existing-but-empty one ---"
|
||||||
|
MISSING_ROOT="$(mktemp -d)"; track "$MISSING_ROOT"
|
||||||
|
MISSING="$MISSING_ROOT/does-not-exist"
|
||||||
|
if bash "$SCRIPT" "$MISSING" > /dev/null 2>&1; then
|
||||||
|
fail "exited 0 for a plugin dir that does not exist — expected a hard failure"
|
||||||
|
else
|
||||||
|
pass "a nonexistent plugin dir fails instead of silently skipping"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- 8. --check never mutates the real plugin root, even on first-time manifest creation ---
|
||||||
|
echo ""
|
||||||
|
echo "--- --check does not create .claude-plugin/plugin.json or .github/plugin/plugin.json ---"
|
||||||
|
FIXTURE8="$(make_fixture)"; track "$FIXTURE8"
|
||||||
|
bash "$SCRIPT" --check "$FIXTURE8" > /dev/null 2>&1 || true
|
||||||
|
if [[ ! -e "$FIXTURE8/.claude-plugin/plugin.json" ]] && [[ ! -e "$FIXTURE8/.github/plugin/plugin.json" ]]; then
|
||||||
|
pass "--check leaves the real plugin root without a first-write plugin.json"
|
||||||
|
else
|
||||||
|
fail "--check created plugin.json in the real plugin root — it must never mutate it"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- 9. A duplicate plugin-dir basename among arguments fails fast, not silently ---
|
||||||
|
echo ""
|
||||||
|
echo "--- duplicate plugin dir basenames among arguments are rejected ---"
|
||||||
|
DUP_PARENT_A="$(mktemp -d)"; track "$DUP_PARENT_A"
|
||||||
|
DUP_PARENT_B="$(mktemp -d)"; track "$DUP_PARENT_B"
|
||||||
|
mkdir -p "$DUP_PARENT_A/dup" "$DUP_PARENT_B/dup"
|
||||||
|
if bash "$SCRIPT" "$DUP_PARENT_A/dup" "$DUP_PARENT_B/dup" > /dev/null 2>&1; then
|
||||||
|
fail "exited 0 with two plugin-dir arguments sharing a basename — expected a collision error"
|
||||||
|
else
|
||||||
|
pass "rejects two plugin-dir arguments that share a basename"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- 10. Real sync re-injects mcpServers that apm's Copilot builder strips ---
|
||||||
|
echo ""
|
||||||
|
echo "--- real sync re-injects mcpServers into .github/plugin/plugin.json ---"
|
||||||
|
FIXTURE10="$(make_fixture_with_mcp '{"mcpServers":{"demo":{"command":"demo-server","type":"stdio"}}}')"; track "$FIXTURE10"
|
||||||
|
bash "$SCRIPT" "$FIXTURE10" > /dev/null 2>&1
|
||||||
|
if jq -e '.mcpServers.demo.command == "demo-server"' "$FIXTURE10/.github/plugin/plugin.json" > /dev/null 2>&1; then
|
||||||
|
pass "mcpServers from .mcp.json is present in .github/plugin/plugin.json after a real sync"
|
||||||
|
else
|
||||||
|
fail "mcpServers was not re-injected into .github/plugin/plugin.json"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- 11. An empty .mcp.json does not add a redundant mcpServers: {} ---
|
||||||
|
echo ""
|
||||||
|
echo "--- an empty .mcp.json does not add mcpServers: {} ---"
|
||||||
|
FIXTURE11="$(make_fixture_with_mcp '{"mcpServers":{}}')"; track "$FIXTURE11"
|
||||||
|
bash "$SCRIPT" "$FIXTURE11" > /dev/null 2>&1
|
||||||
|
if jq -e 'has("mcpServers") | not' "$FIXTURE11/.github/plugin/plugin.json" > /dev/null 2>&1; then
|
||||||
|
pass "an empty .mcp.json does not add mcpServers to .github/plugin/plugin.json"
|
||||||
|
else
|
||||||
|
fail "an empty .mcp.json still added mcpServers -- should match apm's own omit-when-empty convention"
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Results: $PASS passed, $FAIL failed"
|
echo "Results: $PASS passed, $FAIL failed"
|
||||||
[[ $FAIL -eq 0 ]]
|
[[ $FAIL -eq 0 ]]
|
||||||
|
|||||||
Reference in New Issue
Block a user