agent-aider 0.1.0: Aider as a magpie agent plugin, the first of the new agent kind (#78)

magpie (cb406c84) lets a plugin add an agent it has no setup of its own
for. This one writes Aider's ~/.aider.conf.yml: the model under litellm's
openai/ prefix, magpie's /v1 and Aider's own key. check.mjs skips agent
packages as it does middleware; README gains an Agents section.

Run: bun test packages/aider (2 pass); bun scripts/check.mjs; the module
loaded through magpie's agentplug.Compile and its connect returned the
three keys. The same module, in a sandbox magpie, wired a real aider
0.86.2 that answered from a real DeepSeek account, and Disconnect put
the file back byte for byte.
This commit is contained in:
yetone
2026-10-10 22:52:47 +08:00
committed by GitHub
parent 98e91cc4a2
commit 6e720301aa
6 changed files with 103 additions and 3 deletions
+22 -1
View File
@@ -1,7 +1,7 @@
# magpie-community plugins # magpie-community plugins
[OpenCode](https://opencode.ai) provider plugins for coding-plan [OpenCode](https://opencode.ai) provider plugins for coding-plan
subscriptions, and [gateway middleware](#gateway-middleware) for magpie, subscriptions, and [gateway middleware](#gateway-middleware) and [agents](#agents) for magpie,
maintained by the community. Each package signs in to one maintained by the community. Each package signs in to one
subscription and makes its requests. The packages work in OpenCode and in subscription and makes its requests. The packages work in OpenCode and in
[magpie](https://usemagpie.ai), which runs OpenCode's provider plugins. [magpie](https://usemagpie.ai), which runs OpenCode's provider plugins.
@@ -52,6 +52,27 @@ A middleware package is a folder under `packages/<name>/` with:
- **`<name>.middleware.js`**: exports `onRequest`, `onEvent` and/or `onResponse` ([the hooks](https://usemagpie.ai/docs/plugins#middleware)). It runs in magpie's gateway on moejs, so it is one file and imports nothing. - **`<name>.middleware.js`**: exports `onRequest`, `onEvent` and/or `onResponse` ([the hooks](https://usemagpie.ai/docs/plugins#middleware)). It runs in magpie's gateway on moejs, so it is one file and imports nothing.
- **`cases.json`** and a test that runs them with `check()` from `scripts/middleware.mjs`, which calls the hooks the way the gateway does. - **`cases.json`** and a test that runs them with `check()` from `scripts/middleware.mjs`, which calls the hooks the way the gateway does.
## Agents
These add an agent magpie has no setup of its own for. Once added, the agent is
on magpie's Agents page like the ones magpie ships with: pick one of magpie's
models in its row and magpie writes it into the agent's config, and switching
it off puts the config back.
| Package | Agent |
|---|---|
| [aider](packages/aider) | [Aider](https://aider.chat): `~/.aider.conf.yml`, through litellm's `openai/` prefix |
```sh
magpie plugin add @magpie-community/agent-<name>
```
An agent package is a folder under `packages/<name>/` with:
- **`package.json`**: name `@magpie-community/agent-<name>`, `"magpie": {"agent": "./<name>.agent.js"}`, no `main`.
- **`<name>.agent.js`**: exports `agent` (where the agent keeps its model) and, if it needs more than the model, `connect` (the other keys to write) ([the reference](https://usemagpie.ai/docs/plugins#agents)). It runs in magpie on moejs, so it is one file and imports nothing.
- a test of what `connect` returns.
## Skills ## Skills
Agent skills for magpie users, in `skills/<name>/SKILL.md`. Agent skills for magpie users, in `skills/<name>/SKILL.md`.
+25
View File
@@ -0,0 +1,25 @@
# @magpie-community/agent-aider
[Aider](https://aider.chat) as a magpie agent. magpie has no setup of its own
for Aider; with this plugin it is on magpie's Agents page like the agents
magpie ships with.
```sh
magpie plugin add @magpie-community/agent-aider
```
Then pick one of magpie's models in Aider's row. magpie writes into
`~/.aider.conf.yml`:
```yaml
model: openai/deepseek/deepseek-flash # magpie's model, through litellm's openai/ prefix
openai-api-base: http://127.0.0.1:3425/v1
openai-api-key: magpie-aider # Aider's own key, so Usage names it
show-model-warnings: false
```
Your comments and other settings stay. Picking Aider's own model again, or
switching it off, puts every key back as it was. Restart Aider after a change:
it reads its settings when it starts.
How agent plugins work: [usemagpie.ai/docs/plugins#agents](https://usemagpie.ai/docs/plugins#agents).
+23
View File
@@ -0,0 +1,23 @@
// Aider (aider.chat) keeps its settings in ~/.aider.conf.yml and reaches
// any OpenAI-compatible endpoint through litellm's openai/ prefix, so
// magpie's model goes in as openai/<provider>/<model>, beside magpie's
// address and the key magpie keeps for Aider.
export const agent = {
id: "aider",
name: "Aider",
bin: "aider",
config: "~/.aider.conf.yml",
model: "model",
prefix: "openai/",
ua: ["aider", "litellm"],
notice: "Aider reads its settings when it starts: restart it to use the new model.",
}
export function connect({ gateway }) {
return {
"openai-api-base": gateway.v1,
"openai-api-key": gateway.key,
// magpie's model ids aren't in litellm's list, so aider would warn on each
"show-model-warnings": false,
}
}
+20
View File
@@ -0,0 +1,20 @@
import { expect, test } from "bun:test"
import { agent, connect } from "./aider.agent.js"
test("says where Aider keeps its model", () => {
expect(agent).toMatchObject({ id: "aider", config: "~/.aider.conf.yml", model: "model", prefix: "openai/" })
})
test("points Aider at magpie with its own key", () => {
const out = connect({
gateway: { url: "http://127.0.0.1:3425", v1: "http://127.0.0.1:3425/v1", key: "magpie-aider" },
model: { id: "deepseek/deepseek-flash", name: "DeepSeek Flash" },
models: [],
agent: { id: "aider", config: "/home/u/.aider.conf.yml" },
})
expect(out).toEqual({
"openai-api-base": "http://127.0.0.1:3425/v1",
"openai-api-key": "magpie-aider",
"show-model-warnings": false,
})
})
+11
View File
@@ -0,0 +1,11 @@
{
"name": "@magpie-community/agent-aider",
"version": "0.1.0",
"description": "Aider (aider.chat) as a magpie agent: pick one of magpie's models for it on the Agents page",
"type": "module",
"files": ["aider.agent.js", "README.md"],
"keywords": ["magpie", "magpie-agent", "aider", "llm-gateway"],
"license": "MIT",
"repository": { "type": "git", "url": "git+https://github.com/magpie-community/plugins.git", "directory": "packages/aider" },
"magpie": { "agent": "./aider.agent.js" }
}
+2 -2
View File
@@ -14,8 +14,8 @@ for (const name of readdirSync(root)) {
const pj = join(dir, "package.json") const pj = join(dir, "package.json")
if (!existsSync(pj)) continue if (!existsSync(pj)) continue
const pkg = JSON.parse(readFileSync(pj, "utf8")) const pkg = JSON.parse(readFileSync(pj, "utf8"))
// gateway middleware has no OpenCode plugin; its own tests check it // gateway middleware and agents have no OpenCode plugin; their own tests check them
if (pkg.magpie?.middleware) continue if (pkg.magpie?.middleware || pkg.magpie?.agent) continue
const problems = [] const problems = []
try { try {
const mod = await import(pathToFileURL(join(dir, pkg.main ?? "index.mjs")).href) const mod = await import(pathToFileURL(join(dir, pkg.main ?? "index.mjs")).href)