bots-garden/mini-mepublic Fork
⑂ 87ac47a
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/mini-me.git
git clone ssh://git@rickub.com/bots-garden/mini-me.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

✨ docSearch.dirs: "@agent/" folders beside the agent file (#156)

An entry that starts with "@agent/" is resolved at load time against the
agent's folder (BaseDir), so documentation shipped with an agent is found
wherever mm runs. The prefix is optional: other relative entries keep
following the working directory. learning-rust drops its absolute path;
new demo demos/docs-from-agent; docs EN+FR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
agent committed 2026-11-26T19:07:46+01:00 Browse files
87ac47a parent: 5faf85c
modified .tickets/issues/0156-docsearch-dirs-relative-to-the-agent-file.yaml +60 -7
@@ -1,12 +1,13 @@
11 # Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
22 id: 156
33 title: "docSearch dirs: allow a path relative to the agent file (@agent/ prefix)"
4-state: open
4+state: closed
55 author:
66 name: k33g
77 email: ph.charriere@gmail.com
88 createdAt: 2026-10-25T13:38:47.000Z
9-updatedAt: 2026-11-01T20:44:45.000Z
9+updatedAt: 2026-11-26T21:00:00.000Z
10+closedAt: 2026-11-26T21:00:00.000Z
1011 labels:
1112 - enhancement
1213 - kind::feature
@@ -51,34 +52,86 @@ body: |+
5152 tasks:
5253 - id: 1
5354 title: Resolve "@agent/" entries of docSearch.dirs against the agent file's folder at load time
54- state: open
55+ state: closed
5556 priority: none
5657 author:
5758 name: k33g
5859 email: ph.charriere@gmail.com
5960 createdAt: 2026-10-25T13:38:47.000Z
61+ updatedAt: 2026-11-26T20:30:00.000Z
62+ closedAt: 2026-11-26T20:30:00.000Z
6063 - id: 2
6164 title: Tests (relative, prefixed, absolute, missing folder)
62- state: open
65+ state: closed
6366 priority: none
6467 author:
6568 name: k33g
6669 email: ph.charriere@gmail.com
6770 createdAt: 2026-10-25T13:38:47.000Z
71+ updatedAt: 2026-11-26T20:30:00.000Z
72+ closedAt: 2026-11-26T20:30:00.000Z
6873 - id: 3
6974 title: Docs EN + FR (DocSearchConfig comment, reference)
70- state: open
75+ state: closed
7176 priority: none
7277 author:
7378 name: k33g
7479 email: ph.charriere@gmail.com
7580 createdAt: 2026-10-25T13:38:47.000Z
81+ updatedAt: 2026-11-26T20:30:00.000Z
82+ closedAt: 2026-11-26T20:30:00.000Z
7683 - id: 4
7784 title: Switch learning-rust/agent-config/agent.yaml back to a relative path
78- state: open
85+ state: closed
7986 priority: none
8087 author:
8188 name: k33g
8289 email: ph.charriere@gmail.com
8390 createdAt: 2026-10-25T13:38:47.000Z
84-comments: []
91+ updatedAt: 2026-11-26T20:30:00.000Z
92+ closedAt: 2026-11-26T20:30:00.000Z
93+comments:
94+ - id: 1
95+ author:
96+ name: k33g
97+ email: ph.charriere@gmail.com
98+ createdAt: 2026-11-26T19:30:00.000Z
99+ body: |
100+ Still relevant (checked 2026-11-26): no `@agent` prefix nor
101+ `resolveDocSearch*` in internal/config or internal/docsearch;
102+ `docSearch.dirs` still follows the working directory (docsearch.go
103+ comment, reference configuration.md:96);
104+ demos/learning-rust/agent-config/agent.yaml:52 still held the author's
105+ absolute path. Since the ticket was written, more paths are anchored on
106+ the agent's folder with BaseDir(configPath): resolveDecider,
107+ resolveToolDecider, resolveRazorbillPaths beside resolveToolPaths,
108+ resolveAgentPaths, resolveHooks — docSearch.dirs was the odd one out.
109+
110+ Decided (user, 2026-11-26): the prefix is `@agent/`, and it is
111+ optional — an entry without it keeps following the working directory.
112+ - id: 2
113+ author:
114+ name: k33g
115+ email: ph.charriere@gmail.com
116+ createdAt: 2026-11-26T20:30:00.000Z
117+ body: |
118+ Done on branch feature/docsearch-agent-prefix (not merged yet):
119+ - internal/config/docsearch.go: `resolveDocSearchPaths` (called in Load
120+ beside the other resolve*), `agentRelative`: `@agent`, `@agent/` and
121+ `@agent\` followed by a path → BaseDir(agent file) + path; `@agents/x`
122+ and `@agentdocs` stay ordinary names; a copy of the slice, so the
123+ defaults are never written to.
124+ - Base is BaseDir, as for wasm modules and hooks: the agent file's
125+ folder, or the project root for a .mm/agent.yaml.
126+ - Display (the ticket's second open question): the `@agent/` entry is
127+ shown RESOLVED (absolute) in the results header and in "missing",
128+ and its files with absolute paths (they are outside the working
129+ directory) — usable by read_file as they are.
130+ - Tests: internal/config/docsearch_agent_test.go (10 cases + mixed list).
131+ - Docs EN+FR: reference configuration.md (docSearch.dirs), how-to
132+ search-the-docs.md (new variant), the DocSearchConfig comment.
133+ - demos/learning-rust back to `dirs: ["@agent/docs"]`.
134+ - New demo demos/docs-from-agent (Tern, Qwen3.5 4B on llama.cpp):
135+ agent/handbook via `@agent/handbook` + project/docs via `docs`;
136+ checked live with /docs and -p (handbook, project, "not covered"),
137+ and from a folder without docs/.
@@ -1,12 +1,13 @@
1 # Managed by IssueSpec. Hand edits are welcome; keep the schema valid.1 # Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
2 id: 1562 id: 156
3 title: "docSearch dirs: allow a path relative to the agent file (@agent/ prefix)"3 title: "docSearch dirs: allow a path relative to the agent file (@agent/ prefix)"
4-state: open4+state: closed
5 author:5 author:
6 name: k33g6 name: k33g
7 email: ph.charriere@gmail.com7 email: ph.charriere@gmail.com
8 createdAt: 2026-10-25T13:38:47.000Z8 createdAt: 2026-10-25T13:38:47.000Z
9-updatedAt: 2026-11-01T20:44:45.000Z9+updatedAt: 2026-11-26T21:00:00.000Z
10+closedAt: 2026-11-26T21:00:00.000Z
10 labels:11 labels:
11 - enhancement12 - enhancement
12 - kind::feature13 - kind::feature
@@ -51,34 +52,86 @@ body: |+
51 tasks:52 tasks:
52 - id: 153 - id: 1
53 title: Resolve "@agent/" entries of docSearch.dirs against the agent file's folder at load time54 title: Resolve "@agent/" entries of docSearch.dirs against the agent file's folder at load time
54- state: open55+ state: closed
55 priority: none56 priority: none
56 author:57 author:
57 name: k33g58 name: k33g
58 email: ph.charriere@gmail.com59 email: ph.charriere@gmail.com
59 createdAt: 2026-10-25T13:38:47.000Z60 createdAt: 2026-10-25T13:38:47.000Z
61+ updatedAt: 2026-11-26T20:30:00.000Z
62+ closedAt: 2026-11-26T20:30:00.000Z
60 - id: 263 - id: 2
61 title: Tests (relative, prefixed, absolute, missing folder)64 title: Tests (relative, prefixed, absolute, missing folder)
62- state: open65+ state: closed
63 priority: none66 priority: none
64 author:67 author:
65 name: k33g68 name: k33g
66 email: ph.charriere@gmail.com69 email: ph.charriere@gmail.com
67 createdAt: 2026-10-25T13:38:47.000Z70 createdAt: 2026-10-25T13:38:47.000Z
71+ updatedAt: 2026-11-26T20:30:00.000Z
72+ closedAt: 2026-11-26T20:30:00.000Z
68 - id: 373 - id: 3
69 title: Docs EN + FR (DocSearchConfig comment, reference)74 title: Docs EN + FR (DocSearchConfig comment, reference)
70- state: open75+ state: closed
71 priority: none76 priority: none
72 author:77 author:
73 name: k33g78 name: k33g
74 email: ph.charriere@gmail.com79 email: ph.charriere@gmail.com
75 createdAt: 2026-10-25T13:38:47.000Z80 createdAt: 2026-10-25T13:38:47.000Z
81+ updatedAt: 2026-11-26T20:30:00.000Z
82+ closedAt: 2026-11-26T20:30:00.000Z
76 - id: 483 - id: 4
77 title: Switch learning-rust/agent-config/agent.yaml back to a relative path84 title: Switch learning-rust/agent-config/agent.yaml back to a relative path
78- state: open85+ state: closed
79 priority: none86 priority: none
80 author:87 author:
81 name: k33g88 name: k33g
82 email: ph.charriere@gmail.com89 email: ph.charriere@gmail.com
83 createdAt: 2026-10-25T13:38:47.000Z90 createdAt: 2026-10-25T13:38:47.000Z
84-comments: []91+ updatedAt: 2026-11-26T20:30:00.000Z
92+ closedAt: 2026-11-26T20:30:00.000Z
93+comments:
94+ - id: 1
95+ author:
96+ name: k33g
97+ email: ph.charriere@gmail.com
98+ createdAt: 2026-11-26T19:30:00.000Z
99+ body: |
100+ Still relevant (checked 2026-11-26): no `@agent` prefix nor
101+ `resolveDocSearch*` in internal/config or internal/docsearch;
102+ `docSearch.dirs` still follows the working directory (docsearch.go
103+ comment, reference configuration.md:96);
104+ demos/learning-rust/agent-config/agent.yaml:52 still held the author's
105+ absolute path. Since the ticket was written, more paths are anchored on
106+ the agent's folder with BaseDir(configPath): resolveDecider,
107+ resolveToolDecider, resolveRazorbillPaths beside resolveToolPaths,
108+ resolveAgentPaths, resolveHooks — docSearch.dirs was the odd one out.
109+
110+ Decided (user, 2026-11-26): the prefix is `@agent/`, and it is
111+ optional — an entry without it keeps following the working directory.
112+ - id: 2
113+ author:
114+ name: k33g
115+ email: ph.charriere@gmail.com
116+ createdAt: 2026-11-26T20:30:00.000Z
117+ body: |
118+ Done on branch feature/docsearch-agent-prefix (not merged yet):
119+ - internal/config/docsearch.go: `resolveDocSearchPaths` (called in Load
120+ beside the other resolve*), `agentRelative`: `@agent`, `@agent/` and
121+ `@agent\` followed by a path → BaseDir(agent file) + path; `@agents/x`
122+ and `@agentdocs` stay ordinary names; a copy of the slice, so the
123+ defaults are never written to.
124+ - Base is BaseDir, as for wasm modules and hooks: the agent file's
125+ folder, or the project root for a .mm/agent.yaml.
126+ - Display (the ticket's second open question): the `@agent/` entry is
127+ shown RESOLVED (absolute) in the results header and in "missing",
128+ and its files with absolute paths (they are outside the working
129+ directory) — usable by read_file as they are.
130+ - Tests: internal/config/docsearch_agent_test.go (10 cases + mixed list).
131+ - Docs EN+FR: reference configuration.md (docSearch.dirs), how-to
132+ search-the-docs.md (new variant), the DocSearchConfig comment.
133+ - demos/learning-rust back to `dirs: ["@agent/docs"]`.
134+ - New demo demos/docs-from-agent (Tern, Qwen3.5 4B on llama.cpp):
135+ agent/handbook via `@agent/handbook` + project/docs via `docs`;
136+ checked live with /docs and -p (handbook, project, "not covered"),
137+ and from a folder without docs/.
modified README.md +1 -0
@@ -192,6 +192,7 @@ The `demos/` directory holds ready-made set-ups (most with a README explaining h
192192 | `demos/guards/` | an assistant (Gemma 4 E4B) protected by seven guard agents, one per risk: a Node.js `preGeneration` hook asks them in parallel without the history, the assistant refuses or answers according to their verdicts; `displayHooks: true`; measured results |
193193 | `demos/unload-models/` | a coordinator (Qwen3.5 9B) hands programming questions to an expert (Qwen3.5 4B) with `ask_agent`, a `preAsk` hook unloads the coordinator's own model before the expert starts and a `postAsk` hook unloads the expert's once it has answered — the two models are never loaded together; `/unload` and `unload_model` on request; llmman, measured results |
194194 | `demos/plans/` | the `plan` tool at work: Planner (Qwen3.5 4B on llmman) builds a tiny Go program in four steps — module, code, test, README — while mm shows `📋 [C/N] …` after each plan action; a failing variant ends on `Plan finished: 2 done, 1 failed`; measured results |
195+| `demos/docs-from-agent/` | `docSearch.dirs: ["@agent/handbook", docs]`: a handbook shipped beside the agent file plus the docs of the project mm runs in, searched together; Qwen3.5 4B on llama.cpp |
195196 | `demos/docs-search/` | an assistant answering from a documentation folder: nine Ratatui tutorials (Rust terminal UIs, each program checked against ratatui 0.30 by `check-tutorials.sh`), `/docs <words>` for you and the `search_docs` tool for the model; Qwen3.5 4B on llmman, measured results |
196197 | `demos/memory-search/` | an assistant that remembers a project's decisions: four earlier sessions (port, storage, logs in French, deployment as a `/compact` summary), `/memory <words>` for you and the `search_memory` tool for the model; Qwen3.5 4B on llmman, measured results — including what a word search cannot find |
197198 | `demos/declared-tools/` | an ops desk with no `bash` and no skills, acting only through four tools declared under `tools:` — release, version bump, service logs, slow requests — covering every parameter type (string, enum, boolean, integer, number), a safe default (`dryRun: true`) and an optional argument; Mellum2 12B on DMR, measured results |
@@ -192,6 +192,7 @@ The `demos/` directory holds ready-made set-ups (most with a README explaining h
192 | `demos/guards/` | an assistant (Gemma 4 E4B) protected by seven guard agents, one per risk: a Node.js `preGeneration` hook asks them in parallel without the history, the assistant refuses or answers according to their verdicts; `displayHooks: true`; measured results |192 | `demos/guards/` | an assistant (Gemma 4 E4B) protected by seven guard agents, one per risk: a Node.js `preGeneration` hook asks them in parallel without the history, the assistant refuses or answers according to their verdicts; `displayHooks: true`; measured results |
193 | `demos/unload-models/` | a coordinator (Qwen3.5 9B) hands programming questions to an expert (Qwen3.5 4B) with `ask_agent`, a `preAsk` hook unloads the coordinator's own model before the expert starts and a `postAsk` hook unloads the expert's once it has answered — the two models are never loaded together; `/unload` and `unload_model` on request; llmman, measured results |193 | `demos/unload-models/` | a coordinator (Qwen3.5 9B) hands programming questions to an expert (Qwen3.5 4B) with `ask_agent`, a `preAsk` hook unloads the coordinator's own model before the expert starts and a `postAsk` hook unloads the expert's once it has answered — the two models are never loaded together; `/unload` and `unload_model` on request; llmman, measured results |
194 | `demos/plans/` | the `plan` tool at work: Planner (Qwen3.5 4B on llmman) builds a tiny Go program in four steps — module, code, test, README — while mm shows `📋 [C/N] …` after each plan action; a failing variant ends on `Plan finished: 2 done, 1 failed`; measured results |194 | `demos/plans/` | the `plan` tool at work: Planner (Qwen3.5 4B on llmman) builds a tiny Go program in four steps — module, code, test, README — while mm shows `📋 [C/N] …` after each plan action; a failing variant ends on `Plan finished: 2 done, 1 failed`; measured results |
195+| `demos/docs-from-agent/` | `docSearch.dirs: ["@agent/handbook", docs]`: a handbook shipped beside the agent file plus the docs of the project mm runs in, searched together; Qwen3.5 4B on llama.cpp |
195 | `demos/docs-search/` | an assistant answering from a documentation folder: nine Ratatui tutorials (Rust terminal UIs, each program checked against ratatui 0.30 by `check-tutorials.sh`), `/docs <words>` for you and the `search_docs` tool for the model; Qwen3.5 4B on llmman, measured results |196 | `demos/docs-search/` | an assistant answering from a documentation folder: nine Ratatui tutorials (Rust terminal UIs, each program checked against ratatui 0.30 by `check-tutorials.sh`), `/docs <words>` for you and the `search_docs` tool for the model; Qwen3.5 4B on llmman, measured results |
196 | `demos/memory-search/` | an assistant that remembers a project's decisions: four earlier sessions (port, storage, logs in French, deployment as a `/compact` summary), `/memory <words>` for you and the `search_memory` tool for the model; Qwen3.5 4B on llmman, measured results — including what a word search cannot find |197 | `demos/memory-search/` | an assistant that remembers a project's decisions: four earlier sessions (port, storage, logs in French, deployment as a `/compact` summary), `/memory <words>` for you and the `search_memory` tool for the model; Qwen3.5 4B on llmman, measured results — including what a word search cannot find |
197 | `demos/declared-tools/` | an ops desk with no `bash` and no skills, acting only through four tools declared under `tools:` — release, version bump, service logs, slow requests — covering every parameter type (string, enum, boolean, integer, number), a safe default (`dryRun: true`) and an optional argument; Mellum2 12B on DMR, measured results |198 | `demos/declared-tools/` | an ops desk with no `bash` and no skills, acting only through four tools declared under `tools:` — release, version bump, service logs, slow requests — covering every parameter type (string, enum, boolean, integer, number), a safe default (`dryRun: true`) and an optional argument; Mellum2 12B on DMR, measured results |
added demos/docs-from-agent/README.en.md +52 -0
new file mode 100644
@@ -0,0 +1,52 @@
1+# docs-from-agent demo — documentation shipped with the agent (`@agent/`)
2+
3+Tern answers questions about how the team works and about the current project. It searches two folders with `search_docs`:
4+
5+- **its own handbook**, shipped beside its agent file — `agent/handbook/` (commit messages, code reviews);
6+- **the docs of the project it runs in** — `docs/` of the working directory (here `project/docs/`: releases, configuration).
7+
8+The agent file lives in `agent/`, mm runs in `project/`. A relative folder of `docSearch.dirs` follows the working directory; the `@agent/` prefix (ticket 156) anchors it on the agent file's folder instead:
9+
10+```yaml
11+docSearch:
12+ dirs:
13+ - "@agent/handbook" # beside agent.yaml, wherever mm runs
14+ - docs # the working directory's docs/
15+```
16+
17+The prefix is optional, and the quotes are needed in YAML.
18+
19+Version française : [README.fr.md](README.fr.md).
20+
21+| File | What it is |
22+|------|------------|
23+| `agent/agent.yaml` | Tern: `provider: llamacpp`, `unsloth/Qwen3.5-4B-GGUF:Q4_K_M` (thinking off), `search_docs` and `/docs`, no other tool |
24+| `agent/handbook/` | the handbook shipped with the agent: `commits.md`, `reviews.md` |
25+| `project/docs/` | the project's own docs: `release.md`, `config.md` |
26+
27+## Before you start
28+
29+The model runs on llama-server on 127.0.0.1:9931 (the Llama app, or `llama-server` in router mode) with `unsloth/Qwen3.5-4B-GGUF:Q4_K_M`.
30+
31+## Run it
32+
33+```bash
34+cd demos/docs-from-agent/project
35+../../../mm -config ../agent/agent.yaml # line mode
36+../../../mm -config ../agent/agent.yaml -tui # window
37+```
38+
39+1. `/docs commit subject` — the passages come from `agent/handbook/commits.md`, although mm runs in `project/`.
40+2. `/docs release tag` — the passage comes from `docs/release.md`, the project's.
41+3. Ask Tern: `How long can a commit subject be?` (handbook), `How do I release this project?` (project), `How do I deploy to Kubernetes?` (neither: Tern says the docs do not cover it).
42+4. Start mm from a folder with no `docs/`: `/docs review` still finds the handbook, and reports `⚠️ docs: no such folder`.
43+
44+In Zed: `AGENT_CONFIG=<absolute path>/demos/docs-from-agent/agent/agent.yaml`, args `["-acp"]`, and open `project/` — the handbook is found from the agent file, the docs from the editor's project.
45+
46+## What was checked (2026-11-26, from an sbx sandbox, llama-server router on the Mac)
47+
48+- `/docs` from `project/`: `commit subject` → 4 passages of `agent/handbook/commits.md` and one of `docs/release.md`; `release tag` → `docs/release.md:1`. The header lists the two folders: the `@agent/` one resolved to its absolute path, `docs` as written.
49+- `-p` with Qwen3.5 4B: "52 characters, emoji included" with the link `…/agent/handbook/commits.md:5`; the French question on releases answered in French with the four steps and the Tuesday rule (`docs/release.md:1`); Kubernetes: three searches, no passage, "the documentation does not cover" it.
50+- From a folder without `docs/`: `⚠️ docs: no such folder`, the handbook still searched.
51+- The window and Zed were not tried live.
52+- The start-up line `[warning: no skills found in …/no-skills …]` is expected: this agent has no skills.
new file mode 100644
@@ -0,0 +1,52 @@
1+# docs-from-agent demo — documentation shipped with the agent (`@agent/`)
2+
3+Tern answers questions about how the team works and about the current project. It searches two folders with `search_docs`:
4+
5+- **its own handbook**, shipped beside its agent file — `agent/handbook/` (commit messages, code reviews);
6+- **the docs of the project it runs in** — `docs/` of the working directory (here `project/docs/`: releases, configuration).
7+
8+The agent file lives in `agent/`, mm runs in `project/`. A relative folder of `docSearch.dirs` follows the working directory; the `@agent/` prefix (ticket 156) anchors it on the agent file's folder instead:
9+
10+```yaml
11+docSearch:
12+ dirs:
13+ - "@agent/handbook" # beside agent.yaml, wherever mm runs
14+ - docs # the working directory's docs/
15+```
16+
17+The prefix is optional, and the quotes are needed in YAML.
18+
19+Version française : [README.fr.md](README.fr.md).
20+
21+| File | What it is |
22+|------|------------|
23+| `agent/agent.yaml` | Tern: `provider: llamacpp`, `unsloth/Qwen3.5-4B-GGUF:Q4_K_M` (thinking off), `search_docs` and `/docs`, no other tool |
24+| `agent/handbook/` | the handbook shipped with the agent: `commits.md`, `reviews.md` |
25+| `project/docs/` | the project's own docs: `release.md`, `config.md` |
26+
27+## Before you start
28+
29+The model runs on llama-server on 127.0.0.1:9931 (the Llama app, or `llama-server` in router mode) with `unsloth/Qwen3.5-4B-GGUF:Q4_K_M`.
30+
31+## Run it
32+
33+```bash
34+cd demos/docs-from-agent/project
35+../../../mm -config ../agent/agent.yaml # line mode
36+../../../mm -config ../agent/agent.yaml -tui # window
37+```
38+
39+1. `/docs commit subject` — the passages come from `agent/handbook/commits.md`, although mm runs in `project/`.
40+2. `/docs release tag` — the passage comes from `docs/release.md`, the project's.
41+3. Ask Tern: `How long can a commit subject be?` (handbook), `How do I release this project?` (project), `How do I deploy to Kubernetes?` (neither: Tern says the docs do not cover it).
42+4. Start mm from a folder with no `docs/`: `/docs review` still finds the handbook, and reports `⚠️ docs: no such folder`.
43+
44+In Zed: `AGENT_CONFIG=<absolute path>/demos/docs-from-agent/agent/agent.yaml`, args `["-acp"]`, and open `project/` — the handbook is found from the agent file, the docs from the editor's project.
45+
46+## What was checked (2026-11-26, from an sbx sandbox, llama-server router on the Mac)
47+
48+- `/docs` from `project/`: `commit subject` → 4 passages of `agent/handbook/commits.md` and one of `docs/release.md`; `release tag` → `docs/release.md:1`. The header lists the two folders: the `@agent/` one resolved to its absolute path, `docs` as written.
49+- `-p` with Qwen3.5 4B: "52 characters, emoji included" with the link `…/agent/handbook/commits.md:5`; the French question on releases answered in French with the four steps and the Tuesday rule (`docs/release.md:1`); Kubernetes: three searches, no passage, "the documentation does not cover" it.
50+- From a folder without `docs/`: `⚠️ docs: no such folder`, the handbook still searched.
51+- The window and Zed were not tried live.
52+- The start-up line `[warning: no skills found in …/no-skills …]` is expected: this agent has no skills.
added demos/docs-from-agent/README.fr.md +52 -0
new file mode 100644
@@ -0,0 +1,52 @@
1+# Démo docs-from-agent — une documentation livrée avec l'agent (`@agent/`)
2+
3+Tern répond à des questions sur la façon de travailler de l'équipe et sur le projet en cours. Il cherche dans deux dossiers avec `search_docs` :
4+
5+- **son propre manuel**, livré à côté de son fichier d'agent — `agent/handbook/` (messages de commit, revues de code) ;
6+- **la doc du projet où il tourne** — le `docs/` du répertoire de travail (ici `project/docs/` : releases, configuration).
7+
8+Le fichier d'agent vit dans `agent/`, mm tourne dans `project/`. Un dossier relatif de `docSearch.dirs` suit le répertoire de travail ; le préfixe `@agent/` (ticket 156) l'ancre plutôt sur le dossier du fichier d'agent :
9+
10+```yaml
11+docSearch:
12+ dirs:
13+ - "@agent/handbook" # à côté d'agent.yaml, d'où que mm soit lancé
14+ - docs # le docs/ du répertoire de travail
15+```
16+
17+Le préfixe est facultatif, et les guillemets sont obligatoires en YAML.
18+
19+English version: [README.en.md](README.en.md).
20+
21+| Fichier | Ce que c'est |
22+|---------|--------------|
23+| `agent/agent.yaml` | Tern : `provider: llamacpp`, `unsloth/Qwen3.5-4B-GGUF:Q4_K_M` (raisonnement coupé), `search_docs` et `/docs`, aucun autre outil |
24+| `agent/handbook/` | le manuel livré avec l'agent : `commits.md`, `reviews.md` |
25+| `project/docs/` | la doc propre au projet : `release.md`, `config.md` |
26+
27+## Avant de commencer
28+
29+Le modèle tourne sur llama-server en 127.0.0.1:9931 (l'application Llama, ou `llama-server` en mode routeur) avec `unsloth/Qwen3.5-4B-GGUF:Q4_K_M`.
30+
31+## Lancer la démo
32+
33+```bash
34+cd demos/docs-from-agent/project
35+../../../mm -config ../agent/agent.yaml # mode ligne
36+../../../mm -config ../agent/agent.yaml -tui # fenêtre
37+```
38+
39+1. `/docs commit subject` — les passages viennent de `agent/handbook/commits.md`, alors que mm tourne dans `project/`.
40+2. `/docs release tag` — le passage vient de `docs/release.md`, celui du projet.
41+3. Demandez à Tern : `How long can a commit subject be?` (manuel), `Comment je fais une release de ce projet ?` (projet), `How do I deploy to Kubernetes?` (ni l'un ni l'autre : Tern dit que la doc n'en parle pas).
42+4. Lancez mm depuis un dossier sans `docs/` : `/docs review` trouve toujours le manuel, et signale `⚠️ docs: no such folder`.
43+
44+Dans Zed : `AGENT_CONFIG=<chemin absolu>/demos/docs-from-agent/agent/agent.yaml`, args `["-acp"]`, et ouvrez `project/` — le manuel est trouvé depuis le fichier d'agent, la doc depuis le projet de l'éditeur.
45+
46+## Ce qui a été vérifié (26/11/2026, depuis un sandbox sbx, routeur llama-server sur le Mac)
47+
48+- `/docs` depuis `project/` : `commit subject` → 4 passages de `agent/handbook/commits.md` et un de `docs/release.md` ; `release tag` → `docs/release.md:1`. L'en-tête liste les deux dossiers : celui en `@agent/` résolu en chemin absolu, `docs` tel qu'écrit.
49+- `-p` avec Qwen3.5 4B : « 52 characters, emoji included » avec le lien `…/agent/handbook/commits.md:5` ; la question en français sur les releases a reçu une réponse en français avec les quatre étapes et la règle du mardi (`docs/release.md:1`) ; Kubernetes : trois recherches, aucun passage, « la documentation n'en parle pas ».
50+- Depuis un dossier sans `docs/` : `⚠️ docs: no such folder`, le manuel toujours cherché.
51+- La fenêtre et Zed n'ont pas été essayés en vrai.
52+- La ligne de démarrage `[warning: no skills found in …/no-skills …]` est attendue : cet agent n'a pas de skills.
new file mode 100644
@@ -0,0 +1,52 @@
1+# Démo docs-from-agent — une documentation livrée avec l'agent (`@agent/`)
2+
3+Tern répond à des questions sur la façon de travailler de l'équipe et sur le projet en cours. Il cherche dans deux dossiers avec `search_docs` :
4+
5+- **son propre manuel**, livré à côté de son fichier d'agent — `agent/handbook/` (messages de commit, revues de code) ;
6+- **la doc du projet où il tourne** — le `docs/` du répertoire de travail (ici `project/docs/` : releases, configuration).
7+
8+Le fichier d'agent vit dans `agent/`, mm tourne dans `project/`. Un dossier relatif de `docSearch.dirs` suit le répertoire de travail ; le préfixe `@agent/` (ticket 156) l'ancre plutôt sur le dossier du fichier d'agent :
9+
10+```yaml
11+docSearch:
12+ dirs:
13+ - "@agent/handbook" # à côté d'agent.yaml, d'où que mm soit lancé
14+ - docs # le docs/ du répertoire de travail
15+```
16+
17+Le préfixe est facultatif, et les guillemets sont obligatoires en YAML.
18+
19+English version: [README.en.md](README.en.md).
20+
21+| Fichier | Ce que c'est |
22+|---------|--------------|
23+| `agent/agent.yaml` | Tern : `provider: llamacpp`, `unsloth/Qwen3.5-4B-GGUF:Q4_K_M` (raisonnement coupé), `search_docs` et `/docs`, aucun autre outil |
24+| `agent/handbook/` | le manuel livré avec l'agent : `commits.md`, `reviews.md` |
25+| `project/docs/` | la doc propre au projet : `release.md`, `config.md` |
26+
27+## Avant de commencer
28+
29+Le modèle tourne sur llama-server en 127.0.0.1:9931 (l'application Llama, ou `llama-server` en mode routeur) avec `unsloth/Qwen3.5-4B-GGUF:Q4_K_M`.
30+
31+## Lancer la démo
32+
33+```bash
34+cd demos/docs-from-agent/project
35+../../../mm -config ../agent/agent.yaml # mode ligne
36+../../../mm -config ../agent/agent.yaml -tui # fenêtre
37+```
38+
39+1. `/docs commit subject` — les passages viennent de `agent/handbook/commits.md`, alors que mm tourne dans `project/`.
40+2. `/docs release tag` — le passage vient de `docs/release.md`, celui du projet.
41+3. Demandez à Tern : `How long can a commit subject be?` (manuel), `Comment je fais une release de ce projet ?` (projet), `How do I deploy to Kubernetes?` (ni l'un ni l'autre : Tern dit que la doc n'en parle pas).
42+4. Lancez mm depuis un dossier sans `docs/` : `/docs review` trouve toujours le manuel, et signale `⚠️ docs: no such folder`.
43+
44+Dans Zed : `AGENT_CONFIG=<chemin absolu>/demos/docs-from-agent/agent/agent.yaml`, args `["-acp"]`, et ouvrez `project/` — le manuel est trouvé depuis le fichier d'agent, la doc depuis le projet de l'éditeur.
45+
46+## Ce qui a été vérifié (26/11/2026, depuis un sandbox sbx, routeur llama-server sur le Mac)
47+
48+- `/docs` depuis `project/` : `commit subject` → 4 passages de `agent/handbook/commits.md` et un de `docs/release.md` ; `release tag` → `docs/release.md:1`. L'en-tête liste les deux dossiers : celui en `@agent/` résolu en chemin absolu, `docs` tel qu'écrit.
49+- `-p` avec Qwen3.5 4B : « 52 characters, emoji included » avec le lien `…/agent/handbook/commits.md:5` ; la question en français sur les releases a reçu une réponse en français avec les quatre étapes et la règle du mardi (`docs/release.md:1`) ; Kubernetes : trois recherches, aucun passage, « la documentation n'en parle pas ».
50+- Depuis un dossier sans `docs/` : `⚠️ docs: no such folder`, le manuel toujours cherché.
51+- La fenêtre et Zed n'ont pas été essayés en vrai.
52+- La ligne de démarrage `[warning: no skills found in …/no-skills …]` est attendue : cet agent n'a pas de skills.
added demos/docs-from-agent/agent/agent.yaml +68 -0
new file mode 100644
@@ -0,0 +1,68 @@
1+# Tern — a demo of docSearch.dirs "@agent/…" (ticket 156).
2+#
3+# Tern ships with its own handbook (agent/handbook/, beside this file) and
4+# also searches the docs of the project it runs in (docs/ of the working
5+# directory). mm runs in project/, the agent file lives in agent/:
6+#
7+# cd demos/docs-from-agent/project
8+# ../../../mm -config ../agent/agent.yaml line mode
9+# ../../../mm -config ../agent/agent.yaml -tui window
10+# ../../../mm -config ../agent/agent.yaml -p "How do I release this project?"
11+#
12+# See ../README.en.md.
13+
14+provider: llamacpp
15+# Qwen3.5 4B, thinking off. No baseUrl: llamacpp's defaults apply —
16+# 127.0.0.1:9931 (the Llama app), then 8080, then host.docker.internal:9931.
17+model: "unsloth/Qwen3.5-4B-GGUF:Q4_K_M"
18+
19+docSearch:
20+ # /docs <words>, for you.
21+ searchDocs: true
22+ # search_docs, for the model.
23+ autoSearchDocs: true
24+ dirs:
25+ # the handbook shipped with the agent: resolved against THIS file's
26+ # folder (agent/), wherever mm runs from
27+ - "@agent/handbook"
28+ # no prefix: the docs/ of the working directory — the project's own
29+ - docs
30+ extensions: [.md]
31+ maxFileSize: 1MB
32+
33+# Tern only searches and answers: no command, no file.
34+yolo: true
35+bashTool: false
36+editTools: false
37+planTool: false
38+fetchContentTool: false
39+askUserTool: false
40+skillsDir: no-skills
41+agentsMd:
42+ enabled: false
43+# The model is shared with your other agents: leave it loaded.
44+unloadOnExit: false
45+unloadModels: false
46+maxTurns: 6
47+firstTokenTimeout: 3m
48+
49+sampling:
50+ # family qwen, precise (measured with Qwen3.5 4B for document search)
51+ temperature: 0.0
52+ max_tokens: 2048
53+ parallel_tool_calls: false
54+ chat_template_kwargs:
55+ enable_thinking: false
56+
57+acp:
58+ name: tern
59+ title: "Tern (docs from the agent and the project)"
60+
61+system: |
62+ Your name is Tern. You answer questions about how the team works and
63+ about the current project. You know nothing about either by yourself:
64+ for each question, call search_docs first, with English words, and
65+ answer only from the passages it returns. End with the link of the
66+ passage you used (path:line). If search_docs finds nothing, try other
67+ words once, then say the docs do not cover it.
68+ Always answer in the language of the user's question, in a few lines.
new file mode 100644
@@ -0,0 +1,68 @@
1+# Tern — a demo of docSearch.dirs "@agent/…" (ticket 156).
2+#
3+# Tern ships with its own handbook (agent/handbook/, beside this file) and
4+# also searches the docs of the project it runs in (docs/ of the working
5+# directory). mm runs in project/, the agent file lives in agent/:
6+#
7+# cd demos/docs-from-agent/project
8+# ../../../mm -config ../agent/agent.yaml line mode
9+# ../../../mm -config ../agent/agent.yaml -tui window
10+# ../../../mm -config ../agent/agent.yaml -p "How do I release this project?"
11+#
12+# See ../README.en.md.
13+
14+provider: llamacpp
15+# Qwen3.5 4B, thinking off. No baseUrl: llamacpp's defaults apply —
16+# 127.0.0.1:9931 (the Llama app), then 8080, then host.docker.internal:9931.
17+model: "unsloth/Qwen3.5-4B-GGUF:Q4_K_M"
18+
19+docSearch:
20+ # /docs <words>, for you.
21+ searchDocs: true
22+ # search_docs, for the model.
23+ autoSearchDocs: true
24+ dirs:
25+ # the handbook shipped with the agent: resolved against THIS file's
26+ # folder (agent/), wherever mm runs from
27+ - "@agent/handbook"
28+ # no prefix: the docs/ of the working directory — the project's own
29+ - docs
30+ extensions: [.md]
31+ maxFileSize: 1MB
32+
33+# Tern only searches and answers: no command, no file.
34+yolo: true
35+bashTool: false
36+editTools: false
37+planTool: false
38+fetchContentTool: false
39+askUserTool: false
40+skillsDir: no-skills
41+agentsMd:
42+ enabled: false
43+# The model is shared with your other agents: leave it loaded.
44+unloadOnExit: false
45+unloadModels: false
46+maxTurns: 6
47+firstTokenTimeout: 3m
48+
49+sampling:
50+ # family qwen, precise (measured with Qwen3.5 4B for document search)
51+ temperature: 0.0
52+ max_tokens: 2048
53+ parallel_tool_calls: false
54+ chat_template_kwargs:
55+ enable_thinking: false
56+
57+acp:
58+ name: tern
59+ title: "Tern (docs from the agent and the project)"
60+
61+system: |
62+ Your name is Tern. You answer questions about how the team works and
63+ about the current project. You know nothing about either by yourself:
64+ for each question, call search_docs first, with English words, and
65+ answer only from the passages it returns. End with the link of the
66+ passage you used (path:line). If search_docs finds nothing, try other
67+ words once, then say the docs do not cover it.
68+ Always answer in the language of the user's question, in a few lines.
added demos/docs-from-agent/agent/handbook/commits.md +21 -0
new file mode 100644
@@ -0,0 +1,21 @@
1+# Commit messages (team handbook)
2+
3+The team writes every commit message the same way, in every repository.
4+
5+## The subject line
6+
7+- Start with one emoji that says what kind of change it is: ✨ feature, 🐛 fix,
8+ 📝 documentation, ♻️ refactor, 🎫 tickets.
9+- Then the imperative ("Add", "Fix", never "Added").
10+- At most 52 characters, emoji included. No final period.
11+
12+## The body
13+
14+- A blank line after the subject.
15+- Say **why**, not what: the diff already shows what.
16+- Name the ticket at the end of the subject, like `(#156)`.
17+
18+## Never
19+
20+- Never `git commit -m "wip"` on a shared branch.
21+- Never push without asking the repository's owner.
new file mode 100644
@@ -0,0 +1,21 @@
1+# Commit messages (team handbook)
2+
3+The team writes every commit message the same way, in every repository.
4+
5+## The subject line
6+
7+- Start with one emoji that says what kind of change it is: ✨ feature, 🐛 fix,
8+ 📝 documentation, ♻️ refactor, 🎫 tickets.
9+- Then the imperative ("Add", "Fix", never "Added").
10+- At most 52 characters, emoji included. No final period.
11+
12+## The body
13+
14+- A blank line after the subject.
15+- Say **why**, not what: the diff already shows what.
16+- Name the ticket at the end of the subject, like `(#156)`.
17+
18+## Never
19+
20+- Never `git commit -m "wip"` on a shared branch.
21+- Never push without asking the repository's owner.
added demos/docs-from-agent/agent/handbook/reviews.md +18 -0
new file mode 100644
@@ -0,0 +1,18 @@
1+# Code reviews (team handbook)
2+
3+## Who reviews
4+
5+Every change is reviewed by one person who did not write it. A change of more
6+than 400 lines is split before it is reviewed.
7+
8+## What a review checks
9+
10+1. The tests: a new behaviour has a test, and the test fails without the change.
11+2. The names: a reader understands the code without the ticket.
12+3. The documentation: a user-visible change updates the docs, in English and French.
13+
14+## Answering a review
15+
16+Answer every comment, even with "done". A reviewer approves only once all of
17+them are answered. A disagreement that two answers did not settle goes to a
18+short call, not to a third comment.
new file mode 100644
@@ -0,0 +1,18 @@
1+# Code reviews (team handbook)
2+
3+## Who reviews
4+
5+Every change is reviewed by one person who did not write it. A change of more
6+than 400 lines is split before it is reviewed.
7+
8+## What a review checks
9+
10+1. The tests: a new behaviour has a test, and the test fails without the change.
11+2. The names: a reader understands the code without the ticket.
12+3. The documentation: a user-visible change updates the docs, in English and French.
13+
14+## Answering a review
15+
16+Answer every comment, even with "done". A reviewer approves only once all of
17+them are answered. A disagreement that two answers did not settle goes to a
18+short call, not to a third comment.
added demos/docs-from-agent/project/docs/config.md +12 -0
new file mode 100644
@@ -0,0 +1,12 @@
1+# Configuring the weather CLI
2+
3+The CLI reads `~/.config/weather/config.toml`:
4+
5+```toml
6+city = "Lyon"
7+units = "metric" # or "imperial"
8+cache_minutes = 15
9+```
10+
11+`WEATHER_CITY` in the environment overrides `city`. Without a file, the CLI
12+asks for the city once and writes the file.
new file mode 100644
@@ -0,0 +1,12 @@
1+# Configuring the weather CLI
2+
3+The CLI reads `~/.config/weather/config.toml`:
4+
5+```toml
6+city = "Lyon"
7+units = "metric" # or "imperial"
8+cache_minutes = 15
9+```
10+
11+`WEATHER_CITY` in the environment overrides `city`. Without a file, the CLI
12+asks for the city once and writes the file.
added demos/docs-from-agent/project/docs/release.md +11 -0
new file mode 100644
@@ -0,0 +1,11 @@
1+# Releasing the weather CLI
2+
3+This is the project's own release procedure.
4+
5+1. Update `CHANGELOG.md`: move the "Unreleased" section under the new version.
6+2. Tag the commit `rel-YYYY.MM` (for example `rel-2026.11`) — never a `v` tag.
7+3. Run `make dist`: it builds the Linux and macOS archives into `dist/`.
8+4. Upload `dist/*.tar.gz` to the project's release page, then announce it in
9+ the `#weather` channel.
10+
11+A release is made on a Tuesday only, so that a fix can follow during the week.
new file mode 100644
@@ -0,0 +1,11 @@
1+# Releasing the weather CLI
2+
3+This is the project's own release procedure.
4+
5+1. Update `CHANGELOG.md`: move the "Unreleased" section under the new version.
6+2. Tag the commit `rel-YYYY.MM` (for example `rel-2026.11`) — never a `v` tag.
7+3. Run `make dist`: it builds the Linux and macOS archives into `dist/`.
8+4. Upload `dist/*.tar.gz` to the project's release page, then announce it in
9+ the `#weather` channel.
10+
11+A release is made on a Tuesday only, so that a fix can follow during the week.
modified demos/learning-rust/agent-config/agent.yaml +7 -10
@@ -1,7 +1,7 @@
11 # Tuto — an agent that answers with mini tutorials
2-provider: llmman
3-#model: hf.co/JetBrains/Mellum2.1-12B-A2.5B-Thinking-GGUF:Q4_K_M
4-model: hf.co/JetBrains/Mellum2-12B-A2.5B-Instruct-GGUF-Q8_0:Q8_0
2+provider: llamacpp
3+model: hf.co/JetBrains/Mellum2.1-12B-A2.5B-Thinking-GGUF:Q4_K_M
4+#model: hf.co/JetBrains/Mellum2-12B-A2.5B-Instruct-GGUF-Q8_0:Q8_0
55 baseUrl: http://127.0.0.1:17434/v1
66 fallback: http://host.docker.internal:17434/v1
77
@@ -43,13 +43,10 @@ skillsDir: no-skills
4343 docSearch:
4444 #searchDocs: true
4545 autoSearchDocs: true
46- # A relative dir is resolved against the working directory (workspace/),
47- # not against this file: the docs live in agent-config/, mounted read-only
48- # at the same path as on the host (as AGENT_CONFIG assumes).
49- # This absolute path is the author's machine: on yours, replace it with the
50- # absolute path of this demo's agent-config/docs folder, or the search finds
51- # nothing.
52- dirs: [/Users/k33g/kDrive/Rickub/bots-garden/mini-me/demos/learning-rust/agent-config/docs]
46+ # "@agent/docs": the docs/ beside this file (agent-config/docs), wherever
47+ # mm runs from — workspace/ here. A dir without the prefix would follow
48+ # the working directory instead.
49+ dirs: ["@agent/docs"]
5350 extensions: [.md]
5451 maxFileSize: 1MB
5552
@@ -1,7 +1,7 @@
1 # Tuto — an agent that answers with mini tutorials1 # Tuto — an agent that answers with mini tutorials
2-provider: llmman2+provider: llamacpp
3-#model: hf.co/JetBrains/Mellum2.1-12B-A2.5B-Thinking-GGUF:Q4_K_M3+model: hf.co/JetBrains/Mellum2.1-12B-A2.5B-Thinking-GGUF:Q4_K_M
4-model: hf.co/JetBrains/Mellum2-12B-A2.5B-Instruct-GGUF-Q8_0:Q8_04+#model: hf.co/JetBrains/Mellum2-12B-A2.5B-Instruct-GGUF-Q8_0:Q8_0
5 baseUrl: http://127.0.0.1:17434/v15 baseUrl: http://127.0.0.1:17434/v1
6 fallback: http://host.docker.internal:17434/v16 fallback: http://host.docker.internal:17434/v1
7 7
@@ -43,13 +43,10 @@ skillsDir: no-skills
43 docSearch:43 docSearch:
44 #searchDocs: true44 #searchDocs: true
45 autoSearchDocs: true45 autoSearchDocs: true
46- # A relative dir is resolved against the working directory (workspace/),46+ # "@agent/docs": the docs/ beside this file (agent-config/docs), wherever
47- # not against this file: the docs live in agent-config/, mounted read-only47+ # mm runs from — workspace/ here. A dir without the prefix would follow
48- # at the same path as on the host (as AGENT_CONFIG assumes).48+ # the working directory instead.
49- # This absolute path is the author's machine: on yours, replace it with the49+ dirs: ["@agent/docs"]
50- # absolute path of this demo's agent-config/docs folder, or the search finds
51- # nothing.
52- dirs: [/Users/k33g/kDrive/Rickub/bots-garden/mini-me/demos/learning-rust/agent-config/docs]
53 extensions: [.md]50 extensions: [.md]
54 maxFileSize: 1MB51 maxFileSize: 1MB
55 52
modified docs/en/how-to/search-the-docs.md +2 -1
@@ -55,7 +55,8 @@ The two switches are independent: `searchDocs` alone gives you the command and t
5555 ## Variants
5656
5757 - **Several folders, several formats.** `dirs: [docs, guides, /shared/handbook]`, `extensions: [.md, .adoc, .txt]`. Only the listed extensions are read.
58-- **Over ACP.** Relative folders are resolved against the session's `cwd`: the project the editor opened.
58+- **Docs shipped with the agent.** When the agent file lives apart from the project — `AGENT_CONFIG` or `-config` pointing at a folder of its own — write `dirs: ["@agent/docs", docs]`: `@agent/docs` is the `docs/` beside the agent file, `docs` the one of the project mm runs in. The quotes are needed in YAML. See `demos/docs-from-agent/`.
59+- **Over ACP.** Relative folders without `@agent/` are resolved against the session's `cwd`: the project the editor opened.
5960 - **Large files.** Files above `maxFileSize` (default `1MB`) are skipped; raise it, or split the file.
6061 - **Questions in another language.** The search matches words, not meanings. Documentation in English searched with French words finds nothing — ask the model to search with the documentation's words (see the prompt above), which a small model did reliably in `demos/docs-search/`.
6162
@@ -55,7 +55,8 @@ The two switches are independent: `searchDocs` alone gives you the command and t
55 ## Variants55 ## Variants
56 56
57 - **Several folders, several formats.** `dirs: [docs, guides, /shared/handbook]`, `extensions: [.md, .adoc, .txt]`. Only the listed extensions are read.57 - **Several folders, several formats.** `dirs: [docs, guides, /shared/handbook]`, `extensions: [.md, .adoc, .txt]`. Only the listed extensions are read.
58-- **Over ACP.** Relative folders are resolved against the session's `cwd`: the project the editor opened.58+- **Docs shipped with the agent.** When the agent file lives apart from the project — `AGENT_CONFIG` or `-config` pointing at a folder of its own — write `dirs: ["@agent/docs", docs]`: `@agent/docs` is the `docs/` beside the agent file, `docs` the one of the project mm runs in. The quotes are needed in YAML. See `demos/docs-from-agent/`.
59+- **Over ACP.** Relative folders without `@agent/` are resolved against the session's `cwd`: the project the editor opened.
59 - **Large files.** Files above `maxFileSize` (default `1MB`) are skipped; raise it, or split the file.60 - **Large files.** Files above `maxFileSize` (default `1MB`) are skipped; raise it, or split the file.
60 - **Questions in another language.** The search matches words, not meanings. Documentation in English searched with French words finds nothing — ask the model to search with the documentation's words (see the prompt above), which a small model did reliably in `demos/docs-search/`.61 - **Questions in another language.** The search matches words, not meanings. Documentation in English searched with French words finds nothing — ask the model to search with the documentation's words (see the prompt above), which a small model did reliably in `demos/docs-search/`.
61 62
modified docs/en/reference/configuration.md +1 -1
@@ -93,7 +93,7 @@ Either memory key set while `sessions.enabled` is false prints the start-up warn
9393 |-----|------|---------|-------------|
9494 | `docSearch.searchDocs` | bool | `false` | The `/docs <words>` command (terminal, window, editor). See [slash commands](slash-commands.md) and [How to search a documentation folder](../how-to/search-the-docs.md). |
9595 | `docSearch.autoSearchDocs` | bool | `false` | The [`search_docs`](tools.md#search_docs) tool: the same search, called by the model. Independent of `searchDocs`. |
96-| `docSearch.dirs` | list of strings | `[docs]` | The folders searched, recursively. A relative one is resolved against the working directory — the directory `mm` runs in, the session's `cwd` in ACP mode and the window; an absolute one is used as-is. A folder that does not exist is reported in the result (`⚠️ <dir>: no such folder`). |
96+| `docSearch.dirs` | list of strings | `[docs]` | The folders searched, recursively. A relative one is resolved against the working directory — the directory `mm` runs in, the session's `cwd` in ACP mode and the window; an absolute one is used as-is; one that starts with `"@agent/"` (quotes needed in YAML) is resolved when the file loads against the agent's folder — the folder of the agent file, or the project root for a `.mm/agent.yaml`, as for wasm modules and hooks: `"@agent/docs"` is the documentation shipped with the agent, wherever `mm` runs. The prefix is optional; both kinds combine: `["@agent/docs", docs]`. A `@agent/` folder is shown resolved (absolute) in the results. A folder that does not exist is reported in the result (`⚠️ <dir>: no such folder`). |
9797 | `docSearch.extensions` | list of strings | `[.md, .markdown, .txt, .adoc, .asciidoc, .rst]` | The files searched, by extension, compared without case. Only these are read. |
9898 | `docSearch.maxFileSize` | size | `1MB` | A bigger file is skipped. A number of bytes, or with `KB` / `MB` / `GB` (powers of 1024): `512KB`. |
9999
@@ -93,7 +93,7 @@ Either memory key set while `sessions.enabled` is false prints the start-up warn
93 |-----|------|---------|-------------|93 |-----|------|---------|-------------|
94 | `docSearch.searchDocs` | bool | `false` | The `/docs <words>` command (terminal, window, editor). See [slash commands](slash-commands.md) and [How to search a documentation folder](../how-to/search-the-docs.md). |94 | `docSearch.searchDocs` | bool | `false` | The `/docs <words>` command (terminal, window, editor). See [slash commands](slash-commands.md) and [How to search a documentation folder](../how-to/search-the-docs.md). |
95 | `docSearch.autoSearchDocs` | bool | `false` | The [`search_docs`](tools.md#search_docs) tool: the same search, called by the model. Independent of `searchDocs`. |95 | `docSearch.autoSearchDocs` | bool | `false` | The [`search_docs`](tools.md#search_docs) tool: the same search, called by the model. Independent of `searchDocs`. |
96-| `docSearch.dirs` | list of strings | `[docs]` | The folders searched, recursively. A relative one is resolved against the working directory — the directory `mm` runs in, the session's `cwd` in ACP mode and the window; an absolute one is used as-is. A folder that does not exist is reported in the result (`⚠️ <dir>: no such folder`). |96+| `docSearch.dirs` | list of strings | `[docs]` | The folders searched, recursively. A relative one is resolved against the working directory — the directory `mm` runs in, the session's `cwd` in ACP mode and the window; an absolute one is used as-is; one that starts with `"@agent/"` (quotes needed in YAML) is resolved when the file loads against the agent's folder — the folder of the agent file, or the project root for a `.mm/agent.yaml`, as for wasm modules and hooks: `"@agent/docs"` is the documentation shipped with the agent, wherever `mm` runs. The prefix is optional; both kinds combine: `["@agent/docs", docs]`. A `@agent/` folder is shown resolved (absolute) in the results. A folder that does not exist is reported in the result (`⚠️ <dir>: no such folder`). |
97 | `docSearch.extensions` | list of strings | `[.md, .markdown, .txt, .adoc, .asciidoc, .rst]` | The files searched, by extension, compared without case. Only these are read. |97 | `docSearch.extensions` | list of strings | `[.md, .markdown, .txt, .adoc, .asciidoc, .rst]` | The files searched, by extension, compared without case. Only these are read. |
98 | `docSearch.maxFileSize` | size | `1MB` | A bigger file is skipped. A number of bytes, or with `KB` / `MB` / `GB` (powers of 1024): `512KB`. |98 | `docSearch.maxFileSize` | size | `1MB` | A bigger file is skipped. A number of bytes, or with `KB` / `MB` / `GB` (powers of 1024): `512KB`. |
99 99
modified docs/fr/how-to/search-the-docs.md +2 -1
@@ -55,7 +55,8 @@ Les deux interrupteurs sont indépendants : `searchDocs` seul vous donne la comm
5555 ## Variantes
5656
5757 - **Plusieurs dossiers, plusieurs formats.** `dirs: [docs, guides, /shared/handbook]`, `extensions: [.md, .adoc, .txt]`. Seules les extensions listées sont lues.
58-- **En ACP.** Les dossiers relatifs sont résolus par rapport au `cwd` de la session : le projet ouvert dans l'éditeur.
58+- **Une doc livrée avec l'agent.** Quand le fichier d'agent vit à part du projet — `AGENT_CONFIG` ou `-config` qui pointe vers un dossier à lui —, écrivez `dirs: ["@agent/docs", docs]` : `@agent/docs` est le `docs/` à côté du fichier d'agent, `docs` celui du projet où mm tourne. Les guillemets sont obligatoires en YAML. Voir `demos/docs-from-agent/`.
59+- **En ACP.** Les dossiers relatifs sans `@agent/` sont résolus par rapport au `cwd` de la session : le projet ouvert dans l'éditeur.
5960 - **Gros fichiers.** Les fichiers au-delà de `maxFileSize` (`1MB` par défaut) sont ignorés ; augmentez la limite, ou découpez le fichier.
6061 - **Questions dans une autre langue.** La recherche porte sur les mots, pas sur le sens. Une documentation en anglais cherchée avec des mots français ne donne rien — demandez au modèle de chercher avec les mots de la documentation (voir le prompt ci-dessus), ce qu'un petit modèle a fait de façon fiable dans `demos/docs-search/`.
6162
@@ -55,7 +55,8 @@ Les deux interrupteurs sont indépendants : `searchDocs` seul vous donne la comm
55 ## Variantes55 ## Variantes
56 56
57 - **Plusieurs dossiers, plusieurs formats.** `dirs: [docs, guides, /shared/handbook]`, `extensions: [.md, .adoc, .txt]`. Seules les extensions listées sont lues.57 - **Plusieurs dossiers, plusieurs formats.** `dirs: [docs, guides, /shared/handbook]`, `extensions: [.md, .adoc, .txt]`. Seules les extensions listées sont lues.
58-- **En ACP.** Les dossiers relatifs sont résolus par rapport au `cwd` de la session : le projet ouvert dans l'éditeur.58+- **Une doc livrée avec l'agent.** Quand le fichier d'agent vit à part du projet — `AGENT_CONFIG` ou `-config` qui pointe vers un dossier à lui —, écrivez `dirs: ["@agent/docs", docs]` : `@agent/docs` est le `docs/` à côté du fichier d'agent, `docs` celui du projet où mm tourne. Les guillemets sont obligatoires en YAML. Voir `demos/docs-from-agent/`.
59+- **En ACP.** Les dossiers relatifs sans `@agent/` sont résolus par rapport au `cwd` de la session : le projet ouvert dans l'éditeur.
59 - **Gros fichiers.** Les fichiers au-delà de `maxFileSize` (`1MB` par défaut) sont ignorés ; augmentez la limite, ou découpez le fichier.60 - **Gros fichiers.** Les fichiers au-delà de `maxFileSize` (`1MB` par défaut) sont ignorés ; augmentez la limite, ou découpez le fichier.
60 - **Questions dans une autre langue.** La recherche porte sur les mots, pas sur le sens. Une documentation en anglais cherchée avec des mots français ne donne rien — demandez au modèle de chercher avec les mots de la documentation (voir le prompt ci-dessus), ce qu'un petit modèle a fait de façon fiable dans `demos/docs-search/`.61 - **Questions dans une autre langue.** La recherche porte sur les mots, pas sur le sens. Une documentation en anglais cherchée avec des mots français ne donne rien — demandez au modèle de chercher avec les mots de la documentation (voir le prompt ci-dessus), ce qu'un petit modèle a fait de façon fiable dans `demos/docs-search/`.
61 62
modified docs/fr/reference/configuration.md +1 -1
@@ -93,7 +93,7 @@ Une clé de mémoire activée alors que `sessions.enabled` vaut false affiche au
9393 |-----|------|--------|-------------|
9494 | `docSearch.searchDocs` | booléen | `false` | La commande `/docs <mots>` (terminal, fenêtre, éditeur). Voir [commandes](slash-commands.md) et [Chercher dans un dossier de documentation](../how-to/search-the-docs.md). |
9595 | `docSearch.autoSearchDocs` | booléen | `false` | L'outil [`search_docs`](tools.md#search_docs) : la même recherche, appelée par le modèle. Indépendante de `searchDocs`. |
96-| `docSearch.dirs` | liste de chaînes | `[docs]` | Les dossiers cherchés, récursivement. Un dossier relatif est résolu par rapport au répertoire de travail — celui où `mm` est lancé, le `cwd` de la session en mode ACP et dans la fenêtre ; un dossier absolu est utilisé tel quel. Un dossier qui n'existe pas est signalé dans le résultat (`⚠️ <rép>: no such folder`). |
96+| `docSearch.dirs` | liste de chaînes | `[docs]` | Les dossiers cherchés, récursivement. Un dossier relatif est résolu par rapport au répertoire de travail — celui où `mm` est lancé, le `cwd` de la session en mode ACP et dans la fenêtre ; un dossier absolu est utilisé tel quel ; un dossier qui commence par `"@agent/"` (guillemets obligatoires en YAML) est résolu au chargement par rapport au dossier de l'agent — le dossier du fichier d'agent, ou la racine du projet pour un `.mm/agent.yaml`, comme pour les modules wasm et les hooks : `"@agent/docs"` est la documentation livrée avec l'agent, d'où que `mm` soit lancé. Le préfixe est facultatif ; les deux sortes se combinent : `["@agent/docs", docs]`. Un dossier `@agent/` est affiché résolu (absolu) dans les résultats. Un dossier qui n'existe pas est signalé dans le résultat (`⚠️ <rép>: no such folder`). |
9797 | `docSearch.extensions` | liste de chaînes | `[.md, .markdown, .txt, .adoc, .asciidoc, .rst]` | Les fichiers cherchés, par extension, comparée sans tenir compte de la casse. Seuls ceux-là sont lus. |
9898 | `docSearch.maxFileSize` | taille | `1MB` | Un fichier plus gros est ignoré. Un nombre d'octets, ou avec `KB` / `MB` / `GB` (puissances de 1024) : `512KB`. |
9999
@@ -93,7 +93,7 @@ Une clé de mémoire activée alors que `sessions.enabled` vaut false affiche au
93 |-----|------|--------|-------------|93 |-----|------|--------|-------------|
94 | `docSearch.searchDocs` | booléen | `false` | La commande `/docs <mots>` (terminal, fenêtre, éditeur). Voir [commandes](slash-commands.md) et [Chercher dans un dossier de documentation](../how-to/search-the-docs.md). |94 | `docSearch.searchDocs` | booléen | `false` | La commande `/docs <mots>` (terminal, fenêtre, éditeur). Voir [commandes](slash-commands.md) et [Chercher dans un dossier de documentation](../how-to/search-the-docs.md). |
95 | `docSearch.autoSearchDocs` | booléen | `false` | L'outil [`search_docs`](tools.md#search_docs) : la même recherche, appelée par le modèle. Indépendante de `searchDocs`. |95 | `docSearch.autoSearchDocs` | booléen | `false` | L'outil [`search_docs`](tools.md#search_docs) : la même recherche, appelée par le modèle. Indépendante de `searchDocs`. |
96-| `docSearch.dirs` | liste de chaînes | `[docs]` | Les dossiers cherchés, récursivement. Un dossier relatif est résolu par rapport au répertoire de travail — celui où `mm` est lancé, le `cwd` de la session en mode ACP et dans la fenêtre ; un dossier absolu est utilisé tel quel. Un dossier qui n'existe pas est signalé dans le résultat (`⚠️ <rép>: no such folder`). |96+| `docSearch.dirs` | liste de chaînes | `[docs]` | Les dossiers cherchés, récursivement. Un dossier relatif est résolu par rapport au répertoire de travail — celui où `mm` est lancé, le `cwd` de la session en mode ACP et dans la fenêtre ; un dossier absolu est utilisé tel quel ; un dossier qui commence par `"@agent/"` (guillemets obligatoires en YAML) est résolu au chargement par rapport au dossier de l'agent — le dossier du fichier d'agent, ou la racine du projet pour un `.mm/agent.yaml`, comme pour les modules wasm et les hooks : `"@agent/docs"` est la documentation livrée avec l'agent, d'où que `mm` soit lancé. Le préfixe est facultatif ; les deux sortes se combinent : `["@agent/docs", docs]`. Un dossier `@agent/` est affiché résolu (absolu) dans les résultats. Un dossier qui n'existe pas est signalé dans le résultat (`⚠️ <rép>: no such folder`). |
97 | `docSearch.extensions` | liste de chaînes | `[.md, .markdown, .txt, .adoc, .asciidoc, .rst]` | Les fichiers cherchés, par extension, comparée sans tenir compte de la casse. Seuls ceux-là sont lus. |97 | `docSearch.extensions` | liste de chaînes | `[.md, .markdown, .txt, .adoc, .asciidoc, .rst]` | Les fichiers cherchés, par extension, comparée sans tenir compte de la casse. Seuls ceux-là sont lus. |
98 | `docSearch.maxFileSize` | taille | `1MB` | Un fichier plus gros est ignoré. Un nombre d'octets, ou avec `KB` / `MB` / `GB` (puissances de 1024) : `512KB`. |98 | `docSearch.maxFileSize` | taille | `1MB` | Un fichier plus gros est ignoré. Un nombre d'octets, ou avec `KB` / `MB` / `GB` (puissances de 1024) : `512KB`. |
99 99
modified internal/config/config.go +1 -0
@@ -1019,6 +1019,7 @@ func Load(cliPath string) (string, error) {
10191019 resolveRazorbillPaths(path)
10201020 resolveHooks(path)
10211021 resolveToolPaths(path)
1022+ resolveDocSearchPaths(path)
10221023 resolveDecider(path)
10231024 resolveToolDecider(path)
10241025 if err := Cfg.validate(); err != nil {
@@ -1019,6 +1019,7 @@ func Load(cliPath string) (string, error) {
1019 resolveRazorbillPaths(path)1019 resolveRazorbillPaths(path)
1020 resolveHooks(path)1020 resolveHooks(path)
1021 resolveToolPaths(path)1021 resolveToolPaths(path)
1022+ resolveDocSearchPaths(path)
1022 resolveDecider(path)1023 resolveDecider(path)
1023 resolveToolDecider(path)1024 resolveToolDecider(path)
1024 if err := Cfg.validate(); err != nil {1025 if err := Cfg.validate(); err != nil {
modified internal/config/docsearch.go +46 -2
@@ -3,6 +3,7 @@ package config
33 import (
44 "errors"
55 "fmt"
6+ "path/filepath"
67 "strconv"
78 "strings"
89
@@ -16,7 +17,8 @@ import (
1617 // docSearch:
1718 // searchDocs: true # the /docs <words> command, for the user
1819 // autoSearchDocs: true # the search_docs tool, for the model
19-// dirs: [docs] # relative to the working directory
20+// dirs: [docs, "@agent/docs"] # docs/ of the working directory, and the
21+// # docs/ shipped beside the agent file
2022 // extensions: [.md, .txt] # exactly the files searched
2123 // maxFileSize: 1MB # bigger files are skipped
2224 type DocSearchConfig struct {
@@ -28,7 +30,9 @@ type DocSearchConfig struct {
2830 AutoSearchDocs bool `yaml:"autoSearchDocs"`
2931 // Dirs: the folders searched, recursively. A relative one is resolved
3032 // against the working directory — the directory mm runs in, the
31- // session's cwd over ACP; an absolute one is used as-is.
33+ // session's cwd over ACP; an absolute one is used as-is; one that starts
34+ // with "@agent/" is resolved against the agent's folder (BaseDir) when
35+ // the file loads (ticket 156) — the docs that ship with the agent.
3236 Dirs []string `yaml:"dirs"`
3337 // Extensions: the files searched, by extension, compared without case.
3438 // Only these: nothing else is ever read.
@@ -38,6 +42,46 @@ type DocSearchConfig struct {
3842 MaxFileSize ByteSize `yaml:"maxFileSize"`
3943 }
4044
45+// AgentPrefix starts a docSearch.dirs entry that is relative to the agent's
46+// folder rather than to the working directory: "@agent/docs".
47+const AgentPrefix = "@agent"
48+
49+// resolveDocSearchPaths makes every "@agent/…" entry of docSearch.dirs
50+// absolute against the BaseDir of the agent file — its folder, or the
51+// project root for a .mm/agent.yaml, as for wasm modules and hooks. The
52+// other entries are left as written: relative ones still follow the
53+// working directory.
54+//
55+// dirs: ["@agent/docs", docs] // → [/path/to/agent-config/docs, docs]
56+func resolveDocSearchPaths(configPath string) {
57+ base := BaseDir(configPath)
58+ dirs := make([]string, len(Cfg.DocSearch.Dirs)) // never write into the defaults' slice
59+ for i, dir := range Cfg.DocSearch.Dirs {
60+ dirs[i] = dir
61+ if rest, ok := agentRelative(dir); ok {
62+ dirs[i] = filepath.Join(base, rest)
63+ }
64+ }
65+ Cfg.DocSearch.Dirs = dirs
66+}
67+
68+// agentRelative reports whether dir starts with the @agent prefix — alone,
69+// or followed by a separator — and returns what follows it. "@agents/x"
70+// and "@agentdocs" are ordinary relative names.
71+func agentRelative(dir string) (string, bool) {
72+ rest, ok := strings.CutPrefix(strings.TrimSpace(dir), AgentPrefix)
73+ if !ok {
74+ return "", false
75+ }
76+ if rest == "" {
77+ return ".", true
78+ }
79+ if rest[0] != '/' && rest[0] != '\\' {
80+ return "", false
81+ }
82+ return filepath.FromSlash(strings.TrimLeft(rest, `/\`)), true
83+}
84+
4185 // DocsCommand reports whether /docs is offered.
4286 //
4387 // command.SetDocs(config.Cfg.DocSearch.DocsCommand())
@@ -3,6 +3,7 @@ package config
3 import (3 import (
4 "errors"4 "errors"
5 "fmt"5 "fmt"
6+ "path/filepath"
6 "strconv"7 "strconv"
7 "strings"8 "strings"
8 9
@@ -16,7 +17,8 @@ import (
16 // docSearch:17 // docSearch:
17 // searchDocs: true # the /docs <words> command, for the user18 // searchDocs: true # the /docs <words> command, for the user
18 // autoSearchDocs: true # the search_docs tool, for the model19 // autoSearchDocs: true # the search_docs tool, for the model
19-// dirs: [docs] # relative to the working directory20+// dirs: [docs, "@agent/docs"] # docs/ of the working directory, and the
21+// # docs/ shipped beside the agent file
20 // extensions: [.md, .txt] # exactly the files searched22 // extensions: [.md, .txt] # exactly the files searched
21 // maxFileSize: 1MB # bigger files are skipped23 // maxFileSize: 1MB # bigger files are skipped
22 type DocSearchConfig struct {24 type DocSearchConfig struct {
@@ -28,7 +30,9 @@ type DocSearchConfig struct {
28 AutoSearchDocs bool `yaml:"autoSearchDocs"`30 AutoSearchDocs bool `yaml:"autoSearchDocs"`
29 // Dirs: the folders searched, recursively. A relative one is resolved31 // Dirs: the folders searched, recursively. A relative one is resolved
30 // against the working directory — the directory mm runs in, the32 // against the working directory — the directory mm runs in, the
31- // session's cwd over ACP; an absolute one is used as-is.33+ // session's cwd over ACP; an absolute one is used as-is; one that starts
34+ // with "@agent/" is resolved against the agent's folder (BaseDir) when
35+ // the file loads (ticket 156) — the docs that ship with the agent.
32 Dirs []string `yaml:"dirs"`36 Dirs []string `yaml:"dirs"`
33 // Extensions: the files searched, by extension, compared without case.37 // Extensions: the files searched, by extension, compared without case.
34 // Only these: nothing else is ever read.38 // Only these: nothing else is ever read.
@@ -38,6 +42,46 @@ type DocSearchConfig struct {
38 MaxFileSize ByteSize `yaml:"maxFileSize"`42 MaxFileSize ByteSize `yaml:"maxFileSize"`
39 }43 }
40 44
45+// AgentPrefix starts a docSearch.dirs entry that is relative to the agent's
46+// folder rather than to the working directory: "@agent/docs".
47+const AgentPrefix = "@agent"
48+
49+// resolveDocSearchPaths makes every "@agent/…" entry of docSearch.dirs
50+// absolute against the BaseDir of the agent file — its folder, or the
51+// project root for a .mm/agent.yaml, as for wasm modules and hooks. The
52+// other entries are left as written: relative ones still follow the
53+// working directory.
54+//
55+// dirs: ["@agent/docs", docs] // → [/path/to/agent-config/docs, docs]
56+func resolveDocSearchPaths(configPath string) {
57+ base := BaseDir(configPath)
58+ dirs := make([]string, len(Cfg.DocSearch.Dirs)) // never write into the defaults' slice
59+ for i, dir := range Cfg.DocSearch.Dirs {
60+ dirs[i] = dir
61+ if rest, ok := agentRelative(dir); ok {
62+ dirs[i] = filepath.Join(base, rest)
63+ }
64+ }
65+ Cfg.DocSearch.Dirs = dirs
66+}
67+
68+// agentRelative reports whether dir starts with the @agent prefix — alone,
69+// or followed by a separator — and returns what follows it. "@agents/x"
70+// and "@agentdocs" are ordinary relative names.
71+func agentRelative(dir string) (string, bool) {
72+ rest, ok := strings.CutPrefix(strings.TrimSpace(dir), AgentPrefix)
73+ if !ok {
74+ return "", false
75+ }
76+ if rest == "" {
77+ return ".", true
78+ }
79+ if rest[0] != '/' && rest[0] != '\\' {
80+ return "", false
81+ }
82+ return filepath.FromSlash(strings.TrimLeft(rest, `/\`)), true
83+}
84+
41 // DocsCommand reports whether /docs is offered.85 // DocsCommand reports whether /docs is offered.
42 //86 //
43 // command.SetDocs(config.Cfg.DocSearch.DocsCommand())87 // command.SetDocs(config.Cfg.DocSearch.DocsCommand())
added internal/config/docsearch_agent_test.go +77 -0
new file mode 100644
@@ -0,0 +1,77 @@
1+package config
2+
3+import (
4+ "os"
5+ "path/filepath"
6+ "testing"
7+)
8+
9+// TestDocSearchAgentPrefix checks ticket 156: an "@agent/…" entry of
10+// docSearch.dirs is made absolute against the agent's folder at load time;
11+// a relative entry still follows the working directory, an absolute one is
12+// kept.
13+func TestDocSearchAgentPrefix(t *testing.T) {
14+ defaults := Cfg
15+ t.Cleanup(func() { Cfg = defaults })
16+ root := t.TempDir()
17+ abs := filepath.Join(root, "elsewhere")
18+ cases := []struct {
19+ name, file, entry, want string
20+ }{
21+ {"prefixed", "agent-config/agent.yaml", "@agent/docs", filepath.Join(root, "agent-config", "docs")},
22+ {"prefixed, nested", "agent-config/agent.yaml", "@agent/a/b", filepath.Join(root, "agent-config", "a", "b")},
23+ {"prefix alone", "agent-config/agent.yaml", "@agent", filepath.Join(root, "agent-config")},
24+ {"prefix and slash", "agent-config/agent.yaml", "@agent/", filepath.Join(root, "agent-config")},
25+ {"parent of the agent", "agent-config/agent.yaml", "@agent/../shared", filepath.Join(root, "shared")},
26+ {".mm/agent.yaml: the project root", "proj/.mm/agent.yaml", "@agent/docs", filepath.Join(root, "proj", "docs")},
27+ {"relative: unchanged", "agent-config/agent.yaml", "docs", "docs"},
28+ {"absolute: unchanged", "agent-config/agent.yaml", abs, abs},
29+ {"not the prefix: @agents", "agent-config/agent.yaml", "@agents/docs", "@agents/docs"},
30+ {"not the prefix: @agentdocs", "agent-config/agent.yaml", "@agentdocs", "@agentdocs"},
31+ }
32+ for _, c := range cases {
33+ t.Run(c.name, func(t *testing.T) {
34+ Cfg = defaults
35+ Cfg.DocSearch.Dirs = append([]string(nil), defaults.DocSearch.Dirs...)
36+ path := filepath.Join(root, c.file)
37+ if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
38+ t.Fatal(err)
39+ }
40+ yaml := "docSearch:\n searchDocs: true\n dirs: [\"" + filepath.ToSlash(c.entry) + "\"]\n"
41+ if err := os.WriteFile(path, []byte(yaml), 0o644); err != nil {
42+ t.Fatal(err)
43+ }
44+ if _, err := Load(path); err != nil {
45+ t.Fatal(err)
46+ }
47+ got := Cfg.DocSearch.Dirs
48+ want := filepath.FromSlash(c.want)
49+ if c.entry == c.want { // unchanged entries keep their spelling
50+ want = c.entry
51+ }
52+ if len(got) != 1 || got[0] != want {
53+ t.Errorf("dirs = %q, want [%q]", got, want)
54+ }
55+ })
56+ }
57+}
58+
59+// TestDocSearchAgentPrefixMixed: the two kinds combine in one list, in order.
60+func TestDocSearchAgentPrefixMixed(t *testing.T) {
61+ defaults := Cfg
62+ t.Cleanup(func() { Cfg = defaults })
63+ dir := filepath.Join(t.TempDir(), "kit")
64+ if err := os.MkdirAll(dir, 0o755); err != nil {
65+ t.Fatal(err)
66+ }
67+ path := filepath.Join(dir, "agent.yaml")
68+ if err := os.WriteFile(path, []byte("docSearch:\n autoSearchDocs: true\n dirs: [\"@agent/docs\", docs]\n"), 0o644); err != nil {
69+ t.Fatal(err)
70+ }
71+ if _, err := Load(path); err != nil {
72+ t.Fatal(err)
73+ }
74+ if got := Cfg.DocSearch.Dirs; len(got) != 2 || got[0] != filepath.Join(dir, "docs") || got[1] != "docs" {
75+ t.Errorf("dirs = %q", got)
76+ }
77+}
new file mode 100644
@@ -0,0 +1,77 @@
1+package config
2+
3+import (
4+ "os"
5+ "path/filepath"
6+ "testing"
7+)
8+
9+// TestDocSearchAgentPrefix checks ticket 156: an "@agent/…" entry of
10+// docSearch.dirs is made absolute against the agent's folder at load time;
11+// a relative entry still follows the working directory, an absolute one is
12+// kept.
13+func TestDocSearchAgentPrefix(t *testing.T) {
14+ defaults := Cfg
15+ t.Cleanup(func() { Cfg = defaults })
16+ root := t.TempDir()
17+ abs := filepath.Join(root, "elsewhere")
18+ cases := []struct {
19+ name, file, entry, want string
20+ }{
21+ {"prefixed", "agent-config/agent.yaml", "@agent/docs", filepath.Join(root, "agent-config", "docs")},
22+ {"prefixed, nested", "agent-config/agent.yaml", "@agent/a/b", filepath.Join(root, "agent-config", "a", "b")},
23+ {"prefix alone", "agent-config/agent.yaml", "@agent", filepath.Join(root, "agent-config")},
24+ {"prefix and slash", "agent-config/agent.yaml", "@agent/", filepath.Join(root, "agent-config")},
25+ {"parent of the agent", "agent-config/agent.yaml", "@agent/../shared", filepath.Join(root, "shared")},
26+ {".mm/agent.yaml: the project root", "proj/.mm/agent.yaml", "@agent/docs", filepath.Join(root, "proj", "docs")},
27+ {"relative: unchanged", "agent-config/agent.yaml", "docs", "docs"},
28+ {"absolute: unchanged", "agent-config/agent.yaml", abs, abs},
29+ {"not the prefix: @agents", "agent-config/agent.yaml", "@agents/docs", "@agents/docs"},
30+ {"not the prefix: @agentdocs", "agent-config/agent.yaml", "@agentdocs", "@agentdocs"},
31+ }
32+ for _, c := range cases {
33+ t.Run(c.name, func(t *testing.T) {
34+ Cfg = defaults
35+ Cfg.DocSearch.Dirs = append([]string(nil), defaults.DocSearch.Dirs...)
36+ path := filepath.Join(root, c.file)
37+ if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
38+ t.Fatal(err)
39+ }
40+ yaml := "docSearch:\n searchDocs: true\n dirs: [\"" + filepath.ToSlash(c.entry) + "\"]\n"
41+ if err := os.WriteFile(path, []byte(yaml), 0o644); err != nil {
42+ t.Fatal(err)
43+ }
44+ if _, err := Load(path); err != nil {
45+ t.Fatal(err)
46+ }
47+ got := Cfg.DocSearch.Dirs
48+ want := filepath.FromSlash(c.want)
49+ if c.entry == c.want { // unchanged entries keep their spelling
50+ want = c.entry
51+ }
52+ if len(got) != 1 || got[0] != want {
53+ t.Errorf("dirs = %q, want [%q]", got, want)
54+ }
55+ })
56+ }
57+}
58+
59+// TestDocSearchAgentPrefixMixed: the two kinds combine in one list, in order.
60+func TestDocSearchAgentPrefixMixed(t *testing.T) {
61+ defaults := Cfg
62+ t.Cleanup(func() { Cfg = defaults })
63+ dir := filepath.Join(t.TempDir(), "kit")
64+ if err := os.MkdirAll(dir, 0o755); err != nil {
65+ t.Fatal(err)
66+ }
67+ path := filepath.Join(dir, "agent.yaml")
68+ if err := os.WriteFile(path, []byte("docSearch:\n autoSearchDocs: true\n dirs: [\"@agent/docs\", docs]\n"), 0o644); err != nil {
69+ t.Fatal(err)
70+ }
71+ if _, err := Load(path); err != nil {
72+ t.Fatal(err)
73+ }
74+ if got := Cfg.DocSearch.Dirs; len(got) != 2 || got[0] != filepath.Join(dir, "docs") || got[1] != "docs" {
75+ t.Errorf("dirs = %q", got)
76+ }
77+}