mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 03:04:28 +00:00
feat(coding-agent): add --no-tools flag to disable built-in tools
Add --no-tools flag that allows starting pi without any built-in tools, enabling extension-only tool setups (e.g., pi-ssh-remote). - Add --no-tools flag to CLI args parsing - Handle --tools '' (empty string) as equivalent to no tools - Fix system prompt to not show READ-ONLY mode when no tools (extensions may provide write capabilities) - Add tests for new flag and system prompt behavior fixes #555
This commit is contained in:
parent
cfa63c255d
commit
8f5523ed56
6 changed files with 123 additions and 15 deletions
|
|
@ -170,6 +170,24 @@ describe("parseArgs", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("--no-tools flag", () => {
|
||||
test("parses --no-tools flag", () => {
|
||||
const result = parseArgs(["--no-tools"]);
|
||||
expect(result.noTools).toBe(true);
|
||||
});
|
||||
|
||||
test("parses --no-tools with explicit --tools flags", () => {
|
||||
const result = parseArgs(["--no-tools", "--tools", "read,bash"]);
|
||||
expect(result.noTools).toBe(true);
|
||||
expect(result.tools).toEqual(["read", "bash"]);
|
||||
});
|
||||
|
||||
test("parses --tools with empty string", () => {
|
||||
const result = parseArgs(["--tools", ""]);
|
||||
expect(result.tools).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("messages and file args", () => {
|
||||
test("parses plain text messages", () => {
|
||||
const result = parseArgs(["hello", "world"]);
|
||||
|
|
|
|||
65
packages/coding-agent/test/system-prompt.test.ts
Normal file
65
packages/coding-agent/test/system-prompt.test.ts
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
import { describe, expect, test } from "vitest";
|
||||
import { buildSystemPrompt } from "../src/core/system-prompt.js";
|
||||
|
||||
describe("buildSystemPrompt", () => {
|
||||
describe("empty tools", () => {
|
||||
test("does not show READ-ONLY mode when no built-in tools", () => {
|
||||
const prompt = buildSystemPrompt({
|
||||
selectedTools: [],
|
||||
contextFiles: [],
|
||||
skills: [],
|
||||
});
|
||||
|
||||
// Should not mention READ-ONLY mode when there are no tools
|
||||
// (extensions may provide write capabilities)
|
||||
expect(prompt).not.toContain("READ-ONLY mode");
|
||||
});
|
||||
|
||||
test("shows (none) for empty tools list", () => {
|
||||
const prompt = buildSystemPrompt({
|
||||
selectedTools: [],
|
||||
contextFiles: [],
|
||||
skills: [],
|
||||
});
|
||||
|
||||
expect(prompt).toContain("Available tools:\n(none)");
|
||||
});
|
||||
|
||||
test("does not show file paths guideline when no tools", () => {
|
||||
const prompt = buildSystemPrompt({
|
||||
selectedTools: [],
|
||||
contextFiles: [],
|
||||
skills: [],
|
||||
});
|
||||
|
||||
expect(prompt).not.toContain("Show file paths clearly");
|
||||
});
|
||||
});
|
||||
|
||||
describe("read-only tools", () => {
|
||||
test("shows READ-ONLY mode when only read tools available", () => {
|
||||
const prompt = buildSystemPrompt({
|
||||
selectedTools: ["read", "grep", "find", "ls"],
|
||||
contextFiles: [],
|
||||
skills: [],
|
||||
});
|
||||
|
||||
expect(prompt).toContain("READ-ONLY mode");
|
||||
});
|
||||
});
|
||||
|
||||
describe("default tools", () => {
|
||||
test("does not show READ-ONLY mode with default tools", () => {
|
||||
const prompt = buildSystemPrompt({
|
||||
contextFiles: [],
|
||||
skills: [],
|
||||
});
|
||||
|
||||
expect(prompt).not.toContain("READ-ONLY mode");
|
||||
expect(prompt).toContain("- read:");
|
||||
expect(prompt).toContain("- bash:");
|
||||
expect(prompt).toContain("- edit:");
|
||||
expect(prompt).toContain("- write:");
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue