Skip to content

feat(cli): dirctl init to install directory Agent Skill and MCP server#1787

Open
akijakya wants to merge 3 commits into
mainfrom
feat/init-install-dir-skill-mcp
Open

feat(cli): dirctl init to install directory Agent Skill and MCP server#1787
akijakya wants to merge 3 commits into
mainfrom
feat/init-install-dir-skill-mcp

Conversation

@akijakya

@akijakya akijakya commented Jul 10, 2026

Copy link
Copy Markdown
Member

Closes #1705

Summary

Adds a "Directory MCP server & skills" step to the existing dirctl init onboarding wizard, filling the slot it previously reserved as "MCP server & skills — coming soon." The step installs the built-in DIR MCP server entry and DIR Agent Skill into the user's detected AI coding agents, and dirctl init --remove tears them down symmetrically.

What it does

On dirctl init, after the client-context and OASF-extractor steps, the wizard detects installed AI coding agents and asks — with two independent, interactive checkbox prompts (skill first, then MCP server) — which agents each artifact should go into. All detected agents are selected by default; the two selections are independent.

Install the DIR skill into:  (↑/↓ move · space toggles · enter confirms · q skips)
> [x] Claude Code
  [x] Cursor
  [ ] VS Code
  • ↑/↓ (or j/k) move, space toggles, enter confirms, q/esc skips that artifact.
  • Non-interactive: with --yes, installs both into every detected agent; without --yes on a non-TTY, it skips rather than acting unattended.
  • --agents narrows the candidate pool; the step is skippable and idempotent, and --remove uninstalls what it added.

Implementation notes

  • No Directory round-trip. The DIR record is built locally via skill.BuildRecord (from server/skill, which embeds SKILL.md as the single source of truth), then its artifacts are derived — skill body from the embedded SKILL.md, MCP entry from the server/skill definition (dirctl mcp serve, stdio). The MCP server is keyed by the OASF translator's normalized name (agntcy-dir).
  • Shared placement engine, no duplication. The record→artifacts→placement logic is lifted out of dirctl install into a new internal package cli/internal/agentinstall (Artifacts, DeriveArtifacts, Install, Uninstall), so init and install share the same derive + apply code and the same per-agent path/codec/managed-block/atomic-write engine (cli/internal/agentcfg). install behavior is unchanged.
    • agentinstall.Artifacts.SkillOnly() / MCPOnly() filters let init place the skill and MCP server independently (one per prompt).
  • Shared --agents parsing moved into cli/internal/agentcfg (AllAgents, AgentIDs, ParseSelection), reused by both commands.
  • Interactive selector is dependency-free. The checkbox UI uses raw terminal mode via golang.org/x/term (already a CLI dependency) — no new TUI library. Key decoding (decodeKey) and list state (selectState) are pure functions; the selector is injected into the step so the logic is unit-tested without a TTY.
  • Idempotency and atomic writes are delegated to agentcfg (re-running only adds/updates what is missing).

Tests

  • agentinstall / agentcfg: derive + apply and ParseSelection unit tests.
  • init: installAgents covered for no-agents-detected (skip), non-interactive-without---yes (skip, writes nothing), --yes (installs both), interactive per-artifact independence (skill vs. MCP selected separately), and --remove (entry proven present-before / absent-after). Plus decodeKey (arrows, j/k, space, enter, ctrl-c, q) and selectState (cursor clamp + toggle).
  • task lint:go = 0 issues across all modules; task test:unit passes.

@akijakya akijakya self-assigned this Jul 10, 2026
@akijakya akijakya requested a review from a team as a code owner July 10, 2026 21:25
@github-actions github-actions Bot added the size/M Denotes a PR that changes 200-999 lines label Jul 10, 2026
@akijakya akijakya requested a review from Copilot July 10, 2026 21:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Step 3 to dirctl init to install (and --remove to uninstall) the built-in Directory Agent Skill and Directory MCP server entry into detected AI coding agents, reusing shared placement logic and enabling per-artifact agent selection.

Changes:

  • Introduces cli/internal/agentinstall as a shared “derive artifacts + install/uninstall” engine used by both dirctl install and dirctl init.
  • Adds cli/internal/agentcfg.ParseSelection / AgentIDs to centralize --agents parsing and flag help/validation.
  • Implements dirctl init Step 3 with an interactive, dependency-free checkbox selector (skill selection and MCP selection handled independently), plus unit tests.

Reviewed changes

Copilot reviewed 18 out of 23 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cli/internal/agentinstall/testdata/skill.json Adds skill-only OASF record fixture for derive/apply tests.
cli/internal/agentinstall/testdata/multi.json Adds combined skill+MCP OASF record fixture for derive/apply tests.
cli/internal/agentinstall/testdata/mcp.json Adds MCP-only OASF record fixture for derive/apply tests.
cli/internal/agentinstall/testdata/bare.json Adds empty-modules fixture to validate “no installable module” errors.
cli/internal/agentinstall/testdata/a2a.json Adds A2A-only fixture to validate “cannot install into agent configs” errors.
cli/internal/agentinstall/filter.go Adds Artifacts.SkillOnly() / MCPOnly() to support independent placement flows (init prompts).
cli/internal/agentinstall/derive.go Renames/exports Artifacts + DeriveArtifacts under new agentinstall package.
cli/internal/agentinstall/derive_test.go Updates tests to agentinstall package and exported DeriveArtifacts.
cli/internal/agentinstall/apply.go Exports Install / Uninstall entrypoints for reuse across commands.
cli/internal/agentinstall/apply_test.go Updates apply tests to use exported Artifacts + Install/Uninstall.
cli/internal/agentcfg/selection.go Centralizes --agents sentinel (all) and selection parsing/validation.
cli/internal/agentcfg/selection_test.go Adds unit tests for ParseSelection and AgentIDs.
cli/cmd/install/uninstall.go Switches uninstall command to use agentinstall.Uninstall.
cli/cmd/install/install.go Switches install command to use agentinstall.DeriveArtifacts + agentinstall.Install and shared agent selection parsing.
cli/cmd/install/flags.go Updates --agents flag help/defaults to use agentcfg.AllAgents and agentcfg.AgentIDs().
cli/cmd/install/flags_test.go Removes now-obsolete tests for in-command --agents parsing (moved to agentcfg).
cli/cmd/install/batch.go Switches batch install/uninstall to use agentinstall engine and artifact type.
cli/cmd/install/batch_test.go Updates batch tests to use agentinstall.DeriveArtifacts and inline bare record.
cli/cmd/init/select.go Adds raw-terminal checkbox selector UI (decodeKey, render loop) for interactive agent picking.
cli/cmd/init/run.go Adds Step 3 into wizard flow and hooks --remove to also uninstall from agents.
cli/cmd/init/options.go Adds --agents flag to scope which agents are eligible in the Step 3 wizard.
cli/cmd/init/agents.go Implements Step 3 logic (derive built-in DIR artifacts, prompt independently, install/uninstall).
cli/cmd/init/agents_test.go Adds unit tests covering Step 3 install/remove and selector state/key decoding.

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

Comment thread cli/cmd/init/select.go Outdated
Comment thread cli/cmd/init/agents.go Outdated
akijakya added 3 commits July 11, 2026 00:21
Signed-off-by: András Jáky <ajaky@cisco.com>
Signed-off-by: András Jáky <ajaky@cisco.com>
@akijakya akijakya force-pushed the feat/init-install-dir-skill-mcp branch from 37d7f63 to 2ebc4d9 Compare July 10, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 200-999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli): dirctl init — add the "Directory MCP server & skills" step to the onboarding wizard

2 participants