Open History to see the last commit
1import { Schema } from "effect";
2import { TrimmedNonEmptyString } from "./baseSchemas.ts";
3
4export const EditorLaunchStyle = Schema.Literals(["direct-path", "goto", "line-column"]);
5export type EditorLaunchStyle = typeof EditorLaunchStyle.Type;
6
7type EditorDefinition = {
8 readonly id: string;
9 readonly label: string;
10 readonly commands: readonly [string, ...string[]] | null;
11 readonly baseArgs?: readonly string[];
12 readonly launchStyle: EditorLaunchStyle;
13};
14
15export const EDITORS = [
16 { id: "cursor", label: "Cursor", commands: ["cursor"], launchStyle: "goto" },
17 { id: "trae", label: "Trae", commands: ["trae"], launchStyle: "goto" },
18 { id: "kiro", label: "Kiro", commands: ["kiro"], baseArgs: ["ide"], launchStyle: "goto" },
19 { id: "vscode", label: "VS Code", commands: ["code"], launchStyle: "goto" },
20 {
21 id: "vscode-insiders",
22 label: "VS Code Insiders",
23 commands: ["code-insiders"],
24 launchStyle: "goto",
25 },
26 { id: "vscodium", label: "VSCodium", commands: ["codium"], launchStyle: "goto" },
27 { id: "zed", label: "Zed", commands: ["zed", "zeditor"], launchStyle: "direct-path" },
28 { id: "antigravity", label: "Antigravity", commands: ["agy"], launchStyle: "goto" },
29 { id: "idea", label: "IntelliJ IDEA", commands: ["idea"], launchStyle: "line-column" },
30 { id: "file-manager", label: "File Manager", commands: null, launchStyle: "direct-path" },
31] as const satisfies ReadonlyArray<EditorDefinition>;
32
33export const EditorId = Schema.Literals(EDITORS.map((e) => e.id));
34export type EditorId = typeof EditorId.Type;
35
36export const OpenInEditorInput = Schema.Struct({
37 cwd: TrimmedNonEmptyString,
38 editor: EditorId,
39});
40export type OpenInEditorInput = typeof OpenInEditorInput.Type;
41
42export class OpenError extends Schema.TaggedErrorClass<OpenError>()("OpenError", {
43 message: Schema.String,
44 cause: Schema.optional(Schema.Defect),
45}) {}