-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtypes.ts
More file actions
87 lines (70 loc) · 2.73 KB
/
Copy pathtypes.ts
File metadata and controls
87 lines (70 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/** Which config(s) a plugin entry comes from. */
export type ConfigOrigin = "global" | "tui" | "tui-global";
/** A plugin entry that has been successfully parsed. */
export type ParsedEntry =
| { source: "npm"; name: string; version: string; configOrigin: ConfigOrigin }
| {
source: "git-github";
name: string;
owner: string;
repo: string;
version: string;
configOrigin: ConfigOrigin;
};
/** One plugin that has a newer version available. */
export type UpdateResult =
| { source: "npm"; name: string; pinned: string; latest: string; configOrigin: ConfigOrigin }
| {
source: "git-github";
name: string;
owner: string;
repo: string;
pinned: string;
latest: string;
configOrigin: ConfigOrigin;
};
/** Reason a raw plugin entry was dropped by the parser. */
export type DropReason = "unpinned-or-malformed" | "unsupported-git-host" | "git-ref-not-semver";
/** A raw plugin entry that could not be parsed, with a reason tag. */
export type DroppedEntry = { raw: string; reason: DropReason };
/** Persisted cache file schema. */
export type CacheEntry = {
latest: string;
fetchedAt: number;
};
export type Cache = {
version: 2;
entries: {
npm: Record<string, CacheEntry>; // key: package name
"git-github": Record<string, CacheEntry>; // key: "owner/repo"
};
};
// --- Dependency interfaces ---
/** Reads an environment variable. Returns undefined if unset. */
export type EnvReader = (key: string) => string | undefined;
/** Reads a file's text content. Throws if the file does not exist or is unreadable. */
export type FsReader = (path: string) => string;
/** Writes text to a file, creating parent directories as needed. Throws on error. */
export type FsWriter = (path: string, content: string) => void;
/** Renames (atomically moves) a file. Throws on error. */
export type FsRename = (from: string, to: string) => void;
/** Creates a directory, including any missing parents. Throws on error. */
export type FsMkdir = (path: string) => void;
/** Returns true if a path exists on the filesystem. */
export type FsExists = (path: string) => boolean;
/** Returns the user's home directory. */
export type HomeDir = () => string;
/** Returns the current time as a Unix timestamp in milliseconds. */
export type Clock = () => number;
/** Structured log function matching @opencode-ai/sdk App.log body. */
export type Logger = (entry: {
service: string;
level: "debug" | "info" | "warn" | "error";
message: string;
extra?: Record<string, unknown>;
}) => Promise<void>;
/** Fetches the latest published version of an npm package. */
export type RegistryFetcher = (
name: string,
opts: { fetch: typeof globalThis.fetch; timeoutMs: number },
) => Promise<string>;