@oh-my-pi/pi-coding-agent 15.13.2 → 16.0.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 +62 -0
- package/dist/cli.js +587 -499
- package/dist/types/advisor/__tests__/advisor.test.d.ts +1 -0
- package/dist/types/advisor/advise-tool.d.ts +58 -0
- package/dist/types/advisor/index.d.ts +3 -0
- package/dist/types/advisor/runtime.d.ts +52 -0
- package/dist/types/advisor/watchdog.d.ts +5 -0
- package/dist/types/config/model-roles.d.ts +1 -1
- package/dist/types/config/settings-schema.d.ts +75 -5
- package/dist/types/eval/js/context-manager.d.ts +15 -0
- package/dist/types/modes/components/advisor-message.d.ts +9 -0
- package/dist/types/modes/components/assistant-message.d.ts +1 -0
- package/dist/types/modes/controllers/command-controller.d.ts +3 -1
- package/dist/types/modes/interactive-mode.d.ts +4 -1
- package/dist/types/modes/types.d.ts +9 -1
- package/dist/types/sdk.d.ts +3 -3
- package/dist/types/session/agent-session.d.ts +71 -2
- package/dist/types/session/session-history-format.d.ts +4 -0
- package/dist/types/session/unexpected-stop-classifier.d.ts +13 -0
- package/dist/types/session/yield-queue.d.ts +2 -0
- package/dist/types/stt/asr-client.d.ts +1 -1
- package/dist/types/tiny/title-client.d.ts +1 -1
- package/dist/types/tools/job.d.ts +1 -0
- package/dist/types/tools/path-utils.d.ts +1 -0
- package/dist/types/tools/report-tool-issue.d.ts +0 -1
- package/dist/types/tts/tts-client.d.ts +1 -1
- package/dist/types/utils/thinking-display.d.ts +1 -17
- package/package.json +13 -13
- package/src/advisor/__tests__/advisor.test.ts +586 -0
- package/src/advisor/advise-tool.ts +87 -0
- package/src/advisor/index.ts +3 -0
- package/src/advisor/runtime.ts +248 -0
- package/src/advisor/watchdog.ts +83 -0
- package/src/cli.ts +25 -12
- package/src/config/model-registry.ts +6 -2
- package/src/config/model-roles.ts +13 -1
- package/src/config/settings-schema.ts +67 -5
- package/src/eval/__tests__/agent-bridge.test.ts +106 -46
- package/src/eval/__tests__/js-context-manager.test.ts +12 -2
- package/src/eval/js/context-manager.ts +40 -3
- package/src/eval/js/worker-entry.ts +7 -0
- package/src/export/html/template.js +18 -22
- package/src/internal-urls/docs-index.generated.ts +8 -5
- package/src/main.ts +19 -5
- package/src/modes/acp/acp-agent.ts +2 -2
- package/src/modes/acp/acp-event-mapper.ts +2 -2
- package/src/modes/components/advisor-message.ts +99 -0
- package/src/modes/components/agent-hub.ts +38 -7
- package/src/modes/components/assistant-message.ts +110 -15
- package/src/modes/components/snapcompact-shape-preview-doc.md +2 -2
- package/src/modes/components/snapcompact-shape-preview.ts +2 -2
- package/src/modes/components/status-line/segments.ts +20 -7
- package/src/modes/components/tree-selector.ts +3 -2
- package/src/modes/controllers/command-controller.ts +69 -2
- package/src/modes/controllers/event-controller.ts +3 -3
- package/src/modes/controllers/input-controller.ts +7 -1
- package/src/modes/controllers/streaming-reveal.ts +4 -4
- package/src/modes/interactive-mode.ts +14 -2
- package/src/modes/types.ts +9 -1
- package/src/modes/utils/ui-helpers.ts +12 -3
- package/src/prompts/advisor/advise-tool.md +1 -0
- package/src/prompts/advisor/system.md +31 -0
- package/src/prompts/agents/oracle.md +0 -1
- package/src/prompts/agents/reviewer.md +0 -1
- package/src/prompts/system/unexpected-stop-classifier.md +17 -0
- package/src/prompts/system/unexpected-stop-retry.md +4 -0
- package/src/sdk.ts +52 -13
- package/src/session/agent-session.ts +722 -21
- package/src/session/session-dump-format.ts +15 -142
- package/src/session/session-history-format.ts +30 -11
- package/src/session/unexpected-stop-classifier.ts +129 -0
- package/src/session/yield-queue.ts +5 -1
- package/src/slash-commands/builtin-registry.ts +102 -4
- package/src/stt/asr-client.ts +1 -1
- package/src/system-prompt.ts +1 -1
- package/src/tiny/title-client.ts +1 -1
- package/src/tools/browser/tab-supervisor.ts +1 -1
- package/src/tools/browser/tab-worker-entry.ts +12 -4
- package/src/tools/job.ts +1 -0
- package/src/tools/path-utils.ts +33 -2
- package/src/tools/report-tool-issue.ts +2 -7
- package/src/tts/tts-client.ts +1 -1
- package/src/utils/thinking-display.ts +8 -34
- package/src/web/scrapers/docs-rs.ts +2 -3
package/src/tools/path-utils.ts
CHANGED
|
@@ -143,6 +143,37 @@ export function expandPath(filePath: string): string {
|
|
|
143
143
|
const normalized = stripFileUrl(normalizeUnicodeSpaces(normalizeAtPrefix(filePath)));
|
|
144
144
|
return expandTilde(normalized);
|
|
145
145
|
}
|
|
146
|
+
|
|
147
|
+
function isAsciiDriveLetter(value: string): boolean {
|
|
148
|
+
if (value.length !== 1) return false;
|
|
149
|
+
const code = value.charCodeAt(0);
|
|
150
|
+
return (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function windowsDriveAliasPath(filePath: string): string | undefined {
|
|
154
|
+
if (!filePath.startsWith("/")) return undefined;
|
|
155
|
+
const parts = filePath.split("/");
|
|
156
|
+
if (parts[0] !== "") return undefined;
|
|
157
|
+
|
|
158
|
+
let drive: string | undefined;
|
|
159
|
+
let tailStart = 2;
|
|
160
|
+
if (parts.length >= 2 && isAsciiDriveLetter(parts[1] ?? "")) {
|
|
161
|
+
drive = parts[1]!.toUpperCase();
|
|
162
|
+
} else if (parts.length >= 3 && (parts[1] ?? "").toLowerCase() === "mnt" && isAsciiDriveLetter(parts[2] ?? "")) {
|
|
163
|
+
drive = parts[2]!.toUpperCase();
|
|
164
|
+
tailStart = 3;
|
|
165
|
+
}
|
|
166
|
+
if (!drive) return undefined;
|
|
167
|
+
|
|
168
|
+
const tail = parts.slice(tailStart).filter(Boolean).join("\\");
|
|
169
|
+
return tail ? `${drive}:\\${tail}` : `${drive}:\\`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function normalizeWindowsDriveAliasPath(filePath: string, platform: NodeJS.Platform = process.platform): string {
|
|
173
|
+
if (platform !== "win32") return filePath;
|
|
174
|
+
return windowsDriveAliasPath(filePath) ?? filePath;
|
|
175
|
+
}
|
|
176
|
+
|
|
146
177
|
/**
|
|
147
178
|
* Inclusive line range describing one selector segment (e.g. `50-100`,
|
|
148
179
|
* `301-`, or `50+10`). `endLine` is `undefined` for open-ended ranges.
|
|
@@ -353,7 +384,7 @@ export function isInternalUrlPath(filePath: string): boolean {
|
|
|
353
384
|
*/
|
|
354
385
|
export function resolveToCwd(filePath: string, cwd: string): string {
|
|
355
386
|
const normalized = normalizeLocalScheme(filePath);
|
|
356
|
-
const expanded = expandPath(normalized);
|
|
387
|
+
const expanded = normalizeWindowsDriveAliasPath(expandPath(normalized));
|
|
357
388
|
const expandedAndNormalized = normalizeLocalScheme(expanded);
|
|
358
389
|
|
|
359
390
|
assertNotInternalUrl(expandedAndNormalized, normalized);
|
|
@@ -530,8 +561,8 @@ export async function splitDelimitedPathEntry(
|
|
|
530
561
|
}
|
|
531
562
|
|
|
532
563
|
return (
|
|
533
|
-
(await tryDelimitedPathSplit(normalizedEntry, cwd, splitter, "comma", false)) ??
|
|
534
564
|
(await tryDelimitedPathSplit(normalizedEntry, cwd, splitter, "semicolon", false)) ??
|
|
565
|
+
(await tryDelimitedPathSplit(normalizedEntry, cwd, splitter, "comma", false)) ??
|
|
535
566
|
(await tryDelimitedPathSplit(normalizedEntry, cwd, splitter, "whitespace", true)) ??
|
|
536
567
|
(await tryDelimitedPathSplit(normalizedEntry, cwd, splitter, "mixed", true))
|
|
537
568
|
);
|
|
@@ -20,10 +20,9 @@
|
|
|
20
20
|
* never blocked on the network and never throws.
|
|
21
21
|
*/
|
|
22
22
|
import { Database } from "bun:sqlite";
|
|
23
|
-
import path from "node:path";
|
|
24
23
|
import type { AgentTool } from "@oh-my-pi/pi-agent-core";
|
|
25
24
|
import type { FetchImpl } from "@oh-my-pi/pi-ai";
|
|
26
|
-
import { $env, $flag,
|
|
25
|
+
import { $env, $flag, getAutoQaDbDir, getInstallId, logger, VERSION } from "@oh-my-pi/pi-utils";
|
|
27
26
|
import { z } from "zod/v4";
|
|
28
27
|
import type { Settings } from "..";
|
|
29
28
|
import type { ToolSession } from "./index";
|
|
@@ -184,10 +183,6 @@ export async function resolveAutoQaConsent(settings: Settings | undefined): Prom
|
|
|
184
183
|
return consentInFlight;
|
|
185
184
|
}
|
|
186
185
|
|
|
187
|
-
export function getAutoQaDbPath(): string {
|
|
188
|
-
return path.join(getAgentDir(), "autoqa.db");
|
|
189
|
-
}
|
|
190
|
-
|
|
191
186
|
let cachedDb: Database | null = null;
|
|
192
187
|
|
|
193
188
|
/**
|
|
@@ -205,7 +200,7 @@ let cachedDb: Database | null = null;
|
|
|
205
200
|
export function openAutoQaDb(): Database | null {
|
|
206
201
|
if (cachedDb) return cachedDb;
|
|
207
202
|
try {
|
|
208
|
-
const db = new Database(
|
|
203
|
+
const db = new Database(getAutoQaDbDir());
|
|
209
204
|
// Install the busy handler BEFORE any lock-taking statement. See #2421.
|
|
210
205
|
db.run("PRAGMA busy_timeout = 5000");
|
|
211
206
|
db.run(`
|
package/src/tts/tts-client.ts
CHANGED
|
@@ -142,7 +142,7 @@ const SMOKE_TEST_TIMEOUT_MS = 30_000;
|
|
|
142
142
|
* Hidden subcommand on the main CLI that boots the TTS worker in the spawned
|
|
143
143
|
* subprocess. Kept in sync with the dispatch in `cli.ts` (Main-owned).
|
|
144
144
|
*/
|
|
145
|
-
export const TTS_WORKER_ARG = "
|
|
145
|
+
export const TTS_WORKER_ARG = "__omp_worker_tts";
|
|
146
146
|
|
|
147
147
|
function readTinyModelSetting(path: "providers.tinyModelDevice" | "providers.tinyModelDtype"): string | undefined {
|
|
148
148
|
try {
|
|
@@ -1,37 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
for (let i = 0; i < text.length; i++) {
|
|
9
|
-
const code = text.charCodeAt(i);
|
|
10
|
-
if (code === 0x2e || code === 0x2026) {
|
|
11
|
-
sawDot = true;
|
|
12
|
-
continue;
|
|
1
|
+
export function canonicalizeMessage(text: string | null | undefined): string {
|
|
2
|
+
if (!text) return "";
|
|
3
|
+
const trimmed = text.trim();
|
|
4
|
+
for (let i = 0; i < trimmed.length; i++) {
|
|
5
|
+
const code = trimmed.charCodeAt(i);
|
|
6
|
+
if (code !== 0x2e && code !== 0x2026 && code !== 0x20 && code !== 0x09 && code !== 0x0a && code !== 0x0d) {
|
|
7
|
+
return trimmed;
|
|
13
8
|
}
|
|
14
|
-
if (code === 0x20 || code === 0x09 || code === 0x0a || code === 0x0d) continue;
|
|
15
|
-
return false;
|
|
16
9
|
}
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Returns the operator-visible thinking text for a block.
|
|
22
|
-
*
|
|
23
|
-
* Some OpenAI-compatible reasoning gateways require a non-empty
|
|
24
|
-
* `reasoning_content` field on historical assistant tool-call turns even when
|
|
25
|
-
* the model did not emit any reasoning. The provider adapter uses a single dot
|
|
26
|
-
* as the wire-only placeholder those gateways accept; if that value is later
|
|
27
|
-
* replayed or echoed as a thinking block, it should not render as model thought.
|
|
28
|
-
*/
|
|
29
|
-
export function getVisibleThinkingText(block: ThinkingBlock): string {
|
|
30
|
-
const text = block.thinking.trim();
|
|
31
|
-
if (text.length === 0) return "";
|
|
32
|
-
return isDotOnlyThinking(text) ? "" : text;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function hasVisibleThinking(block: ThinkingBlock): boolean {
|
|
36
|
-
return getVisibleThinkingText(block).length > 0;
|
|
10
|
+
return "";
|
|
37
11
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { gunzipSync } from "node:zlib";
|
|
4
|
-
import {
|
|
4
|
+
import { getDocsRsCacheDir, isEnoent, logger, ptree, tryParseJson } from "@oh-my-pi/pi-utils";
|
|
5
5
|
import { ToolAbortError } from "../../tools/tool-errors";
|
|
6
6
|
import type { RenderResult, SpecialHandler } from "./types";
|
|
7
7
|
import { buildResult, MAX_BYTES } from "./types";
|
|
@@ -276,7 +276,6 @@ function findItemInModule(mod_: RustdocItem, name: string, index: Record<string,
|
|
|
276
276
|
return null;
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
-
const DOCS_RS_CACHE_ROOT = "webcache";
|
|
280
279
|
const DOCS_RS_CACHE_FILENAME = "rustdoc.json";
|
|
281
280
|
|
|
282
281
|
function sanitizeCacheSegment(value: string): string {
|
|
@@ -291,7 +290,7 @@ function getDocsRsCacheVersionSegment(version: string, now = new Date()): string
|
|
|
291
290
|
function getDocsRsCachePath(target: DocsRsTarget, now = new Date()): string {
|
|
292
291
|
const crate = sanitizeCacheSegment(target.crateName);
|
|
293
292
|
const version = getDocsRsCacheVersionSegment(target.version, now);
|
|
294
|
-
return path.join(
|
|
293
|
+
return path.join(getDocsRsCacheDir(), `docsrs_${crate}_${version}`, DOCS_RS_CACHE_FILENAME);
|
|
295
294
|
}
|
|
296
295
|
|
|
297
296
|
async function readCachedRustdocCrate(
|