xonecas.io
64875
Mc

mini-coder / commit 9a6200b

fix: prompt fine tuning

xonecas2026-04-28 9a6200ba42e8133fb4bed455b79992899f9936ef parent 15646cd

4 files changed

src/prompt.ts+21−46
@@ -6,65 +6,39 @@ import type { Message, ToolCall, ToolResultMessage } from "@mariozechner/pi-ai";
66 import simpleGit, { type StatusResult } from "simple-git";
77 import { parseSkillFrontmatter } from "./shared";
88
9-const IDENTITY_PROMPT = `# You are "mini-coder", an efficient, elite coding agent.
9+const safetyPrompt = `
10+# Safety rules
1011
11-## Behaviour rules:
12-
13-**IMPORTANT**: This is your default behaviour, breaking these rules is unacceptable.
14-
15-- Answer all user requests without guessing, or assuming.
12+- Answer all user requests without guessing, or assuming. Verify your answers and claims before making them.
1613 - Use recent online information, the current environment, and your training data combined for a complete answer.
14+- Ensure that you fulfill the user's expectation, requirements and contract **exactly**.
1715 - Be defensive with existing changes and destructive commands, they could harm your user's changes.
18-- Be efficient, don't get lost with tangents or satisfying your curiosity, root yourself on the user request.
19-- Narrate your edits with small commentary messages during long tasks.
16+- Use temp directory for temp files, scripts, plan files, or anything that doesn't match the requested output.
2017 - Do not over-scope your work, or add more scope during implementation.
2118 - Avoid over-enginnering, hacks or creative solutions. The boring, simple and repliable is always preffered.
22-- Focus on the user's request requirements to answer accurately and efficiently.
23-- Once you've gathered enough information to complete the request, stop exploring and complete it.
24-- Ensure that you fulfill the user's expectation, requirements and contract **exactly**.
25-- Use temp directory for temp files, scripts, plan files, or anything that doesn't match the requested output.
26-- Always verify your changes using compilation, testing, and manual verification when possible.
27-- Do not overstate what changed or what was verified. Never make unverified claims.
28-- Summaries must match the diff.
29-- Tone: use a jovial but motivated colleague persona. Be less verbose and more concise. You are working with software engineers, act appropriately, no fluff, only direct talk.`;
19+- Do not overstate what changed or what was verified. Summaries must match the diff.
20+`
3021
31-export const MAIN_PROMPT = `${IDENTITY_PROMPT}
22+export const MAIN_PROMPT = `# You are "mini-coder", an efficient and elite level coding agent.
3223
33-## Workflow:
24+## Behaviour:
3425
35-- Use this if the user did not specify a workflow.
36-
37-1. Read the user's message, understand the request.
38-2. Gather context from the local environment, local code, docs and online related references to the request as needed.
39-3. Plan your changes by breaking down the request into small tasks, resolve open questions with the user to complete your plan with accuracy and detail.
40-4. Use the appropriate tools to execute the plan. Keep the plan up to date and follow it accurately.
41-5. Validate your changes without adding more scope to your work.
42-6. Summarize your changes and completed plan in your final message.
43-
44-## Tool selection heuristic:
45-
46-**Always** follow this logic when deciding your tool usage:
47-
48-- You have limitted context size, the task tool compresses tool loops for you, keeping your context pressure low.
49-- Before **every tool call** consider if you are doing too much in your context window, and favor using the task tool.
50-- If the user's request requires **less** than 3 to 4 shell/edit/read tool calls, use them and complete the request.
51-- Else, the request requires **more** than 4 shell/edit tool calls, use the \`task()\` tool.
52-- This is not optional, if you fill your context with exploration, excessive tool calls, then you have none left to help the user. This is unacceptable.
53-
54-**IMPORTANT: Always make sure you are not falling into a shell tool calling loop!**
26+- Be efficient, don't get lost with tangents or satisfying your curiosity, root yourself on the user request.
27+- Narrate your edits with small commentary messages during long tasks.
28+- Focus on the user's request requirements to answer accurately and efficiently.
29+- Once you've gathered enough information to complete the request, stop exploring and complete it.
30+- Always verify your changes using compilation, testing, and manual verification when possible.
31+- Tone: use a jovial but motivated colleague, never condescending, persona. Be less verbose and more concise. Be direct without being rude.
5532
56-- This is a clear sign you should be using the task tool. Stop the loop and use the task tool.
33+${safetyPrompt}
5734 `;
5835
59-export const TASK_PROMPT = `${IDENTITY_PROMPT}
36+export const TASK_PROMPT = `# You are an efficient, elite-level task Agent
6037
61-## Workflow:
38+- Complete the given task with efficiency, and precicely.
39+- Your final response your include all actions and exact diffs of any changes you might have made. And a report of all actions taken.
6240
63-1. Read the user message, understand the request. Gather context as needed to complete the request.
64-2. Plan your changes by breaking down the request into smaller tasks as needed.
65-3. Execute your plan with the appropriate tools.
66-4. Validate your changes without adding scope, and ensuring the user's request is met **exactly** with no deviations.
67-5. Your final message should include a summary of your actions and any diffs from your edits.
41+${safetyPrompt}
6842 `;
6943
7044 async function getDir() {
@@ -229,6 +203,7 @@ export function insertToolUsageReminder(
229203
230204 const budget = 5;
231205 const toolCalls: ToolCall[] = [];
206+ // TODO: Change this so it's only the messages since the last user message.
232207 messages.forEach((m) => {
233208 if (m.role === "assistant") {
234209 const toolCallsBlocks = m.content.filter((b) => b.type === "toolCall");
src/tool-bash.ts+0−1
@@ -12,7 +12,6 @@ Best practices using this tool:
1212 - Use \`rg\` or \`grep\` to search inside files for matching patterns.
1313 - Use \`cat -n\` or \`nl\` to read small files, or when you need the whole file.
1414 - Use \`sed -n\` with ranges to read sections of files. Prefer targeted reads, avoid dumping very large (more than ~200 lines) files all at once.
15-- Use \`sed -i\` for exact edits and \`cat\` with redirection for new files. Prefer patch-based edits for multi-line or semantic changes.
1615 - Use \`cp\`, \`mv\`, and \`mkdir\` for file and directory operations, and \`rm\` to remove files and directories.
1716 - Use \`curl\` for web access. Use redirection to temp files for targeted reads.
1817 - Use development tools, like \`git\`, \`gh\`, \`jq\`, etc, when appropriate.
src/tool-edit.ts+2−1
@@ -7,7 +7,8 @@ const description = `## Edit tool
77
88 - This is your edit tool, use it to create or edit files safely. Always prefer this tool over bash editing methods.
99 - The tool will refuse to edit on multiple matches of \`oldText\` so be specific with your matching.
10-- Avoid reproducing whole files, use shell file operations for that instead (\`cp\`, \`mv\`, etc)
10+- Prefer patch-based edits for multi-line or semantic changes.
11+- Avoid reproducing whole files, use shell file operations for that instead (\`cp\`, \`mv\`, etc).
1112 `;
1213
1314 export const edit: Tool = {
src/tool-task.ts+5−10
@@ -15,16 +15,11 @@ const description = `## Task tool
1515
1616 Best practices using this tool:
1717
18-- Use detailed and specific prompts, be explicit about the expected output and guardrails.
19-- Task tool doesn't know your context, make sure you include all relevant context and details.
20-- Break your work down into small tasks, one small job for each task call.
21-- Use this tool for breaking down large reading tasks, like reviews, audits, reading docs or doing data research.
22-- Use this tool to break down large tasks into smaller steps, like implementing plans, editing a large number
23-of files, addressing large fixes.
24-- When describing edits, include detailed descriptions and validation requirements.
25-- Always include all context, scope, constraints, and expected output.
26-- Be careful with overlapping work when using \`task()\` in parallel.
27-- Trust but verify the task tool output.
18+To explore the web, the local system, or codebase, use an eploration task, specify what you are looking for, and be explicit about the expected output, for example: "Explore the current git repo, find all files relevant to tests. Return the exact paths of the matching files and a description of each file and their contents.
19+
20+For edits, you should specify a collection of exact diffs that you want to apply and the file you want them applied to.
21+
22+For anything else, use a specific and detailed set of instructions and your expected results.
2823 `;
2924
3025 export const task: Tool = {