-
Notifications
You must be signed in to change notification settings - Fork 12k
feat(docker-agent): add Docker Agent integration #4302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c500dd6
feat(docker-agent): add Docker Agent integration
nervgh 0a13ed0
feat(docker-agent): address Copilot's feedback
nervgh 444fd2b
fix(docker-agent): pass prompts after agent configuration
nervgh 3409a06
fix(utils): detect Docker Agent CLI plugin
nervgh d5d93b1
fix(docker-agent): validate plugin availability and agent config
nervgh b27d500
Apply suggestions from code review
nervgh 6c3a889
fix(docker-agent): delimit prompts from CLI flags
nervgh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| """Docker Agent integration — skills-based Docker CLI agent. | ||
|
|
||
| Docker Agent discovers project skills from ``.docker-agent/skills``. Runtime | ||
| configuration is owned by Docker Agent and is not managed by Spec Kit. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import shutil | ||
|
|
||
| from ..base import SkillsIntegration | ||
|
|
||
|
|
||
| class DockerAgentIntegration(SkillsIntegration): | ||
|
mnriem marked this conversation as resolved.
|
||
| """Integration for Docker Agent.""" | ||
|
|
||
| key = "docker-agent" | ||
| config = { | ||
| "name": "Docker Agent", | ||
| "folder": ".docker-agent/", | ||
| "commands_subdir": "skills", | ||
|
nervgh marked this conversation as resolved.
Outdated
|
||
| "install_url": "https://docs.docker.com/ai/docker-agent/getting-started/installation/", | ||
| "requires_cli": True, | ||
|
nervgh marked this conversation as resolved.
|
||
| } | ||
| registrar_config = { | ||
| "dir": ".docker-agent/skills", | ||
|
nervgh marked this conversation as resolved.
Outdated
|
||
| "format": "markdown", | ||
| "args": "$ARGUMENTS", | ||
| "extension": "/SKILL.md", | ||
| } | ||
| multi_install_safe = True | ||
|
|
||
| # Docker Agent hook names are lowercase snake_case and are configured in | ||
| # the agent team's YAML under ``agents.<name>.hooks``. | ||
| CANONICAL_TO_NATIVE = { | ||
| "session_start": "session_start", | ||
| "pre_tool_use": "pre_tool_use", | ||
| "post_tool_use": "post_tool_use", | ||
| "session_end": "session_end", | ||
|
nervgh marked this conversation as resolved.
Outdated
|
||
| "user_prompt_submit": "user_prompt_submit", | ||
| "stop": "stop", | ||
| } | ||
|
|
||
|
|
||
| @staticmethod | ||
| def _agent_command() -> list[str]: | ||
| """Return the available Docker Agent command form.""" | ||
| if shutil.which("docker-agent"): | ||
| return ["docker-agent", "run"] | ||
| return ["docker", "agent", "run"] | ||
|
nervgh marked this conversation as resolved.
Outdated
nervgh marked this conversation as resolved.
Outdated
|
||
|
|
||
| def build_exec_args( | ||
| self, | ||
| prompt: str, | ||
| *, | ||
| model: str | None = None, | ||
| output_json: bool = True, | ||
| ) -> list[str] | None: | ||
| """Build a headless Docker Agent invocation for workflow dispatch.""" | ||
| args = [*self._agent_command(), "--exec"] | ||
|
nervgh marked this conversation as resolved.
nervgh marked this conversation as resolved.
Copilot marked this conversation as resolved.
|
||
| if output_json: | ||
| args.append("--json") | ||
| self._apply_extra_args_env_var(args) | ||
| if model: | ||
| args.extend(["--model", model]) | ||
| args.append(prompt) | ||
|
nervgh marked this conversation as resolved.
Outdated
|
||
| return args | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| """Tests for the Docker Agent integration.""" | ||
|
|
||
|
|
||
| from specify_cli.integrations import get_integration | ||
| from specify_cli.integrations.base import SkillsIntegration | ||
| from specify_cli.integrations.docker_agent import DockerAgentIntegration | ||
|
|
||
|
|
||
| def test_registered_metadata(): | ||
|
nervgh marked this conversation as resolved.
Outdated
|
||
| integration = get_integration("docker-agent") | ||
|
|
||
| assert isinstance(integration, DockerAgentIntegration) | ||
| assert isinstance(integration, SkillsIntegration) | ||
| assert integration.config["name"] == "Docker Agent" | ||
| assert integration.config["folder"] == ".docker-agent/" | ||
| assert integration.config["commands_subdir"] == "skills" | ||
| assert integration.config["requires_cli"] is True | ||
| assert integration.registrar_config["dir"] == ".docker-agent/skills" | ||
|
nervgh marked this conversation as resolved.
Outdated
|
||
| assert integration.registrar_config["format"] == "markdown" | ||
| assert integration.registrar_config["args"] == "$ARGUMENTS" | ||
| assert integration.registrar_config["extension"] == "/SKILL.md" | ||
| assert integration.multi_install_safe is True | ||
| assert integration.CANONICAL_TO_NATIVE == { | ||
| "session_start": "session_start", | ||
| "pre_tool_use": "pre_tool_use", | ||
| "post_tool_use": "post_tool_use", | ||
| "session_end": "session_end", | ||
|
nervgh marked this conversation as resolved.
Outdated
|
||
| "user_prompt_submit": "user_prompt_submit", | ||
| "stop": "stop", | ||
| } | ||
|
|
||
|
|
||
| def test_build_exec_args_without_config(monkeypatch): | ||
| monkeypatch.setattr("shutil.which", lambda name: None) | ||
|
|
||
| args = DockerAgentIntegration().build_exec_args("/speckit-specify build an API") | ||
|
nervgh marked this conversation as resolved.
Outdated
|
||
|
|
||
| assert args == [ | ||
| "docker", | ||
| "agent", | ||
| "run", | ||
| "--exec", | ||
| "--json", | ||
| "/speckit-specify build an API", | ||
| ] | ||
|
|
||
|
|
||
| def test_uses_standalone_executable(monkeypatch): | ||
| monkeypatch.setattr( | ||
| "shutil.which", | ||
| lambda name: "/usr/bin/docker-agent" if name == "docker-agent" else None, | ||
| ) | ||
|
|
||
| args = DockerAgentIntegration().build_exec_args("prompt", output_json=False) | ||
|
|
||
| assert args[:4] == ["docker-agent", "run", "--exec", "prompt"] | ||
|
|
||
|
|
||
| def test_standalone_executable_has_priority(monkeypatch): | ||
| monkeypatch.setattr("shutil.which", lambda name: "/usr/bin/docker-agent") | ||
|
|
||
| args = DockerAgentIntegration().build_exec_args("prompt", output_json=False) | ||
|
|
||
| assert args[:3] == ["docker-agent", "run", "--exec"] | ||
|
|
||
|
|
||
| def test_extra_args_can_supply_agent_config(monkeypatch): | ||
| monkeypatch.setattr("shutil.which", lambda name: None) | ||
| monkeypatch.setenv( | ||
| "SPECKIT_INTEGRATION_DOCKER_AGENT_EXTRA_ARGS", "./agent.yaml" | ||
| ) | ||
|
|
||
| args = DockerAgentIntegration().build_exec_args("prompt", output_json=False) | ||
|
|
||
| assert args == [ | ||
| "docker", | ||
| "agent", | ||
| "run", | ||
| "--exec", | ||
| "./agent.yaml", | ||
| "prompt", | ||
| ] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.