@oh-my-pi/pi-coding-agent 4.0.1 → 4.2.0
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/CHANGELOG.md +49 -0
- package/README.md +2 -1
- package/docs/sdk.md +0 -3
- package/package.json +6 -5
- package/src/config.ts +9 -0
- package/src/core/agent-storage.ts +450 -0
- package/src/core/auth-storage.ts +111 -184
- package/src/core/compaction/branch-summarization.ts +5 -4
- package/src/core/compaction/compaction.ts +7 -6
- package/src/core/compaction/utils.ts +6 -11
- package/src/core/custom-commands/bundled/review/index.ts +22 -94
- package/src/core/custom-share.ts +66 -0
- package/src/core/history-storage.ts +174 -0
- package/src/core/index.ts +1 -0
- package/src/core/keybindings.ts +3 -0
- package/src/core/prompt-templates.ts +271 -1
- package/src/core/sdk.ts +14 -3
- package/src/core/settings-manager.ts +100 -34
- package/src/core/slash-commands.ts +4 -1
- package/src/core/storage-migration.ts +215 -0
- package/src/core/system-prompt.ts +87 -289
- package/src/core/title-generator.ts +3 -2
- package/src/core/tools/ask.ts +2 -2
- package/src/core/tools/bash.ts +2 -1
- package/src/core/tools/calculator.ts +2 -1
- package/src/core/tools/edit.ts +2 -1
- package/src/core/tools/find.ts +2 -1
- package/src/core/tools/gemini-image.ts +2 -1
- package/src/core/tools/git.ts +2 -2
- package/src/core/tools/grep.ts +2 -1
- package/src/core/tools/index.test.ts +0 -28
- package/src/core/tools/index.ts +0 -6
- package/src/core/tools/lsp/index.ts +2 -1
- package/src/core/tools/output.ts +2 -1
- package/src/core/tools/read.ts +4 -1
- package/src/core/tools/ssh.ts +4 -2
- package/src/core/tools/task/agents.ts +56 -30
- package/src/core/tools/task/commands.ts +9 -8
- package/src/core/tools/task/index.ts +7 -15
- package/src/core/tools/web-fetch.ts +2 -1
- package/src/core/tools/web-search/auth.ts +106 -16
- package/src/core/tools/web-search/index.ts +3 -2
- package/src/core/tools/web-search/providers/anthropic.ts +44 -6
- package/src/core/tools/write.ts +2 -1
- package/src/core/voice.ts +3 -1
- package/src/main.ts +1 -1
- package/src/migrations.ts +20 -20
- package/src/modes/interactive/components/custom-editor.ts +7 -0
- package/src/modes/interactive/components/history-search.ts +158 -0
- package/src/modes/interactive/controllers/command-controller.ts +527 -0
- package/src/modes/interactive/controllers/event-controller.ts +340 -0
- package/src/modes/interactive/controllers/extension-ui-controller.ts +600 -0
- package/src/modes/interactive/controllers/input-controller.ts +585 -0
- package/src/modes/interactive/controllers/selector-controller.ts +585 -0
- package/src/modes/interactive/interactive-mode.ts +370 -3115
- package/src/modes/interactive/theme/theme.ts +5 -5
- package/src/modes/interactive/types.ts +189 -0
- package/src/modes/interactive/utils/ui-helpers.ts +449 -0
- package/src/modes/interactive/utils/voice-manager.ts +96 -0
- package/src/prompts/{explore.md → agents/explore.md} +7 -5
- package/src/prompts/agents/frontmatter.md +7 -0
- package/src/prompts/{plan.md → agents/plan.md} +3 -3
- package/src/prompts/{task.md → agents/task.md} +1 -1
- package/src/prompts/review-request.md +44 -8
- package/src/prompts/system/custom-system-prompt.md +80 -0
- package/src/prompts/system/file-operations.md +12 -0
- package/src/prompts/system/system-prompt.md +232 -0
- package/src/prompts/system/title-system.md +2 -0
- package/src/prompts/tools/bash.md +1 -1
- package/src/prompts/tools/read.md +1 -1
- package/src/prompts/tools/task.md +9 -3
- package/src/core/tools/rulebook.ts +0 -132
- package/src/prompts/system-prompt.md +0 -43
- package/src/prompts/title-system.md +0 -8
- /package/src/prompts/{architect-plan.md → agents/architect-plan.md} +0 -0
- /package/src/prompts/{implement-with-critic.md → agents/implement-with-critic.md} +0 -0
- /package/src/prompts/{implement.md → agents/implement.md} +0 -0
- /package/src/prompts/{init.md → agents/init.md} +0 -0
- /package/src/prompts/{reviewer.md → agents/reviewer.md} +0 -0
- /package/src/prompts/{branch-summary-preamble.md → compaction/branch-summary-preamble.md} +0 -0
- /package/src/prompts/{branch-summary.md → compaction/branch-summary.md} +0 -0
- /package/src/prompts/{compaction-summary.md → compaction/compaction-summary.md} +0 -0
- /package/src/prompts/{compaction-turn-prefix.md → compaction/compaction-turn-prefix.md} +0 -0
- /package/src/prompts/{compaction-update-summary.md → compaction/compaction-update-summary.md} +0 -0
- /package/src/prompts/{summarization-system.md → system/summarization-system.md} +0 -0
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rulebook Tool
|
|
3
|
-
*
|
|
4
|
-
* Allows the agent to fetch full content of rules that have descriptions.
|
|
5
|
-
* Rules are listed in the system prompt with name + description; this tool
|
|
6
|
-
* retrieves the complete rule content on demand.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { AgentTool } from "@oh-my-pi/pi-agent-core";
|
|
10
|
-
import { Type } from "@sinclair/typebox";
|
|
11
|
-
import type { Rule } from "../../capability/rule";
|
|
12
|
-
import type { ToolSession } from "./index";
|
|
13
|
-
|
|
14
|
-
export interface RulebookToolDetails {
|
|
15
|
-
type: "rulebook";
|
|
16
|
-
ruleName: string;
|
|
17
|
-
found: boolean;
|
|
18
|
-
content?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const rulebookSchema = Type.Object({
|
|
22
|
-
name: Type.String({ description: "The name of the rule to fetch" }),
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Create a rulebook tool with access to discovered rules.
|
|
27
|
-
* Returns null if no rules available.
|
|
28
|
-
*/
|
|
29
|
-
export function createRulebookTool(session: ToolSession): AgentTool<typeof rulebookSchema> | null {
|
|
30
|
-
const rules = session.rulebookRules;
|
|
31
|
-
if (!rules || rules.length === 0) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Build lookup map for O(1) access
|
|
36
|
-
const ruleMap = new Map<string, Rule>();
|
|
37
|
-
for (const rule of rules) {
|
|
38
|
-
ruleMap.set(rule.name, rule);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const ruleNames = rules.map((r) => r.name);
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
name: "rulebook",
|
|
45
|
-
label: "Rulebook",
|
|
46
|
-
description: `Fetch the full content of a project rule by name. Use this when a rule listed in <available_rules> is relevant to your current task. Available: ${
|
|
47
|
-
ruleNames.join(", ") || "(none)"
|
|
48
|
-
}`,
|
|
49
|
-
parameters: rulebookSchema,
|
|
50
|
-
execute: async (_toolCallId: string, { name }: { name: string }) => {
|
|
51
|
-
const rule = ruleMap.get(name);
|
|
52
|
-
|
|
53
|
-
if (!rule) {
|
|
54
|
-
const available = ruleNames.join(", ");
|
|
55
|
-
return {
|
|
56
|
-
content: [{ type: "text", text: `Rule "${name}" not found. Available rules: ${available || "(none)"}` }],
|
|
57
|
-
details: {
|
|
58
|
-
type: "rulebook",
|
|
59
|
-
ruleName: name,
|
|
60
|
-
found: false,
|
|
61
|
-
} satisfies RulebookToolDetails,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
content: [{ type: "text", text: `# Rule: ${rule.name}\n\n${rule.content}` }],
|
|
67
|
-
details: {
|
|
68
|
-
type: "rulebook",
|
|
69
|
-
ruleName: name,
|
|
70
|
-
found: true,
|
|
71
|
-
content: rule.content,
|
|
72
|
-
} satisfies RulebookToolDetails,
|
|
73
|
-
};
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Filter rules to only those suitable for the rulebook (have descriptions, no TTSR trigger).
|
|
80
|
-
*/
|
|
81
|
-
export function filterRulebookRules(rules: Rule[]): Rule[] {
|
|
82
|
-
return rules.filter((rule) => {
|
|
83
|
-
// Exclude TTSR rules (handled separately by streaming)
|
|
84
|
-
if (rule.ttsrTrigger) return false;
|
|
85
|
-
// Exclude always-apply rules (already in context)
|
|
86
|
-
if (rule.alwaysApply) return false;
|
|
87
|
-
// Must have a description for agent to know when to fetch
|
|
88
|
-
if (!rule.description) return false;
|
|
89
|
-
return true;
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Format rules for inclusion in the system prompt.
|
|
95
|
-
* Lists rule names and descriptions so the agent knows what's available.
|
|
96
|
-
*/
|
|
97
|
-
export function formatRulesForPrompt(rules: Rule[]): string {
|
|
98
|
-
if (rules.length === 0) {
|
|
99
|
-
return "";
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const lines = [
|
|
103
|
-
"\n\n## Available Rules",
|
|
104
|
-
"",
|
|
105
|
-
"The following project rules are available. Use the `rulebook` tool to fetch a rule's full content when it's relevant to your task.",
|
|
106
|
-
"",
|
|
107
|
-
"<available_rules>",
|
|
108
|
-
];
|
|
109
|
-
|
|
110
|
-
for (const rule of rules) {
|
|
111
|
-
lines.push(" <rule>");
|
|
112
|
-
lines.push(` <name>${escapeXml(rule.name)}</name>`);
|
|
113
|
-
lines.push(` <description>${escapeXml(rule.description || "")}</description>`);
|
|
114
|
-
if (rule.globs && rule.globs.length > 0) {
|
|
115
|
-
lines.push(` <globs>${escapeXml(rule.globs.join(", "))}</globs>`);
|
|
116
|
-
}
|
|
117
|
-
lines.push(" </rule>");
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
lines.push("</available_rules>");
|
|
121
|
-
|
|
122
|
-
return lines.join("\n");
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function escapeXml(str: string): string {
|
|
126
|
-
return str
|
|
127
|
-
.replace(/&/g, "&")
|
|
128
|
-
.replace(/</g, "<")
|
|
129
|
-
.replace(/>/g, ">")
|
|
130
|
-
.replace(/"/g, """)
|
|
131
|
-
.replace(/'/g, "'");
|
|
132
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
You are a senior software engineer with deep expertise in debugging, refactoring, and system design. You read files, execute commands, edit code, and write new files to complete coding tasks.
|
|
2
|
-
|
|
3
|
-
<critical>
|
|
4
|
-
Keep working until the user's task is fully resolved. Use tools to verify—never guess.
|
|
5
|
-
</critical>
|
|
6
|
-
|
|
7
|
-
<environment>
|
|
8
|
-
{{environmentInfo}}
|
|
9
|
-
</environment>
|
|
10
|
-
|
|
11
|
-
<tools>
|
|
12
|
-
{{toolsList}}
|
|
13
|
-
</tools>
|
|
14
|
-
{{antiBashSection}}
|
|
15
|
-
<guidelines>
|
|
16
|
-
{{guidelines}}
|
|
17
|
-
</guidelines>
|
|
18
|
-
|
|
19
|
-
<instructions>
|
|
20
|
-
## Execution
|
|
21
|
-
- Before each tool call, state the action in one sentence.
|
|
22
|
-
- After each result, verify relevance; iterate if results conflict or are insufficient.
|
|
23
|
-
- Plan multi-step work with update_plan when available; skip for simple tasks.
|
|
24
|
-
- On sandbox/permission failures, request approval and retry.
|
|
25
|
-
|
|
26
|
-
## Verification
|
|
27
|
-
- Ground answers with tools when deterministic info is needed.
|
|
28
|
-
- Ask for missing parameters instead of assuming.
|
|
29
|
-
- Follow project testing guidance; suggest validation if not run.
|
|
30
|
-
|
|
31
|
-
## Communication
|
|
32
|
-
- Concise, scannable responses; file paths in backticks.
|
|
33
|
-
- Brief progress updates on long tasks; heads-up before large changes.
|
|
34
|
-
- Short bullets for lists; avoid dumping large files.
|
|
35
|
-
|
|
36
|
-
## Project Integration
|
|
37
|
-
- Follow AGENTS.md by scope: nearest file applies, deeper overrides higher.
|
|
38
|
-
- Resolve blockers before yielding.
|
|
39
|
-
</instructions>
|
|
40
|
-
|
|
41
|
-
<critical>
|
|
42
|
-
Complete the full user request before ending your turn. This matters.
|
|
43
|
-
</critical>
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
Generate a very short title (3-6 words) for a coding session based on the user's first message. The title should capture the main task or topic. Output ONLY the title, nothing else. No quotes, no punctuation at the end.
|
|
2
|
-
|
|
3
|
-
Examples:
|
|
4
|
-
- "Fix TypeScript compilation errors"
|
|
5
|
-
- "Add user authentication"
|
|
6
|
-
- "Refactor database queries"
|
|
7
|
-
- "Debug payment webhook"
|
|
8
|
-
- "Update React components"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/prompts/{compaction-update-summary.md → compaction/compaction-update-summary.md}
RENAMED
|
File without changes
|
|
File without changes
|