@dogsbay/commands 0.2.0-beta.101
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 +137 -0
- package/dist/commands/content.d.ts +78 -0
- package/dist/commands/content.d.ts.map +1 -0
- package/dist/commands/content.js +634 -0
- package/dist/commands/content.js.map +1 -0
- package/dist/commands/examples.d.ts +49 -0
- package/dist/commands/examples.d.ts.map +1 -0
- package/dist/commands/examples.js +173 -0
- package/dist/commands/examples.js.map +1 -0
- package/dist/commands/keys.d.ts +14 -0
- package/dist/commands/keys.d.ts.map +1 -0
- package/dist/commands/keys.js +87 -0
- package/dist/commands/keys.js.map +1 -0
- package/dist/commands/link-retarget.d.ts +18 -0
- package/dist/commands/link-retarget.d.ts.map +1 -0
- package/dist/commands/link-retarget.js +104 -0
- package/dist/commands/link-retarget.js.map +1 -0
- package/dist/commands/refactor-files.d.ts +27 -0
- package/dist/commands/refactor-files.d.ts.map +1 -0
- package/dist/commands/refactor-files.js +264 -0
- package/dist/commands/refactor-files.js.map +1 -0
- package/dist/commands/refactor-keys.d.ts +21 -0
- package/dist/commands/refactor-keys.d.ts.map +1 -0
- package/dist/commands/refactor-keys.js +224 -0
- package/dist/commands/refactor-keys.js.map +1 -0
- package/dist/commands/refactor-structure.d.ts +19 -0
- package/dist/commands/refactor-structure.d.ts.map +1 -0
- package/dist/commands/refactor-structure.js +314 -0
- package/dist/commands/refactor-structure.js.map +1 -0
- package/dist/commands/reindex.d.ts +10 -0
- package/dist/commands/reindex.d.ts.map +1 -0
- package/dist/commands/reindex.js +23 -0
- package/dist/commands/reindex.js.map +1 -0
- package/dist/commands/topicmap-edit.d.ts +65 -0
- package/dist/commands/topicmap-edit.d.ts.map +1 -0
- package/dist/commands/topicmap-edit.js +194 -0
- package/dist/commands/topicmap-edit.js.map +1 -0
- package/dist/commands/topicmap.d.ts +13 -0
- package/dist/commands/topicmap.d.ts.map +1 -0
- package/dist/commands/topicmap.js +69 -0
- package/dist/commands/topicmap.js.map +1 -0
- package/dist/commands/validate.d.ts +13 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +753 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/commands/where-used.d.ts +16 -0
- package/dist/commands/where-used.d.ts.map +1 -0
- package/dist/commands/where-used.js +83 -0
- package/dist/commands/where-used.js.map +1 -0
- package/dist/edits.d.ts +54 -0
- package/dist/edits.d.ts.map +1 -0
- package/dist/edits.js +158 -0
- package/dist/edits.js.map +1 -0
- package/dist/engine.d.ts +103 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +115 -0
- package/dist/engine.js.map +1 -0
- package/dist/flags.d.ts +31 -0
- package/dist/flags.d.ts.map +1 -0
- package/dist/flags.js +73 -0
- package/dist/flags.js.map +1 -0
- package/dist/frontmatter-schema.d.ts +97 -0
- package/dist/frontmatter-schema.d.ts.map +1 -0
- package/dist/frontmatter-schema.js +240 -0
- package/dist/frontmatter-schema.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +70 -0
- package/dist/index.js.map +1 -0
- package/dist/indexes.d.ts +175 -0
- package/dist/indexes.d.ts.map +1 -0
- package/dist/indexes.js +536 -0
- package/dist/indexes.js.map +1 -0
- package/dist/json-schema.d.ts +10 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +50 -0
- package/dist/json-schema.js.map +1 -0
- package/dist/storage.d.ts +68 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +193 -0
- package/dist/storage.js.map +1 -0
- package/dist/workspace.d.ts +30 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +63 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,CAAC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AAY,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;AAElG;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAgD,EAAE;IAC/E,IAAI,IAAI,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAC5C,OAAO,CAAI,IAAsB,EAAc,EAAE;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QACvC,IAAI,GAAG,MAAM,CAAC,IAAI,CAChB,GAAG,EAAE,CAAC,SAAS,EACf,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/flags.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema → CLI-flag derivation. Lives in the engine package (not the
|
|
3
|
+
* CLI) so every surface generator reads schemas through one zod
|
|
4
|
+
* instance, and the conformance test can assert that every registered
|
|
5
|
+
* command is expressible with no per-surface code.
|
|
6
|
+
*
|
|
7
|
+
* Supported field types: string, number, boolean, enum,
|
|
8
|
+
* array-of-string, record-of-string — optionally wrapped in
|
|
9
|
+
* optional()/default()/describe(). Anything else throws, which the
|
|
10
|
+
* conformance test turns into a CI failure instead of a user-facing
|
|
11
|
+
* crash.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
/**
|
|
15
|
+
* Malformed option-argument input (e.g. `--variables foo` without "=").
|
|
16
|
+
* Surfaces translate it into their native usage error — the commander
|
|
17
|
+
* adapter maps it to InvalidArgumentError so users get a one-line
|
|
18
|
+
* usage message, never a stack trace.
|
|
19
|
+
*/
|
|
20
|
+
export declare class FlagArgumentError extends Error {
|
|
21
|
+
}
|
|
22
|
+
export interface FlagSpec {
|
|
23
|
+
/** commander-style flags string, e.g. `--name <value>`. */
|
|
24
|
+
flags: string;
|
|
25
|
+
description: string;
|
|
26
|
+
/** Option-argument parser (collector for arrays/records). */
|
|
27
|
+
parse?: (value: string, previous: unknown) => unknown;
|
|
28
|
+
defaultValue?: unknown;
|
|
29
|
+
}
|
|
30
|
+
export declare const flagForField: (name: string, schema: z.ZodTypeAny) => FlagSpec;
|
|
31
|
+
//# sourceMappingURL=flags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;GAKG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;CAAG;AAE/C,MAAM,WAAW,QAAQ;IACvB,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAC;IACtD,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU,KAAG,QAkDjE,CAAC"}
|
package/dist/flags.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema → CLI-flag derivation. Lives in the engine package (not the
|
|
3
|
+
* CLI) so every surface generator reads schemas through one zod
|
|
4
|
+
* instance, and the conformance test can assert that every registered
|
|
5
|
+
* command is expressible with no per-surface code.
|
|
6
|
+
*
|
|
7
|
+
* Supported field types: string, number, boolean, enum,
|
|
8
|
+
* array-of-string, record-of-string — optionally wrapped in
|
|
9
|
+
* optional()/default()/describe(). Anything else throws, which the
|
|
10
|
+
* conformance test turns into a CI failure instead of a user-facing
|
|
11
|
+
* crash.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
import { unwrap } from "./engine.js";
|
|
15
|
+
/**
|
|
16
|
+
* Malformed option-argument input (e.g. `--variables foo` without "=").
|
|
17
|
+
* Surfaces translate it into their native usage error — the commander
|
|
18
|
+
* adapter maps it to InvalidArgumentError so users get a one-line
|
|
19
|
+
* usage message, never a stack trace.
|
|
20
|
+
*/
|
|
21
|
+
export class FlagArgumentError extends Error {
|
|
22
|
+
}
|
|
23
|
+
export const flagForField = (name, schema) => {
|
|
24
|
+
const base = unwrap(schema);
|
|
25
|
+
const description = schema.description ?? base.description ?? "";
|
|
26
|
+
if (base instanceof z.ZodBoolean) {
|
|
27
|
+
return { flags: `--${name}`, description };
|
|
28
|
+
}
|
|
29
|
+
if (base instanceof z.ZodString) {
|
|
30
|
+
return { flags: `--${name} <value>`, description };
|
|
31
|
+
}
|
|
32
|
+
if (base instanceof z.ZodNumber) {
|
|
33
|
+
return {
|
|
34
|
+
flags: `--${name} <number>`,
|
|
35
|
+
description,
|
|
36
|
+
parse: (value) => Number(value),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (base instanceof z.ZodEnum) {
|
|
40
|
+
const values = base.options.join("|");
|
|
41
|
+
return { flags: `--${name} <${values}>`, description };
|
|
42
|
+
}
|
|
43
|
+
if (base instanceof z.ZodArray) {
|
|
44
|
+
const element = unwrap(base.element);
|
|
45
|
+
if (element instanceof z.ZodString) {
|
|
46
|
+
return {
|
|
47
|
+
flags: `--${name} <value>`,
|
|
48
|
+
description: `${description}${description ? " " : ""}(repeatable)`,
|
|
49
|
+
parse: (value, previous) => [...(previous ?? []), value],
|
|
50
|
+
defaultValue: undefined,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (base instanceof z.ZodRecord) {
|
|
55
|
+
return {
|
|
56
|
+
flags: `--${name} <key=value>`,
|
|
57
|
+
description: `${description}${description ? " " : ""}(repeatable)`,
|
|
58
|
+
parse: (value, previous) => {
|
|
59
|
+
const eq = value.indexOf("=");
|
|
60
|
+
if (eq <= 0) {
|
|
61
|
+
throw new FlagArgumentError(`--${name} expects key=value, got "${value}"`);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
...(previous ?? {}),
|
|
65
|
+
[value.slice(0, eq)]: value.slice(eq + 1),
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
defaultValue: undefined,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
throw new Error(`Command schema field "${name}" uses a type the CLI adapter cannot express`);
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=flags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;GAKG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;CAAG;AAW/C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,MAAoB,EAAY,EAAE;IAC3E,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5B,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC;IAEjE,IAAI,IAAI,YAAY,CAAC,CAAC,UAAU,EAAE,CAAC;QACjC,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC;IAC7C,CAAC;IACD,IAAI,IAAI,YAAY,CAAC,CAAC,SAAS,EAAE,CAAC;QAChC,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,UAAU,EAAE,WAAW,EAAE,CAAC;IACrD,CAAC;IACD,IAAI,IAAI,YAAY,CAAC,CAAC,SAAS,EAAE,CAAC;QAChC,OAAO;YACL,KAAK,EAAE,KAAK,IAAI,WAA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iBAAiB,CAAC,KAAK,IAAI,4BAA4B,KAAK,GAAG,CAAC,CAAC;gBAC7E,CAAC;gBACD,OAAO;oBACL,GAAG,CAAE,QAA+C,IAAI,EAAE,CAAC;oBAC3D,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;iBAC1C,CAAC;YACJ,CAAC;YACD,YAAY,EAAE,SAAS;SACxB,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,8CAA8C,CAAC,CAAC;AAC/F,CAAC,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/** The YAML shapes a field may take. `date` accepts a Date (js-yaml parses ISO dates) or an ISO-ish string. */
|
|
2
|
+
export type FieldType = "string" | "number" | "boolean" | "date" | "string[]" | "string|string[]" | "object" | "boolean|object" | "scalar|scalar[]";
|
|
3
|
+
export interface FieldSpec {
|
|
4
|
+
type: FieldType;
|
|
5
|
+
/** Closed set of values (checked case-sensitively; a case-only miss is reported with the fix). */
|
|
6
|
+
values?: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The well-known fields. Anything not listed is free-form as far as the
|
|
10
|
+
* engine is concerned (see `unknown` above).
|
|
11
|
+
*/
|
|
12
|
+
export declare const WELL_KNOWN_FIELDS: Record<string, FieldSpec>;
|
|
13
|
+
/**
|
|
14
|
+
* Fields the pipeline ACCEPTS but does not act on: they are here so imported
|
|
15
|
+
* content does not light up as "unknown", not because setting them does
|
|
16
|
+
* anything. Kept in one list so the docs can say so honestly.
|
|
17
|
+
*/
|
|
18
|
+
export declare const INERT_FIELDS: Set<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Keys the AGGREGATOR owns: the multi-source build writes them, and a writer
|
|
21
|
+
* setting one by hand is a mistake that shows up as a page routed to the
|
|
22
|
+
* wrong namespace/version (documented in the frontmatter-fields skill).
|
|
23
|
+
*/
|
|
24
|
+
export declare const AGGREGATOR_OWNED: string[];
|
|
25
|
+
/** One `propSchema` entry from dogsbay.config: a type, optionally a closed set. */
|
|
26
|
+
export interface PropSpec {
|
|
27
|
+
type: "string" | "number" | "boolean";
|
|
28
|
+
enum?: string[];
|
|
29
|
+
}
|
|
30
|
+
export interface TaxonomySpec {
|
|
31
|
+
values?: string[];
|
|
32
|
+
hierarchical?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface FrontmatterPolicy {
|
|
35
|
+
/** Declared taxonomies (config `taxonomies:`), keyed by frontmatter field name. */
|
|
36
|
+
taxonomies: Record<string, TaxonomySpec>;
|
|
37
|
+
/**
|
|
38
|
+
* Config `propSchema:` — the free-form `props:` bag's declared shape. It has
|
|
39
|
+
* been in the config schema (and validated as CONFIG) since taxonomies
|
|
40
|
+
* landed, with nothing ever checking a PAGE against it.
|
|
41
|
+
*/
|
|
42
|
+
propSchema: Record<string, PropSpec>;
|
|
43
|
+
/** `content.frontmatter.required`: path glob → fields that must be present. */
|
|
44
|
+
required: Array<{
|
|
45
|
+
glob: string;
|
|
46
|
+
fields: string[];
|
|
47
|
+
}>;
|
|
48
|
+
/** `content.frontmatter.unknown`: what to do with keys nobody declared. */
|
|
49
|
+
unknown: "ignore" | "warn" | "error";
|
|
50
|
+
/**
|
|
51
|
+
* The content roots (config `content.sources[].path`). The declared policy
|
|
52
|
+
* applies to CONTENT: a README, a plan or a dev note in the same workspace
|
|
53
|
+
* is not a page, and reporting its frontmatter is noise. Globs are matched
|
|
54
|
+
* against the content-root-relative path, which is what a writer means by
|
|
55
|
+
* `guides/**`.
|
|
56
|
+
*/
|
|
57
|
+
roots: string[];
|
|
58
|
+
/** Set when the config's policy is itself malformed — reported, never guessed around. */
|
|
59
|
+
invalid?: string;
|
|
60
|
+
}
|
|
61
|
+
export declare const EMPTY_POLICY: FrontmatterPolicy;
|
|
62
|
+
/** The type name to SHOW for a value the writer got wrong. */
|
|
63
|
+
export declare const typeOf: (v: unknown) => string;
|
|
64
|
+
export declare function matchesType(value: unknown, type: FieldType): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* The near-miss values for a bad enum entry: a case-only difference first
|
|
67
|
+
* (the overwhelmingly common typo), then a one-edit neighbour. A fix is
|
|
68
|
+
* offered only when exactly one candidate comes back.
|
|
69
|
+
*/
|
|
70
|
+
export declare function nearMisses(value: string, allowed: string[]): string[];
|
|
71
|
+
/**
|
|
72
|
+
* Whether a near miss may be APPLIED with one click, as opposed to merely
|
|
73
|
+
* listed. Only a case difference qualifies: at edit distance 2 the single
|
|
74
|
+
* candidate for `unstable` is `stable`, and for `review` it is `preview` —
|
|
75
|
+
* a one-click fix that inverts the writer's meaning is worse than no fix.
|
|
76
|
+
*/
|
|
77
|
+
export declare const isSafeAutoFix: (value: string, candidate: string) => boolean;
|
|
78
|
+
/**
|
|
79
|
+
* The 1-based line of a top-level key inside the frontmatter block, so a
|
|
80
|
+
* finding can be revealed where the writer wrote it. Only the block is
|
|
81
|
+
* scanned (the body may contain a line that looks like a key).
|
|
82
|
+
*/
|
|
83
|
+
export declare function frontmatterKeyLines(source: string): Map<string, number>;
|
|
84
|
+
/**
|
|
85
|
+
* `content/guides/**` / `*.md` / `content/*/index.md`. Deliberately small:
|
|
86
|
+
* `**` crosses directories, `*` does not, everything else is literal.
|
|
87
|
+
*/
|
|
88
|
+
export declare function globMatches(glob: string, path: string): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* The path a glob is matched against: relative to the content root the doc
|
|
91
|
+
* lives under, so `guides/**` means what the writer means when their content
|
|
92
|
+
* is `content/guides/…`. A doc outside every declared root is not content.
|
|
93
|
+
*/
|
|
94
|
+
export declare function contentRelativePath(policy: FrontmatterPolicy, path: string): string | null;
|
|
95
|
+
/** Fields required for a path by the declared globs (deduped, in declaration order). */
|
|
96
|
+
export declare function requiredFieldsFor(policy: FrontmatterPolicy, path: string): string[];
|
|
97
|
+
//# sourceMappingURL=frontmatter-schema.d.ts.map
|
|
@@ -0,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IACH,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,yFAAyF;IACzF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,YAAY,EAAE,iBAAoG,CAAC;AAUhI,8DAA8D;AAC9D,eAAO,MAAM,MAAM,GAAI,GAAG,OAAO,KAAG,MAMnC,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAkBpE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAKrE;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,WAAW,MAAM,KAAG,OACT,CAAC;AAuBzD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAcvE;AAID;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAM/D;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAY1F;AAED,wFAAwF;AACxF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CASnF"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What page frontmatter MEANS — the vocabulary `validate` checks against
|
|
3
|
+
* (plans/frontmatter-validation.md).
|
|
4
|
+
*
|
|
5
|
+
* Three sources, in order of how much the writer had to declare:
|
|
6
|
+
*
|
|
7
|
+
* 1. WELL-KNOWN FIELDS. `docs/metadata.md` is the field reference and the
|
|
8
|
+
* emitters read exactly these; the table below mirrors it. A bare
|
|
9
|
+
* directory with no config gets type checking for free.
|
|
10
|
+
* 2. `taxonomies:` in `dogsbay.config.*` — already carries `values` (the
|
|
11
|
+
* allowed terms) and `hierarchical` (whether `api/rest` is legal). No
|
|
12
|
+
* new config surface: if you declared the taxonomy, you declared the
|
|
13
|
+
* check.
|
|
14
|
+
* 3. `content.frontmatter` — opt-in strictness: `required` (globs → fields
|
|
15
|
+
* that must be present) and `unknown` (ignore | warn | error).
|
|
16
|
+
*
|
|
17
|
+
* Unknown keys are silent unless (3) asks for them: free-form keys are
|
|
18
|
+
* legitimate, and a checker that cries wolf on them gets switched off.
|
|
19
|
+
*
|
|
20
|
+
* The nine fields `parseMeta` owns are checked against the rules IT applies
|
|
21
|
+
* (it silently drops what it cannot use), and `tests/meta-parity.test.ts`
|
|
22
|
+
* asserts the two agree value-by-value — the anti-drift device, since a
|
|
23
|
+
* checker that disagrees with the parser is worse than no checker.
|
|
24
|
+
*/
|
|
25
|
+
import { STATUS_VALUES } from "@dogsbay/types";
|
|
26
|
+
/**
|
|
27
|
+
* The well-known fields. Anything not listed is free-form as far as the
|
|
28
|
+
* engine is concerned (see `unknown` above).
|
|
29
|
+
*/
|
|
30
|
+
export const WELL_KNOWN_FIELDS = {
|
|
31
|
+
title: { type: "string" },
|
|
32
|
+
description: { type: "string" },
|
|
33
|
+
// parseMeta coerces a single string ("tags: api"), so a scalar is correct authoring
|
|
34
|
+
tags: { type: "string|string[]" },
|
|
35
|
+
category: { type: "string|string[]" },
|
|
36
|
+
type: { type: "string" },
|
|
37
|
+
status: { type: "string", values: [...STATUS_VALUES] },
|
|
38
|
+
audience: { type: "string|string[]" },
|
|
39
|
+
weight: { type: "number" },
|
|
40
|
+
updated: { type: "date" },
|
|
41
|
+
created: { type: "date" },
|
|
42
|
+
lastUpdated: { type: "date" },
|
|
43
|
+
lastmod: { type: "date" },
|
|
44
|
+
date: { type: "date" },
|
|
45
|
+
props: { type: "object" },
|
|
46
|
+
keyword: { type: "string" },
|
|
47
|
+
targetKeyword: { type: "string" },
|
|
48
|
+
// visibility / build behaviour the emitters read
|
|
49
|
+
draft: { type: "boolean" },
|
|
50
|
+
noindex: { type: "boolean" },
|
|
51
|
+
nofollow: { type: "boolean" },
|
|
52
|
+
excludeFromSearch: { type: "boolean" },
|
|
53
|
+
pagefindExclude: { type: "boolean" },
|
|
54
|
+
ogImage: { type: "string" },
|
|
55
|
+
ogType: { type: "string" },
|
|
56
|
+
canonicalUrl: { type: "string" },
|
|
57
|
+
slug: { type: "string" },
|
|
58
|
+
// every reader casts/checks `redirect` as a STRING: a list would validate and then be ignored
|
|
59
|
+
redirect: { type: "string" },
|
|
60
|
+
llmActions: { type: "boolean|object" },
|
|
61
|
+
preprocess: { type: "boolean" },
|
|
62
|
+
autoH1: { type: "boolean" },
|
|
63
|
+
autoLede: { type: "boolean" },
|
|
64
|
+
fragment: { type: "boolean" },
|
|
65
|
+
_fragment: { type: "boolean" },
|
|
66
|
+
"single-page": { type: "string", values: ["yes", "children", "no"] },
|
|
67
|
+
// chunk facet keys (@dogsbay/chunk facets.ts TAXONOMY_KEYS) — consumed even without a
|
|
68
|
+
// `taxonomies:` declaration, so reporting them as unknown would be a false positive
|
|
69
|
+
product: { type: "scalar|scalar[]" },
|
|
70
|
+
platform: { type: "scalar|scalar[]" },
|
|
71
|
+
edition: { type: "scalar|scalar[]" },
|
|
72
|
+
// DITA profiling attributes carried through the pipeline
|
|
73
|
+
rev: { type: "scalar|scalar[]" },
|
|
74
|
+
otherprops: { type: "scalar|scalar[]" },
|
|
75
|
+
// stamped by the single-page (book) emitter on the pages it generates
|
|
76
|
+
granularity: { type: "string" },
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Fields the pipeline ACCEPTS but does not act on: they are here so imported
|
|
80
|
+
* content does not light up as "unknown", not because setting them does
|
|
81
|
+
* anything. Kept in one list so the docs can say so honestly.
|
|
82
|
+
*/
|
|
83
|
+
export const INERT_FIELDS = new Set(["canonicalUrl", "ogType", "autoH1", "autoLede", "date", "fragment", "_fragment", "slug"]);
|
|
84
|
+
/**
|
|
85
|
+
* Keys the AGGREGATOR owns: the multi-source build writes them, and a writer
|
|
86
|
+
* setting one by hand is a mistake that shows up as a page routed to the
|
|
87
|
+
* wrong namespace/version (documented in the frontmatter-fields skill).
|
|
88
|
+
*/
|
|
89
|
+
export const AGGREGATOR_OWNED = ["multiSource"];
|
|
90
|
+
export const EMPTY_POLICY = { taxonomies: {}, propSchema: {}, required: [], unknown: "ignore", roots: [""] };
|
|
91
|
+
/* ───────────────────────────── type checking ───────────────────────────── */
|
|
92
|
+
// `2026`, `2026-08` and RFC-1123 are all valid to the consumers (sitemap lastmod, `new Date()`),
|
|
93
|
+
// so the check is "a date this system can read", not one spelling of it
|
|
94
|
+
const isDateString = (v) => /^\d{4}(-\d{2}(-\d{2}([T ].*)?)?)?$/.test(v.trim()) || !Number.isNaN(Date.parse(v));
|
|
95
|
+
const isStringArray = (v) => Array.isArray(v) && v.every((x) => typeof x === "string");
|
|
96
|
+
/** The type name to SHOW for a value the writer got wrong. */
|
|
97
|
+
export const typeOf = (v) => {
|
|
98
|
+
if (v === null)
|
|
99
|
+
return "null";
|
|
100
|
+
if (typeof v === "number" && !Number.isFinite(v))
|
|
101
|
+
return Number.isNaN(v) ? "NaN" : "infinity";
|
|
102
|
+
if (Array.isArray(v))
|
|
103
|
+
return v.every((x) => typeof x === "string") ? "string[]" : "list";
|
|
104
|
+
if (v instanceof Date)
|
|
105
|
+
return "date";
|
|
106
|
+
return typeof v;
|
|
107
|
+
};
|
|
108
|
+
export function matchesType(value, type) {
|
|
109
|
+
switch (type) {
|
|
110
|
+
case "string": return typeof value === "string";
|
|
111
|
+
case "number": return typeof value === "number" && Number.isFinite(value);
|
|
112
|
+
case "boolean": return typeof value === "boolean";
|
|
113
|
+
// js-yaml turns an unquoted ISO date into a Date; a quoted one stays a string
|
|
114
|
+
case "date": return value instanceof Date || (typeof value === "string" && isDateString(value));
|
|
115
|
+
case "string[]": return isStringArray(value);
|
|
116
|
+
case "string|string[]": return typeof value === "string" || isStringArray(value);
|
|
117
|
+
case "object": return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date);
|
|
118
|
+
case "boolean|object": return typeof value === "boolean" || (typeof value === "object" && value !== null && !Array.isArray(value));
|
|
119
|
+
// the facet/profiling axes: the chunker stringifies scalars and splits a string on
|
|
120
|
+
// whitespace/commas, so `rev: 2` and `product: a, b` are both real authoring
|
|
121
|
+
case "scalar|scalar[]": {
|
|
122
|
+
const scalar = (v) => v !== null && typeof v !== "object";
|
|
123
|
+
return scalar(value) || (Array.isArray(value) && value.every(scalar));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The near-miss values for a bad enum entry: a case-only difference first
|
|
129
|
+
* (the overwhelmingly common typo), then a one-edit neighbour. A fix is
|
|
130
|
+
* offered only when exactly one candidate comes back.
|
|
131
|
+
*/
|
|
132
|
+
export function nearMisses(value, allowed) {
|
|
133
|
+
const lower = value.toLowerCase().trim();
|
|
134
|
+
const caseOnly = allowed.filter((a) => a.toLowerCase() === lower);
|
|
135
|
+
if (caseOnly.length)
|
|
136
|
+
return caseOnly;
|
|
137
|
+
return allowed.filter((a) => editDistanceAtMost(a.toLowerCase(), lower, 2));
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Whether a near miss may be APPLIED with one click, as opposed to merely
|
|
141
|
+
* listed. Only a case difference qualifies: at edit distance 2 the single
|
|
142
|
+
* candidate for `unstable` is `stable`, and for `review` it is `preview` —
|
|
143
|
+
* a one-click fix that inverts the writer's meaning is worse than no fix.
|
|
144
|
+
*/
|
|
145
|
+
export const isSafeAutoFix = (value, candidate) => value.trim().toLowerCase() === candidate.toLowerCase();
|
|
146
|
+
/** Bounded Levenshtein: true when `a` and `b` are within `max` edits. */
|
|
147
|
+
function editDistanceAtMost(a, b, max) {
|
|
148
|
+
if (Math.abs(a.length - b.length) > max)
|
|
149
|
+
return false;
|
|
150
|
+
let prev = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
151
|
+
for (let i = 1; i <= a.length; i++) {
|
|
152
|
+
const row = [i];
|
|
153
|
+
let best = i;
|
|
154
|
+
for (let j = 1; j <= b.length; j++) {
|
|
155
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
156
|
+
const v = Math.min(prev[j] + 1, row[j - 1] + 1, prev[j - 1] + cost);
|
|
157
|
+
row.push(v);
|
|
158
|
+
best = Math.min(best, v);
|
|
159
|
+
}
|
|
160
|
+
if (best > max)
|
|
161
|
+
return false;
|
|
162
|
+
prev = row;
|
|
163
|
+
}
|
|
164
|
+
return prev[b.length] <= max;
|
|
165
|
+
}
|
|
166
|
+
/* ───────────────────────────── key positions ───────────────────────────── */
|
|
167
|
+
/**
|
|
168
|
+
* The 1-based line of a top-level key inside the frontmatter block, so a
|
|
169
|
+
* finding can be revealed where the writer wrote it. Only the block is
|
|
170
|
+
* scanned (the body may contain a line that looks like a key).
|
|
171
|
+
*/
|
|
172
|
+
export function frontmatterKeyLines(source) {
|
|
173
|
+
const out = new Map();
|
|
174
|
+
const lines = source.split("\n");
|
|
175
|
+
if (lines[0]?.trim() !== "---")
|
|
176
|
+
return out;
|
|
177
|
+
for (let i = 1; i < lines.length; i++) {
|
|
178
|
+
const line = lines[i];
|
|
179
|
+
// the closer is at COLUMN 0 (what splitFrontmatter matches) — an indented `---` inside a
|
|
180
|
+
// block scalar is content, and breaking on it lost the line of every key after it
|
|
181
|
+
if (/^(---|\.\.\.)[ \t]*\r?$/.test(line))
|
|
182
|
+
break;
|
|
183
|
+
const m = /^(?:"([^"]+)"|'([^']+)'|([A-Za-z_][\w.-]*))\s*:/.exec(line); // top level only: no leading space
|
|
184
|
+
const key = m?.[1] ?? m?.[2] ?? m?.[3];
|
|
185
|
+
if (key && !out.has(key))
|
|
186
|
+
out.set(key, i + 1);
|
|
187
|
+
}
|
|
188
|
+
return out;
|
|
189
|
+
}
|
|
190
|
+
/* ─────────────────────────────── globs ─────────────────────────────────── */
|
|
191
|
+
/**
|
|
192
|
+
* `content/guides/**` / `*.md` / `content/*/index.md`. Deliberately small:
|
|
193
|
+
* `**` crosses directories, `*` does not, everything else is literal.
|
|
194
|
+
*/
|
|
195
|
+
export function globMatches(glob, path) {
|
|
196
|
+
const escaped = glob
|
|
197
|
+
.split("**")
|
|
198
|
+
.map((part) => part.split("*").map((lit) => lit.replace(/[.+^${}()|[\]\\?]/g, "\\$&")).join("[^/]*"))
|
|
199
|
+
.join(".*");
|
|
200
|
+
return new RegExp(`^${escaped}$`).test(path);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The path a glob is matched against: relative to the content root the doc
|
|
204
|
+
* lives under, so `guides/**` means what the writer means when their content
|
|
205
|
+
* is `content/guides/…`. A doc outside every declared root is not content.
|
|
206
|
+
*/
|
|
207
|
+
export function contentRelativePath(policy, path) {
|
|
208
|
+
const roots = policy.roots.length ? policy.roots : [""];
|
|
209
|
+
let best = null;
|
|
210
|
+
for (const root of roots) {
|
|
211
|
+
if (root === "") {
|
|
212
|
+
if (best === null)
|
|
213
|
+
best = path;
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
const prefix = root.replace(/\/+$/, "") + "/";
|
|
217
|
+
if (path.startsWith(prefix)) {
|
|
218
|
+
const rel = path.slice(prefix.length);
|
|
219
|
+
if (best === null || rel.length < best.length)
|
|
220
|
+
best = rel;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return best;
|
|
224
|
+
}
|
|
225
|
+
/** Fields required for a path by the declared globs (deduped, in declaration order). */
|
|
226
|
+
export function requiredFieldsFor(policy, path) {
|
|
227
|
+
const rel = contentRelativePath(policy, path);
|
|
228
|
+
if (rel === null)
|
|
229
|
+
return [];
|
|
230
|
+
const out = [];
|
|
231
|
+
for (const rule of policy.required) {
|
|
232
|
+
if (!globMatches(rule.glob, rel))
|
|
233
|
+
continue;
|
|
234
|
+
for (const f of rule.fields)
|
|
235
|
+
if (!out.includes(f))
|
|
236
|
+
out.push(f);
|
|
237
|
+
}
|
|
238
|
+
return out;
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=frontmatter-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-schema.js","sourceRoot":"","sources":["../src/frontmatter-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAW/C;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA8B;IAC1D,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACzB,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC/B,oFAAoF;IACpF,IAAI,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;IACjC,QAAQ,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;IACrC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACxB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,GAAG,aAAa,CAAC,EAAE;IACtD,QAAQ,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;IACrC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC1B,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IACzB,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IACzB,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IAC7B,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IACzB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IACtB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACzB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC3B,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ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AAM,IAAI,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACnC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC;YAAE,SAAS;QAC3C,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM;YAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @dogsbay/commands
|
|
3
|
+
*
|
|
4
|
+
* Typed, headless-first command engine (Plan 04 Phase 1). One command
|
|
5
|
+
* definition — name + zod input schema + pure handler over a Workspace —
|
|
6
|
+
* yields every surface: the CLI generates flags from the schema, and the
|
|
7
|
+
* JSON-RPC/MCP servers (Phase 3) will consume the same registry.
|
|
8
|
+
*
|
|
9
|
+
* No I/O assumptions: commands see an injected Storage (real fs in Node,
|
|
10
|
+
* memory in tests/browser, IPC-backed in Electron).
|
|
11
|
+
*/
|
|
12
|
+
export { type Storage, MemoryStorage, NodeStorage, normalizeStoragePath, } from "./storage.js";
|
|
13
|
+
export { Workspace } from "./workspace.js";
|
|
14
|
+
export { buildWorkspaceIndex, anchorAliases, anchorAliasTargets, blankCodeRegions, type BuildIndexOptions, type WorkspaceIndex, type DocIndexEntry, type DocHeading, type DocLink, type DocInclude, type TopicMapIndexEntry, type TopicMapRef, type KeyDefinition, type KeyFileError, type InboundRef, type RefKind, } from "./indexes.js";
|
|
15
|
+
export { flagForField, FlagArgumentError, type FlagSpec } from "./flags.js";
|
|
16
|
+
export { commandInputJsonSchema, type CommandJsonSchema } from "./json-schema.js";
|
|
17
|
+
export { defineCommand, CommandRegistry, createTaskQueue, shapeOf, unwrap, isRequired, type CommandDef, type CommandContext, type CommandWrites, type CommandOutput, type CommandResult, type EngineIssue, type IssueSeverity, } from "./engine.js";
|
|
18
|
+
export { relativeHref, replaceLinkHref, replaceIncludePath, replaceMapHref, rewriteInboundRefs, splitFrontmatter, } from "./edits.js";
|
|
19
|
+
import { CommandRegistry } from "./engine.js";
|
|
20
|
+
import { validateCommand } from "./commands/validate.js";
|
|
21
|
+
import { whereUsedCommand } from "./commands/where-used.js";
|
|
22
|
+
import { keysListCommand, keysResolveCommand } from "./commands/keys.js";
|
|
23
|
+
import { topicmapResolveCommand } from "./commands/topicmap.js";
|
|
24
|
+
import { reindexCommand } from "./commands/reindex.js";
|
|
25
|
+
import { renameFileCommand, safeDeleteCommand, extractIncludeCommand } from "./commands/refactor-files.js";
|
|
26
|
+
import { renameKeyCommand, keyifyCommand } from "./commands/refactor-keys.js";
|
|
27
|
+
import { splitTopicCommand, mergeTopicsCommand } from "./commands/refactor-structure.js";
|
|
28
|
+
export { WELL_KNOWN_FIELDS, type FieldSpec, type FrontmatterPolicy, } from "./frontmatter-schema.js";
|
|
29
|
+
export { linkRetargetCommand } from "./commands/link-retarget.js";
|
|
30
|
+
export { validateCommand, whereUsedCommand, keysListCommand, keysResolveCommand, topicmapResolveCommand, reindexCommand, renameFileCommand, safeDeleteCommand, extractIncludeCommand, renameKeyCommand, keyifyCommand, splitTopicCommand, mergeTopicsCommand, };
|
|
31
|
+
export { contentHash } from "./commands/content.js";
|
|
32
|
+
export { topicReadCommand, topicSetTitleCommand, sectionReplaceCommand, blockInsertCommand, blockDeleteCommand, propsGetCommand, propsSetCommand, } from "./commands/content.js";
|
|
33
|
+
export { mapListCommand, mapAddRefCommand, mapMoveRefCommand, mapRemoveRefCommand, mapSetPropsCommand, } from "./commands/topicmap-edit.js";
|
|
34
|
+
export declare const createDefaultRegistry: () => CommandRegistry;
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;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AAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAUzF,OAAO,EACL,iBAAiB,EACjB,KAAK,SAAS,EACd,KAAK,iBAAiB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AASlE,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,kBAAkB,GACnB,CAAC;AACF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,6BAA6B,CAAC;AAIrC,eAAO,MAAM,qBAAqB,QAAO,eA+BxC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @dogsbay/commands
|
|
3
|
+
*
|
|
4
|
+
* Typed, headless-first command engine (Plan 04 Phase 1). One command
|
|
5
|
+
* definition — name + zod input schema + pure handler over a Workspace —
|
|
6
|
+
* yields every surface: the CLI generates flags from the schema, and the
|
|
7
|
+
* JSON-RPC/MCP servers (Phase 3) will consume the same registry.
|
|
8
|
+
*
|
|
9
|
+
* No I/O assumptions: commands see an injected Storage (real fs in Node,
|
|
10
|
+
* memory in tests/browser, IPC-backed in Electron).
|
|
11
|
+
*/
|
|
12
|
+
export { MemoryStorage, NodeStorage, normalizeStoragePath, } from "./storage.js";
|
|
13
|
+
export { Workspace } from "./workspace.js";
|
|
14
|
+
export { buildWorkspaceIndex, anchorAliases, anchorAliasTargets, blankCodeRegions, } from "./indexes.js";
|
|
15
|
+
export { flagForField, FlagArgumentError } from "./flags.js";
|
|
16
|
+
export { commandInputJsonSchema } from "./json-schema.js";
|
|
17
|
+
export { defineCommand, CommandRegistry, createTaskQueue, shapeOf, unwrap, isRequired, } from "./engine.js";
|
|
18
|
+
export { relativeHref, replaceLinkHref, replaceIncludePath, replaceMapHref, rewriteInboundRefs, splitFrontmatter, } from "./edits.js";
|
|
19
|
+
import { CommandRegistry } from "./engine.js";
|
|
20
|
+
import { validateCommand } from "./commands/validate.js";
|
|
21
|
+
import { whereUsedCommand } from "./commands/where-used.js";
|
|
22
|
+
import { keysListCommand, keysResolveCommand } from "./commands/keys.js";
|
|
23
|
+
import { topicmapResolveCommand } from "./commands/topicmap.js";
|
|
24
|
+
import { reindexCommand } from "./commands/reindex.js";
|
|
25
|
+
import { renameFileCommand, safeDeleteCommand, extractIncludeCommand, } from "./commands/refactor-files.js";
|
|
26
|
+
import { renameKeyCommand, keyifyCommand } from "./commands/refactor-keys.js";
|
|
27
|
+
import { splitTopicCommand, mergeTopicsCommand } from "./commands/refactor-structure.js";
|
|
28
|
+
import { topicReadCommand, topicSetTitleCommand, sectionReplaceCommand, blockInsertCommand, blockDeleteCommand, propsGetCommand, propsSetCommand, } from "./commands/content.js";
|
|
29
|
+
export { WELL_KNOWN_FIELDS, } from "./frontmatter-schema.js";
|
|
30
|
+
export { linkRetargetCommand } from "./commands/link-retarget.js";
|
|
31
|
+
import { mapListCommand, mapAddRefCommand, mapMoveRefCommand, mapRemoveRefCommand, mapSetPropsCommand, } from "./commands/topicmap-edit.js";
|
|
32
|
+
export { validateCommand, whereUsedCommand, keysListCommand, keysResolveCommand, topicmapResolveCommand, reindexCommand, renameFileCommand, safeDeleteCommand, extractIncludeCommand, renameKeyCommand, keyifyCommand, splitTopicCommand, mergeTopicsCommand, };
|
|
33
|
+
export { contentHash } from "./commands/content.js";
|
|
34
|
+
export { topicReadCommand, topicSetTitleCommand, sectionReplaceCommand, blockInsertCommand, blockDeleteCommand, propsGetCommand, propsSetCommand, } from "./commands/content.js";
|
|
35
|
+
export { mapListCommand, mapAddRefCommand, mapMoveRefCommand, mapRemoveRefCommand, mapSetPropsCommand, } from "./commands/topicmap-edit.js";
|
|
36
|
+
/** The standard registry with every built-in command registered. */
|
|
37
|
+
import { linkRetargetCommand } from "./commands/link-retarget.js";
|
|
38
|
+
export const createDefaultRegistry = () => {
|
|
39
|
+
const registry = new CommandRegistry();
|
|
40
|
+
registry.register(validateCommand);
|
|
41
|
+
registry.register(whereUsedCommand);
|
|
42
|
+
registry.register(keysListCommand);
|
|
43
|
+
registry.register(keysResolveCommand);
|
|
44
|
+
registry.register(topicmapResolveCommand);
|
|
45
|
+
registry.register(reindexCommand);
|
|
46
|
+
registry.register(renameFileCommand);
|
|
47
|
+
registry.register(safeDeleteCommand);
|
|
48
|
+
registry.register(extractIncludeCommand);
|
|
49
|
+
registry.register(renameKeyCommand);
|
|
50
|
+
registry.register(keyifyCommand);
|
|
51
|
+
registry.register(splitTopicCommand);
|
|
52
|
+
registry.register(mergeTopicsCommand);
|
|
53
|
+
// content verbs (agent-broker Phase 3)
|
|
54
|
+
registry.register(topicReadCommand);
|
|
55
|
+
registry.register(topicSetTitleCommand);
|
|
56
|
+
registry.register(sectionReplaceCommand);
|
|
57
|
+
registry.register(blockInsertCommand);
|
|
58
|
+
registry.register(blockDeleteCommand);
|
|
59
|
+
registry.register(propsGetCommand);
|
|
60
|
+
registry.register(propsSetCommand);
|
|
61
|
+
registry.register(linkRetargetCommand);
|
|
62
|
+
// structure verbs
|
|
63
|
+
registry.register(mapListCommand);
|
|
64
|
+
registry.register(mapAddRefCommand);
|
|
65
|
+
registry.register(mapMoveRefCommand);
|
|
66
|
+
registry.register(mapRemoveRefCommand);
|
|
67
|
+
registry.register(mapSetPropsCommand);
|
|
68
|
+
return registry;
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAEL,aAAa,EACb,WAAW,EACX,oBAAoB,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,gBAAgB,GAajB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAiB,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAA0B,MAAM,kBAAkB,CAAC;AAClF,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,OAAO,EACP,MAAM,EACN,UAAU,GAQX,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,qBAAq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