@fro.bot/systematic 3.30.0 → 3.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HARNESSES.md +4 -4
- package/dist/cli.d.ts +13 -9
- package/dist/cli.js +140 -31
- package/dist/{index-jvpbpj9z.js → index-a5jd8n2y.js} +2432 -1698
- package/dist/index.js +1 -1
- package/dist/lib/config-schema.d.ts +2 -0
- package/dist/lib/config.d.ts +29 -9
- package/dist/lib/search-corpus.d.ts +40 -0
- package/dist/lib/search-exclude.d.ts +84 -0
- package/dist/lib/search-external-deciduous.d.ts +9 -2
- package/dist/lib/search-external-sources.d.ts +102 -3
- package/dist/lib/search-external.d.ts +2 -1
- package/dist/lib/search-user-config.d.ts +186 -13
- package/dist/pi.js +869 -248
- package/package.json +3 -2
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* carry the same `trust: 'project-or-higher'` meta inline here.
|
|
12
12
|
*
|
|
13
13
|
* Trust, per field: `enabled` and `allow_project_sources` are user-only (user
|
|
14
|
-
* config and `OPENCODE_CONFIG_DIR` config
|
|
14
|
+
* config and `OPENCODE_CONFIG_DIR` config, each with the `systematic.local`
|
|
15
|
+
* file beside it). A project config may set `sources`
|
|
15
16
|
* only. `config.ts` strips the two user-only fields from a project with
|
|
16
17
|
* per-path warnings, validates the project's `sources` with the validators
|
|
17
18
|
* here, and then discards them; the per-call reader is their only consumer.
|
|
@@ -44,6 +45,7 @@ export declare const SearchSourceSchema: z.ZodObject<{
|
|
|
44
45
|
}>;
|
|
45
46
|
roots: z.ZodArray<z.ZodString>;
|
|
46
47
|
projects: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
48
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
47
49
|
}, z.core.$strict>;
|
|
48
50
|
export type SearchSourceEntry = z.output<typeof SearchSourceSchema>;
|
|
49
51
|
/**
|
|
@@ -66,6 +68,7 @@ export declare const SearchSettingsSchema: z.ZodObject<{
|
|
|
66
68
|
}>;
|
|
67
69
|
roots: z.ZodArray<z.ZodString>;
|
|
68
70
|
projects: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
71
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
69
72
|
}, z.core.$strict>>>;
|
|
70
73
|
}, z.core.$strict>;
|
|
71
74
|
/** What a successful parse of the `search` block yields. Assignable to the core's `SearchSettings`. */
|
|
@@ -89,7 +92,48 @@ export interface SearchConfigValidation {
|
|
|
89
92
|
readonly structural: boolean;
|
|
90
93
|
/** Bounded warnings. They name fields and source names, never a value. */
|
|
91
94
|
readonly warnings: readonly string[];
|
|
95
|
+
/**
|
|
96
|
+
* Every source entry that was dropped whole, with the label the warning
|
|
97
|
+
* uses (`"name"`, or `#index` when the name is unusable) and the reason. A
|
|
98
|
+
* dropped exclude pattern is not listed here: its source stays.
|
|
99
|
+
*/
|
|
100
|
+
readonly dropped: readonly DroppedSearchEntry[];
|
|
101
|
+
/**
|
|
102
|
+
* Every entry of `sources`, in array order, with the warnings that entry
|
|
103
|
+
* produced. These are the same messages as in `warnings`, kept with the
|
|
104
|
+
* entry so a caller never has to match them by name.
|
|
105
|
+
*/
|
|
106
|
+
readonly entries: readonly SearchEntryOutcome[];
|
|
92
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* What validation made of one entry of a `sources` array. A kept outcome holds
|
|
110
|
+
* the validated entry itself, so the entry a merge keeps can be traced back to
|
|
111
|
+
* the warnings of its own declaration. `warnings` holds only the messages that
|
|
112
|
+
* were listed; a message past the cap is counted, not kept.
|
|
113
|
+
*/
|
|
114
|
+
export type SearchEntryOutcome = {
|
|
115
|
+
readonly kind: 'kept';
|
|
116
|
+
readonly index: number;
|
|
117
|
+
readonly label: string;
|
|
118
|
+
readonly entry: SearchSourceEntry;
|
|
119
|
+
readonly warnings: readonly string[];
|
|
120
|
+
} | {
|
|
121
|
+
readonly kind: 'dropped';
|
|
122
|
+
readonly index: number;
|
|
123
|
+
readonly label: string;
|
|
124
|
+
readonly reason: string;
|
|
125
|
+
readonly warnings: readonly string[];
|
|
126
|
+
};
|
|
127
|
+
/** One source entry the validator dropped, as the warning names it. */
|
|
128
|
+
export interface DroppedSearchEntry {
|
|
129
|
+
readonly label: string;
|
|
130
|
+
readonly reason: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Escape control characters and cap the length of a path before it goes into a
|
|
134
|
+
* warning. The CLI uses it for exception text too.
|
|
135
|
+
*/
|
|
136
|
+
export declare function displaySafe(text: string): string;
|
|
93
137
|
/**
|
|
94
138
|
* Validate a raw `search` value field by field and entry by entry, so a
|
|
95
139
|
* typo in `sources` can never lose `enabled: false`. This is the one
|
|
@@ -111,22 +155,40 @@ export declare function validateSearchConfig(value: unknown, trust: SearchConfig
|
|
|
111
155
|
export interface SearchSettingsSource {
|
|
112
156
|
readonly settings?: SearchSchemaOutput | undefined;
|
|
113
157
|
readonly unreadable: boolean;
|
|
158
|
+
/** The layer this source was read from. Callers that do not track layers leave it out. */
|
|
159
|
+
readonly layer?: UserLevelLayer | undefined;
|
|
114
160
|
}
|
|
115
161
|
export interface MergedSearchSettings {
|
|
116
162
|
readonly settings: SearchSchemaOutput | undefined;
|
|
117
163
|
readonly unreadable: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* The layer each surviving source entry came from, by source name: the layer
|
|
166
|
+
* of the last source that defined that name. Names defined only by sources
|
|
167
|
+
* with no `layer` are absent.
|
|
168
|
+
*/
|
|
169
|
+
readonly sourceLayers: ReadonlyMap<string, UserLevelLayer>;
|
|
118
170
|
}
|
|
119
171
|
/**
|
|
120
172
|
* The one merge rule, used by both `config.ts` and the reader. Sources arrive
|
|
121
|
-
* in priority order, user
|
|
122
|
-
* defines it, `allow_project_sources` is the union, and
|
|
123
|
-
* name with the later source
|
|
124
|
-
* `unreadable` is set when any source
|
|
173
|
+
* in priority order: user, user.local, custom, custom.local. `enabled` takes
|
|
174
|
+
* the last source that defines it, `allow_project_sources` is the union, and
|
|
175
|
+
* `sources` merge by name with the later source replacing the earlier entry
|
|
176
|
+
* whole (in the earlier entry's position). `unreadable` is set when any source
|
|
177
|
+
* was.
|
|
125
178
|
*/
|
|
126
179
|
export declare function mergeSearchSettings(sources: readonly SearchSettingsSource[]): MergedSearchSettings;
|
|
127
180
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
181
|
+
* Whether `target` is a directory entry, a symlink included. Selection asks
|
|
182
|
+
* this instead of `existsSync` because `existsSync` follows a link: a dangling
|
|
183
|
+
* link would read as absent, and a lower-priority file would win over it. An
|
|
184
|
+
* entry that cannot be inspected for a reason other than absence counts as
|
|
185
|
+
* present, so the read that follows reports it.
|
|
186
|
+
*/
|
|
187
|
+
export declare function configEntryExists(target: string): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Pick a config file in `dir`: `<basename>.jsonc` when its entry exists, else
|
|
190
|
+
* the `.json` path (returned even when absent, so callers that stat it still
|
|
191
|
+
* work). A dangling `.jsonc` link is selected, and its read reports it.
|
|
130
192
|
*/
|
|
131
193
|
export declare function selectConfigFile(dir: string, basename: string): string;
|
|
132
194
|
export interface UserLevelConfigDirOptions {
|
|
@@ -146,17 +208,121 @@ export interface UserLevelConfigDirs {
|
|
|
146
208
|
* a blank value counts as unset. `config.ts` and the reader both call this.
|
|
147
209
|
*/
|
|
148
210
|
export declare function resolveUserLevelConfigDirs(options?: UserLevelConfigDirOptions): UserLevelConfigDirs;
|
|
211
|
+
/** The four user-level layers, in the order their search settings merge. */
|
|
212
|
+
export type UserLevelLayer = 'user' | 'user.local' | 'custom' | 'custom.local';
|
|
213
|
+
/** One selected user-level file: the layer it feeds and the path to read. */
|
|
214
|
+
export interface UserLevelConfigFile {
|
|
215
|
+
readonly layer: UserLevelLayer;
|
|
216
|
+
readonly path: string;
|
|
217
|
+
}
|
|
218
|
+
export interface UserLevelFileSelection {
|
|
219
|
+
/**
|
|
220
|
+
* The selected files in layer order: user, user.local, then custom and
|
|
221
|
+
* custom.local when a custom directory is set. A local file is selected even
|
|
222
|
+
* when its sibling is absent, and the path of an absent file is still
|
|
223
|
+
* returned (`selectConfigFile` rule).
|
|
224
|
+
*/
|
|
225
|
+
readonly files: readonly UserLevelConfigFile[];
|
|
226
|
+
/**
|
|
227
|
+
* The custom directory is the user directory, spelled the same way or
|
|
228
|
+
* reached through a symlink. The custom layers stay in `files` so the custom
|
|
229
|
+
* file keeps its precedence, but they name the same two files as `user` and
|
|
230
|
+
* `user.local`: a reader reads each file once and reuses the result.
|
|
231
|
+
*/
|
|
232
|
+
readonly aliased: boolean;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Pick the user-level config files for the resolved directories. The
|
|
236
|
+
* basenames are `systematic` and `systematic.local`, each choosing `.jsonc`
|
|
237
|
+
* before `.json`. Selection looks at existence only, never validity.
|
|
238
|
+
*/
|
|
239
|
+
export declare function selectUserLevelConfigFiles(dirs: UserLevelConfigDirs): UserLevelFileSelection;
|
|
240
|
+
export interface ProjectConfigSelection {
|
|
241
|
+
/** The project file to read. When none exists, the `.opencode/systematic.json` path. */
|
|
242
|
+
readonly path: string;
|
|
243
|
+
/**
|
|
244
|
+
* The `.opencode/` file a repo-root file shadowed. Present only when a root
|
|
245
|
+
* file won and an `.opencode/` file also exists.
|
|
246
|
+
*/
|
|
247
|
+
readonly ignoredPath?: string;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Pick the project config file under the repository root: `.systematic.jsonc`,
|
|
251
|
+
* else `.systematic.json`, else `.opencode/systematic.jsonc`, else
|
|
252
|
+
* `.opencode/systematic.json`. A root file wins even when invalid; selection
|
|
253
|
+
* looks at the directory entry only (a dangling link is a file that exists)
|
|
254
|
+
* and never falls back past a broken file.
|
|
255
|
+
*/
|
|
256
|
+
export declare function selectProjectConfigFile(repoRoot: string): ProjectConfigSelection;
|
|
257
|
+
/**
|
|
258
|
+
* The start directory's own `.opencode/systematic.*` file when the repository
|
|
259
|
+
* root is a different directory: a file that is never read, because project
|
|
260
|
+
* config comes from the root. `repoRoot` is the lookup of the start directory
|
|
261
|
+
* (`lookupSearchRoot`). The file is not reported when it is the selected one
|
|
262
|
+
* (the same file reached through a link). Both the config loader and the
|
|
263
|
+
* per-call reader ask this, so they warn under the same condition.
|
|
264
|
+
*/
|
|
265
|
+
export declare function findStartDirProjectConfig(startDir: string, repoRoot: {
|
|
266
|
+
readonly root: string;
|
|
267
|
+
readonly foundGit: boolean;
|
|
268
|
+
}, selectedProjectConfig: string): string | undefined;
|
|
269
|
+
/**
|
|
270
|
+
* The warning for a start directory's own project file that is not read.
|
|
271
|
+
* `safe` makes each path fit for a message; the config loader passes its own
|
|
272
|
+
* sanitizer, and the default is `displaySafe`.
|
|
273
|
+
*/
|
|
274
|
+
export declare function startDirProjectWarning(startDirConfig: string, projectRoot: string, selectedProjectConfig: string, safe?: (text: string) => string): string;
|
|
149
275
|
export interface UserLevelSearchLoad {
|
|
150
276
|
readonly settings: SearchSchemaOutput | undefined;
|
|
151
277
|
readonly warnings: readonly string[];
|
|
152
278
|
readonly unreadable: boolean;
|
|
279
|
+
/**
|
|
280
|
+
* Every source entry the validator dropped whole, across the files read,
|
|
281
|
+
* with the label the warning uses and the reason.
|
|
282
|
+
*/
|
|
283
|
+
readonly dropped: readonly DroppedSearchEntry[];
|
|
284
|
+
/**
|
|
285
|
+
* Every entry of `sources` in every file read, in file order then array
|
|
286
|
+
* order, with the warnings that entry produced (`SearchEntryOutcome`). A
|
|
287
|
+
* file two layers share is listed once.
|
|
288
|
+
*/
|
|
289
|
+
readonly entries: readonly SearchEntryOutcome[];
|
|
290
|
+
/** The layer each surviving source entry came from, by source name (`mergeSearchSettings`). */
|
|
291
|
+
readonly sourceLayers: ReadonlyMap<string, UserLevelLayer>;
|
|
292
|
+
/**
|
|
293
|
+
* The subset of `warnings` that report a file that could not be read or
|
|
294
|
+
* parsed, as opposed to a problem inside a readable `search` block. A caller
|
|
295
|
+
* that already named those files can leave them out.
|
|
296
|
+
*/
|
|
297
|
+
readonly readFailures: readonly string[];
|
|
153
298
|
}
|
|
299
|
+
export type TextRead = {
|
|
300
|
+
readonly kind: 'absent';
|
|
301
|
+
} | {
|
|
302
|
+
readonly kind: 'failed';
|
|
303
|
+
readonly reason: string;
|
|
304
|
+
} | {
|
|
305
|
+
readonly kind: 'text';
|
|
306
|
+
readonly content: string;
|
|
307
|
+
};
|
|
154
308
|
/** Largest project config file the bin-safe project reader accepts. */
|
|
155
309
|
export declare const MAX_PROJECT_CONFIG_BYTES: number;
|
|
156
310
|
/**
|
|
157
|
-
* Read
|
|
158
|
-
*
|
|
159
|
-
*
|
|
311
|
+
* Read a text file with the shared bounded fd read: never more than
|
|
312
|
+
* `maxBytes + 1` bytes, regular files only, and a non-blocking open so a FIFO
|
|
313
|
+
* planted at the path cannot hang the reader.
|
|
314
|
+
*/
|
|
315
|
+
export declare function readTextBounded(filePath: string, maxBytes: number): TextRead;
|
|
316
|
+
/**
|
|
317
|
+
* Read the `search` block from the user-level files and merge them: user,
|
|
318
|
+
* user.local, then custom and custom.local when a custom directory is set. A
|
|
319
|
+
* local file is read with or without its sibling. It never reads project
|
|
320
|
+
* config and never throws: an unparseable file or an invalid block gives one
|
|
321
|
+
* warning and `unreadable: true`, and the valid remainder still merges.
|
|
322
|
+
*
|
|
323
|
+
* When the custom directory is the user directory, each file is read once and
|
|
324
|
+
* its diagnostics are reported once; the custom layers still take their
|
|
325
|
+
* place in the merge order.
|
|
160
326
|
*/
|
|
161
327
|
export declare function loadUserLevelSearchSettings(options?: UserLevelConfigDirOptions): UserLevelSearchLoad;
|
|
162
328
|
export interface ProjectSearchLoad {
|
|
@@ -171,12 +337,19 @@ export interface ProjectSearchLoad {
|
|
|
171
337
|
* alone does not set it. This is not the user-config `config unreadable` note.
|
|
172
338
|
*/
|
|
173
339
|
readonly unreadable: boolean;
|
|
340
|
+
/** Every source entry dropped whole, with the label the warning uses and the reason. */
|
|
341
|
+
readonly dropped: readonly DroppedSearchEntry[];
|
|
342
|
+
/** Every entry of the file's `sources`, in array order, with the warnings that entry produced. */
|
|
343
|
+
readonly entries: readonly SearchEntryOutcome[];
|
|
174
344
|
}
|
|
175
345
|
/**
|
|
176
346
|
* Read the sources a project config proposes, from the checkout root's
|
|
177
|
-
* `.
|
|
178
|
-
*
|
|
179
|
-
*
|
|
347
|
+
* project file: `.systematic.jsonc`, else `.systematic.json`, else
|
|
348
|
+
* `.opencode/systematic.jsonc`, else `.opencode/systematic.json`
|
|
349
|
+
* (`selectProjectConfigFile`). A root file shadowing an `.opencode/` file is
|
|
350
|
+
* reported in `warnings`; the two are never merged, and a broken winner never
|
|
351
|
+
* falls back. Bin-safe: it needs no `config.ts`. The read is capped at
|
|
352
|
+
* `MAX_PROJECT_CONFIG_BYTES`, the file is validated with the project rules
|
|
180
353
|
* (`sources` only; `enabled` and `allow_project_sources` are never read), and
|
|
181
354
|
* it never throws. A missing file or a missing `search` block is normal.
|
|
182
355
|
*/
|