Back out @lib indirection in tsconfig.json (#111)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { ApprovalPolicy } from "./approvals";
|
||||
import type { AppConfig } from "./utils/config";
|
||||
import type { ApprovalPolicy } from "@lib/approvals";
|
||||
import type { ResponseItem } from "openai/resources/responses/responses";
|
||||
|
||||
import TerminalChat from "./components/chat/terminal-chat";
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { ParseEntry, ControlOperator } from "shell-quote";
|
||||
import {
|
||||
identify_files_added,
|
||||
identify_files_needed,
|
||||
} from "../utils/agent/apply-patch";
|
||||
} from "./utils/agent/apply-patch";
|
||||
import * as path from "path";
|
||||
import { parse } from "shell-quote";
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import type { AppRollout } from "./app";
|
||||
import type { ApprovalPolicy } from "./approvals";
|
||||
import type { CommandConfirmation } from "./utils/agent/agent-loop";
|
||||
import type { AppConfig } from "./utils/config";
|
||||
import type { ApprovalPolicy } from "@lib/approvals";
|
||||
import type { ResponseItem } from "openai/resources/responses/responses";
|
||||
|
||||
import App from "./app";
|
||||
@@ -124,7 +124,7 @@ const cli = meow(
|
||||
fullContext: {
|
||||
type: "boolean",
|
||||
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.`,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
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 { Box, Text, useInput, useStdin } from "ink";
|
||||
import { EventEmitter } from "node:events";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { parseApplyPatch } from "../../parse-apply-patch";
|
||||
import { shortenPath } from "../../utils/short-path";
|
||||
import { parseApplyPatch } from "@lib/parse-apply-patch";
|
||||
import chalk from "chalk";
|
||||
import { Text } from "ink";
|
||||
import React from "react";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ApplyPatchCommand, ApprovalPolicy } from "../../approvals.js";
|
||||
import type { CommandConfirmation } from "../../utils/agent/agent-loop.js";
|
||||
import type { AppConfig } from "../../utils/config.js";
|
||||
import type { ApplyPatchCommand, ApprovalPolicy } from "@lib/approvals.js";
|
||||
import type { ColorName } from "chalk";
|
||||
import type { ResponseItem } from "openai/resources/responses/responses.mjs";
|
||||
import type { ReviewDecision } from "src/utils/agent/review.ts";
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
uniqueById,
|
||||
} from "./terminal-chat-utils.js";
|
||||
import TerminalMessageHistory from "./terminal-message-history.js";
|
||||
import { formatCommandForDisplay } from "../../format-command.js";
|
||||
import { useConfirmation } from "../../hooks/use-confirmation.js";
|
||||
import { useTerminalSize } from "../../hooks/use-terminal-size.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 HistoryOverlay from "../history-overlay.js";
|
||||
import ModelOverlay from "../model-overlay.js";
|
||||
import { formatCommandForDisplay } from "@lib/format-command.js";
|
||||
import { Box, Text } from "ink";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { inspect } from "util";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ReviewDecision } from "./review.js";
|
||||
import type { ApplyPatchCommand, ApprovalPolicy } from "../../approvals.js";
|
||||
import type { AppConfig } from "../config.js";
|
||||
import type { ApplyPatchCommand, ApprovalPolicy } from "@lib/approvals.js";
|
||||
import type {
|
||||
ResponseFunctionToolCall,
|
||||
ResponseInputItem,
|
||||
|
||||
@@ -5,7 +5,7 @@ import { process_patch } from "./apply-patch.js";
|
||||
import { SandboxType } from "./sandbox/interface.js";
|
||||
import { execWithSeatbelt } from "./sandbox/macos-seatbelt.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 os from "os";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { CommandConfirmation } from "./agent-loop.js";
|
||||
import type { AppConfig } from "../config.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 { exec, execApplyPatch } from "./exec.js";
|
||||
@@ -9,8 +9,8 @@ import { isLoggingEnabled, log } from "./log.js";
|
||||
import { ReviewDecision } from "./review.js";
|
||||
import { FullAutoErrorMode } from "../auto-approval-mode.js";
|
||||
import { SandboxType } from "./sandbox/interface.js";
|
||||
import { canAutoApprove } from "@lib/approvals.js";
|
||||
import { formatCommandForDisplay } from "@lib/format-command.js";
|
||||
import { canAutoApprove } from "../../approvals.js";
|
||||
import { formatCommandForDisplay } from "../../format-command.js";
|
||||
import { access } from "fs/promises";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { SafeCommandReason } from "@lib/approvals";
|
||||
import type { SafeCommandReason } from "../../approvals";
|
||||
|
||||
export type CommandReviewDetails = {
|
||||
cmd: Array<string>;
|
||||
|
||||
@@ -3,11 +3,13 @@ import type {
|
||||
ExecInput,
|
||||
ExecOutputMetadata,
|
||||
} from "./agent/sandbox/interface.js";
|
||||
import type { SafeCommandReason } from "@lib/approvals.js";
|
||||
import type { ResponseFunctionToolCall } from "openai/resources/responses/responses.mjs";
|
||||
|
||||
import { isSafeCommand, type SafeCommandReason } from "../approvals.js";
|
||||
import { log } from "node:console";
|
||||
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
|
||||
// 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 unit‑testing small UI
|
||||
// helpers – continues to work without the full codex‑lib 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): {
|
||||
output: string;
|
||||
metadata: ExecOutputMetadata;
|
||||
@@ -175,10 +131,9 @@ function computeAutoApproval(cmd: Array<string>): SafeCommandReason | null {
|
||||
cmd.length === 3 &&
|
||||
cmd[0] === "bash" &&
|
||||
cmd[1] === "-lc" &&
|
||||
typeof cmd[2] === "string" &&
|
||||
shellQuoteParse
|
||||
typeof cmd[2] === "string"
|
||||
) {
|
||||
const parsed = shellQuoteParse(cmd[2], process.env ?? {});
|
||||
const parsed = parse(cmd[2], process.env ?? {});
|
||||
if (parsed.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user