@kanonak-protocol/cli 1.4.0 → 1.6.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/dist/agents/AgentDeploymentHandler.d.ts +19 -0
- package/dist/agents/AgentLock.d.ts +15 -0
- package/dist/agents/AgentPaths.d.ts +23 -0
- package/dist/capabilities/DeploymentHandlerRegistry.d.ts +14 -3
- package/dist/index.js +114 -47
- package/dist/skills/SkillDeploymentHandler.d.ts +8 -6
- package/dist/skills/SkillPaths.d.ts +23 -10
- package/dist/transformations/CompiledTransformation.d.ts +146 -0
- package/dist/transformations/DocAst.d.ts +84 -0
- package/dist/transformations/ExpressionEngine.d.ts +28 -0
- package/dist/transformations/ReferenceResolver.d.ts +20 -0
- package/dist/transformations/TransformationLoader.d.ts +20 -0
- package/dist/transformations/TransformationRunner.d.ts +57 -0
- package/dist/transformations/UriConstants.d.ts +145 -0
- package/dist/transformations/backends/HtmlBackend.d.ts +7 -0
- package/dist/transformations/backends/IDocumentAstBackend.d.ts +16 -0
- package/dist/transformations/backends/JsonBackend.d.ts +12 -0
- package/dist/transformations/backends/MarkdownFrontmatterBackend.d.ts +7 -0
- package/dist/transformations/backends/SimpleMarkdownRenderer.d.ts +17 -0
- package/dist/transformations/backends/SvgBackend.d.ts +7 -0
- package/dist/transformations/backends/TomlBackend.d.ts +7 -0
- package/package.json +6 -4
- package/dist/skills/SkillTransformer.d.ts +0 -19
|
@@ -1,27 +1,40 @@
|
|
|
1
|
+
import type { IKanonakDocumentRepository } from '@kanonak-protocol/sdk';
|
|
1
2
|
/**
|
|
2
3
|
* Options for resolving skill discovery paths.
|
|
3
4
|
*/
|
|
4
5
|
export interface SkillPathOptions {
|
|
6
|
+
/**
|
|
7
|
+
* clientId of a named Client instance in the agent-skills ontology
|
|
8
|
+
* (e.g. "agents", "claude-code"). When omitted, the CLI first tries
|
|
9
|
+
* `detectClient()` on process env vars, then falls back to the
|
|
10
|
+
* "agents" cross-client default.
|
|
11
|
+
*/
|
|
5
12
|
client?: string;
|
|
13
|
+
/** "project" (default) or "user". */
|
|
6
14
|
scope?: string;
|
|
7
15
|
}
|
|
8
16
|
/**
|
|
9
|
-
* Resolve the skills directory
|
|
17
|
+
* Resolve the skills directory for the requested client and scope.
|
|
10
18
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
19
|
+
* This goes through the SDK object model: the agent-skills ontology
|
|
20
|
+
* is parsed, Client instances are looked up by URI, and the matching
|
|
21
|
+
* Client's `projectSkillDir` or `userSkillDir` is read. No hardcoded
|
|
22
|
+
* path templates, no alias string-stripping — the installer adapts
|
|
23
|
+
* to whatever named Client instances exist in the ontology at
|
|
24
|
+
* runtime.
|
|
16
25
|
*/
|
|
17
|
-
export declare function resolveSkillsDir(options: SkillPathOptions): string
|
|
26
|
+
export declare function resolveSkillsDir(options: SkillPathOptions, repository: IKanonakDocumentRepository): Promise<string>;
|
|
18
27
|
/**
|
|
19
|
-
* Resolve the directory for a specific skill.
|
|
28
|
+
* Resolve the directory for a specific skill by name.
|
|
20
29
|
*/
|
|
21
|
-
export declare function resolveSkillDir(skillName: string, options: SkillPathOptions): string
|
|
30
|
+
export declare function resolveSkillDir(skillName: string, options: SkillPathOptions, repository: IKanonakDocumentRepository): Promise<string>;
|
|
22
31
|
/**
|
|
23
32
|
* Auto-detect the current AI agent client from environment variables.
|
|
33
|
+
* Returns a clientId matching a named Client instance in the
|
|
34
|
+
* agent-skills ontology, or undefined when nothing is detected.
|
|
24
35
|
*
|
|
25
|
-
*
|
|
36
|
+
* Matches the default Client instances declared in
|
|
37
|
+
* kanonak.org/agent-skills@1.1.0. Extend this mapping when adding
|
|
38
|
+
* new named Client instances with their own env-var signature.
|
|
26
39
|
*/
|
|
27
40
|
export declare function detectClient(): string | undefined;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed, parsed-once representation of a Transformation ontology
|
|
3
|
+
* instance. Produced by `TransformationLoader` from a `SubjectKanonak`
|
|
4
|
+
* of type `kanonak.org/transformations/Transformation`; consumed by
|
|
5
|
+
* `TransformationRunner` and `ExpressionEngine`.
|
|
6
|
+
*
|
|
7
|
+
* Separating the compiled form from the raw SDK object model means
|
|
8
|
+
* expression evaluation is a plain-data walk with no repeated
|
|
9
|
+
* predicate-URI matching per step. Compilation validates shape and
|
|
10
|
+
* throws with a BuilderNode path breadcrumb on first error.
|
|
11
|
+
*/
|
|
12
|
+
import type { EntityUri } from '../capabilities/UriHelpers.js';
|
|
13
|
+
export type NormalizeKindName = 'trim-end';
|
|
14
|
+
export interface CompiledTransformation {
|
|
15
|
+
/** The transformation entity's own local name, for diagnostics. */
|
|
16
|
+
name: string;
|
|
17
|
+
inputPattern: CompiledInputPattern;
|
|
18
|
+
rule: CompiledExpression;
|
|
19
|
+
artifactName: CompiledExpression;
|
|
20
|
+
/**
|
|
21
|
+
* The set of OutputFormat URIs this transformation supports,
|
|
22
|
+
* keyed by the OutputFormat's local name (not its backendUri).
|
|
23
|
+
* The runner rejects requests to render in a format not in this set.
|
|
24
|
+
*/
|
|
25
|
+
outputs: Set<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Per-format overrides keyed by the OutputFormat's local name.
|
|
28
|
+
*/
|
|
29
|
+
overrides: Map<string, CompiledFormatOverride>;
|
|
30
|
+
}
|
|
31
|
+
export interface CompiledInputPattern {
|
|
32
|
+
/** The class URI whose instances this transformation matches. */
|
|
33
|
+
matchesClass: EntityUri;
|
|
34
|
+
/**
|
|
35
|
+
* Property URIs that must resolve to a non-empty value on the
|
|
36
|
+
* input subject. Missing-required instances are silently skipped.
|
|
37
|
+
*/
|
|
38
|
+
requires: EntityUri[];
|
|
39
|
+
}
|
|
40
|
+
export interface CompiledFormatOverride {
|
|
41
|
+
/**
|
|
42
|
+
* Optional include list of metadata entry keys the backend should
|
|
43
|
+
* emit, in order. Keys outside this list are skipped. If omitted,
|
|
44
|
+
* the backend emits all metadata entries in their AST order.
|
|
45
|
+
*/
|
|
46
|
+
metadataKeys?: string[];
|
|
47
|
+
/** AST-key → emitted-key renames. */
|
|
48
|
+
metadataRenames: Map<string, string>;
|
|
49
|
+
/** Whether to append a final newline to the serialized output. */
|
|
50
|
+
trailingNewline?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export type CompiledExpression = CompiledBuildAstNode | CompiledForEach | CompiledWhen | CompiledConcat | CompiledStringLiteral | CompiledIntegerLiteral | CompiledBooleanLiteral | CompiledVarRef | CompiledPropertyRead | CompiledTraverse | CompiledFallback | CompiledUriName | CompiledListMap | CompiledJoin | CompiledNormalize | CompiledIsSet | CompiledUriLiteral | CompiledDisplayLabel;
|
|
53
|
+
export interface CompiledBuildAstNode {
|
|
54
|
+
kind: 'build-ast-node';
|
|
55
|
+
astClass: EntityUri;
|
|
56
|
+
set: CompiledBinding[];
|
|
57
|
+
}
|
|
58
|
+
export interface CompiledForEach {
|
|
59
|
+
kind: 'for-each';
|
|
60
|
+
iterate: CompiledExpression;
|
|
61
|
+
loopVar: string;
|
|
62
|
+
emit: CompiledExpression;
|
|
63
|
+
}
|
|
64
|
+
export interface CompiledWhen {
|
|
65
|
+
kind: 'when';
|
|
66
|
+
condition: CompiledExpression;
|
|
67
|
+
thenBuild: CompiledExpression;
|
|
68
|
+
elseBuild?: CompiledExpression;
|
|
69
|
+
}
|
|
70
|
+
export interface CompiledConcat {
|
|
71
|
+
kind: 'concat';
|
|
72
|
+
parts: CompiledExpression[];
|
|
73
|
+
}
|
|
74
|
+
export interface CompiledStringLiteral {
|
|
75
|
+
kind: 'string-literal';
|
|
76
|
+
value: string;
|
|
77
|
+
}
|
|
78
|
+
export interface CompiledIntegerLiteral {
|
|
79
|
+
kind: 'integer-literal';
|
|
80
|
+
value: number;
|
|
81
|
+
}
|
|
82
|
+
export interface CompiledBooleanLiteral {
|
|
83
|
+
kind: 'boolean-literal';
|
|
84
|
+
value: boolean;
|
|
85
|
+
}
|
|
86
|
+
export interface CompiledVarRef {
|
|
87
|
+
kind: 'var-ref';
|
|
88
|
+
varName: string;
|
|
89
|
+
}
|
|
90
|
+
export interface CompiledPropertyRead {
|
|
91
|
+
kind: 'property-read';
|
|
92
|
+
source: CompiledExpression;
|
|
93
|
+
readProp: EntityUri;
|
|
94
|
+
}
|
|
95
|
+
export interface CompiledTraverse {
|
|
96
|
+
kind: 'traverse';
|
|
97
|
+
source: CompiledExpression;
|
|
98
|
+
through: EntityUri;
|
|
99
|
+
step: CompiledExpression;
|
|
100
|
+
}
|
|
101
|
+
export interface CompiledFallback {
|
|
102
|
+
kind: 'fallback';
|
|
103
|
+
primary: CompiledExpression;
|
|
104
|
+
alternate: CompiledExpression;
|
|
105
|
+
}
|
|
106
|
+
export interface CompiledUriName {
|
|
107
|
+
kind: 'uri-name';
|
|
108
|
+
of: CompiledExpression;
|
|
109
|
+
}
|
|
110
|
+
export interface CompiledListMap {
|
|
111
|
+
kind: 'list-map';
|
|
112
|
+
source: CompiledExpression;
|
|
113
|
+
loopVar: string;
|
|
114
|
+
mapBody: CompiledExpression;
|
|
115
|
+
}
|
|
116
|
+
export interface CompiledJoin {
|
|
117
|
+
kind: 'join';
|
|
118
|
+
separator: string;
|
|
119
|
+
items: CompiledExpression;
|
|
120
|
+
}
|
|
121
|
+
export interface CompiledNormalize {
|
|
122
|
+
kind: 'normalize';
|
|
123
|
+
source: CompiledExpression;
|
|
124
|
+
normKind: NormalizeKindName;
|
|
125
|
+
}
|
|
126
|
+
export interface CompiledIsSet {
|
|
127
|
+
kind: 'is-set';
|
|
128
|
+
check: CompiledExpression;
|
|
129
|
+
}
|
|
130
|
+
export interface CompiledUriLiteral {
|
|
131
|
+
kind: 'uri-literal';
|
|
132
|
+
refTo: EntityUri;
|
|
133
|
+
}
|
|
134
|
+
export interface CompiledDisplayLabel {
|
|
135
|
+
kind: 'display-label';
|
|
136
|
+
/** The entity whose display label this expression resolves. */
|
|
137
|
+
labelTarget: EntityUri;
|
|
138
|
+
/** The property to read off the target for the display value. */
|
|
139
|
+
labelSource: EntityUri;
|
|
140
|
+
}
|
|
141
|
+
export interface CompiledBinding {
|
|
142
|
+
/** The document-ast property URI being bound. */
|
|
143
|
+
field: EntityUri;
|
|
144
|
+
/** Expression that produces the bound value. */
|
|
145
|
+
value: CompiledExpression;
|
|
146
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluates a `CompiledExpression` tree against an input binding
|
|
3
|
+
* environment. Handles both value-producing kinds (property-read,
|
|
4
|
+
* traverse, fallback, ...) and structure-building kinds
|
|
5
|
+
* (build-ast-node, for-each, when, concat) under a single dispatch.
|
|
6
|
+
*
|
|
7
|
+
* All property reads walk `statement[]` by canonical predicate URI
|
|
8
|
+
* (via `UriHelpers`). Reference resolution during traverse goes
|
|
9
|
+
* through the shared `ReferenceResolver`. No string heuristics, no
|
|
10
|
+
* YAML hand-parsing.
|
|
11
|
+
*/
|
|
12
|
+
import { type Kanonak, type KanonakUri } from '@kanonak-protocol/sdk';
|
|
13
|
+
import { ReferenceResolver } from './ReferenceResolver.js';
|
|
14
|
+
import type { CompiledExpression } from './CompiledTransformation.js';
|
|
15
|
+
import { DOCAST } from './UriConstants.js';
|
|
16
|
+
export type EnvValue = string | number | boolean | Kanonak | Kanonak[] | KanonakUri | unknown[] | object | undefined | null;
|
|
17
|
+
export type Env = Map<string, EnvValue>;
|
|
18
|
+
export declare class ExpressionEvalError extends Error {
|
|
19
|
+
constructor(message: string);
|
|
20
|
+
}
|
|
21
|
+
export declare class ExpressionEngine {
|
|
22
|
+
private readonly resolver;
|
|
23
|
+
private readonly allKanonaks;
|
|
24
|
+
constructor(resolver: ReferenceResolver, allKanonaks: Kanonak[]);
|
|
25
|
+
evaluate(expr: CompiledExpression, env: Env): Promise<EnvValue>;
|
|
26
|
+
private buildAstNode;
|
|
27
|
+
}
|
|
28
|
+
export { DOCAST };
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compiles a Kanonak `Transformation` subject into a typed
|
|
3
|
+
* CompiledTransformation. All property reads go through
|
|
4
|
+
* `UriHelpers`; no string matching, no YAML hand-parsing. Throws
|
|
5
|
+
* `TransformationLoadError` with a breadcrumb path on the first
|
|
6
|
+
* shape violation.
|
|
7
|
+
*/
|
|
8
|
+
import { SubjectKanonak, type Kanonak } from '@kanonak-protocol/sdk';
|
|
9
|
+
import { type EntityUri } from '../capabilities/UriHelpers.js';
|
|
10
|
+
import type { CompiledTransformation } from './CompiledTransformation.js';
|
|
11
|
+
export declare class TransformationLoadError extends Error {
|
|
12
|
+
readonly path: string;
|
|
13
|
+
constructor(message: string, path: string);
|
|
14
|
+
}
|
|
15
|
+
export declare function compileTransformation(transformation: SubjectKanonak, allKanonaks: Kanonak[]): CompiledTransformation;
|
|
16
|
+
/**
|
|
17
|
+
* Reference to a transformations-ontology entity (used externally
|
|
18
|
+
* to look up named Transformation instances by local name).
|
|
19
|
+
*/
|
|
20
|
+
export declare function findTransformation(kanonaks: Kanonak[], uri: EntityUri): SubjectKanonak | undefined;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Top-level entry point for the generic transformation runner.
|
|
3
|
+
*
|
|
4
|
+
* Given a Transformation SubjectKanonak, a list of candidate input
|
|
5
|
+
* instances, the broader repository (for reference resolution), and
|
|
6
|
+
* the desired OutputFormat, produces a list of in-memory `Artifact`
|
|
7
|
+
* records. The runner never touches the filesystem — writing is the
|
|
8
|
+
* deployment handler's job.
|
|
9
|
+
*
|
|
10
|
+
* Pipeline per input:
|
|
11
|
+
* 1. Filter by InputPattern.matchesClass + requires.
|
|
12
|
+
* 2. Evaluate `rule` → DocAstDocument.
|
|
13
|
+
* 3. Evaluate `artifactName` → filename stem.
|
|
14
|
+
* 4. Look up backend by OutputFormat's local name.
|
|
15
|
+
* 5. Apply FormatOverride for that format if present.
|
|
16
|
+
* 6. Serialize → bytes → wrap as Artifact.
|
|
17
|
+
*/
|
|
18
|
+
import { KanonakParser, KanonakObjectParser, SubjectKanonak, type Kanonak, type IKanonakDocumentRepository } from '@kanonak-protocol/sdk';
|
|
19
|
+
import type { IDocumentAstBackend } from './backends/IDocumentAstBackend.js';
|
|
20
|
+
export interface Artifact {
|
|
21
|
+
/** Filename stem with no directory and no extension. */
|
|
22
|
+
fileName: string;
|
|
23
|
+
/** The OutputFormat local name this artifact was serialized as. */
|
|
24
|
+
format: string;
|
|
25
|
+
/** The serialized bytes (UTF-8 string). */
|
|
26
|
+
content: string;
|
|
27
|
+
/** The source subject this artifact was produced from. */
|
|
28
|
+
sourceName: string;
|
|
29
|
+
}
|
|
30
|
+
export interface RunInput {
|
|
31
|
+
transformation: SubjectKanonak;
|
|
32
|
+
/** Candidate input subjects to run the transformation against. */
|
|
33
|
+
instances: SubjectKanonak[];
|
|
34
|
+
allKanonaks: Kanonak[];
|
|
35
|
+
/**
|
|
36
|
+
* Optional: the Kanonaks of the transformation's own package
|
|
37
|
+
* (plus any packages hosting fragments the transformation calls).
|
|
38
|
+
* Used at compile time to resolve `call-fragment` references. If
|
|
39
|
+
* the transformation does not use fragments this can be left
|
|
40
|
+
* undefined — the retrofit Skill/Agent cases pass nothing.
|
|
41
|
+
*/
|
|
42
|
+
transformationKanonaks?: Kanonak[];
|
|
43
|
+
repository: IKanonakDocumentRepository;
|
|
44
|
+
parser: KanonakParser;
|
|
45
|
+
objectParser: KanonakObjectParser;
|
|
46
|
+
/** The OutputFormat local name (e.g. `'markdown-with-frontmatter'`). */
|
|
47
|
+
outputFormat: string;
|
|
48
|
+
}
|
|
49
|
+
export declare class TransformationRunnerError extends Error {
|
|
50
|
+
}
|
|
51
|
+
export declare class TransformationRunner {
|
|
52
|
+
private readonly backends;
|
|
53
|
+
constructor();
|
|
54
|
+
register(backend: IDocumentAstBackend): void;
|
|
55
|
+
run(input: RunInput): Promise<Artifact[]>;
|
|
56
|
+
private findBackendForFormat;
|
|
57
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hardcoded canonical URIs for the document-ast and transformations
|
|
3
|
+
* ontologies. Per `typescript/CLAUDE.md` rule 6, hardcoded URI
|
|
4
|
+
* constants are fine and expected — they are the ontology contract.
|
|
5
|
+
* String-based alias or suffix matching is NOT.
|
|
6
|
+
*
|
|
7
|
+
* Every comparison in the runner is KanonakUri → EntityUri equality
|
|
8
|
+
* (publisher + package + name), never string manipulation of YAML
|
|
9
|
+
* keys or alias prefixes.
|
|
10
|
+
*/
|
|
11
|
+
import type { EntityUri } from '../capabilities/UriHelpers.js';
|
|
12
|
+
export declare const DOCAST_PUB = "kanonak.org";
|
|
13
|
+
export declare const DOCAST_PKG = "document-ast";
|
|
14
|
+
export declare const DOCAST: {
|
|
15
|
+
readonly Document: EntityUri;
|
|
16
|
+
readonly Block: EntityUri;
|
|
17
|
+
readonly Inline: EntityUri;
|
|
18
|
+
readonly StructuredValue: EntityUri;
|
|
19
|
+
readonly Heading: EntityUri;
|
|
20
|
+
readonly Paragraph: EntityUri;
|
|
21
|
+
readonly RawBlock: EntityUri;
|
|
22
|
+
readonly Text: EntityUri;
|
|
23
|
+
readonly StructuredMap: EntityUri;
|
|
24
|
+
readonly StructuredEntry: EntityUri;
|
|
25
|
+
readonly StructuredList: EntityUri;
|
|
26
|
+
readonly StringScalar: EntityUri;
|
|
27
|
+
readonly IntegerScalar: EntityUri;
|
|
28
|
+
readonly EscapeHint: EntityUri;
|
|
29
|
+
readonly MediaType: EntityUri;
|
|
30
|
+
readonly metadata: EntityUri;
|
|
31
|
+
readonly children: EntityUri;
|
|
32
|
+
readonly level: EntityUri;
|
|
33
|
+
readonly inlines: EntityUri;
|
|
34
|
+
readonly text: EntityUri;
|
|
35
|
+
readonly entries: EntityUri;
|
|
36
|
+
readonly key: EntityUri;
|
|
37
|
+
readonly value: EntityUri;
|
|
38
|
+
readonly escapeHint: EntityUri;
|
|
39
|
+
readonly items: EntityUri;
|
|
40
|
+
readonly stringValue: EntityUri;
|
|
41
|
+
readonly integerValue: EntityUri;
|
|
42
|
+
readonly rawContent: EntityUri;
|
|
43
|
+
readonly mediaType: EntityUri;
|
|
44
|
+
readonly mimeType: EntityUri;
|
|
45
|
+
readonly ESC_RAW: EntityUri;
|
|
46
|
+
readonly ESC_YAML_SAFE: EntityUri;
|
|
47
|
+
readonly ESC_TOML_STRING: EntityUri;
|
|
48
|
+
readonly ESC_TOML_MULTILINE: EntityUri;
|
|
49
|
+
readonly ESC_JSON: EntityUri;
|
|
50
|
+
readonly TEXT_PLAIN: EntityUri;
|
|
51
|
+
readonly TEXT_MARKDOWN: EntityUri;
|
|
52
|
+
readonly TEXT_HTML: EntityUri;
|
|
53
|
+
readonly APPLICATION_JSON: EntityUri;
|
|
54
|
+
readonly TEXT_YAML: EntityUri;
|
|
55
|
+
readonly IMAGE_SVG_XML: EntityUri;
|
|
56
|
+
};
|
|
57
|
+
export declare const TX_PUB = "kanonak.org";
|
|
58
|
+
export declare const TX_PKG = "transformations";
|
|
59
|
+
export declare const TX: {
|
|
60
|
+
readonly Transformation: EntityUri;
|
|
61
|
+
readonly InputPattern: EntityUri;
|
|
62
|
+
readonly Expression: EntityUri;
|
|
63
|
+
readonly ExpressionKind: EntityUri;
|
|
64
|
+
readonly ExpressionFragment: EntityUri;
|
|
65
|
+
readonly AstFieldBinding: EntityUri;
|
|
66
|
+
readonly OutputFormat: EntityUri;
|
|
67
|
+
readonly FormatOverride: EntityUri;
|
|
68
|
+
readonly RenameEntry: EntityUri;
|
|
69
|
+
readonly Artifact: EntityUri;
|
|
70
|
+
readonly NormalizeKind: EntityUri;
|
|
71
|
+
readonly inputPattern: EntityUri;
|
|
72
|
+
readonly rule: EntityUri;
|
|
73
|
+
readonly artifactName: EntityUri;
|
|
74
|
+
readonly outputs: EntityUri;
|
|
75
|
+
readonly formatOverrides: EntityUri;
|
|
76
|
+
readonly matchesClass: EntityUri;
|
|
77
|
+
readonly requires: EntityUri;
|
|
78
|
+
readonly kind: EntityUri;
|
|
79
|
+
readonly astClass: EntityUri;
|
|
80
|
+
readonly set: EntityUri;
|
|
81
|
+
readonly iterate: EntityUri;
|
|
82
|
+
readonly loopVar: EntityUri;
|
|
83
|
+
readonly emit: EntityUri;
|
|
84
|
+
readonly condition: EntityUri;
|
|
85
|
+
readonly thenBuild: EntityUri;
|
|
86
|
+
readonly elseBuild: EntityUri;
|
|
87
|
+
readonly parts: EntityUri;
|
|
88
|
+
readonly stringLiteral: EntityUri;
|
|
89
|
+
readonly integerLiteral: EntityUri;
|
|
90
|
+
readonly booleanLiteral: EntityUri;
|
|
91
|
+
readonly varName: EntityUri;
|
|
92
|
+
readonly readSource: EntityUri;
|
|
93
|
+
readonly readProp: EntityUri;
|
|
94
|
+
readonly traverseSource: EntityUri;
|
|
95
|
+
readonly through: EntityUri;
|
|
96
|
+
readonly step: EntityUri;
|
|
97
|
+
readonly primary: EntityUri;
|
|
98
|
+
readonly alternate: EntityUri;
|
|
99
|
+
readonly uriNameOf: EntityUri;
|
|
100
|
+
readonly listMapSource: EntityUri;
|
|
101
|
+
readonly mapBody: EntityUri;
|
|
102
|
+
readonly separator: EntityUri;
|
|
103
|
+
readonly items: EntityUri;
|
|
104
|
+
readonly normSource: EntityUri;
|
|
105
|
+
readonly normKind: EntityUri;
|
|
106
|
+
readonly checkExpr: EntityUri;
|
|
107
|
+
readonly refTo: EntityUri;
|
|
108
|
+
readonly fragmentRef: EntityUri;
|
|
109
|
+
readonly expr: EntityUri;
|
|
110
|
+
readonly labelTarget: EntityUri;
|
|
111
|
+
readonly labelSource: EntityUri;
|
|
112
|
+
readonly field: EntityUri;
|
|
113
|
+
readonly bindValue: EntityUri;
|
|
114
|
+
readonly backendUri: EntityUri;
|
|
115
|
+
readonly formatTarget: EntityUri;
|
|
116
|
+
readonly metadataKeys: EntityUri;
|
|
117
|
+
readonly metadataRenames: EntityUri;
|
|
118
|
+
readonly trailingNewline: EntityUri;
|
|
119
|
+
readonly fromKey: EntityUri;
|
|
120
|
+
readonly toKey: EntityUri;
|
|
121
|
+
readonly KIND_BUILD_AST_NODE: EntityUri;
|
|
122
|
+
readonly KIND_FOR_EACH: EntityUri;
|
|
123
|
+
readonly KIND_WHEN: EntityUri;
|
|
124
|
+
readonly KIND_CONCAT: EntityUri;
|
|
125
|
+
readonly KIND_STRING_LITERAL: EntityUri;
|
|
126
|
+
readonly KIND_INTEGER_LITERAL: EntityUri;
|
|
127
|
+
readonly KIND_BOOLEAN_LITERAL: EntityUri;
|
|
128
|
+
readonly KIND_VAR_REF: EntityUri;
|
|
129
|
+
readonly KIND_PROPERTY_READ: EntityUri;
|
|
130
|
+
readonly KIND_TRAVERSE: EntityUri;
|
|
131
|
+
readonly KIND_FALLBACK: EntityUri;
|
|
132
|
+
readonly KIND_URI_NAME: EntityUri;
|
|
133
|
+
readonly KIND_LIST_MAP: EntityUri;
|
|
134
|
+
readonly KIND_JOIN: EntityUri;
|
|
135
|
+
readonly KIND_NORMALIZE: EntityUri;
|
|
136
|
+
readonly KIND_IS_SET: EntityUri;
|
|
137
|
+
readonly KIND_URI_LITERAL: EntityUri;
|
|
138
|
+
readonly KIND_CALL_FRAGMENT: EntityUri;
|
|
139
|
+
readonly KIND_DISPLAY_LABEL: EntityUri;
|
|
140
|
+
readonly NORM_TRIM_END: EntityUri;
|
|
141
|
+
readonly FMT_MARKDOWN_FRONTMATTER: EntityUri;
|
|
142
|
+
readonly FMT_TOML: EntityUri;
|
|
143
|
+
readonly FMT_JSON: EntityUri;
|
|
144
|
+
readonly FMT_PLAIN_MARKDOWN: EntityUri;
|
|
145
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DocAstDocument } from '../DocAst.js';
|
|
2
|
+
import type { CompiledFormatOverride } from '../CompiledTransformation.js';
|
|
3
|
+
import type { IDocumentAstBackend } from './IDocumentAstBackend.js';
|
|
4
|
+
export declare class HtmlBackend implements IDocumentAstBackend {
|
|
5
|
+
readonly backendUri = "kanonak.org/transformations/backend/html";
|
|
6
|
+
render(document: DocAstDocument, override?: CompiledFormatOverride): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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 { CompiledFormatOverride } from '../CompiledTransformation.js';
|
|
12
|
+
export interface IDocumentAstBackend {
|
|
13
|
+
/** The backendUri string this backend registers under. */
|
|
14
|
+
readonly backendUri: string;
|
|
15
|
+
render(document: DocAstDocument, override?: CompiledFormatOverride): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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 { CompiledFormatOverride } from '../CompiledTransformation.js';
|
|
8
|
+
import type { IDocumentAstBackend } from './IDocumentAstBackend.js';
|
|
9
|
+
export declare class JsonBackend implements IDocumentAstBackend {
|
|
10
|
+
readonly backendUri = "kanonak.org/transformations/backend/json";
|
|
11
|
+
render(document: DocAstDocument, override?: CompiledFormatOverride): string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DocAstDocument } from '../DocAst.js';
|
|
2
|
+
import type { CompiledFormatOverride } from '../CompiledTransformation.js';
|
|
3
|
+
import type { IDocumentAstBackend } from './IDocumentAstBackend.js';
|
|
4
|
+
export declare class MarkdownFrontmatterBackend implements IDocumentAstBackend {
|
|
5
|
+
readonly backendUri = "kanonak.org/transformations/backend/markdown-with-frontmatter";
|
|
6
|
+
render(document: DocAstDocument, override?: CompiledFormatOverride): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DocAstDocument } from '../DocAst.js';
|
|
2
|
+
import type { CompiledFormatOverride } from '../CompiledTransformation.js';
|
|
3
|
+
import type { IDocumentAstBackend } from './IDocumentAstBackend.js';
|
|
4
|
+
export declare class SvgBackend implements IDocumentAstBackend {
|
|
5
|
+
readonly backendUri = "kanonak.org/transformations/backend/svg";
|
|
6
|
+
render(document: DocAstDocument, override?: CompiledFormatOverride): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DocAstDocument } from '../DocAst.js';
|
|
2
|
+
import type { CompiledFormatOverride } from '../CompiledTransformation.js';
|
|
3
|
+
import type { IDocumentAstBackend } from './IDocumentAstBackend.js';
|
|
4
|
+
export declare class TomlBackend implements IDocumentAstBackend {
|
|
5
|
+
readonly backendUri = "kanonak.org/transformations/backend/toml";
|
|
6
|
+
render(document: DocAstDocument, override?: CompiledFormatOverride): string;
|
|
7
|
+
}
|