@deepseek-ai/cordis-plugin-include 1.1.0 → 1.2.0-alpha.1
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/README.md +9 -3
- package/lib/index.js +410 -167
- package/lib/types/index.d.ts +47 -9
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/patch.d.ts +21 -20
- package/lib/types/patch.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +279 -61
- package/src/patch.ts +148 -135
package/README.md
CHANGED
|
@@ -35,16 +35,22 @@ Example `cordis.yml`:
|
|
|
35
35
|
|
|
36
36
|
| Field | Description |
|
|
37
37
|
| --- | --- |
|
|
38
|
-
| `path` | YAML or JSON file path resolved from `ctx.baseUrl
|
|
38
|
+
| `path` | YAML or JSON file path resolved from `ctx.baseUrl`; on Windows a drive-letter path is used as a file path. |
|
|
39
39
|
| `initial` | Entry list written when the file is missing. |
|
|
40
40
|
| `patches` | Runtime patches applied after reading the file. |
|
|
41
41
|
| `enableLogs` | Enables loader apply, reload, and unload logs. |
|
|
42
42
|
|
|
43
|
-
Patches can insert entries or override fields on entries with a matching `id`.
|
|
43
|
+
Patches can insert entries or override fields on entries with a matching `id`. A patch that replaces a group's `config` brings its own child entries, which later patches can address; the children it replaces can no longer be patched.
|
|
44
|
+
|
|
45
|
+
## File format and errors
|
|
46
|
+
|
|
47
|
+
YAML files are parsed as YAML 1.2 under the core schema with the `yaml` package, plus the `!!js` tag for Loader expressions. Unknown tags and aliases without a preceding anchor are rejected. The file must be a top-level array whose entries, including the entries of each group, are mappings. A file that cannot be read, parsed or validated rejects with `ConfigFileError`; parse and validation errors carry `issues`, each with a message and a `file:line:column` location, and JSON files report the position of their syntax error. Include implements `getLocation(id, path)` for its entries: values written in the file resolve to the file, values supplied by a patch resolve through the parent entry to that patch, and values changed at runtime but not yet written resolve to nothing.
|
|
48
|
+
|
|
49
|
+
Anonymous entries receive ids before the Loader sees them. An anonymous entry identical to one named on the previous read, under the same parent, keeps that id unless the file or an inserted patch row now uses it explicitly.
|
|
44
50
|
|
|
45
51
|
## Patch composition and persistence
|
|
46
52
|
|
|
47
|
-
`applyEntryPatches(data, patches, warn)` uses the same upstream algorithm as mounting. It clones file entries even without patches and clones inserted entry lists before indexing them, so later patches can address
|
|
53
|
+
`applyEntryPatches(data, patches, warn)` uses the same upstream algorithm as mounting and returns a `PatchResult`: the composed entries as `data`, and as `index` the owner of every entry and key, built from the patches that apply. It clones file entries even without patches and clones inserted entry lists and replaced group configs before indexing them, so later patches can address those rows without mutating the input lists. It writes generated ids for anonymous entries of a replaced group config into the patch itself, so callers that keep their patches unchanged pass clones. `parseEntryYaml(content)` and `stringifyEntryYaml(value, options)` read and write Include’s YAML dialect for configuration tools with the options Include uses for its own file, and `entryYamlErrorPosition(error)` locates a parse error. `stringifyEntryYaml` writes repeated references in full instead of as aliases; Include’s own writer may write a repeated reference as an alias. Nested entry expressions remain literal until their owning Loader entry evaluates them.
|
|
48
54
|
|
|
49
55
|
Tree mutations arrive through `commit(change)` and enter a journal. Include merges them with the latest file before writing; file edits win conflicts on the same fields and produce a diagnostic. Patch-owned fields and inserted entries update the parent Include’s patches instead of the included file. Invalid, missing or read-only files leave unsaved changes in memory.
|
|
50
56
|
|