You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(compile): explicit apm compile -g + install-time hint for global root context (#1632)
* feat(compile): add explicit global compile hint
Rebuilds PR #1632 on current main after the original branch could not be rebased due to historical add/add conflicts, preserving the user-visible apm compile -g behavior and the install-time read-only hint for issue #1485.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(compile): fold global compile review follow-ups
Tightens the explicit global compile surface after panel review: dry-run output now uses info styling, --global rejects every explicitly supplied project-output flag via an allowlist, user root context writes scan generated content before writing, and marker ownership is anchored to the file header so quoted markers cannot clobber hand-authored files.
Also updates security/install docs and adds regression traps for hand-authored root context preservation. Addresses panel follow-ups from cli-logging, DevX UX, supply-chain security, doc-writer, and test coverage.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(compile): align global flag diagnostics
Allows --verbose with the explicit global compile path, routes the handler through CommandLogger when called from the CLI, and keeps the security documentation precise about compile -g scan reporting.
Addresses final panel follow-ups from CLI logging, DevX UX, and doc-writer.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: tighten global compile safeguards
Block critical hidden-character output in the new global compile path before writing root context files, reduce default output noise, and keep install hints scoped to verified root-context targets. Adds regression coverage for the security, dry-run, missing apm_modules, and logger-routing contracts raised by the shepherd panel.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: fold compile global review follow-ups
Route global compile output through CommandLogger, clarify the install hint and help text, and enumerate user-scope root context outputs in docs. Addresses shepherd-driver panel follow-ups for PR #1632.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* docs: clarify global compile target matrix
Document user-scope root context outputs in the target matrix so the global compile guide does not drift from reference docs. Addresses final panel doc-writer follow-up.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: danielmeppiel <danielmeppiel@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -154,6 +154,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
154
154
-`apm lock export --format cyclonedx|spdx` emits a standard SBOM inventory of installed packages, and a new declared-license recorder stores each package's manifest-declared license (`apm.yml``license:` / `plugin.json`) in the lockfile after offline SPDX-id validation. APM records what a package declares -- it does not scan LICENSE text or gate installs on a license. (closes #1777) (#1820)
155
155
-`apm install` / `apm pack` can now deploy an experimental Copilot-only `canvas` primitive: a package declaring `.apm/extensions/<name>/` ships verbatim to `.github/extensions/<name>/` (or `~/.copilot/extensions/<name>/` with `--global`), where Copilot CLI discovers it in-session. The surface is gated twice -- `apm experimental enable canvas` plus `--trust-canvas-extensions` for dependency-provided canvases -- and is fail-closed when the flag is off. (#1689)
156
156
-`apm install` now blocks dependency-provided executables (hooks and `bin/`) by default, mirroring npm v12's default-deny model. A dependency's hooks or binaries deploy only after explicit approval in an `allowExecutables` block of `apm.yml`, managed via `apm approve` / `apm deny`; root-authored content and text-only primitives are unaffected. (#1723)
157
+
-`apm compile --global` / `-g` compiles user-scope root context files such as
158
+
`~/.claude/CLAUDE.md`, `~/.codex/AGENTS.md`, and `~/.gemini/GEMINI.md` from
- **`apm compile`** scans compiled output (AGENTS.md, CLAUDE.md, `.github/copilot-instructions.md`, commands) before writing to disk. Critical findings cause `apm compile` to exit with code 1 after writing — defense-in-depth since source files were already scanned at install, but compilation assembles content from multiple sources. `.github/copilot-instructions.md` is assembled from global instructions in `.apm/instructions/`, including those installed under `apm_modules/`.
globally installed instructions before writing them. Critical findings stop
141
+
the write and exit with code 1. Existing hand-authored root context files are
142
+
skipped unless they carry APM's generated marker, so opting into global
143
+
compilation does not clobber user-managed `CLAUDE.md`, `AGENTS.md`, or
144
+
`GEMINI.md`files.
139
145
- **`apm pack`** scans files before bundling. This catches hidden characters before a package is published, preventing authors from accidentally distributing tainted content.
140
146
- **`apm unpack`** scans bundle contents before deployment. This is a pre-deployment gate matching `apm install` — critical findings block deployment unless `--force` is used. (Note: `apm unpack` is DEPRECATED; prefer `apm install <bundle-path>` for new pipelines -- it applies the same scan plus lockfile integration. See [Pack and distribute](../producer/pack-a-bundle/).)
Copy file name to clipboardExpand all lines: docs/src/content/docs/reference/cli/compile.md
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,6 +109,25 @@ The dry-run output shows `[dry-run] would remove stale CLAUDE.md -- instructions
109
109
|`--dry-run`| Show placement decisions without writing files. |
110
110
|`-v, --verbose`| Show source attribution and optimizer analysis. |
111
111
112
+
### Global compilation
113
+
114
+
Global compilation keeps supported user-scope root-context targets in sync with
115
+
globally installed instruction packages -- one command, no per-tool setup.
116
+
117
+
| Flag | Description |
118
+
|------|-------------|
119
+
|`-g, --global`| Compile user-scope root context files from `~/.apm/apm_modules`. Reads globally installed packages and writes one root context file per supported user-scope target (e.g. `~/.claude/CLAUDE.md`, `~/.codex/AGENTS.md`). Not valid with project-output flags such as `--target`, `--all`, `--watch`, `--root`, or `--output`. Exits non-zero if `~/.apm/apm_modules` does not exist. |
120
+
121
+
`apm compile --global` is explicit. `apm install -g` does not run it; instead,
122
+
when global instructions land on a root-context-only target, install prints a
123
+
one-line hint pointing at `apm compile -g`. Run it manually after adding or
124
+
removing global packages. Hand-authored files (files that do not carry the
Copy file name to clipboardExpand all lines: docs/src/content/docs/reference/cli/install.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,6 +103,7 @@ Transport env vars: `APM_GIT_PROTOCOL` (`ssh` or `https`) sets the default initi
103
103
-**No-op nudge.** When the lockfile is already satisfied and nothing needs deploying, install prints `[i] Run 'apm update' to check for newer versions.` so you know the silent success was not a missed refresh.
104
104
-**Frozen mode.** With `--frozen`, install resolves only what is in `apm.lock.yaml`. A direct dependency missing from the lockfile, or a missing lockfile entirely, exits `1`. Orphan lockfile entries (locked but no longer in `apm.yml`) are tolerated; local-path deps are skipped. This is a structural check, not a content check -- run `apm audit --ci` for hash verification.
105
105
-**Local `.apm/` deployment.** After dependencies are integrated, primitives in the project's own `.apm/` directory are deployed to the same targets. Local files win on collision. Skipped at `--global` and with `--only mcp`.
106
+
-**User-scope root context hint.** Compilation stays explicit. After `apm install -g`, targets with native user-scope instruction files pick up global instructions during install. Targets whose user-scope instruction surface is a root context file require [`apm compile --global`](../compile/#global-compilation); install prints a one-line `[i]` hint and writes no root context file.
106
107
-**Stale-file cleanup.** Files a still-present package previously deployed but no longer produces are removed from the workspace, gated by per-file content hashes recorded in the lockfile (user-edited files are kept with a warning).
107
108
-**Enterprise marketplace gate.** When installing from a `*.ghe.com` marketplace, bare cross-repo `repo:` fields (e.g. `repo: owner/repo`) are refused before any network request runs, preventing dependency-confusion attacks. Host-qualify the field to proceed: `repo: corp.ghe.com/owner/repo` for an enterprise dep, or `repo: github.com/owner/repo` for a declared cross-host dep.
108
109
-**Security scan.** Source files are scanned for hidden Unicode and other tag-character / bidi-override patterns before deployment. Critical findings block the package; the install exits `1`. Use `--force` to deploy anyway, or run `apm audit --strip` first to remediate.
-**User scope.** Partial. `prompts` deploy under `~/.copilot/prompts/`; `instructions` from all packages are concatenated into `~/.copilot/copilot-instructions.md` (Copilot CLI reads only that single file at user scope). User-scope deploys land under `~/.copilot/`, not `~/.github/`.
93
+
-**Global compile.**`apm compile -g` can also render global instructions to
94
+
`~/.copilot/AGENTS.md` for root-context readers that honor `AGENTS.md`.
93
95
94
96
## claude
95
97
@@ -120,6 +122,9 @@ Cursor.
120
122
- skills: `.agents/skills/<name>/SKILL.md`
121
123
- hooks: `.cursor/hooks.json`
122
124
-**User scope.** Partial. `instructions` is excluded at user scope; Cursor reads global rules from its Settings UI rather than from disk.
125
+
-**Global compile.**`apm compile -g` can render global instructions to
126
+
`~/.cursor/AGENTS.md` for root-context readers that honor `AGENTS.md`; Cursor
127
+
global rules still use the Settings UI.
123
128
-**Caveat.** Command files use the shared `claude_command` transformer today; Cursor-specific frontmatter keys (`author`, `mcp`, `parameters`, ...) are dropped at install time and surfaced via diagnostics.
124
129
125
130
## codex
@@ -174,6 +179,8 @@ OpenCode.
174
179
- commands: `.opencode/commands/<name>.md`
175
180
- skills: `.agents/skills/<name>/SKILL.md`
176
181
-**Caveat.** OpenCode has no hooks concept; the `hooks` primitive is silently skipped for this target.
182
+
-**Global compile.**`apm compile -g` writes
183
+
`~/.config/opencode/AGENTS.md` from global instructions.
Copy file name to clipboardExpand all lines: packages/apm-guide/.apm/skills/apm-usage/commands.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ If no `--target`, no `targets:` in `apm.yml`, and no harness signal is present,
55
55
56
56
| Command | Purpose | Key flags |
57
57
|---------|---------|-----------|
58
-
|`apm compile`| Compile agent context |`-o` output, `-t` target (comma-separated; resolution chain `--target` > apm.yml `targets:` > auto-detect), `--all` compile for every canonical target (preferred over deprecated `--target all`), `--chatmode`, `--dry-run`, `--no-links`, `--watch`, `--validate`, `--single-agents`, `-v` verbose, `--local-only`, `--clean`, `--with-constitution/--no-constitution`, `--no-dedup` / `--force-instructions` (opt out of Claude/Copilot deduplication), `--root DIR` redirect generated artifacts under DIR while sources resolve from `$PWD` (mirrors `pip install --target`; not valid with `--watch`) |
58
+
|`apm compile`| Compile agent context |`-o` output, `-t` target (comma-separated; resolution chain `--target` > apm.yml `targets:` > auto-detect), `--all` compile for every canonical target (preferred over deprecated `--target all`), `-g`/`--global` (read global instructions from `~/.apm/apm_modules/`, write user-scope root files; cannot combine with project-output flags such as `--target`, `--all`, `--watch`, `--root`, or `--output`; critical hidden-character findings stop the write and exit 1), `--chatmode`, `--dry-run`, `--no-links`, `--watch`, `--validate`, `--single-agents`, `-v` verbose, `--local-only`, `--clean`, `--with-constitution/--no-constitution`, `--no-dedup` / `--force-instructions` (opt out of Claude/Copilot deduplication), `--root DIR` redirect generated artifacts under DIR while sources resolve from `$PWD` (mirrors `pip install --target`; not valid with `--watch`) |
59
59
60
60
`apm compile --watch` live-reloads `apm.yml`: editing `target:` / `targets:` mid-session takes effect on the next file event without restarting the watcher. The CLI `--target` flag, when passed to `apm compile --watch`, still outranks `apm.yml`. Re-resolution is gated on the changed file's basename being `apm.yml`, so `.instructions.md` edits do not pay an extra resolver round-trip and a stray `backup_apm.yml` cannot trigger a reload. `--clean` is ignored in watch mode and the watcher prints an explicit `[!]` warning at startup (`--clean is ignored in watch mode; run 'apm compile --clean' separately to remove orphaned outputs.`); run `apm compile --clean` separately between watch sessions to remove orphans.
0 commit comments