Back out @lib indirection in tsconfig.json (#111)

This commit is contained in:
Michael Bolin
2025-04-16 14:16:53 -07:00
committed by GitHub
parent 7ac633b69c
commit 9b733fc48f
41 changed files with 63 additions and 111 deletions

View File

@@ -1,5 +1,5 @@
import type { ApprovalPolicy } from "./approvals";
import type { AppConfig } from "./utils/config"; import type { AppConfig } from "./utils/config";
import type { ApprovalPolicy } from "@lib/approvals";
import type { ResponseItem } from "openai/resources/responses/responses"; import type { ResponseItem } from "openai/resources/responses/responses";
import TerminalChat from "./components/chat/terminal-chat"; import TerminalChat from "./components/chat/terminal-chat";

View File

@@ -3,7 +3,7 @@ import type { ParseEntry, ControlOperator } from "shell-quote";
import { import {
identify_files_added, identify_files_added,
identify_files_needed, identify_files_needed,
} from "../utils/agent/apply-patch"; } from "./utils/agent/apply-patch";
import * as path from "path"; import * as path from "path";
import { parse } from "shell-quote"; import { parse } from "shell-quote";

View File

@@ -1,9 +1,9 @@
#!/usr/bin/env node #!/usr/bin/env node
import type { AppRollout } from "./app"; import type { AppRollout } from "./app";
import type { ApprovalPolicy } from "./approvals";
import type { CommandConfirmation } from "./utils/agent/agent-loop"; import type { CommandConfirmation } from "./utils/agent/agent-loop";
import type { AppConfig } from "./utils/config"; import type { AppConfig } from "./utils/config";
import type { ApprovalPolicy } from "@lib/approvals";
import type { ResponseItem } from "openai/resources/responses/responses"; import type { ResponseItem } from "openai/resources/responses/responses";
import App from "./app"; import App from "./app";
@@ -124,7 +124,7 @@ const cli = meow(
fullContext: { fullContext: {
type: "boolean", type: "boolean",
aliases: ["f"], aliases: ["f"],
description: `Run in full-context editing approach. The model is given the whole code description: `Run in full-context editing approach. The model is given the whole code
directory as context and performs changes in one go without acting.`, directory as context and performs changes in one go without acting.`,
}, },
}, },

View File

@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import { useTerminalSize } from "../../hooks/use-terminal-size"; import { useTerminalSize } from "../../hooks/use-terminal-size";
import TextBuffer from "../../lib/text-buffer.js"; import TextBuffer from "../../text-buffer.js";
import chalk from "chalk"; import chalk from "chalk";
import { Box, Text, useInput, useStdin } from "ink"; import { Box, Text, useInput, useStdin } from "ink";
import { EventEmitter } from "node:events"; import { EventEmitter } from "node:events";

View File

@@ -1,5 +1,5 @@
import { parseApplyPatch } from "../../parse-apply-patch";
import { shortenPath } from "../../utils/short-path"; import { shortenPath } from "../../utils/short-path";
import { parseApplyPatch } from "@lib/parse-apply-patch";
import chalk from "chalk"; import chalk from "chalk";
import { Text } from "ink"; import { Text } from "ink";
import React from "react"; import React from "react";

View File

@@ -1,6 +1,6 @@
import type { ApplyPatchCommand, ApprovalPolicy } from "../../approvals.js";
import type { CommandConfirmation } from "../../utils/agent/agent-loop.js"; import type { CommandConfirmation } from "../../utils/agent/agent-loop.js";
import type { AppConfig } from "../../utils/config.js"; import type { AppConfig } from "../../utils/config.js";
import type { ApplyPatchCommand, ApprovalPolicy } from "@lib/approvals.js";
import type { ColorName } from "chalk"; import type { ColorName } from "chalk";
import type { ResponseItem } from "openai/resources/responses/responses.mjs"; import type { ResponseItem } from "openai/resources/responses/responses.mjs";
import type { ReviewDecision } from "src/utils/agent/review.ts"; import type { ReviewDecision } from "src/utils/agent/review.ts";
@@ -12,6 +12,7 @@ import {
uniqueById, uniqueById,
} from "./terminal-chat-utils.js"; } from "./terminal-chat-utils.js";
import TerminalMessageHistory from "./terminal-message-history.js"; import TerminalMessageHistory from "./terminal-message-history.js";
import { formatCommandForDisplay } from "../../format-command.js";
import { useConfirmation } from "../../hooks/use-confirmation.js"; import { useConfirmation } from "../../hooks/use-confirmation.js";
import { useTerminalSize } from "../../hooks/use-terminal-size.js"; import { useTerminalSize } from "../../hooks/use-terminal-size.js";
import { AgentLoop } from "../../utils/agent/agent-loop.js"; import { AgentLoop } from "../../utils/agent/agent-loop.js";
@@ -25,7 +26,6 @@ import ApprovalModeOverlay from "../approval-mode-overlay.js";
import HelpOverlay from "../help-overlay.js"; import HelpOverlay from "../help-overlay.js";
import HistoryOverlay from "../history-overlay.js"; import HistoryOverlay from "../history-overlay.js";
import ModelOverlay from "../model-overlay.js"; import ModelOverlay from "../model-overlay.js";
import { formatCommandForDisplay } from "@lib/format-command.js";
import { Box, Text } from "ink"; import { Box, Text } from "ink";
import React, { useEffect, useMemo, useState } from "react"; import React, { useEffect, useMemo, useState } from "react";
import { inspect } from "util"; import { inspect } from "util";

View File

@@ -1,6 +1,6 @@
import type { ReviewDecision } from "./review.js"; import type { ReviewDecision } from "./review.js";
import type { ApplyPatchCommand, ApprovalPolicy } from "../../approvals.js";
import type { AppConfig } from "../config.js"; import type { AppConfig } from "../config.js";
import type { ApplyPatchCommand, ApprovalPolicy } from "@lib/approvals.js";
import type { import type {
ResponseFunctionToolCall, ResponseFunctionToolCall,
ResponseInputItem, ResponseInputItem,

View File

@@ -5,7 +5,7 @@ import { process_patch } from "./apply-patch.js";
import { SandboxType } from "./sandbox/interface.js"; import { SandboxType } from "./sandbox/interface.js";
import { execWithSeatbelt } from "./sandbox/macos-seatbelt.js"; import { execWithSeatbelt } from "./sandbox/macos-seatbelt.js";
import { exec as rawExec } from "./sandbox/raw-exec.js"; import { exec as rawExec } from "./sandbox/raw-exec.js";
import { formatCommandForDisplay } from "@lib/format-command.js"; import { formatCommandForDisplay } from "../../format-command.js";
import fs from "fs"; import fs from "fs";
import os from "os"; import os from "os";

View File

@@ -1,7 +1,7 @@
import type { CommandConfirmation } from "./agent-loop.js"; import type { CommandConfirmation } from "./agent-loop.js";
import type { AppConfig } from "../config.js"; import type { AppConfig } from "../config.js";
import type { ExecInput } from "./sandbox/interface.js"; import type { ExecInput } from "./sandbox/interface.js";
import type { ApplyPatchCommand, ApprovalPolicy } from "@lib/approvals.js"; import type { ApplyPatchCommand, ApprovalPolicy } from "../../approvals.js";
import type { ResponseInputItem } from "openai/resources/responses/responses.mjs"; import type { ResponseInputItem } from "openai/resources/responses/responses.mjs";
import { exec, execApplyPatch } from "./exec.js"; import { exec, execApplyPatch } from "./exec.js";
@@ -9,8 +9,8 @@ import { isLoggingEnabled, log } from "./log.js";
import { ReviewDecision } from "./review.js"; import { ReviewDecision } from "./review.js";
import { FullAutoErrorMode } from "../auto-approval-mode.js"; import { FullAutoErrorMode } from "../auto-approval-mode.js";
import { SandboxType } from "./sandbox/interface.js"; import { SandboxType } from "./sandbox/interface.js";
import { canAutoApprove } from "@lib/approvals.js"; import { canAutoApprove } from "../../approvals.js";
import { formatCommandForDisplay } from "@lib/format-command.js"; import { formatCommandForDisplay } from "../../format-command.js";
import { access } from "fs/promises"; import { access } from "fs/promises";
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -1,4 +1,4 @@
import type { SafeCommandReason } from "@lib/approvals"; import type { SafeCommandReason } from "../../approvals";
export type CommandReviewDetails = { export type CommandReviewDetails = {
cmd: Array<string>; cmd: Array<string>;

View File

@@ -3,11 +3,13 @@ import type {
ExecInput, ExecInput,
ExecOutputMetadata, ExecOutputMetadata,
} from "./agent/sandbox/interface.js"; } from "./agent/sandbox/interface.js";
import type { SafeCommandReason } from "@lib/approvals.js";
import type { ResponseFunctionToolCall } from "openai/resources/responses/responses.mjs"; import type { ResponseFunctionToolCall } from "openai/resources/responses/responses.mjs";
import { isSafeCommand, type SafeCommandReason } from "../approvals.js";
import { log } from "node:console"; import { log } from "node:console";
import process from "process"; import process from "process";
import { parse } from "shell-quote";
import { formatCommandForDisplay } from "src/format-command.js";
// The console utility import is intentionally explicit to avoid bundlers from // The console utility import is intentionally explicit to avoid bundlers from
// including the entire `console` module when only the `log` function is // including the entire `console` module when only the `log` function is
@@ -23,52 +25,6 @@ const SAFE_SHELL_OPERATORS: ReadonlySet<string> = new Set([
";", ";",
]); ]);
// Lazily resolve heavy dependencies at runtime to avoid test environments
// (which might not have the @lib alias configured) from failing at import
// time. If the modules cannot be loaded we fall back to permissive stub
// implementations so that basic functionality like unittesting small UI
// helpers continues to work without the full codexlib dependency tree.
let isSafeCommand: (cmd: Array<string>) => SafeCommandReason | null = () =>
null;
let shellQuoteParse:
| ((cmd: string, env?: Record<string, string | undefined>) => Array<unknown>)
| undefined;
let formatCommandForDisplay: (cmd: Array<string>) => string = (cmd) =>
cmd.join(" ");
async function loadLibs(): Promise<void> {
try {
const approvals = await import("@lib/approvals.js");
if (typeof approvals.isSafeCommand === "function") {
isSafeCommand = approvals.isSafeCommand;
}
} catch {
// ignore keep stub
}
try {
const fmt = await import("@lib/format-command.js");
if (typeof fmt.formatCommandForDisplay === "function") {
formatCommandForDisplay = fmt.formatCommandForDisplay;
}
} catch {
// ignore keep stub
}
try {
const sq = await import("shell-quote");
if (typeof sq.parse === "function") {
shellQuoteParse = sq.parse as typeof shellQuoteParse;
}
} catch {
// ignore keep stub
}
}
// Trigger the dynamic import in the background; callers that need the real
// implementation should await the returned promise (parsers currently does not
// require this for correctness during tests).
void loadLibs();
export function parseToolCallOutput(toolCallOutput: string): { export function parseToolCallOutput(toolCallOutput: string): {
output: string; output: string;
metadata: ExecOutputMetadata; metadata: ExecOutputMetadata;
@@ -175,10 +131,9 @@ function computeAutoApproval(cmd: Array<string>): SafeCommandReason | null {
cmd.length === 3 && cmd.length === 3 &&
cmd[0] === "bash" && cmd[0] === "bash" &&
cmd[1] === "-lc" && cmd[1] === "-lc" &&
typeof cmd[2] === "string" && typeof cmd[2] === "string"
shellQuoteParse
) { ) {
const parsed = shellQuoteParse(cmd[2], process.env ?? {}); const parsed = parse(cmd[2], process.env ?? {});
if (parsed.length === 0) { if (parsed.length === 0) {
return null; return null;
} }

View File

@@ -64,13 +64,13 @@ vi.mock("openai", () => {
}; };
}); });
vi.mock("@lib/approvals.js", () => ({ vi.mock("../src/approvals.js", () => ({
__esModule: true, __esModule: true,
alwaysApprovedCommands: new Set<string>(), alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any), canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
})); }));
vi.mock("@lib/format-command.js", () => ({ vi.mock("../src/format-command.js", () => ({
__esModule: true, __esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "), formatCommandForDisplay: (c: Array<string>) => c.join(" "),
})); }));

View File

@@ -71,13 +71,13 @@ vi.mock("openai", () => {
}); });
// Stub helpers not relevant for this test. // Stub helpers not relevant for this test.
vi.mock("@lib/approvals.js", () => ({ vi.mock("../src/approvals.js", () => ({
__esModule: true, __esModule: true,
alwaysApprovedCommands: new Set<string>(), alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any), canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
})); }));
vi.mock("@lib/format-command.js", () => ({ vi.mock("../src/format-command.js", () => ({
__esModule: true, __esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "), formatCommandForDisplay: (c: Array<string>) => c.join(" "),
})); }));

View File

@@ -67,11 +67,11 @@ vi.mock("openai", () => {
}); });
// Stubs for external helpers referenced indirectly. // Stubs for external helpers referenced indirectly.
vi.mock("@lib/approvals.js", () => ({ vi.mock("../src/approvals.js", () => ({
__esModule: true, __esModule: true,
isSafeCommand: () => null, isSafeCommand: () => null,
})); }));
vi.mock("@lib/format-command.js", () => ({ vi.mock("../src/format-command.js", () => ({
__esModule: true, __esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "), formatCommandForDisplay: (c: Array<string>) => c.join(" "),
})); }));

View File

@@ -47,7 +47,7 @@ vi.mock("openai", () => {
}); });
// Mock the approvals and formatCommand helpers referenced by handleexeccommand. // Mock the approvals and formatCommand helpers referenced by handleexeccommand.
vi.mock("@lib/approvals.js", () => { vi.mock("../src/approvals.js", () => {
return { return {
__esModule: true, __esModule: true,
alwaysApprovedCommands: new Set<string>(), alwaysApprovedCommands: new Set<string>(),
@@ -57,7 +57,7 @@ vi.mock("@lib/approvals.js", () => {
}; };
}); });
vi.mock("@lib/format-command.js", () => { vi.mock("../src/format-command.js", () => {
return { return {
__esModule: true, __esModule: true,
formatCommandForDisplay: (cmd: Array<string>) => cmd.join(" "), formatCommandForDisplay: (cmd: Array<string>) => cmd.join(" "),

View File

@@ -88,14 +88,14 @@ vi.mock("openai", () => {
}); });
// Stub approvals & command formatting not relevant for this test. // Stub approvals & command formatting not relevant for this test.
vi.mock("@lib/approvals.js", () => ({ vi.mock("../src/approvals.js", () => ({
__esModule: true, __esModule: true,
alwaysApprovedCommands: new Set<string>(), alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any), canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
isSafeCommand: () => null, isSafeCommand: () => null,
})); }));
vi.mock("@lib/format-command.js", () => ({ vi.mock("../src/format-command.js", () => ({
__esModule: true, __esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "), formatCommandForDisplay: (c: Array<string>) => c.join(" "),
})); }));

View File

@@ -23,14 +23,14 @@ vi.mock("openai", () => {
}); });
// Stub approvals / formatting helpers unrelated to network handling. // Stub approvals / formatting helpers unrelated to network handling.
vi.mock("@lib/approvals.js", () => ({ vi.mock("../src/approvals.js", () => ({
__esModule: true, __esModule: true,
alwaysApprovedCommands: new Set<string>(), alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any), canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
isSafeCommand: () => null, isSafeCommand: () => null,
})); }));
vi.mock("@lib/format-command.js", () => ({ vi.mock("../src/format-command.js", () => ({
__esModule: true, __esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "), formatCommandForDisplay: (c: Array<string>) => c.join(" "),
})); }));

View File

@@ -22,14 +22,14 @@ vi.mock("openai", () => {
}; };
}); });
vi.mock("@lib/approvals.js", () => ({ vi.mock("../src/approvals.js", () => ({
__esModule: true, __esModule: true,
alwaysApprovedCommands: new Set<string>(), alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any), canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
isSafeCommand: () => null, isSafeCommand: () => null,
})); }));
vi.mock("@lib/format-command.js", () => ({ vi.mock("../src/format-command.js", () => ({
__esModule: true, __esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "), formatCommandForDisplay: (c: Array<string>) => c.join(" "),
})); }));

View File

@@ -22,14 +22,14 @@ vi.mock("openai", () => {
}; };
}); });
vi.mock("@lib/approvals.js", () => ({ vi.mock("../src/approvals.js", () => ({
__esModule: true, __esModule: true,
alwaysApprovedCommands: new Set<string>(), alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any), canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
isSafeCommand: () => null, isSafeCommand: () => null,
})); }));
vi.mock("@lib/format-command.js", () => ({ vi.mock("../src/format-command.js", () => ({
__esModule: true, __esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "), formatCommandForDisplay: (c: Array<string>) => c.join(" "),
})); }));

View File

@@ -42,14 +42,14 @@ vi.mock("openai", () => {
}); });
// Stub approvals / formatting helpers not relevant here. // Stub approvals / formatting helpers not relevant here.
vi.mock("@lib/approvals.js", () => ({ vi.mock("../src/approvals.js", () => ({
__esModule: true, __esModule: true,
alwaysApprovedCommands: new Set<string>(), alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any), canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
isSafeCommand: () => null, isSafeCommand: () => null,
})); }));
vi.mock("@lib/format-command.js", () => ({ vi.mock("../src/format-command.js", () => ({
__esModule: true, __esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "), formatCommandForDisplay: (c: Array<string>) => c.join(" "),
})); }));

View File

@@ -51,7 +51,7 @@ vi.mock("openai", () => {
// The AgentLoop pulls these helpers in order to decide whether a command can // The AgentLoop pulls these helpers in order to decide whether a command can
// be autoapproved. None of that matters for this test, so we stub the module // be autoapproved. None of that matters for this test, so we stub the module
// with minimal noop implementations. // with minimal noop implementations.
vi.mock("@lib/approvals.js", () => { vi.mock("../src/approvals.js", () => {
return { return {
__esModule: true, __esModule: true,
alwaysApprovedCommands: new Set<string>(), alwaysApprovedCommands: new Set<string>(),
@@ -61,7 +61,7 @@ vi.mock("@lib/approvals.js", () => {
}; };
}); });
vi.mock("@lib/format-command.js", () => { vi.mock("../src/format-command.js", () => {
return { return {
__esModule: true, __esModule: true,
formatCommandForDisplay: (cmd: Array<string>) => cmd.join(" "), formatCommandForDisplay: (cmd: Array<string>) => cmd.join(" "),

View File

@@ -34,14 +34,14 @@ vi.mock("openai", () => {
// Stub helpers that the agent indirectly imports so it does not attempt any // Stub helpers that the agent indirectly imports so it does not attempt any
// filesystem access or real approvals logic during the test. // filesystem access or real approvals logic during the test.
vi.mock("@lib/approvals.js", () => ({ vi.mock("../src/approvals.js", () => ({
__esModule: true, __esModule: true,
alwaysApprovedCommands: new Set<string>(), alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any), canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
isSafeCommand: () => null, isSafeCommand: () => null,
})); }));
vi.mock("@lib/format-command.js", () => ({ vi.mock("../src/format-command.js", () => ({
__esModule: true, __esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "), formatCommandForDisplay: (c: Array<string>) => c.join(" "),
})); }));

View File

@@ -32,14 +32,14 @@ vi.mock("openai", () => {
}; };
}); });
vi.mock("@lib/approvals.js", () => ({ vi.mock("../src/approvals.js", () => ({
__esModule: true, __esModule: true,
alwaysApprovedCommands: new Set<string>(), alwaysApprovedCommands: new Set<string>(),
canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any), canAutoApprove: () => ({ type: "auto-approve", runInSandbox: false } as any),
isSafeCommand: () => null, isSafeCommand: () => null,
})); }));
vi.mock("@lib/format-command.js", () => ({ vi.mock("../src/format-command.js", () => ({
__esModule: true, __esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "), formatCommandForDisplay: (c: Array<string>) => c.join(" "),
})); }));

View File

@@ -49,7 +49,7 @@ vi.mock("openai", () => {
// --- Helpers referenced by handleexeccommand ----------------------------- // --- Helpers referenced by handleexeccommand -----------------------------
vi.mock("@lib/approvals.js", () => { vi.mock("../src/approvals.js", () => {
return { return {
__esModule: true, __esModule: true,
alwaysApprovedCommands: new Set<string>(), alwaysApprovedCommands: new Set<string>(),
@@ -59,7 +59,7 @@ vi.mock("@lib/approvals.js", () => {
}; };
}); });
vi.mock("@lib/format-command.js", () => { vi.mock("../src/format-command.js", () => {
return { return {
__esModule: true, __esModule: true,
formatCommandForDisplay: (cmd: Array<string>) => cmd.join(" "), formatCommandForDisplay: (cmd: Array<string>) => cmd.join(" "),

View File

@@ -74,12 +74,12 @@ vi.mock("openai", () => {
}); });
// Stub helpers referenced indirectly so we do not pull in real FS/network // Stub helpers referenced indirectly so we do not pull in real FS/network
vi.mock("@lib/approvals.js", () => ({ vi.mock("../src/approvals.js", () => ({
__esModule: true, __esModule: true,
isSafeCommand: () => null, isSafeCommand: () => null,
})); }));
vi.mock("@lib/format-command.js", () => ({ vi.mock("../src/format-command.js", () => ({
__esModule: true, __esModule: true,
formatCommandForDisplay: (c: Array<string>) => c.join(" "), formatCommandForDisplay: (c: Array<string>) => c.join(" "),
})); }));

View File

@@ -1,6 +1,6 @@
import type { SafetyAssessment } from "../src/lib/approvals"; import type { SafetyAssessment } from "../src/approvals";
import { canAutoApprove } from "../src/lib/approvals"; import { canAutoApprove } from "../src/approvals";
import { describe, test, expect } from "vitest"; import { describe, test, expect } from "vitest";
describe("canAutoApprove()", () => { describe("canAutoApprove()", () => {

View File

@@ -1,4 +1,4 @@
import TextBuffer from "../src/lib/text-buffer"; import TextBuffer from "../src/text-buffer";
import { describe, it, expect, vi } from "vitest"; import { describe, it, expect, vi } from "vitest";
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------

View File

@@ -1,4 +1,4 @@
import { formatCommandForDisplay } from "../src/lib/format-command"; import { formatCommandForDisplay } from "../src/format-command";
import { describe, test, expect } from "vitest"; import { describe, test, expect } from "vitest";
describe("formatCommandForDisplay()", () => { describe("formatCommandForDisplay()", () => {

View File

@@ -22,7 +22,7 @@ describe("rawExec invalid command handling", () => {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Mock approvals and logging helpers so the test focuses on execution flow. // Mock approvals and logging helpers so the test focuses on execution flow.
vi.mock("@lib/approvals.js", () => { vi.mock("../src/approvals.js", () => {
return { return {
__esModule: true, __esModule: true,
canAutoApprove: () => canAutoApprove: () =>
@@ -31,7 +31,7 @@ vi.mock("@lib/approvals.js", () => {
}; };
}); });
vi.mock("@lib/format-command.js", () => { vi.mock("../src/format-command.js", () => {
return { return {
__esModule: true, __esModule: true,
formatCommandForDisplay: (cmd: Array<string>) => cmd.join(" "), formatCommandForDisplay: (cmd: Array<string>) => cmd.join(" "),

View File

@@ -1,6 +1,6 @@
import { renderTui } from "./ui-test-helpers.js"; import { renderTui } from "./ui-test-helpers.js";
import MultilineTextEditor from "../src/components/chat/multiline-editor.js"; import MultilineTextEditor from "../src/components/chat/multiline-editor.js";
import TextBuffer from "../src/lib/text-buffer.js"; import TextBuffer from "../src/text-buffer.js";
import * as React from "react"; import * as React from "react";
import { describe, it, expect, vi } from "vitest"; import { describe, it, expect, vi } from "vitest";

View File

@@ -34,12 +34,12 @@ vi.mock("../src/utils/input-utils.js", () => ({
})), })),
})); }));
// Mock the optional @lib/* dependencies so the dynamic import in parsers.ts // Mock the optional ../src/* dependencies so the dynamic import in parsers.ts
// does not fail during the test environment where the alias isn't configured. // does not fail during the test environment where the alias isn't configured.
vi.mock("@lib/format-command.js", () => ({ vi.mock("../src/format-command.js", () => ({
formatCommandForDisplay: (cmd: Array<string>) => cmd.join(" "), formatCommandForDisplay: (cmd: Array<string>) => cmd.join(" "),
})); }));
vi.mock("@lib/approvals.js", () => ({ vi.mock("../src/approvals.js", () => ({
isSafeCommand: (_cmd: Array<string>) => null, isSafeCommand: (_cmd: Array<string>) => null,
})); }));

View File

@@ -1,4 +1,4 @@
import { parseApplyPatch } from "../src/lib/parse-apply-patch"; import { parseApplyPatch } from "../src/parse-apply-patch";
import { expect, test, describe } from "vitest"; import { expect, test, describe } from "vitest";
// Helper function to unwrap a nonnull result in tests that expect success. // Helper function to unwrap a nonnull result in tests that expect success.

View File

@@ -1,4 +1,4 @@
import TextBuffer from "../src/lib/text-buffer.js"; import TextBuffer from "../src/text-buffer.js";
import { describe, it, expect } from "vitest"; import { describe, it, expect } from "vitest";
// These tests ensure that the TextBuffer copy&paste logic keeps parity with // These tests ensure that the TextBuffer copy&paste logic keeps parity with

View File

@@ -1,4 +1,4 @@
import TextBuffer from "../src/lib/text-buffer.js"; import TextBuffer from "../src/text-buffer.js";
import { describe, it, expect } from "vitest"; import { describe, it, expect } from "vitest";
describe("TextBuffer newline normalisation", () => { describe("TextBuffer newline normalisation", () => {

View File

@@ -1,4 +1,4 @@
import TextBuffer from "../src/lib/text-buffer"; import TextBuffer from "../src/text-buffer";
import { describe, it, expect } from "vitest"; import { describe, it, expect } from "vitest";
// The purpose of this testsuite is NOT to make the implementation green today // The purpose of this testsuite is NOT to make the implementation green today

View File

@@ -1,4 +1,4 @@
import TextBuffer from "../src/lib/text-buffer.js"; import TextBuffer from "../src/text-buffer.js";
import { describe, test, expect } from "vitest"; import { describe, test, expect } from "vitest";
describe("TextBuffer wordwise navigation & deletion", () => { describe("TextBuffer wordwise navigation & deletion", () => {

View File

@@ -1,4 +1,4 @@
import TextBuffer from "../src/lib/text-buffer"; import TextBuffer from "../src/text-buffer";
import { describe, it, expect } from "vitest"; import { describe, it, expect } from "vitest";
describe("TextBuffer basic editing parity with Rust suite", () => { describe("TextBuffer basic editing parity with Rust suite", () => {

View File

@@ -11,9 +11,6 @@
], ],
"types": ["node"], "types": ["node"],
"baseUrl": "./", "baseUrl": "./",
"paths": {
"@lib/*": ["./src/lib/*"]
},
"resolveJsonModule": false, // ESM doesn't yet support JSON modules. "resolveJsonModule": false, // ESM doesn't yet support JSON modules.
"jsx": "react", "jsx": "react",
"declaration": true, "declaration": true,