pig 0.1.1: the Agents row picks the model PiG starts on (str_)
str_ on Discord: PiG's row only listed models, where Pi's picks the one it
starts on. PiG keeps that in ~/.pig/agent/settings.json as
defaultProvider and defaultModel (PiG's settings reference and
startup_model.go). The descriptor now says `startup: {config:
settings.json, model: "defaultModel", keys: {defaultProvider: "magpie"}}`,
which magpie v0.1.3008 (1fd02d33c) reads: the row gets a model picker,
both keys are kept aside and put back on disconnect. An older magpie
ignores startup and keeps 0.1.0's connect-only row. The READMEs say so,
and that an enabledModels scope leaving the model out starts PiG on the
scope's first model.
Run (mote): bun test pig.test.mjs (11 pass; the new startup test checks
connect writes the provider defaultProvider names), bun scripts/check.mjs
ok. Real PiG 0.5.3 (darwin-arm64 release, SHA256SUMS checked) in a
sandbox HOME with this connect's models.json and the startup keys,
against a fake OpenAI server: `pig -p` sent model deepseek/flash; with
enabledModels ["magpie/deepseek/pro"] it sent deepseek/pro.
Not tried: PiG on Windows or Linux, a real magpie gateway in front of it.
This commit is contained in:
@@ -254,7 +254,7 @@ it off puts the config back.
|
||||
| [kilo](packages/kilo) | [Kilo Code](https://kilo.ai): `~/.config/kilo/kilo.jsonc`, through an OpenAI-compatible provider |
|
||||
| [junie](packages/junie) | [Junie CLI](https://junie.jetbrains.com/): an explicit `/v1/models` seed for its full picker and Magpie's selected model as the launch default; no LiteLLM |
|
||||
| [kimi-desktop](packages/kimi-desktop) | Ordinary [Kimi desktop](https://www.kimi.com/) Work, through its authenticated local runtime; not Kimi Code CLI |
|
||||
| [pig](packages/pig) | [PiG](https://github.com/MichaelKinsy/PiG): injects Magpie's endpoint and model catalog into `~/.pig/agent/models.json`; choose the model in PiG, startup settings stay unchanged |
|
||||
| [pig](packages/pig) | [PiG](https://github.com/MichaelKinsy/PiG): Magpie's endpoint and model catalog in `~/.pig/agent/models.json`, and the model PiG starts on (`defaultProvider`/`defaultModel` in `settings.json`) picked on the Agents page |
|
||||
| [type4me](packages/type4me) | [Type4Me](https://github.com/joewongjc/type4me), macOS voice input: `~/Library/Application Support/Type4Me/magpie-agent.json`, for its LLM post-processing |
|
||||
| [opencodereview](packages/opencodereview) | [Open Code Review](https://github.com/alibaba/open-code-review) (`ocr`): `~/.opencodereview/config.json` as a custom Anthropic provider, so `ocr review` / `ocr scan` run on magpie's models |
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# agent-pig
|
||||
|
||||
`@magpie-community/agent-pig` adds [PiG (Pi in Go)](https://github.com/MichaelKinsy/PiG) to Magpie as a **connect-only agent**. It supplies Magpie's endpoint and model catalog in `~/.pig/agent/models.json`. You choose the model in PiG. The plugin never writes `settings.json`.
|
||||
`@magpie-community/agent-pig` adds [PiG (Pi in Go)](https://github.com/MichaelKinsy/PiG) to Magpie. It supplies Magpie's endpoint and model catalog in `~/.pig/agent/models.json`, and the Agents row picks the model PiG starts on, as Pi's does: Magpie writes `defaultProvider: "magpie"` and `defaultModel` in `~/.pig/agent/settings.json`, PiG's own startup default ([PiG's settings reference](https://github.com/MichaelKinsy/PiG/blob/main/docs/site/docs/settings.md)). This needs a Magpie with the Agent contract's `startup` field (v0.1.3008 or later); an older Magpie reads 0.1.1 as 0.1.0 was, connect-only, and you choose the model with `/model` in PiG.
|
||||
|
||||
The Agents row identifies PiG with the project's pixel-pig icon from its official site. The image is not bundled: Magpie references it by URL and keeps its own cache. This is an unofficial integration; PiG is a project by Michael Kinsy and is not affiliated with, or endorsing, Magpie.
|
||||
|
||||
@@ -12,17 +12,17 @@ With a Magpie release that supports connect-only Agent plugins:
|
||||
magpie plugin add @magpie-community/agent-pig
|
||||
```
|
||||
|
||||
1. Open Magpie's Agents page and turn on **PiG**. Its row is a provider switch, with no model picker. CLI equivalent: `magpie pig provider magpie`.
|
||||
2. Start PiG, run `/model`, and select a model under the **Magpie** provider. Reopen `/model` after Magpie's catalog changes; restart PiG if your installed version does not reload it there.
|
||||
3. Before disconnecting, choose a model from another provider in PiG. Turn off **PiG** in Magpie, or run `magpie pig default`.
|
||||
1. Open Magpie's Agents page and pick one of Magpie's models in **PiG**'s row. CLI equivalent: `magpie pig model magpie/<provider>/<model>`.
|
||||
2. Start PiG: a new session starts on that model. `/model` in PiG still lists every Magpie model and switches among them; a model of Magpie's saved there keeps the row on Magpie, and one of another provider saved there is yours and is kept.
|
||||
3. Turn off **PiG** in Magpie, or run `magpie pig default`: `settings.json`'s `defaultProvider` and `defaultModel` go back to what you had (or are taken out where you had none), unless you saved another provider's model in PiG since, and the `magpie` provider leaves `models.json`.
|
||||
|
||||
Saving a startup default is a separate PiG action: use PiG's own model picker to save it. The plugin does not set or restore defaults, thinking preferences, or scoped models. An existing `enabledModels` scope can restrict selection; change that scope yourself in PiG if necessary. Disconnecting cannot repair a saved default or resumed session that still names a Magpie model.
|
||||
The plugin does not set thinking preferences or scoped models. An `enabledModels` scope that leaves the picked model out makes PiG start on the scope's first model instead (PiG's `coding/cli/startup_model.go`); add the Magpie model to it, or remove the scope, in PiG. A resumed session keeps the model it was saved with.
|
||||
|
||||
Disconnect the PiG agent before disabling or uninstalling the plugin; do not rely on removing a plugin to run the agent's disconnect flow.
|
||||
|
||||
## What it owns
|
||||
|
||||
Magpie manages **one complete object**, `providers.magpie`, inside `models.json`:
|
||||
Magpie manages **one complete object**, `providers.magpie`, inside `models.json`, and the two keys `defaultProvider` and `defaultModel` inside `settings.json` (each kept aside before the first write and put back on disconnect, the rest of the file untouched):
|
||||
|
||||
| Field inside the managed object | Value |
|
||||
| --- | --- |
|
||||
@@ -68,15 +68,15 @@ The repository's `scripts/check.mjs` skips Agent packages; `pig.test.mjs` checks
|
||||
|
||||
## 中文
|
||||
|
||||
这是仅注入模型目录的 PiG 适配插件。通过 `magpie plugin add @magpie-community/agent-pig` 安装后,在 Magpie 的 Agent 页打开 **PiG**,再到 PiG 中运行 `/model` 选择 Magpie 模型。
|
||||
这是 PiG 的适配插件。通过 `magpie plugin add @magpie-community/agent-pig` 安装后,在 Magpie 的 Agent 页 **PiG** 一行里直接选 Magpie 的模型,和 Pi 一样:Magpie 把 `~/.pig/agent/models.json` 里的 `providers.magpie` 和 `settings.json` 里的 `defaultProvider`/`defaultModel` 写好,新开的 PiG 会话就从这个模型开始;PiG 里的 `/model` 仍可切换。需要支持 Agent 契约 `startup` 字段的 Magpie(v0.1.3008 及以后);更早的 Magpie 把 0.1.1 当作 0.1.0,只能在 PiG 里用 `/model` 选。
|
||||
|
||||
插件只通过 Magpie 托管 `~/.pig/agent/models.json` 中完整的 `providers.magpie` 对象,不修改 `settings.json` 或 `auth.json`,也不替用户设置启动默认模型、思考等级或模型范围。断开时,原先有同名 provider 就恢复原对象,原先没有就移除整个 provider,避免空 provider 导致 PiG 解析失败。
|
||||
插件不修改 `auth.json`,也不设置思考等级或模型范围。若 `enabledModels` 不包含所选模型,PiG 会从范围里的第一个模型启动。断开时 `settings.json` 的两个键还原为原值(若之后在 PiG 里保存了其他 provider 的模型,则保留你的选择)。断开时,原先有同名 provider 就恢复原对象,原先没有就移除整个 provider,避免空 provider 导致 PiG 解析失败。
|
||||
|
||||
其他 provider 和顶层设置不在托管范围内。若原先就手动配置了名为 `magpie` 的 provider,它在接入期间会被替换,断开后恢复;接入期间对该区块的手写改动会被同步覆盖。需要同时使用的手动服务应使用其他 provider ID。插件不会修改既有凭证优先级。
|
||||
|
||||
默认仅支持 `~/.pig/agent`。使用环境变量改过目录或开启 Pi 共享目录的用户,需要先明确实际路径,再安装改过路径的本地描述文件。不要直接启用默认描述文件。
|
||||
|
||||
断开前在 PiG 中换回其他 provider 的模型;先断开 PiG,再禁用或卸载插件。PiG 自行保存的默认模型和会话引用不由本插件恢复。
|
||||
先断开 PiG,再禁用或卸载插件。已恢复的会话会沿用它保存时的模型。
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@magpie-community/agent-pig",
|
||||
"version": "0.1.0",
|
||||
"description": "PiG as a connect-only Magpie agent: inject endpoints and model catalog without changing startup settings",
|
||||
"version": "0.1.1",
|
||||
"description": "PiG as a Magpie agent: Magpie's endpoint and model catalog in models.json, and the model PiG starts on in settings.json",
|
||||
"type": "module",
|
||||
"files": ["pig.agent.js", "README.md"],
|
||||
"keywords": ["magpie", "magpie-agent", "pig", "pi-in-go", "llm-gateway"],
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
// PiG reads providers from models.json and startup preferences from a separate
|
||||
// settings.json. This connect-only agent owns the provider catalog alone.
|
||||
// settings.json (docs/site/docs/settings.md: defaultProvider, plus defaultModel
|
||||
// "without a provider prefix"). connect owns the provider catalog in
|
||||
// models.json; startup names the model a new session starts on in
|
||||
// settings.json, so the Agents row picks it as it does for Pi. A Magpie
|
||||
// without startup support reads this as connect-only, as 0.1.0 was.
|
||||
export const agent = {
|
||||
id: "pig",
|
||||
name: "PiG",
|
||||
@@ -9,7 +13,14 @@ export const agent = {
|
||||
dir: "~/.pig/agent",
|
||||
config: "~/.pig/agent/models.json",
|
||||
format: "json",
|
||||
notice: "Choose a Magpie model with /model in PiG. Startup settings are unchanged. 在 PiG 中用 /model 选择模型;启动设置保持原样。",
|
||||
startup: {
|
||||
config: "~/.pig/agent/settings.json",
|
||||
format: "json",
|
||||
model: "defaultModel",
|
||||
// the provider ID connect writes below
|
||||
keys: { defaultProvider: "magpie" },
|
||||
},
|
||||
notice: "New PiG sessions start on this model; /model in PiG still switches. 新开的 PiG 会话从这个模型开始;PiG 里的 /model 仍可切换。",
|
||||
}
|
||||
|
||||
const thinkingLevels = ["off", "minimal", "low", "medium", "high", "xhigh", "max"]
|
||||
|
||||
@@ -7,14 +7,20 @@ const model = { id: "relay/vendor/model:variant", name: "Example", context: 2621
|
||||
const output = (models = [model]) => connect({ gateway, models, agent: { id: "pig", config: "/synthetic/.pig/agent/models.json" } })
|
||||
const provider = (models = [model]) => output(models)["providers.magpie"]
|
||||
|
||||
test("registers PiG as a connect-only agent with no model or Library writes", () => {
|
||||
test("registers PiG with its startup model in settings.json and no Library writes", () => {
|
||||
expect(agent).toMatchObject({ id: "pig", name: "PiG", bin: "pig", config: "~/.pig/agent/models.json", format: "json" })
|
||||
expect(agent.icon).toBe("https://pi-in-go.dev/pig-favicon.svg")
|
||||
// agent.model stays out: a Magpie without startup reads PiG as connect-only
|
||||
expect(agent.model).toBeUndefined()
|
||||
expect(agent.startup).toEqual({ config: "~/.pig/agent/settings.json", format: "json", model: "defaultModel", keys: { defaultProvider: "magpie" } })
|
||||
expect(agent.library).toBeUndefined()
|
||||
expect(agent.notice).toContain("/model")
|
||||
})
|
||||
|
||||
test("starts PiG on the provider connect writes", () => {
|
||||
expect(Object.keys(output())).toEqual([`providers.${agent.startup.keys.defaultProvider}`])
|
||||
})
|
||||
|
||||
test("declares the standard community Agent entry and no host plugin", () => {
|
||||
const pkg = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf8"))
|
||||
expect(pkg.name).toBe("@magpie-community/agent-pig")
|
||||
|
||||
Reference in New Issue
Block a user