update Kate integration prompts

This commit is contained in:
Ollie Agent 2026-08-17 00:05:35 +02:00
parent a700b91002
commit 68616cb247
1 changed files with 12 additions and 11 deletions

View File

@ -439,7 +439,7 @@ void OllieKateView::askAboutFile()
ensureAgent();
if (m_agentId.isEmpty()) return;
QString prompt = "Describe and explain this file: " + filePath;
QString prompt = QStringLiteral("Read-only task. Inspect the complete file ") + filePath + QStringLiteral(" and describe it. Do not edit files. Report the file's purpose, main components, important data flow, dependencies, and relevant tests or checks. Do not guess details that are not present in the file or repository.\n\nFile: ") + filePath + QStringLiteral("\n\nGive a concise implementation-oriented overview.");
m_9p->write(agentPath() + "/prompt", prompt.toUtf8());
}
@ -459,8 +459,7 @@ void OllieKateView::explainSelection()
if (m_agentId.isEmpty()) return;
QString filePath = view->document()->url().toLocalFile();
QString context = filePath.isEmpty() ? "" : " (from " + filePath + ")";
QString prompt = "Explain this code" + context + ":\n\n```\n" + selection + "\n```";
QString prompt = QStringLiteral("Read-only task. Inspect the actual file ") + filePath + QStringLiteral(" and explain the selected code below. Do not edit files. Explain what it does, how it works, important inputs and outputs, and any risks or edge cases. The selection is the target, not necessarily the complete context.\n\nFile: ") + filePath + QStringLiteral("\nSelected code:\n\n") + selection + QStringLiteral("\n\nGive a concise explanation. Do not propose or apply a patch.");
m_9p->write(agentPath() + "/prompt", prompt.toUtf8());
}
@ -476,13 +475,16 @@ void OllieKateView::submitSelectionPrompt(const QString &action)
if (m_agentId.isEmpty()) return;
QString filePath = view->document()->url().toLocalFile();
auto cursor = view->selectionRange().start();
QString location;
if (!filePath.isEmpty()) {
location = " in `" + filePath + ":" + QString::number(cursor.line() + 1) + "`";
QString prompt;
if (action == QStringLiteral("Fix")) {
prompt = QStringLiteral("Edit the source file ") + filePath + QStringLiteral(".\n\nThe selected code below is the target. It may be incomplete context:\n\n") + selection + QStringLiteral("\n\nInstructions:\n- Read the actual file and relevant surrounding code before editing.\n- Find the concrete bug or problem in the selected code.\n- Make the smallest safe fix. Do not rewrite unrelated code.\n- Preserve intended behavior outside the fix.\n- Apply the fix directly to the file. Do not only describe a patch.\n- Run formatting and the most relevant tests or diagnostics if available.\n\nAfter editing, report the file changed, the problem fixed, and verification performed.");
} else if (action == QStringLiteral("Refactor")) {
prompt = QStringLiteral("Edit the source file ") + filePath + QStringLiteral(".\n\nThe selected code below is the target. It may be incomplete context:\n\n") + selection + QStringLiteral("\n\nInstructions:\n- Read the actual file and relevant surrounding code before editing.\n- Refactor the selected code without changing its external behavior.\n- Make one focused improvement. Do not rewrite unrelated code.\n- Follow the existing project style. Do not add unnecessary abstractions.\n- Apply the refactor directly to the file. Do not only describe a patch.\n- Run formatting and the most relevant tests or diagnostics if available.\n\nAfter editing, report the file changed, the refactor made, and verification performed.");
} else if (action == QStringLiteral("Write unit tests for")) {
prompt = QStringLiteral("Edit the source tree to add tests for the selected code in ") + filePath + QStringLiteral(".\n\nThe selected code below is the target. It may be incomplete context:\n\n") + selection + QStringLiteral("\n\nInstructions:\n- Read the actual source file, existing tests, and project test conventions first.\n- Add focused unit tests for normal behavior, important edge cases, and errors.\n- Do not change production code unless a test requires a minimal testability fix.\n- Do not rewrite or remove existing tests.\n- Apply the tests directly to the repository. Do not only describe test code.\n- Format the files and run the relevant tests.\n\nAfter editing, report the test files changed and the test command and result.");
} else {
prompt = QStringLiteral("Edit the source file ") + filePath + QStringLiteral(".\n\nThe selected code below is the target. It may be incomplete context:\n\n") + selection + QStringLiteral("\n\nInstructions:\n- Read the actual file and relevant surrounding code before editing.\n- Add documentation comments to the selected declarations.\n- Do not change executable code or unrelated code.\n- Match the language and existing project style.\n- Document behavior, parameters, return values, errors, and non-obvious edge cases.\n- Apply the edit directly to the file. Do not only describe a patch.\n- Run formatting or relevant checks if available.\n\nAfter editing, report the file changed and a one-sentence summary.");
}
QString prompt = action + " this code" + location + ":\n\n```\n" + selection + "\n```";
m_9p->write(agentPath() + "/prompt", prompt.toUtf8());
}
@ -539,8 +541,7 @@ void OllieKateView::reviewDiff()
ensureAgent();
if (m_agentId.isEmpty()) return;
QString prompt = QStringLiteral("Review this diff. Point out potential issues, bugs, "
"or improvements:\n\n```diff\n") + diff + QStringLiteral("\n```");
QString prompt = QStringLiteral("Read-only task. Review the following diff. Do not edit files. Identify correctness bugs, regressions, security issues, missing tests, and maintainability concerns. For each finding, explain the impact and cite the relevant hunk. If there are no findings, say so explicitly.\n\n```diff\n") + diff + QStringLiteral("\n```");
m_9p->write(agentPath() + "/prompt", prompt.toUtf8());
}