Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions extensions/file-search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ import {
type PlatformTarget,
type ResolvedBinary,
} from "./src/binaries.ts";
import { formatCapturedOutput, type CapturedOutput } from "./src/output.ts";
import {
formatCapturedOutput,
type CapturedOutput,
} from "../shared/search-output.ts";
import {
FD_PARAMETER_DESCRIPTIONS,
FD_PROMPT_GUIDELINES,
Expand All @@ -53,7 +56,10 @@ import {
RG_PROMPT_SNIPPET,
RG_TOOL_DESCRIPTION,
} from "./src/prompt.ts";
import { discardCapturedOutput, executeSearchProcess } from "./src/process.ts";
import {
discardCapturedOutput,
executeSearchProcess,
} from "../shared/search-process.ts";
import {
OPENPI_TOOL_SURFACE,
patchOwnedTools,
Expand Down
2 changes: 1 addition & 1 deletion extensions/git-read/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
import { Text } from "@earendil-works/pi-tui";
import { Cause, Effect, Exit } from "effect";
import { Type } from "typebox";
import { formatCapturedOutput } from "../file-search/src/output.ts";
import { formatCapturedOutput } from "../shared/search-output.ts";
import { sanitizeTerminalText } from "../shared/terminal-text.ts";
import {
OPENPI_TOOL_SURFACE,
Expand Down
6 changes: 3 additions & 3 deletions extensions/git-read/src/process.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
* Bounded git process execution for the read-only git tools.
*
* Reuses the file-search capture discipline: a preview is retained in memory
* Reuses the shared bounded capture discipline: a preview is retained in memory
* under pi's standard truncation limits while the complete output (up to the
* 10 MiB capture cap) streams to a temporary file, and the process group is
* terminated when the cap is exceeded.
*/

import * as NodeServices from "@effect/platform-node/NodeServices";
import { Data, Effect } from "effect";
import type { CapturedOutput } from "../../file-search/src/output.ts";
import type { CapturedOutput } from "../../shared/search-output.ts";
import {
discardCapturedOutput,
executeSearchProcess,
} from "../../file-search/src/process.ts";
} from "../../shared/search-process.ts";
import { GIT_TIMEOUT_MS } from "./args.ts";

export const GIT_CAPTURE_MAX_BYTES = 10 * 1024 * 1024;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Shared output shaping for the fd and rg tools: standard pi truncation
* Shared output shaping for bounded search and git-read tools: standard pi truncation
* (2000 lines / 50KB) with complete output persisted to a temp file up to the
* documented 10 MiB capture limit.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {
truncateHead,
} from "@earendil-works/pi-coding-agent";
import { Data, Effect, FileSystem } from "effect";
import { COMPLETE_OUTPUT_MAX_BYTES, type CapturedOutput } from "./output.ts";
import {
COMPLETE_OUTPUT_MAX_BYTES,
type CapturedOutput,
} from "./search-output.ts";

const STDERR_MAX_BYTES = 64 * 1024;

Expand Down
4 changes: 2 additions & 2 deletions tests/extensions/file-search/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import {
COMPLETE_OUTPUT_MAX_BYTES,
formatCapturedOutput,
formatOutput,
} from "../../../extensions/file-search/src/output.ts";
import { executeSearchProcess } from "../../../extensions/file-search/src/process.ts";
} from "../../../extensions/shared/search-output.ts";
import { executeSearchProcess } from "../../../extensions/shared/search-process.ts";
import {
expandedPreview,
installNotifications,
Expand Down
22 changes: 22 additions & 0 deletions tests/extensions/shared/import-boundary.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import assert from "node:assert/strict";
import { readdir, readFile } from "node:fs/promises";
import { join } from "node:path";
import test from "node:test";

const SHARED_DIR = join(import.meta.dirname, "../../../extensions/shared");
const FEATURE_IMPORT =
/from\s+["'](?:\.\.\/(?!shared\/)[A-Za-z0-9._-]+|.*extensions\/(?!shared\/))/u;

test("shared modules do not import feature extension implementations", async () => {
const files = (await readdir(SHARED_DIR)).filter((name) =>
name.endsWith(".ts"),
);
assert.ok(files.includes("search-output.ts"));
assert.ok(files.includes("search-process.ts"));
const offenders: string[] = [];
for (const name of files) {
const source = await readFile(join(SHARED_DIR, name), "utf8");
if (FEATURE_IMPORT.test(source)) offenders.push(name);
}
assert.deepEqual(offenders, []);
});
Loading