Draft: feat(agent): mount endpoint-agent-platform as glab agent
What
Mounts the endpoint-agent-platform command tree under a new top-level agent verb by importing it as a Go module. glab gains real-time security interception for AI coding agents — without shipping a second binary.
New commands:
glab agent install claude— register Claude Code hooksglab agent hook claude-code— the hook entrypoint (PreToolUse can deny in real time)glab agent verify claude— tamper detectionglab agent uninstall claude— clean removal
How
The platform exposes its command tree as an importable package. glab mounts it with two lines in internal/commands/root.go:
import agentcli "gitlab.com/gitlab-org/security-products/endpoint-agent-platform/cli"
...
rootCmd.AddCommand(agentcli.NewCommand(agentcli.Options{Use: "agent"}))The imported tree cannot set glab's MCP annotations itself, so the mount also stamps the whole subtree with the MCP Exclude annotation (same approach as duo), which keeps it out of the MCP tool catalog and satisfies glab's annotation-coverage check.
Tests
The agent subtree is not glab code — it is the imported module. glab's tests therefore prove the mount and routing, not the module internals (those are covered upstream in endpoint-agent-platform's own mock labs). See internal/commands/agent_mount_test.go:
TestAgentSubtreeIsMounted—agentand every module-owned subcommand (version,install,uninstall,hook,verify,evaluate,auth) are registered; the commandShortcomes from the module.TestAgentVersionIsHandledByModule—glab agent version --jsonis driven through the real root command and emits the module's ownversionResultJSON ({"version":"dev"}), which only the module'sRunEcan produce. This proves the call routes into and is handled by the standalone module.TestAgentVersionHumanOutput— the non-JSON path prints the module's bare version string.
agent version is the probe because it is deterministic and side-effect-free. Verified by controlled revert: commenting out the mount makes all three fail with unknown command "agent".
Binary size: ~0.8 MB
The platform makes analyzers opt-in per host, so glab links only the command tree, collector, and reporter — not the secret-detection analyzer and its embedded model.
Measured linux/amd64, stripped (-s -w), isolated builds of origin/main vs this branch:
| Build | Size |
|---|---|
glab main |
46.9 MB |
glab + agent (this MR) |
47.8 MB (+0.84 MB) |
(Mounting with all analyzers would have been ~+20 MB; opt-in avoids that.)
Relationship to glab govern
glab agent is intended to replace glab govern in the long term. govern does audit (records sessions, post-hoc: Stop/SessionEnd); agent adds real-time enforcement (blocks tool calls: PreToolUse deny) and will absorb the audit role as it matures.
Both ship for now because agent is an experiment. They coexist safely in the meantime: both write to ~/.claude/settings.json, and our uninstall removes only our hooks and leaves govern's intact.
Status: DRAFT — proof of concept
Open design decisions for the team before merge:
- D1 — module-import (this MR) vs
binarymgrexternal binary (#627904). - D2 — namespace: top-level
glab agent(here) vs underglab govern. - Q3 — is real-time enforcement (PreToolUse deny) in product scope for glab yet, or audit-only?
Depends on endpoint-agent-platform@v0.0.8. CI fetches the (private) security-products module with the job token: the goreleaser container (build_test / release) gets a .netrc + GOPRIVATE so go mod vendor can authenticate, and the release drops the go mod tidy before-hook (it pulled a dependency's private test-only module, secret-detection/scanner.git, which glab never builds). The platform project allows gitlab-org/cli in its CI_JOB_TOKEN inbound allowlist.
cc the glab CLI team (group::code review) — your repo, your call on namespace + scope.