Skip to content

feat(runtime): register AGENTS commands as policy-gated runtime actions#3

Merged
dubscode merged 2 commits intomainfrom
feat/agents-runtime-actions
Mar 4, 2026
Merged

feat(runtime): register AGENTS commands as policy-gated runtime actions#3
dubscode merged 2 commits intomainfrom
feat/agents-runtime-actions

Conversation

@dubscode
Copy link
Contributor

@dubscode dubscode commented Mar 3, 2026

Summary

  • Register AGENTS.md commands as runtime-invokable tools (agents:<name>, plus unprefixed alias when non-conflicting).
  • Add deterministic duplicate-command handling (first definition wins + warning).
  • Route AGENTS commands through existing command execution with pre-execution policy evaluation.
  • Enforce approval-required behavior for mutating commands and preserve automation write allowlist semantics.
  • Emit structured execution metadata in runtime traces/transcripts (actionName, resolvedCommand, policyOutcome, executionSummary).
  • Archive and sync OpenSpec change agents-md-runtime-actions into main specs.

Behavior Details

  • Unknown AGENTS command references now return deterministic not-found tool results with no shell execution.
  • Policy-denied and approval-required outcomes return structured denial payloads before execution.
  • Successful AGENTS command executions include structured policy + execution summaries.

Tests and Verification

  • pnpm test
  • pnpm typecheck
  • pnpm lint

Docs

  • Added docs/agents-runtime-actions.md.
  • Synced spec at openspec/specs/agents-runtime-actions/spec.md.

🥞 DubStack

Add AGENTS command registration, deterministic duplicate handling,
policy-gated execution/approval flow, structured observability payloads,
tests, docs, and archive synced OpenSpec change.
Copilot AI review requested due to automatic review settings March 3, 2026 13:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR wires AGENTS.md command entries into the runtime tool surface so they can be invoked as agents:<name> (optionally also as an unprefixed alias), and routes their execution through policy/approval with structured observability payloads.

Changes:

  • Load AGENTS.md at runtime, detect duplicate command names with deterministic warnings, and register commands as runtime tools.
  • Add policy-gated execution for exec-command and AGENTS commands, returning structured policyOutcome/executionSummary payloads.
  • Extend interactive chat UX and observability (traces + transcripts) to record structured tool execution metadata.

Reviewed changes

Copilot reviewed 13 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/tool-registry.test.ts Adds coverage for AGENTS tool registration, not-found behavior, and policy outcomes.
tests/agents-loader.test.ts Extends loader tests to assert warnings and deterministic duplicate handling.
src/tools/registry.ts Registers AGENTS commands as tools/aliases; adds policy evaluation + approval gate to command execution.
src/tools/exec-command.ts Adds side-effect classification helpers; propagates toolName into results.
src/observability/transcripts.ts Adds optional structured payload to transcript entries.
src/config/agents-loader.ts Adds warnings to config and emits deterministic duplicate-command warnings.
src/cli/runtime.ts Loads AGENTS config and passes it into ToolRegistry with warning logging.
src/cli/commands/chat.tsx Plumbs transcripts into the chat UI.
src/cli/app.tsx Updates interactive execution flow to use policy outcomes and writes structured trace/transcript payloads.
openspec/specs/agents-runtime-actions/spec.md Adds a spec for AGENTS runtime actions behavior.
openspec/changes/archive/** Archives the spec-driven change artifacts (tasks/spec/proposal/design).
openspec/changes/agents-md-runtime-actions/tasks.md Removes the unarchived tasks file.
docs/agents-runtime-actions.md Documents registration, resolution rules, and policy/observability behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- infer and conservatively rank side effects for exec-command policy checks

- pass invocation cwd into policy evaluation for exec and AGENTS commands

- make write-path test hermetic and complete runtime actions spec purpose
@dubscode dubscode merged commit 9316628 into main Mar 4, 2026
@dubscode dubscode deleted the feat/agents-runtime-actions branch March 4, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants