@kanonak-protocol/cli 3.11.0 → 3.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanonak-protocol/cli",
3
- "version": "3.11.0",
3
+ "version": "3.13.0",
4
4
  "description": "Kanonak Protocol CLI - Validate and resolve Kanonak ontology packages",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -34,8 +34,8 @@
34
34
  "semantic-web"
35
35
  ],
36
36
  "dependencies": {
37
- "@kanonak-protocol/sdk": "^3.11.0",
38
- "@kanonak-protocol/types": "^3.11.0",
37
+ "@kanonak-protocol/sdk": "^3.13.0",
38
+ "@kanonak-protocol/types": "^3.13.0",
39
39
  "commander": "^13.0.0",
40
40
  "js-yaml": "^4.1.1"
41
41
  },
@@ -1,28 +0,0 @@
1
- import type { KanonakDocument, Import, DocumentReference } from '@kanonak-protocol/types/document/models/types';
2
- import type { IKanonakDocumentRepository } from '@kanonak-protocol/sdk';
3
- /**
4
- * A repository that exposes exactly one target document through
5
- * `getAllDocumentsAsync` but delegates every import-resolution lookup
6
- * (`getHighestCompatibleVersionAsync`, `getDocumentAsync`, etc.) to a
7
- * broader backing repository.
8
- *
9
- * This is what lets `KanonakObjectParser.parseKanonaks` parse a single
10
- * capability or skill document with full URI resolution across its
11
- * transitive imports, without inheriting every other cached document's
12
- * entities.
13
- */
14
- export declare class SingleDocumentRepository implements IKanonakDocumentRepository {
15
- private readonly doc;
16
- private readonly broader;
17
- constructor(doc: KanonakDocument, broader: IKanonakDocumentRepository);
18
- getAllDocumentsAsync(): Promise<KanonakDocument[]>;
19
- getDocumentAsync(identifier: string): Promise<KanonakDocument | null>;
20
- getDocumentsByNamespaceAsync(publisher: string, package_: string): Promise<KanonakDocument[]>;
21
- getHighestCompatibleVersionAsync(publisher: string, import_: Import): Promise<KanonakDocument | null>;
22
- saveDocumentAsync(): Promise<void>;
23
- deleteDocumentAsync(): Promise<void>;
24
- clearNamespaceAsync(): Promise<void>;
25
- getAllDocumentReferencesAsync(): Promise<DocumentReference[]>;
26
- getDocumentContentAsync(identifier: string): Promise<string | null>;
27
- getDocumentUriAsync(identifier: string): Promise<string | null>;
28
- }
@@ -1,85 +0,0 @@
1
- import { SubjectKanonak, EmbeddedKanonak, DefinedKanonak, Kanonak, KanonakUri } from '@kanonak-protocol/sdk';
2
- /**
3
- * Canonical URI identity for an ontology entity.
4
- *
5
- * Version is intentionally omitted: the CLI compares against
6
- * publisher + package + name so it can accept any backwards-compatible
7
- * version of the ontology it was built against. If a new major version
8
- * breaks semantics, a separate entry (or explicit version check) is
9
- * added at that point.
10
- */
11
- export interface EntityUri {
12
- publisher: string;
13
- package_: string;
14
- name: string;
15
- }
16
- /**
17
- * Convert a `KanonakUri` or `EntityUri` into a stable map key.
18
- * Version is dropped.
19
- */
20
- export declare function uriKey(uri: KanonakUri | EntityUri): string;
21
- /**
22
- * True when a resolved `KanonakUri` matches the given publisher + package
23
- * + local name (version ignored).
24
- */
25
- export declare function uriMatches(uri: KanonakUri, target: EntityUri): boolean;
26
- /**
27
- * True when a `Kanonak` is a `DefinedKanonak` whose `type` statement's
28
- * object URI matches the given class URI.
29
- */
30
- export declare function hasType(kanonak: Kanonak, target: EntityUri): boolean;
31
- /**
32
- * Filter a list of parsed kanonaks down to `SubjectKanonak`s whose type
33
- * matches the given class URI.
34
- */
35
- export declare function findSubjectsByType(kanonaks: Kanonak[], target: EntityUri): SubjectKanonak[];
36
- /**
37
- * Look up a `SubjectKanonak` by full URI across a list of kanonaks.
38
- * Used for following a reference to its definition (e.g. to read a
39
- * `License`'s `spdxId` or a `Tool`'s `label`).
40
- *
41
- * Version handling:
42
- *
43
- * - When `uri.version` is present (concrete `M.m.p`), the match
44
- * is STRICT — only a subject whose `namespace` is exactly
45
- * `<publisher>/<package>@<M.m.p>` qualifies. This is what
46
- * `tx.ResolveRef` needs when walking inner references in a
47
- * multi-scope SetTransformation: a reference to
48
- * `pkg@1.0.1/foo` must resolve to the 1.0.1 instance, not
49
- * collapse to whichever same-named instance was loaded first
50
- * across versions (kanonak-protocol/typescript#12).
51
- *
52
- * - When `uri.version` is absent (an unversioned reference, e.g.
53
- * authored as `pkg/foo` with no `@version` qualifier or coming
54
- * from an `EntityUri` that carries no version), the match is
55
- * LENIENT — any version of `<publisher>/<package>/<name>`
56
- * qualifies. This preserves the historical behavior for
57
- * callers that pass version-less URIs (UriLiteral, parsed
58
- * bare-name references in single-version workspaces, etc).
59
- */
60
- export declare function findSubjectByUri(kanonaks: Kanonak[], uri: KanonakUri): SubjectKanonak | undefined;
61
- /**
62
- * Read a datatype property value (string, number, boolean) off a defined
63
- * kanonak, by property URI. Returns `undefined` when the property is not
64
- * set or not a datatype value.
65
- */
66
- export declare function getDatatypeValue(defined: DefinedKanonak, property: EntityUri): string | number | boolean | undefined;
67
- export declare function getStringValue(defined: DefinedKanonak, property: EntityUri): string | undefined;
68
- /**
69
- * Read the target `KanonakUri` of an ObjectProperty reference off a
70
- * defined kanonak, by property URI. Returns `undefined` when the
71
- * property is not set or not a reference statement.
72
- */
73
- export declare function getReferenceUri(defined: DefinedKanonak, property: EntityUri): KanonakUri | undefined;
74
- /**
75
- * Read an embedded kanonak off a defined kanonak, by property URI.
76
- * Returns `undefined` when the property is not set or not an embedded
77
- * statement.
78
- */
79
- export declare function getEmbeddedValue(defined: DefinedKanonak, property: EntityUri): EmbeddedKanonak | undefined;
80
- /**
81
- * Read the list values off a ListStatement property. Each item is either
82
- * a `ReferenceKanonak` (named reference) or an `EmbeddedKanonak` (inline).
83
- * Returns an empty array when the property is unset or not a list.
84
- */
85
- export declare function getListValues(defined: DefinedKanonak, property: EntityUri): Kanonak[];
@@ -1,84 +0,0 @@
1
- /**
2
- * In-memory document AST types.
3
- *
4
- * Runtime-only: built by the ExpressionEngine during transformation
5
- * evaluation, consumed by format backends. The ontology in
6
- * `kanonak.org/document-ast@1.0.0` is the external contract; these
7
- * TypeScript types are the internal representation.
8
- *
9
- * Each node carries a `kind` discriminant whose value is the local
10
- * name of the document-ast Class URI (e.g. `'Document'`, `'Heading'`).
11
- * The discriminant is a plain string because the AST never leaves the
12
- * runner — no Kanonak URI comparisons happen against AST nodes, only
13
- * against the ontology entities that describe them.
14
- *
15
- * `escapeHint` is a full EntityUri, not a string, so backends compare
16
- * against `DOCAST.ESC_RAW` etc. via `uriMatches` — maintaining URI
17
- * equality end-to-end.
18
- */
19
- import type { EntityUri } from '../capabilities/UriHelpers.js';
20
- export interface DocAstDocument {
21
- kind: 'Document';
22
- metadata?: DocAstStructuredMap;
23
- children: DocAstBlock[];
24
- }
25
- export type DocAstBlock = DocAstHeading | DocAstParagraph | DocAstRawBlock;
26
- export interface DocAstHeading {
27
- kind: 'Heading';
28
- level: number;
29
- inlines: DocAstInline[];
30
- }
31
- export interface DocAstParagraph {
32
- kind: 'Paragraph';
33
- inlines: DocAstInline[];
34
- }
35
- /**
36
- * Pre-formatted content in a declared media type. Borrowed from
37
- * Pandoc's `RawBlock(format, content)`. The `mediaType` is a full
38
- * EntityUri referencing a named MediaType instance from
39
- * `kanonak.org/document-ast@1.0.0` (e.g. DOCAST.TEXT_MARKDOWN).
40
- *
41
- * Backends dispatch by URI: HTML runs markdown through a renderer,
42
- * passes HTML through verbatim, and falls back to escaped `<pre>`
43
- * for unknown media types. Markdown backends emit the content
44
- * verbatim because it's already in a text format.
45
- */
46
- export interface DocAstRawBlock {
47
- kind: 'RawBlock';
48
- mediaType?: EntityUri;
49
- rawContent: string;
50
- }
51
- export type DocAstInline = DocAstText;
52
- export interface DocAstText {
53
- kind: 'Text';
54
- text: string;
55
- }
56
- export type DocAstStructuredValue = DocAstStructuredMap | DocAstStructuredList | DocAstStringScalar | DocAstIntegerScalar;
57
- export interface DocAstStructuredMap {
58
- kind: 'StructuredMap';
59
- entries: DocAstStructuredEntry[];
60
- }
61
- export interface DocAstStructuredEntry {
62
- kind: 'StructuredEntry';
63
- key: string;
64
- value: DocAstStructuredValue;
65
- /**
66
- * Per-entry serialization hint — one of the named EscapeHint
67
- * instances from `kanonak.org/document-ast@1.0.0`. Stored as a
68
- * full `EntityUri` so backends compare by canonical URI, never
69
- * by string local name.
70
- */
71
- escapeHint?: EntityUri;
72
- }
73
- export interface DocAstStructuredList {
74
- kind: 'StructuredList';
75
- items: DocAstStructuredValue[];
76
- }
77
- export interface DocAstStringScalar {
78
- kind: 'StringScalar';
79
- stringValue: string;
80
- }
81
- export interface DocAstIntegerScalar {
82
- kind: 'IntegerScalar';
83
- integerValue: number;
84
- }
@@ -1,57 +0,0 @@
1
- /**
2
- * Hardcoded canonical URIs for the document-ast ontology.
3
- *
4
- * Version-agnostic — docast is its own ontology and doesn't move
5
- * with the transformations major version. Both the v2 runtime
6
- * (legacy) and the v3 runtime read from this same file.
7
- *
8
- * Per the typescript repo's CLAUDE.md rule 6, hardcoded URI
9
- * constants are fine and expected — they are the ontology contract.
10
- * String-based alias or suffix matching is NOT.
11
- */
12
- import type { EntityUri } from '../capabilities/UriHelpers.js';
13
- export declare const DOCAST_PUB = "kanonak.org";
14
- export declare const DOCAST_PKG = "document-ast";
15
- export declare const DOCAST: {
16
- readonly Document: EntityUri;
17
- readonly Block: EntityUri;
18
- readonly Inline: EntityUri;
19
- readonly StructuredValue: EntityUri;
20
- readonly Heading: EntityUri;
21
- readonly Paragraph: EntityUri;
22
- readonly RawBlock: EntityUri;
23
- readonly Text: EntityUri;
24
- readonly StructuredMap: EntityUri;
25
- readonly StructuredEntry: EntityUri;
26
- readonly StructuredList: EntityUri;
27
- readonly StringScalar: EntityUri;
28
- readonly IntegerScalar: EntityUri;
29
- readonly EscapeHint: EntityUri;
30
- readonly MediaType: EntityUri;
31
- readonly metadata: EntityUri;
32
- readonly children: EntityUri;
33
- readonly level: EntityUri;
34
- readonly inlines: EntityUri;
35
- readonly text: EntityUri;
36
- readonly entries: EntityUri;
37
- readonly key: EntityUri;
38
- readonly value: EntityUri;
39
- readonly escapeHint: EntityUri;
40
- readonly items: EntityUri;
41
- readonly stringValue: EntityUri;
42
- readonly integerValue: EntityUri;
43
- readonly rawContent: EntityUri;
44
- readonly mediaType: EntityUri;
45
- readonly mimeType: EntityUri;
46
- readonly ESC_RAW: EntityUri;
47
- readonly ESC_YAML_SAFE: EntityUri;
48
- readonly ESC_TOML_STRING: EntityUri;
49
- readonly ESC_TOML_MULTILINE: EntityUri;
50
- readonly ESC_JSON: EntityUri;
51
- readonly TEXT_PLAIN: EntityUri;
52
- readonly TEXT_MARKDOWN: EntityUri;
53
- readonly TEXT_HTML: EntityUri;
54
- readonly APPLICATION_JSON: EntityUri;
55
- readonly TEXT_YAML: EntityUri;
56
- readonly IMAGE_SVG_XML: EntityUri;
57
- };
@@ -1,34 +0,0 @@
1
- /**
2
- * Backend-facing FormatOverride contract.
3
- *
4
- * Version-agnostic — backends operate on docast trees and accept
5
- * format-specific tweaks via this shape, regardless of which
6
- * transformation runtime produced it. Each runtime version compiles
7
- * its FormatOverride YAML into a value of this shape before handing
8
- * it to a backend.
9
- */
10
- export interface BackendFormatOverride {
11
- /**
12
- * Optional include-list of metadata entry keys the backend should
13
- * emit, in order. Keys outside this list are skipped. If omitted,
14
- * the backend emits all metadata entries in their AST order.
15
- */
16
- metadataKeys?: string[];
17
- /** AST-key → emitted-key renames. */
18
- metadataRenames: Map<string, string>;
19
- /** Whether to append a final newline to the serialized output. */
20
- trailingNewline?: boolean;
21
- /**
22
- * Suppress the backend's default chrome (e.g. the HTML backend's
23
- * `<!DOCTYPE html><html>...<style>...</style>...</html>` wrapper
24
- * and its `<dl class="metadata">` block). When true, the backend
25
- * emits ONLY the rendered content from `document.children`,
26
- * without any framing — useful for transformations that build
27
- * the entire HTML document themselves and don't want the CLI's
28
- * opinionated default getting in the way.
29
- *
30
- * Backends that have no chrome (e.g. JSON, plain Markdown) ignore
31
- * this flag.
32
- */
33
- omitWrapper?: boolean;
34
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Resolves a `KanonakUri` to its defining `SubjectKanonak`, following
3
- * cross-package imports through a broader repository.
4
- *
5
- * Extracted from `SkillTransformer.ts:189-235` so the transformation
6
- * engine and any other consumer can share a single cached resolver.
7
- * Behavior is identical to the original — local shadowing first,
8
- * then a cache-keyed lookup in the broader repository, with a final
9
- * name-based fallback for edge cases where the parser emits a
10
- * namespace string that doesn't start with the expected prefix.
11
- */
12
- import { KanonakParser, KanonakObjectParser, SubjectKanonak, type Kanonak, type KanonakUri, type IKanonakDocumentRepository } from '@kanonak-protocol/sdk';
13
- export declare class ReferenceResolver {
14
- private readonly repository;
15
- private readonly parser;
16
- private readonly objectParser;
17
- private readonly cache;
18
- constructor(repository: IKanonakDocumentRepository, parser: KanonakParser, objectParser: KanonakObjectParser);
19
- resolveSubject(uri: KanonakUri, localKanonaks: Kanonak[]): Promise<SubjectKanonak | undefined>;
20
- }
@@ -1,7 +0,0 @@
1
- import type { DocAstDocument } from '../DocAst.js';
2
- import type { BackendFormatOverride } from '../FormatOverride.js';
3
- import type { IDocumentAstBackend } from './IDocumentAstBackend.js';
4
- export declare class HtmlBackend implements IDocumentAstBackend {
5
- readonly backendUri = "kanonak.org/transformations/html";
6
- render(document: DocAstDocument, override?: BackendFormatOverride): string;
7
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * Format backend interface. Given a document-ast Document tree and
3
- * an optional per-transformation format override, produce the
4
- * serialized bytes of the artifact as a string.
5
- *
6
- * Backends are pure functions of (document, override) — they never
7
- * touch the filesystem or the repository. That's the deployment
8
- * handler's job.
9
- */
10
- import type { DocAstDocument } from '../DocAst.js';
11
- import type { BackendFormatOverride } from '../FormatOverride.js';
12
- export interface IDocumentAstBackend {
13
- /** The backendUri string this backend registers under. */
14
- readonly backendUri: string;
15
- render(document: DocAstDocument, override?: BackendFormatOverride): string;
16
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Trivial JSON backend. Serializes the full Document (both channels)
3
- * as pretty-printed JSON. Useful as a regression-test oracle that is
4
- * immune to the whitespace sensitivity of the text backends.
5
- */
6
- import type { DocAstDocument } from '../DocAst.js';
7
- import type { BackendFormatOverride } from '../FormatOverride.js';
8
- import type { IDocumentAstBackend } from './IDocumentAstBackend.js';
9
- export declare class JsonBackend implements IDocumentAstBackend {
10
- readonly backendUri = "kanonak.org/transformations/json";
11
- render(document: DocAstDocument, override?: BackendFormatOverride): string;
12
- }
@@ -1,7 +0,0 @@
1
- import type { DocAstDocument } from '../DocAst.js';
2
- import type { BackendFormatOverride } from '../FormatOverride.js';
3
- import type { IDocumentAstBackend } from './IDocumentAstBackend.js';
4
- export declare class MarkdownFrontmatterBackend implements IDocumentAstBackend {
5
- readonly backendUri = "kanonak.org/transformations/markdown-with-frontmatter";
6
- render(document: DocAstDocument, override?: BackendFormatOverride): string;
7
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * Minimal CommonMark-ish markdown → HTML renderer.
3
- *
4
- * Covers the subset of markdown the Skill hasSection bodies actually
5
- * use: ATX headings (# through ######), paragraphs, fenced code
6
- * blocks (```lang\n...\n```), inline code (`code`), bold (**text**),
7
- * italic (*text* or _text_), unordered lists (- or * item), ordered
8
- * lists (1. item), links ([text](url)), and GitHub-flavored tables
9
- * (| header | header | ... |). Does NOT handle blockquotes,
10
- * reference-style links, HTML passthrough, setext headings, or
11
- * pipe-escape in table cells.
12
- *
13
- * Intentionally self-contained (no dependencies). If a real CommonMark
14
- * implementation is ever needed, swap this file out — nothing else in
15
- * the transformation system depends on its internals.
16
- */
17
- export declare function renderMarkdownToHtml(source: string): string;
@@ -1,7 +0,0 @@
1
- import type { DocAstDocument } from '../DocAst.js';
2
- import type { BackendFormatOverride } from '../FormatOverride.js';
3
- import type { IDocumentAstBackend } from './IDocumentAstBackend.js';
4
- export declare class SvgBackend implements IDocumentAstBackend {
5
- readonly backendUri = "kanonak.org/transformations/svg";
6
- render(document: DocAstDocument, override?: BackendFormatOverride): string;
7
- }
@@ -1,7 +0,0 @@
1
- import type { DocAstDocument } from '../DocAst.js';
2
- import type { BackendFormatOverride } from '../FormatOverride.js';
3
- import type { IDocumentAstBackend } from './IDocumentAstBackend.js';
4
- export declare class TomlBackend implements IDocumentAstBackend {
5
- readonly backendUri = "kanonak.org/transformations/toml";
6
- render(document: DocAstDocument, override?: BackendFormatOverride): string;
7
- }