🧪 Demos: dynamic-rules (WIP experiment), diagrams for the memory demos
dynamic-rules: only the rules a question needs — a preGeneration hook adds the matching rules/*.md next to the question, compared with rules as skills and all rules in the system prompt (Qwen3.5 4B, rules followed 6/6, 104–223 prompt tokens against ~500). memory-skills and memory-skills-2: draw.io diagrams (svg in the READMEs) and a WIP banner. Ticket 19 updated (the user's edit). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0eac53d parent: f05dfe0 modified
.tickets/issues/0019-try-to-auto-improve-the-source-code-of-mini-me-w.yaml +2 -2 | @@ -1,12 +1,12 @@ | ||
| 1 | 1 | # Managed by IssueSpec. Hand edits are welcome; keep the schema valid. |
| 2 | 2 | id: 19 |
| 3 | 3 | title: Try to "auto improve" the source code of Mini Me with Claude and local model at the same time |
| 4 | -state: open | |
| 4 | +state: closed | |
| 5 | 5 | author: |
| 6 | 6 | name: k33g |
| 7 | 7 | email: ph.charriere@gmail.com |
| 8 | 8 | createdAt: 2026-09-17T13:22:40.786Z |
| 9 | -updatedAt: 2026-11-11T06:51:08.000Z | |
| 9 | +updatedAt: 2026-11-27T04:24:09.408Z | |
| 10 | 10 | labels: |
| 11 | 11 | - priority::low |
| 12 | 12 | - kind::chore |
| @@ -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: 19 | 2 | id: 19 |
| 3 | title: Try to "auto improve" the source code of Mini Me with Claude and local model at the same time | 3 | title: Try to "auto improve" the source code of Mini Me with Claude and local model at the same time |
| 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-09-17T13:22:40.786Z | 8 | createdAt: 2026-09-17T13:22:40.786Z |
| 9 | -updatedAt: 2026-11-11T06:51:08.000Z | 9 | +updatedAt: 2026-11-27T04:24:09.408Z |
| 10 | labels: | 10 | labels: |
| 11 | - priority::low | 11 | - priority::low |
| 12 | - kind::chore | 12 | - kind::chore |
modified
README.md +3 -2 | @@ -193,10 +193,11 @@ The `demos/` directory holds ready-made set-ups (most with a README explaining h | ||
| 193 | 193 | | `demos/unload-models/` | a coordinator (Qwen3.5 9B) hands programming questions to an expert (Qwen3.5 4B) with `ask_agent`, a `preAsk` hook unloads the coordinator's own model before the expert starts and a `postAsk` hook unloads the expert's once it has answered — the two models are never loaded together; `/unload` and `unload_model` on request; llmman, measured results | |
| 194 | 194 | | `demos/plans/` | the `plan` tool at work: Planner (Qwen3.5 4B on llmman) builds a tiny Go program in four steps — module, code, test, README — while mm shows `📋 [C/N] …` after each plan action; a failing variant ends on `Plan finished: 2 done, 1 failed`; measured results | |
| 195 | 195 | | `demos/docs-from-agent/` | `docSearch.dirs: ["@agent/handbook", docs]`: a handbook shipped beside the agent file plus the docs of the project mm runs in, searched together; Qwen3.5 4B on llama.cpp | |
| 196 | +| `demos/dynamic-rules/` | WIP experiment — a short system prompt and only the rules a question needs: a `preGeneration` hook adds the matching rules next to the question, compared with rules as skills and all rules in `system` (rules followed, tokens: 104–223 against ~500); Qwen3.5 4B on llama.cpp | | |
| 196 | 197 | | `demos/how-to-use-mini-me/` | Owl, a guide to configuring mm made of 16 small skills (keys, defaults, a YAML example, links to the docs on the repository), fetching the linked guide when asked for more; Qwen3.5 4B on llama.cpp, 25/25 right skills | |
| 197 | 198 | | `demos/meta-prompts/` | your own meta-prompts in the window's `[` picker (`metaPrompts:` — added, or rewording a built-in), and why `system` must explain them: measured with and without, Qwen3.5 4B on llama.cpp | |
| 198 | -| `demos/memory-skills/` | a memory from one conversation to the next made of three skills (`remember`, `recall`, `forget`) over `.mm/memory.md`, no mm code; Qwen3.5 4B on llama.cpp, measured on 8 questions | | |
| 199 | -| `demos/memory-skills-2/` | the same memory always in the prompt (`agentsMd.path: .mm/memory.md`), a `recall` skill with no tool, no mm code; 8/8 after four measured runs, compared with `memory-skills` | | |
| 199 | +| `demos/memory-skills/` | WIP experiment — a memory from one conversation to the next made of three skills (`remember`, `recall`, `forget`) over `.mm/memory.md`, no mm code; Qwen3.5 4B on llama.cpp, measured on 8 questions | | |
| 200 | +| `demos/memory-skills-2/` | WIP experiment — the same memory always in the prompt (`agentsMd.path: .mm/memory.md`), a `recall` skill with no tool, no mm code; 8/8 after four measured runs, compared with `memory-skills` | | |
| 200 | 201 | | `demos/docs-search/` | an assistant answering from a documentation folder: nine Ratatui tutorials (Rust terminal UIs, each program checked against ratatui 0.30 by `check-tutorials.sh`), `/docs <words>` for you and the `search_docs` tool for the model; Qwen3.5 4B on llmman, measured results | |
| 201 | 202 | | `demos/memory-search/` | an assistant that remembers a project's decisions: four earlier sessions (port, storage, logs in French, deployment as a `/compact` summary), `/memory <words>` for you and the `search_memory` tool for the model; Qwen3.5 4B on llmman, measured results — including what a word search cannot find | |
| 202 | 203 | | `demos/declared-tools/` | an ops desk with no `bash` and no skills, acting only through four tools declared under `tools:` — release, version bump, service logs, slow requests — covering every parameter type (string, enum, boolean, integer, number), a safe default (`dryRun: true`) and an optional argument; Mellum2 12B on DMR, measured results | |
| @@ -193,10 +193,11 @@ The `demos/` directory holds ready-made set-ups (most with a README explaining h | |||
| 193 | | `demos/unload-models/` | a coordinator (Qwen3.5 9B) hands programming questions to an expert (Qwen3.5 4B) with `ask_agent`, a `preAsk` hook unloads the coordinator's own model before the expert starts and a `postAsk` hook unloads the expert's once it has answered — the two models are never loaded together; `/unload` and `unload_model` on request; llmman, measured results | | 193 | | `demos/unload-models/` | a coordinator (Qwen3.5 9B) hands programming questions to an expert (Qwen3.5 4B) with `ask_agent`, a `preAsk` hook unloads the coordinator's own model before the expert starts and a `postAsk` hook unloads the expert's once it has answered — the two models are never loaded together; `/unload` and `unload_model` on request; llmman, measured results | |
| 194 | | `demos/plans/` | the `plan` tool at work: Planner (Qwen3.5 4B on llmman) builds a tiny Go program in four steps — module, code, test, README — while mm shows `📋 [C/N] …` after each plan action; a failing variant ends on `Plan finished: 2 done, 1 failed`; measured results | | 194 | | `demos/plans/` | the `plan` tool at work: Planner (Qwen3.5 4B on llmman) builds a tiny Go program in four steps — module, code, test, README — while mm shows `📋 [C/N] …` after each plan action; a failing variant ends on `Plan finished: 2 done, 1 failed`; measured results | |
| 195 | | `demos/docs-from-agent/` | `docSearch.dirs: ["@agent/handbook", docs]`: a handbook shipped beside the agent file plus the docs of the project mm runs in, searched together; Qwen3.5 4B on llama.cpp | | 195 | | `demos/docs-from-agent/` | `docSearch.dirs: ["@agent/handbook", docs]`: a handbook shipped beside the agent file plus the docs of the project mm runs in, searched together; Qwen3.5 4B on llama.cpp | |
| 196 | +| `demos/dynamic-rules/` | WIP experiment — a short system prompt and only the rules a question needs: a `preGeneration` hook adds the matching rules next to the question, compared with rules as skills and all rules in `system` (rules followed, tokens: 104–223 against ~500); Qwen3.5 4B on llama.cpp | | ||
| 196 | | `demos/how-to-use-mini-me/` | Owl, a guide to configuring mm made of 16 small skills (keys, defaults, a YAML example, links to the docs on the repository), fetching the linked guide when asked for more; Qwen3.5 4B on llama.cpp, 25/25 right skills | | 197 | | `demos/how-to-use-mini-me/` | Owl, a guide to configuring mm made of 16 small skills (keys, defaults, a YAML example, links to the docs on the repository), fetching the linked guide when asked for more; Qwen3.5 4B on llama.cpp, 25/25 right skills | |
| 197 | | `demos/meta-prompts/` | your own meta-prompts in the window's `[` picker (`metaPrompts:` — added, or rewording a built-in), and why `system` must explain them: measured with and without, Qwen3.5 4B on llama.cpp | | 198 | | `demos/meta-prompts/` | your own meta-prompts in the window's `[` picker (`metaPrompts:` — added, or rewording a built-in), and why `system` must explain them: measured with and without, Qwen3.5 4B on llama.cpp | |
| 198 | -| `demos/memory-skills/` | a memory from one conversation to the next made of three skills (`remember`, `recall`, `forget`) over `.mm/memory.md`, no mm code; Qwen3.5 4B on llama.cpp, measured on 8 questions | | 199 | +| `demos/memory-skills/` | WIP experiment — a memory from one conversation to the next made of three skills (`remember`, `recall`, `forget`) over `.mm/memory.md`, no mm code; Qwen3.5 4B on llama.cpp, measured on 8 questions | |
| 199 | -| `demos/memory-skills-2/` | the same memory always in the prompt (`agentsMd.path: .mm/memory.md`), a `recall` skill with no tool, no mm code; 8/8 after four measured runs, compared with `memory-skills` | | 200 | +| `demos/memory-skills-2/` | WIP experiment — the same memory always in the prompt (`agentsMd.path: .mm/memory.md`), a `recall` skill with no tool, no mm code; 8/8 after four measured runs, compared with `memory-skills` | |
| 200 | | `demos/docs-search/` | an assistant answering from a documentation folder: nine Ratatui tutorials (Rust terminal UIs, each program checked against ratatui 0.30 by `check-tutorials.sh`), `/docs <words>` for you and the `search_docs` tool for the model; Qwen3.5 4B on llmman, measured results | | 201 | | `demos/docs-search/` | an assistant answering from a documentation folder: nine Ratatui tutorials (Rust terminal UIs, each program checked against ratatui 0.30 by `check-tutorials.sh`), `/docs <words>` for you and the `search_docs` tool for the model; Qwen3.5 4B on llmman, measured results | |
| 201 | | `demos/memory-search/` | an assistant that remembers a project's decisions: four earlier sessions (port, storage, logs in French, deployment as a `/compact` summary), `/memory <words>` for you and the `search_memory` tool for the model; Qwen3.5 4B on llmman, measured results — including what a word search cannot find | | 202 | | `demos/memory-search/` | an assistant that remembers a project's decisions: four earlier sessions (port, storage, logs in French, deployment as a `/compact` summary), `/memory <words>` for you and the `search_memory` tool for the model; Qwen3.5 4B on llmman, measured results — including what a word search cannot find | |
| 202 | | `demos/declared-tools/` | an ops desk with no `bash` and no skills, acting only through four tools declared under `tools:` — release, version bump, service logs, slow requests — covering every parameter type (string, enum, boolean, integer, number), a safe default (`dryRun: true`) and an optional argument; Mellum2 12B on DMR, measured results | | 203 | | `demos/declared-tools/` | an ops desk with no `bash` and no skills, acting only through four tools declared under `tools:` — release, version bump, service logs, slow requests — covering every parameter type (string, enum, boolean, integer, number), a safe default (`dryRun: true`) and an optional argument; Mellum2 12B on DMR, measured results | |
added
demos/dynamic-rules/.gitignore +3 -0 | new file mode 100644 | ||
| @@ -0,0 +1,3 @@ | ||
| 1 | +!.mm | |
| 2 | +.mm/sessions | |
| 3 | +.mm/traces | |
| new file mode 100644 | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | +!.mm | ||
| 2 | +.mm/sessions | ||
| 3 | +.mm/traces | ||
added
demos/dynamic-rules/.mm/agent.skills.yaml +56 -0 | new file mode 100644 | ||
| @@ -0,0 +1,56 @@ | ||
| 1 | +# Rook — dynamic rules as skills: the model loads the rule it needs. | |
| 2 | +# | |
| 3 | +# Same rules/*.md files: here the folder is the skills folder. Each rule is a | |
| 4 | +# skill (name, description, keywords); the model calls read_skill for the | |
| 5 | +# one a request needs, before it writes the code. | |
| 6 | +# | |
| 7 | +# cd demos/dynamic-rules | |
| 8 | +# ../../mm -config .mm/agent.skills.yaml -p "Write tests for Add(a, b int) int." | |
| 9 | +# | |
| 10 | +# See ../README.en.md. | |
| 11 | + | |
| 12 | +provider: llamacpp | |
| 13 | +# Qwen3.5 4B, thinking off. No baseUrl: llamacpp's defaults apply — | |
| 14 | +# 127.0.0.1:9931 (the Llama app), then 8080, then host.docker.internal:9931. | |
| 15 | +model: "unsloth/Qwen3.5-4B-GGUF:Q4_K_M" | |
| 16 | + | |
| 17 | +# Rook only writes code in its answers: no command, no file. | |
| 18 | +bashTool: false | |
| 19 | +editTools: false | |
| 20 | +planTool: false | |
| 21 | +fetchContentTool: false | |
| 22 | +askUserTool: false | |
| 23 | +agentsMd: | |
| 24 | + enabled: false | |
| 25 | +yolo: true | |
| 26 | +# The model is shared with your other agents: leave it loaded. | |
| 27 | +unloadOnExit: false | |
| 28 | +unloadModels: false | |
| 29 | +maxTurns: 4 | |
| 30 | +firstTokenTimeout: 3m | |
| 31 | + | |
| 32 | +sampling: | |
| 33 | + # family qwen, precise: rules are to be followed, not reinterpreted | |
| 34 | + temperature: 0.0 | |
| 35 | + max_tokens: 2048 | |
| 36 | + parallel_tool_calls: false | |
| 37 | + chat_template_kwargs: | |
| 38 | + enable_thinking: false | |
| 39 | + | |
| 40 | +# The rule that ALWAYS applies, next to every question (not in system: a | |
| 41 | +# small model follows a rule next to the question far more often). | |
| 42 | +turnReminder: "After the code block, write one sentence, then a last line with only: — Rook" | |
| 43 | + | |
| 44 | +# The rules, relative to the folder mm runs in (demos/dynamic-rules). | |
| 45 | +skillsDir: rules | |
| 46 | + | |
| 47 | +acp: | |
| 48 | + name: rook-skills | |
| 49 | + title: "Rook (rules as skills)" | |
| 50 | + | |
| 51 | +system: | | |
| 52 | + Your name is Rook. You write Go code for a team that has its own rules. | |
| 53 | + Answer with one short Go code block and one or two sentences, no more. | |
| 54 | + The team's rules are skills: before you write any code, call read_skill | |
| 55 | + with each rule that concerns it (errors, logging, tests, http, config), | |
| 56 | + and follow what it says exactly. | |
| new file mode 100644 | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | +# Rook — dynamic rules as skills: the model loads the rule it needs. | ||
| 2 | +# | ||
| 3 | +# Same rules/*.md files: here the folder is the skills folder. Each rule is a | ||
| 4 | +# skill (name, description, keywords); the model calls read_skill for the | ||
| 5 | +# one a request needs, before it writes the code. | ||
| 6 | +# | ||
| 7 | +# cd demos/dynamic-rules | ||
| 8 | +# ../../mm -config .mm/agent.skills.yaml -p "Write tests for Add(a, b int) int." | ||
| 9 | +# | ||
| 10 | +# See ../README.en.md. | ||
| 11 | + | ||
| 12 | +provider: llamacpp | ||
| 13 | +# Qwen3.5 4B, thinking off. No baseUrl: llamacpp's defaults apply — | ||
| 14 | +# 127.0.0.1:9931 (the Llama app), then 8080, then host.docker.internal:9931. | ||
| 15 | +model: "unsloth/Qwen3.5-4B-GGUF:Q4_K_M" | ||
| 16 | + | ||
| 17 | +# Rook only writes code in its answers: no command, no file. | ||
| 18 | +bashTool: false | ||
| 19 | +editTools: false | ||
| 20 | +planTool: false | ||
| 21 | +fetchContentTool: false | ||
| 22 | +askUserTool: false | ||
| 23 | +agentsMd: | ||
| 24 | + enabled: false | ||
| 25 | +yolo: true | ||
| 26 | +# The model is shared with your other agents: leave it loaded. | ||
| 27 | +unloadOnExit: false | ||
| 28 | +unloadModels: false | ||
| 29 | +maxTurns: 4 | ||
| 30 | +firstTokenTimeout: 3m | ||
| 31 | + | ||
| 32 | +sampling: | ||
| 33 | + # family qwen, precise: rules are to be followed, not reinterpreted | ||
| 34 | + temperature: 0.0 | ||
| 35 | + max_tokens: 2048 | ||
| 36 | + parallel_tool_calls: false | ||
| 37 | + chat_template_kwargs: | ||
| 38 | + enable_thinking: false | ||
| 39 | + | ||
| 40 | +# The rule that ALWAYS applies, next to every question (not in system: a | ||
| 41 | +# small model follows a rule next to the question far more often). | ||
| 42 | +turnReminder: "After the code block, write one sentence, then a last line with only: — Rook" | ||
| 43 | + | ||
| 44 | +# The rules, relative to the folder mm runs in (demos/dynamic-rules). | ||
| 45 | +skillsDir: rules | ||
| 46 | + | ||
| 47 | +acp: | ||
| 48 | + name: rook-skills | ||
| 49 | + title: "Rook (rules as skills)" | ||
| 50 | + | ||
| 51 | +system: | | ||
| 52 | + Your name is Rook. You write Go code for a team that has its own rules. | ||
| 53 | + Answer with one short Go code block and one or two sentences, no more. | ||
| 54 | + The team's rules are skills: before you write any code, call read_skill | ||
| 55 | + with each rule that concerns it (errors, logging, tests, http, config), | ||
| 56 | + and follow what it says exactly. | ||
added
demos/dynamic-rules/.mm/agent.static.yaml +105 -0 | new file mode 100644 | ||
| @@ -0,0 +1,105 @@ | ||
| 1 | +# Rook — every rule in the system prompt (the baseline, for comparison). | |
| 2 | +# | |
| 3 | +# The five rules of rules/*.md written once in `system`, the sign-off rule | |
| 4 | +# too: what an agent file looks like without dynamic rules. Every question | |
| 5 | +# pays for every rule. | |
| 6 | +# | |
| 7 | +# cd demos/dynamic-rules | |
| 8 | +# ../../mm -config .mm/agent.static.yaml -p "Write a Go function that logs a job." | |
| 9 | +# | |
| 10 | +# See ../README.en.md. | |
| 11 | + | |
| 12 | +provider: llamacpp | |
| 13 | +# Qwen3.5 4B, thinking off. No baseUrl: llamacpp's defaults apply — | |
| 14 | +# 127.0.0.1:9931 (the Llama app), then 8080, then host.docker.internal:9931. | |
| 15 | +model: "unsloth/Qwen3.5-4B-GGUF:Q4_K_M" | |
| 16 | + | |
| 17 | +# Rook only writes code in its answers: no command, no file. | |
| 18 | +bashTool: false | |
| 19 | +editTools: false | |
| 20 | +planTool: false | |
| 21 | +fetchContentTool: false | |
| 22 | +askUserTool: false | |
| 23 | +agentsMd: | |
| 24 | + enabled: false | |
| 25 | +yolo: true | |
| 26 | +# The model is shared with your other agents: leave it loaded. | |
| 27 | +unloadOnExit: false | |
| 28 | +unloadModels: false | |
| 29 | +maxTurns: 4 | |
| 30 | +firstTokenTimeout: 3m | |
| 31 | + | |
| 32 | +sampling: | |
| 33 | + # family qwen, precise: rules are to be followed, not reinterpreted | |
| 34 | + temperature: 0.0 | |
| 35 | + max_tokens: 2048 | |
| 36 | + parallel_tool_calls: false | |
| 37 | + chat_template_kwargs: | |
| 38 | + enable_thinking: false | |
| 39 | + | |
| 40 | +skillsDir: no-skills | |
| 41 | + | |
| 42 | +acp: | |
| 43 | + name: rook-static | |
| 44 | + title: "Rook (rules in the system prompt)" | |
| 45 | + | |
| 46 | +system: | | |
| 47 | + Your name is Rook. You write Go code for a team that has its own rules. | |
| 48 | + Answer with one short Go code block and one or two sentences, no more. | |
| 49 | + Follow the team's rules below exactly. | |
| 50 | + After the code block, write one sentence, then a last line with only: — Rook | |
| 51 | + | |
| 52 | + # Rule: config | |
| 53 | + | |
| 54 | + Read the settings from environment variables prefixed `APP_`, with `os.Getenv`: | |
| 55 | + | |
| 56 | + port := os.Getenv("APP_PORT") | |
| 57 | + if port == "" { | |
| 58 | + return Config{}, errors.New("APP_PORT is not set") | |
| 59 | + } | |
| 60 | + | |
| 61 | + A missing required variable is an error that names it. No config file. | |
| 62 | + | |
| 63 | + # Rule: errors | |
| 64 | + | |
| 65 | + Wrap every error you return with what failed, using `%w`: | |
| 66 | + | |
| 67 | + return nil, fmt.Errorf("read %s: %w", path, err) | |
| 68 | + | |
| 69 | + Never return a bare `err`. Never call `log.Fatal` or `panic` in a function that can return an error. | |
| 70 | + | |
| 71 | + # Rule: http | |
| 72 | + | |
| 73 | + Create every request with a context, and send it with a client that has a timeout: | |
| 74 | + | |
| 75 | + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) | |
| 76 | + client := &http.Client{Timeout: 10 * time.Second} | |
| 77 | + resp, err := client.Do(req) | |
| 78 | + | |
| 79 | + Never `http.Get` or `http.DefaultClient`. Close the body with `defer resp.Body.Close()`. | |
| 80 | + | |
| 81 | + # Rule: logging | |
| 82 | + | |
| 83 | + Log with the standard `log/slog` package, as key-value pairs: | |
| 84 | + | |
| 85 | + slog.Info("job started", "job", name) | |
| 86 | + slog.Error("job failed", "job", name, "err", err) | |
| 87 | + | |
| 88 | + Never `fmt.Println` or the `log` package for logs. | |
| 89 | + | |
| 90 | + # Rule: tests | |
| 91 | + | |
| 92 | + Write table-driven tests: a slice of cases, one `t.Run` per case. | |
| 93 | + | |
| 94 | + tests := []struct { | |
| 95 | + name string | |
| 96 | + a, b int | |
| 97 | + want int | |
| 98 | + }{ | |
| 99 | + {"zero", 0, 0, 0}, | |
| 100 | + } | |
| 101 | + for _, tt := range tests { | |
| 102 | + t.Run(tt.name, func(t *testing.T) { … }) | |
| 103 | + } | |
| 104 | + | |
| 105 | + Put the tests in the `_test` package (`package calc_test`). | |
| new file mode 100644 | |||
| @@ -0,0 +1,105 @@ | |||
| 1 | +# Rook — every rule in the system prompt (the baseline, for comparison). | ||
| 2 | +# | ||
| 3 | +# The five rules of rules/*.md written once in `system`, the sign-off rule | ||
| 4 | +# too: what an agent file looks like without dynamic rules. Every question | ||
| 5 | +# pays for every rule. | ||
| 6 | +# | ||
| 7 | +# cd demos/dynamic-rules | ||
| 8 | +# ../../mm -config .mm/agent.static.yaml -p "Write a Go function that logs a job." | ||
| 9 | +# | ||
| 10 | +# See ../README.en.md. | ||
| 11 | + | ||
| 12 | +provider: llamacpp | ||
| 13 | +# Qwen3.5 4B, thinking off. No baseUrl: llamacpp's defaults apply — | ||
| 14 | +# 127.0.0.1:9931 (the Llama app), then 8080, then host.docker.internal:9931. | ||
| 15 | +model: "unsloth/Qwen3.5-4B-GGUF:Q4_K_M" | ||
| 16 | + | ||
| 17 | +# Rook only writes code in its answers: no command, no file. | ||
| 18 | +bashTool: false | ||
| 19 | +editTools: false | ||
| 20 | +planTool: false | ||
| 21 | +fetchContentTool: false | ||
| 22 | +askUserTool: false | ||
| 23 | +agentsMd: | ||
| 24 | + enabled: false | ||
| 25 | +yolo: true | ||
| 26 | +# The model is shared with your other agents: leave it loaded. | ||
| 27 | +unloadOnExit: false | ||
| 28 | +unloadModels: false | ||
| 29 | +maxTurns: 4 | ||
| 30 | +firstTokenTimeout: 3m | ||
| 31 | + | ||
| 32 | +sampling: | ||
| 33 | + # family qwen, precise: rules are to be followed, not reinterpreted | ||
| 34 | + temperature: 0.0 | ||
| 35 | + max_tokens: 2048 | ||
| 36 | + parallel_tool_calls: false | ||
| 37 | + chat_template_kwargs: | ||
| 38 | + enable_thinking: false | ||
| 39 | + | ||
| 40 | +skillsDir: no-skills | ||
| 41 | + | ||
| 42 | +acp: | ||
| 43 | + name: rook-static | ||
| 44 | + title: "Rook (rules in the system prompt)" | ||
| 45 | + | ||
| 46 | +system: | | ||
| 47 | + Your name is Rook. You write Go code for a team that has its own rules. | ||
| 48 | + Answer with one short Go code block and one or two sentences, no more. | ||
| 49 | + Follow the team's rules below exactly. | ||
| 50 | + After the code block, write one sentence, then a last line with only: — Rook | ||
| 51 | + | ||
| 52 | + # Rule: config | ||
| 53 | + | ||
| 54 | + Read the settings from environment variables prefixed `APP_`, with `os.Getenv`: | ||
| 55 | + | ||
| 56 | + port := os.Getenv("APP_PORT") | ||
| 57 | + if port == "" { | ||
| 58 | + return Config{}, errors.New("APP_PORT is not set") | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + A missing required variable is an error that names it. No config file. | ||
| 62 | + | ||
| 63 | + # Rule: errors | ||
| 64 | + | ||
| 65 | + Wrap every error you return with what failed, using `%w`: | ||
| 66 | + | ||
| 67 | + return nil, fmt.Errorf("read %s: %w", path, err) | ||
| 68 | + | ||
| 69 | + Never return a bare `err`. Never call `log.Fatal` or `panic` in a function that can return an error. | ||
| 70 | + | ||
| 71 | + # Rule: http | ||
| 72 | + | ||
| 73 | + Create every request with a context, and send it with a client that has a timeout: | ||
| 74 | + | ||
| 75 | + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) | ||
| 76 | + client := &http.Client{Timeout: 10 * time.Second} | ||
| 77 | + resp, err := client.Do(req) | ||
| 78 | + | ||
| 79 | + Never `http.Get` or `http.DefaultClient`. Close the body with `defer resp.Body.Close()`. | ||
| 80 | + | ||
| 81 | + # Rule: logging | ||
| 82 | + | ||
| 83 | + Log with the standard `log/slog` package, as key-value pairs: | ||
| 84 | + | ||
| 85 | + slog.Info("job started", "job", name) | ||
| 86 | + slog.Error("job failed", "job", name, "err", err) | ||
| 87 | + | ||
| 88 | + Never `fmt.Println` or the `log` package for logs. | ||
| 89 | + | ||
| 90 | + # Rule: tests | ||
| 91 | + | ||
| 92 | + Write table-driven tests: a slice of cases, one `t.Run` per case. | ||
| 93 | + | ||
| 94 | + tests := []struct { | ||
| 95 | + name string | ||
| 96 | + a, b int | ||
| 97 | + want int | ||
| 98 | + }{ | ||
| 99 | + {"zero", 0, 0, 0}, | ||
| 100 | + } | ||
| 101 | + for _, tt := range tests { | ||
| 102 | + t.Run(tt.name, func(t *testing.T) { … }) | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + Put the tests in the `_test` package (`package calc_test`). | ||
added
demos/dynamic-rules/.mm/agent.yaml +68 -0 | new file mode 100644 | ||
| @@ -0,0 +1,68 @@ | ||
| 1 | +# Rook — dynamic rules with a preGeneration hook (the recommended way here). | |
| 2 | +# | |
| 3 | +# The team's rules live in rules/*.md, one per file, with `keywords:`. Before | |
| 4 | +# each question, hooks/pick-rules.py keeps the rules whose keywords appear in | |
| 5 | +# it and adds them NEXT TO THE QUESTION (the hook's `context`); the system | |
| 6 | +# prompt never changes, so the server's prompt cache holds. A rule that does | |
| 7 | +# not apply costs nothing. | |
| 8 | +# | |
| 9 | +# cd demos/dynamic-rules | |
| 10 | +# ../../mm line mode | |
| 11 | +# ../../mm -tui window | |
| 12 | +# ../../mm -p "Write a Go function that calls an HTTP API." | |
| 13 | +# | |
| 14 | +# The two other ways, to compare: .mm/agent.skills.yaml, .mm/agent.static.yaml. | |
| 15 | +# See ../README.en.md. | |
| 16 | + | |
| 17 | +provider: llamacpp | |
| 18 | +# Qwen3.5 4B, thinking off. No baseUrl: llamacpp's defaults apply — | |
| 19 | +# 127.0.0.1:9931 (the Llama app), then 8080, then host.docker.internal:9931. | |
| 20 | +model: "unsloth/Qwen3.5-4B-GGUF:Q4_K_M" | |
| 21 | + | |
| 22 | +# Rook only writes code in its answers: no command, no file. | |
| 23 | +bashTool: false | |
| 24 | +editTools: false | |
| 25 | +planTool: false | |
| 26 | +fetchContentTool: false | |
| 27 | +askUserTool: false | |
| 28 | +agentsMd: | |
| 29 | + enabled: false | |
| 30 | +yolo: true | |
| 31 | +# The model is shared with your other agents: leave it loaded. | |
| 32 | +unloadOnExit: false | |
| 33 | +unloadModels: false | |
| 34 | +maxTurns: 4 | |
| 35 | +firstTokenTimeout: 3m | |
| 36 | + | |
| 37 | +sampling: | |
| 38 | + # family qwen, precise: rules are to be followed, not reinterpreted | |
| 39 | + temperature: 0.0 | |
| 40 | + max_tokens: 2048 | |
| 41 | + parallel_tool_calls: false | |
| 42 | + chat_template_kwargs: | |
| 43 | + enable_thinking: false | |
| 44 | + | |
| 45 | +# The rule that ALWAYS applies, next to every question (not in system: a | |
| 46 | +# small model follows a rule next to the question far more often). | |
| 47 | +turnReminder: "After the code block, write one sentence, then a last line with only: — Rook" | |
| 48 | + | |
| 49 | +hooks: | |
| 50 | + preGeneration: | |
| 51 | + # MM_CONFIG_DIR is this demo's folder (the parent of .mm/). | |
| 52 | + - command: python3 "$MM_CONFIG_DIR/hooks/pick-rules.py" | |
| 53 | + timeout: 5s | |
| 54 | + # a broken hook must not leave the model without its rules unnoticed | |
| 55 | + onError: warn | |
| 56 | +# Show each hook run under the answer: which rules were added. | |
| 57 | +displayHooks: true | |
| 58 | + | |
| 59 | +skillsDir: no-skills | |
| 60 | + | |
| 61 | +acp: | |
| 62 | + name: rook | |
| 63 | + title: "Rook (rules by hook)" | |
| 64 | + | |
| 65 | +system: | | |
| 66 | + Your name is Rook. You write Go code for a team that has its own rules. | |
| 67 | + Answer with one short Go code block and one or two sentences, no more. | |
| 68 | + When the question comes with the team's rules, follow them exactly. | |
| new file mode 100644 | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | +# Rook — dynamic rules with a preGeneration hook (the recommended way here). | ||
| 2 | +# | ||
| 3 | +# The team's rules live in rules/*.md, one per file, with `keywords:`. Before | ||
| 4 | +# each question, hooks/pick-rules.py keeps the rules whose keywords appear in | ||
| 5 | +# it and adds them NEXT TO THE QUESTION (the hook's `context`); the system | ||
| 6 | +# prompt never changes, so the server's prompt cache holds. A rule that does | ||
| 7 | +# not apply costs nothing. | ||
| 8 | +# | ||
| 9 | +# cd demos/dynamic-rules | ||
| 10 | +# ../../mm line mode | ||
| 11 | +# ../../mm -tui window | ||
| 12 | +# ../../mm -p "Write a Go function that calls an HTTP API." | ||
| 13 | +# | ||
| 14 | +# The two other ways, to compare: .mm/agent.skills.yaml, .mm/agent.static.yaml. | ||
| 15 | +# See ../README.en.md. | ||
| 16 | + | ||
| 17 | +provider: llamacpp | ||
| 18 | +# Qwen3.5 4B, thinking off. No baseUrl: llamacpp's defaults apply — | ||
| 19 | +# 127.0.0.1:9931 (the Llama app), then 8080, then host.docker.internal:9931. | ||
| 20 | +model: "unsloth/Qwen3.5-4B-GGUF:Q4_K_M" | ||
| 21 | + | ||
| 22 | +# Rook only writes code in its answers: no command, no file. | ||
| 23 | +bashTool: false | ||
| 24 | +editTools: false | ||
| 25 | +planTool: false | ||
| 26 | +fetchContentTool: false | ||
| 27 | +askUserTool: false | ||
| 28 | +agentsMd: | ||
| 29 | + enabled: false | ||
| 30 | +yolo: true | ||
| 31 | +# The model is shared with your other agents: leave it loaded. | ||
| 32 | +unloadOnExit: false | ||
| 33 | +unloadModels: false | ||
| 34 | +maxTurns: 4 | ||
| 35 | +firstTokenTimeout: 3m | ||
| 36 | + | ||
| 37 | +sampling: | ||
| 38 | + # family qwen, precise: rules are to be followed, not reinterpreted | ||
| 39 | + temperature: 0.0 | ||
| 40 | + max_tokens: 2048 | ||
| 41 | + parallel_tool_calls: false | ||
| 42 | + chat_template_kwargs: | ||
| 43 | + enable_thinking: false | ||
| 44 | + | ||
| 45 | +# The rule that ALWAYS applies, next to every question (not in system: a | ||
| 46 | +# small model follows a rule next to the question far more often). | ||
| 47 | +turnReminder: "After the code block, write one sentence, then a last line with only: — Rook" | ||
| 48 | + | ||
| 49 | +hooks: | ||
| 50 | + preGeneration: | ||
| 51 | + # MM_CONFIG_DIR is this demo's folder (the parent of .mm/). | ||
| 52 | + - command: python3 "$MM_CONFIG_DIR/hooks/pick-rules.py" | ||
| 53 | + timeout: 5s | ||
| 54 | + # a broken hook must not leave the model without its rules unnoticed | ||
| 55 | + onError: warn | ||
| 56 | +# Show each hook run under the answer: which rules were added. | ||
| 57 | +displayHooks: true | ||
| 58 | + | ||
| 59 | +skillsDir: no-skills | ||
| 60 | + | ||
| 61 | +acp: | ||
| 62 | + name: rook | ||
| 63 | + title: "Rook (rules by hook)" | ||
| 64 | + | ||
| 65 | +system: | | ||
| 66 | + Your name is Rook. You write Go code for a team that has its own rules. | ||
| 67 | + Answer with one short Go code block and one or two sentences, no more. | ||
| 68 | + When the question comes with the team's rules, follow them exactly. | ||
added
demos/dynamic-rules/README.en.md +142 -0 | new file mode 100644 | ||
| @@ -0,0 +1,142 @@ | ||
| 1 | +# dynamic-rules demo — give the model only the rules a question needs | |
| 2 | + | |
| 3 | +> **Work in progress — an experiment.** The aim: keep the system prompt short, and add to each question only what it needs — here, the team's rules that concern it. This demo tries that with what mini-me already has, measures it on one small model, and is meant to change as the idea is tested further. Nothing here is a finished feature of mm. | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | +A team has rules: how to return errors, how to log, how to test, how to call an HTTP API, how to read the configuration. Written all at once in the system prompt, every question pays for every rule, and a small model applies them all, everywhere. This demo gives the model **only the rules that apply to the question**, with what mini-me already has — no new mechanism (ticket 261: pk's "dynamic directives", done another way). | |
| 8 | + | |
| 9 | +Rook writes Go code. The same five rules (`rules/*.md`) reach it three ways, one agent file each: | |
| 10 | + | |
| 11 | +| Agent file | How the rules reach the model | | |
| 12 | +|------------|-------------------------------| | |
| 13 | +| `.mm/agent.yaml` (the default) | **a `preGeneration` hook** picks the rules whose keywords appear in the question and adds them **next to the question** | | |
| 14 | +| `.mm/agent.skills.yaml` | **skills**: each rule is a skill, the model loads the one it needs with `read_skill` | | |
| 15 | +| `.mm/agent.static.yaml` | **all rules in the system prompt** — the baseline, for comparison | | |
| 16 | + | |
| 17 | +The rule that always applies — sign every answer with `— Rook` — is a `turnReminder` in the first two: a text next to every question. | |
| 18 | + | |
| 19 | +Version française : [README.fr.md](README.fr.md). | |
| 20 | + | |
| 21 | +## What is here | |
| 22 | + | |
| 23 | +| File | What it is | | |
| 24 | +|------|------------| | |
| 25 | +| `rules/errors.md`, `logging.md`, `tests.md`, `http.md`, `config.md` | the team's rules, one per file: a front matter (`name`, `description`, `keywords`), then the rule with an example | | |
| 26 | +| `hooks/pick-rules.py` | the `preGeneration` hook (Python 3, standard library only) | | |
| 27 | +| `dynamic-rules-flow.drawio`, `.svg`, `.png` | the diagram above: the draw.io source and its renderings (generated from `.claude/skills/drawio-fancy-diagram/generator/examples/dynamic_rules.py`) | | |
| 28 | +| `.mm/agent.yaml`, `.mm/agent.skills.yaml`, `.mm/agent.static.yaml` | Rook three ways: `provider: llamacpp`, `unsloth/Qwen3.5-4B-GGUF:Q4_K_M` (thinking off, temperature 0), no command, no file tool | | |
| 29 | + | |
| 30 | +A rule file: | |
| 31 | + | |
| 32 | +```markdown | |
| 33 | +--- | |
| 34 | +name: http | |
| 35 | +description: The team's rule for HTTP calls in Go — a context and a client with a timeout. | |
| 36 | +keywords: http, https, request, api, client, endpoint, url, download | |
| 37 | +--- | |
| 38 | + | |
| 39 | +# Rule: http | |
| 40 | + | |
| 41 | +Create every request with a context, and send it with a client that has a timeout: | |
| 42 | + | |
| 43 | + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) | |
| 44 | + client := &http.Client{Timeout: 10 * time.Second} | |
| 45 | + … | |
| 46 | +``` | |
| 47 | + | |
| 48 | +The same front matter as a skill's: that is what lets one folder serve both the hook and the skills. | |
| 49 | + | |
| 50 | +## How the hook way works | |
| 51 | + | |
| 52 | +```yaml | |
| 53 | +hooks: | |
| 54 | + preGeneration: | |
| 55 | + - command: python3 "$MM_CONFIG_DIR/hooks/pick-rules.py" | |
| 56 | + timeout: 5s | |
| 57 | + onError: warn | |
| 58 | +displayHooks: true | |
| 59 | +turnReminder: "After the code block, write one sentence, then a last line with only: — Rook" | |
| 60 | +``` | |
| 61 | + | |
| 62 | +1. Before each question reaches the model, mm runs the hook and writes one JSON object on its stdin: `{"event": "preGeneration", "prompt": "Write a Go function that calls an HTTP API…", …}`. `MM_CONFIG_DIR` is this demo's folder (the parent of `.mm/`). | |
| 63 | +2. The hook reads the `keywords:` of every rule, keeps those found in the question (whole words, case ignored, three at most), and answers `{"context": "<the rules>", "display": "📏 rules: http"}`. | |
| 64 | +3. mm appends `context` to the question, under a `[context added by a hook]` line; `display` is shown to you, never to the model. No rule matches: the hook writes nothing and the question goes as it is. | |
| 65 | +4. The question the model reads, then, ends like this: | |
| 66 | + | |
| 67 | +```text | |
| 68 | +Write a Go function that calls an HTTP API and returns the response body. | |
| 69 | + | |
| 70 | +[context added by a hook] | |
| 71 | +[the team's rules that apply to this question — follow them] | |
| 72 | + | |
| 73 | +# Rule: http | |
| 74 | +… | |
| 75 | + | |
| 76 | +[reminder] | |
| 77 | +After the code block, write one sentence, then a last line with only: — Rook | |
| 78 | +``` | |
| 79 | + | |
| 80 | +Three consequences: | |
| 81 | + | |
| 82 | +- **The system prompt never changes**: the server keeps it in its prompt cache from one question to the next. (pk puts its directives in the system prompt: every question re-reads the whole history.) | |
| 83 | +- **A question no rule concerns costs nothing.** | |
| 84 | +- **The selection is yours.** `pick` is twenty lines of keyword matching on purpose: replace it with BM25, embeddings, a call to another model — mm only sees the JSON. With `displayHooks: true`, every run shows under the answer: `🪝 1. preGeneration · python3 … → context (289 chars) + display (16 chars)`. | |
| 85 | + | |
| 86 | +The rules added stay in the history with the question, like the reminder: a later question still "remembers" why the code looks the way it does. | |
| 87 | + | |
| 88 | +## Run it | |
| 89 | + | |
| 90 | +The model runs on llama-server on 127.0.0.1:9931 (the Llama app, or `llama-server` in router mode) with `unsloth/Qwen3.5-4B-GGUF:Q4_K_M`; the hook needs `python3`. | |
| 91 | + | |
| 92 | +```bash | |
| 93 | +cd demos/dynamic-rules | |
| 94 | +../../mm # the hook way, line mode | |
| 95 | +../../mm -tui # the hook way, window | |
| 96 | +../../mm -p "Write a Go function that calls an HTTP API and returns the response body." | |
| 97 | +../../mm -config .mm/agent.skills.yaml -p "Write tests for a Go function Add(a, b int) int." | |
| 98 | +../../mm -config .mm/agent.static.yaml -p "Write a Go function that runs a job and logs its start and its end." | |
| 99 | +``` | |
| 100 | + | |
| 101 | +Try the hook alone, without a model: | |
| 102 | + | |
| 103 | +```bash | |
| 104 | +echo '{"prompt": "Write a Go function that calls an HTTP API and returns an error if it fails."}' \ | |
| 105 | + | MM_CONFIG_DIR=$PWD python3 hooks/pick-rules.py | |
| 106 | +``` | |
| 107 | + | |
| 108 | +Add a rule: write `rules/<name>.md` with its `keywords`. The hook and the skills read it at the next question / the next start; for the static agent, copy it into `system`. | |
| 109 | + | |
| 110 | +## What was checked (2026-11-27, from an sbx sandbox, llama-server router on the Mac, one run) | |
| 111 | + | |
| 112 | +Six questions, each a separate `-p`, the three agents. "Rule" is checked in the code of the answer: `%w` (errors), `slog.` and no `fmt.Println` (logging), `[]struct` and `t.Run(` (tests), `NewRequestWithContext` and `Timeout` (http), `APP_` and `os.Getenv` (config). | |
| 113 | + | |
| 114 | +| Question | static | hook | skills | | |
| 115 | +|----------|--------|------|--------| | |
| 116 | +| a function that reads a file … or an error | ✓ | ✓ — rules: errors | ✓ — read `http` (the wrong skill; `%w` anyway) | | |
| 117 | +| a function that runs a job and logs it | **✗** | ✓ — rules: logging | ✓ — read `logging` | | |
| 118 | +| tests for `Add(a, b int) int` | ✓ | ✓ — rules: tests | ✓ — read `tests` | | |
| 119 | +| a function that calls an HTTP API | ✓ | ✓ — rules: http | ✓ — read `http` | | |
| 120 | +| a function that loads the configuration (a port, a database URL) | ✓ | ✓ — rules: config, **http** | ✓ — read `config` | | |
| 121 | +| What is a goroutine? (no rule) | ✓ | ✓ — no rule added | ✓ — no skill | | |
| 122 | +| signed `— Rook` | 6/6 | 6/6 | 6/6 | | |
| 123 | + | |
| 124 | +What the context costs (llama-server's `prompt_tokens` for the first model call): | |
| 125 | + | |
| 126 | +| | no rule applies | the http rule applies | | |
| 127 | +|---|---|---| | |
| 128 | +| static | 501 | 504 | | |
| 129 | +| hook | **104** | **223** | | |
| 130 | +| skills | 632 | 635, then 832 for the call after `read_skill` | | |
| 131 | + | |
| 132 | +What these runs show, with this 4B model: | |
| 133 | + | |
| 134 | +- **All rules in the system prompt get applied everywhere.** Asked only to log a job, the static agent wrote a whole program with an HTTP server and an `APP_PORT` check — and an `fmt.Println`, which broke the logging rule. Given only the logging rule, the hook agent wrote the six lines asked for. | |
| 135 | +- **Keywords are a blunt selection**: "a database **URL**" brought the http rule into the config question (harmless here). Every rule the hook adds is named on screen (`📏 rules: config, http`), so a wrong pick is seen at once; a stricter matcher is the hook's business. | |
| 136 | +- **The model picking its own rule can pick the wrong one**: for the errors question the skills agent read `http`. Its code was right anyway — the model knew `%w` — but the rule was not what guided it. | |
| 137 | +- **A vague reminder is not followed**: "End your answer with the line: — Rook" gave 0/6 (static) and 2/6 (hook) in a first run — the model stopped after the code block. "After the code block, write one sentence, then a last line with only: — Rook" gave 6/6 everywhere. | |
| 138 | +- The skills way costs the most tokens here: the catalogue and the `read_skill` tool are in every request, and the rule comes back in a second call. | |
| 139 | + | |
| 140 | +Other ways mm has, not built here: `skillRouting` (a decision model picks the skill before the turn and adds the `$skill` line — `demos/decision-skills`), `docSearch` over the rules folder (the model searches them with `search_docs`; `"@agent/rules"` ships them with the agent), and `agentsMd.path` for a fixed file of project rules. | |
| 141 | + | |
| 142 | +The window and Zed were not tried live. | |
| new file mode 100644 | |||
| @@ -0,0 +1,142 @@ | |||
| 1 | +# dynamic-rules demo — give the model only the rules a question needs | ||
| 2 | + | ||
| 3 | +> **Work in progress — an experiment.** The aim: keep the system prompt short, and add to each question only what it needs — here, the team's rules that concern it. This demo tries that with what mini-me already has, measures it on one small model, and is meant to change as the idea is tested further. Nothing here is a finished feature of mm. | ||
| 4 | + | ||
| 5 | + | ||
| 6 | + | ||
| 7 | +A team has rules: how to return errors, how to log, how to test, how to call an HTTP API, how to read the configuration. Written all at once in the system prompt, every question pays for every rule, and a small model applies them all, everywhere. This demo gives the model **only the rules that apply to the question**, with what mini-me already has — no new mechanism (ticket 261: pk's "dynamic directives", done another way). | ||
| 8 | + | ||
| 9 | +Rook writes Go code. The same five rules (`rules/*.md`) reach it three ways, one agent file each: | ||
| 10 | + | ||
| 11 | +| Agent file | How the rules reach the model | | ||
| 12 | +|------------|-------------------------------| | ||
| 13 | +| `.mm/agent.yaml` (the default) | **a `preGeneration` hook** picks the rules whose keywords appear in the question and adds them **next to the question** | | ||
| 14 | +| `.mm/agent.skills.yaml` | **skills**: each rule is a skill, the model loads the one it needs with `read_skill` | | ||
| 15 | +| `.mm/agent.static.yaml` | **all rules in the system prompt** — the baseline, for comparison | | ||
| 16 | + | ||
| 17 | +The rule that always applies — sign every answer with `— Rook` — is a `turnReminder` in the first two: a text next to every question. | ||
| 18 | + | ||
| 19 | +Version française : [README.fr.md](README.fr.md). | ||
| 20 | + | ||
| 21 | +## What is here | ||
| 22 | + | ||
| 23 | +| File | What it is | | ||
| 24 | +|------|------------| | ||
| 25 | +| `rules/errors.md`, `logging.md`, `tests.md`, `http.md`, `config.md` | the team's rules, one per file: a front matter (`name`, `description`, `keywords`), then the rule with an example | | ||
| 26 | +| `hooks/pick-rules.py` | the `preGeneration` hook (Python 3, standard library only) | | ||
| 27 | +| `dynamic-rules-flow.drawio`, `.svg`, `.png` | the diagram above: the draw.io source and its renderings (generated from `.claude/skills/drawio-fancy-diagram/generator/examples/dynamic_rules.py`) | | ||
| 28 | +| `.mm/agent.yaml`, `.mm/agent.skills.yaml`, `.mm/agent.static.yaml` | Rook three ways: `provider: llamacpp`, `unsloth/Qwen3.5-4B-GGUF:Q4_K_M` (thinking off, temperature 0), no command, no file tool | | ||
| 29 | + | ||
| 30 | +A rule file: | ||
| 31 | + | ||
| 32 | +```markdown | ||
| 33 | +--- | ||
| 34 | +name: http | ||
| 35 | +description: The team's rule for HTTP calls in Go — a context and a client with a timeout. | ||
| 36 | +keywords: http, https, request, api, client, endpoint, url, download | ||
| 37 | +--- | ||
| 38 | + | ||
| 39 | +# Rule: http | ||
| 40 | + | ||
| 41 | +Create every request with a context, and send it with a client that has a timeout: | ||
| 42 | + | ||
| 43 | + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) | ||
| 44 | + client := &http.Client{Timeout: 10 * time.Second} | ||
| 45 | + … | ||
| 46 | +``` | ||
| 47 | + | ||
| 48 | +The same front matter as a skill's: that is what lets one folder serve both the hook and the skills. | ||
| 49 | + | ||
| 50 | +## How the hook way works | ||
| 51 | + | ||
| 52 | +```yaml | ||
| 53 | +hooks: | ||
| 54 | + preGeneration: | ||
| 55 | + - command: python3 "$MM_CONFIG_DIR/hooks/pick-rules.py" | ||
| 56 | + timeout: 5s | ||
| 57 | + onError: warn | ||
| 58 | +displayHooks: true | ||
| 59 | +turnReminder: "After the code block, write one sentence, then a last line with only: — Rook" | ||
| 60 | +``` | ||
| 61 | + | ||
| 62 | +1. Before each question reaches the model, mm runs the hook and writes one JSON object on its stdin: `{"event": "preGeneration", "prompt": "Write a Go function that calls an HTTP API…", …}`. `MM_CONFIG_DIR` is this demo's folder (the parent of `.mm/`). | ||
| 63 | +2. The hook reads the `keywords:` of every rule, keeps those found in the question (whole words, case ignored, three at most), and answers `{"context": "<the rules>", "display": "📏 rules: http"}`. | ||
| 64 | +3. mm appends `context` to the question, under a `[context added by a hook]` line; `display` is shown to you, never to the model. No rule matches: the hook writes nothing and the question goes as it is. | ||
| 65 | +4. The question the model reads, then, ends like this: | ||
| 66 | + | ||
| 67 | +```text | ||
| 68 | +Write a Go function that calls an HTTP API and returns the response body. | ||
| 69 | + | ||
| 70 | +[context added by a hook] | ||
| 71 | +[the team's rules that apply to this question — follow them] | ||
| 72 | + | ||
| 73 | +# Rule: http | ||
| 74 | +… | ||
| 75 | + | ||
| 76 | +[reminder] | ||
| 77 | +After the code block, write one sentence, then a last line with only: — Rook | ||
| 78 | +``` | ||
| 79 | + | ||
| 80 | +Three consequences: | ||
| 81 | + | ||
| 82 | +- **The system prompt never changes**: the server keeps it in its prompt cache from one question to the next. (pk puts its directives in the system prompt: every question re-reads the whole history.) | ||
| 83 | +- **A question no rule concerns costs nothing.** | ||
| 84 | +- **The selection is yours.** `pick` is twenty lines of keyword matching on purpose: replace it with BM25, embeddings, a call to another model — mm only sees the JSON. With `displayHooks: true`, every run shows under the answer: `🪝 1. preGeneration · python3 … → context (289 chars) + display (16 chars)`. | ||
| 85 | + | ||
| 86 | +The rules added stay in the history with the question, like the reminder: a later question still "remembers" why the code looks the way it does. | ||
| 87 | + | ||
| 88 | +## Run it | ||
| 89 | + | ||
| 90 | +The model runs on llama-server on 127.0.0.1:9931 (the Llama app, or `llama-server` in router mode) with `unsloth/Qwen3.5-4B-GGUF:Q4_K_M`; the hook needs `python3`. | ||
| 91 | + | ||
| 92 | +```bash | ||
| 93 | +cd demos/dynamic-rules | ||
| 94 | +../../mm # the hook way, line mode | ||
| 95 | +../../mm -tui # the hook way, window | ||
| 96 | +../../mm -p "Write a Go function that calls an HTTP API and returns the response body." | ||
| 97 | +../../mm -config .mm/agent.skills.yaml -p "Write tests for a Go function Add(a, b int) int." | ||
| 98 | +../../mm -config .mm/agent.static.yaml -p "Write a Go function that runs a job and logs its start and its end." | ||
| 99 | +``` | ||
| 100 | + | ||
| 101 | +Try the hook alone, without a model: | ||
| 102 | + | ||
| 103 | +```bash | ||
| 104 | +echo '{"prompt": "Write a Go function that calls an HTTP API and returns an error if it fails."}' \ | ||
| 105 | + | MM_CONFIG_DIR=$PWD python3 hooks/pick-rules.py | ||
| 106 | +``` | ||
| 107 | + | ||
| 108 | +Add a rule: write `rules/<name>.md` with its `keywords`. The hook and the skills read it at the next question / the next start; for the static agent, copy it into `system`. | ||
| 109 | + | ||
| 110 | +## What was checked (2026-11-27, from an sbx sandbox, llama-server router on the Mac, one run) | ||
| 111 | + | ||
| 112 | +Six questions, each a separate `-p`, the three agents. "Rule" is checked in the code of the answer: `%w` (errors), `slog.` and no `fmt.Println` (logging), `[]struct` and `t.Run(` (tests), `NewRequestWithContext` and `Timeout` (http), `APP_` and `os.Getenv` (config). | ||
| 113 | + | ||
| 114 | +| Question | static | hook | skills | | ||
| 115 | +|----------|--------|------|--------| | ||
| 116 | +| a function that reads a file … or an error | ✓ | ✓ — rules: errors | ✓ — read `http` (the wrong skill; `%w` anyway) | | ||
| 117 | +| a function that runs a job and logs it | **✗** | ✓ — rules: logging | ✓ — read `logging` | | ||
| 118 | +| tests for `Add(a, b int) int` | ✓ | ✓ — rules: tests | ✓ — read `tests` | | ||
| 119 | +| a function that calls an HTTP API | ✓ | ✓ — rules: http | ✓ — read `http` | | ||
| 120 | +| a function that loads the configuration (a port, a database URL) | ✓ | ✓ — rules: config, **http** | ✓ — read `config` | | ||
| 121 | +| What is a goroutine? (no rule) | ✓ | ✓ — no rule added | ✓ — no skill | | ||
| 122 | +| signed `— Rook` | 6/6 | 6/6 | 6/6 | | ||
| 123 | + | ||
| 124 | +What the context costs (llama-server's `prompt_tokens` for the first model call): | ||
| 125 | + | ||
| 126 | +| | no rule applies | the http rule applies | | ||
| 127 | +|---|---|---| | ||
| 128 | +| static | 501 | 504 | | ||
| 129 | +| hook | **104** | **223** | | ||
| 130 | +| skills | 632 | 635, then 832 for the call after `read_skill` | | ||
| 131 | + | ||
| 132 | +What these runs show, with this 4B model: | ||
| 133 | + | ||
| 134 | +- **All rules in the system prompt get applied everywhere.** Asked only to log a job, the static agent wrote a whole program with an HTTP server and an `APP_PORT` check — and an `fmt.Println`, which broke the logging rule. Given only the logging rule, the hook agent wrote the six lines asked for. | ||
| 135 | +- **Keywords are a blunt selection**: "a database **URL**" brought the http rule into the config question (harmless here). Every rule the hook adds is named on screen (`📏 rules: config, http`), so a wrong pick is seen at once; a stricter matcher is the hook's business. | ||
| 136 | +- **The model picking its own rule can pick the wrong one**: for the errors question the skills agent read `http`. Its code was right anyway — the model knew `%w` — but the rule was not what guided it. | ||
| 137 | +- **A vague reminder is not followed**: "End your answer with the line: — Rook" gave 0/6 (static) and 2/6 (hook) in a first run — the model stopped after the code block. "After the code block, write one sentence, then a last line with only: — Rook" gave 6/6 everywhere. | ||
| 138 | +- The skills way costs the most tokens here: the catalogue and the `read_skill` tool are in every request, and the rule comes back in a second call. | ||
| 139 | + | ||
| 140 | +Other ways mm has, not built here: `skillRouting` (a decision model picks the skill before the turn and adds the `$skill` line — `demos/decision-skills`), `docSearch` over the rules folder (the model searches them with `search_docs`; `"@agent/rules"` ships them with the agent), and `agentsMd.path` for a fixed file of project rules. | ||
| 141 | + | ||
| 142 | +The window and Zed were not tried live. | ||
added
demos/dynamic-rules/README.fr.md +142 -0 | new file mode 100644 | ||
| @@ -0,0 +1,142 @@ | ||
| 1 | +# Démo dynamic-rules — ne donner au modèle que les règles dont une question a besoin | |
| 2 | + | |
| 3 | +> **Travail en cours — une expérimentation.** L'objectif : garder les instructions système courtes, et n'ajouter à chaque question que ce dont elle a besoin — ici, les règles de l'équipe qui la concernent. Cette démo l'essaie avec ce que mini-me a déjà, le mesure sur un petit modèle, et a vocation à évoluer à mesure que l'idée est éprouvée. Rien ici n'est une fonction terminée de mm. | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | +Une équipe a des règles : comment renvoyer les erreurs, comment journaliser, comment tester, comment appeler une API HTTP, comment lire la configuration. Écrites d'un bloc dans le prompt système, chaque question paie pour toutes les règles, et un petit modèle les applique toutes, partout. Cette démo donne au modèle **seulement les règles qui concernent la question**, avec ce que mini-me a déjà — aucun mécanisme nouveau (ticket 261 : les « directives dynamiques » de pk, faites autrement). | |
| 8 | + | |
| 9 | +Rook écrit du code Go. Les cinq mêmes règles (`rules/*.md`) lui parviennent de trois façons, un fichier d'agent chacune : | |
| 10 | + | |
| 11 | +| Fichier d'agent | Comment les règles arrivent au modèle | | |
| 12 | +|-----------------|---------------------------------------| | |
| 13 | +| `.mm/agent.yaml` (par défaut) | **un hook `preGeneration`** choisit les règles dont les mots-clés figurent dans la question et les ajoute **à côté de la question** | | |
| 14 | +| `.mm/agent.skills.yaml` | **des skills** : chaque règle est une skill, le modèle charge celle dont il a besoin avec `read_skill` | | |
| 15 | +| `.mm/agent.static.yaml` | **toutes les règles dans le prompt système** — la référence, pour comparer | | |
| 16 | + | |
| 17 | +La règle qui s'applique toujours — signer chaque réponse `— Rook` — est un `turnReminder` dans les deux premiers : un texte à côté de chaque question. | |
| 18 | + | |
| 19 | +English version: [README.en.md](README.en.md). | |
| 20 | + | |
| 21 | +## Ce qu'il y a ici | |
| 22 | + | |
| 23 | +| Fichier | Ce que c'est | | |
| 24 | +|---------|--------------| | |
| 25 | +| `rules/errors.md`, `logging.md`, `tests.md`, `http.md`, `config.md` | les règles de l'équipe, une par fichier : un en-tête (`name`, `description`, `keywords`), puis la règle avec un exemple | | |
| 26 | +| `hooks/pick-rules.py` | le hook `preGeneration` (Python 3, bibliothèque standard seulement) | | |
| 27 | +| `dynamic-rules-flow.drawio`, `.svg`, `.png` | le diagramme ci-dessus : la source draw.io et ses rendus (générés depuis `.claude/skills/drawio-fancy-diagram/generator/examples/dynamic_rules.py`) | | |
| 28 | +| `.mm/agent.yaml`, `.mm/agent.skills.yaml`, `.mm/agent.static.yaml` | Rook de trois façons : `provider: llamacpp`, `unsloth/Qwen3.5-4B-GGUF:Q4_K_M` (raisonnement coupé, température 0), aucune commande, aucun outil de fichier | | |
| 29 | + | |
| 30 | +Un fichier de règle : | |
| 31 | + | |
| 32 | +```markdown | |
| 33 | +--- | |
| 34 | +name: http | |
| 35 | +description: The team's rule for HTTP calls in Go — a context and a client with a timeout. | |
| 36 | +keywords: http, https, request, api, client, endpoint, url, download | |
| 37 | +--- | |
| 38 | + | |
| 39 | +# Rule: http | |
| 40 | + | |
| 41 | +Create every request with a context, and send it with a client that has a timeout: | |
| 42 | + | |
| 43 | + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) | |
| 44 | + client := &http.Client{Timeout: 10 * time.Second} | |
| 45 | + … | |
| 46 | +``` | |
| 47 | + | |
| 48 | +Le même en-tête que celui d'une skill : c'est ce qui permet à un seul dossier de servir le hook et les skills. | |
| 49 | + | |
| 50 | +## Comment marche la voie du hook | |
| 51 | + | |
| 52 | +```yaml | |
| 53 | +hooks: | |
| 54 | + preGeneration: | |
| 55 | + - command: python3 "$MM_CONFIG_DIR/hooks/pick-rules.py" | |
| 56 | + timeout: 5s | |
| 57 | + onError: warn | |
| 58 | +displayHooks: true | |
| 59 | +turnReminder: "After the code block, write one sentence, then a last line with only: — Rook" | |
| 60 | +``` | |
| 61 | + | |
| 62 | +1. Avant que chaque question parte au modèle, mm lance le hook et écrit un objet JSON sur son entrée standard : `{"event": "preGeneration", "prompt": "Write a Go function that calls an HTTP API…", …}`. `MM_CONFIG_DIR` est le dossier de cette démo (le parent de `.mm/`). | |
| 63 | +2. Le hook lit les `keywords:` de chaque règle, garde celles qu'il trouve dans la question (mots entiers, casse ignorée, trois au plus), et répond `{"context": "<les règles>", "display": "📏 rules: http"}`. | |
| 64 | +3. mm ajoute `context` à la question, sous une ligne `[context added by a hook]` ; `display` vous est montré, jamais au modèle. Aucune règle ne correspond : le hook n'écrit rien et la question part telle quelle. | |
| 65 | +4. La question que lit le modèle finit alors ainsi : | |
| 66 | + | |
| 67 | +```text | |
| 68 | +Write a Go function that calls an HTTP API and returns the response body. | |
| 69 | + | |
| 70 | +[context added by a hook] | |
| 71 | +[the team's rules that apply to this question — follow them] | |
| 72 | + | |
| 73 | +# Rule: http | |
| 74 | +… | |
| 75 | + | |
| 76 | +[reminder] | |
| 77 | +After the code block, write one sentence, then a last line with only: — Rook | |
| 78 | +``` | |
| 79 | + | |
| 80 | +Trois conséquences : | |
| 81 | + | |
| 82 | +- **Le prompt système ne change jamais** : le serveur le garde dans son cache de prompt d'une question à l'autre. (pk met ses directives dans le prompt système : chaque question relit tout l'historique.) | |
| 83 | +- **Une question qu'aucune règle ne concerne ne coûte rien.** | |
| 84 | +- **La sélection vous appartient.** `pick` fait vingt lignes de recherche par mots-clés, exprès : remplacez-la par du BM25, des embeddings, l'appel d'un autre modèle — mm ne voit que le JSON. Avec `displayHooks: true`, chaque passage s'affiche sous la réponse : `🪝 1. preGeneration · python3 … → context (289 chars) + display (16 chars)`. | |
| 85 | + | |
| 86 | +Les règles ajoutées restent dans l'historique avec la question, comme le rappel : une question suivante « se souvient » encore de pourquoi le code a cette forme. | |
| 87 | + | |
| 88 | +## Lancer la démo | |
| 89 | + | |
| 90 | +Le modèle tourne sur llama-server en 127.0.0.1:9931 (l'application Llama, ou `llama-server` en mode routeur) avec `unsloth/Qwen3.5-4B-GGUF:Q4_K_M` ; le hook a besoin de `python3`. | |
| 91 | + | |
| 92 | +```bash | |
| 93 | +cd demos/dynamic-rules | |
| 94 | +../../mm # la voie du hook, mode ligne | |
| 95 | +../../mm -tui # la voie du hook, fenêtre | |
| 96 | +../../mm -p "Write a Go function that calls an HTTP API and returns the response body." | |
| 97 | +../../mm -config .mm/agent.skills.yaml -p "Write tests for a Go function Add(a, b int) int." | |
| 98 | +../../mm -config .mm/agent.static.yaml -p "Write a Go function that runs a job and logs its start and its end." | |
| 99 | +``` | |
| 100 | + | |
| 101 | +Essayer le hook seul, sans modèle : | |
| 102 | + | |
| 103 | +```bash | |
| 104 | +echo '{"prompt": "Write a Go function that calls an HTTP API and returns an error if it fails."}' \ | |
| 105 | + | MM_CONFIG_DIR=$PWD python3 hooks/pick-rules.py | |
| 106 | +``` | |
| 107 | + | |
| 108 | +Ajouter une règle : écrivez `rules/<nom>.md` avec ses `keywords`. Le hook et les skills la lisent à la question suivante / au démarrage suivant ; pour l'agent statique, copiez-la dans `system`. | |
| 109 | + | |
| 110 | +## Ce qui a été vérifié (27/11/2026, depuis un sandbox sbx, routeur llama-server sur le Mac, un passage) | |
| 111 | + | |
| 112 | +Six questions, chacune un `-p` à part, les trois agents. « Règle » est vérifiée dans le code de la réponse : `%w` (erreurs), `slog.` et pas de `fmt.Println` (journalisation), `[]struct` et `t.Run(` (tests), `NewRequestWithContext` et `Timeout` (http), `APP_` et `os.Getenv` (config). | |
| 113 | + | |
| 114 | +| Question | statique | hook | skills | | |
| 115 | +|----------|----------|------|--------| | |
| 116 | +| une fonction qui lit un fichier … ou une erreur | ✓ | ✓ — règles : errors | ✓ — a lu `http` (la mauvaise skill ; `%w` quand même) | | |
| 117 | +| une fonction qui lance un job et le journalise | **✗** | ✓ — règles : logging | ✓ — a lu `logging` | | |
| 118 | +| des tests pour `Add(a, b int) int` | ✓ | ✓ — règles : tests | ✓ — a lu `tests` | | |
| 119 | +| une fonction qui appelle une API HTTP | ✓ | ✓ — règles : http | ✓ — a lu `http` | | |
| 120 | +| une fonction qui charge la configuration (un port, une URL de base) | ✓ | ✓ — règles : config, **http** | ✓ — a lu `config` | | |
| 121 | +| What is a goroutine? (aucune règle) | ✓ | ✓ — aucune règle ajoutée | ✓ — aucune skill | | |
| 122 | +| signé `— Rook` | 6/6 | 6/6 | 6/6 | | |
| 123 | + | |
| 124 | +Ce que coûte le contexte (`prompt_tokens` de llama-server pour le premier appel au modèle) : | |
| 125 | + | |
| 126 | +| | aucune règle ne s'applique | la règle http s'applique | | |
| 127 | +|---|---|---| | |
| 128 | +| statique | 501 | 504 | | |
| 129 | +| hook | **104** | **223** | | |
| 130 | +| skills | 632 | 635, puis 832 pour l'appel après `read_skill` | | |
| 131 | + | |
| 132 | +Ce que montrent ces passages, avec ce modèle de 4B : | |
| 133 | + | |
| 134 | +- **Toutes les règles dans le prompt système sont appliquées partout.** À qui demandait seulement de journaliser un job, l'agent statique a écrit tout un programme avec un serveur HTTP et une vérification d'`APP_PORT` — et un `fmt.Println`, qui a cassé la règle de journalisation. Avec la seule règle de journalisation, l'agent du hook a écrit les six lignes demandées. | |
| 135 | +- **Les mots-clés sont une sélection grossière** : « a database **URL** » a fait entrer la règle http dans la question de config (sans dégât ici). Chaque règle ajoutée par le hook est nommée à l'écran (`📏 rules: config, http`), donc un mauvais choix se voit tout de suite ; une sélection plus fine est l'affaire du hook. | |
| 136 | +- **Le modèle qui choisit sa règle peut choisir la mauvaise** : pour la question sur les erreurs, l'agent à skills a lu `http`. Son code était juste quand même — le modèle connaissait `%w` — mais ce n'est pas la règle qui l'a guidé. | |
| 137 | +- **Un rappel vague n'est pas suivi** : « End your answer with the line: — Rook » a donné 0/6 (statique) et 2/6 (hook) dans un premier passage — le modèle s'arrêtait après le bloc de code. « After the code block, write one sentence, then a last line with only: — Rook » a donné 6/6 partout. | |
| 138 | +- La voie des skills coûte ici le plus de tokens : le catalogue et l'outil `read_skill` sont dans chaque requête, et la règle revient dans un second appel. | |
| 139 | + | |
| 140 | +D'autres voies que mm offre, pas construites ici : `skillRouting` (un modèle de décision choisit la skill avant le tour et ajoute la ligne `$skill` — `demos/decision-skills`), `docSearch` sur le dossier des règles (le modèle les cherche avec `search_docs` ; `"@agent/rules"` les livre avec l'agent), et `agentsMd.path` pour un fichier fixe de règles du projet. | |
| 141 | + | |
| 142 | +La fenêtre et Zed n'ont pas été essayés en vrai. | |
| new file mode 100644 | |||
| @@ -0,0 +1,142 @@ | |||
| 1 | +# Démo dynamic-rules — ne donner au modèle que les règles dont une question a besoin | ||
| 2 | + | ||
| 3 | +> **Travail en cours — une expérimentation.** L'objectif : garder les instructions système courtes, et n'ajouter à chaque question que ce dont elle a besoin — ici, les règles de l'équipe qui la concernent. Cette démo l'essaie avec ce que mini-me a déjà, le mesure sur un petit modèle, et a vocation à évoluer à mesure que l'idée est éprouvée. Rien ici n'est une fonction terminée de mm. | ||
| 4 | + | ||
| 5 | + | ||
| 6 | + | ||
| 7 | +Une équipe a des règles : comment renvoyer les erreurs, comment journaliser, comment tester, comment appeler une API HTTP, comment lire la configuration. Écrites d'un bloc dans le prompt système, chaque question paie pour toutes les règles, et un petit modèle les applique toutes, partout. Cette démo donne au modèle **seulement les règles qui concernent la question**, avec ce que mini-me a déjà — aucun mécanisme nouveau (ticket 261 : les « directives dynamiques » de pk, faites autrement). | ||
| 8 | + | ||
| 9 | +Rook écrit du code Go. Les cinq mêmes règles (`rules/*.md`) lui parviennent de trois façons, un fichier d'agent chacune : | ||
| 10 | + | ||
| 11 | +| Fichier d'agent | Comment les règles arrivent au modèle | | ||
| 12 | +|-----------------|---------------------------------------| | ||
| 13 | +| `.mm/agent.yaml` (par défaut) | **un hook `preGeneration`** choisit les règles dont les mots-clés figurent dans la question et les ajoute **à côté de la question** | | ||
| 14 | +| `.mm/agent.skills.yaml` | **des skills** : chaque règle est une skill, le modèle charge celle dont il a besoin avec `read_skill` | | ||
| 15 | +| `.mm/agent.static.yaml` | **toutes les règles dans le prompt système** — la référence, pour comparer | | ||
| 16 | + | ||
| 17 | +La règle qui s'applique toujours — signer chaque réponse `— Rook` — est un `turnReminder` dans les deux premiers : un texte à côté de chaque question. | ||
| 18 | + | ||
| 19 | +English version: [README.en.md](README.en.md). | ||
| 20 | + | ||
| 21 | +## Ce qu'il y a ici | ||
| 22 | + | ||
| 23 | +| Fichier | Ce que c'est | | ||
| 24 | +|---------|--------------| | ||
| 25 | +| `rules/errors.md`, `logging.md`, `tests.md`, `http.md`, `config.md` | les règles de l'équipe, une par fichier : un en-tête (`name`, `description`, `keywords`), puis la règle avec un exemple | | ||
| 26 | +| `hooks/pick-rules.py` | le hook `preGeneration` (Python 3, bibliothèque standard seulement) | | ||
| 27 | +| `dynamic-rules-flow.drawio`, `.svg`, `.png` | le diagramme ci-dessus : la source draw.io et ses rendus (générés depuis `.claude/skills/drawio-fancy-diagram/generator/examples/dynamic_rules.py`) | | ||
| 28 | +| `.mm/agent.yaml`, `.mm/agent.skills.yaml`, `.mm/agent.static.yaml` | Rook de trois façons : `provider: llamacpp`, `unsloth/Qwen3.5-4B-GGUF:Q4_K_M` (raisonnement coupé, température 0), aucune commande, aucun outil de fichier | | ||
| 29 | + | ||
| 30 | +Un fichier de règle : | ||
| 31 | + | ||
| 32 | +```markdown | ||
| 33 | +--- | ||
| 34 | +name: http | ||
| 35 | +description: The team's rule for HTTP calls in Go — a context and a client with a timeout. | ||
| 36 | +keywords: http, https, request, api, client, endpoint, url, download | ||
| 37 | +--- | ||
| 38 | + | ||
| 39 | +# Rule: http | ||
| 40 | + | ||
| 41 | +Create every request with a context, and send it with a client that has a timeout: | ||
| 42 | + | ||
| 43 | + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) | ||
| 44 | + client := &http.Client{Timeout: 10 * time.Second} | ||
| 45 | + … | ||
| 46 | +``` | ||
| 47 | + | ||
| 48 | +Le même en-tête que celui d'une skill : c'est ce qui permet à un seul dossier de servir le hook et les skills. | ||
| 49 | + | ||
| 50 | +## Comment marche la voie du hook | ||
| 51 | + | ||
| 52 | +```yaml | ||
| 53 | +hooks: | ||
| 54 | + preGeneration: | ||
| 55 | + - command: python3 "$MM_CONFIG_DIR/hooks/pick-rules.py" | ||
| 56 | + timeout: 5s | ||
| 57 | + onError: warn | ||
| 58 | +displayHooks: true | ||
| 59 | +turnReminder: "After the code block, write one sentence, then a last line with only: — Rook" | ||
| 60 | +``` | ||
| 61 | + | ||
| 62 | +1. Avant que chaque question parte au modèle, mm lance le hook et écrit un objet JSON sur son entrée standard : `{"event": "preGeneration", "prompt": "Write a Go function that calls an HTTP API…", …}`. `MM_CONFIG_DIR` est le dossier de cette démo (le parent de `.mm/`). | ||
| 63 | +2. Le hook lit les `keywords:` de chaque règle, garde celles qu'il trouve dans la question (mots entiers, casse ignorée, trois au plus), et répond `{"context": "<les règles>", "display": "📏 rules: http"}`. | ||
| 64 | +3. mm ajoute `context` à la question, sous une ligne `[context added by a hook]` ; `display` vous est montré, jamais au modèle. Aucune règle ne correspond : le hook n'écrit rien et la question part telle quelle. | ||
| 65 | +4. La question que lit le modèle finit alors ainsi : | ||
| 66 | + | ||
| 67 | +```text | ||
| 68 | +Write a Go function that calls an HTTP API and returns the response body. | ||
| 69 | + | ||
| 70 | +[context added by a hook] | ||
| 71 | +[the team's rules that apply to this question — follow them] | ||
| 72 | + | ||
| 73 | +# Rule: http | ||
| 74 | +… | ||
| 75 | + | ||
| 76 | +[reminder] | ||
| 77 | +After the code block, write one sentence, then a last line with only: — Rook | ||
| 78 | +``` | ||
| 79 | + | ||
| 80 | +Trois conséquences : | ||
| 81 | + | ||
| 82 | +- **Le prompt système ne change jamais** : le serveur le garde dans son cache de prompt d'une question à l'autre. (pk met ses directives dans le prompt système : chaque question relit tout l'historique.) | ||
| 83 | +- **Une question qu'aucune règle ne concerne ne coûte rien.** | ||
| 84 | +- **La sélection vous appartient.** `pick` fait vingt lignes de recherche par mots-clés, exprès : remplacez-la par du BM25, des embeddings, l'appel d'un autre modèle — mm ne voit que le JSON. Avec `displayHooks: true`, chaque passage s'affiche sous la réponse : `🪝 1. preGeneration · python3 … → context (289 chars) + display (16 chars)`. | ||
| 85 | + | ||
| 86 | +Les règles ajoutées restent dans l'historique avec la question, comme le rappel : une question suivante « se souvient » encore de pourquoi le code a cette forme. | ||
| 87 | + | ||
| 88 | +## Lancer la démo | ||
| 89 | + | ||
| 90 | +Le modèle tourne sur llama-server en 127.0.0.1:9931 (l'application Llama, ou `llama-server` en mode routeur) avec `unsloth/Qwen3.5-4B-GGUF:Q4_K_M` ; le hook a besoin de `python3`. | ||
| 91 | + | ||
| 92 | +```bash | ||
| 93 | +cd demos/dynamic-rules | ||
| 94 | +../../mm # la voie du hook, mode ligne | ||
| 95 | +../../mm -tui # la voie du hook, fenêtre | ||
| 96 | +../../mm -p "Write a Go function that calls an HTTP API and returns the response body." | ||
| 97 | +../../mm -config .mm/agent.skills.yaml -p "Write tests for a Go function Add(a, b int) int." | ||
| 98 | +../../mm -config .mm/agent.static.yaml -p "Write a Go function that runs a job and logs its start and its end." | ||
| 99 | +``` | ||
| 100 | + | ||
| 101 | +Essayer le hook seul, sans modèle : | ||
| 102 | + | ||
| 103 | +```bash | ||
| 104 | +echo '{"prompt": "Write a Go function that calls an HTTP API and returns an error if it fails."}' \ | ||
| 105 | + | MM_CONFIG_DIR=$PWD python3 hooks/pick-rules.py | ||
| 106 | +``` | ||
| 107 | + | ||
| 108 | +Ajouter une règle : écrivez `rules/<nom>.md` avec ses `keywords`. Le hook et les skills la lisent à la question suivante / au démarrage suivant ; pour l'agent statique, copiez-la dans `system`. | ||
| 109 | + | ||
| 110 | +## Ce qui a été vérifié (27/11/2026, depuis un sandbox sbx, routeur llama-server sur le Mac, un passage) | ||
| 111 | + | ||
| 112 | +Six questions, chacune un `-p` à part, les trois agents. « Règle » est vérifiée dans le code de la réponse : `%w` (erreurs), `slog.` et pas de `fmt.Println` (journalisation), `[]struct` et `t.Run(` (tests), `NewRequestWithContext` et `Timeout` (http), `APP_` et `os.Getenv` (config). | ||
| 113 | + | ||
| 114 | +| Question | statique | hook | skills | | ||
| 115 | +|----------|----------|------|--------| | ||
| 116 | +| une fonction qui lit un fichier … ou une erreur | ✓ | ✓ — règles : errors | ✓ — a lu `http` (la mauvaise skill ; `%w` quand même) | | ||
| 117 | +| une fonction qui lance un job et le journalise | **✗** | ✓ — règles : logging | ✓ — a lu `logging` | | ||
| 118 | +| des tests pour `Add(a, b int) int` | ✓ | ✓ — règles : tests | ✓ — a lu `tests` | | ||
| 119 | +| une fonction qui appelle une API HTTP | ✓ | ✓ — règles : http | ✓ — a lu `http` | | ||
| 120 | +| une fonction qui charge la configuration (un port, une URL de base) | ✓ | ✓ — règles : config, **http** | ✓ — a lu `config` | | ||
| 121 | +| What is a goroutine? (aucune règle) | ✓ | ✓ — aucune règle ajoutée | ✓ — aucune skill | | ||
| 122 | +| signé `— Rook` | 6/6 | 6/6 | 6/6 | | ||
| 123 | + | ||
| 124 | +Ce que coûte le contexte (`prompt_tokens` de llama-server pour le premier appel au modèle) : | ||
| 125 | + | ||
| 126 | +| | aucune règle ne s'applique | la règle http s'applique | | ||
| 127 | +|---|---|---| | ||
| 128 | +| statique | 501 | 504 | | ||
| 129 | +| hook | **104** | **223** | | ||
| 130 | +| skills | 632 | 635, puis 832 pour l'appel après `read_skill` | | ||
| 131 | + | ||
| 132 | +Ce que montrent ces passages, avec ce modèle de 4B : | ||
| 133 | + | ||
| 134 | +- **Toutes les règles dans le prompt système sont appliquées partout.** À qui demandait seulement de journaliser un job, l'agent statique a écrit tout un programme avec un serveur HTTP et une vérification d'`APP_PORT` — et un `fmt.Println`, qui a cassé la règle de journalisation. Avec la seule règle de journalisation, l'agent du hook a écrit les six lignes demandées. | ||
| 135 | +- **Les mots-clés sont une sélection grossière** : « a database **URL** » a fait entrer la règle http dans la question de config (sans dégât ici). Chaque règle ajoutée par le hook est nommée à l'écran (`📏 rules: config, http`), donc un mauvais choix se voit tout de suite ; une sélection plus fine est l'affaire du hook. | ||
| 136 | +- **Le modèle qui choisit sa règle peut choisir la mauvaise** : pour la question sur les erreurs, l'agent à skills a lu `http`. Son code était juste quand même — le modèle connaissait `%w` — mais ce n'est pas la règle qui l'a guidé. | ||
| 137 | +- **Un rappel vague n'est pas suivi** : « End your answer with the line: — Rook » a donné 0/6 (statique) et 2/6 (hook) dans un premier passage — le modèle s'arrêtait après le bloc de code. « After the code block, write one sentence, then a last line with only: — Rook » a donné 6/6 partout. | ||
| 138 | +- La voie des skills coûte ici le plus de tokens : le catalogue et l'outil `read_skill` sont dans chaque requête, et la règle revient dans un second appel. | ||
| 139 | + | ||
| 140 | +D'autres voies que mm offre, pas construites ici : `skillRouting` (un modèle de décision choisit la skill avant le tour et ajoute la ligne `$skill` — `demos/decision-skills`), `docSearch` sur le dossier des règles (le modèle les cherche avec `search_docs` ; `"@agent/rules"` les livre avec l'agent), et `agentsMd.path` pour un fichier fixe de règles du projet. | ||
| 141 | + | ||
| 142 | +La fenêtre et Zed n'ont pas été essayés en vrai. | ||
added
demos/dynamic-rules/dynamic-rules-flow.drawio +43 -0 | new file mode 100644 | ||
| @@ -0,0 +1,43 @@ | ||
| 1 | +<mxfile host="app.diagrams.net"> | |
| 2 | + <diagram id="dynamic-rules-flow" name="demos/dynamic-rules — only the rules a question needs"> | |
| 3 | + <mxGraphModel dx="1200" dy="700" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1200" pageHeight="700" background="#F5F7FC" math="0" shadow="0"> | |
| 4 | + <root> | |
| 5 | + <mxCell id="0"/> | |
| 6 | + <mxCell id="1" parent="0"/> | |
| 7 | + <mxCell id="title" value="<b style="font-size:25px;color:#1A237E">demos/dynamic-rules — only the rules a question needs</b><br><i style="font-size:14px;color:#546E7A">WIP experiment: a short system prompt, and a preGeneration hook that adds the matching rules next to the question</i>" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;" vertex="1" parent="1"><mxGeometry x="150.0" y="12" width="900" height="56" as="geometry"/></mxCell> | |
| 8 | + <mxCell id="c19" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="230" y="200" as="sourcePoint"/><mxPoint x="330" y="200" as="targetPoint"/></mxGeometry></mxCell> | |
| 9 | + <mxCell id="c21" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="580" y="200" as="sourcePoint"/><mxPoint x="880" y="200" as="targetPoint"/></mxGeometry></mxCell> | |
| 10 | + <mxCell id="c23" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=block;startFill=1;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="455" y="260" as="sourcePoint"/><mxPoint x="455" y="340" as="targetPoint"/></mxGeometry></mxCell> | |
| 11 | + <mxCell id="c25" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;dashed=1;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="1020" y="260" as="sourcePoint"/><mxPoint x="1020" y="340" as="targetPoint"/></mxGeometry></mxCell> | |
| 12 | + <mxCell id="c26" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="1020" y="140" as="sourcePoint"/><mxPoint x="135" y="140" as="targetPoint"/><Array as="points"><mxPoint x="1020" y="100"/><mxPoint x="135" y="100"/></Array></mxGeometry></mxCell> | |
| 13 | + <mxCell id="c1" value="🧑<br><b style="font-size:16px">User</b><br><span style="font-size:11.5px;font-weight:normal">asks for some Go code<br>terminal · -tui · editor</span>" style="rounded=1;arcSize=14;whiteSpace=wrap;html=1;fillColor=#E3F2FD;gradientColor=#BBDEFB;strokeColor=#1565C0;strokeWidth=2;shadow=1;fontSize=20;fontColor=#0D47A1;" vertex="1" parent="1"><mxGeometry x="40" y="140" width="190" height="120" as="geometry"/></mxCell> | |
| 14 | + <mxCell id="c2" value="⚙️<br><b style="font-size:16px">preGeneration hook</b><br><span style="font-size:11.5px;font-weight:normal">hooks/pick-rules.py<br>keywords found in the question</span>" style="rounded=1;arcSize=14;whiteSpace=wrap;html=1;fillColor=#FFFDE7;gradientColor=#FFF9C4;strokeColor=#F9A825;strokeWidth=2;shadow=1;fontSize=20;fontColor=#E65100;" vertex="1" parent="1"><mxGeometry x="330" y="140" width="250" height="120" as="geometry"/></mxCell> | |
| 15 | + <mxCell id="c3" value="<b>★ picks the rules</b>" style="rounded=1;arcSize=50;html=1;fillColor=#F9A825;strokeColor=none;fontColor=#FFFFFF;fontSize=11;" vertex="1" parent="1"><mxGeometry x="453.6" y="128" width="136.4" height="24" as="geometry"/></mxCell> | |
| 16 | + <mxCell id="c4" value="🤖<br><b style="font-size:16px">Chat model</b><br><span style="font-size:11.5px;font-weight:normal">Qwen3.5-4B · short system prompt<br>unchanged → stays in the cache</span>" style="rounded=1;arcSize=14;whiteSpace=wrap;html=1;fillColor=#E1F5FE;gradientColor=#B3E5FC;strokeColor=#0277BD;strokeWidth=2;shadow=1;fontSize=20;fontColor=#01579B;" vertex="1" parent="1"><mxGeometry x="880" y="140" width="280" height="120" as="geometry"/></mxCell> | |
| 17 | + <mxCell id="c5" value="<i><b>rules/*.md · one rule per file, with keywords</b></i>" style="rounded=1;arcSize=3;html=1;dashed=1;dashPattern=7 5;fillColor=#FAFAFA;strokeColor=#90A4AE;strokeWidth=2;verticalAlign=top;fontColor=#607D8B;fontSize=13;" vertex="1" parent="1"><mxGeometry x="250" y="340" width="410" height="170" as="geometry"/></mxCell> | |
| 18 | + <mxCell id="c6" value="<b>errors</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#ECEFF1;gradientColor=#CFD8DC;strokeColor=#455A64;strokeWidth=2;shadow=1;fontSize=12;fontColor=#263238;" vertex="1" parent="1"><mxGeometry x="270" y="390" width="72" height="44" as="geometry"/></mxCell> | |
| 19 | + <mxCell id="c7" value="<b>logging</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#ECEFF1;gradientColor=#CFD8DC;strokeColor=#455A64;strokeWidth=2;shadow=1;fontSize=12;fontColor=#263238;" vertex="1" parent="1"><mxGeometry x="348" y="390" width="72" height="44" as="geometry"/></mxCell> | |
| 20 | + <mxCell id="c8" value="<b>tests</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#ECEFF1;gradientColor=#CFD8DC;strokeColor=#455A64;strokeWidth=2;shadow=1;fontSize=12;fontColor=#263238;" vertex="1" parent="1"><mxGeometry x="426" y="390" width="72" height="44" as="geometry"/></mxCell> | |
| 21 | + <mxCell id="c9" value="<b>http</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#FFFDE7;gradientColor=#FFF9C4;strokeColor=#F9A825;strokeWidth=2;shadow=1;fontSize=12;fontColor=#E65100;" vertex="1" parent="1"><mxGeometry x="504" y="390" width="72" height="44" as="geometry"/></mxCell> | |
| 22 | + <mxCell id="c10" value="<b>config</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#ECEFF1;gradientColor=#CFD8DC;strokeColor=#455A64;strokeWidth=2;shadow=1;fontSize=12;fontColor=#263238;" vertex="1" parent="1"><mxGeometry x="582" y="390" width="72" height="44" as="geometry"/></mxCell> | |
| 23 | + <mxCell id="c11" value="keywords: http, request, api, client, url…" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=11.5;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="305.27" y="458.5" width="299.46" height="17.5" as="geometry"/></mxCell> | |
| 24 | + <mxCell id="c12" value="the same files serve as skills (agent.skills.yaml)" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="292.25" y="479.5" width="325.5" height="16.5" as="geometry"/></mxCell> | |
| 25 | + <mxCell id="c13" value="<i><b>what the model reads for this question</b></i>" style="rounded=1;arcSize=3;html=1;dashed=1;dashPattern=7 5;fillColor=#FAFAFA;strokeColor=#90A4AE;strokeWidth=2;verticalAlign=top;fontColor=#607D8B;fontSize=13;" vertex="1" parent="1"><mxGeometry x="720" y="340" width="440" height="170" as="geometry"/></mxCell> | |
| 26 | + <mxCell id="c14" value="Write a Go function that calls an HTTP API…" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=11.5;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="786.705" y="370.5" width="306.59" height="17.5" as="geometry"/></mxCell> | |
| 27 | + <mxCell id="c15" value="[context added by a hook]" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=11.5;fontColor=#E65100;fontStyle=1;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="850.875" y="394.5" width="178.25" height="17.5" as="geometry"/></mxCell> | |
| 28 | + <mxCell id="c16" value="# Rule: http — NewRequestWithContext, Timeout" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=11.5;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="779.575" y="414.5" width="320.85" height="17.5" as="geometry"/></mxCell> | |
| 29 | + <mxCell id="c17" value="[reminder] … a last line with only: — Rook" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=11.5;fontColor=#0277BD;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="786.705" y="438.5" width="306.59" height="17.5" as="geometry"/></mxCell> | |
| 30 | + <mxCell id="c18" value="turnReminder: the rule that always applies" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="803.29" y="469.5" width="273.42" height="16.5" as="geometry"/></mxCell> | |
| 31 | + <mxCell id="c20" value="<b style="font-size:12.5px;color:#263238">question</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="241.0" y="216.0" width="78" height="24" as="geometry"/></mxCell> | |
| 32 | + <mxCell id="c22" value="<b style="font-size:12.5px;color:#263238">question + its rules</b><br><span style="font-size:10.5px;color:#78909C">[context added by a hook]</span>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="641.25" y="180.0" width="177.5" height="40" as="geometry"/></mxCell> | |
| 33 | + <mxCell id="c24" value="<b style="font-size:12.5px;color:#263238">reads keywords</b><br><span style="font-size:10.5px;color:#78909C">← the rules that match</span>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="470.7" y="280.0" width="158.6" height="40" as="geometry"/></mxCell> | |
| 34 | + <mxCell id="c27" value="<b style="font-size:12.5px;color:#263238">Go code that follows the rules — Rook</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="449.4" y="88.0" width="301.2" height="24" as="geometry"/></mxCell> | |
| 35 | + <mxCell id="c28" value="<b>hook · 104 tokens, 223 with the http rule</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#FFFDE7;gradientColor=#FFF9C4;strokeColor=#F9A825;strokeWidth=2;shadow=1;fontSize=12.5;fontColor=#E65100;" vertex="1" parent="1"><mxGeometry x="40" y="560" width="360" height="48" as="geometry"/></mxCell> | |
| 36 | + <mxCell id="c29" value="<b>skills · 632, then 832 after read_skill</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#ECEFF1;gradientColor=#CFD8DC;strokeColor=#455A64;strokeWidth=2;shadow=1;fontSize=12.5;fontColor=#263238;" vertex="1" parent="1"><mxGeometry x="420" y="560" width="360" height="48" as="geometry"/></mxCell> | |
| 37 | + <mxCell id="c30" value="<b>static · ~500, every rule applied everywhere</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#ECEFF1;gradientColor=#CFD8DC;strokeColor=#455A64;strokeWidth=2;shadow=1;fontSize=12.5;fontColor=#263238;" vertex="1" parent="1"><mxGeometry x="800" y="560" width="360" height="48" as="geometry"/></mxCell> | |
| 38 | + <mxCell id="c31" value="prompt_tokens of the first model call (Qwen3.5 4B): a question no rule concerns costs nothing," style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#455A64;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="235.75" y="627.5" width="728.5" height="18.5" as="geometry"/></mxCell> | |
| 39 | + <mxCell id="c32" value="and the system prompt never changes, so the server keeps it in its prompt cache." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#455A64;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="290.0" y="647.5" width="620.0" height="18.5" as="geometry"/></mxCell> | |
| 40 | + </root> | |
| 41 | + </mxGraphModel> | |
| 42 | + </diagram> | |
| 43 | +</mxfile> | |
| new file mode 100644 | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | +<mxfile host="app.diagrams.net"> | ||
| 2 | + <diagram id="dynamic-rules-flow" name="demos/dynamic-rules — only the rules a question needs"> | ||
| 3 | + <mxGraphModel dx="1200" dy="700" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1200" pageHeight="700" background="#F5F7FC" math="0" shadow="0"> | ||
| 4 | + <root> | ||
| 5 | + <mxCell id="0"/> | ||
| 6 | + <mxCell id="1" parent="0"/> | ||
| 7 | + <mxCell id="title" value="<b style="font-size:25px;color:#1A237E">demos/dynamic-rules — only the rules a question needs</b><br><i style="font-size:14px;color:#546E7A">WIP experiment: a short system prompt, and a preGeneration hook that adds the matching rules next to the question</i>" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;" vertex="1" parent="1"><mxGeometry x="150.0" y="12" width="900" height="56" as="geometry"/></mxCell> | ||
| 8 | + <mxCell id="c19" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="230" y="200" as="sourcePoint"/><mxPoint x="330" y="200" as="targetPoint"/></mxGeometry></mxCell> | ||
| 9 | + <mxCell id="c21" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="580" y="200" as="sourcePoint"/><mxPoint x="880" y="200" as="targetPoint"/></mxGeometry></mxCell> | ||
| 10 | + <mxCell id="c23" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=block;startFill=1;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="455" y="260" as="sourcePoint"/><mxPoint x="455" y="340" as="targetPoint"/></mxGeometry></mxCell> | ||
| 11 | + <mxCell id="c25" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;dashed=1;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="1020" y="260" as="sourcePoint"/><mxPoint x="1020" y="340" as="targetPoint"/></mxGeometry></mxCell> | ||
| 12 | + <mxCell id="c26" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="1020" y="140" as="sourcePoint"/><mxPoint x="135" y="140" as="targetPoint"/><Array as="points"><mxPoint x="1020" y="100"/><mxPoint x="135" y="100"/></Array></mxGeometry></mxCell> | ||
| 13 | + <mxCell id="c1" value="🧑<br><b style="font-size:16px">User</b><br><span style="font-size:11.5px;font-weight:normal">asks for some Go code<br>terminal · -tui · editor</span>" style="rounded=1;arcSize=14;whiteSpace=wrap;html=1;fillColor=#E3F2FD;gradientColor=#BBDEFB;strokeColor=#1565C0;strokeWidth=2;shadow=1;fontSize=20;fontColor=#0D47A1;" vertex="1" parent="1"><mxGeometry x="40" y="140" width="190" height="120" as="geometry"/></mxCell> | ||
| 14 | + <mxCell id="c2" value="⚙️<br><b style="font-size:16px">preGeneration hook</b><br><span style="font-size:11.5px;font-weight:normal">hooks/pick-rules.py<br>keywords found in the question</span>" style="rounded=1;arcSize=14;whiteSpace=wrap;html=1;fillColor=#FFFDE7;gradientColor=#FFF9C4;strokeColor=#F9A825;strokeWidth=2;shadow=1;fontSize=20;fontColor=#E65100;" vertex="1" parent="1"><mxGeometry x="330" y="140" width="250" height="120" as="geometry"/></mxCell> | ||
| 15 | + <mxCell id="c3" value="<b>★ picks the rules</b>" style="rounded=1;arcSize=50;html=1;fillColor=#F9A825;strokeColor=none;fontColor=#FFFFFF;fontSize=11;" vertex="1" parent="1"><mxGeometry x="453.6" y="128" width="136.4" height="24" as="geometry"/></mxCell> | ||
| 16 | + <mxCell id="c4" value="🤖<br><b style="font-size:16px">Chat model</b><br><span style="font-size:11.5px;font-weight:normal">Qwen3.5-4B · short system prompt<br>unchanged → stays in the cache</span>" style="rounded=1;arcSize=14;whiteSpace=wrap;html=1;fillColor=#E1F5FE;gradientColor=#B3E5FC;strokeColor=#0277BD;strokeWidth=2;shadow=1;fontSize=20;fontColor=#01579B;" vertex="1" parent="1"><mxGeometry x="880" y="140" width="280" height="120" as="geometry"/></mxCell> | ||
| 17 | + <mxCell id="c5" value="<i><b>rules/*.md · one rule per file, with keywords</b></i>" style="rounded=1;arcSize=3;html=1;dashed=1;dashPattern=7 5;fillColor=#FAFAFA;strokeColor=#90A4AE;strokeWidth=2;verticalAlign=top;fontColor=#607D8B;fontSize=13;" vertex="1" parent="1"><mxGeometry x="250" y="340" width="410" height="170" as="geometry"/></mxCell> | ||
| 18 | + <mxCell id="c6" value="<b>errors</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#ECEFF1;gradientColor=#CFD8DC;strokeColor=#455A64;strokeWidth=2;shadow=1;fontSize=12;fontColor=#263238;" vertex="1" parent="1"><mxGeometry x="270" y="390" width="72" height="44" as="geometry"/></mxCell> | ||
| 19 | + <mxCell id="c7" value="<b>logging</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#ECEFF1;gradientColor=#CFD8DC;strokeColor=#455A64;strokeWidth=2;shadow=1;fontSize=12;fontColor=#263238;" vertex="1" parent="1"><mxGeometry x="348" y="390" width="72" height="44" as="geometry"/></mxCell> | ||
| 20 | + <mxCell id="c8" value="<b>tests</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#ECEFF1;gradientColor=#CFD8DC;strokeColor=#455A64;strokeWidth=2;shadow=1;fontSize=12;fontColor=#263238;" vertex="1" parent="1"><mxGeometry x="426" y="390" width="72" height="44" as="geometry"/></mxCell> | ||
| 21 | + <mxCell id="c9" value="<b>http</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#FFFDE7;gradientColor=#FFF9C4;strokeColor=#F9A825;strokeWidth=2;shadow=1;fontSize=12;fontColor=#E65100;" vertex="1" parent="1"><mxGeometry x="504" y="390" width="72" height="44" as="geometry"/></mxCell> | ||
| 22 | + <mxCell id="c10" value="<b>config</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#ECEFF1;gradientColor=#CFD8DC;strokeColor=#455A64;strokeWidth=2;shadow=1;fontSize=12;fontColor=#263238;" vertex="1" parent="1"><mxGeometry x="582" y="390" width="72" height="44" as="geometry"/></mxCell> | ||
| 23 | + <mxCell id="c11" value="keywords: http, request, api, client, url…" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=11.5;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="305.27" y="458.5" width="299.46" height="17.5" as="geometry"/></mxCell> | ||
| 24 | + <mxCell id="c12" value="the same files serve as skills (agent.skills.yaml)" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="292.25" y="479.5" width="325.5" height="16.5" as="geometry"/></mxCell> | ||
| 25 | + <mxCell id="c13" value="<i><b>what the model reads for this question</b></i>" style="rounded=1;arcSize=3;html=1;dashed=1;dashPattern=7 5;fillColor=#FAFAFA;strokeColor=#90A4AE;strokeWidth=2;verticalAlign=top;fontColor=#607D8B;fontSize=13;" vertex="1" parent="1"><mxGeometry x="720" y="340" width="440" height="170" as="geometry"/></mxCell> | ||
| 26 | + <mxCell id="c14" value="Write a Go function that calls an HTTP API…" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=11.5;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="786.705" y="370.5" width="306.59" height="17.5" as="geometry"/></mxCell> | ||
| 27 | + <mxCell id="c15" value="[context added by a hook]" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=11.5;fontColor=#E65100;fontStyle=1;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="850.875" y="394.5" width="178.25" height="17.5" as="geometry"/></mxCell> | ||
| 28 | + <mxCell id="c16" value="# Rule: http — NewRequestWithContext, Timeout" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=11.5;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="779.575" y="414.5" width="320.85" height="17.5" as="geometry"/></mxCell> | ||
| 29 | + <mxCell id="c17" value="[reminder] … a last line with only: — Rook" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=11.5;fontColor=#0277BD;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="786.705" y="438.5" width="306.59" height="17.5" as="geometry"/></mxCell> | ||
| 30 | + <mxCell id="c18" value="turnReminder: the rule that always applies" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="803.29" y="469.5" width="273.42" height="16.5" as="geometry"/></mxCell> | ||
| 31 | + <mxCell id="c20" value="<b style="font-size:12.5px;color:#263238">question</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="241.0" y="216.0" width="78" height="24" as="geometry"/></mxCell> | ||
| 32 | + <mxCell id="c22" value="<b style="font-size:12.5px;color:#263238">question + its rules</b><br><span style="font-size:10.5px;color:#78909C">[context added by a hook]</span>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="641.25" y="180.0" width="177.5" height="40" as="geometry"/></mxCell> | ||
| 33 | + <mxCell id="c24" value="<b style="font-size:12.5px;color:#263238">reads keywords</b><br><span style="font-size:10.5px;color:#78909C">← the rules that match</span>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="470.7" y="280.0" width="158.6" height="40" as="geometry"/></mxCell> | ||
| 34 | + <mxCell id="c27" value="<b style="font-size:12.5px;color:#263238">Go code that follows the rules — Rook</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="449.4" y="88.0" width="301.2" height="24" as="geometry"/></mxCell> | ||
| 35 | + <mxCell id="c28" value="<b>hook · 104 tokens, 223 with the http rule</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#FFFDE7;gradientColor=#FFF9C4;strokeColor=#F9A825;strokeWidth=2;shadow=1;fontSize=12.5;fontColor=#E65100;" vertex="1" parent="1"><mxGeometry x="40" y="560" width="360" height="48" as="geometry"/></mxCell> | ||
| 36 | + <mxCell id="c29" value="<b>skills · 632, then 832 after read_skill</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#ECEFF1;gradientColor=#CFD8DC;strokeColor=#455A64;strokeWidth=2;shadow=1;fontSize=12.5;fontColor=#263238;" vertex="1" parent="1"><mxGeometry x="420" y="560" width="360" height="48" as="geometry"/></mxCell> | ||
| 37 | + <mxCell id="c30" value="<b>static · ~500, every rule applied everywhere</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#ECEFF1;gradientColor=#CFD8DC;strokeColor=#455A64;strokeWidth=2;shadow=1;fontSize=12.5;fontColor=#263238;" vertex="1" parent="1"><mxGeometry x="800" y="560" width="360" height="48" as="geometry"/></mxCell> | ||
| 38 | + <mxCell id="c31" value="prompt_tokens of the first model call (Qwen3.5 4B): a question no rule concerns costs nothing," style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#455A64;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="235.75" y="627.5" width="728.5" height="18.5" as="geometry"/></mxCell> | ||
| 39 | + <mxCell id="c32" value="and the system prompt never changes, so the server keeps it in its prompt cache." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#455A64;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="290.0" y="647.5" width="620.0" height="18.5" as="geometry"/></mxCell> | ||
| 40 | + </root> | ||
| 41 | + </mxGraphModel> | ||
| 42 | + </diagram> | ||
| 43 | +</mxfile> | ||
added
demos/dynamic-rules/dynamic-rules-flow.png +0 -0 | new file mode 100644 | ||
| Binary files /dev/null and b/demos/dynamic-rules/dynamic-rules-flow.png differ | ||
| new file mode 100644 | |||
| Binary files /dev/null and b/demos/dynamic-rules/dynamic-rules-flow.png differ | Binary files /dev/null and b/demos/dynamic-rules/dynamic-rules-flow.png differ | ||
added
demos/dynamic-rules/dynamic-rules-flow.svg +78 -0 | new file mode 100644 | ||
| @@ -0,0 +1,78 @@ | ||
| 1 | +<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="700" viewBox="0 0 1200 700" font-family="DejaVu Sans, Verdana, sans-serif"> | |
| 2 | + <defs> | |
| 3 | + <linearGradient id="gBg" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#FFFFFF"/><stop offset="100%" stop-color="#EEF2FA"/></linearGradient> | |
| 4 | + <linearGradient id="gBlue" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#E3F2FD"/><stop offset="100%" stop-color="#BBDEFB"/></linearGradient> | |
| 5 | + <linearGradient id="gBlue2" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#E1F5FE"/><stop offset="100%" stop-color="#B3E5FC"/></linearGradient> | |
| 6 | + <linearGradient id="gPurple" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#F3E5F5"/><stop offset="100%" stop-color="#E1BEE7"/></linearGradient> | |
| 7 | + <linearGradient id="gYellow" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#FFFDE7"/><stop offset="100%" stop-color="#FFF9C4"/></linearGradient> | |
| 8 | + <linearGradient id="gGrey" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#ECEFF1"/><stop offset="100%" stop-color="#CFD8DC"/></linearGradient> | |
| 9 | + <filter id="shadow" x="-30%" y="-30%" width="160%" height="160%"><feDropShadow dx="2" dy="3" stdDeviation="4" flood-color="#000000" flood-opacity="0.25"/></filter> | |
| 10 | + <marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#37474F"/></marker> | |
| 11 | + <marker id="arrowGrey" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#78909C"/></marker> | |
| 12 | + <marker id="arrowOrange" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#EF6C00"/></marker> | |
| 13 | + </defs> | |
| 14 | + <rect x="0" y="0" width="1200" height="700" fill="url(#gBg)"/> | |
| 15 | + <text x="600.0" y="38" text-anchor="middle" font-size="25" font-weight="700" fill="#1A237E">demos/dynamic-rules — only the rules a question needs</text> | |
| 16 | + <text x="600.0" y="61" text-anchor="middle" font-size="14" font-style="italic" fill="#546E7A">WIP experiment: a short system prompt, and a preGeneration hook that adds the matching rules next to the question</text> | |
| 17 | + <path d="M230,200 L330,200" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | |
| 18 | + <path d="M580,200 L880,200" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | |
| 19 | + <path d="M455,260 L455,340" fill="none" stroke="#37474F" stroke-width="2.2" marker-start="url(#arrow)" marker-end="url(#arrow)"/> | |
| 20 | + <path d="M1020,260 L1020,340" fill="none" stroke="#37474F" stroke-width="2.2" stroke-dasharray="6,4" marker-end="url(#arrow)"/> | |
| 21 | + <path d="M1020,140 L1020,100 L135,100 L135,140" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | |
| 22 | + <g filter="url(#shadow)"><rect x="40" y="140" width="190" height="120" rx="16" fill="url(#gBlue)" stroke="#1565C0" stroke-width="2"/></g> | |
| 23 | + <text x="135.0" y="180.0" text-anchor="middle" font-size="22">🧑</text> | |
| 24 | + <text x="135.0" y="203.0" text-anchor="middle" font-size="16" font-weight="700" fill="#0D47A1">User</text> | |
| 25 | + <text x="135.0" y="221.0" text-anchor="middle" font-size="11.5" fill="#0D47A1">asks for some Go code</text> | |
| 26 | + <text x="135.0" y="238.0" text-anchor="middle" font-size="11.5" fill="#0D47A1">terminal · -tui · editor</text> | |
| 27 | + <g filter="url(#shadow)"><rect x="330" y="140" width="250" height="120" rx="16" fill="url(#gYellow)" stroke="#F9A825" stroke-width="2"/></g> | |
| 28 | + <text x="455.0" y="180.0" text-anchor="middle" font-size="22">⚙️</text> | |
| 29 | + <text x="455.0" y="203.0" text-anchor="middle" font-size="16" font-weight="700" fill="#E65100">preGeneration hook</text> | |
| 30 | + <text x="455.0" y="221.0" text-anchor="middle" font-size="11.5" fill="#E65100">hooks/pick-rules.py</text> | |
| 31 | + <text x="455.0" y="238.0" text-anchor="middle" font-size="11.5" fill="#E65100">keywords found in the question</text> | |
| 32 | + <rect x="453.6" y="128" width="136.4" height="24" rx="12" fill="#F9A825"/> | |
| 33 | + <text x="521.8000000000001" y="144" text-anchor="middle" font-size="11.5" font-weight="700" fill="#FFFFFF">★ picks the rules</text> | |
| 34 | + <g filter="url(#shadow)"><rect x="880" y="140" width="280" height="120" rx="16" fill="url(#gBlue2)" stroke="#0277BD" stroke-width="2"/></g> | |
| 35 | + <text x="1020.0" y="180.0" text-anchor="middle" font-size="22">🤖</text> | |
| 36 | + <text x="1020.0" y="203.0" text-anchor="middle" font-size="16" font-weight="700" fill="#01579B">Chat model</text> | |
| 37 | + <text x="1020.0" y="221.0" text-anchor="middle" font-size="11.5" fill="#01579B">Qwen3.5-4B · short system prompt</text> | |
| 38 | + <text x="1020.0" y="238.0" text-anchor="middle" font-size="11.5" fill="#01579B">unchanged → stays in the cache</text> | |
| 39 | + <rect x="250" y="340" width="410" height="170" rx="10" fill="#FAFAFA" fill-opacity="0.7" stroke="#90A4AE" stroke-width="2" stroke-dasharray="7,5"/> | |
| 40 | + <text x="455.0" y="362" text-anchor="middle" font-size="13" font-style="italic" font-weight="700" fill="#607D8B">rules/*.md · one rule per file, with keywords</text> | |
| 41 | + <g filter="url(#shadow)"><rect x="270" y="390" width="72" height="44" rx="12" fill="url(#gGrey)" stroke="#455A64" stroke-width="2"/></g> | |
| 42 | + <text x="306.0" y="417.0" text-anchor="middle" font-size="12" font-weight="700" fill="#263238">errors</text> | |
| 43 | + <g filter="url(#shadow)"><rect x="348" y="390" width="72" height="44" rx="12" fill="url(#gGrey)" stroke="#455A64" stroke-width="2"/></g> | |
| 44 | + <text x="384.0" y="417.0" text-anchor="middle" font-size="12" font-weight="700" fill="#263238">logging</text> | |
| 45 | + <g filter="url(#shadow)"><rect x="426" y="390" width="72" height="44" rx="12" fill="url(#gGrey)" stroke="#455A64" stroke-width="2"/></g> | |
| 46 | + <text x="462.0" y="417.0" text-anchor="middle" font-size="12" font-weight="700" fill="#263238">tests</text> | |
| 47 | + <g filter="url(#shadow)"><rect x="504" y="390" width="72" height="44" rx="12" fill="url(#gYellow)" stroke="#F9A825" stroke-width="2"/></g> | |
| 48 | + <text x="540.0" y="417.0" text-anchor="middle" font-size="12" font-weight="700" fill="#E65100">http</text> | |
| 49 | + <g filter="url(#shadow)"><rect x="582" y="390" width="72" height="44" rx="12" fill="url(#gGrey)" stroke="#455A64" stroke-width="2"/></g> | |
| 50 | + <text x="618.0" y="417.0" text-anchor="middle" font-size="12" font-weight="700" fill="#263238">config</text> | |
| 51 | + <text x="455" y="470" text-anchor="middle" font-size="11.5" fill="#37474F" font-family="DejaVu Sans Mono, monospace">keywords: http, request, api, client, url…</text> | |
| 52 | + <text x="455" y="490" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">the same files serve as skills (agent.skills.yaml)</text> | |
| 53 | + <rect x="720" y="340" width="440" height="170" rx="10" fill="#FAFAFA" fill-opacity="0.7" stroke="#90A4AE" stroke-width="2" stroke-dasharray="7,5"/> | |
| 54 | + <text x="940.0" y="362" text-anchor="middle" font-size="13" font-style="italic" font-weight="700" fill="#607D8B">what the model reads for this question</text> | |
| 55 | + <text x="940" y="382" text-anchor="middle" font-size="11.5" fill="#37474F" font-family="DejaVu Sans Mono, monospace">Write a Go function that calls an HTTP API…</text> | |
| 56 | + <text x="940" y="406" text-anchor="middle" font-size="11.5" fill="#E65100" font-weight="700" font-family="DejaVu Sans Mono, monospace">[context added by a hook]</text> | |
| 57 | + <text x="940" y="426" text-anchor="middle" font-size="11.5" fill="#37474F" font-family="DejaVu Sans Mono, monospace"># Rule: http — NewRequestWithContext, Timeout</text> | |
| 58 | + <text x="940" y="450" text-anchor="middle" font-size="11.5" fill="#0277BD" font-family="DejaVu Sans Mono, monospace">[reminder] … a last line with only: — Rook</text> | |
| 59 | + <text x="940" y="480" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">turnReminder: the rule that always applies</text> | |
| 60 | + <rect x="241.0" y="216.0" width="78" height="24" rx="5" fill="#FFFFFF"/> | |
| 61 | + <text x="280" y="232.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">question</text> | |
| 62 | + <rect x="641.25" y="180.0" width="177.5" height="40" rx="5" fill="#FFFFFF"/> | |
| 63 | + <text x="730" y="197" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">question + its rules</text> | |
| 64 | + <text x="730" y="213" text-anchor="middle" font-size="10.5" fill="#78909C">[context added by a hook]</text> | |
| 65 | + <rect x="470.7" y="280.0" width="158.6" height="40" rx="5" fill="#FFFFFF"/> | |
| 66 | + <text x="550" y="297" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">reads keywords</text> | |
| 67 | + <text x="550" y="313" text-anchor="middle" font-size="10.5" fill="#78909C">← the rules that match</text> | |
| 68 | + <rect x="449.4" y="88.0" width="301.2" height="24" rx="5" fill="#FFFFFF"/> | |
| 69 | + <text x="600" y="104.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">Go code that follows the rules — Rook</text> | |
| 70 | + <g filter="url(#shadow)"><rect x="40" y="560" width="360" height="48" rx="12" fill="url(#gYellow)" stroke="#F9A825" stroke-width="2"/></g> | |
| 71 | + <text x="220.0" y="589.0" text-anchor="middle" font-size="12.5" font-weight="700" fill="#E65100">hook · 104 tokens, 223 with the http rule</text> | |
| 72 | + <g filter="url(#shadow)"><rect x="420" y="560" width="360" height="48" rx="12" fill="url(#gGrey)" stroke="#455A64" stroke-width="2"/></g> | |
| 73 | + <text x="600.0" y="589.0" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">skills · 632, then 832 after read_skill</text> | |
| 74 | + <g filter="url(#shadow)"><rect x="800" y="560" width="360" height="48" rx="12" fill="url(#gGrey)" stroke="#455A64" stroke-width="2"/></g> | |
| 75 | + <text x="980.0" y="589.0" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">static · ~500, every rule applied everywhere</text> | |
| 76 | + <text x="600" y="640" text-anchor="middle" font-size="12.5" fill="#455A64" font-style="italic">prompt_tokens of the first model call (Qwen3.5 4B): a question no rule concerns costs nothing,</text> | |
| 77 | + <text x="600" y="660" text-anchor="middle" font-size="12.5" fill="#455A64" font-style="italic">and the system prompt never changes, so the server keeps it in its prompt cache.</text> | |
| 78 | +</svg> | |
| new file mode 100644 | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | +<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="700" viewBox="0 0 1200 700" font-family="DejaVu Sans, Verdana, sans-serif"> | ||
| 2 | + <defs> | ||
| 3 | + <linearGradient id="gBg" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#FFFFFF"/><stop offset="100%" stop-color="#EEF2FA"/></linearGradient> | ||
| 4 | + <linearGradient id="gBlue" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#E3F2FD"/><stop offset="100%" stop-color="#BBDEFB"/></linearGradient> | ||
| 5 | + <linearGradient id="gBlue2" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#E1F5FE"/><stop offset="100%" stop-color="#B3E5FC"/></linearGradient> | ||
| 6 | + <linearGradient id="gPurple" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#F3E5F5"/><stop offset="100%" stop-color="#E1BEE7"/></linearGradient> | ||
| 7 | + <linearGradient id="gYellow" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#FFFDE7"/><stop offset="100%" stop-color="#FFF9C4"/></linearGradient> | ||
| 8 | + <linearGradient id="gGrey" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#ECEFF1"/><stop offset="100%" stop-color="#CFD8DC"/></linearGradient> | ||
| 9 | + <filter id="shadow" x="-30%" y="-30%" width="160%" height="160%"><feDropShadow dx="2" dy="3" stdDeviation="4" flood-color="#000000" flood-opacity="0.25"/></filter> | ||
| 10 | + <marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#37474F"/></marker> | ||
| 11 | + <marker id="arrowGrey" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#78909C"/></marker> | ||
| 12 | + <marker id="arrowOrange" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#EF6C00"/></marker> | ||
| 13 | + </defs> | ||
| 14 | + <rect x="0" y="0" width="1200" height="700" fill="url(#gBg)"/> | ||
| 15 | + <text x="600.0" y="38" text-anchor="middle" font-size="25" font-weight="700" fill="#1A237E">demos/dynamic-rules — only the rules a question needs</text> | ||
| 16 | + <text x="600.0" y="61" text-anchor="middle" font-size="14" font-style="italic" fill="#546E7A">WIP experiment: a short system prompt, and a preGeneration hook that adds the matching rules next to the question</text> | ||
| 17 | + <path d="M230,200 L330,200" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | ||
| 18 | + <path d="M580,200 L880,200" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | ||
| 19 | + <path d="M455,260 L455,340" fill="none" stroke="#37474F" stroke-width="2.2" marker-start="url(#arrow)" marker-end="url(#arrow)"/> | ||
| 20 | + <path d="M1020,260 L1020,340" fill="none" stroke="#37474F" stroke-width="2.2" stroke-dasharray="6,4" marker-end="url(#arrow)"/> | ||
| 21 | + <path d="M1020,140 L1020,100 L135,100 L135,140" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | ||
| 22 | + <g filter="url(#shadow)"><rect x="40" y="140" width="190" height="120" rx="16" fill="url(#gBlue)" stroke="#1565C0" stroke-width="2"/></g> | ||
| 23 | + <text x="135.0" y="180.0" text-anchor="middle" font-size="22">🧑</text> | ||
| 24 | + <text x="135.0" y="203.0" text-anchor="middle" font-size="16" font-weight="700" fill="#0D47A1">User</text> | ||
| 25 | + <text x="135.0" y="221.0" text-anchor="middle" font-size="11.5" fill="#0D47A1">asks for some Go code</text> | ||
| 26 | + <text x="135.0" y="238.0" text-anchor="middle" font-size="11.5" fill="#0D47A1">terminal · -tui · editor</text> | ||
| 27 | + <g filter="url(#shadow)"><rect x="330" y="140" width="250" height="120" rx="16" fill="url(#gYellow)" stroke="#F9A825" stroke-width="2"/></g> | ||
| 28 | + <text x="455.0" y="180.0" text-anchor="middle" font-size="22">⚙️</text> | ||
| 29 | + <text x="455.0" y="203.0" text-anchor="middle" font-size="16" font-weight="700" fill="#E65100">preGeneration hook</text> | ||
| 30 | + <text x="455.0" y="221.0" text-anchor="middle" font-size="11.5" fill="#E65100">hooks/pick-rules.py</text> | ||
| 31 | + <text x="455.0" y="238.0" text-anchor="middle" font-size="11.5" fill="#E65100">keywords found in the question</text> | ||
| 32 | + <rect x="453.6" y="128" width="136.4" height="24" rx="12" fill="#F9A825"/> | ||
| 33 | + <text x="521.8000000000001" y="144" text-anchor="middle" font-size="11.5" font-weight="700" fill="#FFFFFF">★ picks the rules</text> | ||
| 34 | + <g filter="url(#shadow)"><rect x="880" y="140" width="280" height="120" rx="16" fill="url(#gBlue2)" stroke="#0277BD" stroke-width="2"/></g> | ||
| 35 | + <text x="1020.0" y="180.0" text-anchor="middle" font-size="22">🤖</text> | ||
| 36 | + <text x="1020.0" y="203.0" text-anchor="middle" font-size="16" font-weight="700" fill="#01579B">Chat model</text> | ||
| 37 | + <text x="1020.0" y="221.0" text-anchor="middle" font-size="11.5" fill="#01579B">Qwen3.5-4B · short system prompt</text> | ||
| 38 | + <text x="1020.0" y="238.0" text-anchor="middle" font-size="11.5" fill="#01579B">unchanged → stays in the cache</text> | ||
| 39 | + <rect x="250" y="340" width="410" height="170" rx="10" fill="#FAFAFA" fill-opacity="0.7" stroke="#90A4AE" stroke-width="2" stroke-dasharray="7,5"/> | ||
| 40 | + <text x="455.0" y="362" text-anchor="middle" font-size="13" font-style="italic" font-weight="700" fill="#607D8B">rules/*.md · one rule per file, with keywords</text> | ||
| 41 | + <g filter="url(#shadow)"><rect x="270" y="390" width="72" height="44" rx="12" fill="url(#gGrey)" stroke="#455A64" stroke-width="2"/></g> | ||
| 42 | + <text x="306.0" y="417.0" text-anchor="middle" font-size="12" font-weight="700" fill="#263238">errors</text> | ||
| 43 | + <g filter="url(#shadow)"><rect x="348" y="390" width="72" height="44" rx="12" fill="url(#gGrey)" stroke="#455A64" stroke-width="2"/></g> | ||
| 44 | + <text x="384.0" y="417.0" text-anchor="middle" font-size="12" font-weight="700" fill="#263238">logging</text> | ||
| 45 | + <g filter="url(#shadow)"><rect x="426" y="390" width="72" height="44" rx="12" fill="url(#gGrey)" stroke="#455A64" stroke-width="2"/></g> | ||
| 46 | + <text x="462.0" y="417.0" text-anchor="middle" font-size="12" font-weight="700" fill="#263238">tests</text> | ||
| 47 | + <g filter="url(#shadow)"><rect x="504" y="390" width="72" height="44" rx="12" fill="url(#gYellow)" stroke="#F9A825" stroke-width="2"/></g> | ||
| 48 | + <text x="540.0" y="417.0" text-anchor="middle" font-size="12" font-weight="700" fill="#E65100">http</text> | ||
| 49 | + <g filter="url(#shadow)"><rect x="582" y="390" width="72" height="44" rx="12" fill="url(#gGrey)" stroke="#455A64" stroke-width="2"/></g> | ||
| 50 | + <text x="618.0" y="417.0" text-anchor="middle" font-size="12" font-weight="700" fill="#263238">config</text> | ||
| 51 | + <text x="455" y="470" text-anchor="middle" font-size="11.5" fill="#37474F" font-family="DejaVu Sans Mono, monospace">keywords: http, request, api, client, url…</text> | ||
| 52 | + <text x="455" y="490" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">the same files serve as skills (agent.skills.yaml)</text> | ||
| 53 | + <rect x="720" y="340" width="440" height="170" rx="10" fill="#FAFAFA" fill-opacity="0.7" stroke="#90A4AE" stroke-width="2" stroke-dasharray="7,5"/> | ||
| 54 | + <text x="940.0" y="362" text-anchor="middle" font-size="13" font-style="italic" font-weight="700" fill="#607D8B">what the model reads for this question</text> | ||
| 55 | + <text x="940" y="382" text-anchor="middle" font-size="11.5" fill="#37474F" font-family="DejaVu Sans Mono, monospace">Write a Go function that calls an HTTP API…</text> | ||
| 56 | + <text x="940" y="406" text-anchor="middle" font-size="11.5" fill="#E65100" font-weight="700" font-family="DejaVu Sans Mono, monospace">[context added by a hook]</text> | ||
| 57 | + <text x="940" y="426" text-anchor="middle" font-size="11.5" fill="#37474F" font-family="DejaVu Sans Mono, monospace"># Rule: http — NewRequestWithContext, Timeout</text> | ||
| 58 | + <text x="940" y="450" text-anchor="middle" font-size="11.5" fill="#0277BD" font-family="DejaVu Sans Mono, monospace">[reminder] … a last line with only: — Rook</text> | ||
| 59 | + <text x="940" y="480" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">turnReminder: the rule that always applies</text> | ||
| 60 | + <rect x="241.0" y="216.0" width="78" height="24" rx="5" fill="#FFFFFF"/> | ||
| 61 | + <text x="280" y="232.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">question</text> | ||
| 62 | + <rect x="641.25" y="180.0" width="177.5" height="40" rx="5" fill="#FFFFFF"/> | ||
| 63 | + <text x="730" y="197" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">question + its rules</text> | ||
| 64 | + <text x="730" y="213" text-anchor="middle" font-size="10.5" fill="#78909C">[context added by a hook]</text> | ||
| 65 | + <rect x="470.7" y="280.0" width="158.6" height="40" rx="5" fill="#FFFFFF"/> | ||
| 66 | + <text x="550" y="297" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">reads keywords</text> | ||
| 67 | + <text x="550" y="313" text-anchor="middle" font-size="10.5" fill="#78909C">← the rules that match</text> | ||
| 68 | + <rect x="449.4" y="88.0" width="301.2" height="24" rx="5" fill="#FFFFFF"/> | ||
| 69 | + <text x="600" y="104.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">Go code that follows the rules — Rook</text> | ||
| 70 | + <g filter="url(#shadow)"><rect x="40" y="560" width="360" height="48" rx="12" fill="url(#gYellow)" stroke="#F9A825" stroke-width="2"/></g> | ||
| 71 | + <text x="220.0" y="589.0" text-anchor="middle" font-size="12.5" font-weight="700" fill="#E65100">hook · 104 tokens, 223 with the http rule</text> | ||
| 72 | + <g filter="url(#shadow)"><rect x="420" y="560" width="360" height="48" rx="12" fill="url(#gGrey)" stroke="#455A64" stroke-width="2"/></g> | ||
| 73 | + <text x="600.0" y="589.0" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">skills · 632, then 832 after read_skill</text> | ||
| 74 | + <g filter="url(#shadow)"><rect x="800" y="560" width="360" height="48" rx="12" fill="url(#gGrey)" stroke="#455A64" stroke-width="2"/></g> | ||
| 75 | + <text x="980.0" y="589.0" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">static · ~500, every rule applied everywhere</text> | ||
| 76 | + <text x="600" y="640" text-anchor="middle" font-size="12.5" fill="#455A64" font-style="italic">prompt_tokens of the first model call (Qwen3.5 4B): a question no rule concerns costs nothing,</text> | ||
| 77 | + <text x="600" y="660" text-anchor="middle" font-size="12.5" fill="#455A64" font-style="italic">and the system prompt never changes, so the server keeps it in its prompt cache.</text> | ||
| 78 | +</svg> | ||
added
demos/dynamic-rules/hooks/pick-rules.py +64 -0 | new file mode 100755 | ||
| @@ -0,0 +1,64 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +"""preGeneration hook: add the team's rules that apply to the question. | |
| 3 | + | |
| 4 | +mm writes one JSON object on stdin ({"event": "preGeneration", "prompt": …}); | |
| 5 | +this hook reads the `keywords:` line of every rules/*.md file, keeps the rules | |
| 6 | +whose keywords appear in the question (whole words, case ignored), and answers | |
| 7 | +on stdout: | |
| 8 | + | |
| 9 | + {"context": "<the rules>", "display": "📏 rules: errors, http"} | |
| 10 | + | |
| 11 | +`context` is appended to the question the model reads (the system prompt is | |
| 12 | +left alone, so the server's prompt cache holds); `display` is shown to the | |
| 13 | +user only. No rule matches: nothing is written, mm goes on. | |
| 14 | + | |
| 15 | +The selection is plain keywords on purpose: replace `pick` by BM25, | |
| 16 | +embeddings or anything else — the contract with mm stays the same. | |
| 17 | +""" | |
| 18 | +import json | |
| 19 | +import os | |
| 20 | +import re | |
| 21 | +import sys | |
| 22 | + | |
| 23 | +MAX_RULES = 3 | |
| 24 | + | |
| 25 | + | |
| 26 | +def rules(folder): | |
| 27 | + """(name, keywords, body) of every rule file of folder.""" | |
| 28 | + out = [] | |
| 29 | + for name in sorted(os.listdir(folder)): | |
| 30 | + if not name.endswith(".md") or name == "README.md": | |
| 31 | + continue | |
| 32 | + text = open(os.path.join(folder, name), encoding="utf-8").read() | |
| 33 | + m = re.match(r"---\n(.*?)\n---\n(.*)", text, re.S) | |
| 34 | + if not m: | |
| 35 | + continue | |
| 36 | + head, body = m.groups() | |
| 37 | + kw = re.search(r"^keywords:\s*(.*)$", head, re.M) | |
| 38 | + keywords = [k.strip().lower() for k in kw.group(1).split(",")] if kw else [] | |
| 39 | + out.append((name[:-3], [k for k in keywords if k], body.strip())) | |
| 40 | + return out | |
| 41 | + | |
| 42 | + | |
| 43 | +def pick(question, all_rules): | |
| 44 | + """The rules whose keywords appear in the question, at most MAX_RULES.""" | |
| 45 | + q = question.lower() | |
| 46 | + hits = [] | |
| 47 | + for name, keywords, body in all_rules: | |
| 48 | + if any(re.search(r"\b" + re.escape(k) + r"\b", q) for k in keywords): | |
| 49 | + hits.append((name, body)) | |
| 50 | + return hits[:MAX_RULES] | |
| 51 | + | |
| 52 | + | |
| 53 | +def main(): | |
| 54 | + event = json.load(sys.stdin) | |
| 55 | + base = os.environ.get("MM_CONFIG_DIR", ".") | |
| 56 | + hits = pick(event.get("prompt", ""), rules(os.path.join(base, "rules"))) | |
| 57 | + if not hits: | |
| 58 | + return | |
| 59 | + context = "[the team's rules that apply to this question — follow them]\n\n" + "\n\n".join(body for _, body in hits) | |
| 60 | + json.dump({"context": context, "display": "📏 rules: " + ", ".join(n for n, _ in hits)}, sys.stdout) | |
| 61 | + | |
| 62 | + | |
| 63 | +if __name__ == "__main__": | |
| 64 | + main() | |
| new file mode 100755 | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | +#!/usr/bin/env python3 | ||
| 2 | +"""preGeneration hook: add the team's rules that apply to the question. | ||
| 3 | + | ||
| 4 | +mm writes one JSON object on stdin ({"event": "preGeneration", "prompt": …}); | ||
| 5 | +this hook reads the `keywords:` line of every rules/*.md file, keeps the rules | ||
| 6 | +whose keywords appear in the question (whole words, case ignored), and answers | ||
| 7 | +on stdout: | ||
| 8 | + | ||
| 9 | + {"context": "<the rules>", "display": "📏 rules: errors, http"} | ||
| 10 | + | ||
| 11 | +`context` is appended to the question the model reads (the system prompt is | ||
| 12 | +left alone, so the server's prompt cache holds); `display` is shown to the | ||
| 13 | +user only. No rule matches: nothing is written, mm goes on. | ||
| 14 | + | ||
| 15 | +The selection is plain keywords on purpose: replace `pick` by BM25, | ||
| 16 | +embeddings or anything else — the contract with mm stays the same. | ||
| 17 | +""" | ||
| 18 | +import json | ||
| 19 | +import os | ||
| 20 | +import re | ||
| 21 | +import sys | ||
| 22 | + | ||
| 23 | +MAX_RULES = 3 | ||
| 24 | + | ||
| 25 | + | ||
| 26 | +def rules(folder): | ||
| 27 | + """(name, keywords, body) of every rule file of folder.""" | ||
| 28 | + out = [] | ||
| 29 | + for name in sorted(os.listdir(folder)): | ||
| 30 | + if not name.endswith(".md") or name == "README.md": | ||
| 31 | + continue | ||
| 32 | + text = open(os.path.join(folder, name), encoding="utf-8").read() | ||
| 33 | + m = re.match(r"---\n(.*?)\n---\n(.*)", text, re.S) | ||
| 34 | + if not m: | ||
| 35 | + continue | ||
| 36 | + head, body = m.groups() | ||
| 37 | + kw = re.search(r"^keywords:\s*(.*)$", head, re.M) | ||
| 38 | + keywords = [k.strip().lower() for k in kw.group(1).split(",")] if kw else [] | ||
| 39 | + out.append((name[:-3], [k for k in keywords if k], body.strip())) | ||
| 40 | + return out | ||
| 41 | + | ||
| 42 | + | ||
| 43 | +def pick(question, all_rules): | ||
| 44 | + """The rules whose keywords appear in the question, at most MAX_RULES.""" | ||
| 45 | + q = question.lower() | ||
| 46 | + hits = [] | ||
| 47 | + for name, keywords, body in all_rules: | ||
| 48 | + if any(re.search(r"\b" + re.escape(k) + r"\b", q) for k in keywords): | ||
| 49 | + hits.append((name, body)) | ||
| 50 | + return hits[:MAX_RULES] | ||
| 51 | + | ||
| 52 | + | ||
| 53 | +def main(): | ||
| 54 | + event = json.load(sys.stdin) | ||
| 55 | + base = os.environ.get("MM_CONFIG_DIR", ".") | ||
| 56 | + hits = pick(event.get("prompt", ""), rules(os.path.join(base, "rules"))) | ||
| 57 | + if not hits: | ||
| 58 | + return | ||
| 59 | + context = "[the team's rules that apply to this question — follow them]\n\n" + "\n\n".join(body for _, body in hits) | ||
| 60 | + json.dump({"context": context, "display": "📏 rules: " + ", ".join(n for n, _ in hits)}, sys.stdout) | ||
| 61 | + | ||
| 62 | + | ||
| 63 | +if __name__ == "__main__": | ||
| 64 | + main() | ||
added
demos/dynamic-rules/rules/README.md +9 -0 | new file mode 100644 | ||
| @@ -0,0 +1,9 @@ | ||
| 1 | +# The team's rules | |
| 2 | + | |
| 3 | +One rule per file: a front matter (`name`, `description`, `keywords`), then the rule. The same files serve the three agents of this demo: | |
| 4 | + | |
| 5 | +- `.mm/agent.yaml` — the hook `hooks/pick-rules.py` reads the `keywords` and adds the rules that match the question next to it; | |
| 6 | +- `.mm/agent.skills.yaml` — this folder is the agent's `skillsDir`: each rule is a skill the model loads with `read_skill`; | |
| 7 | +- `.mm/agent.static.yaml` — every rule written in the system prompt, for comparison. | |
| 8 | + | |
| 9 | +A `README.md` at the root of a skills folder is documentation, not a skill: mm skips it. | |
| new file mode 100644 | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | +# The team's rules | ||
| 2 | + | ||
| 3 | +One rule per file: a front matter (`name`, `description`, `keywords`), then the rule. The same files serve the three agents of this demo: | ||
| 4 | + | ||
| 5 | +- `.mm/agent.yaml` — the hook `hooks/pick-rules.py` reads the `keywords` and adds the rules that match the question next to it; | ||
| 6 | +- `.mm/agent.skills.yaml` — this folder is the agent's `skillsDir`: each rule is a skill the model loads with `read_skill`; | ||
| 7 | +- `.mm/agent.static.yaml` — every rule written in the system prompt, for comparison. | ||
| 8 | + | ||
| 9 | +A `README.md` at the root of a skills folder is documentation, not a skill: mm skips it. | ||
added
demos/dynamic-rules/rules/config.md +16 -0 | new file mode 100644 | ||
| @@ -0,0 +1,16 @@ | ||
| 1 | +--- | |
| 2 | +name: config | |
| 3 | +description: The team's rule for configuration in Go — environment variables prefixed APP_. | |
| 4 | +keywords: config, configuration, settings, setting, env, environment, variable, variables | |
| 5 | +--- | |
| 6 | + | |
| 7 | +# Rule: config | |
| 8 | + | |
| 9 | +Read the settings from environment variables prefixed `APP_`, with `os.Getenv`: | |
| 10 | + | |
| 11 | + port := os.Getenv("APP_PORT") | |
| 12 | + if port == "" { | |
| 13 | + return Config{}, errors.New("APP_PORT is not set") | |
| 14 | + } | |
| 15 | + | |
| 16 | +A missing required variable is an error that names it. No config file. | |
| new file mode 100644 | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | +--- | ||
| 2 | +name: config | ||
| 3 | +description: The team's rule for configuration in Go — environment variables prefixed APP_. | ||
| 4 | +keywords: config, configuration, settings, setting, env, environment, variable, variables | ||
| 5 | +--- | ||
| 6 | + | ||
| 7 | +# Rule: config | ||
| 8 | + | ||
| 9 | +Read the settings from environment variables prefixed `APP_`, with `os.Getenv`: | ||
| 10 | + | ||
| 11 | + port := os.Getenv("APP_PORT") | ||
| 12 | + if port == "" { | ||
| 13 | + return Config{}, errors.New("APP_PORT is not set") | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | +A missing required variable is an error that names it. No config file. | ||
added
demos/dynamic-rules/rules/errors.md +13 -0 | new file mode 100644 | ||
| @@ -0,0 +1,13 @@ | ||
| 1 | +--- | |
| 2 | +name: errors | |
| 3 | +description: The team's rule for Go errors — wrap every returned error with context. | |
| 4 | +keywords: error, errors, err, fail, fails, failure, erreur, erreurs | |
| 5 | +--- | |
| 6 | + | |
| 7 | +# Rule: errors | |
| 8 | + | |
| 9 | +Wrap every error you return with what failed, using `%w`: | |
| 10 | + | |
| 11 | + return nil, fmt.Errorf("read %s: %w", path, err) | |
| 12 | + | |
| 13 | +Never return a bare `err`. Never call `log.Fatal` or `panic` in a function that can return an error. | |
| new file mode 100644 | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | +--- | ||
| 2 | +name: errors | ||
| 3 | +description: The team's rule for Go errors — wrap every returned error with context. | ||
| 4 | +keywords: error, errors, err, fail, fails, failure, erreur, erreurs | ||
| 5 | +--- | ||
| 6 | + | ||
| 7 | +# Rule: errors | ||
| 8 | + | ||
| 9 | +Wrap every error you return with what failed, using `%w`: | ||
| 10 | + | ||
| 11 | + return nil, fmt.Errorf("read %s: %w", path, err) | ||
| 12 | + | ||
| 13 | +Never return a bare `err`. Never call `log.Fatal` or `panic` in a function that can return an error. | ||
added
demos/dynamic-rules/rules/http.md +15 -0 | new file mode 100644 | ||
| @@ -0,0 +1,15 @@ | ||
| 1 | +--- | |
| 2 | +name: http | |
| 3 | +description: The team's rule for HTTP calls in Go — a context and a client with a timeout. | |
| 4 | +keywords: http, https, request, api, client, endpoint, url, download | |
| 5 | +--- | |
| 6 | + | |
| 7 | +# Rule: http | |
| 8 | + | |
| 9 | +Create every request with a context, and send it with a client that has a timeout: | |
| 10 | + | |
| 11 | + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) | |
| 12 | + client := &http.Client{Timeout: 10 * time.Second} | |
| 13 | + resp, err := client.Do(req) | |
| 14 | + | |
| 15 | +Never `http.Get` or `http.DefaultClient`. Close the body with `defer resp.Body.Close()`. | |
| new file mode 100644 | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | +--- | ||
| 2 | +name: http | ||
| 3 | +description: The team's rule for HTTP calls in Go — a context and a client with a timeout. | ||
| 4 | +keywords: http, https, request, api, client, endpoint, url, download | ||
| 5 | +--- | ||
| 6 | + | ||
| 7 | +# Rule: http | ||
| 8 | + | ||
| 9 | +Create every request with a context, and send it with a client that has a timeout: | ||
| 10 | + | ||
| 11 | + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) | ||
| 12 | + client := &http.Client{Timeout: 10 * time.Second} | ||
| 13 | + resp, err := client.Do(req) | ||
| 14 | + | ||
| 15 | +Never `http.Get` or `http.DefaultClient`. Close the body with `defer resp.Body.Close()`. | ||
added
demos/dynamic-rules/rules/logging.md +14 -0 | new file mode 100644 | ||
| @@ -0,0 +1,14 @@ | ||
| 1 | +--- | |
| 2 | +name: logging | |
| 3 | +description: The team's rule for logs in Go — log/slog with key-value pairs. | |
| 4 | +keywords: log, logs, logging, logger, trace, journal, journaliser | |
| 5 | +--- | |
| 6 | + | |
| 7 | +# Rule: logging | |
| 8 | + | |
| 9 | +Log with the standard `log/slog` package, as key-value pairs: | |
| 10 | + | |
| 11 | + slog.Info("job started", "job", name) | |
| 12 | + slog.Error("job failed", "job", name, "err", err) | |
| 13 | + | |
| 14 | +Never `fmt.Println` or the `log` package for logs. | |
| new file mode 100644 | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | +--- | ||
| 2 | +name: logging | ||
| 3 | +description: The team's rule for logs in Go — log/slog with key-value pairs. | ||
| 4 | +keywords: log, logs, logging, logger, trace, journal, journaliser | ||
| 5 | +--- | ||
| 6 | + | ||
| 7 | +# Rule: logging | ||
| 8 | + | ||
| 9 | +Log with the standard `log/slog` package, as key-value pairs: | ||
| 10 | + | ||
| 11 | + slog.Info("job started", "job", name) | ||
| 12 | + slog.Error("job failed", "job", name, "err", err) | ||
| 13 | + | ||
| 14 | +Never `fmt.Println` or the `log` package for logs. | ||
added
demos/dynamic-rules/rules/tests.md +22 -0 | new file mode 100644 | ||
| @@ -0,0 +1,22 @@ | ||
| 1 | +--- | |
| 2 | +name: tests | |
| 3 | +description: The team's rule for Go tests — table-driven, with t.Run. | |
| 4 | +keywords: test, tests, testing, unit, tester | |
| 5 | +--- | |
| 6 | + | |
| 7 | +# Rule: tests | |
| 8 | + | |
| 9 | +Write table-driven tests: a slice of cases, one `t.Run` per case. | |
| 10 | + | |
| 11 | + tests := []struct { | |
| 12 | + name string | |
| 13 | + a, b int | |
| 14 | + want int | |
| 15 | + }{ | |
| 16 | + {"zero", 0, 0, 0}, | |
| 17 | + } | |
| 18 | + for _, tt := range tests { | |
| 19 | + t.Run(tt.name, func(t *testing.T) { … }) | |
| 20 | + } | |
| 21 | + | |
| 22 | +Put the tests in the `_test` package (`package calc_test`). | |
| new file mode 100644 | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | +--- | ||
| 2 | +name: tests | ||
| 3 | +description: The team's rule for Go tests — table-driven, with t.Run. | ||
| 4 | +keywords: test, tests, testing, unit, tester | ||
| 5 | +--- | ||
| 6 | + | ||
| 7 | +# Rule: tests | ||
| 8 | + | ||
| 9 | +Write table-driven tests: a slice of cases, one `t.Run` per case. | ||
| 10 | + | ||
| 11 | + tests := []struct { | ||
| 12 | + name string | ||
| 13 | + a, b int | ||
| 14 | + want int | ||
| 15 | + }{ | ||
| 16 | + {"zero", 0, 0, 0}, | ||
| 17 | + } | ||
| 18 | + for _, tt := range tests { | ||
| 19 | + t.Run(tt.name, func(t *testing.T) { … }) | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | +Put the tests in the `_test` package (`package calc_test`). | ||
modified
demos/memory-skills-2/README.en.md +5 -0 | @@ -1,5 +1,9 @@ | ||
| 1 | 1 | # memory-skills-2 demo — the memory always in the prompt (`agentsMd.path`) |
| 2 | 2 | |
| 3 | +> **Work in progress — an experiment** (ticket 74). The aim: give an agent a memory from one conversation to the next — your preferences, the project's conventions — with small skills and a plain file, without adding anything to mm. This demo tries it, measures it on one small model, and is meant to change as the idea is tested further. Nothing here is a finished feature of mm. | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 3 | 7 | The variant of [`demos/memory-skills`](../memory-skills/README.en.md). Same agent, Jay, same memory file `.mm/memory.md`, same `remember` and `forget` skills. One difference: **`recall` reads no file**. mm puts the memory in the system prompt by itself, at the start of every conversation, with the mechanism it uses for `AGENTS.md` — pointed at the memory file: |
| 4 | 8 | |
| 5 | 9 | ```yaml |
| @@ -19,6 +23,7 @@ Version française : [README.fr.md](README.fr.md). | ||
| 19 | 23 | | `.mm/skills/remember`, `.mm/skills/forget` | the same as in `memory-skills`: one list of facts, `edit_file` only (never `write_file` on an existing file), a second read to check no fact was lost, lines always in English, never unasked — the rules were found here (runs B, C, E) then given to `memory-skills` too | |
| 20 | 24 | | `.mm/skills/recall` | no tool: "your memory is already in your prompt — answer from it, in the language the memory says" | |
| 21 | 25 | | `.mm/memory.md` | the memory, created by the first `remember` — not in the repository | |
| 26 | +| `memory-skills-2-flow.drawio`, `.svg`, `.png` | the diagram above: the draw.io source and its renderings (generated from `.claude/skills/drawio-fancy-diagram/generator/examples/memory_skills.py`) | | |
| 22 | 27 | |
| 23 | 28 | The file is read at the start of a conversation, never in the middle (the server's prompt cache is kept): a fact saved during a conversation is in its history already, and in the prompt from the next conversation on. A missing file is no error. |
| 24 | 29 | |
| @@ -1,5 +1,9 @@ | |||
| 1 | # memory-skills-2 demo — the memory always in the prompt (`agentsMd.path`) | 1 | # memory-skills-2 demo — the memory always in the prompt (`agentsMd.path`) |
| 2 | 2 | ||
| 3 | +> **Work in progress — an experiment** (ticket 74). The aim: give an agent a memory from one conversation to the next — your preferences, the project's conventions — with small skills and a plain file, without adding anything to mm. This demo tries it, measures it on one small model, and is meant to change as the idea is tested further. Nothing here is a finished feature of mm. | ||
| 4 | + | ||
| 5 | + | ||
| 6 | + | ||
| 3 | The variant of [`demos/memory-skills`](../memory-skills/README.en.md). Same agent, Jay, same memory file `.mm/memory.md`, same `remember` and `forget` skills. One difference: **`recall` reads no file**. mm puts the memory in the system prompt by itself, at the start of every conversation, with the mechanism it uses for `AGENTS.md` — pointed at the memory file: | 7 | The variant of [`demos/memory-skills`](../memory-skills/README.en.md). Same agent, Jay, same memory file `.mm/memory.md`, same `remember` and `forget` skills. One difference: **`recall` reads no file**. mm puts the memory in the system prompt by itself, at the start of every conversation, with the mechanism it uses for `AGENTS.md` — pointed at the memory file: |
| 4 | 8 | ||
| 5 | ```yaml | 9 | ```yaml |
| @@ -19,6 +23,7 @@ Version française : [README.fr.md](README.fr.md). | |||
| 19 | | `.mm/skills/remember`, `.mm/skills/forget` | the same as in `memory-skills`: one list of facts, `edit_file` only (never `write_file` on an existing file), a second read to check no fact was lost, lines always in English, never unasked — the rules were found here (runs B, C, E) then given to `memory-skills` too | | 23 | | `.mm/skills/remember`, `.mm/skills/forget` | the same as in `memory-skills`: one list of facts, `edit_file` only (never `write_file` on an existing file), a second read to check no fact was lost, lines always in English, never unasked — the rules were found here (runs B, C, E) then given to `memory-skills` too | |
| 20 | | `.mm/skills/recall` | no tool: "your memory is already in your prompt — answer from it, in the language the memory says" | | 24 | | `.mm/skills/recall` | no tool: "your memory is already in your prompt — answer from it, in the language the memory says" | |
| 21 | | `.mm/memory.md` | the memory, created by the first `remember` — not in the repository | | 25 | | `.mm/memory.md` | the memory, created by the first `remember` — not in the repository | |
| 26 | +| `memory-skills-2-flow.drawio`, `.svg`, `.png` | the diagram above: the draw.io source and its renderings (generated from `.claude/skills/drawio-fancy-diagram/generator/examples/memory_skills.py`) | | ||
| 22 | 27 | ||
| 23 | The file is read at the start of a conversation, never in the middle (the server's prompt cache is kept): a fact saved during a conversation is in its history already, and in the prompt from the next conversation on. A missing file is no error. | 28 | The file is read at the start of a conversation, never in the middle (the server's prompt cache is kept): a fact saved during a conversation is in its history already, and in the prompt from the next conversation on. A missing file is no error. |
| 24 | 29 | ||
modified
demos/memory-skills-2/README.fr.md +5 -0 | @@ -1,5 +1,9 @@ | ||
| 1 | 1 | # Démo memory-skills-2 — la mémoire toujours dans le prompt (`agentsMd.path`) |
| 2 | 2 | |
| 3 | +> **Travail en cours — une expérimentation** (ticket 74). L'objectif : donner à un agent une mémoire d'une conversation à l'autre — vos préférences, les conventions du projet — avec de petites skills et un simple fichier, sans rien ajouter à mm. Cette démo l'essaie, la mesure sur un petit modèle, et a vocation à évoluer à mesure que l'idée est éprouvée. Rien ici n'est une fonction terminée de mm. | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 3 | 7 | La variante de [`demos/memory-skills`](../memory-skills/README.fr.md). Même agent, Jay, même fichier mémoire `.mm/memory.md`, mêmes skills `remember` et `forget`. Une différence : **`recall` ne lit aucun fichier**. mm met lui-même la mémoire dans le prompt système, au début de chaque conversation, avec le mécanisme qu'il utilise pour `AGENTS.md` — pointé sur le fichier mémoire : |
| 4 | 8 | |
| 5 | 9 | ```yaml |
| @@ -19,6 +23,7 @@ English version: [README.en.md](README.en.md). | ||
| 19 | 23 | | `.mm/skills/remember`, `.mm/skills/forget` | les mêmes que dans `memory-skills` : une seule liste de faits, `edit_file` seulement (jamais `write_file` sur un fichier qui existe), une seconde lecture pour vérifier qu'aucun fait n'a été perdu, lignes toujours en anglais, jamais sans demande — règles trouvées ici (passages B, C, E) puis données aussi à `memory-skills` | |
| 20 | 24 | | `.mm/skills/recall` | aucun outil : « ta mémoire est déjà dans ton prompt — réponds à partir d'elle, dans la langue qu'elle indique » | |
| 21 | 25 | | `.mm/memory.md` | la mémoire, créée par le premier `remember` — pas dans le dépôt | |
| 26 | +| `memory-skills-2-flow.drawio`, `.svg`, `.png` | le diagramme ci-dessus : la source draw.io et ses rendus (générés depuis `.claude/skills/drawio-fancy-diagram/generator/examples/memory_skills.py`) | | |
| 22 | 27 | |
| 23 | 28 | Le fichier est lu au début d'une conversation, jamais au milieu (le cache de prompt du serveur est préservé) : un fait enregistré pendant une conversation est déjà dans son historique, et dans le prompt dès la conversation suivante. Un fichier absent n'est pas une erreur. |
| 24 | 29 | |
| @@ -1,5 +1,9 @@ | |||
| 1 | # Démo memory-skills-2 — la mémoire toujours dans le prompt (`agentsMd.path`) | 1 | # Démo memory-skills-2 — la mémoire toujours dans le prompt (`agentsMd.path`) |
| 2 | 2 | ||
| 3 | +> **Travail en cours — une expérimentation** (ticket 74). L'objectif : donner à un agent une mémoire d'une conversation à l'autre — vos préférences, les conventions du projet — avec de petites skills et un simple fichier, sans rien ajouter à mm. Cette démo l'essaie, la mesure sur un petit modèle, et a vocation à évoluer à mesure que l'idée est éprouvée. Rien ici n'est une fonction terminée de mm. | ||
| 4 | + | ||
| 5 | + | ||
| 6 | + | ||
| 3 | La variante de [`demos/memory-skills`](../memory-skills/README.fr.md). Même agent, Jay, même fichier mémoire `.mm/memory.md`, mêmes skills `remember` et `forget`. Une différence : **`recall` ne lit aucun fichier**. mm met lui-même la mémoire dans le prompt système, au début de chaque conversation, avec le mécanisme qu'il utilise pour `AGENTS.md` — pointé sur le fichier mémoire : | 7 | La variante de [`demos/memory-skills`](../memory-skills/README.fr.md). Même agent, Jay, même fichier mémoire `.mm/memory.md`, mêmes skills `remember` et `forget`. Une différence : **`recall` ne lit aucun fichier**. mm met lui-même la mémoire dans le prompt système, au début de chaque conversation, avec le mécanisme qu'il utilise pour `AGENTS.md` — pointé sur le fichier mémoire : |
| 4 | 8 | ||
| 5 | ```yaml | 9 | ```yaml |
| @@ -19,6 +23,7 @@ English version: [README.en.md](README.en.md). | |||
| 19 | | `.mm/skills/remember`, `.mm/skills/forget` | les mêmes que dans `memory-skills` : une seule liste de faits, `edit_file` seulement (jamais `write_file` sur un fichier qui existe), une seconde lecture pour vérifier qu'aucun fait n'a été perdu, lignes toujours en anglais, jamais sans demande — règles trouvées ici (passages B, C, E) puis données aussi à `memory-skills` | | 23 | | `.mm/skills/remember`, `.mm/skills/forget` | les mêmes que dans `memory-skills` : une seule liste de faits, `edit_file` seulement (jamais `write_file` sur un fichier qui existe), une seconde lecture pour vérifier qu'aucun fait n'a été perdu, lignes toujours en anglais, jamais sans demande — règles trouvées ici (passages B, C, E) puis données aussi à `memory-skills` | |
| 20 | | `.mm/skills/recall` | aucun outil : « ta mémoire est déjà dans ton prompt — réponds à partir d'elle, dans la langue qu'elle indique » | | 24 | | `.mm/skills/recall` | aucun outil : « ta mémoire est déjà dans ton prompt — réponds à partir d'elle, dans la langue qu'elle indique » | |
| 21 | | `.mm/memory.md` | la mémoire, créée par le premier `remember` — pas dans le dépôt | | 25 | | `.mm/memory.md` | la mémoire, créée par le premier `remember` — pas dans le dépôt | |
| 26 | +| `memory-skills-2-flow.drawio`, `.svg`, `.png` | le diagramme ci-dessus : la source draw.io et ses rendus (générés depuis `.claude/skills/drawio-fancy-diagram/generator/examples/memory_skills.py`) | | ||
| 22 | 27 | ||
| 23 | Le fichier est lu au début d'une conversation, jamais au milieu (le cache de prompt du serveur est préservé) : un fait enregistré pendant une conversation est déjà dans son historique, et dans le prompt dès la conversation suivante. Un fichier absent n'est pas une erreur. | 28 | Le fichier est lu au début d'une conversation, jamais au milieu (le cache de prompt du serveur est préservé) : un fait enregistré pendant une conversation est déjà dans son historique, et dans le prompt dès la conversation suivante. Un fichier absent n'est pas une erreur. |
| 24 | 29 | ||
added
demos/memory-skills-2/memory-skills-2-flow.drawio +41 -0 | new file mode 100644 | ||
| @@ -0,0 +1,41 @@ | ||
| 1 | +<mxfile host="app.diagrams.net"> | |
| 2 | + <diagram id="memory-skills-2-flow" name="demos/memory-skills-2 — the memory always in the prompt"> | |
| 3 | + <mxGraphModel dx="1200" dy="680" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1200" pageHeight="680" background="#F5F7FC" math="0" shadow="0"> | |
| 4 | + <root> | |
| 5 | + <mxCell id="0"/> | |
| 6 | + <mxCell id="1" parent="0"/> | |
| 7 | + <mxCell id="title" value="<b style="font-size:25px;color:#1A237E">demos/memory-skills-2 — the memory always in the prompt</b><br><i style="font-size:14px;color:#546E7A">WIP experiment: agentsMd.path reads .mm/memory.md into the system prompt — no mm code</i>" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;" vertex="1" parent="1"><mxGeometry x="150.0" y="12" width="900" height="56" as="geometry"/></mxCell> | |
| 8 | + <mxCell id="c17" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="230" y="200" as="sourcePoint"/><mxPoint x="330" y="200" as="targetPoint"/></mxGeometry></mxCell> | |
| 9 | + <mxCell id="c19" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="580" y="200" as="sourcePoint"/><mxPoint x="680" y="200" as="targetPoint"/></mxGeometry></mxCell> | |
| 10 | + <mxCell id="c21" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="1068" y="290" as="sourcePoint"/><mxPoint x="1068" y="360" as="targetPoint"/></mxGeometry></mxCell> | |
| 11 | + <mxCell id="c23" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="680" y="445" as="sourcePoint"/><mxPoint x="455" y="260" as="targetPoint"/><Array as="points"><mxPoint x="455" y="445"/></Array></mxGeometry></mxCell> | |
| 12 | + <mxCell id="c25" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="455" y="140" as="sourcePoint"/><mxPoint x="135" y="140" as="targetPoint"/><Array as="points"><mxPoint x="455" y="100"/><mxPoint x="135" y="100"/></Array></mxGeometry></mxCell> | |
| 13 | + <mxCell id="c1" value="🧑<br><b style="font-size:16px">User</b><br><span style="font-size:11.5px;font-weight:normal">"remember…", "forget…"<br>or a question</span>" style="rounded=1;arcSize=14;whiteSpace=wrap;html=1;fillColor=#E3F2FD;gradientColor=#BBDEFB;strokeColor=#1565C0;strokeWidth=2;shadow=1;fontSize=20;fontColor=#0D47A1;" vertex="1" parent="1"><mxGeometry x="40" y="140" width="190" height="120" as="geometry"/></mxCell> | |
| 14 | + <mxCell id="c2" value="🤖<br><b style="font-size:16px">Jay</b><br><span style="font-size:11.5px;font-weight:normal">Qwen3.5-4B<br>the memory in its system prompt</span>" style="rounded=1;arcSize=14;whiteSpace=wrap;html=1;fillColor=#E1F5FE;gradientColor=#B3E5FC;strokeColor=#0277BD;strokeWidth=2;shadow=1;fontSize=20;fontColor=#01579B;" vertex="1" parent="1"><mxGeometry x="330" y="140" width="250" height="120" as="geometry"/></mxCell> | |
| 15 | + <mxCell id="c3" value="<i><b>skills · .mm/skills/</b></i>" style="rounded=1;arcSize=3;html=1;dashed=1;dashPattern=7 5;fillColor=#FAFAFA;strokeColor=#90A4AE;strokeWidth=2;verticalAlign=top;fontColor=#607D8B;fontSize=13;" vertex="1" parent="1"><mxGeometry x="680" y="110" width="480" height="180" as="geometry"/></mxCell> | |
| 16 | + <mxCell id="c4" value="<b>remember</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#FFFDE7;gradientColor=#FFF9C4;strokeColor=#F9A825;strokeWidth=2;shadow=1;fontSize=13;fontColor=#E65100;" vertex="1" parent="1"><mxGeometry x="705" y="160" width="135" height="50" as="geometry"/></mxCell> | |
| 17 | + <mxCell id="c5" value="<b>recall</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#F3E5F5;gradientColor=#E1BEE7;strokeColor=#6A1B9A;strokeWidth=2;shadow=1;fontSize=13;fontColor=#4A148C;" vertex="1" parent="1"><mxGeometry x="853" y="160" width="135" height="50" as="geometry"/></mxCell> | |
| 18 | + <mxCell id="c6" value="<b>forget</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#FFFDE7;gradientColor=#FFF9C4;strokeColor=#F9A825;strokeWidth=2;shadow=1;fontSize=13;fontColor=#E65100;" vertex="1" parent="1"><mxGeometry x="1001" y="160" width="135" height="50" as="geometry"/></mxCell> | |
| 19 | + <mxCell id="c7" value="add / replace a line" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="706.9" y="227.5" width="130.2" height="16.5" as="geometry"/></mxCell> | |
| 20 | + <mxCell id="c8" value="no tool: answer" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="871.175" y="227.5" width="97.65" height="16.5" as="geometry"/></mxCell> | |
| 21 | + <mxCell id="c9" value="from the prompt" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="871.175" y="243.5" width="97.65" height="16.5" as="geometry"/></mxCell> | |
| 22 | + <mxCell id="c10" value="remove a line" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="1025.685" y="227.5" width="84.63" height="16.5" as="geometry"/></mxCell> | |
| 23 | + <mxCell id="c11" value="<i><b>.mm/memory.md · one fact per line</b></i>" style="rounded=1;arcSize=3;html=1;dashed=1;dashPattern=7 5;fillColor=#FAFAFA;strokeColor=#90A4AE;strokeWidth=2;verticalAlign=top;fontColor=#607D8B;fontSize=13;" vertex="1" parent="1"><mxGeometry x="680" y="360" width="480" height="170" as="geometry"/></mxCell> | |
| 24 | + <mxCell id="c12" value="# Memory" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12;fontColor=#37474F;fontStyle=1;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="890.24" y="392" width="59.519999999999996" height="18" as="geometry"/></mxCell> | |
| 25 | + <mxCell id="c13" value="- Sam is the user." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="853.04" y="418" width="133.92" height="18" as="geometry"/></mxCell> | |
| 26 | + <mxCell id="c14" value="- Prefers answers in French." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="815.84" y="440" width="208.32" height="18" as="geometry"/></mxCell> | |
| 27 | + <mxCell id="c15" value="- Release tags are rel-YYYY.MM." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="804.6800000000001" y="462" width="230.64" height="18" as="geometry"/></mxCell> | |
| 28 | + <mxCell id="c16" value="a plain file: read it, correct it, delete it" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="776.78" y="495.5" width="286.44" height="16.5" as="geometry"/></mxCell> | |
| 29 | + <mxCell id="c18" value="<b style="font-size:12.5px;color:#263238">question</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="241.0" y="216.0" width="78" height="24" as="geometry"/></mxCell> | |
| 30 | + <mxCell id="c20" value="<b style="font-size:12.5px;color:#263238">read_skill</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="589.0" y="216.0" width="82" height="24" as="geometry"/></mxCell> | |
| 31 | + <mxCell id="c22" value="<b style="font-size:12.5px;color:#263238">edit_file</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="1075.0" y="313.0" width="70" height="24" as="geometry"/></mxCell> | |
| 32 | + <mxCell id="c24" value="<b style="font-size:12.5px;color:#263238">agentsMd.path</b><br><span style="font-size:10.5px;color:#78909C">at the start of every conversation</span>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="467.0" y="425.0" width="200" height="40" as="geometry"/></mxCell> | |
| 33 | + <mxCell id="c26" value="<b style="font-size:12.5px;color:#263238">the answer</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="247.0" y="88.0" width="96.0" height="24" as="geometry"/></mxCell> | |
| 34 | + <mxCell id="c27" value="<b>French in 7 of 7 answers after it was saved</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#F3E5F5;gradientColor=#E1BEE7;strokeColor=#6A1B9A;strokeWidth=2;shadow=1;fontSize=12.5;fontColor=#4A148C;" vertex="1" parent="1"><mxGeometry x="40" y="560" width="360" height="48" as="geometry"/></mxCell> | |
| 35 | + <mxCell id="c28" value="<b>8/8 right · no fact lost in 6 writes</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#ECEFF1;gradientColor=#CFD8DC;strokeColor=#455A64;strokeWidth=2;shadow=1;fontSize=12.5;fontColor=#263238;" vertex="1" parent="1"><mxGeometry x="420" y="560" width="360" height="48" as="geometry"/></mxCell> | |
| 36 | + <mxCell id="c29" value="<b>~10 tokens a fact, on every call — cached</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#ECEFF1;gradientColor=#CFD8DC;strokeColor=#455A64;strokeWidth=2;shadow=1;fontSize=12.5;fontColor=#263238;" vertex="1" parent="1"><mxGeometry x="800" y="560" width="360" height="48" as="geometry"/></mxCell> | |
| 37 | + <mxCell id="c30" value="Read at the start of a conversation, never in the middle: the prompt cache holds. Same skills as memory-skills." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#455A64;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="169.875" y="627.5" width="860.25" height="18.5" as="geometry"/></mxCell> | |
| 38 | + </root> | |
| 39 | + </mxGraphModel> | |
| 40 | + </diagram> | |
| 41 | +</mxfile> | |
| new file mode 100644 | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | +<mxfile host="app.diagrams.net"> | ||
| 2 | + <diagram id="memory-skills-2-flow" name="demos/memory-skills-2 — the memory always in the prompt"> | ||
| 3 | + <mxGraphModel dx="1200" dy="680" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1200" pageHeight="680" background="#F5F7FC" math="0" shadow="0"> | ||
| 4 | + <root> | ||
| 5 | + <mxCell id="0"/> | ||
| 6 | + <mxCell id="1" parent="0"/> | ||
| 7 | + <mxCell id="title" value="<b style="font-size:25px;color:#1A237E">demos/memory-skills-2 — the memory always in the prompt</b><br><i style="font-size:14px;color:#546E7A">WIP experiment: agentsMd.path reads .mm/memory.md into the system prompt — no mm code</i>" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;" vertex="1" parent="1"><mxGeometry x="150.0" y="12" width="900" height="56" as="geometry"/></mxCell> | ||
| 8 | + <mxCell id="c17" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="230" y="200" as="sourcePoint"/><mxPoint x="330" y="200" as="targetPoint"/></mxGeometry></mxCell> | ||
| 9 | + <mxCell id="c19" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="580" y="200" as="sourcePoint"/><mxPoint x="680" y="200" as="targetPoint"/></mxGeometry></mxCell> | ||
| 10 | + <mxCell id="c21" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="1068" y="290" as="sourcePoint"/><mxPoint x="1068" y="360" as="targetPoint"/></mxGeometry></mxCell> | ||
| 11 | + <mxCell id="c23" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="680" y="445" as="sourcePoint"/><mxPoint x="455" y="260" as="targetPoint"/><Array as="points"><mxPoint x="455" y="445"/></Array></mxGeometry></mxCell> | ||
| 12 | + <mxCell id="c25" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="455" y="140" as="sourcePoint"/><mxPoint x="135" y="140" as="targetPoint"/><Array as="points"><mxPoint x="455" y="100"/><mxPoint x="135" y="100"/></Array></mxGeometry></mxCell> | ||
| 13 | + <mxCell id="c1" value="🧑<br><b style="font-size:16px">User</b><br><span style="font-size:11.5px;font-weight:normal">"remember…", "forget…"<br>or a question</span>" style="rounded=1;arcSize=14;whiteSpace=wrap;html=1;fillColor=#E3F2FD;gradientColor=#BBDEFB;strokeColor=#1565C0;strokeWidth=2;shadow=1;fontSize=20;fontColor=#0D47A1;" vertex="1" parent="1"><mxGeometry x="40" y="140" width="190" height="120" as="geometry"/></mxCell> | ||
| 14 | + <mxCell id="c2" value="🤖<br><b style="font-size:16px">Jay</b><br><span style="font-size:11.5px;font-weight:normal">Qwen3.5-4B<br>the memory in its system prompt</span>" style="rounded=1;arcSize=14;whiteSpace=wrap;html=1;fillColor=#E1F5FE;gradientColor=#B3E5FC;strokeColor=#0277BD;strokeWidth=2;shadow=1;fontSize=20;fontColor=#01579B;" vertex="1" parent="1"><mxGeometry x="330" y="140" width="250" height="120" as="geometry"/></mxCell> | ||
| 15 | + <mxCell id="c3" value="<i><b>skills · .mm/skills/</b></i>" style="rounded=1;arcSize=3;html=1;dashed=1;dashPattern=7 5;fillColor=#FAFAFA;strokeColor=#90A4AE;strokeWidth=2;verticalAlign=top;fontColor=#607D8B;fontSize=13;" vertex="1" parent="1"><mxGeometry x="680" y="110" width="480" height="180" as="geometry"/></mxCell> | ||
| 16 | + <mxCell id="c4" value="<b>remember</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#FFFDE7;gradientColor=#FFF9C4;strokeColor=#F9A825;strokeWidth=2;shadow=1;fontSize=13;fontColor=#E65100;" vertex="1" parent="1"><mxGeometry x="705" y="160" width="135" height="50" as="geometry"/></mxCell> | ||
| 17 | + <mxCell id="c5" value="<b>recall</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#F3E5F5;gradientColor=#E1BEE7;strokeColor=#6A1B9A;strokeWidth=2;shadow=1;fontSize=13;fontColor=#4A148C;" vertex="1" parent="1"><mxGeometry x="853" y="160" width="135" height="50" as="geometry"/></mxCell> | ||
| 18 | + <mxCell id="c6" value="<b>forget</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#FFFDE7;gradientColor=#FFF9C4;strokeColor=#F9A825;strokeWidth=2;shadow=1;fontSize=13;fontColor=#E65100;" vertex="1" parent="1"><mxGeometry x="1001" y="160" width="135" height="50" as="geometry"/></mxCell> | ||
| 19 | + <mxCell id="c7" value="add / replace a line" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="706.9" y="227.5" width="130.2" height="16.5" as="geometry"/></mxCell> | ||
| 20 | + <mxCell id="c8" value="no tool: answer" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="871.175" y="227.5" width="97.65" height="16.5" as="geometry"/></mxCell> | ||
| 21 | + <mxCell id="c9" value="from the prompt" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="871.175" y="243.5" width="97.65" height="16.5" as="geometry"/></mxCell> | ||
| 22 | + <mxCell id="c10" value="remove a line" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="1025.685" y="227.5" width="84.63" height="16.5" as="geometry"/></mxCell> | ||
| 23 | + <mxCell id="c11" value="<i><b>.mm/memory.md · one fact per line</b></i>" style="rounded=1;arcSize=3;html=1;dashed=1;dashPattern=7 5;fillColor=#FAFAFA;strokeColor=#90A4AE;strokeWidth=2;verticalAlign=top;fontColor=#607D8B;fontSize=13;" vertex="1" parent="1"><mxGeometry x="680" y="360" width="480" height="170" as="geometry"/></mxCell> | ||
| 24 | + <mxCell id="c12" value="# Memory" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12;fontColor=#37474F;fontStyle=1;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="890.24" y="392" width="59.519999999999996" height="18" as="geometry"/></mxCell> | ||
| 25 | + <mxCell id="c13" value="- Sam is the user." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="853.04" y="418" width="133.92" height="18" as="geometry"/></mxCell> | ||
| 26 | + <mxCell id="c14" value="- Prefers answers in French." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="815.84" y="440" width="208.32" height="18" as="geometry"/></mxCell> | ||
| 27 | + <mxCell id="c15" value="- Release tags are rel-YYYY.MM." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="804.6800000000001" y="462" width="230.64" height="18" as="geometry"/></mxCell> | ||
| 28 | + <mxCell id="c16" value="a plain file: read it, correct it, delete it" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="776.78" y="495.5" width="286.44" height="16.5" as="geometry"/></mxCell> | ||
| 29 | + <mxCell id="c18" value="<b style="font-size:12.5px;color:#263238">question</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="241.0" y="216.0" width="78" height="24" as="geometry"/></mxCell> | ||
| 30 | + <mxCell id="c20" value="<b style="font-size:12.5px;color:#263238">read_skill</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="589.0" y="216.0" width="82" height="24" as="geometry"/></mxCell> | ||
| 31 | + <mxCell id="c22" value="<b style="font-size:12.5px;color:#263238">edit_file</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="1075.0" y="313.0" width="70" height="24" as="geometry"/></mxCell> | ||
| 32 | + <mxCell id="c24" value="<b style="font-size:12.5px;color:#263238">agentsMd.path</b><br><span style="font-size:10.5px;color:#78909C">at the start of every conversation</span>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="467.0" y="425.0" width="200" height="40" as="geometry"/></mxCell> | ||
| 33 | + <mxCell id="c26" value="<b style="font-size:12.5px;color:#263238">the answer</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="247.0" y="88.0" width="96.0" height="24" as="geometry"/></mxCell> | ||
| 34 | + <mxCell id="c27" value="<b>French in 7 of 7 answers after it was saved</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#F3E5F5;gradientColor=#E1BEE7;strokeColor=#6A1B9A;strokeWidth=2;shadow=1;fontSize=12.5;fontColor=#4A148C;" vertex="1" parent="1"><mxGeometry x="40" y="560" width="360" height="48" as="geometry"/></mxCell> | ||
| 35 | + <mxCell id="c28" value="<b>8/8 right · no fact lost in 6 writes</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#ECEFF1;gradientColor=#CFD8DC;strokeColor=#455A64;strokeWidth=2;shadow=1;fontSize=12.5;fontColor=#263238;" vertex="1" parent="1"><mxGeometry x="420" y="560" width="360" height="48" as="geometry"/></mxCell> | ||
| 36 | + <mxCell id="c29" value="<b>~10 tokens a fact, on every call — cached</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#ECEFF1;gradientColor=#CFD8DC;strokeColor=#455A64;strokeWidth=2;shadow=1;fontSize=12.5;fontColor=#263238;" vertex="1" parent="1"><mxGeometry x="800" y="560" width="360" height="48" as="geometry"/></mxCell> | ||
| 37 | + <mxCell id="c30" value="Read at the start of a conversation, never in the middle: the prompt cache holds. Same skills as memory-skills." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#455A64;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="169.875" y="627.5" width="860.25" height="18.5" as="geometry"/></mxCell> | ||
| 38 | + </root> | ||
| 39 | + </mxGraphModel> | ||
| 40 | + </diagram> | ||
| 41 | +</mxfile> | ||
added
demos/memory-skills-2/memory-skills-2-flow.png +0 -0 | new file mode 100644 | ||
| Binary files /dev/null and b/demos/memory-skills-2/memory-skills-2-flow.png differ | ||
| new file mode 100644 | |||
| Binary files /dev/null and b/demos/memory-skills-2/memory-skills-2-flow.png differ | Binary files /dev/null and b/demos/memory-skills-2/memory-skills-2-flow.png differ | ||
added
demos/memory-skills-2/memory-skills-2-flow.svg +69 -0 | new file mode 100644 | ||
| @@ -0,0 +1,69 @@ | ||
| 1 | +<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="680" viewBox="0 0 1200 680" font-family="DejaVu Sans, Verdana, sans-serif"> | |
| 2 | + <defs> | |
| 3 | + <linearGradient id="gBg" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#FFFFFF"/><stop offset="100%" stop-color="#EEF2FA"/></linearGradient> | |
| 4 | + <linearGradient id="gBlue" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#E3F2FD"/><stop offset="100%" stop-color="#BBDEFB"/></linearGradient> | |
| 5 | + <linearGradient id="gBlue2" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#E1F5FE"/><stop offset="100%" stop-color="#B3E5FC"/></linearGradient> | |
| 6 | + <linearGradient id="gPurple" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#F3E5F5"/><stop offset="100%" stop-color="#E1BEE7"/></linearGradient> | |
| 7 | + <linearGradient id="gYellow" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#FFFDE7"/><stop offset="100%" stop-color="#FFF9C4"/></linearGradient> | |
| 8 | + <linearGradient id="gGrey" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#ECEFF1"/><stop offset="100%" stop-color="#CFD8DC"/></linearGradient> | |
| 9 | + <filter id="shadow" x="-30%" y="-30%" width="160%" height="160%"><feDropShadow dx="2" dy="3" stdDeviation="4" flood-color="#000000" flood-opacity="0.25"/></filter> | |
| 10 | + <marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#37474F"/></marker> | |
| 11 | + <marker id="arrowGrey" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#78909C"/></marker> | |
| 12 | + <marker id="arrowOrange" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#EF6C00"/></marker> | |
| 13 | + </defs> | |
| 14 | + <rect x="0" y="0" width="1200" height="680" fill="url(#gBg)"/> | |
| 15 | + <text x="600.0" y="38" text-anchor="middle" font-size="25" font-weight="700" fill="#1A237E">demos/memory-skills-2 — the memory always in the prompt</text> | |
| 16 | + <text x="600.0" y="61" text-anchor="middle" font-size="14" font-style="italic" fill="#546E7A">WIP experiment: agentsMd.path reads .mm/memory.md into the system prompt — no mm code</text> | |
| 17 | + <path d="M230,200 L330,200" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | |
| 18 | + <path d="M580,200 L680,200" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | |
| 19 | + <path d="M1068,290 L1068,360" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | |
| 20 | + <path d="M680,445 L455,445 L455,260" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | |
| 21 | + <path d="M455,140 L455,100 L135,100 L135,140" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | |
| 22 | + <g filter="url(#shadow)"><rect x="40" y="140" width="190" height="120" rx="16" fill="url(#gBlue)" stroke="#1565C0" stroke-width="2"/></g> | |
| 23 | + <text x="135.0" y="180.0" text-anchor="middle" font-size="22">🧑</text> | |
| 24 | + <text x="135.0" y="203.0" text-anchor="middle" font-size="16" font-weight="700" fill="#0D47A1">User</text> | |
| 25 | + <text x="135.0" y="221.0" text-anchor="middle" font-size="11.5" fill="#0D47A1">"remember…", "forget…"</text> | |
| 26 | + <text x="135.0" y="238.0" text-anchor="middle" font-size="11.5" fill="#0D47A1">or a question</text> | |
| 27 | + <g filter="url(#shadow)"><rect x="330" y="140" width="250" height="120" rx="16" fill="url(#gBlue2)" stroke="#0277BD" stroke-width="2"/></g> | |
| 28 | + <text x="455.0" y="180.0" text-anchor="middle" font-size="22">🤖</text> | |
| 29 | + <text x="455.0" y="203.0" text-anchor="middle" font-size="16" font-weight="700" fill="#01579B">Jay</text> | |
| 30 | + <text x="455.0" y="221.0" text-anchor="middle" font-size="11.5" fill="#01579B">Qwen3.5-4B</text> | |
| 31 | + <text x="455.0" y="238.0" text-anchor="middle" font-size="11.5" fill="#01579B">the memory in its system prompt</text> | |
| 32 | + <rect x="680" y="110" width="480" height="180" rx="10" fill="#FAFAFA" fill-opacity="0.7" stroke="#90A4AE" stroke-width="2" stroke-dasharray="7,5"/> | |
| 33 | + <text x="920.0" y="132" text-anchor="middle" font-size="13" font-style="italic" font-weight="700" fill="#607D8B">skills · .mm/skills/</text> | |
| 34 | + <g filter="url(#shadow)"><rect x="705" y="160" width="135" height="50" rx="12" fill="url(#gYellow)" stroke="#F9A825" stroke-width="2"/></g> | |
| 35 | + <text x="772.5" y="190.0" text-anchor="middle" font-size="13" font-weight="700" fill="#E65100">remember</text> | |
| 36 | + <g filter="url(#shadow)"><rect x="853" y="160" width="135" height="50" rx="12" fill="url(#gPurple)" stroke="#6A1B9A" stroke-width="2"/></g> | |
| 37 | + <text x="920.5" y="190.0" text-anchor="middle" font-size="13" font-weight="700" fill="#4A148C">recall</text> | |
| 38 | + <g filter="url(#shadow)"><rect x="1001" y="160" width="135" height="50" rx="12" fill="url(#gYellow)" stroke="#F9A825" stroke-width="2"/></g> | |
| 39 | + <text x="1068.5" y="190.0" text-anchor="middle" font-size="13" font-weight="700" fill="#E65100">forget</text> | |
| 40 | + <text x="772" y="238" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">add / replace a line</text> | |
| 41 | + <text x="920" y="238" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">no tool: answer</text> | |
| 42 | + <text x="920" y="254" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">from the prompt</text> | |
| 43 | + <text x="1068" y="238" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">remove a line</text> | |
| 44 | + <rect x="680" y="360" width="480" height="170" rx="10" fill="#FAFAFA" fill-opacity="0.7" stroke="#90A4AE" stroke-width="2" stroke-dasharray="7,5"/> | |
| 45 | + <text x="920.0" y="382" text-anchor="middle" font-size="13" font-style="italic" font-weight="700" fill="#607D8B">.mm/memory.md · one fact per line</text> | |
| 46 | + <text x="920" y="404" text-anchor="middle" font-size="12" fill="#37474F" font-weight="700" font-family="DejaVu Sans Mono, monospace"># Memory</text> | |
| 47 | + <text x="920" y="430" text-anchor="middle" font-size="12" fill="#37474F" font-family="DejaVu Sans Mono, monospace">- Sam is the user.</text> | |
| 48 | + <text x="920" y="452" text-anchor="middle" font-size="12" fill="#37474F" font-family="DejaVu Sans Mono, monospace">- Prefers answers in French.</text> | |
| 49 | + <text x="920" y="474" text-anchor="middle" font-size="12" fill="#37474F" font-family="DejaVu Sans Mono, monospace">- Release tags are rel-YYYY.MM.</text> | |
| 50 | + <text x="920" y="506" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">a plain file: read it, correct it, delete it</text> | |
| 51 | + <rect x="241.0" y="216.0" width="78" height="24" rx="5" fill="#FFFFFF"/> | |
| 52 | + <text x="280" y="232.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">question</text> | |
| 53 | + <rect x="589.0" y="216.0" width="82" height="24" rx="5" fill="#FFFFFF"/> | |
| 54 | + <text x="630" y="232.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">read_skill</text> | |
| 55 | + <rect x="1075.0" y="313.0" width="70" height="24" rx="5" fill="#FFFFFF"/> | |
| 56 | + <text x="1110" y="329.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">edit_file</text> | |
| 57 | + <rect x="467.0" y="425.0" width="200" height="40" rx="5" fill="#FFFFFF"/> | |
| 58 | + <text x="567" y="442" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">agentsMd.path</text> | |
| 59 | + <text x="567" y="458" text-anchor="middle" font-size="10.5" fill="#78909C">at the start of every conversation</text> | |
| 60 | + <rect x="247.0" y="88.0" width="96.0" height="24" rx="5" fill="#FFFFFF"/> | |
| 61 | + <text x="295" y="104.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">the answer</text> | |
| 62 | + <g filter="url(#shadow)"><rect x="40" y="560" width="360" height="48" rx="12" fill="url(#gPurple)" stroke="#6A1B9A" stroke-width="2"/></g> | |
| 63 | + <text x="220.0" y="589.0" text-anchor="middle" font-size="12.5" font-weight="700" fill="#4A148C">French in 7 of 7 answers after it was saved</text> | |
| 64 | + <g filter="url(#shadow)"><rect x="420" y="560" width="360" height="48" rx="12" fill="url(#gGrey)" stroke="#455A64" stroke-width="2"/></g> | |
| 65 | + <text x="600.0" y="589.0" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">8/8 right · no fact lost in 6 writes</text> | |
| 66 | + <g filter="url(#shadow)"><rect x="800" y="560" width="360" height="48" rx="12" fill="url(#gGrey)" stroke="#455A64" stroke-width="2"/></g> | |
| 67 | + <text x="980.0" y="589.0" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">~10 tokens a fact, on every call — cached</text> | |
| 68 | + <text x="600" y="640" text-anchor="middle" font-size="12.5" fill="#455A64" font-style="italic">Read at the start of a conversation, never in the middle: the prompt cache holds. Same skills as memory-skills.</text> | |
| 69 | +</svg> | |
| new file mode 100644 | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | +<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="680" viewBox="0 0 1200 680" font-family="DejaVu Sans, Verdana, sans-serif"> | ||
| 2 | + <defs> | ||
| 3 | + <linearGradient id="gBg" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#FFFFFF"/><stop offset="100%" stop-color="#EEF2FA"/></linearGradient> | ||
| 4 | + <linearGradient id="gBlue" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#E3F2FD"/><stop offset="100%" stop-color="#BBDEFB"/></linearGradient> | ||
| 5 | + <linearGradient id="gBlue2" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#E1F5FE"/><stop offset="100%" stop-color="#B3E5FC"/></linearGradient> | ||
| 6 | + <linearGradient id="gPurple" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#F3E5F5"/><stop offset="100%" stop-color="#E1BEE7"/></linearGradient> | ||
| 7 | + <linearGradient id="gYellow" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#FFFDE7"/><stop offset="100%" stop-color="#FFF9C4"/></linearGradient> | ||
| 8 | + <linearGradient id="gGrey" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#ECEFF1"/><stop offset="100%" stop-color="#CFD8DC"/></linearGradient> | ||
| 9 | + <filter id="shadow" x="-30%" y="-30%" width="160%" height="160%"><feDropShadow dx="2" dy="3" stdDeviation="4" flood-color="#000000" flood-opacity="0.25"/></filter> | ||
| 10 | + <marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#37474F"/></marker> | ||
| 11 | + <marker id="arrowGrey" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#78909C"/></marker> | ||
| 12 | + <marker id="arrowOrange" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#EF6C00"/></marker> | ||
| 13 | + </defs> | ||
| 14 | + <rect x="0" y="0" width="1200" height="680" fill="url(#gBg)"/> | ||
| 15 | + <text x="600.0" y="38" text-anchor="middle" font-size="25" font-weight="700" fill="#1A237E">demos/memory-skills-2 — the memory always in the prompt</text> | ||
| 16 | + <text x="600.0" y="61" text-anchor="middle" font-size="14" font-style="italic" fill="#546E7A">WIP experiment: agentsMd.path reads .mm/memory.md into the system prompt — no mm code</text> | ||
| 17 | + <path d="M230,200 L330,200" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | ||
| 18 | + <path d="M580,200 L680,200" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | ||
| 19 | + <path d="M1068,290 L1068,360" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | ||
| 20 | + <path d="M680,445 L455,445 L455,260" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | ||
| 21 | + <path d="M455,140 L455,100 L135,100 L135,140" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | ||
| 22 | + <g filter="url(#shadow)"><rect x="40" y="140" width="190" height="120" rx="16" fill="url(#gBlue)" stroke="#1565C0" stroke-width="2"/></g> | ||
| 23 | + <text x="135.0" y="180.0" text-anchor="middle" font-size="22">🧑</text> | ||
| 24 | + <text x="135.0" y="203.0" text-anchor="middle" font-size="16" font-weight="700" fill="#0D47A1">User</text> | ||
| 25 | + <text x="135.0" y="221.0" text-anchor="middle" font-size="11.5" fill="#0D47A1">"remember…", "forget…"</text> | ||
| 26 | + <text x="135.0" y="238.0" text-anchor="middle" font-size="11.5" fill="#0D47A1">or a question</text> | ||
| 27 | + <g filter="url(#shadow)"><rect x="330" y="140" width="250" height="120" rx="16" fill="url(#gBlue2)" stroke="#0277BD" stroke-width="2"/></g> | ||
| 28 | + <text x="455.0" y="180.0" text-anchor="middle" font-size="22">🤖</text> | ||
| 29 | + <text x="455.0" y="203.0" text-anchor="middle" font-size="16" font-weight="700" fill="#01579B">Jay</text> | ||
| 30 | + <text x="455.0" y="221.0" text-anchor="middle" font-size="11.5" fill="#01579B">Qwen3.5-4B</text> | ||
| 31 | + <text x="455.0" y="238.0" text-anchor="middle" font-size="11.5" fill="#01579B">the memory in its system prompt</text> | ||
| 32 | + <rect x="680" y="110" width="480" height="180" rx="10" fill="#FAFAFA" fill-opacity="0.7" stroke="#90A4AE" stroke-width="2" stroke-dasharray="7,5"/> | ||
| 33 | + <text x="920.0" y="132" text-anchor="middle" font-size="13" font-style="italic" font-weight="700" fill="#607D8B">skills · .mm/skills/</text> | ||
| 34 | + <g filter="url(#shadow)"><rect x="705" y="160" width="135" height="50" rx="12" fill="url(#gYellow)" stroke="#F9A825" stroke-width="2"/></g> | ||
| 35 | + <text x="772.5" y="190.0" text-anchor="middle" font-size="13" font-weight="700" fill="#E65100">remember</text> | ||
| 36 | + <g filter="url(#shadow)"><rect x="853" y="160" width="135" height="50" rx="12" fill="url(#gPurple)" stroke="#6A1B9A" stroke-width="2"/></g> | ||
| 37 | + <text x="920.5" y="190.0" text-anchor="middle" font-size="13" font-weight="700" fill="#4A148C">recall</text> | ||
| 38 | + <g filter="url(#shadow)"><rect x="1001" y="160" width="135" height="50" rx="12" fill="url(#gYellow)" stroke="#F9A825" stroke-width="2"/></g> | ||
| 39 | + <text x="1068.5" y="190.0" text-anchor="middle" font-size="13" font-weight="700" fill="#E65100">forget</text> | ||
| 40 | + <text x="772" y="238" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">add / replace a line</text> | ||
| 41 | + <text x="920" y="238" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">no tool: answer</text> | ||
| 42 | + <text x="920" y="254" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">from the prompt</text> | ||
| 43 | + <text x="1068" y="238" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">remove a line</text> | ||
| 44 | + <rect x="680" y="360" width="480" height="170" rx="10" fill="#FAFAFA" fill-opacity="0.7" stroke="#90A4AE" stroke-width="2" stroke-dasharray="7,5"/> | ||
| 45 | + <text x="920.0" y="382" text-anchor="middle" font-size="13" font-style="italic" font-weight="700" fill="#607D8B">.mm/memory.md · one fact per line</text> | ||
| 46 | + <text x="920" y="404" text-anchor="middle" font-size="12" fill="#37474F" font-weight="700" font-family="DejaVu Sans Mono, monospace"># Memory</text> | ||
| 47 | + <text x="920" y="430" text-anchor="middle" font-size="12" fill="#37474F" font-family="DejaVu Sans Mono, monospace">- Sam is the user.</text> | ||
| 48 | + <text x="920" y="452" text-anchor="middle" font-size="12" fill="#37474F" font-family="DejaVu Sans Mono, monospace">- Prefers answers in French.</text> | ||
| 49 | + <text x="920" y="474" text-anchor="middle" font-size="12" fill="#37474F" font-family="DejaVu Sans Mono, monospace">- Release tags are rel-YYYY.MM.</text> | ||
| 50 | + <text x="920" y="506" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">a plain file: read it, correct it, delete it</text> | ||
| 51 | + <rect x="241.0" y="216.0" width="78" height="24" rx="5" fill="#FFFFFF"/> | ||
| 52 | + <text x="280" y="232.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">question</text> | ||
| 53 | + <rect x="589.0" y="216.0" width="82" height="24" rx="5" fill="#FFFFFF"/> | ||
| 54 | + <text x="630" y="232.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">read_skill</text> | ||
| 55 | + <rect x="1075.0" y="313.0" width="70" height="24" rx="5" fill="#FFFFFF"/> | ||
| 56 | + <text x="1110" y="329.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">edit_file</text> | ||
| 57 | + <rect x="467.0" y="425.0" width="200" height="40" rx="5" fill="#FFFFFF"/> | ||
| 58 | + <text x="567" y="442" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">agentsMd.path</text> | ||
| 59 | + <text x="567" y="458" text-anchor="middle" font-size="10.5" fill="#78909C">at the start of every conversation</text> | ||
| 60 | + <rect x="247.0" y="88.0" width="96.0" height="24" rx="5" fill="#FFFFFF"/> | ||
| 61 | + <text x="295" y="104.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">the answer</text> | ||
| 62 | + <g filter="url(#shadow)"><rect x="40" y="560" width="360" height="48" rx="12" fill="url(#gPurple)" stroke="#6A1B9A" stroke-width="2"/></g> | ||
| 63 | + <text x="220.0" y="589.0" text-anchor="middle" font-size="12.5" font-weight="700" fill="#4A148C">French in 7 of 7 answers after it was saved</text> | ||
| 64 | + <g filter="url(#shadow)"><rect x="420" y="560" width="360" height="48" rx="12" fill="url(#gGrey)" stroke="#455A64" stroke-width="2"/></g> | ||
| 65 | + <text x="600.0" y="589.0" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">8/8 right · no fact lost in 6 writes</text> | ||
| 66 | + <g filter="url(#shadow)"><rect x="800" y="560" width="360" height="48" rx="12" fill="url(#gGrey)" stroke="#455A64" stroke-width="2"/></g> | ||
| 67 | + <text x="980.0" y="589.0" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">~10 tokens a fact, on every call — cached</text> | ||
| 68 | + <text x="600" y="640" text-anchor="middle" font-size="12.5" fill="#455A64" font-style="italic">Read at the start of a conversation, never in the middle: the prompt cache holds. Same skills as memory-skills.</text> | ||
| 69 | +</svg> | ||
modified
demos/memory-skills/README.en.md +5 -0 | @@ -1,5 +1,9 @@ | ||
| 1 | 1 | # memory-skills demo — a memory made of three small skills |
| 2 | 2 | |
| 3 | +> **Work in progress — an experiment** (ticket 74). The aim: give an agent a memory from one conversation to the next — your preferences, the project's conventions — with small skills and a plain file, without adding anything to mm. This demo tries it, measures it on one small model, and is meant to change as the idea is tested further. Nothing here is a finished feature of mm. | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 3 | 7 | Jay remembers facts about you and about the project from one conversation to the next. There is no memory feature in mm for this: the memory is one Markdown file, `.mm/memory.md`, and Jay changes it only through three skills (ticket 74, "mini-skills first"). Its name is the jay's: the bird hides thousands of acorns in autumn and finds them again months later. |
| 4 | 8 | |
| 5 | 9 | | Skill | When | What it does | |
| @@ -15,6 +19,7 @@ Version française : [README.fr.md](README.fr.md). | ||
| 15 | 19 | | `.mm/agent.yaml` | Jay: `provider: llamacpp`, `unsloth/Qwen3.5-4B-GGUF:Q4_K_M` (thinking off, temperature 0), `read_file` / `write_file` / `edit_file`, no `bash`, sessions on | |
| 16 | 20 | | `.mm/skills/remember`, `.mm/skills/recall`, `.mm/skills/forget` | the three skills (`SKILL.md`) | |
| 17 | 21 | | `.mm/memory.md` | the memory, created by the first `remember` — not in the repository | |
| 22 | +| `memory-skills-flow.drawio`, `.svg`, `.png` | the diagram above: the draw.io source and its renderings (generated from `.claude/skills/drawio-fancy-diagram/generator/examples/memory_skills.py`) | | |
| 18 | 23 | |
| 19 | 24 | The memory file looks like this: |
| 20 | 25 | |
| @@ -1,5 +1,9 @@ | |||
| 1 | # memory-skills demo — a memory made of three small skills | 1 | # memory-skills demo — a memory made of three small skills |
| 2 | 2 | ||
| 3 | +> **Work in progress — an experiment** (ticket 74). The aim: give an agent a memory from one conversation to the next — your preferences, the project's conventions — with small skills and a plain file, without adding anything to mm. This demo tries it, measures it on one small model, and is meant to change as the idea is tested further. Nothing here is a finished feature of mm. | ||
| 4 | + | ||
| 5 | + | ||
| 6 | + | ||
| 3 | Jay remembers facts about you and about the project from one conversation to the next. There is no memory feature in mm for this: the memory is one Markdown file, `.mm/memory.md`, and Jay changes it only through three skills (ticket 74, "mini-skills first"). Its name is the jay's: the bird hides thousands of acorns in autumn and finds them again months later. | 7 | Jay remembers facts about you and about the project from one conversation to the next. There is no memory feature in mm for this: the memory is one Markdown file, `.mm/memory.md`, and Jay changes it only through three skills (ticket 74, "mini-skills first"). Its name is the jay's: the bird hides thousands of acorns in autumn and finds them again months later. |
| 4 | 8 | ||
| 5 | | Skill | When | What it does | | 9 | | Skill | When | What it does | |
| @@ -15,6 +19,7 @@ Version française : [README.fr.md](README.fr.md). | |||
| 15 | | `.mm/agent.yaml` | Jay: `provider: llamacpp`, `unsloth/Qwen3.5-4B-GGUF:Q4_K_M` (thinking off, temperature 0), `read_file` / `write_file` / `edit_file`, no `bash`, sessions on | | 19 | | `.mm/agent.yaml` | Jay: `provider: llamacpp`, `unsloth/Qwen3.5-4B-GGUF:Q4_K_M` (thinking off, temperature 0), `read_file` / `write_file` / `edit_file`, no `bash`, sessions on | |
| 16 | | `.mm/skills/remember`, `.mm/skills/recall`, `.mm/skills/forget` | the three skills (`SKILL.md`) | | 20 | | `.mm/skills/remember`, `.mm/skills/recall`, `.mm/skills/forget` | the three skills (`SKILL.md`) | |
| 17 | | `.mm/memory.md` | the memory, created by the first `remember` — not in the repository | | 21 | | `.mm/memory.md` | the memory, created by the first `remember` — not in the repository | |
| 22 | +| `memory-skills-flow.drawio`, `.svg`, `.png` | the diagram above: the draw.io source and its renderings (generated from `.claude/skills/drawio-fancy-diagram/generator/examples/memory_skills.py`) | | ||
| 18 | 23 | ||
| 19 | The memory file looks like this: | 24 | The memory file looks like this: |
| 20 | 25 | ||
modified
demos/memory-skills/README.fr.md +5 -0 | @@ -1,5 +1,9 @@ | ||
| 1 | 1 | # Démo memory-skills — une mémoire faite de trois petites skills |
| 2 | 2 | |
| 3 | +> **Travail en cours — une expérimentation** (ticket 74). L'objectif : donner à un agent une mémoire d'une conversation à l'autre — vos préférences, les conventions du projet — avec de petites skills et un simple fichier, sans rien ajouter à mm. Cette démo l'essaie, la mesure sur un petit modèle, et a vocation à évoluer à mesure que l'idée est éprouvée. Rien ici n'est une fonction terminée de mm. | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 3 | 7 | Jay retient des faits sur vous et sur le projet d'une conversation à l'autre. mm n'a pas de fonction mémoire pour cela : la mémoire est un fichier Markdown, `.mm/memory.md`, et Jay ne le modifie qu'au travers de trois skills (ticket 74, « des mini-skills d'abord »). Son nom est celui du geai (*jay*) : l'oiseau cache des milliers de glands à l'automne et les retrouve des mois plus tard. |
| 4 | 8 | |
| 5 | 9 | | Skill | Quand | Ce qu'elle fait | |
| @@ -15,6 +19,7 @@ English version: [README.en.md](README.en.md). | ||
| 15 | 19 | | `.mm/agent.yaml` | Jay : `provider: llamacpp`, `unsloth/Qwen3.5-4B-GGUF:Q4_K_M` (raisonnement coupé, température 0), `read_file` / `write_file` / `edit_file`, pas de `bash`, sessions activées | |
| 16 | 20 | | `.mm/skills/remember`, `.mm/skills/recall`, `.mm/skills/forget` | les trois skills (`SKILL.md`) | |
| 17 | 21 | | `.mm/memory.md` | la mémoire, créée par le premier `remember` — pas dans le dépôt | |
| 22 | +| `memory-skills-flow.drawio`, `.svg`, `.png` | le diagramme ci-dessus : la source draw.io et ses rendus (générés depuis `.claude/skills/drawio-fancy-diagram/generator/examples/memory_skills.py`) | | |
| 18 | 23 | |
| 19 | 24 | Le fichier mémoire ressemble à ceci : |
| 20 | 25 | |
| @@ -1,5 +1,9 @@ | |||
| 1 | # Démo memory-skills — une mémoire faite de trois petites skills | 1 | # Démo memory-skills — une mémoire faite de trois petites skills |
| 2 | 2 | ||
| 3 | +> **Travail en cours — une expérimentation** (ticket 74). L'objectif : donner à un agent une mémoire d'une conversation à l'autre — vos préférences, les conventions du projet — avec de petites skills et un simple fichier, sans rien ajouter à mm. Cette démo l'essaie, la mesure sur un petit modèle, et a vocation à évoluer à mesure que l'idée est éprouvée. Rien ici n'est une fonction terminée de mm. | ||
| 4 | + | ||
| 5 | + | ||
| 6 | + | ||
| 3 | Jay retient des faits sur vous et sur le projet d'une conversation à l'autre. mm n'a pas de fonction mémoire pour cela : la mémoire est un fichier Markdown, `.mm/memory.md`, et Jay ne le modifie qu'au travers de trois skills (ticket 74, « des mini-skills d'abord »). Son nom est celui du geai (*jay*) : l'oiseau cache des milliers de glands à l'automne et les retrouve des mois plus tard. | 7 | Jay retient des faits sur vous et sur le projet d'une conversation à l'autre. mm n'a pas de fonction mémoire pour cela : la mémoire est un fichier Markdown, `.mm/memory.md`, et Jay ne le modifie qu'au travers de trois skills (ticket 74, « des mini-skills d'abord »). Son nom est celui du geai (*jay*) : l'oiseau cache des milliers de glands à l'automne et les retrouve des mois plus tard. |
| 4 | 8 | ||
| 5 | | Skill | Quand | Ce qu'elle fait | | 9 | | Skill | Quand | Ce qu'elle fait | |
| @@ -15,6 +19,7 @@ English version: [README.en.md](README.en.md). | |||
| 15 | | `.mm/agent.yaml` | Jay : `provider: llamacpp`, `unsloth/Qwen3.5-4B-GGUF:Q4_K_M` (raisonnement coupé, température 0), `read_file` / `write_file` / `edit_file`, pas de `bash`, sessions activées | | 19 | | `.mm/agent.yaml` | Jay : `provider: llamacpp`, `unsloth/Qwen3.5-4B-GGUF:Q4_K_M` (raisonnement coupé, température 0), `read_file` / `write_file` / `edit_file`, pas de `bash`, sessions activées | |
| 16 | | `.mm/skills/remember`, `.mm/skills/recall`, `.mm/skills/forget` | les trois skills (`SKILL.md`) | | 20 | | `.mm/skills/remember`, `.mm/skills/recall`, `.mm/skills/forget` | les trois skills (`SKILL.md`) | |
| 17 | | `.mm/memory.md` | la mémoire, créée par le premier `remember` — pas dans le dépôt | | 21 | | `.mm/memory.md` | la mémoire, créée par le premier `remember` — pas dans le dépôt | |
| 22 | +| `memory-skills-flow.drawio`, `.svg`, `.png` | le diagramme ci-dessus : la source draw.io et ses rendus (générés depuis `.claude/skills/drawio-fancy-diagram/generator/examples/memory_skills.py`) | | ||
| 18 | 23 | ||
| 19 | Le fichier mémoire ressemble à ceci : | 24 | Le fichier mémoire ressemble à ceci : |
| 20 | 25 | ||
added
demos/memory-skills/memory-skills-flow.drawio +41 -0 | new file mode 100644 | ||
| @@ -0,0 +1,41 @@ | ||
| 1 | +<mxfile host="app.diagrams.net"> | |
| 2 | + <diagram id="memory-skills-flow" name="demos/memory-skills — a memory made of three small skills"> | |
| 3 | + <mxGraphModel dx="1200" dy="680" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1200" pageHeight="680" background="#F5F7FC" math="0" shadow="0"> | |
| 4 | + <root> | |
| 5 | + <mxCell id="0"/> | |
| 6 | + <mxCell id="1" parent="0"/> | |
| 7 | + <mxCell id="title" value="<b style="font-size:25px;color:#1A237E">demos/memory-skills — a memory made of three small skills</b><br><i style="font-size:14px;color:#546E7A">WIP experiment: the agent keeps .mm/memory.md itself, through skills — no mm code</i>" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;" vertex="1" parent="1"><mxGeometry x="150.0" y="12" width="900" height="56" as="geometry"/></mxCell> | |
| 8 | + <mxCell id="c16" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="230" y="200" as="sourcePoint"/><mxPoint x="330" y="200" as="targetPoint"/></mxGeometry></mxCell> | |
| 9 | + <mxCell id="c18" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="580" y="200" as="sourcePoint"/><mxPoint x="680" y="200" as="targetPoint"/></mxGeometry></mxCell> | |
| 10 | + <mxCell id="c20" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=block;startFill=1;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="920" y="290" as="sourcePoint"/><mxPoint x="920" y="360" as="targetPoint"/></mxGeometry></mxCell> | |
| 11 | + <mxCell id="c22" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="455" y="140" as="sourcePoint"/><mxPoint x="135" y="140" as="targetPoint"/><Array as="points"><mxPoint x="455" y="100"/><mxPoint x="135" y="100"/></Array></mxGeometry></mxCell> | |
| 12 | + <mxCell id="c1" value="🧑<br><b style="font-size:16px">User</b><br><span style="font-size:11.5px;font-weight:normal">"remember…", "forget…"<br>or a question</span>" style="rounded=1;arcSize=14;whiteSpace=wrap;html=1;fillColor=#E3F2FD;gradientColor=#BBDEFB;strokeColor=#1565C0;strokeWidth=2;shadow=1;fontSize=20;fontColor=#0D47A1;" vertex="1" parent="1"><mxGeometry x="40" y="140" width="190" height="120" as="geometry"/></mxCell> | |
| 13 | + <mxCell id="c2" value="🤖<br><b style="font-size:16px">Jay</b><br><span style="font-size:11.5px;font-weight:normal">Qwen3.5-4B<br>read_file · write_file · edit_file</span>" style="rounded=1;arcSize=14;whiteSpace=wrap;html=1;fillColor=#E1F5FE;gradientColor=#B3E5FC;strokeColor=#0277BD;strokeWidth=2;shadow=1;fontSize=20;fontColor=#01579B;" vertex="1" parent="1"><mxGeometry x="330" y="140" width="250" height="120" as="geometry"/></mxCell> | |
| 14 | + <mxCell id="c3" value="<i><b>skills · .mm/skills/</b></i>" style="rounded=1;arcSize=3;html=1;dashed=1;dashPattern=7 5;fillColor=#FAFAFA;strokeColor=#90A4AE;strokeWidth=2;verticalAlign=top;fontColor=#607D8B;fontSize=13;" vertex="1" parent="1"><mxGeometry x="680" y="110" width="480" height="180" as="geometry"/></mxCell> | |
| 15 | + <mxCell id="c4" value="<b>remember</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#FFFDE7;gradientColor=#FFF9C4;strokeColor=#F9A825;strokeWidth=2;shadow=1;fontSize=13;fontColor=#E65100;" vertex="1" parent="1"><mxGeometry x="705" y="160" width="135" height="50" as="geometry"/></mxCell> | |
| 16 | + <mxCell id="c5" value="<b>recall</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#F3E5F5;gradientColor=#E1BEE7;strokeColor=#6A1B9A;strokeWidth=2;shadow=1;fontSize=13;fontColor=#4A148C;" vertex="1" parent="1"><mxGeometry x="853" y="160" width="135" height="50" as="geometry"/></mxCell> | |
| 17 | + <mxCell id="c6" value="<b>forget</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#FFFDE7;gradientColor=#FFF9C4;strokeColor=#F9A825;strokeWidth=2;shadow=1;fontSize=13;fontColor=#E65100;" vertex="1" parent="1"><mxGeometry x="1001" y="160" width="135" height="50" as="geometry"/></mxCell> | |
| 18 | + <mxCell id="c7" value="add / replace a line" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="706.9" y="227.5" width="130.2" height="16.5" as="geometry"/></mxCell> | |
| 19 | + <mxCell id="c8" value="read the file" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="877.685" y="227.5" width="84.63" height="16.5" as="geometry"/></mxCell> | |
| 20 | + <mxCell id="c9" value="remove a line" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="1025.685" y="227.5" width="84.63" height="16.5" as="geometry"/></mxCell> | |
| 21 | + <mxCell id="c10" value="<i><b>.mm/memory.md · one fact per line</b></i>" style="rounded=1;arcSize=3;html=1;dashed=1;dashPattern=7 5;fillColor=#FAFAFA;strokeColor=#90A4AE;strokeWidth=2;verticalAlign=top;fontColor=#607D8B;fontSize=13;" vertex="1" parent="1"><mxGeometry x="680" y="360" width="480" height="170" as="geometry"/></mxCell> | |
| 22 | + <mxCell id="c11" value="# Memory" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12;fontColor=#37474F;fontStyle=1;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="890.24" y="392" width="59.519999999999996" height="18" as="geometry"/></mxCell> | |
| 23 | + <mxCell id="c12" value="- Sam is the user." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="853.04" y="418" width="133.92" height="18" as="geometry"/></mxCell> | |
| 24 | + <mxCell id="c13" value="- Prefers answers in French." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="815.84" y="440" width="208.32" height="18" as="geometry"/></mxCell> | |
| 25 | + <mxCell id="c14" value="- Release tags are rel-YYYY.MM." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="804.6800000000001" y="462" width="230.64" height="18" as="geometry"/></mxCell> | |
| 26 | + <mxCell id="c15" value="a plain file: read it, correct it, delete it" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="776.78" y="495.5" width="286.44" height="16.5" as="geometry"/></mxCell> | |
| 27 | + <mxCell id="c17" value="<b style="font-size:12.5px;color:#263238">question</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="241.0" y="216.0" width="78" height="24" as="geometry"/></mxCell> | |
| 28 | + <mxCell id="c19" value="<b style="font-size:12.5px;color:#263238">read_skill</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="589.0" y="216.0" width="82" height="24" as="geometry"/></mxCell> | |
| 29 | + <mxCell id="c21" value="<b style="font-size:12.5px;color:#263238">read_file · edit_file</b><br><span style="font-size:10.5px;color:#78909C">only through a skill</span>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="950.2" y="305.0" width="179.6" height="40" as="geometry"/></mxCell> | |
| 30 | + <mxCell id="c23" value="<b style="font-size:12.5px;color:#263238">the answer</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="247.0" y="88.0" width="96.0" height="24" as="geometry"/></mxCell> | |
| 31 | + <mxCell id="c24" value="<i><b>what this way shows</b></i>" style="rounded=1;arcSize=3;html=1;dashed=1;dashPattern=7 5;fillColor=#FAFAFA;strokeColor=#90A4AE;strokeWidth=2;verticalAlign=top;fontColor=#607D8B;fontSize=13;" vertex="1" parent="1"><mxGeometry x="40" y="360" width="560" height="170" as="geometry"/></mxCell> | |
| 32 | + <mxCell id="c25" value="The memory reaches the model only when recall is called." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#37474F;fontStyle=0;" vertex="1" parent="1"><mxGeometry x="103.0" y="391.5" width="434.0" height="18.5" as="geometry"/></mxCell> | |
| 33 | + <mxCell id="c26" value="Asked about you or the project, Jay calls recall: 8/8 right." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#37474F;fontStyle=0;" vertex="1" parent="1"><mxGeometry x="87.5" y="417.5" width="465.0" height="18.5" as="geometry"/></mxCell> | |
| 34 | + <mxCell id="c27" value="Any other question: the memory is not read —" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#37474F;fontStyle=0;" vertex="1" parent="1"><mxGeometry x="149.5" y="443.5" width="341.0" height="18.5" as="geometry"/></mxCell> | |
| 35 | + <mxCell id="c28" value="French in 4 of the 7 answers after it was saved." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#E65100;fontStyle=1;" vertex="1" parent="1"><mxGeometry x="134.0" y="467.5" width="372.0" height="18.5" as="geometry"/></mxCell> | |
| 36 | + <mxCell id="c29" value="Qwen3.5 4B on llama.cpp, temperature 0 · each question a new conversation (-p)" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#455A64;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="297.75" y="587.5" width="604.5" height="18.5" as="geometry"/></mxCell> | |
| 37 | + <mxCell id="c30" value="the next step, memory-skills-2: the memory always in the prompt" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#455A64;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="355.875" y="609.5" width="488.25" height="18.5" as="geometry"/></mxCell> | |
| 38 | + </root> | |
| 39 | + </mxGraphModel> | |
| 40 | + </diagram> | |
| 41 | +</mxfile> | |
| new file mode 100644 | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | +<mxfile host="app.diagrams.net"> | ||
| 2 | + <diagram id="memory-skills-flow" name="demos/memory-skills — a memory made of three small skills"> | ||
| 3 | + <mxGraphModel dx="1200" dy="680" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1200" pageHeight="680" background="#F5F7FC" math="0" shadow="0"> | ||
| 4 | + <root> | ||
| 5 | + <mxCell id="0"/> | ||
| 6 | + <mxCell id="1" parent="0"/> | ||
| 7 | + <mxCell id="title" value="<b style="font-size:25px;color:#1A237E">demos/memory-skills — a memory made of three small skills</b><br><i style="font-size:14px;color:#546E7A">WIP experiment: the agent keeps .mm/memory.md itself, through skills — no mm code</i>" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;" vertex="1" parent="1"><mxGeometry x="150.0" y="12" width="900" height="56" as="geometry"/></mxCell> | ||
| 8 | + <mxCell id="c16" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="230" y="200" as="sourcePoint"/><mxPoint x="330" y="200" as="targetPoint"/></mxGeometry></mxCell> | ||
| 9 | + <mxCell id="c18" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="580" y="200" as="sourcePoint"/><mxPoint x="680" y="200" as="targetPoint"/></mxGeometry></mxCell> | ||
| 10 | + <mxCell id="c20" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=block;startFill=1;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="920" y="290" as="sourcePoint"/><mxPoint x="920" y="360" as="targetPoint"/></mxGeometry></mxCell> | ||
| 11 | + <mxCell id="c22" value="" style="edgeStyle=none;rounded=0;html=1;strokeColor=#37474F;strokeWidth=2;endArrow=block;endFill=1;startArrow=none;" edge="1" parent="1"><mxGeometry relative="1" as="geometry"><mxPoint x="455" y="140" as="sourcePoint"/><mxPoint x="135" y="140" as="targetPoint"/><Array as="points"><mxPoint x="455" y="100"/><mxPoint x="135" y="100"/></Array></mxGeometry></mxCell> | ||
| 12 | + <mxCell id="c1" value="🧑<br><b style="font-size:16px">User</b><br><span style="font-size:11.5px;font-weight:normal">"remember…", "forget…"<br>or a question</span>" style="rounded=1;arcSize=14;whiteSpace=wrap;html=1;fillColor=#E3F2FD;gradientColor=#BBDEFB;strokeColor=#1565C0;strokeWidth=2;shadow=1;fontSize=20;fontColor=#0D47A1;" vertex="1" parent="1"><mxGeometry x="40" y="140" width="190" height="120" as="geometry"/></mxCell> | ||
| 13 | + <mxCell id="c2" value="🤖<br><b style="font-size:16px">Jay</b><br><span style="font-size:11.5px;font-weight:normal">Qwen3.5-4B<br>read_file · write_file · edit_file</span>" style="rounded=1;arcSize=14;whiteSpace=wrap;html=1;fillColor=#E1F5FE;gradientColor=#B3E5FC;strokeColor=#0277BD;strokeWidth=2;shadow=1;fontSize=20;fontColor=#01579B;" vertex="1" parent="1"><mxGeometry x="330" y="140" width="250" height="120" as="geometry"/></mxCell> | ||
| 14 | + <mxCell id="c3" value="<i><b>skills · .mm/skills/</b></i>" style="rounded=1;arcSize=3;html=1;dashed=1;dashPattern=7 5;fillColor=#FAFAFA;strokeColor=#90A4AE;strokeWidth=2;verticalAlign=top;fontColor=#607D8B;fontSize=13;" vertex="1" parent="1"><mxGeometry x="680" y="110" width="480" height="180" as="geometry"/></mxCell> | ||
| 15 | + <mxCell id="c4" value="<b>remember</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#FFFDE7;gradientColor=#FFF9C4;strokeColor=#F9A825;strokeWidth=2;shadow=1;fontSize=13;fontColor=#E65100;" vertex="1" parent="1"><mxGeometry x="705" y="160" width="135" height="50" as="geometry"/></mxCell> | ||
| 16 | + <mxCell id="c5" value="<b>recall</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#F3E5F5;gradientColor=#E1BEE7;strokeColor=#6A1B9A;strokeWidth=2;shadow=1;fontSize=13;fontColor=#4A148C;" vertex="1" parent="1"><mxGeometry x="853" y="160" width="135" height="50" as="geometry"/></mxCell> | ||
| 17 | + <mxCell id="c6" value="<b>forget</b>" style="rounded=1;arcSize=20;whiteSpace=wrap;html=1;fillColor=#FFFDE7;gradientColor=#FFF9C4;strokeColor=#F9A825;strokeWidth=2;shadow=1;fontSize=13;fontColor=#E65100;" vertex="1" parent="1"><mxGeometry x="1001" y="160" width="135" height="50" as="geometry"/></mxCell> | ||
| 18 | + <mxCell id="c7" value="add / replace a line" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="706.9" y="227.5" width="130.2" height="16.5" as="geometry"/></mxCell> | ||
| 19 | + <mxCell id="c8" value="read the file" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="877.685" y="227.5" width="84.63" height="16.5" as="geometry"/></mxCell> | ||
| 20 | + <mxCell id="c9" value="remove a line" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="1025.685" y="227.5" width="84.63" height="16.5" as="geometry"/></mxCell> | ||
| 21 | + <mxCell id="c10" value="<i><b>.mm/memory.md · one fact per line</b></i>" style="rounded=1;arcSize=3;html=1;dashed=1;dashPattern=7 5;fillColor=#FAFAFA;strokeColor=#90A4AE;strokeWidth=2;verticalAlign=top;fontColor=#607D8B;fontSize=13;" vertex="1" parent="1"><mxGeometry x="680" y="360" width="480" height="170" as="geometry"/></mxCell> | ||
| 22 | + <mxCell id="c11" value="# Memory" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12;fontColor=#37474F;fontStyle=1;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="890.24" y="392" width="59.519999999999996" height="18" as="geometry"/></mxCell> | ||
| 23 | + <mxCell id="c12" value="- Sam is the user." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="853.04" y="418" width="133.92" height="18" as="geometry"/></mxCell> | ||
| 24 | + <mxCell id="c13" value="- Prefers answers in French." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="815.84" y="440" width="208.32" height="18" as="geometry"/></mxCell> | ||
| 25 | + <mxCell id="c14" value="- Release tags are rel-YYYY.MM." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12;fontColor=#37474F;fontStyle=0;fontFamily=DejaVu Sans Mono;" vertex="1" parent="1"><mxGeometry x="804.6800000000001" y="462" width="230.64" height="18" as="geometry"/></mxCell> | ||
| 26 | + <mxCell id="c15" value="a plain file: read it, correct it, delete it" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=10.5;fontColor=#78909C;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="776.78" y="495.5" width="286.44" height="16.5" as="geometry"/></mxCell> | ||
| 27 | + <mxCell id="c17" value="<b style="font-size:12.5px;color:#263238">question</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="241.0" y="216.0" width="78" height="24" as="geometry"/></mxCell> | ||
| 28 | + <mxCell id="c19" value="<b style="font-size:12.5px;color:#263238">read_skill</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="589.0" y="216.0" width="82" height="24" as="geometry"/></mxCell> | ||
| 29 | + <mxCell id="c21" value="<b style="font-size:12.5px;color:#263238">read_file · edit_file</b><br><span style="font-size:10.5px;color:#78909C">only through a skill</span>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="950.2" y="305.0" width="179.6" height="40" as="geometry"/></mxCell> | ||
| 30 | + <mxCell id="c23" value="<b style="font-size:12.5px;color:#263238">the answer</b>" style="text;html=1;align=center;verticalAlign=middle;fillColor=#FFFFFF;strokeColor=none;rounded=1;" vertex="1" parent="1"><mxGeometry x="247.0" y="88.0" width="96.0" height="24" as="geometry"/></mxCell> | ||
| 31 | + <mxCell id="c24" value="<i><b>what this way shows</b></i>" style="rounded=1;arcSize=3;html=1;dashed=1;dashPattern=7 5;fillColor=#FAFAFA;strokeColor=#90A4AE;strokeWidth=2;verticalAlign=top;fontColor=#607D8B;fontSize=13;" vertex="1" parent="1"><mxGeometry x="40" y="360" width="560" height="170" as="geometry"/></mxCell> | ||
| 32 | + <mxCell id="c25" value="The memory reaches the model only when recall is called." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#37474F;fontStyle=0;" vertex="1" parent="1"><mxGeometry x="103.0" y="391.5" width="434.0" height="18.5" as="geometry"/></mxCell> | ||
| 33 | + <mxCell id="c26" value="Asked about you or the project, Jay calls recall: 8/8 right." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#37474F;fontStyle=0;" vertex="1" parent="1"><mxGeometry x="87.5" y="417.5" width="465.0" height="18.5" as="geometry"/></mxCell> | ||
| 34 | + <mxCell id="c27" value="Any other question: the memory is not read —" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#37474F;fontStyle=0;" vertex="1" parent="1"><mxGeometry x="149.5" y="443.5" width="341.0" height="18.5" as="geometry"/></mxCell> | ||
| 35 | + <mxCell id="c28" value="French in 4 of the 7 answers after it was saved." style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#E65100;fontStyle=1;" vertex="1" parent="1"><mxGeometry x="134.0" y="467.5" width="372.0" height="18.5" as="geometry"/></mxCell> | ||
| 36 | + <mxCell id="c29" value="Qwen3.5 4B on llama.cpp, temperature 0 · each question a new conversation (-p)" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#455A64;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="297.75" y="587.5" width="604.5" height="18.5" as="geometry"/></mxCell> | ||
| 37 | + <mxCell id="c30" value="the next step, memory-skills-2: the memory always in the prompt" style="text;html=1;align=center;verticalAlign=middle;strokeColor=none;fillColor=none;fontSize=12.5;fontColor=#455A64;fontStyle=2;" vertex="1" parent="1"><mxGeometry x="355.875" y="609.5" width="488.25" height="18.5" as="geometry"/></mxCell> | ||
| 38 | + </root> | ||
| 39 | + </mxGraphModel> | ||
| 40 | + </diagram> | ||
| 41 | +</mxfile> | ||
added
demos/memory-skills/memory-skills-flow.png +0 -0 | new file mode 100644 | ||
| Binary files /dev/null and b/demos/memory-skills/memory-skills-flow.png differ | ||
| new file mode 100644 | |||
| Binary files /dev/null and b/demos/memory-skills/memory-skills-flow.png differ | Binary files /dev/null and b/demos/memory-skills/memory-skills-flow.png differ | ||
added
demos/memory-skills/memory-skills-flow.svg +66 -0 | new file mode 100644 | ||
| @@ -0,0 +1,66 @@ | ||
| 1 | +<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="680" viewBox="0 0 1200 680" font-family="DejaVu Sans, Verdana, sans-serif"> | |
| 2 | + <defs> | |
| 3 | + <linearGradient id="gBg" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#FFFFFF"/><stop offset="100%" stop-color="#EEF2FA"/></linearGradient> | |
| 4 | + <linearGradient id="gBlue" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#E3F2FD"/><stop offset="100%" stop-color="#BBDEFB"/></linearGradient> | |
| 5 | + <linearGradient id="gBlue2" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#E1F5FE"/><stop offset="100%" stop-color="#B3E5FC"/></linearGradient> | |
| 6 | + <linearGradient id="gPurple" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#F3E5F5"/><stop offset="100%" stop-color="#E1BEE7"/></linearGradient> | |
| 7 | + <linearGradient id="gYellow" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#FFFDE7"/><stop offset="100%" stop-color="#FFF9C4"/></linearGradient> | |
| 8 | + <linearGradient id="gGrey" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#ECEFF1"/><stop offset="100%" stop-color="#CFD8DC"/></linearGradient> | |
| 9 | + <filter id="shadow" x="-30%" y="-30%" width="160%" height="160%"><feDropShadow dx="2" dy="3" stdDeviation="4" flood-color="#000000" flood-opacity="0.25"/></filter> | |
| 10 | + <marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#37474F"/></marker> | |
| 11 | + <marker id="arrowGrey" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#78909C"/></marker> | |
| 12 | + <marker id="arrowOrange" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#EF6C00"/></marker> | |
| 13 | + </defs> | |
| 14 | + <rect x="0" y="0" width="1200" height="680" fill="url(#gBg)"/> | |
| 15 | + <text x="600.0" y="38" text-anchor="middle" font-size="25" font-weight="700" fill="#1A237E">demos/memory-skills — a memory made of three small skills</text> | |
| 16 | + <text x="600.0" y="61" text-anchor="middle" font-size="14" font-style="italic" fill="#546E7A">WIP experiment: the agent keeps .mm/memory.md itself, through skills — no mm code</text> | |
| 17 | + <path d="M230,200 L330,200" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | |
| 18 | + <path d="M580,200 L680,200" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | |
| 19 | + <path d="M920,290 L920,360" fill="none" stroke="#37474F" stroke-width="2.2" marker-start="url(#arrow)" marker-end="url(#arrow)"/> | |
| 20 | + <path d="M455,140 L455,100 L135,100 L135,140" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | |
| 21 | + <g filter="url(#shadow)"><rect x="40" y="140" width="190" height="120" rx="16" fill="url(#gBlue)" stroke="#1565C0" stroke-width="2"/></g> | |
| 22 | + <text x="135.0" y="180.0" text-anchor="middle" font-size="22">🧑</text> | |
| 23 | + <text x="135.0" y="203.0" text-anchor="middle" font-size="16" font-weight="700" fill="#0D47A1">User</text> | |
| 24 | + <text x="135.0" y="221.0" text-anchor="middle" font-size="11.5" fill="#0D47A1">"remember…", "forget…"</text> | |
| 25 | + <text x="135.0" y="238.0" text-anchor="middle" font-size="11.5" fill="#0D47A1">or a question</text> | |
| 26 | + <g filter="url(#shadow)"><rect x="330" y="140" width="250" height="120" rx="16" fill="url(#gBlue2)" stroke="#0277BD" stroke-width="2"/></g> | |
| 27 | + <text x="455.0" y="180.0" text-anchor="middle" font-size="22">🤖</text> | |
| 28 | + <text x="455.0" y="203.0" text-anchor="middle" font-size="16" font-weight="700" fill="#01579B">Jay</text> | |
| 29 | + <text x="455.0" y="221.0" text-anchor="middle" font-size="11.5" fill="#01579B">Qwen3.5-4B</text> | |
| 30 | + <text x="455.0" y="238.0" text-anchor="middle" font-size="11.5" fill="#01579B">read_file · write_file · edit_file</text> | |
| 31 | + <rect x="680" y="110" width="480" height="180" rx="10" fill="#FAFAFA" fill-opacity="0.7" stroke="#90A4AE" stroke-width="2" stroke-dasharray="7,5"/> | |
| 32 | + <text x="920.0" y="132" text-anchor="middle" font-size="13" font-style="italic" font-weight="700" fill="#607D8B">skills · .mm/skills/</text> | |
| 33 | + <g filter="url(#shadow)"><rect x="705" y="160" width="135" height="50" rx="12" fill="url(#gYellow)" stroke="#F9A825" stroke-width="2"/></g> | |
| 34 | + <text x="772.5" y="190.0" text-anchor="middle" font-size="13" font-weight="700" fill="#E65100">remember</text> | |
| 35 | + <g filter="url(#shadow)"><rect x="853" y="160" width="135" height="50" rx="12" fill="url(#gPurple)" stroke="#6A1B9A" stroke-width="2"/></g> | |
| 36 | + <text x="920.5" y="190.0" text-anchor="middle" font-size="13" font-weight="700" fill="#4A148C">recall</text> | |
| 37 | + <g filter="url(#shadow)"><rect x="1001" y="160" width="135" height="50" rx="12" fill="url(#gYellow)" stroke="#F9A825" stroke-width="2"/></g> | |
| 38 | + <text x="1068.5" y="190.0" text-anchor="middle" font-size="13" font-weight="700" fill="#E65100">forget</text> | |
| 39 | + <text x="772" y="238" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">add / replace a line</text> | |
| 40 | + <text x="920" y="238" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">read the file</text> | |
| 41 | + <text x="1068" y="238" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">remove a line</text> | |
| 42 | + <rect x="680" y="360" width="480" height="170" rx="10" fill="#FAFAFA" fill-opacity="0.7" stroke="#90A4AE" stroke-width="2" stroke-dasharray="7,5"/> | |
| 43 | + <text x="920.0" y="382" text-anchor="middle" font-size="13" font-style="italic" font-weight="700" fill="#607D8B">.mm/memory.md · one fact per line</text> | |
| 44 | + <text x="920" y="404" text-anchor="middle" font-size="12" fill="#37474F" font-weight="700" font-family="DejaVu Sans Mono, monospace"># Memory</text> | |
| 45 | + <text x="920" y="430" text-anchor="middle" font-size="12" fill="#37474F" font-family="DejaVu Sans Mono, monospace">- Sam is the user.</text> | |
| 46 | + <text x="920" y="452" text-anchor="middle" font-size="12" fill="#37474F" font-family="DejaVu Sans Mono, monospace">- Prefers answers in French.</text> | |
| 47 | + <text x="920" y="474" text-anchor="middle" font-size="12" fill="#37474F" font-family="DejaVu Sans Mono, monospace">- Release tags are rel-YYYY.MM.</text> | |
| 48 | + <text x="920" y="506" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">a plain file: read it, correct it, delete it</text> | |
| 49 | + <rect x="241.0" y="216.0" width="78" height="24" rx="5" fill="#FFFFFF"/> | |
| 50 | + <text x="280" y="232.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">question</text> | |
| 51 | + <rect x="589.0" y="216.0" width="82" height="24" rx="5" fill="#FFFFFF"/> | |
| 52 | + <text x="630" y="232.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">read_skill</text> | |
| 53 | + <rect x="950.2" y="305.0" width="179.6" height="40" rx="5" fill="#FFFFFF"/> | |
| 54 | + <text x="1040" y="322" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">read_file · edit_file</text> | |
| 55 | + <text x="1040" y="338" text-anchor="middle" font-size="10.5" fill="#78909C">only through a skill</text> | |
| 56 | + <rect x="247.0" y="88.0" width="96.0" height="24" rx="5" fill="#FFFFFF"/> | |
| 57 | + <text x="295" y="104.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">the answer</text> | |
| 58 | + <rect x="40" y="360" width="560" height="170" rx="10" fill="#FAFAFA" fill-opacity="0.7" stroke="#90A4AE" stroke-width="2" stroke-dasharray="7,5"/> | |
| 59 | + <text x="320.0" y="382" text-anchor="middle" font-size="13" font-style="italic" font-weight="700" fill="#607D8B">what this way shows</text> | |
| 60 | + <text x="320" y="404" text-anchor="middle" font-size="12.5" fill="#37474F">The memory reaches the model only when recall is called.</text> | |
| 61 | + <text x="320" y="430" text-anchor="middle" font-size="12.5" fill="#37474F">Asked about you or the project, Jay calls recall: 8/8 right.</text> | |
| 62 | + <text x="320" y="456" text-anchor="middle" font-size="12.5" fill="#37474F">Any other question: the memory is not read —</text> | |
| 63 | + <text x="320" y="480" text-anchor="middle" font-size="12.5" fill="#E65100" font-weight="700">French in 4 of the 7 answers after it was saved.</text> | |
| 64 | + <text x="600" y="600" text-anchor="middle" font-size="12.5" fill="#455A64" font-style="italic">Qwen3.5 4B on llama.cpp, temperature 0 · each question a new conversation (-p)</text> | |
| 65 | + <text x="600" y="622" text-anchor="middle" font-size="12.5" fill="#455A64" font-style="italic">the next step, memory-skills-2: the memory always in the prompt</text> | |
| 66 | +</svg> | |
| new file mode 100644 | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | +<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="680" viewBox="0 0 1200 680" font-family="DejaVu Sans, Verdana, sans-serif"> | ||
| 2 | + <defs> | ||
| 3 | + <linearGradient id="gBg" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#FFFFFF"/><stop offset="100%" stop-color="#EEF2FA"/></linearGradient> | ||
| 4 | + <linearGradient id="gBlue" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#E3F2FD"/><stop offset="100%" stop-color="#BBDEFB"/></linearGradient> | ||
| 5 | + <linearGradient id="gBlue2" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#E1F5FE"/><stop offset="100%" stop-color="#B3E5FC"/></linearGradient> | ||
| 6 | + <linearGradient id="gPurple" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#F3E5F5"/><stop offset="100%" stop-color="#E1BEE7"/></linearGradient> | ||
| 7 | + <linearGradient id="gYellow" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#FFFDE7"/><stop offset="100%" stop-color="#FFF9C4"/></linearGradient> | ||
| 8 | + <linearGradient id="gGrey" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#ECEFF1"/><stop offset="100%" stop-color="#CFD8DC"/></linearGradient> | ||
| 9 | + <filter id="shadow" x="-30%" y="-30%" width="160%" height="160%"><feDropShadow dx="2" dy="3" stdDeviation="4" flood-color="#000000" flood-opacity="0.25"/></filter> | ||
| 10 | + <marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#37474F"/></marker> | ||
| 11 | + <marker id="arrowGrey" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#78909C"/></marker> | ||
| 12 | + <marker id="arrowOrange" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#EF6C00"/></marker> | ||
| 13 | + </defs> | ||
| 14 | + <rect x="0" y="0" width="1200" height="680" fill="url(#gBg)"/> | ||
| 15 | + <text x="600.0" y="38" text-anchor="middle" font-size="25" font-weight="700" fill="#1A237E">demos/memory-skills — a memory made of three small skills</text> | ||
| 16 | + <text x="600.0" y="61" text-anchor="middle" font-size="14" font-style="italic" fill="#546E7A">WIP experiment: the agent keeps .mm/memory.md itself, through skills — no mm code</text> | ||
| 17 | + <path d="M230,200 L330,200" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | ||
| 18 | + <path d="M580,200 L680,200" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | ||
| 19 | + <path d="M920,290 L920,360" fill="none" stroke="#37474F" stroke-width="2.2" marker-start="url(#arrow)" marker-end="url(#arrow)"/> | ||
| 20 | + <path d="M455,140 L455,100 L135,100 L135,140" fill="none" stroke="#37474F" stroke-width="2.2" marker-end="url(#arrow)"/> | ||
| 21 | + <g filter="url(#shadow)"><rect x="40" y="140" width="190" height="120" rx="16" fill="url(#gBlue)" stroke="#1565C0" stroke-width="2"/></g> | ||
| 22 | + <text x="135.0" y="180.0" text-anchor="middle" font-size="22">🧑</text> | ||
| 23 | + <text x="135.0" y="203.0" text-anchor="middle" font-size="16" font-weight="700" fill="#0D47A1">User</text> | ||
| 24 | + <text x="135.0" y="221.0" text-anchor="middle" font-size="11.5" fill="#0D47A1">"remember…", "forget…"</text> | ||
| 25 | + <text x="135.0" y="238.0" text-anchor="middle" font-size="11.5" fill="#0D47A1">or a question</text> | ||
| 26 | + <g filter="url(#shadow)"><rect x="330" y="140" width="250" height="120" rx="16" fill="url(#gBlue2)" stroke="#0277BD" stroke-width="2"/></g> | ||
| 27 | + <text x="455.0" y="180.0" text-anchor="middle" font-size="22">🤖</text> | ||
| 28 | + <text x="455.0" y="203.0" text-anchor="middle" font-size="16" font-weight="700" fill="#01579B">Jay</text> | ||
| 29 | + <text x="455.0" y="221.0" text-anchor="middle" font-size="11.5" fill="#01579B">Qwen3.5-4B</text> | ||
| 30 | + <text x="455.0" y="238.0" text-anchor="middle" font-size="11.5" fill="#01579B">read_file · write_file · edit_file</text> | ||
| 31 | + <rect x="680" y="110" width="480" height="180" rx="10" fill="#FAFAFA" fill-opacity="0.7" stroke="#90A4AE" stroke-width="2" stroke-dasharray="7,5"/> | ||
| 32 | + <text x="920.0" y="132" text-anchor="middle" font-size="13" font-style="italic" font-weight="700" fill="#607D8B">skills · .mm/skills/</text> | ||
| 33 | + <g filter="url(#shadow)"><rect x="705" y="160" width="135" height="50" rx="12" fill="url(#gYellow)" stroke="#F9A825" stroke-width="2"/></g> | ||
| 34 | + <text x="772.5" y="190.0" text-anchor="middle" font-size="13" font-weight="700" fill="#E65100">remember</text> | ||
| 35 | + <g filter="url(#shadow)"><rect x="853" y="160" width="135" height="50" rx="12" fill="url(#gPurple)" stroke="#6A1B9A" stroke-width="2"/></g> | ||
| 36 | + <text x="920.5" y="190.0" text-anchor="middle" font-size="13" font-weight="700" fill="#4A148C">recall</text> | ||
| 37 | + <g filter="url(#shadow)"><rect x="1001" y="160" width="135" height="50" rx="12" fill="url(#gYellow)" stroke="#F9A825" stroke-width="2"/></g> | ||
| 38 | + <text x="1068.5" y="190.0" text-anchor="middle" font-size="13" font-weight="700" fill="#E65100">forget</text> | ||
| 39 | + <text x="772" y="238" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">add / replace a line</text> | ||
| 40 | + <text x="920" y="238" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">read the file</text> | ||
| 41 | + <text x="1068" y="238" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">remove a line</text> | ||
| 42 | + <rect x="680" y="360" width="480" height="170" rx="10" fill="#FAFAFA" fill-opacity="0.7" stroke="#90A4AE" stroke-width="2" stroke-dasharray="7,5"/> | ||
| 43 | + <text x="920.0" y="382" text-anchor="middle" font-size="13" font-style="italic" font-weight="700" fill="#607D8B">.mm/memory.md · one fact per line</text> | ||
| 44 | + <text x="920" y="404" text-anchor="middle" font-size="12" fill="#37474F" font-weight="700" font-family="DejaVu Sans Mono, monospace"># Memory</text> | ||
| 45 | + <text x="920" y="430" text-anchor="middle" font-size="12" fill="#37474F" font-family="DejaVu Sans Mono, monospace">- Sam is the user.</text> | ||
| 46 | + <text x="920" y="452" text-anchor="middle" font-size="12" fill="#37474F" font-family="DejaVu Sans Mono, monospace">- Prefers answers in French.</text> | ||
| 47 | + <text x="920" y="474" text-anchor="middle" font-size="12" fill="#37474F" font-family="DejaVu Sans Mono, monospace">- Release tags are rel-YYYY.MM.</text> | ||
| 48 | + <text x="920" y="506" text-anchor="middle" font-size="10.5" fill="#78909C" font-style="italic">a plain file: read it, correct it, delete it</text> | ||
| 49 | + <rect x="241.0" y="216.0" width="78" height="24" rx="5" fill="#FFFFFF"/> | ||
| 50 | + <text x="280" y="232.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">question</text> | ||
| 51 | + <rect x="589.0" y="216.0" width="82" height="24" rx="5" fill="#FFFFFF"/> | ||
| 52 | + <text x="630" y="232.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">read_skill</text> | ||
| 53 | + <rect x="950.2" y="305.0" width="179.6" height="40" rx="5" fill="#FFFFFF"/> | ||
| 54 | + <text x="1040" y="322" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">read_file · edit_file</text> | ||
| 55 | + <text x="1040" y="338" text-anchor="middle" font-size="10.5" fill="#78909C">only through a skill</text> | ||
| 56 | + <rect x="247.0" y="88.0" width="96.0" height="24" rx="5" fill="#FFFFFF"/> | ||
| 57 | + <text x="295" y="104.5" text-anchor="middle" font-size="12.5" font-weight="700" fill="#263238">the answer</text> | ||
| 58 | + <rect x="40" y="360" width="560" height="170" rx="10" fill="#FAFAFA" fill-opacity="0.7" stroke="#90A4AE" stroke-width="2" stroke-dasharray="7,5"/> | ||
| 59 | + <text x="320.0" y="382" text-anchor="middle" font-size="13" font-style="italic" font-weight="700" fill="#607D8B">what this way shows</text> | ||
| 60 | + <text x="320" y="404" text-anchor="middle" font-size="12.5" fill="#37474F">The memory reaches the model only when recall is called.</text> | ||
| 61 | + <text x="320" y="430" text-anchor="middle" font-size="12.5" fill="#37474F">Asked about you or the project, Jay calls recall: 8/8 right.</text> | ||
| 62 | + <text x="320" y="456" text-anchor="middle" font-size="12.5" fill="#37474F">Any other question: the memory is not read —</text> | ||
| 63 | + <text x="320" y="480" text-anchor="middle" font-size="12.5" fill="#E65100" font-weight="700">French in 4 of the 7 answers after it was saved.</text> | ||
| 64 | + <text x="600" y="600" text-anchor="middle" font-size="12.5" fill="#455A64" font-style="italic">Qwen3.5 4B on llama.cpp, temperature 0 · each question a new conversation (-p)</text> | ||
| 65 | + <text x="600" y="622" text-anchor="middle" font-size="12.5" fill="#455A64" font-style="italic">the next step, memory-skills-2: the memory always in the prompt</text> | ||
| 66 | +</svg> | ||