Skip to content

Commit ffa432b

Browse files
committed
fix(agent): TUI agent wiring, scout cleanup, planner paths, subagent default (#556-#559)
- TUI buildPromptInput sends CurrentAgent to server - Scout prompt drops repo_clone/repo_overview (not implemented) - Planner path-scoped edit restricted to plans/* and drafts/* - Bundled .md agent defaults to mode: subagent
1 parent 62add72 commit ffa432b

11 files changed

Lines changed: 596 additions & 132 deletions

File tree

‎docs/spec/07-agents.md‎

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ Agents define behavioral presets: system prompts, tool permissions, and model pa
88

99
```go
1010
type Info struct {
11-
Name string // unique identifier
11+
Name string // unique identifier (registry key is filename stem; Name may differ via frontmatter)
1212
Description string // human-readable description
1313
Mode Mode // "primary", "subagent", "all"
1414
Native bool // true for hardcoded agents
1515
Hidden bool // hidden from user lists
16+
Disabled bool // soft-disabled; Get/List skip these
1617
TopP *float64 // LLM sampling parameter
1718
Temperature *float64 // LLM sampling parameter
1819
Color string // TUI display color (hex)
@@ -38,9 +39,13 @@ type Info struct {
3839

3940
### Loading Order
4041

41-
1. **Native agents** — Hardcoded in `registerNativeAgents()` with specific permissions
42-
2. **Bundled agents** — Loaded from `defaults/*.md` via embedded filesystem (`embed.FS`)
43-
3. **Config overrides** — Applied from `config.Info.Agents` via `ApplyConfigOverrides()`
42+
1. **Native agents** — Hardcoded in `registerNativeAgents()` with specific permissions (prompts from `defaults/*.txt`, except `explore` which prefers `explore.md` body)
43+
2. **Bundled agents** — Loaded from `defaults/*.md` via embedded filesystem (`embed.FS`); skipped when a native agent already owns the name
44+
3. **User agents** — `LoadUserAgents`: `~/.config/tinycode/agents/*.md` then `~/.config/tinycode/agent/*.md` (compat)
45+
4. **Project agents** — `.tinycode/agent/*.md` (loaded after user; overwrites non-native)
46+
5. **Config overrides** — Applied from `config.Info.Agents` via `ApplyConfigOverrides()`
47+
48+
User/project `.md` agents may replace bundled (non-native) agents. Native agents are never overwritten by directory loads.
4449

4550
### Native Agents
4651

@@ -50,49 +55,49 @@ type Info struct {
5055
| `plan` | Primary | Read-only plan mode | `plan_exit:allow`, `edit:deny` |
5156
| `general` | Subagent | Multi-step task execution | `todowrite:deny` |
5257
| `explore` | Subagent | Fast codebase search | Only: `grep`, `glob`, `bash`, `webfetch`, `websearch`, `read` |
53-
| `scout` | Subagent | External research | Only: `grep`, `glob`, `webfetch`, `websearch`, `read`, `repo_clone`, `repo_overview` |
58+
| `scout` | Subagent | External research | Only: `grep`, `glob`, `webfetch`, `websearch`, `read` |
5459
| `compaction` | Primary (hidden) | Context summarization | All denied |
5560
| `title` | Primary (hidden) | Session title generation | All denied, temp=0.5 |
5661
| `summary` | Primary (hidden) | Session summary | All denied |
5762

5863
### Bundled Agents (from `defaults/*.md`)
5964

60-
Loaded from embedded markdown files with YAML frontmatter:
65+
Loaded from embedded markdown files with YAML frontmatter. Actual set in Go `internal/agent/defaults/`:
6166

6267
| Agent | Description |
6368
|-------|-------------|
6469
| `architect` | Code design and architecture review (read-only) |
6570
| `code-reviewer` | Severity-rated code review with SOLID checks |
66-
| `code-simplifier` | Refactoring for clarity and maintainability |
71+
| `code-simplifier` | Refactoring for clarity (archived: disabled by default) |
6772
| `critic` | Multi-perspective quality review |
6873
| `debugger` | Root-cause analysis and bug fixing |
69-
| `designer` | Production-grade UI/UX |
70-
| `document-specialist` | External library and API reference |
7174
| `executor` | Focused implementation of scoped tasks |
7275
| `git-master` | Git history, rebasing, atomic commits |
7376
| `planner` | Strategic planning and work breakdown |
74-
| `qa-tester` | Interactive CLI testing |
75-
| `scientist` | Data analysis and research |
77+
| `qa-tester` | Interactive CLI testing (archived: disabled by default) |
78+
| `scientist` | Data analysis and research (archived: disabled by default) |
7679
| `security-reviewer` | Security vulnerability detection |
7780
| `test-engineer` | Test strategy and TDD workflows |
78-
| `tracer` | Evidence-driven causal tracing |
7981
| `verifier` | Completion verification |
80-
| `workspace` | Development environment setup |
8182
| `writer` | Technical documentation |
82-
| `analyst` | Requirements analysis |
83-
| `cluster-admin` | Kubernetes/OpenShift operations |
83+
84+
`explore.md` / `explore.compact.md` also live under defaults; the native `explore` agent uses the `explore.md` body as its prompt (permissions stay native). Compact peers of archived agents are disabled alongside the base agent.
8485

8586
## 7.3 Frontmatter Schema
8687

87-
Agent `.md` files use YAML frontmatter:
88+
Agent `.md` files use YAML frontmatter. Shared parsing via `applyFrontmatter`:
8889

8990
```yaml
9091
---
92+
name: optional-display-name
9193
description: Human-readable description
92-
mode: primary | subagent | all
94+
mode: primary | subagent | all # omitted → subagent (bundled/user .md defaults)
9395
hidden: true | false
9496
color: "#ff0000"
9597
steps: 10
98+
temperature: 0.7
99+
top_p: 0.9
100+
model: ollama/qwen3:8b
96101
permission:
97102
edit: deny
98103
read: allow
@@ -104,6 +109,8 @@ permission:
104109
System prompt content here...
105110
```
106111

112+
The registry map key is always the filename stem. If `name` is set in frontmatter, it updates `Info.Name` only. Omitted `mode` defaults to `ModeSubagent` (not `ModeAll`).
113+
107114
### Permission Rules in Frontmatter
108115

109116
Permissions support two formats:
@@ -115,7 +122,7 @@ permission:
115122
read: allow
116123
```
117124
118-
**Pattern-specific:**
125+
**Pattern-specific (nested maps):**
119126
```yaml
120127
permission:
121128
bash:
@@ -125,23 +132,24 @@ permission:
125132
126133
## 7.4 Small-Model Variants
127134
128-
When a model's parameter count is ≤8B (detected from model name), the registry returns a **compact variant** if available:
135+
When a model's parameter count is ≤8B (detected from model name), the registry returns a **compact variant** if available and not disabled:
129136
130137
```go
131138
func (r *Registry) Get(name string, modelSizeB *float64) *Info {
132139
if modelSizeB != nil && *modelSizeB <= 8 {
133140
compact := r.agents[name+".compact"]
134-
if compact != nil {
141+
if compact != nil && !compact.Disabled {
135142
result := *compact
143+
result.Name = name // requested base name, not "*.compact"
136144
result.Compact = true
137145
return &result
138146
}
139147
}
140-
// ... return standard agent
148+
// ... return standard agent (nil if missing or Disabled)
141149
}
142150
```
143151

144-
Compact variants are agent files named `<agent>.compact.md` with simplified prompts optimized for smaller models.
152+
Compact variants are agent files named `<agent>.compact.md` with simplified prompts optimized for smaller models. `Get` never serves disabled agents (base or compact).
145153

146154
## 7.5 Permission Merging
147155

@@ -192,15 +200,15 @@ Users can modify agents via config:
192200

193201
Override fields: `model`, `variant`, `prompt`, `description`, `temperature`, `top_p`, `mode`, `color`, `hidden`, `name`, `steps`, `options`, `permission`, `disable`.
194202

195-
Setting `disable: true` removes the agent from the registry.
203+
Setting `disable: true` sets `Disabled` on the agent (soft disable). It does **not** remove the agent from the registry. Native agents cannot be disabled. `Get` and `List` skip disabled agents; `ListAll` includes them.
196204

197205
## 7.7 Default Agent Resolution
198206

199207
`DefaultAgent(configDefault)` resolves the default agent:
200208

201-
1. If `configDefault` is set in config, validate it exists and is a primary, visible agent
202-
2. Otherwise, use `"build"`
203-
3. Fallback: first registered non-subagent, non-hidden agent
209+
1. If `configDefault` is set in config, validate it exists and is a primary, visible, non-disabled agent
210+
2. Otherwise, use `"build"` if not disabled
211+
3. Fallback: first registered non-subagent, non-hidden, non-disabled agent
204212

205213
## 7.8 Agent Model Override
206214

@@ -221,12 +229,13 @@ When an agent has a `Model` set, the session manager uses that model instead of
221229

222230
Source: `internal/agent/loader.go`
223231

224-
`LoadUserAgents(configDir, projectDir)` loads user-defined agents from two directories:
232+
`LoadUserAgents(configDir, projectDir)` loads user-defined agents from:
225233

226234
1. **User config:** `~/.config/tinycode/agents/*.md`
227-
2. **Project:** `.tinycode/agent/*.md`
235+
2. **User compat:** `~/.config/tinycode/agent/*.md`
236+
3. **Project:** `.tinycode/agent/*.md`
228237

229-
Files are parsed identically to bundled agents (frontmatter + body). Agents already in the registry are **not** overwritten — bundled and native agents take precedence.
238+
Files are parsed identically to bundled agents (frontmatter + body via `applyFrontmatter`). Non-native agents already in the registry **may be overwritten** (project wins over user over bundled). Native agents are never overwritten. Load errors are logged, not silently discarded.
230239

231240
Compact variants (`*.compact.md`) are loaded alongside their full counterparts.
232241

0 commit comments

Comments
 (0)