@sublang/slc 0.1.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/LICENSE +201 -0
- package/README.md +192 -0
- package/dist/app.d.ts +85 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +233 -0
- package/dist/app.js.map +1 -0
- package/dist/artifacts.d.ts +61 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +97 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +26 -0
- package/dist/cli.js.map +1 -0
- package/dist/cligent-agent.d.ts +11 -0
- package/dist/cligent-agent.d.ts.map +1 -0
- package/dist/cligent-agent.js +66 -0
- package/dist/cligent-agent.js.map +1 -0
- package/dist/compiled-executor.d.ts +42 -0
- package/dist/compiled-executor.d.ts.map +1 -0
- package/dist/compiled-executor.js +433 -0
- package/dist/compiled-executor.js.map +1 -0
- package/dist/config-file.d.ts +52 -0
- package/dist/config-file.d.ts.map +1 -0
- package/dist/config-file.js +159 -0
- package/dist/config-file.js.map +1 -0
- package/dist/config.d.ts +82 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +161 -0
- package/dist/config.js.map +1 -0
- package/dist/entry-module.d.ts +22 -0
- package/dist/entry-module.d.ts.map +1 -0
- package/dist/entry-module.js +216 -0
- package/dist/entry-module.js.map +1 -0
- package/dist/execution.d.ts +71 -0
- package/dist/execution.d.ts.map +1 -0
- package/dist/execution.js +207 -0
- package/dist/execution.js.map +1 -0
- package/dist/file-capability.d.ts +46 -0
- package/dist/file-capability.d.ts.map +1 -0
- package/dist/file-capability.js +234 -0
- package/dist/file-capability.js.map +1 -0
- package/dist/file-grants.d.ts +79 -0
- package/dist/file-grants.d.ts.map +1 -0
- package/dist/file-grants.js +133 -0
- package/dist/file-grants.js.map +1 -0
- package/dist/hash.d.ts +14 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +34 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/interpreter.d.ts +48 -0
- package/dist/interpreter.d.ts.map +1 -0
- package/dist/interpreter.js +118 -0
- package/dist/interpreter.js.map +1 -0
- package/dist/invocation.d.ts +64 -0
- package/dist/invocation.d.ts.map +1 -0
- package/dist/invocation.js +148 -0
- package/dist/invocation.js.map +1 -0
- package/dist/link.d.ts +63 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +172 -0
- package/dist/link.js.map +1 -0
- package/dist/markdown.d.ts +12 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +63 -0
- package/dist/markdown.js.map +1 -0
- package/dist/normalize.md +68 -0
- package/dist/phase-runner.d.ts +64 -0
- package/dist/phase-runner.d.ts.map +1 -0
- package/dist/phase-runner.js +322 -0
- package/dist/phase-runner.js.map +1 -0
- package/dist/phase.d.ts +62 -0
- package/dist/phase.d.ts.map +1 -0
- package/dist/phase.js +111 -0
- package/dist/phase.js.map +1 -0
- package/dist/pin-closure.d.ts +19 -0
- package/dist/pin-closure.d.ts.map +1 -0
- package/dist/pin-closure.js +110 -0
- package/dist/pin-closure.js.map +1 -0
- package/dist/pin-currency.d.ts +55 -0
- package/dist/pin-currency.d.ts.map +1 -0
- package/dist/pin-currency.js +435 -0
- package/dist/pin-currency.js.map +1 -0
- package/dist/pin-generate.d.ts +46 -0
- package/dist/pin-generate.d.ts.map +1 -0
- package/dist/pin-generate.js +131 -0
- package/dist/pin-generate.js.map +1 -0
- package/dist/pin-paths.d.ts +11 -0
- package/dist/pin-paths.d.ts.map +1 -0
- package/dist/pin-paths.js +108 -0
- package/dist/pin-paths.js.map +1 -0
- package/dist/pins.d.ts +84 -0
- package/dist/pins.d.ts.map +1 -0
- package/dist/pins.js +265 -0
- package/dist/pins.js.map +1 -0
- package/dist/pipeline.d.ts +61 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +147 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/playbook-contract.d.ts +194 -0
- package/dist/playbook-contract.d.ts.map +1 -0
- package/dist/playbook-contract.js +180 -0
- package/dist/playbook-contract.js.map +1 -0
- package/dist/playbook-ports.d.ts +53 -0
- package/dist/playbook-ports.d.ts.map +1 -0
- package/dist/playbook-ports.js +217 -0
- package/dist/playbook-ports.js.map +1 -0
- package/dist/resolver.d.ts +68 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +133 -0
- package/dist/resolver.js.map +1 -0
- package/dist/runner.d.ts +45 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +506 -0
- package/dist/runner.js.map +1 -0
- package/dist/runtime-package.d.ts +7 -0
- package/dist/runtime-package.d.ts.map +1 -0
- package/dist/runtime-package.js +132 -0
- package/dist/runtime-package.js.map +1 -0
- package/dist/slc.config.template.yaml +5 -0
- package/dist/verify-coverage.d.ts +99 -0
- package/dist/verify-coverage.d.ts.map +1 -0
- package/dist/verify-coverage.js +1949 -0
- package/dist/verify-coverage.js.map +1 -0
- package/dist/verify-support.d.ts +10 -0
- package/dist/verify-support.d.ts.map +1 -0
- package/dist/verify-support.js +52 -0
- package/dist/verify-support.js.map +1 -0
- package/dist/verify.d.ts +393 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +1790 -0
- package/dist/verify.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invocation.js","sourceRoot":"","sources":["../src/invocation.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,0EAA0E;AAoE1E,8EAA8E;AAC9E,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,IAAI,CAAe;IAE5B,YAAY,IAAkB,EAAE,OAAe;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB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C,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;AAClE,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAuB;IAClD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,QAAQ,CAChB,UAAU,EACV,sCAAsC,IAAI,CAAC,MAAM,EAAE,CACpD,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/link.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type FormatDecl } from './phase.js';
|
|
2
|
+
/** A loaded `link.md` reserved link phase. */
|
|
3
|
+
export interface LinkPhase {
|
|
4
|
+
/** Declared object source format. */
|
|
5
|
+
source: FormatDecl;
|
|
6
|
+
/** Declared linked target format (a distinct token from `source`). */
|
|
7
|
+
target: FormatDecl;
|
|
8
|
+
/** Accepted target forms (the `Target form` column); at least one, or empty for the reserved `slc` link. */
|
|
9
|
+
targetForms: string[];
|
|
10
|
+
/** Symbols a link target must export, or empty when unspecified. */
|
|
11
|
+
requiredSymbols: string[];
|
|
12
|
+
/** Supported `--link-option` names, or empty when unspecified. */
|
|
13
|
+
options: string[];
|
|
14
|
+
/** Opaque validation prose for the link phase, or `null` when unspecified. */
|
|
15
|
+
validation: string | null;
|
|
16
|
+
}
|
|
17
|
+
/** Machine-readable reason a link phase or invocation was refused. */
|
|
18
|
+
export type LinkErrorCode = 'missing-formats' | 'malformed-formats' | 'missing-role' | 'missing-link-targets' | 'linked-format-collision' | 'output-required';
|
|
19
|
+
/** Raised when a `link.md` is malformed or a link invocation is invalid (DR-002). */
|
|
20
|
+
export declare class LinkError extends Error {
|
|
21
|
+
readonly code: LinkErrorCode;
|
|
22
|
+
constructor(code: LinkErrorCode, message: string);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Parses a `link.md` definition (PIPE-11, PIPE-19).
|
|
26
|
+
*
|
|
27
|
+
* `## Link Targets` is required, except when the linked target format is the
|
|
28
|
+
* Playbook-owned `playbook` format, whose target validation Playbook owns and
|
|
29
|
+
* which therefore declares none (DR-002, DR-009). The exception keys on the
|
|
30
|
+
* linked target format, not the pipeline name, so a non-`playbook` link missing
|
|
31
|
+
* `## Link Targets` is refused however its pipeline reference resolved.
|
|
32
|
+
*
|
|
33
|
+
* @throws {LinkError} when `## Formats` is missing or malformed, the linked
|
|
34
|
+
* format token equals the object source token, or `## Link Targets` is
|
|
35
|
+
* missing for a non-`playbook` linked format.
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseLinkPhase(content: string): LinkPhase;
|
|
38
|
+
/** Reads and parses a `link.md` file from disk (PIPE-11). */
|
|
39
|
+
export declare function loadLinkFile(path: string): Promise<LinkPhase>;
|
|
40
|
+
/**
|
|
41
|
+
* Computes the linked-artifact path for a full-pipeline link (PIPE-15) or a
|
|
42
|
+
* direct `.link` invocation (PIPE-18).
|
|
43
|
+
*
|
|
44
|
+
* @throws {LinkError} with code `output-required` for a multi-object `.link`
|
|
45
|
+
* without `-o`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function linkedArtifactPath(spec: {
|
|
48
|
+
kind: 'full';
|
|
49
|
+
artDir: string;
|
|
50
|
+
basename: string;
|
|
51
|
+
linked: FormatDecl;
|
|
52
|
+
output: string | null;
|
|
53
|
+
} | {
|
|
54
|
+
kind: 'link';
|
|
55
|
+
pipeline: string;
|
|
56
|
+
objects: readonly string[];
|
|
57
|
+
source: FormatDecl;
|
|
58
|
+
linked: FormatDecl;
|
|
59
|
+
output: string | null;
|
|
60
|
+
/** Invocation working directory anchoring placement (DR-014). */
|
|
61
|
+
cwd: string;
|
|
62
|
+
}): string;
|
|
63
|
+
//# sourceMappingURL=link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,K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;IACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,iEAAiE;IACjE,GAAG,EAAE,MAAM,CAAC;CACb,GACJ,MAAM,CA6BR"}
|
package/dist/link.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
/**
|
|
4
|
+
* Link phase loading and linked-artifact paths (DR-002).
|
|
5
|
+
*
|
|
6
|
+
* Implements PIPE-11 (read `## Formats` and `## Link Targets`, target-form table
|
|
7
|
+
* required and the rest optional), PIPE-19 (refuse a linked format token equal
|
|
8
|
+
* to the object source token; object count/compatibility is the link phase's
|
|
9
|
+
* job), PIPE-15 (full-pipeline linked-artifact path, honoring `-o`), and PIPE-18
|
|
10
|
+
* (direct `.link` path: source-adjacent for one object, `-o`-required for many).
|
|
11
|
+
* Discovery and exclusion from chain inference (PIPE-10) live in pipeline.ts.
|
|
12
|
+
* See specs/dev/pipeline.md.
|
|
13
|
+
*/
|
|
14
|
+
import { readFile } from 'node:fs/promises';
|
|
15
|
+
import { basename as pathBasename, dirname } from 'node:path';
|
|
16
|
+
import { artifactDir, artifactPath } from './artifacts.js';
|
|
17
|
+
import { findSection, parseTable } from './markdown.js';
|
|
18
|
+
import { readFormats } from './phase.js';
|
|
19
|
+
/** Raised when a `link.md` is malformed or a link invocation is invalid (DR-002). */
|
|
20
|
+
export class LinkError extends Error {
|
|
21
|
+
code;
|
|
22
|
+
constructor(code, message) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.name = 'LinkError';
|
|
25
|
+
this.code = code;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The Playbook-owned linked format token; Playbook validates its targets, so a
|
|
30
|
+
* `link.md` emitting it needs no per-pipeline `## Link Targets` (DR-002, DR-009).
|
|
31
|
+
*/
|
|
32
|
+
const PLAYBOOK_LINKED_FORMAT = 'playbook';
|
|
33
|
+
/**
|
|
34
|
+
* Parses a `link.md` definition (PIPE-11, PIPE-19).
|
|
35
|
+
*
|
|
36
|
+
* `## Link Targets` is required, except when the linked target format is the
|
|
37
|
+
* Playbook-owned `playbook` format, whose target validation Playbook owns and
|
|
38
|
+
* which therefore declares none (DR-002, DR-009). The exception keys on the
|
|
39
|
+
* linked target format, not the pipeline name, so a non-`playbook` link missing
|
|
40
|
+
* `## Link Targets` is refused however its pipeline reference resolved.
|
|
41
|
+
*
|
|
42
|
+
* @throws {LinkError} when `## Formats` is missing or malformed, the linked
|
|
43
|
+
* format token equals the object source token, or `## Link Targets` is
|
|
44
|
+
* missing for a non-`playbook` linked format.
|
|
45
|
+
*/
|
|
46
|
+
export function parseLinkPhase(content) {
|
|
47
|
+
const { source, target } = readFormats(content, (code, message) => {
|
|
48
|
+
throw new LinkError(code, message);
|
|
49
|
+
});
|
|
50
|
+
if (source.format === target.format) {
|
|
51
|
+
throw new LinkError('linked-format-collision', `linked format token "${target.format}" must differ from the object source format token`);
|
|
52
|
+
}
|
|
53
|
+
// Playbook owns target validation for its `playbook` linked format, so a
|
|
54
|
+
// `link.md` emitting it carries no ## Link Targets (DR-002, DR-009, PIPE-11).
|
|
55
|
+
const relaxed = target.format === PLAYBOOK_LINKED_FORMAT;
|
|
56
|
+
const section = findSection(content, 'Link Targets');
|
|
57
|
+
if (section === null) {
|
|
58
|
+
if (relaxed) {
|
|
59
|
+
return {
|
|
60
|
+
source,
|
|
61
|
+
target,
|
|
62
|
+
targetForms: [],
|
|
63
|
+
requiredSymbols: [],
|
|
64
|
+
options: [],
|
|
65
|
+
validation: null,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
throw new LinkError('missing-link-targets', 'missing a ## Link Targets section');
|
|
69
|
+
}
|
|
70
|
+
const { targetForms, requiredSymbols, options, validation } = parseLinkTargets(section);
|
|
71
|
+
if (targetForms.length === 0 && !relaxed) {
|
|
72
|
+
throw new LinkError('missing-link-targets', '## Link Targets has no target-form rows');
|
|
73
|
+
}
|
|
74
|
+
return { source, target, targetForms, requiredSymbols, options, validation };
|
|
75
|
+
}
|
|
76
|
+
/** Reads and parses a `link.md` file from disk (PIPE-11). */
|
|
77
|
+
export async function loadLinkFile(path) {
|
|
78
|
+
return parseLinkPhase(await readFile(path, 'utf8'));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Computes the linked-artifact path for a full-pipeline link (PIPE-15) or a
|
|
82
|
+
* direct `.link` invocation (PIPE-18).
|
|
83
|
+
*
|
|
84
|
+
* @throws {LinkError} with code `output-required` for a multi-object `.link`
|
|
85
|
+
* without `-o`.
|
|
86
|
+
*/
|
|
87
|
+
export function linkedArtifactPath(spec) {
|
|
88
|
+
if (spec.kind === 'full') {
|
|
89
|
+
return (spec.output ??
|
|
90
|
+
artifactPath(spec.artDir, spec.basename, spec.linked.format, spec.linked.ext));
|
|
91
|
+
}
|
|
92
|
+
if (spec.objects.length === 1) {
|
|
93
|
+
const { basename } = deriveObjectBasename(spec.objects[0], spec.source);
|
|
94
|
+
const artDir = artifactDir(spec.cwd, basename, spec.pipeline);
|
|
95
|
+
return (spec.output ??
|
|
96
|
+
artifactPath(artDir, basename, spec.linked.format, spec.linked.ext));
|
|
97
|
+
}
|
|
98
|
+
if (spec.output === null) {
|
|
99
|
+
throw new LinkError('output-required', `a .link with ${spec.objects.length} objects requires -o <linked-target>`);
|
|
100
|
+
}
|
|
101
|
+
return spec.output;
|
|
102
|
+
}
|
|
103
|
+
/** Partitions the `## Link Targets` section into its labeled blocks. */
|
|
104
|
+
function parseLinkTargets(lines) {
|
|
105
|
+
const labels = [
|
|
106
|
+
{ key: 'required', re: /^required symbols:?$/i },
|
|
107
|
+
{ key: 'options', re: /^options:?$/i },
|
|
108
|
+
{ key: 'validation', re: /^validation:?$/i },
|
|
109
|
+
];
|
|
110
|
+
const segments = {
|
|
111
|
+
targets: [],
|
|
112
|
+
required: [],
|
|
113
|
+
options: [],
|
|
114
|
+
validation: [],
|
|
115
|
+
};
|
|
116
|
+
let current = 'targets';
|
|
117
|
+
for (const raw of lines) {
|
|
118
|
+
const label = labels.find((entry) => entry.re.test(raw.trim()));
|
|
119
|
+
if (label) {
|
|
120
|
+
current = label.key;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
segments[current].push(raw);
|
|
124
|
+
}
|
|
125
|
+
const validation = segments.validation.join('\n').trim();
|
|
126
|
+
return {
|
|
127
|
+
targetForms: columnAfterHeader(segments.targets, 'target form'),
|
|
128
|
+
requiredSymbols: listItems(segments.required),
|
|
129
|
+
options: columnAfterHeader(segments.options, 'name'),
|
|
130
|
+
validation: validation.length > 0 ? validation : null,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Returns the data-row first column of the table in `lines`, requiring its
|
|
135
|
+
* header row's first cell to equal `header` (lowercase). Returns an empty array
|
|
136
|
+
* when no such table is present, so a missing or mis-headed required table is
|
|
137
|
+
* caught by the caller's emptiness check rather than leaking the header as data.
|
|
138
|
+
*/
|
|
139
|
+
function columnAfterHeader(lines, header) {
|
|
140
|
+
const rows = parseTable(lines);
|
|
141
|
+
if (rows.length === 0 || rows[0][0].toLowerCase() !== header) {
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
return rows
|
|
145
|
+
.slice(1)
|
|
146
|
+
.map((cells) => cells[0])
|
|
147
|
+
.filter((cell) => cell.length > 0);
|
|
148
|
+
}
|
|
149
|
+
/** Returns the bullet-list item texts in `lines`. */
|
|
150
|
+
function listItems(lines) {
|
|
151
|
+
const items = [];
|
|
152
|
+
for (const raw of lines) {
|
|
153
|
+
const match = /^[-*]\s+(.+)$/.exec(raw.trim());
|
|
154
|
+
if (match)
|
|
155
|
+
items.push(match[1].trim());
|
|
156
|
+
}
|
|
157
|
+
return items;
|
|
158
|
+
}
|
|
159
|
+
/** Derives a basename and directory from a single object, leniently (PIPE-18, PIPE-19). */
|
|
160
|
+
function deriveObjectBasename(objectPath, source) {
|
|
161
|
+
const name = pathBasename(objectPath);
|
|
162
|
+
const dir = dirname(objectPath);
|
|
163
|
+
let stem = name.endsWith(source.ext)
|
|
164
|
+
? name.slice(0, name.length - source.ext.length)
|
|
165
|
+
: name;
|
|
166
|
+
const qualifier = `.${source.format}`;
|
|
167
|
+
if (stem.endsWith(qualifier)) {
|
|
168
|
+
stem = stem.slice(0, stem.length - qualifier.length);
|
|
169
|
+
}
|
|
170
|
+
return { basename: stem, dir };
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=link.js.map
|
package/dist/link.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,0EAA0E;AAE1E;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAmB,WAAW,EAAE,MAAM,YAAY,CAAC;AA2B1D,qFAAqF;AACrF,MAAM,OAAO,SAAU,SAAQ,KAAK;IACzB,IAAI,CAAgB;IAE7B,YAAY,IAAmB,EAAE,OAAe;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,sBAAsB,GAAG,UAAU,CAAC;AAE1C;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC,OAA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,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the lines beneath a heading named `heading` (case-insensitive, any
|
|
3
|
+
* level), up to the next heading, or `null` when the heading is absent.
|
|
4
|
+
*/
|
|
5
|
+
export declare function findSection(content: string, heading: string): string[] | null;
|
|
6
|
+
/**
|
|
7
|
+
* Parses pipe-delimited table rows from `lines` into trimmed cell arrays,
|
|
8
|
+
* dropping the separator row. The header row is returned and left for callers to
|
|
9
|
+
* recognize and skip.
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseTable(lines: readonly string[]): string[][];
|
|
12
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAaA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAyB7E;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAc/D"}
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
/**
|
|
4
|
+
* Minimal markdown helpers shared by the phase and link loaders: locating a
|
|
5
|
+
* named section and reading GitHub-flavored table rows. Not a general parser;
|
|
6
|
+
* just enough to read the `## Formats` and `## Link Targets` blocks DR-001 and
|
|
7
|
+
* DR-002 define.
|
|
8
|
+
*/
|
|
9
|
+
const HEADING = /^#{1,6}\s/;
|
|
10
|
+
const SEPARATOR_CELL = /^:?-+:?$/;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the lines beneath a heading named `heading` (case-insensitive, any
|
|
13
|
+
* level), up to the next heading, or `null` when the heading is absent.
|
|
14
|
+
*/
|
|
15
|
+
export function findSection(content, heading) {
|
|
16
|
+
const lines = content.split(/\r?\n/);
|
|
17
|
+
const wanted = heading.trim().toLowerCase();
|
|
18
|
+
let start = -1;
|
|
19
|
+
for (let i = 0; i < lines.length; i++) {
|
|
20
|
+
const line = lines[i].trim();
|
|
21
|
+
if (HEADING.test(line) &&
|
|
22
|
+
line
|
|
23
|
+
.replace(/^#{1,6}\s+/, '')
|
|
24
|
+
.trim()
|
|
25
|
+
.toLowerCase() === wanted) {
|
|
26
|
+
start = i;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (start === -1)
|
|
31
|
+
return null;
|
|
32
|
+
const body = [];
|
|
33
|
+
for (let i = start + 1; i < lines.length; i++) {
|
|
34
|
+
if (HEADING.test(lines[i].trim()))
|
|
35
|
+
break;
|
|
36
|
+
body.push(lines[i]);
|
|
37
|
+
}
|
|
38
|
+
return body;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Parses pipe-delimited table rows from `lines` into trimmed cell arrays,
|
|
42
|
+
* dropping the separator row. The header row is returned and left for callers to
|
|
43
|
+
* recognize and skip.
|
|
44
|
+
*/
|
|
45
|
+
export function parseTable(lines) {
|
|
46
|
+
const rows = [];
|
|
47
|
+
for (const raw of lines) {
|
|
48
|
+
const line = raw.trim();
|
|
49
|
+
if (!line.startsWith('|'))
|
|
50
|
+
continue;
|
|
51
|
+
const cells = line
|
|
52
|
+
.split('|')
|
|
53
|
+
.slice(1, -1)
|
|
54
|
+
.map((cell) => cell.trim());
|
|
55
|
+
if (cells.length === 0)
|
|
56
|
+
continue;
|
|
57
|
+
if (cells.every((cell) => SEPARATOR_CELL.test(cell)))
|
|
58
|
+
continue;
|
|
59
|
+
rows.push(cells);
|
|
60
|
+
}
|
|
61
|
+
return rows;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,0EAA0E;AAE1E;;;;;GAKG;AAEH,MAAM,OAAO,GAAG,WAAW,CAAC;AAC5B,MAAM,cAAc,GAAG,UAAU,CAAC;AAElC;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,OAAe;IAC1D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC5C,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7B,IACE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;YAClB,IAAI;iBACD,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;iBACzB,IAAI,EAAE;iBACN,WAAW,EAAE,KAAK,MAAM,EAC3B,CAAC;YACD,KAAK,GAAG,CAAC,CAAC;YACV,MAAM;QACR,CAAC;IACH,CAAC;IACD,IAAI,KAAK,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAE9B,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,KAAK,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAAE,MAAM;QACzC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,KAAwB;IACjD,MAAM,IAAI,GAAe,EAAE,CAAC;IAC5B,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS;QACpC,MAAM,KAAK,GAAG,IAAI;aACf,KAAK,CAAC,GAAG,CAAC;aACV,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;aACZ,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,SAAS;QACjC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAAE,SAAS;QAC/D,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
2
|
+
<!-- SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai> -->
|
|
3
|
+
|
|
4
|
+
# Input Normalization
|
|
5
|
+
|
|
6
|
+
Generic pre-phase of any slc pipeline.
|
|
7
|
+
Rewrites a raw user description into a source document that satisfies the
|
|
8
|
+
target pipeline's entry-phase requirements, so free-form input compiles
|
|
9
|
+
reliably regardless of which pipeline consumes it.
|
|
10
|
+
|
|
11
|
+
- Source: raw free-form user input, in any language and layout.
|
|
12
|
+
- Target: a pipeline-ready source document for the pipeline's entry phase.
|
|
13
|
+
|
|
14
|
+
This definition is pipeline-agnostic.
|
|
15
|
+
The concrete requirements come from the **entry-phase definition supplied as a
|
|
16
|
+
read-only reference input**: the normalizer shall read that definition and
|
|
17
|
+
produce a source satisfying its stated Source expectations (declared sections,
|
|
18
|
+
naming rules, structural conventions).
|
|
19
|
+
|
|
20
|
+
## Formats
|
|
21
|
+
|
|
22
|
+
| Role | Format | Extension |
|
|
23
|
+
| ------ | ------ | --------- |
|
|
24
|
+
| source | text | .md |
|
|
25
|
+
| target | text | .md |
|
|
26
|
+
|
|
27
|
+
The concrete target format token and extension are the entry phase's declared
|
|
28
|
+
source format and extension; the driver supplies the exact target path.
|
|
29
|
+
|
|
30
|
+
## Fidelity
|
|
31
|
+
|
|
32
|
+
Normalization restructures; it does not reinterpret:
|
|
33
|
+
|
|
34
|
+
- Preserve the described procedure's meaning, ordering, actors, and
|
|
35
|
+
terminology exactly. Do not add, drop, merge, or reorder steps.
|
|
36
|
+
- Keep the target in the same language as the raw input. Do not translate.
|
|
37
|
+
- Do not invent actors, conditions, or requirements the input does not state
|
|
38
|
+
or directly assume.
|
|
39
|
+
- Quote or restate the input's own wording where the entry phase permits
|
|
40
|
+
prose; prefer the original phrasing over paraphrase.
|
|
41
|
+
|
|
42
|
+
## Structure
|
|
43
|
+
|
|
44
|
+
Where the entry-phase definition supports declared structure, make the raw
|
|
45
|
+
input's implicit structure explicit:
|
|
46
|
+
|
|
47
|
+
- Declare each distinct actor the input describes, following the entry
|
|
48
|
+
phase's naming rules (e.g. an opening `Players:` section), assigning each a
|
|
49
|
+
stable name in the source language when the input leaves actors unnamed.
|
|
50
|
+
- Present the procedure as clearly delimited steps or clauses when the entry
|
|
51
|
+
phase benefits from them, preserving the input's order.
|
|
52
|
+
|
|
53
|
+
## Preconditions
|
|
54
|
+
|
|
55
|
+
An action's implicit executability precondition — state the action requires
|
|
56
|
+
of the environment before it can succeed — may be surfaced as one explicit
|
|
57
|
+
setup step that establishes the precondition when absent.
|
|
58
|
+
E.g., a procedure that commits to a version-control repository assumes the
|
|
59
|
+
working directory is such a repository; normalization may add a setup step
|
|
60
|
+
that checks for the repository and initializes it when missing.
|
|
61
|
+
Surface only preconditions the described actions directly require; do not
|
|
62
|
+
speculate about the wider environment.
|
|
63
|
+
|
|
64
|
+
## Output
|
|
65
|
+
|
|
66
|
+
Write only the normalized source document to the target path.
|
|
67
|
+
Do not emit commentary, the entry-phase definition, or this definition's text
|
|
68
|
+
into the target.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ExecutorResult } from './execution.js';
|
|
2
|
+
/** What a compiled phase is asked to produce: a compile target or a linked artifact (DR-005). */
|
|
3
|
+
export type PhaseInput = {
|
|
4
|
+
kind: 'compile';
|
|
5
|
+
source: string;
|
|
6
|
+
target: string;
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'link';
|
|
9
|
+
objects: string[];
|
|
10
|
+
linkTarget: string;
|
|
11
|
+
options: Record<string, string>;
|
|
12
|
+
linked: string;
|
|
13
|
+
};
|
|
14
|
+
/** A compiled phase's terminal outcome, with diagnostics drained for every status (DR-005). */
|
|
15
|
+
export interface PhaseResult {
|
|
16
|
+
status: 'ok' | 'blocked' | 'error';
|
|
17
|
+
diagnostics: string[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Maps a compiled phase's {@link PhaseResult} onto the DR-003 execution-boundary
|
|
21
|
+
* outcome consumed by `runPhase` (PHEXEC-24).
|
|
22
|
+
*
|
|
23
|
+
* The facade result (owned by the DR-005 artifact contract) and the executor
|
|
24
|
+
* result (owned by the DR-003 boundary) are distinct types, so the compiled
|
|
25
|
+
* executor crosses the boundary through this seam rather than casting: `ok`
|
|
26
|
+
* proceeds to the generic checks, `blocked` is the BLOCKED outcome, and `error`
|
|
27
|
+
* stops the pipeline like a failed generic check, with diagnostics surfaced for
|
|
28
|
+
* every status.
|
|
29
|
+
*/
|
|
30
|
+
export declare function mapPhaseResult(result: PhaseResult): ExecutorResult;
|
|
31
|
+
/**
|
|
32
|
+
* Reports whether a compiled artifact's source resolves to the linked `playbook`
|
|
33
|
+
* format: a module exposing a `createPlaybookRuntime` default export (DR-005).
|
|
34
|
+
* This is the static byte-level recognition the pin-currency validator uses; the
|
|
35
|
+
* loader confirms the contract at run time.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolvesToPlaybook(source: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Seeds a phase request into the single non-interactive Boss turn `slc` hands
|
|
40
|
+
* the runtime through `handleBossInput` (PHEXEC-29; DR-005).
|
|
41
|
+
*
|
|
42
|
+
* The settled SLC-to-runtime seeding contract: one Boss turn whose text states
|
|
43
|
+
* the request kind in prose — so any compiled playbook's judge-backed classifier
|
|
44
|
+
* can route it — and carries the full request as a single-line JSON object
|
|
45
|
+
* introduced by `Request: `, with workspace paths already resolved to absolute
|
|
46
|
+
* host paths, so a runtime (or a deterministic fixture) recovers the exact
|
|
47
|
+
* `PhaseInput` without host-specific parsing.
|
|
48
|
+
*/
|
|
49
|
+
export declare function seedPhaseTurn(input: PhaseInput): string;
|
|
50
|
+
/**
|
|
51
|
+
* Composes the host workspace contract a transformation-performing direct
|
|
52
|
+
* Captain call carries (PHEXEC-34; DR-005, DR-012).
|
|
53
|
+
*
|
|
54
|
+
* A linked `playbook` artifact composes host-agnostic Captain prompts — the
|
|
55
|
+
* GEARS-derived domain body plus typed runtime evidence — and is forbidden from
|
|
56
|
+
* appending workspace specifics, which only the host owns. Mirroring the
|
|
57
|
+
* interpreted agent contract (PHEXEC-14), the host therefore supplies the
|
|
58
|
+
* request's absolute workspace paths and write-scope rules at its transport
|
|
59
|
+
* boundary, so the acting Captain writes exactly the declared target instead
|
|
60
|
+
* of merely emitting the artifact in its reply. Routing-only Captain calls
|
|
61
|
+
* (explicitly empty `allowedTools`) and hidden judge calls never carry it.
|
|
62
|
+
*/
|
|
63
|
+
export declare function composeWorkspaceContract(input: PhaseInput): string;
|
|
64
|
+
//# sourceMappingURL=phase-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phase-runner.d.ts","sourceRoot":"","sources":["../src/phase-runner.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,iGAAiG;AACjG,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACnD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEN,+FAA+F;AAC/F,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC;IACnC,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,cAAc,CAElE;AAID;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAyE1D;AA0ND;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAMvD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAwBlE"}
|