entireio / entireio/cli

`entire agent add/list` does not discover external agents

Open Beginner friendly
#1,928 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
5.1k
Forks
475
Avg merge
1d 11h
Merged PRs (30d)
178

Description

What happened?

Description

The entire agent add <agent>, entire agent remove <agent>, and entire agent list commands omit external agents (like zed), failing with Unknown agent. However, the exact same external agent works perfectly through entire enable --agent <agent> and the various git hook invocations.

Root Cause

In entireio-cli/cmd/entire/cli/agent_group.go, the agent subcommand group (introduced in commit c4109895) does not invoke external.DiscoverAndRegister(ctx) or external.DiscoverAndRegisterAlways(ctx) prior to listing or retrieving agents.

By examining the CLI source codebase, we can see that discovery correctly occurs in most places where agents are retrieved. For instance:

  • entire enable: calls external.DiscoverAndRegisterAlways(ctx) in setup.go.
  • entire hooks ...: calls external.DiscoverAndRegister(discoveryCtx) in hooks_cmd.go and hooks_git_cmd.go.
  • entire attach: calls external.DiscoverAndRegister(cmd.Context()) in attach.go.
  • entire explain: calls external.DiscoverAndRegister(ctx) in explain.go.

However, for the entire agent add <name> flow in newAgentAddCmd() (agent_group.go):

RunE: func(cmd *cobra.Command, args []string) error {
    name := args[0]
    ag, err := agent.Get(types.AgentName(name)) // <-- Fails here, no discovery called!
    // ...
}

Since discovery is skipped entirely, agent.Get() only checks the statically registered built-in agents, throwing Unknown agent for any compliant external agent on the user's $PATH. The exact same omission happens in newAgentRemoveCmd() and newAgentListCmd().

Expected Behavior

The entire agent noun-group (add, list, remove) should discover external agents to comply with the external agent protocol. entire agent add zed should successfully install hooks for the zed agent just like entire enable --agent zed currently does.

Suggested Fix

Call external.DiscoverAndRegister(ctx) or external.DiscoverAndRegisterAlways(ctx) in runAgentMenu (for list), and in newAgentAddCmd/newAgentRemoveCmd prior to invoking agent.Get().

Steps to reproduce

To reproduce the failure programmatically (and prove the fix), you can use the existing writeExternalAgentBinary test helper. If you write a test against runAgentList that creates a mock external agent and asserts it appears in the output, it will fail on v0.9.0 but pass once the discovery calls are added:

func TestAgentGroup_DiscoversExternalAgents(t *testing.T) {
	// Cannot use t.Parallel because we modify PATH via t.Setenv.
	externalDir := t.TempDir()
	writeExternalAgentBinary(t, externalDir, "ext-agentgroup-test")
	t.Setenv("PATH", externalDir+string(os.PathListSeparator)+os.Getenv("PATH"))

	var buf bytes.Buffer
	if err := runAgentList(context.Background(), &buf); err != nil {
		t.Fatalf("runAgentList with external: %v", err)
	}
	if !strings.Contains(buf.String(), "ext-agentgroup-test") {
		t.Errorf("expected external agent 'ext-agentgroup-test' in output, got:\n%s", buf.String())
	}
}

A complete patch implementing both the fix and this test is included in this report as 0001-fix-agent-group-omits-external-agent-discovery.patch.

Entire CLI version

0.9.0

OS and architecture

any

Agent

any

Terminal

any

Logs / debug output

Additional context

0001-fix-agent-group-omits-external-agent-discovery.patch

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in entireio-cli/cmd/entire/cli/agent_group.go, reviewing runAgentMenu, newAgentAddCmd, and newAgentRemoveCmd alongside the existing discovery calls in setup.go, hooks_cmd.go, hooks_git_cmd.go, attach.go, and explain.go. Use writeExternalAgentBinary to exercise runAgentList with an external agent on PATH, then run the relevant agent-group tests. Done means agent add, remove, and list discover external agents such as zed without affecting built-in agents.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
85/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.