@vibe-agent-toolkit/resources 0.1.37 → 0.1.38
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 +2 -2
- package/dist/ajv-factory.d.ts +33 -0
- package/dist/ajv-factory.d.ts.map +1 -0
- package/dist/ajv-factory.js +51 -0
- package/dist/ajv-factory.js.map +1 -0
- package/dist/config-parser.d.ts +0 -18
- package/dist/config-parser.d.ts.map +1 -1
- package/dist/config-parser.js +5 -46
- package/dist/config-parser.js.map +1 -1
- package/dist/frontmatter-editor.d.ts +45 -0
- package/dist/frontmatter-editor.d.ts.map +1 -0
- package/dist/frontmatter-editor.js +161 -0
- package/dist/frontmatter-editor.js.map +1 -0
- package/dist/frontmatter-validator.d.ts.map +1 -1
- package/dist/frontmatter-validator.js +11 -6
- package/dist/frontmatter-validator.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/json-pointer-path.d.ts +13 -0
- package/dist/json-pointer-path.d.ts.map +1 -0
- package/dist/json-pointer-path.js +30 -0
- package/dist/json-pointer-path.js.map +1 -0
- package/dist/link-parser.js +2 -11
- package/dist/link-parser.js.map +1 -1
- package/dist/link-validator.d.ts +22 -0
- package/dist/link-validator.d.ts.map +1 -1
- package/dist/link-validator.js +126 -75
- package/dist/link-validator.js.map +1 -1
- package/dist/rewriter-helpers.d.ts +49 -0
- package/dist/rewriter-helpers.d.ts.map +1 -0
- package/dist/rewriter-helpers.js +142 -0
- package/dist/rewriter-helpers.js.map +1 -0
- package/dist/types/resource-parser.d.ts.map +1 -1
- package/dist/types/resource-parser.js +2 -3
- package/dist/types/resource-parser.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +40 -11
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +39 -13
- package/dist/utils.js.map +1 -1
- package/package.json +5 -5
- package/src/ajv-factory.ts +56 -0
- package/src/config-parser.ts +5 -51
- package/src/frontmatter-editor.ts +214 -0
- package/src/frontmatter-validator.ts +11 -7
- package/src/index.ts +21 -2
- package/src/json-pointer-path.ts +29 -0
- package/src/link-parser.ts +2 -11
- package/src/link-validator.ts +153 -88
- package/src/rewriter-helpers.ts +166 -0
- package/src/types/resource-parser.ts +2 -3
- package/src/types.ts +0 -1
- package/src/utils.ts +57 -14
package/README.md
CHANGED
|
@@ -1082,7 +1082,7 @@ Valid by default.
|
|
|
1082
1082
|
|
|
1083
1083
|
## Related Packages
|
|
1084
1084
|
|
|
1085
|
-
- [@vibe-agent-toolkit/utils](../utils) - Core shared utilities
|
|
1085
|
+
- [@vibe-agent-toolkit/utils](../utils/README.md) - Core shared utilities
|
|
1086
1086
|
|
|
1087
1087
|
## Future Enhancements
|
|
1088
1088
|
|
|
@@ -1098,7 +1098,7 @@ Planned features for future releases:
|
|
|
1098
1098
|
|
|
1099
1099
|
## Documentation
|
|
1100
1100
|
|
|
1101
|
-
- [Project Documentation](../../docs)
|
|
1101
|
+
- [Project Documentation](../../docs/README.md)
|
|
1102
1102
|
- [Architecture](../../docs/architecture/README.md)
|
|
1103
1103
|
|
|
1104
1104
|
## License
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ajv factory for adopters consuming VAT-generated schemas.
|
|
3
|
+
*
|
|
4
|
+
* VAT's frontmatter walker treats `format: "uri-reference"` (plus `uri`,
|
|
5
|
+
* `iri`, `iri-reference`) as first-class URI families and validates the
|
|
6
|
+
* referenced files via {@link import('./utils.js').resolveLocalHref}, not via
|
|
7
|
+
* Ajv. But adopters consuming the same schemas with vanilla
|
|
8
|
+
* `new Ajv(...)` hit Ajv's default strict mode, which upgrades
|
|
9
|
+
* `unknown format "uri-reference" ignored` from a warning to a thrown error.
|
|
10
|
+
*
|
|
11
|
+
* This helper returns an Ajv instance with the standard JSON Schema format
|
|
12
|
+
* vocabulary registered (via `ajv-formats`) plus no-op shims for
|
|
13
|
+
* `iri` / `iri-reference` (which `ajv-formats` does not ship). All
|
|
14
|
+
* URI-family schemas compile cleanly under strict mode.
|
|
15
|
+
*/
|
|
16
|
+
import { Ajv, type Options as AjvOptions } from 'ajv';
|
|
17
|
+
/**
|
|
18
|
+
* Construct an Ajv instance pre-registered with the URI-family formats VAT
|
|
19
|
+
* schemas use. Use this anywhere downstream code compiles a schema that may
|
|
20
|
+
* reference `format: "uri-reference"` (or `uri`, `iri`, `iri-reference`).
|
|
21
|
+
*
|
|
22
|
+
* @param options - Ajv options. Passed through unchanged — caller controls
|
|
23
|
+
* `allErrors`, `strict`, `allowUnionTypes`, `verbose`, etc.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* import { createAjvWithUriFormats } from '@vibe-agent-toolkit/resources';
|
|
27
|
+
*
|
|
28
|
+
* const ajv = createAjvWithUriFormats({ allErrors: true });
|
|
29
|
+
* const validate = ajv.compile(mySchemaWithUriReference);
|
|
30
|
+
* if (!validate(data)) console.error(validate.errors);
|
|
31
|
+
*/
|
|
32
|
+
export declare function createAjvWithUriFormats(options?: AjvOptions): Ajv;
|
|
33
|
+
//# sourceMappingURL=ajv-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ajv-factory.d.ts","sourceRoot":"","sources":["../src/ajv-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,GAAG,EAAE,KAAK,OAAO,IAAI,UAAU,EAAE,MAAM,KAAK,CAAC;AActD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,UAAe,GAAG,GAAG,CAUrE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ajv factory for adopters consuming VAT-generated schemas.
|
|
3
|
+
*
|
|
4
|
+
* VAT's frontmatter walker treats `format: "uri-reference"` (plus `uri`,
|
|
5
|
+
* `iri`, `iri-reference`) as first-class URI families and validates the
|
|
6
|
+
* referenced files via {@link import('./utils.js').resolveLocalHref}, not via
|
|
7
|
+
* Ajv. But adopters consuming the same schemas with vanilla
|
|
8
|
+
* `new Ajv(...)` hit Ajv's default strict mode, which upgrades
|
|
9
|
+
* `unknown format "uri-reference" ignored` from a warning to a thrown error.
|
|
10
|
+
*
|
|
11
|
+
* This helper returns an Ajv instance with the standard JSON Schema format
|
|
12
|
+
* vocabulary registered (via `ajv-formats`) plus no-op shims for
|
|
13
|
+
* `iri` / `iri-reference` (which `ajv-formats` does not ship). All
|
|
14
|
+
* URI-family schemas compile cleanly under strict mode.
|
|
15
|
+
*/
|
|
16
|
+
import { Ajv } from 'ajv';
|
|
17
|
+
// ajv-formats is a CJS module published with `module.exports = formatsPlugin`
|
|
18
|
+
// plus an `exports.default` alias. Under NodeNext module resolution the
|
|
19
|
+
// default import is typed as the namespace object (not callable), even
|
|
20
|
+
// though the runtime value IS the plugin function. The `.default ??
|
|
21
|
+
// namespace` pattern below resolves both at type level and runtime.
|
|
22
|
+
import * as ajvFormatsModule from 'ajv-formats';
|
|
23
|
+
const addFormats = ajvFormatsModule.default ??
|
|
24
|
+
ajvFormatsModule;
|
|
25
|
+
/**
|
|
26
|
+
* Construct an Ajv instance pre-registered with the URI-family formats VAT
|
|
27
|
+
* schemas use. Use this anywhere downstream code compiles a schema that may
|
|
28
|
+
* reference `format: "uri-reference"` (or `uri`, `iri`, `iri-reference`).
|
|
29
|
+
*
|
|
30
|
+
* @param options - Ajv options. Passed through unchanged — caller controls
|
|
31
|
+
* `allErrors`, `strict`, `allowUnionTypes`, `verbose`, etc.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* import { createAjvWithUriFormats } from '@vibe-agent-toolkit/resources';
|
|
35
|
+
*
|
|
36
|
+
* const ajv = createAjvWithUriFormats({ allErrors: true });
|
|
37
|
+
* const validate = ajv.compile(mySchemaWithUriReference);
|
|
38
|
+
* if (!validate(data)) console.error(validate.errors);
|
|
39
|
+
*/
|
|
40
|
+
export function createAjvWithUriFormats(options = {}) {
|
|
41
|
+
const ajv = new Ajv(options);
|
|
42
|
+
addFormats(ajv);
|
|
43
|
+
// ajv-formats does not register `iri` / `iri-reference`. Adopters whose
|
|
44
|
+
// schemas declare those would still hit "unknown format" under strict
|
|
45
|
+
// mode. Register no-op validators — Ajv accepts the format token, and
|
|
46
|
+
// semantic validation happens through resolveLocalHref / equivalent.
|
|
47
|
+
ajv.addFormat('iri', true);
|
|
48
|
+
ajv.addFormat('iri-reference', true);
|
|
49
|
+
return ajv;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=ajv-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ajv-factory.js","sourceRoot":"","sources":["../src/ajv-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,GAAG,EAA8B,MAAM,KAAK,CAAC;AACtD,8EAA8E;AAC9E,wEAAwE;AACxE,uEAAuE;AACvE,oEAAoE;AACpE,oEAAoE;AACpE,OAAO,KAAK,gBAAgB,MAAM,aAAa,CAAC;AAIhD,MAAM,UAAU,GACb,gBAA0D,CAAC,OAAO;IAClE,gBAA4C,CAAC;AAEhD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,uBAAuB,CAAC,UAAsB,EAAE;IAC9D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,UAAU,CAAC,GAAG,CAAC,CAAC;IAChB,wEAAwE;IACxE,sEAAsE;IACtE,sEAAsE;IACtE,qEAAqE;IACrE,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC3B,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;IACrC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/config-parser.d.ts
CHANGED
|
@@ -4,24 +4,6 @@
|
|
|
4
4
|
* Discovers and parses project configuration files with directory tree walk-up.
|
|
5
5
|
*/
|
|
6
6
|
import { type ProjectConfig } from './schemas/project-config.js';
|
|
7
|
-
/**
|
|
8
|
-
* Find the config file by walking up the directory tree.
|
|
9
|
-
*
|
|
10
|
-
* Starts from the current directory and walks up until the config file is found
|
|
11
|
-
* or the root directory is reached.
|
|
12
|
-
*
|
|
13
|
-
* @param startDir - Directory to start searching from (default: process.cwd())
|
|
14
|
-
* @returns Absolute path to config file, or undefined if not found
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const configPath = await findConfigFile();
|
|
19
|
-
* if (configPath) {
|
|
20
|
-
* console.log(`Found config: ${configPath}`);
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare function findConfigFile(startDir?: string): Promise<string | undefined>;
|
|
25
7
|
/**
|
|
26
8
|
* Parse a project configuration file.
|
|
27
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-parser.d.ts","sourceRoot":"","sources":["../src/config-parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"config-parser.d.ts","sourceRoot":"","sources":["../src/config-parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEtF;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAqBhF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,UAAU,CAAC,QAAQ,GAAE,MAAsB,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAQrG"}
|
package/dist/config-parser.js
CHANGED
|
@@ -4,50 +4,9 @@
|
|
|
4
4
|
* Discovers and parses project configuration files with directory tree walk-up.
|
|
5
5
|
*/
|
|
6
6
|
import { readFile } from 'node:fs/promises';
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import { CORE_SCHEMA, load as loadYaml } from 'js-yaml';
|
|
7
|
+
import { findConfigFile } from '@vibe-agent-toolkit/utils';
|
|
8
|
+
import { parse as parseYaml } from 'yaml';
|
|
10
9
|
import { ProjectConfigSchema } from './schemas/project-config.js';
|
|
11
|
-
const CONFIG_FILENAME = 'vibe-agent-toolkit.config.yaml';
|
|
12
|
-
/**
|
|
13
|
-
* Find the config file by walking up the directory tree.
|
|
14
|
-
*
|
|
15
|
-
* Starts from the current directory and walks up until the config file is found
|
|
16
|
-
* or the root directory is reached.
|
|
17
|
-
*
|
|
18
|
-
* @param startDir - Directory to start searching from (default: process.cwd())
|
|
19
|
-
* @returns Absolute path to config file, or undefined if not found
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* const configPath = await findConfigFile();
|
|
24
|
-
* if (configPath) {
|
|
25
|
-
* console.log(`Found config: ${configPath}`);
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export async function findConfigFile(startDir = process.cwd()) {
|
|
30
|
-
let currentDir = safePath.resolve(startDir);
|
|
31
|
-
const { root } = path.parse(currentDir);
|
|
32
|
-
while (true) {
|
|
33
|
-
const configPath = safePath.join(currentDir, CONFIG_FILENAME);
|
|
34
|
-
try {
|
|
35
|
-
// Check if file exists by attempting to read metadata
|
|
36
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- constructing path during tree walk
|
|
37
|
-
await readFile(configPath, 'utf-8');
|
|
38
|
-
return configPath;
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
// File doesn't exist, continue walking up
|
|
42
|
-
}
|
|
43
|
-
// Check if we've reached the root
|
|
44
|
-
if (currentDir === root) {
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
// Move up one directory
|
|
48
|
-
currentDir = path.dirname(currentDir);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
10
|
/**
|
|
52
11
|
* Parse a project configuration file.
|
|
53
12
|
*
|
|
@@ -71,8 +30,7 @@ export async function parseConfigFile(configPath) {
|
|
|
71
30
|
// Parse YAML
|
|
72
31
|
let parsed;
|
|
73
32
|
try {
|
|
74
|
-
|
|
75
|
-
parsed = loadYaml(content, { schema: CORE_SCHEMA });
|
|
33
|
+
parsed = parseYaml(content);
|
|
76
34
|
}
|
|
77
35
|
catch (error) {
|
|
78
36
|
throw new Error(`Invalid YAML in config file: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -106,7 +64,8 @@ export async function parseConfigFile(configPath) {
|
|
|
106
64
|
* ```
|
|
107
65
|
*/
|
|
108
66
|
export async function loadConfig(startDir = process.cwd()) {
|
|
109
|
-
|
|
67
|
+
// findConfigFile from utils is synchronous; awaiting a non-promise is a no-op.
|
|
68
|
+
const configPath = findConfigFile(startDir);
|
|
110
69
|
if (!configPath) {
|
|
111
70
|
return undefined;
|
|
112
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-parser.js","sourceRoot":"","sources":["../src/config-parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"config-parser.js","sourceRoot":"","sources":["../src/config-parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAsB,MAAM,6BAA6B,CAAC;AAEtF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,UA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 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FrontmatterEditor — round-trip-safe primitive for editing YAML frontmatter
|
|
3
|
+
* in markdown files.
|
|
4
|
+
*
|
|
5
|
+
* Public surface: openFrontmatter(markdown) → FrontmatterEditor.
|
|
6
|
+
*
|
|
7
|
+
* Round-trip identity contract: openFrontmatter(x).toString() === x for any
|
|
8
|
+
* well-formed input, byte-for-byte. Mutations preserve comments, blank lines,
|
|
9
|
+
* key ordering, quoting style, and detected EOL.
|
|
10
|
+
*
|
|
11
|
+
* See docs/superpowers/specs/2026-05-17-frontmatter-editor-and-yaml-consolidation-design.md
|
|
12
|
+
* §5 for the full contract.
|
|
13
|
+
*/
|
|
14
|
+
export declare class FrontmatterParseError extends Error {
|
|
15
|
+
readonly cause: unknown;
|
|
16
|
+
constructor(message: string, cause: unknown);
|
|
17
|
+
}
|
|
18
|
+
/** Path to a value in the parsed frontmatter document. */
|
|
19
|
+
export type FrontmatterPath = string | readonly (string | number)[];
|
|
20
|
+
/** Scalar value type accepted by mutation methods. */
|
|
21
|
+
export type FrontmatterScalar = string | number | boolean | null;
|
|
22
|
+
export interface FrontmatterEditor {
|
|
23
|
+
body: string;
|
|
24
|
+
get(path: FrontmatterPath): unknown;
|
|
25
|
+
set(path: FrontmatterPath, value: FrontmatterScalar): void;
|
|
26
|
+
setArrayItem(path: FrontmatterPath, index: number, value: FrontmatterScalar): void;
|
|
27
|
+
appendArrayItem(path: FrontmatterPath, value: FrontmatterScalar): void;
|
|
28
|
+
delete(path: FrontmatterPath): void;
|
|
29
|
+
toString(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Returns true if any mutating method has been called or `body` was
|
|
32
|
+
* reassigned to a different string. Use to gate writeFileSync and avoid
|
|
33
|
+
* the no-op-rewrite churn described in §"What's preserved, what isn't"
|
|
34
|
+
* of the markdown-rewriting skill.
|
|
35
|
+
*
|
|
36
|
+
* **Caveat:** any call to `set` / `setArrayItem` / `appendArrayItem` /
|
|
37
|
+
* `delete` flips the flag, even if the underlying value didn't change
|
|
38
|
+
* (e.g. `set('foo', sameValue)`). For strict byte-level dirty detection
|
|
39
|
+
* compare `editor.toString() !== originalText` instead. `body =` is the
|
|
40
|
+
* one exception — it only flips dirty on actual string change.
|
|
41
|
+
*/
|
|
42
|
+
isDirty(): boolean;
|
|
43
|
+
}
|
|
44
|
+
export declare function openFrontmatter(markdown: string): FrontmatterEditor;
|
|
45
|
+
//# sourceMappingURL=frontmatter-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-editor.d.ts","sourceRoot":"","sources":["../src/frontmatter-editor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,SAAyB,KAAK,EAAE,OAAO,CAAC;gBAE5B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAK5C;AAED,0DAA0D;AAC1D,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;AAEpE,sDAAsD;AACtD,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAEjE,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC;IACpC,GAAG,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC3D,YAAY,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACnF,eAAe,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACvE,MAAM,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;IACpC,QAAQ,IAAI,MAAM,CAAC;IACnB;;;;;;;;;;;OAWG;IACH,OAAO,IAAI,OAAO,CAAC;CACpB;AA8JD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAEnE"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FrontmatterEditor — round-trip-safe primitive for editing YAML frontmatter
|
|
3
|
+
* in markdown files.
|
|
4
|
+
*
|
|
5
|
+
* Public surface: openFrontmatter(markdown) → FrontmatterEditor.
|
|
6
|
+
*
|
|
7
|
+
* Round-trip identity contract: openFrontmatter(x).toString() === x for any
|
|
8
|
+
* well-formed input, byte-for-byte. Mutations preserve comments, blank lines,
|
|
9
|
+
* key ordering, quoting style, and detected EOL.
|
|
10
|
+
*
|
|
11
|
+
* See docs/superpowers/specs/2026-05-17-frontmatter-editor-and-yaml-consolidation-design.md
|
|
12
|
+
* §5 for the full contract.
|
|
13
|
+
*/
|
|
14
|
+
import { Document, parseDocument } from 'yaml';
|
|
15
|
+
export class FrontmatterParseError extends Error {
|
|
16
|
+
cause;
|
|
17
|
+
constructor(message, cause) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = 'FrontmatterParseError';
|
|
20
|
+
this.cause = cause;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const OPENING_FENCE = /^---\r?\n/;
|
|
24
|
+
// Closing fence: either immediately after opening (empty frontmatter), or
|
|
25
|
+
// preceded by a newline. Trailing variants accept newline or EOF.
|
|
26
|
+
const EMPTY_CLOSING_FENCE = /^---(?:\r?\n|$)/;
|
|
27
|
+
const CLOSING_FENCE = /(?:\r?\n---\r?\n|\r?\n---$)/;
|
|
28
|
+
function detectEol(input) {
|
|
29
|
+
const firstBreak = input.indexOf('\n');
|
|
30
|
+
if (firstBreak === -1)
|
|
31
|
+
return '\n';
|
|
32
|
+
return firstBreak > 0 && input.charAt(firstBreak - 1) === '\r' ? '\r\n' : '\n';
|
|
33
|
+
}
|
|
34
|
+
function splitFrontmatter(input) {
|
|
35
|
+
const eol = detectEol(input);
|
|
36
|
+
const openingMatch = OPENING_FENCE.exec(input);
|
|
37
|
+
if (!openingMatch) {
|
|
38
|
+
return { hasFrontmatter: false, frontmatterText: '', body: input, eol };
|
|
39
|
+
}
|
|
40
|
+
const afterOpening = input.slice(openingMatch[0].length);
|
|
41
|
+
// Handle empty frontmatter (closing fence immediately follows opening fence)
|
|
42
|
+
const emptyMatch = EMPTY_CLOSING_FENCE.exec(afterOpening);
|
|
43
|
+
if (emptyMatch) {
|
|
44
|
+
const bodyStart = emptyMatch[0].length;
|
|
45
|
+
return {
|
|
46
|
+
hasFrontmatter: true,
|
|
47
|
+
frontmatterText: '',
|
|
48
|
+
body: afterOpening.slice(bodyStart),
|
|
49
|
+
eol,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const closingMatch = CLOSING_FENCE.exec(afterOpening);
|
|
53
|
+
if (!closingMatch) {
|
|
54
|
+
return { hasFrontmatter: false, frontmatterText: '', body: input, eol };
|
|
55
|
+
}
|
|
56
|
+
const frontmatterText = afterOpening.slice(0, closingMatch.index);
|
|
57
|
+
const bodyStart = closingMatch.index + closingMatch[0].length;
|
|
58
|
+
const body = afterOpening.slice(bodyStart);
|
|
59
|
+
return { hasFrontmatter: true, frontmatterText, body, eol };
|
|
60
|
+
}
|
|
61
|
+
class FrontmatterEditorImpl {
|
|
62
|
+
doc;
|
|
63
|
+
hasFrontmatter;
|
|
64
|
+
eol;
|
|
65
|
+
_body;
|
|
66
|
+
_dirty = false;
|
|
67
|
+
get body() {
|
|
68
|
+
return this._body;
|
|
69
|
+
}
|
|
70
|
+
set body(value) {
|
|
71
|
+
if (value !== this._body) {
|
|
72
|
+
this._body = value;
|
|
73
|
+
this._dirty = true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
isDirty() {
|
|
77
|
+
return this._dirty;
|
|
78
|
+
}
|
|
79
|
+
constructor(input) {
|
|
80
|
+
const split = splitFrontmatter(input);
|
|
81
|
+
this.hasFrontmatter = split.hasFrontmatter;
|
|
82
|
+
this.eol = split.eol;
|
|
83
|
+
this._body = split.body;
|
|
84
|
+
if (!split.hasFrontmatter) {
|
|
85
|
+
this.doc = new Document({});
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
this.doc = parseDocument(split.frontmatterText, { prettyErrors: true });
|
|
90
|
+
if (this.doc.errors.length > 0) {
|
|
91
|
+
throw new FrontmatterParseError(`Invalid YAML frontmatter: ${this.doc.errors[0]?.message ?? 'unknown error'}`, this.doc.errors[0]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
if (error instanceof FrontmatterParseError)
|
|
96
|
+
throw error;
|
|
97
|
+
throw new FrontmatterParseError(`Failed to parse frontmatter: ${error instanceof Error ? error.message : String(error)}`, error);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
toPath(path) {
|
|
101
|
+
if (Array.isArray(path))
|
|
102
|
+
return path;
|
|
103
|
+
if (typeof path === 'string')
|
|
104
|
+
return [path];
|
|
105
|
+
return path;
|
|
106
|
+
}
|
|
107
|
+
get(path) {
|
|
108
|
+
const segments = this.toPath(path);
|
|
109
|
+
if (segments.length === 0)
|
|
110
|
+
return this.doc.toJS();
|
|
111
|
+
return this.doc.getIn(segments, false);
|
|
112
|
+
}
|
|
113
|
+
set(path, value) {
|
|
114
|
+
const segments = this.toPath(path);
|
|
115
|
+
this.doc.setIn(segments, value);
|
|
116
|
+
this._dirty = true;
|
|
117
|
+
}
|
|
118
|
+
setArrayItem(path, index, value) {
|
|
119
|
+
const segments = [...this.toPath(path), index];
|
|
120
|
+
this.doc.setIn(segments, value);
|
|
121
|
+
this._dirty = true;
|
|
122
|
+
}
|
|
123
|
+
appendArrayItem(path, value) {
|
|
124
|
+
const segments = this.toPath(path);
|
|
125
|
+
this.doc.addIn(segments, value);
|
|
126
|
+
this._dirty = true;
|
|
127
|
+
}
|
|
128
|
+
delete(path) {
|
|
129
|
+
const segments = this.toPath(path);
|
|
130
|
+
this.doc.deleteIn(segments);
|
|
131
|
+
this._dirty = true;
|
|
132
|
+
}
|
|
133
|
+
toString() {
|
|
134
|
+
// No frontmatter originally, and nothing was added → return body unchanged.
|
|
135
|
+
if (!this.hasFrontmatter && this.isDocEffectivelyEmpty()) {
|
|
136
|
+
return this.body;
|
|
137
|
+
}
|
|
138
|
+
// Empty frontmatter (e.g. `---\n---\n`) where the doc remained empty —
|
|
139
|
+
// preserve the empty fence block without injecting `null` or `{}` between.
|
|
140
|
+
if (this.hasFrontmatter && this.isDocEffectivelyEmpty()) {
|
|
141
|
+
return `---${this.eol}---${this.eol}${this.body}`;
|
|
142
|
+
}
|
|
143
|
+
const fmText = this.doc.toString();
|
|
144
|
+
const normalized = this.eol === '\r\n' ? fmText.replaceAll('\n', '\r\n') : fmText;
|
|
145
|
+
return `---${this.eol}${normalized}---${this.eol}${this.body}`;
|
|
146
|
+
}
|
|
147
|
+
isDocEffectivelyEmpty() {
|
|
148
|
+
const contents = this.doc.contents;
|
|
149
|
+
if (contents === null)
|
|
150
|
+
return true;
|
|
151
|
+
// yaml.YAMLMap and YAMLSeq expose `items`; an empty map/seq counts as empty.
|
|
152
|
+
const maybeItems = contents.items;
|
|
153
|
+
if (Array.isArray(maybeItems) && maybeItems.length === 0)
|
|
154
|
+
return true;
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
export function openFrontmatter(markdown) {
|
|
159
|
+
return new FrontmatterEditorImpl(markdown);
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=frontmatter-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-editor.js","sourceRoot":"","sources":["../src/frontmatter-editor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAE/C,MAAM,OAAO,qBAAsB,SA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matter-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"frontmatter-validator.d.ts","sourceRoot":"","sources":["../src/frontmatter-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAChD,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,IAAI,GAAE,cAAyB,EAC/B,UAAU,CAAC,EAAE,MAAM,GAClB,eAAe,EAAE,CA+DnB"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* This is the ONLY place in the codebase that should use AJV.
|
|
14
14
|
*/
|
|
15
|
-
import {
|
|
15
|
+
import { createAjvWithUriFormats } from './ajv-factory.js';
|
|
16
16
|
/**
|
|
17
17
|
* Validate frontmatter against a JSON Schema.
|
|
18
18
|
*
|
|
@@ -52,11 +52,16 @@ export function validateFrontmatter(frontmatter, schema, resourcePath, mode = 's
|
|
|
52
52
|
if (mode === 'permissive') {
|
|
53
53
|
effectiveSchema = makeSchemaPermissive(schema);
|
|
54
54
|
}
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
// Use the shared Ajv factory so the internal validator and any adopter
|
|
56
|
+
// consuming `createAjvWithUriFormats` see identical format behavior.
|
|
57
|
+
// Permissive options match how VAT validates user-supplied schemas:
|
|
58
|
+
// - strict: false so non-strict schemas compile (older JSON Schema drafts).
|
|
59
|
+
// - allErrors: true so we report all issues, not just the first.
|
|
60
|
+
// - allowUnionTypes: true for draft-2019-09+ union type support.
|
|
61
|
+
const ajv = createAjvWithUriFormats({
|
|
62
|
+
strict: false,
|
|
63
|
+
allErrors: true,
|
|
64
|
+
allowUnionTypes: true,
|
|
60
65
|
});
|
|
61
66
|
const validate = ajv.compile(effectiveSchema);
|
|
62
67
|
// Case 1: No frontmatter present
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontmatter-validator.js","sourceRoot":"","sources":["../src/frontmatter-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"frontmatter-validator.js","sourceRoot":"","sources":["../src/frontmatter-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAI3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,mBAAmB,CACjC,WAAgD,EAChD,MAAc,EACd,YAAoB,EACpB,OAAuB,QAAQ,EAC/B,UAAmB;IAEnB,MAAM,MAAM,GAAsB,EAAE,CAAC;IAErC,sEAAsE;IACtE,IAAI,eAAe,GAAG,MAAM,CAAC;IAC7B,IAAI,IAAI,KAAK,YAAY,EAAE,CAAC;QAC1B,eAAe,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,uEAAuE;IACvE,qEAAqE;IACrE,oEAAoE;IACpE,4EAA4E;IAC5E,iEAAiE;IACjE,iEAAiE;IACjE,MAAM,GAAG,GAAG,uBAAuB,CAAC;QAClC,MAAM,EAAE,KAAK;QACb,SAAS,EAAE,IAAI;QACf,eAAe,EAAE,IAAI;KACtB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAE9C,iCAAiC;IACjC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,sCAAsC;QACtC,MAAM,cAAc,GAAI,MAAkC,CAAC,QAA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,CAAC,GAAG,CAAC,CAAC;QACvB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,SAAS;QACX,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;oBAC9C,wBAAwB,CAAC,IAA+B,CAAC,CAAC;gBAC5D,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACvD,wBAAwB,CAAC,KAAgC,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -34,8 +34,11 @@ export { LinkNodeTypeSchema, LinkTypeSchema, HeadingNodeSchema, ResourceLinkSche
|
|
|
34
34
|
export { ValidationIssueSchema, ValidationResultSchema, } from './schemas/validation-result.js';
|
|
35
35
|
export { parseMarkdown, type ParseResult } from './link-parser.js';
|
|
36
36
|
export { validateFrontmatter } from './frontmatter-validator.js';
|
|
37
|
+
export { createAjvWithUriFormats } from './ajv-factory.js';
|
|
37
38
|
export { transformContent, type ContentTransformOptions, type LinkRewriteMatch, type LinkRewriteRule, type ResourceLookup, } from './content-transform.js';
|
|
38
|
-
export { resolveLocalHref } from './utils.js';
|
|
39
|
-
export {
|
|
39
|
+
export { resolveLocalHref, type ResolveLocalHrefResult } from './utils.js';
|
|
40
|
+
export { openFrontmatter, FrontmatterParseError, type FrontmatterEditor, } from './frontmatter-editor.js';
|
|
41
|
+
export { rewriteFrontmatterUriReferencesFromSchema, rewriteFrontmatterFieldsAtPaths, rewriteBodyLinks, type RewriteHref, } from './rewriter-helpers.js';
|
|
42
|
+
export { parseConfigFile, loadConfig, } from './config-parser.js';
|
|
40
43
|
export { ProjectConfigSchema, SkillFileEntrySchema, SkillsConfigSchema, SkillPackagingConfigSchema, } from './schemas/project-config.js';
|
|
41
44
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,YAAY,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAGtF,YAAY,EACV,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,YAAY,EACZ,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;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,CAAC;AAGjC,OAAO,EACL,yCAAyC,EACzC,+BAA+B,EAC/B,gBAAgB,EAChB,KAAK,WAAW,GACjB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,eAAe,EACf,UAAU,GACX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -38,13 +38,21 @@ export { ValidationIssueSchema, ValidationResultSchema, } from './schemas/valida
|
|
|
38
38
|
export { parseMarkdown } from './link-parser.js';
|
|
39
39
|
// Export frontmatter validation
|
|
40
40
|
export { validateFrontmatter } from './frontmatter-validator.js';
|
|
41
|
+
// Public Ajv factory for adopters consuming VAT-generated schemas. Registers
|
|
42
|
+
// URI-family formats (uri, uri-reference, iri, iri-reference) so schemas
|
|
43
|
+
// compile cleanly under Ajv strict mode without throwing on "unknown format".
|
|
44
|
+
export { createAjvWithUriFormats } from './ajv-factory.js';
|
|
41
45
|
// Export content transform engine for link rewriting
|
|
42
46
|
export { transformContent, } from './content-transform.js';
|
|
43
47
|
// Note: link-parser and link-validator internals are NOT exported
|
|
44
48
|
// They are implementation details. Users should use ResourceRegistry API.
|
|
45
49
|
// Export href resolution utility (shared by audit and validate code paths)
|
|
46
50
|
export { resolveLocalHref } from './utils.js';
|
|
51
|
+
// Export frontmatter editor primitive (comment-preserving round-trip)
|
|
52
|
+
export { openFrontmatter, FrontmatterParseError, } from './frontmatter-editor.js';
|
|
53
|
+
// Export rewriter helpers (built on FrontmatterEditor + shared callback shape)
|
|
54
|
+
export { rewriteFrontmatterUriReferencesFromSchema, rewriteFrontmatterFieldsAtPaths, rewriteBodyLinks, } from './rewriter-helpers.js';
|
|
47
55
|
// Export project config parsing
|
|
48
|
-
export {
|
|
56
|
+
export { parseConfigFile, loadConfig, } from './config-parser.js';
|
|
49
57
|
export { ProjectConfigSchema, SkillFileEntrySchema, SkillsConfigSchema, SkillPackagingConfigSchema, } from './schemas/project-config.js';
|
|
50
58
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,+DAA+D;AAC/D,OAAO,EACL,gBAAgB,EAChB,kBAAkB,GAMnB,MAAM,wBAAwB,CAAC;AAEhC,yDAAyD;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,oFAAoF;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AA2B9D,qFAAqF;AACrF,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AAExC,iDAAiD;AACjD,OAAO,EAAE,aAAa,EAAoB,MAAM,kBAAkB,CAAC;AAEnE,gCAAgC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,qDAAqD;AACrD,OAAO,EACL,gBAAgB,GAKjB,MAAM,wBAAwB,CAAC;AAEhC,kEAAkE;AAClE,0EAA0E;AAE1E,2EAA2E;AAC3E,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,+DAA+D;AAC/D,OAAO,EACL,gBAAgB,EAChB,kBAAkB,GAMnB,MAAM,wBAAwB,CAAC;AAEhC,yDAAyD;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,oFAAoF;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AA2B9D,qFAAqF;AACrF,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AAExC,iDAAiD;AACjD,OAAO,EAAE,aAAa,EAAoB,MAAM,kBAAkB,CAAC;AAEnE,gCAAgC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,6EAA6E;AAC7E,yEAAyE;AACzE,8EAA8E;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,qDAAqD;AACrD,OAAO,EACL,gBAAgB,GAKjB,MAAM,wBAAwB,CAAC;AAEhC,kEAAkE;AAClE,0EAA0E;AAE1E,2EAA2E;AAC3E,OAAO,EAAE,gBAAgB,EAA+B,MAAM,YAAY,CAAC;AAE3E,sEAAsE;AACtE,OAAO,EACL,eAAe,EACf,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC;AAEjC,+EAA+E;AAC/E,OAAO,EACL,yCAAyC,EACzC,+BAA+B,EAC/B,gBAAgB,GAEjB,MAAM,uBAAuB,CAAC;AAE/B,gCAAgC;AAChC,OAAO,EACL,eAAe,EACf,UAAU,GACX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert an RFC 6901 JSON Pointer string into a path of (string | number)
|
|
3
|
+
* segments suitable for use with the FrontmatterEditor mutation API.
|
|
4
|
+
*
|
|
5
|
+
* Canonical array indices (RFC 6901 §4: no leading zeros except for "0")
|
|
6
|
+
* are converted to numbers; all other segments are decoded strings.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* jsonPointerToPath('/adrs-cited/0') // ['adrs-cited', 0]
|
|
10
|
+
* jsonPointerToPath('') // []
|
|
11
|
+
*/
|
|
12
|
+
export declare function jsonPointerToPath(pointer: string): (string | number)[];
|
|
13
|
+
//# sourceMappingURL=json-pointer-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-pointer-path.d.ts","sourceRoot":"","sources":["../src/json-pointer-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CActE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert an RFC 6901 JSON Pointer string into a path of (string | number)
|
|
3
|
+
* segments suitable for use with the FrontmatterEditor mutation API.
|
|
4
|
+
*
|
|
5
|
+
* Canonical array indices (RFC 6901 §4: no leading zeros except for "0")
|
|
6
|
+
* are converted to numbers; all other segments are decoded strings.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* jsonPointerToPath('/adrs-cited/0') // ['adrs-cited', 0]
|
|
10
|
+
* jsonPointerToPath('') // []
|
|
11
|
+
*/
|
|
12
|
+
import { decodeJsonPointerSegment, isCanonicalArrayIndex } from './utils.js';
|
|
13
|
+
export function jsonPointerToPath(pointer) {
|
|
14
|
+
if (pointer === '')
|
|
15
|
+
return [];
|
|
16
|
+
// eslint-disable-next-line local/no-hardcoded-path-split -- RFC 6901 JSON Pointer delimiter, not a file path
|
|
17
|
+
const raw = pointer.slice(1).split('/');
|
|
18
|
+
const result = [];
|
|
19
|
+
for (const seg of raw) {
|
|
20
|
+
const decoded = decodeJsonPointerSegment(seg);
|
|
21
|
+
if (isCanonicalArrayIndex(decoded)) {
|
|
22
|
+
result.push(Number(decoded));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
result.push(decoded);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=json-pointer-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-pointer-path.js","sourceRoot":"","sources":["../src/json-pointer-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE7E,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAC9B,6GAA6G;IAC7G,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,MAAM,OAAO,GAAG,wBAAwB,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE,CAAC;YACnC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|