fix(cli): preserve unsupported historical-source imports (#795)

This commit is contained in:
N0zoM1z0
2026-10-07 04:02:10 +08:00
committed by GitHub
parent b62931f833
commit 911d580634
8 changed files with 85 additions and 5 deletions
+2
View File
@@ -163,6 +163,8 @@ export const importReferenceSource = async (
if (!readResult.ok) {
const error = readResult.error;
if (error.code === "cancelled") return err(cancelled());
if (error.code === "unsupported")
return err(failure("unsupported", error.message));
return err(failure("io", error.message));
}
@@ -3,7 +3,7 @@ import type { ReferenceSourcePolicy } from "../domain/referenceSourcePolicy.js";
/** Typed expected failure returned by historical-source imports. */
export interface ReferenceSourceImportError {
readonly tag: "reference-source-import";
readonly code: "cancelled" | "invalid-root" | "io" | "parse";
readonly code: "cancelled" | "invalid-root" | "unsupported" | "io" | "parse";
readonly message: string;
}
@@ -23,6 +23,12 @@ export const projectReferenceSourceImportError = (
message:
"Reference source directory could not be opened. Check that the path exists, is readable, and points to a directory.",
};
if (error.code === "unsupported")
return {
category: "unsupported_host",
message:
"Safe no-follow file opens are unavailable on this host. Import the source tree with REA on Linux (including WSL) or macOS.",
};
if (error.code === "io")
return {
category: "execution_failure",
+6 -1
View File
@@ -4,7 +4,12 @@ import { isCliOperationFailure } from "../cliLogging.js";
const referenceSourceImportFailureSchema = z.strictObject({
error: z.literal("Import failed"),
category: z.enum(["cancelled", "invalid_input", "execution_failure"]),
category: z.enum([
"cancelled",
"invalid_input",
"unsupported_host",
"execution_failure",
]),
message: z.string().min(1),
});
+2 -1
View File
@@ -60,7 +60,7 @@ const successfulValues: readonly (readonly [string, unknown])[] = [
];
describe("reference-source import CLI failure classification", () => {
it.each(["cancelled", "invalid-root", "io", "parse"] as const)(
it.each(["cancelled", "invalid-root", "unsupported", "io", "parse"] as const)(
"recognizes the projected %s failure only at this command boundary",
(code) => {
const value = importFailure(code);
@@ -82,6 +82,7 @@ describe("reference-source import CLI logging seam", () => {
it.each([
["cancelled", importFailure("cancelled"), true],
["invalid-root", invalidRootFailure, true],
["unsupported", importFailure("unsupported"), true],
["io", importFailure("io"), true],
["parse", importFailure("parse"), true],
["configuration", configurationFailure, true],