Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/added-18491-repo-agent-discovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **Agents declared in a managed repo's `.hive/agents/`** are discovered and held for owner approval, so a project adds an agent with a PR instead of a hive config edit. Every allowlisted managed repo (the same repo-sourced prompt allowlist as `definition_source`: the seed list or an owner-approved repo) is scanned at startup, every 15 minutes (`HIVE_REPO_AGENTS_INTERVAL`) and on a default-branch push touching `.hive/agents/`; each `<name>.yaml` shows up as pending under **Agents → Import → Declared in your repos** and nothing runs until an owner approves it. Approval registers the agent with `definition_source` (marked `discovered`) and, with a sibling `<name>.md`, `prompt_source`; backend, model, mode and tools stay owner-controlled on every later re-apply. Removing the file pauses the agent rather than deleting it. ([#18491](https://github.com/hivecommons/hive/issues/18491))
358 changes: 358 additions & 0 deletions dashboard/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7870,6 +7870,364 @@
}
}
},
"/api/agents/discovered": {
"get": {
"tags": [
"Agents"
],
"summary": "List agents discovered in managed repos",
"description": "Agent definitions found under .hive/agents/*.yaml in managed repos that pass the repo-sourced prompt allowlist, with their approval status. Nothing runs until an owner approves an entry.",
"responses": {
"200": {
"description": "Discovered definitions",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"description": "False when discovery is not running (no GitHub client)."
},
"pending": {
"type": "integer"
},
"entries": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "owner/repo:path of the definition file."
},
"repo": {
"type": "string"
},
"path": {
"type": "string"
},
"prompt_path": {
"type": "string",
"description": "Sibling <name>.md that becomes prompt_source on approval, when present."
},
"name": {
"type": "string",
"description": "Agent key the definition maps to."
},
"display_name": {
"type": "string"
},
"description": {
"type": "string"
},
"emoji": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
"pending",
"invalid",
"approved",
"rejected",
"orphaned"
]
},
"agent": {
"type": "string",
"description": "Registered agent, once approved."
},
"error": {
"type": "string"
},
"first_seen": {
"type": "string",
"format": "date-time"
},
"last_seen": {
"type": "string",
"format": "date-time"
},
"decided_at": {
"type": "string",
"format": "date-time"
},
"decided_by": {
"type": "string"
},
"orphaned_at": {
"type": "string",
"format": "date-time"
}
}
}
}
}
}
}
}
}
}
}
},
"/api/agents/discovered/approve": {
"post": {
"tags": [
"Agents"
],
"summary": "Approve a discovered agent",
"description": "Owner-only. Re-reads the definition through the allowlist gate and registers the agent with definition_source (marked discovered) and, when a sibling <name>.md exists, prompt_source. Backend, model and mode come from this request, never the file; tools stay unset for the owner to grant.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string",
"description": "Agent key; defaults to the definition's normalized metadata.name."
},
"backend": {
"type": "string",
"description": "Defaults to copilot."
},
"model": {
"type": "string"
},
"mode": {
"type": "string",
"enum": [
"ADVISORY",
"ISSUES_ONLY",
"ISSUES_AND_PRS",
"ISSUES_PRS_MERGE",
"NO_GITHUB"
]
}
}
}
}
}
},
"responses": {
"200": {
"description": "Approved",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "approved"
},
"name": {
"type": "string"
}
}
}
}
}
},
"400": {
"description": "Invalid body, mode or agent name"
},
"403": {
"description": "Owner role required, or the repo is no longer allowlisted"
},
"404": {
"description": "Unknown entry"
},
"409": {
"description": "Entry is not pending, or the agent name is taken"
},
"502": {
"description": "The definition could not be read or parsed"
},
"503": {
"description": "Discovery is not running"
}
}
}
},
"/api/agents/discovered/reject": {
"post": {
"tags": [
"Agents"
],
"summary": "Reject a discovered agent",
"description": "Owner-only. A rejected definition stays rejected until its file is removed.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": "string"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Rejected",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "rejected"
},
"id": {
"type": "string"
}
}
}
}
}
},
"400": {
"description": "Invalid body"
},
"403": {
"description": "Owner role required"
},
"404": {
"description": "Unknown entry"
},
"409": {
"description": "Entry is not pending"
},
"503": {
"description": "Discovery is not running"
}
}
}
},
"/api/agents/discovered/refresh": {
"post": {
"tags": [
"Agents"
],
"summary": "Rescan managed repos for agent definitions",
"description": "Owner-only. Rescans every managed repo now instead of waiting for the timer and returns the refreshed list.",
"responses": {
"200": {
"description": "Discovered definitions",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"description": "False when discovery is not running (no GitHub client)."
},
"pending": {
"type": "integer"
},
"entries": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "owner/repo:path of the definition file."
},
"repo": {
"type": "string"
},
"path": {
"type": "string"
},
"prompt_path": {
"type": "string",
"description": "Sibling <name>.md that becomes prompt_source on approval, when present."
},
"name": {
"type": "string",
"description": "Agent key the definition maps to."
},
"display_name": {
"type": "string"
},
"description": {
"type": "string"
},
"emoji": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
"pending",
"invalid",
"approved",
"rejected",
"orphaned"
]
},
"agent": {
"type": "string",
"description": "Registered agent, once approved."
},
"error": {
"type": "string"
},
"first_seen": {
"type": "string",
"format": "date-time"
},
"last_seen": {
"type": "string",
"format": "date-time"
},
"decided_at": {
"type": "string",
"format": "date-time"
},
"decided_by": {
"type": "string"
},
"orphaned_at": {
"type": "string",
"format": "date-time"
}
}
}
}
}
}
}
}
},
"403": {
"description": "Owner role required"
},
"503": {
"description": "Discovery is not running"
}
}
}
},
"/api/agents/{name}": {
"delete": {
"tags": [
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/hive/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/hivecommons/hive/pkg/priorart"
"github.com/hivecommons/hive/pkg/promptsrc"
"github.com/hivecommons/hive/pkg/questionclose"
"github.com/hivecommons/hive/pkg/repoagents"
"github.com/hivecommons/hive/pkg/retro"
"github.com/hivecommons/hive/pkg/review/eventdispatch"
"github.com/hivecommons/hive/pkg/rotation"
Expand Down Expand Up @@ -197,6 +198,7 @@ type boot struct {
promptFetcher promptsrc.Fetcher
defFetcher defsrc.Fetcher
definitionResolver *defsrc.Resolver
repoAgents *repoagents.Discoverer // #18491; nil without a GitHub client
perspectivesResolver *perspsrc.Resolver
pendingTokenSeed []dashboard.TokenSparklineEntry
pendingFactSeed []dashboard.FactHistoryEntry
Expand Down
Loading
Loading