chore: remove unused infra helpers

This commit is contained in:
Peter Steinberger
2026-05-30 22:45:14 +01:00
parent 71b3bc87ca
commit 3402477314
6 changed files with 2 additions and 80 deletions

View File

@@ -127,8 +127,7 @@ function collectImports(sourceFile) {
const importedName = element.propertyName?.text ?? element.name.text;
if (
importedName === "executeSqliteQuerySync" ||
importedName === "executeSqliteQueryTakeFirstSync" ||
importedName === "executeSqliteQueryTakeFirstOrThrowSync"
importedName === "executeSqliteQueryTakeFirstSync"
) {
syncHelperNames.add(element.name.text);
}

View File

@@ -8,13 +8,7 @@ import { truncateToVisualLines } from "../../modes/interactive/components/visual
import { theme } from "../../modes/interactive/theme/theme.js";
import type { AgentTool } from "../../runtime/index.js";
import { waitForChildProcess } from "../../utils/child-process.js";
import {
getShellConfig,
getShellEnv,
killProcessTree,
trackDetachedChildPid,
untrackDetachedChildPid,
} from "../../utils/shell.js";
import { getShellConfig, getShellEnv, killProcessTree } from "../../utils/shell.js";
import type { ToolDefinition, ToolRenderResultOptions } from "../extensions/types.js";
import type { BashOperations } from "./bash-operations.js";
import { OutputAccumulator } from "./output-accumulator.js";
@@ -68,9 +62,6 @@ export function createLocalBashOperations(options?: { shellPath?: string }): Bas
stdio: ["ignore", "pipe", "pipe"],
windowsHide: true,
});
if (child.pid) {
trackDetachedChildPid(child.pid);
}
let timedOut = false;
let timeoutHandle: NodeJS.Timeout | undefined;
const timeoutMs = resolveBashTimeoutMs(timeout);
@@ -102,9 +93,6 @@ export function createLocalBashOperations(options?: { shellPath?: string }): Bas
// on inherited stdio handles held by detached descendants.
waitForChildProcess(child)
.then((code) => {
if (child.pid) {
untrackDetachedChildPid(child.pid);
}
if (timeoutHandle) {
clearTimeout(timeoutHandle);
}
@@ -122,9 +110,6 @@ export function createLocalBashOperations(options?: { shellPath?: string }): Bas
resolve({ exitCode: code });
})
.catch((err) => {
if (child.pid) {
untrackDetachedChildPid(child.pid);
}
if (timeoutHandle) {
clearTimeout(timeoutHandle);
}

View File

@@ -1,6 +1,5 @@
import { realpathSync } from "node:fs";
import { isAbsolute, relative, resolve as resolvePath, sep } from "node:path";
import { spawnProcessSync } from "./child-process.js";
/**
* Resolve a path to its canonical (real) form, following symlinks.
@@ -56,23 +55,3 @@ export function formatPathRelativeToCwdOrAbsolute(filePath: string, cwd: string)
const absolutePath = resolveAgainstCwd(filePath, cwd);
return (getCwdRelativePath(absolutePath, cwd) ?? absolutePath).split(sep).join("/");
}
export function markPathIgnoredByCloudSync(path: string): void {
const attrs =
process.platform === "darwin"
? ["com.dropbox.ignored", "com.apple.fileprovider.ignore#P"]
: process.platform === "linux"
? ["user.com.dropbox.ignored"]
: [];
for (const attr of attrs) {
if (process.platform === "darwin") {
spawnProcessSync("xattr", ["-w", attr, "1", path], { encoding: "utf-8", stdio: "ignore" });
} else {
spawnProcessSync("setfattr", ["-n", attr, "-v", "1", path], {
encoding: "utf-8",
stdio: "ignore",
});
}
}
}

View File

@@ -177,27 +177,6 @@ export function sanitizeBinaryOutput(str: string): string {
.join("");
}
/**
* Detached child processes must be tracked so they can be killed on parent
* shutdown signals (SIGHUP/SIGTERM).
*/
const trackedDetachedChildPids = new Set<number>();
export function trackDetachedChildPid(pid: number): void {
trackedDetachedChildPids.add(pid);
}
export function untrackDetachedChildPid(pid: number): void {
trackedDetachedChildPids.delete(pid);
}
export function killTrackedDetachedChildren(): void {
for (const pid of trackedDetachedChildPids) {
killProcessTree(pid);
}
trackedDetachedChildPids.clear();
}
export function killProcessTree(pid: number, opts?: KillProcessTreeOptions): void {
killProcessTreeGracefully(pid, { force: true, ...opts });
}

View File

@@ -60,17 +60,6 @@ export function executeSqliteQueryTakeFirstSync<Row>(
return executeSqliteQuerySync<Row>(db, query).rows[0];
}
export function executeSqliteQueryTakeFirstOrThrowSync<Row>(
db: DatabaseSync,
query: CompilableQuery<Row>,
): Row {
const row = executeSqliteQueryTakeFirstSync<Row>(db, query);
if (!row) {
throw new Error("Kysely query returned no rows");
}
return row;
}
export function clearNodeSqliteKyselyCacheForDatabase(db: DatabaseSync): void {
kyselyByDatabase.delete(db);
}

View File

@@ -193,15 +193,6 @@ export async function readRestartSentinel(
}
}
export async function hasRestartSentinel(env: NodeJS.ProcessEnv = process.env): Promise<boolean> {
try {
await fs.access(resolveRestartSentinelPath(env));
return true;
} catch {
return false;
}
}
export async function consumeRestartSentinel(
env: NodeJS.ProcessEnv = process.env,
): Promise<RestartSentinel | null> {