@oh-my-pi/pi-coding-agent 13.11.1 → 13.12.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 +58 -0
- package/package.json +7 -7
- package/src/capability/rule.ts +4 -0
- package/src/cli/commands/init-xdg.ts +27 -0
- package/src/cli/config-cli.ts +8 -3
- package/src/cli/shell-cli.ts +1 -1
- package/src/commands/config.ts +1 -1
- package/src/config/model-registry.ts +63 -10
- package/src/config/model-resolver.ts +84 -21
- package/src/config/settings-schema.ts +803 -637
- package/src/discovery/helpers.ts +8 -2
- package/src/exec/bash-executor.ts +62 -25
- package/src/extensibility/custom-tools/types.ts +2 -3
- package/src/extensibility/extensions/types.ts +2 -0
- package/src/extensibility/hooks/types.ts +2 -0
- package/src/index.ts +6 -6
- package/src/internal-urls/docs-index.generated.ts +2 -2
- package/src/memories/index.ts +20 -7
- package/src/memories/storage.ts +46 -32
- package/src/modes/components/agent-dashboard.ts +23 -35
- package/src/modes/components/assistant-message.ts +25 -2
- package/src/modes/components/btw-panel.ts +104 -0
- package/src/modes/components/settings-defs.ts +1 -1
- package/src/modes/components/settings-selector.ts +6 -6
- package/src/modes/controllers/btw-controller.ts +193 -0
- package/src/modes/controllers/command-controller.ts +1 -1
- package/src/modes/controllers/event-controller.ts +4 -0
- package/src/modes/controllers/input-controller.ts +10 -1
- package/src/modes/interactive-mode.ts +22 -0
- package/src/modes/prompt-action-autocomplete.ts +17 -3
- package/src/modes/rpc/rpc-client.ts +30 -19
- package/src/modes/theme/theme.ts +28 -36
- package/src/modes/types.ts +4 -0
- package/src/modes/utils/ui-helpers.ts +3 -0
- package/src/prompts/system/btw-user.md +8 -0
- package/src/prompts/system/custom-system-prompt.md +1 -1
- package/src/prompts/system/system-prompt.md +1 -0
- package/src/sdk.ts +17 -25
- package/src/session/agent-session.ts +65 -37
- package/src/session/blob-store.ts +32 -0
- package/src/session/compaction/compaction.ts +27 -6
- package/src/session/history-storage.ts +2 -2
- package/src/session/session-manager.ts +116 -44
- package/src/slash-commands/builtin-registry.ts +11 -0
- package/src/system-prompt.ts +4 -17
- package/src/task/agents.ts +1 -1
- package/src/task/index.ts +9 -8
- package/src/tools/browser.ts +11 -0
- package/src/tools/output-meta.ts +96 -3
- package/src/utils/title-generator.ts +70 -92
- package/src/utils/tools-manager.ts +1 -1
- package/src/web/scrapers/index.ts +7 -7
- package/src/web/scrapers/utils.ts +1 -0
|
@@ -9,7 +9,6 @@ import type { ModelRegistry } from "../config/model-registry";
|
|
|
9
9
|
import { resolveModelRoleValue } from "../config/model-resolver";
|
|
10
10
|
import { renderPromptTemplate } from "../config/prompt-templates";
|
|
11
11
|
import type { Settings } from "../config/settings";
|
|
12
|
-
import MODEL_PRIO from "../priority.json" with { type: "json" };
|
|
13
12
|
import titleSystemPrompt from "../prompts/system/title-system.md" with { type: "text" };
|
|
14
13
|
import { toReasoningEffort } from "../thinking";
|
|
15
14
|
|
|
@@ -17,45 +16,28 @@ const TITLE_SYSTEM_PROMPT = renderPromptTemplate(titleSystemPrompt);
|
|
|
17
16
|
|
|
18
17
|
const MAX_INPUT_CHARS = 2000;
|
|
19
18
|
|
|
20
|
-
function
|
|
19
|
+
function getTitleModel(
|
|
21
20
|
registry: ModelRegistry,
|
|
22
21
|
settings: Settings,
|
|
23
|
-
|
|
22
|
+
currentModel?: Model<Api>,
|
|
23
|
+
): { model: Model<Api>; thinkingLevel?: ThinkingLevel } | undefined {
|
|
24
24
|
const availableModels = registry.getAvailable();
|
|
25
|
-
if (availableModels.length === 0) return
|
|
26
|
-
|
|
27
|
-
const candidates: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }> = [];
|
|
28
|
-
const addCandidate = (model?: Model<Api>, thinkingLevel?: ThinkingLevel): void => {
|
|
29
|
-
if (!model) return;
|
|
30
|
-
const exists = candidates.some(
|
|
31
|
-
candidate => candidate.model.provider === model.provider && candidate.model.id === model.id,
|
|
32
|
-
);
|
|
33
|
-
if (!exists) {
|
|
34
|
-
candidates.push({ model, thinkingLevel });
|
|
35
|
-
}
|
|
36
|
-
};
|
|
25
|
+
if (availableModels.length === 0) return undefined;
|
|
37
26
|
|
|
38
27
|
const matchPreferences = { usageOrder: settings.getStorage()?.getModelUsageOrder() };
|
|
39
28
|
const configuredSmol = resolveModelRoleValue(settings.getModelRole("smol"), availableModels, {
|
|
40
29
|
settings,
|
|
41
30
|
matchPreferences,
|
|
42
31
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
for (const pattern of MODEL_PRIO.smol) {
|
|
46
|
-
const needle = pattern.toLowerCase();
|
|
47
|
-
const exactMatch = availableModels.find(model => model.id.toLowerCase() === needle);
|
|
48
|
-
addCandidate(exactMatch);
|
|
49
|
-
|
|
50
|
-
const fuzzyMatch = availableModels.find(model => model.id.toLowerCase().includes(needle));
|
|
51
|
-
addCandidate(fuzzyMatch);
|
|
32
|
+
if (configuredSmol.model) {
|
|
33
|
+
return { model: configuredSmol.model, thinkingLevel: configuredSmol.thinkingLevel };
|
|
52
34
|
}
|
|
53
35
|
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
if (currentModel) {
|
|
37
|
+
return { model: currentModel };
|
|
56
38
|
}
|
|
57
39
|
|
|
58
|
-
return
|
|
40
|
+
return undefined;
|
|
59
41
|
}
|
|
60
42
|
|
|
61
43
|
/**
|
|
@@ -71,10 +53,11 @@ export async function generateSessionTitle(
|
|
|
71
53
|
registry: ModelRegistry,
|
|
72
54
|
settings: Settings,
|
|
73
55
|
sessionId?: string,
|
|
56
|
+
currentModel?: Model<Api>,
|
|
74
57
|
): Promise<string | null> {
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
logger.debug("title-generator: no
|
|
58
|
+
const candidate = getTitleModel(registry, settings, currentModel);
|
|
59
|
+
if (!candidate) {
|
|
60
|
+
logger.debug("title-generator: no title model found");
|
|
78
61
|
return null;
|
|
79
62
|
}
|
|
80
63
|
|
|
@@ -85,78 +68,73 @@ export async function generateSessionTitle(
|
|
|
85
68
|
${truncatedMessage}
|
|
86
69
|
</user-message>`;
|
|
87
70
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const request = {
|
|
99
|
-
model: `${candidate.model.provider}/${candidate.model.id}`,
|
|
100
|
-
systemPrompt: TITLE_SYSTEM_PROMPT,
|
|
101
|
-
userMessage,
|
|
102
|
-
maxTokens: 30,
|
|
103
|
-
};
|
|
104
|
-
logger.debug("title-generator: request", request);
|
|
105
|
-
|
|
106
|
-
try {
|
|
107
|
-
const response = await completeSimple(
|
|
108
|
-
candidate.model,
|
|
109
|
-
{
|
|
110
|
-
systemPrompt: request.systemPrompt,
|
|
111
|
-
messages: [{ role: "user", content: request.userMessage, timestamp: Date.now() }],
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
apiKey,
|
|
115
|
-
maxTokens: 30,
|
|
116
|
-
reasoning: toReasoningEffort(candidate.thinkingLevel),
|
|
117
|
-
},
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
if (response.stopReason === "error") {
|
|
121
|
-
logger.debug("title-generator: response error", {
|
|
122
|
-
model: request.model,
|
|
123
|
-
stopReason: response.stopReason,
|
|
124
|
-
errorMessage: response.errorMessage,
|
|
125
|
-
});
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
71
|
+
const apiKey = await registry.getApiKey(candidate.model, sessionId);
|
|
72
|
+
if (!apiKey) {
|
|
73
|
+
logger.debug("title-generator: no API key for smol model", {
|
|
74
|
+
provider: candidate.model.provider,
|
|
75
|
+
id: candidate.model.id,
|
|
76
|
+
});
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
128
79
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
80
|
+
const request = {
|
|
81
|
+
model: `${candidate.model.provider}/${candidate.model.id}`,
|
|
82
|
+
systemPrompt: TITLE_SYSTEM_PROMPT,
|
|
83
|
+
userMessage,
|
|
84
|
+
maxTokens: 30,
|
|
85
|
+
};
|
|
86
|
+
logger.debug("title-generator: request", request);
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
const response = await completeSimple(
|
|
90
|
+
candidate.model,
|
|
91
|
+
{
|
|
92
|
+
systemPrompt: request.systemPrompt,
|
|
93
|
+
messages: [{ role: "user", content: request.userMessage, timestamp: Date.now() }],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
apiKey,
|
|
97
|
+
maxTokens: 30,
|
|
98
|
+
reasoning: toReasoningEffort(candidate.thinkingLevel),
|
|
99
|
+
},
|
|
100
|
+
);
|
|
137
101
|
|
|
138
|
-
|
|
102
|
+
if (response.stopReason === "error") {
|
|
103
|
+
logger.debug("title-generator: response error", {
|
|
139
104
|
model: request.model,
|
|
140
|
-
title,
|
|
141
|
-
usage: response.usage,
|
|
142
105
|
stopReason: response.stopReason,
|
|
106
|
+
errorMessage: response.errorMessage,
|
|
143
107
|
});
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
144
110
|
|
|
145
|
-
|
|
146
|
-
|
|
111
|
+
let title = "";
|
|
112
|
+
for (const content of response.content) {
|
|
113
|
+
if (content.type === "text") {
|
|
114
|
+
title += content.text;
|
|
147
115
|
}
|
|
116
|
+
}
|
|
117
|
+
title = title.trim();
|
|
148
118
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
119
|
+
logger.debug("title-generator: response", {
|
|
120
|
+
model: request.model,
|
|
121
|
+
title,
|
|
122
|
+
usage: response.usage,
|
|
123
|
+
stopReason: response.stopReason,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
if (!title) {
|
|
127
|
+
return null;
|
|
156
128
|
}
|
|
157
|
-
}
|
|
158
129
|
|
|
159
|
-
|
|
130
|
+
return title.replace(/^["']|["']$/g, "").replace(/[.!?]$/, "");
|
|
131
|
+
} catch (err) {
|
|
132
|
+
logger.debug("title-generator: error", {
|
|
133
|
+
model: request.model,
|
|
134
|
+
error: err instanceof Error ? err.message : String(err),
|
|
135
|
+
});
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
160
138
|
}
|
|
161
139
|
|
|
162
140
|
/**
|
|
@@ -4,7 +4,7 @@ import * as path from "node:path";
|
|
|
4
4
|
import { APP_NAME, getToolsDir, logger, ptree, TempDir } from "@oh-my-pi/pi-utils";
|
|
5
5
|
|
|
6
6
|
const TOOLS_DIR = getToolsDir();
|
|
7
|
-
const TOOL_DOWNLOAD_TIMEOUT_MS =
|
|
7
|
+
const TOOL_DOWNLOAD_TIMEOUT_MS = 120_000;
|
|
8
8
|
const TOOL_METADATA_TIMEOUT_MS = 5000;
|
|
9
9
|
|
|
10
10
|
interface ToolConfig {
|
|
@@ -85,17 +85,16 @@ export type { RenderResult, SpecialHandler } from "./types";
|
|
|
85
85
|
export {
|
|
86
86
|
fetchGitHubApi,
|
|
87
87
|
handleArtifactHub,
|
|
88
|
-
handleDocsRs,
|
|
89
88
|
handleArxiv,
|
|
90
89
|
handleAur,
|
|
91
90
|
handleBiorxiv,
|
|
92
91
|
handleBluesky,
|
|
93
92
|
handleBrew,
|
|
94
93
|
handleCheatSh,
|
|
95
|
-
handleCisaKev,
|
|
96
94
|
handleChocolatey,
|
|
97
|
-
handleClojars,
|
|
98
95
|
handleChooseALicense,
|
|
96
|
+
handleCisaKev,
|
|
97
|
+
handleClojars,
|
|
99
98
|
handleCoinGecko,
|
|
100
99
|
handleCratesIo,
|
|
101
100
|
handleCrossref,
|
|
@@ -103,9 +102,10 @@ export {
|
|
|
103
102
|
handleDiscogs,
|
|
104
103
|
handleDiscourse,
|
|
105
104
|
handleDockerHub,
|
|
105
|
+
handleDocsRs,
|
|
106
106
|
handleFdroid,
|
|
107
|
-
handleFlathub,
|
|
108
107
|
handleFirefoxAddons,
|
|
108
|
+
handleFlathub,
|
|
109
109
|
handleGitHub,
|
|
110
110
|
handleGitHubGist,
|
|
111
111
|
handleGitLab,
|
|
@@ -129,8 +129,8 @@ export {
|
|
|
129
129
|
handleOllama,
|
|
130
130
|
handleOpenCorporates,
|
|
131
131
|
handleOpenLibrary,
|
|
132
|
-
handleOrcid,
|
|
133
132
|
handleOpenVsx,
|
|
133
|
+
handleOrcid,
|
|
134
134
|
handleOsv,
|
|
135
135
|
handlePackagist,
|
|
136
136
|
handlePubDev,
|
|
@@ -142,13 +142,13 @@ export {
|
|
|
142
142
|
handleRepology,
|
|
143
143
|
handleRfc,
|
|
144
144
|
handleRubyGems,
|
|
145
|
-
handleSecEdgar,
|
|
146
145
|
handleSearchcode,
|
|
146
|
+
handleSecEdgar,
|
|
147
147
|
handleSemanticScholar,
|
|
148
148
|
handleSnapcraft,
|
|
149
149
|
handleSourcegraph,
|
|
150
|
-
handleSpotify,
|
|
151
150
|
handleSpdx,
|
|
151
|
+
handleSpotify,
|
|
152
152
|
handleStackOverflow,
|
|
153
153
|
handleTerraform,
|
|
154
154
|
handleTldr,
|