@eduardo191labs/opencode-free-pi 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -3
- package/dist/agents/definitions.d.ts +18 -0
- package/dist/agents/definitions.js +34 -0
- package/dist/catalog/models.js +5 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +3 -0
- package/dist/plugin.js +19 -3
- package/package.json +1 -1
- package/src/agents/definitions.ts +45 -0
- package/src/catalog/models.ts +5 -1
- package/src/constants.ts +3 -0
- package/src/plugin.ts +22 -2
package/README.md
CHANGED
|
@@ -275,14 +275,34 @@ plano, comparten el allowance diario y envían su informe al agente principal.
|
|
|
275
275
|
Así se conservan las sesiones hijas, los permisos, la profundidad de subagentes
|
|
276
276
|
y el resto del comportamiento nativo.
|
|
277
277
|
|
|
278
|
+
La herramienta `subagent` es la de OpenCode y está disponible para **cualquier
|
|
279
|
+
modelo**, no solo para los agentes `free-pi/*`: también puede lanzarlos un
|
|
280
|
+
modelo de otro proveedor configurado en OpenCode. El plugin garantiza además que
|
|
281
|
+
todos los modelos gratuitos anuncien soporte de tools, de modo que el runner
|
|
282
|
+
nunca oculte `subagent` por una capacidad incorrecta de models.dev.
|
|
283
|
+
|
|
278
284
|
El plugin solo reescribe estos archivos si conservan su marca de gestión; si el
|
|
279
285
|
usuario edita o reemplaza uno, se respeta tal cual.
|
|
280
286
|
|
|
281
287
|
## Skill y contexto
|
|
282
288
|
|
|
283
|
-
El plugin
|
|
284
|
-
|
|
285
|
-
|
|
289
|
+
El plugin instala una skill nativa en:
|
|
290
|
+
|
|
291
|
+
```text
|
|
292
|
+
~/.config/opencode/skills/free-pi/SKILL.md
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
OpenCode la descubre con su propio cargador (ID `free-pi`), la anuncia cuando es
|
|
296
|
+
relevante y el agente la carga con su herramienta `skill`. Contiene la lista de
|
|
297
|
+
herramientas, los subagentes y las reglas de allowance. Si el directorio de
|
|
298
|
+
configuración no se puede escribir, el plugin la registra mediante la API de
|
|
299
|
+
skills como respaldo.
|
|
300
|
+
|
|
301
|
+
Cada petición principal de free-pi recibe además una guía breve que pide
|
|
302
|
+
delegar el trabajo grande en `free-pi/scout`, `free-pi/planner`,
|
|
303
|
+
`free-pi/worker` o `free-pi/reviewer` con `subagent`, cargar skills con `skill`
|
|
304
|
+
y seguir `AGENTS.md` en lugar de inventar convenciones. Esa guía solo se añade a
|
|
305
|
+
las peticiones de `free-pi` y `free-pi-defense`.
|
|
286
306
|
|
|
287
307
|
La memoria, las sesiones y el contexto son los de OpenCode: `AGENTS.md` y los
|
|
288
308
|
archivos de `instructions` se cargan de forma nativa, las sesiones persisten y
|
|
@@ -22,9 +22,16 @@ export declare const FREE_PI_SKILL_ID = "free-pi";
|
|
|
22
22
|
export declare const FREE_PI_SKILL_NAME = "free-pi";
|
|
23
23
|
export declare const FREE_PI_SKILL_DESCRIPTION = "How free-pi works in OpenCode: its tools, the installed native subagents, allowance and limits, and where sessions and memory live.";
|
|
24
24
|
export declare const FREE_PI_SKILL = "# free-pi in OpenCode\n\nfree-pi is a free, ad-supported provider for OpenCode. You sign in with GitHub\nand ads in the session pay for the inference; there is no model API key. The\nfree daily allowance is shared by every free-pi model and every tool that spends\nit.\n\n## Tools\n- `free_pi_usage` shows today's remaining allowance, credits, token counts and\n the account tier. Read-only.\n- `look_at_image` asks a vision model about a PNG, JPEG or WebP inside the\n project. Use it when the current model takes text only, or when the image is a\n file on disk and you want a targeted answer instead of attaching it.\n- `generate_image` draws one image from a prompt and saves it under `images/`.\n- `web_search` searches the web for current information.\n- `docs_lookup` looks up current library and framework documentation.\n\nEvery tool except `free_pi_usage` spends allowance. Usage limits\n(`daily_cap`, `rolling_cap`, concurrency) are terminal: stop and continue\nwithout the tool instead of retrying.\n\n## Subagents\n\nUse OpenCode's native subagent tool with the agents this plugin installs:\n\n| Agent | Use it for |\n| --- | --- |\n| `free-pi/scout` | Read-only recon: locate code and return structured findings. |\n| `free-pi/planner` | Read-only plan for a change, ready for a worker. |\n| `free-pi/worker` | Carry out one full task in its own context window. |\n| `free-pi/reviewer` | Read-only review with file and line references. |\n\nSubagents inherit the free-pi model, share the same daily allowance, and run as\nchild sessions in the background. Keep large exploration in a subagent so it\ndoes not fill your own context. Use OpenCode's agent picker or the `subagent`\ntool; do not try to launch them through shell commands.\n\n## Memory and sessions\n\nOpenCode owns memory and context: `AGENTS.md` and configured instruction files\nare loaded natively, sessions persist and resume, and compaction folds long\nconversations into a summary. Put durable project facts in `AGENTS.md` (or a\nfile listed under `instructions`) instead of repeating them in every prompt.\n\n## Native integrations\n\nMCP servers, skills, commands, references and permissions are configured in\nOpenCode as usual; free-pi does not replace them. Prefer those native features\nover running an external CLI.\n";
|
|
25
|
+
/**
|
|
26
|
+
* The same skill as a native `SKILL.md`. OpenCode discovers it from the global
|
|
27
|
+
* skills directory, so the file, its ID, its permissions and the `skill` tool
|
|
28
|
+
* all belong to OpenCode instead of a runtime registration.
|
|
29
|
+
*/
|
|
30
|
+
export declare const FREE_PI_SKILL_FILE = "---\nname: free-pi\ndescription: How free-pi works in OpenCode: its tools, the installed native subagents, allowance and limits, and where sessions and memory live.\n---\n\n<!-- managed by @eduardo191labs/opencode-free-pi; delete this line to keep your own copy -->\n\n# free-pi in OpenCode\n\nfree-pi is a free, ad-supported provider for OpenCode. You sign in with GitHub\nand ads in the session pay for the inference; there is no model API key. The\nfree daily allowance is shared by every free-pi model and every tool that spends\nit.\n\n## Tools\n- `free_pi_usage` shows today's remaining allowance, credits, token counts and\n the account tier. Read-only.\n- `look_at_image` asks a vision model about a PNG, JPEG or WebP inside the\n project. Use it when the current model takes text only, or when the image is a\n file on disk and you want a targeted answer instead of attaching it.\n- `generate_image` draws one image from a prompt and saves it under `images/`.\n- `web_search` searches the web for current information.\n- `docs_lookup` looks up current library and framework documentation.\n\nEvery tool except `free_pi_usage` spends allowance. Usage limits\n(`daily_cap`, `rolling_cap`, concurrency) are terminal: stop and continue\nwithout the tool instead of retrying.\n\n## Subagents\n\nUse OpenCode's native subagent tool with the agents this plugin installs:\n\n| Agent | Use it for |\n| --- | --- |\n| `free-pi/scout` | Read-only recon: locate code and return structured findings. |\n| `free-pi/planner` | Read-only plan for a change, ready for a worker. |\n| `free-pi/worker` | Carry out one full task in its own context window. |\n| `free-pi/reviewer` | Read-only review with file and line references. |\n\nSubagents inherit the free-pi model, share the same daily allowance, and run as\nchild sessions in the background. Keep large exploration in a subagent so it\ndoes not fill your own context. Use OpenCode's agent picker or the `subagent`\ntool; do not try to launch them through shell commands.\n\n## Memory and sessions\n\nOpenCode owns memory and context: `AGENTS.md` and configured instruction files\nare loaded natively, sessions persist and resume, and compaction folds long\nconversations into a summary. Put durable project facts in `AGENTS.md` (or a\nfile listed under `instructions`) instead of repeating them in every prompt.\n\n## Native integrations\n\nMCP servers, skills, commands, references and permissions are configured in\nOpenCode as usual; free-pi does not replace them. Prefer those native features\nover running an external CLI.\n";
|
|
25
31
|
/** OpenCode's user-wide config directory, where it loads custom agents. */
|
|
26
32
|
export declare function openCodeConfigDir(): string;
|
|
27
33
|
export declare function freePiAgentPath(configDir: string, id: FreePiAgentID): string;
|
|
34
|
+
export declare function freePiSkillPath(configDir: string): string;
|
|
28
35
|
export type AgentInstallResult = {
|
|
29
36
|
readonly installed: FreePiAgentID[];
|
|
30
37
|
readonly skipped: FreePiAgentID[];
|
|
@@ -36,3 +43,14 @@ export type AgentInstallResult = {
|
|
|
36
43
|
* treated as user-owned and left untouched.
|
|
37
44
|
*/
|
|
38
45
|
export declare function installFreePiAgents(configDir?: string): Promise<AgentInstallResult>;
|
|
46
|
+
export type SkillInstallResult = {
|
|
47
|
+
readonly installed: boolean;
|
|
48
|
+
readonly skipped: boolean;
|
|
49
|
+
readonly changed: boolean;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Writes the free-pi skill as `skills/free-pi/SKILL.md`, the layout OpenCode's
|
|
53
|
+
* own skill loader reads. A file without our marker is user-owned and stays
|
|
54
|
+
* untouched, exactly like the agent files.
|
|
55
|
+
*/
|
|
56
|
+
export declare function installFreePiSkill(configDir?: string): Promise<SkillInstallResult>;
|
|
@@ -79,6 +79,19 @@ MCP servers, skills, commands, references and permissions are configured in
|
|
|
79
79
|
OpenCode as usual; free-pi does not replace them. Prefer those native features
|
|
80
80
|
over running an external CLI.
|
|
81
81
|
`;
|
|
82
|
+
/**
|
|
83
|
+
* The same skill as a native `SKILL.md`. OpenCode discovers it from the global
|
|
84
|
+
* skills directory, so the file, its ID, its permissions and the `skill` tool
|
|
85
|
+
* all belong to OpenCode instead of a runtime registration.
|
|
86
|
+
*/
|
|
87
|
+
export const FREE_PI_SKILL_FILE = `---
|
|
88
|
+
name: ${FREE_PI_SKILL_NAME}
|
|
89
|
+
description: ${FREE_PI_SKILL_DESCRIPTION}
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
${MARKER}
|
|
93
|
+
|
|
94
|
+
${FREE_PI_SKILL}`;
|
|
82
95
|
const SCOUT = `---
|
|
83
96
|
description: Read-only recon. Locates code, traces how pieces connect, and returns structured findings the lead can use without re-reading the files.
|
|
84
97
|
mode: all
|
|
@@ -240,6 +253,9 @@ export function openCodeConfigDir() {
|
|
|
240
253
|
export function freePiAgentPath(configDir, id) {
|
|
241
254
|
return join(configDir, "agents", ...id.split("/")) + ".md";
|
|
242
255
|
}
|
|
256
|
+
export function freePiSkillPath(configDir) {
|
|
257
|
+
return join(configDir, "skills", FREE_PI_SKILL_ID, "SKILL.md");
|
|
258
|
+
}
|
|
243
259
|
async function fileState(path, content) {
|
|
244
260
|
try {
|
|
245
261
|
const current = await readFile(path, "utf8");
|
|
@@ -275,3 +291,21 @@ export async function installFreePiAgents(configDir = openCodeConfigDir()) {
|
|
|
275
291
|
}
|
|
276
292
|
return { installed, skipped, changed: installed.length > 0 };
|
|
277
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* Writes the free-pi skill as `skills/free-pi/SKILL.md`, the layout OpenCode's
|
|
296
|
+
* own skill loader reads. A file without our marker is user-owned and stays
|
|
297
|
+
* untouched, exactly like the agent files.
|
|
298
|
+
*/
|
|
299
|
+
export async function installFreePiSkill(configDir = openCodeConfigDir()) {
|
|
300
|
+
const path = freePiSkillPath(configDir);
|
|
301
|
+
const state = await fileState(path, FREE_PI_SKILL_FILE);
|
|
302
|
+
if (state === "same") {
|
|
303
|
+
return { installed: false, skipped: false, changed: false };
|
|
304
|
+
}
|
|
305
|
+
if (state === "protected") {
|
|
306
|
+
return { installed: false, skipped: true, changed: false };
|
|
307
|
+
}
|
|
308
|
+
await mkdir(dirname(path), { recursive: true });
|
|
309
|
+
await writeFile(path, FREE_PI_SKILL_FILE, "utf8");
|
|
310
|
+
return { installed: true, skipped: false, changed: true };
|
|
311
|
+
}
|
package/dist/catalog/models.js
CHANGED
|
@@ -298,7 +298,11 @@ export function buildModels(models, candidates = [], options = {}) {
|
|
|
298
298
|
...(defaultEffort ? { settings: { reasoningEffort: defaultEffort } } : {}),
|
|
299
299
|
enabled: model.unavailable !== true,
|
|
300
300
|
temperature: model.temperature ?? capability?.temperature ?? true,
|
|
301
|
-
|
|
301
|
+
// All free models were probed against the gateway and call tools, so a
|
|
302
|
+
// models.dev entry that marks the matched upstream as text-only must not
|
|
303
|
+
// take away their tools. That would also hide OpenCode's native
|
|
304
|
+
// `subagent` tool. A `tool_call` value in free-pi's own catalog still wins.
|
|
305
|
+
tool_call: model.tool_call ?? (model.free === true ? true : capability?.tool_call ?? true),
|
|
302
306
|
attachment: model.attachment ??
|
|
303
307
|
capability?.attachment ??
|
|
304
308
|
modalities.input.includes("image"),
|
package/dist/constants.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export declare const DEFAULT_THINKING_LEVELS: readonly ["none", "minimal", "low"
|
|
|
50
50
|
* models show: skipping analysis, inventing verification, and ignoring the
|
|
51
51
|
* context the conversation already established.
|
|
52
52
|
*/
|
|
53
|
-
export declare const FREE_PI_GUIDANCE = "# free-pi working rules\n- Answer the user's latest request and keep their constraints; do not switch to a different task.\n- Slow down on multi-step work (arithmetic, counting, logic, dates, units, planning, debugging): write out each step, recompute the result a second way, and only then answer. On those tasks a correct answer after a dozen explicit steps beats a fast guess; do not stop at the first plausible number.\n- Read the files involved before editing and run the project's checks afterwards. Never say a test, build or command passed unless you ran it and saw it pass.\n- Treat the conversation above as memory: reuse earlier decisions, file paths, identifiers and results. If something is genuinely missing, say what is missing instead of guessing.\n- Use the available tools (read, grep, glob, bash, edit) for real work; do not describe hypothetical commands as if they ran.\n- Never claim to have compacted, summarized or cleared context unless that actually happened.\n- Continue until the request is finished, then report concisely what changed and what you verified.";
|
|
53
|
+
export declare const FREE_PI_GUIDANCE = "# free-pi working rules\n- Answer the user's latest request and keep their constraints; do not switch to a different task.\n- Slow down on multi-step work (arithmetic, counting, logic, dates, units, planning, debugging): write out each step, recompute the result a second way, and only then answer. On those tasks a correct answer after a dozen explicit steps beats a fast guess; do not stop at the first plausible number.\n- Read the files involved before editing and run the project's checks afterwards. Never say a test, build or command passed unless you ran it and saw it pass.\n- Treat the conversation above as memory: reuse earlier decisions, file paths, identifiers and results. If something is genuinely missing, say what is missing instead of guessing.\n- Use the available tools (read, grep, glob, bash, edit) for real work; do not describe hypothetical commands as if they ran.\n- Delegate large or self-contained work with OpenCode's native `subagent` tool: `free-pi/scout` and `free-pi/planner` for read-only recon and planning, `free-pi/worker` for a full task, `free-pi/reviewer` for review. A subagent runs in its own context and reports back; never launch a subagent from inside one.\n- Load a skill with the native `skill` tool when its description matches the task.\n- `AGENTS.md` and the files listed under `instructions` are the project's memory. Follow them; do not restate or replace them.\n- Never claim to have compacted, summarized or cleared context unless that actually happened.\n- Continue until the request is finished, then report concisely what changed and what you verified.";
|
|
54
54
|
export declare const FREE_PI_GUIDANCE_MARKER = "# free-pi working rules";
|
|
55
55
|
/**
|
|
56
56
|
* Appended to OpenCode's compaction request. Its default summary prompt asks
|
package/dist/constants.js
CHANGED
|
@@ -70,6 +70,9 @@ export const FREE_PI_GUIDANCE = `# free-pi working rules
|
|
|
70
70
|
- Read the files involved before editing and run the project's checks afterwards. Never say a test, build or command passed unless you ran it and saw it pass.
|
|
71
71
|
- Treat the conversation above as memory: reuse earlier decisions, file paths, identifiers and results. If something is genuinely missing, say what is missing instead of guessing.
|
|
72
72
|
- Use the available tools (read, grep, glob, bash, edit) for real work; do not describe hypothetical commands as if they ran.
|
|
73
|
+
- Delegate large or self-contained work with OpenCode's native \`subagent\` tool: \`free-pi/scout\` and \`free-pi/planner\` for read-only recon and planning, \`free-pi/worker\` for a full task, \`free-pi/reviewer\` for review. A subagent runs in its own context and reports back; never launch a subagent from inside one.
|
|
74
|
+
- Load a skill with the native \`skill\` tool when its description matches the task.
|
|
75
|
+
- \`AGENTS.md\` and the files listed under \`instructions\` are the project's memory. Follow them; do not restate or replace them.
|
|
73
76
|
- Never claim to have compacted, summarized or cleared context unless that actually happened.
|
|
74
77
|
- Continue until the request is finished, then report concisely what changed and what you verified.`;
|
|
75
78
|
export const FREE_PI_GUIDANCE_MARKER = "# free-pi working rules";
|
package/dist/plugin.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** OpenCode V2 plugin entry point for free-pi. */
|
|
2
2
|
import { Plugin } from "@opencode/plugin";
|
|
3
|
-
import {
|
|
4
|
-
import { FREE_PI_SKILL, FREE_PI_SKILL_DESCRIPTION, FREE_PI_SKILL_ID, FREE_PI_SKILL_NAME, installFreePiAgents, openCodeConfigDir, } from "./agents/definitions.js";
|
|
3
|
+
import { FREE_PI_SKILL, FREE_PI_SKILL_DESCRIPTION, FREE_PI_SKILL_ID, FREE_PI_SKILL_NAME, freePiSkillPath, installFreePiAgents, installFreePiSkill, openCodeConfigDir, } from "./agents/definitions.js";
|
|
5
4
|
import { fetchQuota } from "./api/quota.js";
|
|
6
5
|
import { closeFreePiSession } from "./api/session.js";
|
|
7
6
|
import { readCredentialsToken } from "./auth/credentials.js";
|
|
@@ -71,6 +70,23 @@ async function setup(ctx) {
|
|
|
71
70
|
catch (error) {
|
|
72
71
|
log.warn("Could not install the free-pi subagents", error);
|
|
73
72
|
}
|
|
73
|
+
// OpenCode's own skill loader reads `skills/free-pi/SKILL.md`. Install the
|
|
74
|
+
// file first so the skill has a real path, supporting files and permissions
|
|
75
|
+
// like any other native skill; the transform below only fills the gap when
|
|
76
|
+
// the config directory is not writable.
|
|
77
|
+
try {
|
|
78
|
+
const skill = await installFreePiSkill();
|
|
79
|
+
if (skill.changed) {
|
|
80
|
+
await ctx.skill.reload();
|
|
81
|
+
log.info("Installed the native free-pi skill");
|
|
82
|
+
}
|
|
83
|
+
if (skill.skipped) {
|
|
84
|
+
log.warn("Left the user-owned free-pi skill file untouched", freePiSkillPath(openCodeConfigDir()));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
log.warn("Could not install the free-pi skill file", error);
|
|
89
|
+
}
|
|
74
90
|
try {
|
|
75
91
|
nativeRegistrations.push(await ctx.skill.transform((editor) => {
|
|
76
92
|
if (editor.get(FREE_PI_SKILL_ID))
|
|
@@ -79,7 +95,7 @@ async function setup(ctx) {
|
|
|
79
95
|
id: FREE_PI_SKILL_ID,
|
|
80
96
|
name: FREE_PI_SKILL_NAME,
|
|
81
97
|
description: FREE_PI_SKILL_DESCRIPTION,
|
|
82
|
-
path:
|
|
98
|
+
path: freePiSkillPath(openCodeConfigDir()),
|
|
83
99
|
content: FREE_PI_SKILL,
|
|
84
100
|
});
|
|
85
101
|
}));
|
package/package.json
CHANGED
|
@@ -89,6 +89,20 @@ OpenCode as usual; free-pi does not replace them. Prefer those native features
|
|
|
89
89
|
over running an external CLI.
|
|
90
90
|
`;
|
|
91
91
|
|
|
92
|
+
/**
|
|
93
|
+
* The same skill as a native `SKILL.md`. OpenCode discovers it from the global
|
|
94
|
+
* skills directory, so the file, its ID, its permissions and the `skill` tool
|
|
95
|
+
* all belong to OpenCode instead of a runtime registration.
|
|
96
|
+
*/
|
|
97
|
+
export const FREE_PI_SKILL_FILE = `---
|
|
98
|
+
name: ${FREE_PI_SKILL_NAME}
|
|
99
|
+
description: ${FREE_PI_SKILL_DESCRIPTION}
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
${MARKER}
|
|
103
|
+
|
|
104
|
+
${FREE_PI_SKILL}`;
|
|
105
|
+
|
|
92
106
|
const SCOUT = `---
|
|
93
107
|
description: Read-only recon. Locates code, traces how pieces connect, and returns structured findings the lead can use without re-reading the files.
|
|
94
108
|
mode: all
|
|
@@ -255,6 +269,10 @@ export function freePiAgentPath(configDir: string, id: FreePiAgentID): string {
|
|
|
255
269
|
return join(configDir, "agents", ...id.split("/")) + ".md";
|
|
256
270
|
}
|
|
257
271
|
|
|
272
|
+
export function freePiSkillPath(configDir: string): string {
|
|
273
|
+
return join(configDir, "skills", FREE_PI_SKILL_ID, "SKILL.md");
|
|
274
|
+
}
|
|
275
|
+
|
|
258
276
|
async function fileState(
|
|
259
277
|
path: string,
|
|
260
278
|
content: string,
|
|
@@ -301,3 +319,30 @@ export async function installFreePiAgents(
|
|
|
301
319
|
|
|
302
320
|
return { installed, skipped, changed: installed.length > 0 };
|
|
303
321
|
}
|
|
322
|
+
|
|
323
|
+
export type SkillInstallResult = {
|
|
324
|
+
readonly installed: boolean;
|
|
325
|
+
readonly skipped: boolean;
|
|
326
|
+
readonly changed: boolean;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Writes the free-pi skill as `skills/free-pi/SKILL.md`, the layout OpenCode's
|
|
331
|
+
* own skill loader reads. A file without our marker is user-owned and stays
|
|
332
|
+
* untouched, exactly like the agent files.
|
|
333
|
+
*/
|
|
334
|
+
export async function installFreePiSkill(
|
|
335
|
+
configDir = openCodeConfigDir(),
|
|
336
|
+
): Promise<SkillInstallResult> {
|
|
337
|
+
const path = freePiSkillPath(configDir);
|
|
338
|
+
const state = await fileState(path, FREE_PI_SKILL_FILE);
|
|
339
|
+
if (state === "same") {
|
|
340
|
+
return { installed: false, skipped: false, changed: false };
|
|
341
|
+
}
|
|
342
|
+
if (state === "protected") {
|
|
343
|
+
return { installed: false, skipped: true, changed: false };
|
|
344
|
+
}
|
|
345
|
+
await mkdir(dirname(path), { recursive: true });
|
|
346
|
+
await writeFile(path, FREE_PI_SKILL_FILE, "utf8");
|
|
347
|
+
return { installed: true, skipped: false, changed: true };
|
|
348
|
+
}
|
package/src/catalog/models.ts
CHANGED
|
@@ -424,7 +424,11 @@ export function buildModels(
|
|
|
424
424
|
...(defaultEffort ? { settings: { reasoningEffort: defaultEffort } } : {}),
|
|
425
425
|
enabled: model.unavailable !== true,
|
|
426
426
|
temperature: model.temperature ?? capability?.temperature ?? true,
|
|
427
|
-
|
|
427
|
+
// All free models were probed against the gateway and call tools, so a
|
|
428
|
+
// models.dev entry that marks the matched upstream as text-only must not
|
|
429
|
+
// take away their tools. That would also hide OpenCode's native
|
|
430
|
+
// `subagent` tool. A `tool_call` value in free-pi's own catalog still wins.
|
|
431
|
+
tool_call: model.tool_call ?? (model.free === true ? true : capability?.tool_call ?? true),
|
|
428
432
|
attachment:
|
|
429
433
|
model.attachment ??
|
|
430
434
|
capability?.attachment ??
|
package/src/constants.ts
CHANGED
|
@@ -77,6 +77,9 @@ export const FREE_PI_GUIDANCE = `# free-pi working rules
|
|
|
77
77
|
- Read the files involved before editing and run the project's checks afterwards. Never say a test, build or command passed unless you ran it and saw it pass.
|
|
78
78
|
- Treat the conversation above as memory: reuse earlier decisions, file paths, identifiers and results. If something is genuinely missing, say what is missing instead of guessing.
|
|
79
79
|
- Use the available tools (read, grep, glob, bash, edit) for real work; do not describe hypothetical commands as if they ran.
|
|
80
|
+
- Delegate large or self-contained work with OpenCode's native \`subagent\` tool: \`free-pi/scout\` and \`free-pi/planner\` for read-only recon and planning, \`free-pi/worker\` for a full task, \`free-pi/reviewer\` for review. A subagent runs in its own context and reports back; never launch a subagent from inside one.
|
|
81
|
+
- Load a skill with the native \`skill\` tool when its description matches the task.
|
|
82
|
+
- \`AGENTS.md\` and the files listed under \`instructions\` are the project's memory. Follow them; do not restate or replace them.
|
|
80
83
|
- Never claim to have compacted, summarized or cleared context unless that actually happened.
|
|
81
84
|
- Continue until the request is finished, then report concisely what changed and what you verified.`;
|
|
82
85
|
export const FREE_PI_GUIDANCE_MARKER = "# free-pi working rules";
|
package/src/plugin.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/** OpenCode V2 plugin entry point for free-pi. */
|
|
2
2
|
|
|
3
3
|
import { Plugin } from "@opencode/plugin";
|
|
4
|
-
import { join } from "node:path";
|
|
5
4
|
import {
|
|
6
5
|
FREE_PI_SKILL,
|
|
7
6
|
FREE_PI_SKILL_DESCRIPTION,
|
|
8
7
|
FREE_PI_SKILL_ID,
|
|
9
8
|
FREE_PI_SKILL_NAME,
|
|
9
|
+
freePiSkillPath,
|
|
10
10
|
installFreePiAgents,
|
|
11
|
+
installFreePiSkill,
|
|
11
12
|
openCodeConfigDir,
|
|
12
13
|
} from "./agents/definitions.js";
|
|
13
14
|
import { fetchQuota } from "./api/quota.js";
|
|
@@ -100,6 +101,25 @@ async function setup(ctx: Plugin.Context): Promise<() => Promise<void>> {
|
|
|
100
101
|
} catch (error) {
|
|
101
102
|
log.warn("Could not install the free-pi subagents", error);
|
|
102
103
|
}
|
|
104
|
+
// OpenCode's own skill loader reads `skills/free-pi/SKILL.md`. Install the
|
|
105
|
+
// file first so the skill has a real path, supporting files and permissions
|
|
106
|
+
// like any other native skill; the transform below only fills the gap when
|
|
107
|
+
// the config directory is not writable.
|
|
108
|
+
try {
|
|
109
|
+
const skill = await installFreePiSkill();
|
|
110
|
+
if (skill.changed) {
|
|
111
|
+
await ctx.skill.reload();
|
|
112
|
+
log.info("Installed the native free-pi skill");
|
|
113
|
+
}
|
|
114
|
+
if (skill.skipped) {
|
|
115
|
+
log.warn(
|
|
116
|
+
"Left the user-owned free-pi skill file untouched",
|
|
117
|
+
freePiSkillPath(openCodeConfigDir()),
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
} catch (error) {
|
|
121
|
+
log.warn("Could not install the free-pi skill file", error);
|
|
122
|
+
}
|
|
103
123
|
try {
|
|
104
124
|
nativeRegistrations.push(
|
|
105
125
|
await ctx.skill.transform((editor) => {
|
|
@@ -108,7 +128,7 @@ async function setup(ctx: Plugin.Context): Promise<() => Promise<void>> {
|
|
|
108
128
|
id: FREE_PI_SKILL_ID,
|
|
109
129
|
name: FREE_PI_SKILL_NAME,
|
|
110
130
|
description: FREE_PI_SKILL_DESCRIPTION,
|
|
111
|
-
path:
|
|
131
|
+
path: freePiSkillPath(openCodeConfigDir()),
|
|
112
132
|
content: FREE_PI_SKILL,
|
|
113
133
|
} as any);
|
|
114
134
|
}),
|