md-pipe 0.5.3 → 0.5.5
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/cli-contract.yaml +10 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +85 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.js +28 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +176 -0
- package/dist/config.js.map +1 -0
- package/dist/generated/commands.d.ts +7 -0
- package/dist/generated/commands.js +67 -0
- package/dist/generated/commands.js.map +1 -0
- package/dist/generated/index.d.ts +6 -0
- package/dist/generated/index.js +7 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/policy-runtime.d.ts +113 -0
- package/dist/generated/policy-runtime.js +195 -0
- package/dist/generated/policy-runtime.js.map +1 -0
- package/dist/generated/policy.d.ts +116 -0
- package/dist/generated/policy.js +165 -0
- package/dist/generated/policy.js.map +1 -0
- package/dist/generated/program.d.ts +21 -0
- package/dist/generated/program.js +54 -0
- package/dist/generated/program.js.map +1 -0
- package/dist/generated/schemas.d.ts +26 -0
- package/dist/generated/schemas.js +30 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +67 -0
- package/dist/generated/types.js +3 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/pipeline/html.d.ts +2 -0
- package/dist/pipeline/html.js +91 -0
- package/dist/pipeline/html.js.map +1 -0
- package/dist/pipeline/index.d.ts +2 -0
- package/dist/pipeline/index.js +48 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/pdf.d.ts +2 -0
- package/dist/pipeline/pdf.js +87 -0
- package/dist/pipeline/pdf.js.map +1 -0
- package/dist/pipeline/preprocess.d.ts +2 -0
- package/dist/pipeline/preprocess.js +134 -0
- package/dist/pipeline/preprocess.js.map +1 -0
- package/dist/pipeline/render.d.ts +1 -0
- package/dist/pipeline/render.js +5 -0
- package/dist/pipeline/render.js.map +1 -0
- package/dist/pipeline/transform.d.ts +2 -0
- package/dist/pipeline/transform.js +75 -0
- package/dist/pipeline/transform.js.map +1 -0
- package/dist/types.d.ts +104 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/docs/cli-reference.md +2 -0
- package/package.json +3 -2
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// Standalone policy runtime. Copied by cli-contracts generate.
|
|
2
|
+
// This file is self-contained — no imports from cli-contracts internals.
|
|
3
|
+
// ─── Risk Level Ordering ────────────────────────────────────────
|
|
4
|
+
const RISK_ORDER = {
|
|
5
|
+
low: 0,
|
|
6
|
+
medium: 1,
|
|
7
|
+
high: 2,
|
|
8
|
+
critical: 3,
|
|
9
|
+
};
|
|
10
|
+
function maxRiskLevel(...levels) {
|
|
11
|
+
let max = "low";
|
|
12
|
+
for (const level of levels) {
|
|
13
|
+
if (RISK_ORDER[level] > RISK_ORDER[max]) {
|
|
14
|
+
max = level;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return max;
|
|
18
|
+
}
|
|
19
|
+
// ─── Active Determination ───────────────────────────────────────
|
|
20
|
+
export function isOptionActive(definition, value, specified) {
|
|
21
|
+
const schemaType = definition.schema?.type;
|
|
22
|
+
if (schemaType === "boolean") {
|
|
23
|
+
return value === true;
|
|
24
|
+
}
|
|
25
|
+
if (definition.repeatable) {
|
|
26
|
+
return specified && Array.isArray(value) && value.length > 0;
|
|
27
|
+
}
|
|
28
|
+
return specified && value != null;
|
|
29
|
+
}
|
|
30
|
+
// ─── Derive Policy ─────────────────────────────────────────────
|
|
31
|
+
export function derivePolicy(input) {
|
|
32
|
+
const sideEffects = new Set();
|
|
33
|
+
const reads = [];
|
|
34
|
+
const writes = [];
|
|
35
|
+
const networkEffects = [];
|
|
36
|
+
const riskLevels = [];
|
|
37
|
+
let executionMode;
|
|
38
|
+
let explicitConfirmation;
|
|
39
|
+
if (input.command_effects) {
|
|
40
|
+
const ce = input.command_effects;
|
|
41
|
+
riskLevels.push(ce.risk_level ?? "low");
|
|
42
|
+
if (ce.writes) {
|
|
43
|
+
sideEffects.add("file_write");
|
|
44
|
+
for (const w of ce.writes) {
|
|
45
|
+
writes.push({
|
|
46
|
+
kind: "semantic",
|
|
47
|
+
target: w.target,
|
|
48
|
+
description: w.description,
|
|
49
|
+
overwrite: w.overwrite,
|
|
50
|
+
destructive: w.destructive,
|
|
51
|
+
...(w.idempotent !== undefined ? { idempotent: w.idempotent } : {}),
|
|
52
|
+
...(w.idempotency_key ? { idempotency_key: w.idempotency_key } : {}),
|
|
53
|
+
...(w.idempotent_note ? { idempotent_note: w.idempotent_note } : {}),
|
|
54
|
+
source: `command:${input.command_id}`,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (ce.reads) {
|
|
59
|
+
for (const r of ce.reads) {
|
|
60
|
+
reads.push({
|
|
61
|
+
kind: "semantic",
|
|
62
|
+
target: r.target,
|
|
63
|
+
description: r.description,
|
|
64
|
+
source: `command:${input.command_id}`,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (ce.network) {
|
|
69
|
+
sideEffects.add("network");
|
|
70
|
+
if (typeof ce.network === "object") {
|
|
71
|
+
networkEffects.push({
|
|
72
|
+
...(ce.network.description ? { description: ce.network.description } : {}),
|
|
73
|
+
...(ce.network.domains ? { domains: ce.network.domains } : {}),
|
|
74
|
+
...(ce.network.idempotent !== undefined ? { idempotent: ce.network.idempotent } : {}),
|
|
75
|
+
...(ce.network.idempotency_key ? { idempotency_key: ce.network.idempotency_key } : {}),
|
|
76
|
+
...(ce.network.idempotent_note ? { idempotent_note: ce.network.idempotent_note } : {}),
|
|
77
|
+
source: `command:${input.command_id}`,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (ce.execution_mode) {
|
|
82
|
+
executionMode = ce.execution_mode;
|
|
83
|
+
}
|
|
84
|
+
if (ce.requires_confirmation !== undefined) {
|
|
85
|
+
explicitConfirmation = ce.requires_confirmation;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
for (const [optName, optInput] of Object.entries(input.options)) {
|
|
89
|
+
const { definition, value, specified } = optInput;
|
|
90
|
+
const active = isOptionActive(definition, value, specified);
|
|
91
|
+
if (!active)
|
|
92
|
+
continue;
|
|
93
|
+
if (definition.file) {
|
|
94
|
+
const filePath = typeof value === "string" ? value : undefined;
|
|
95
|
+
const mode = definition.file.mode;
|
|
96
|
+
if (mode === "read" || mode === "readWrite") {
|
|
97
|
+
reads.push({
|
|
98
|
+
kind: "option-file",
|
|
99
|
+
option: optName,
|
|
100
|
+
path: filePath,
|
|
101
|
+
source: `option:${optName}`,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (mode === "write" || mode === "append" || mode === "readWrite") {
|
|
105
|
+
sideEffects.add("file_write");
|
|
106
|
+
writes.push({
|
|
107
|
+
kind: "option-file",
|
|
108
|
+
option: optName,
|
|
109
|
+
path: filePath,
|
|
110
|
+
mode,
|
|
111
|
+
source: `option:${optName}`,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (definition.effects) {
|
|
116
|
+
const eff = definition.effects;
|
|
117
|
+
riskLevels.push(eff.risk_level ?? "low");
|
|
118
|
+
if (eff.writes) {
|
|
119
|
+
sideEffects.add("file_write");
|
|
120
|
+
for (const w of eff.writes) {
|
|
121
|
+
writes.push({
|
|
122
|
+
kind: "semantic",
|
|
123
|
+
target: w.target,
|
|
124
|
+
description: w.description,
|
|
125
|
+
overwrite: w.overwrite,
|
|
126
|
+
destructive: w.destructive,
|
|
127
|
+
...(w.idempotent !== undefined ? { idempotent: w.idempotent } : {}),
|
|
128
|
+
...(w.idempotency_key ? { idempotency_key: w.idempotency_key } : {}),
|
|
129
|
+
...(w.idempotent_note ? { idempotent_note: w.idempotent_note } : {}),
|
|
130
|
+
source: `option:${optName}`,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (eff.reads) {
|
|
135
|
+
for (const r of eff.reads) {
|
|
136
|
+
reads.push({
|
|
137
|
+
kind: "semantic",
|
|
138
|
+
target: r.target,
|
|
139
|
+
description: r.description,
|
|
140
|
+
source: `option:${optName}`,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (eff.network) {
|
|
145
|
+
sideEffects.add("network");
|
|
146
|
+
if (typeof eff.network === "object") {
|
|
147
|
+
networkEffects.push({
|
|
148
|
+
...(eff.network.description ? { description: eff.network.description } : {}),
|
|
149
|
+
...(eff.network.domains ? { domains: eff.network.domains } : {}),
|
|
150
|
+
...(eff.network.idempotent !== undefined ? { idempotent: eff.network.idempotent } : {}),
|
|
151
|
+
...(eff.network.idempotency_key ? { idempotency_key: eff.network.idempotency_key } : {}),
|
|
152
|
+
...(eff.network.idempotent_note ? { idempotent_note: eff.network.idempotent_note } : {}),
|
|
153
|
+
source: `option:${optName}`,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (eff.execution_mode && !executionMode) {
|
|
158
|
+
executionMode = eff.execution_mode;
|
|
159
|
+
}
|
|
160
|
+
if (eff.requires_confirmation !== undefined && explicitConfirmation === undefined) {
|
|
161
|
+
explicitConfirmation = eff.requires_confirmation;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const finalRiskLevel = riskLevels.length > 0 ? maxRiskLevel(...riskLevels) : "low";
|
|
166
|
+
const requiresConfirmation = explicitConfirmation ??
|
|
167
|
+
(finalRiskLevel === "high" || finalRiskLevel === "critical");
|
|
168
|
+
let requiresSecrets;
|
|
169
|
+
if (input.env) {
|
|
170
|
+
const secrets = [];
|
|
171
|
+
for (const [envName, envVar] of Object.entries(input.env)) {
|
|
172
|
+
if (envVar.sensitive) {
|
|
173
|
+
secrets.push(envName);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (secrets.length > 0) {
|
|
177
|
+
requiresSecrets = secrets;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const semanticWrites = writes.filter((w) => w.kind === "semantic");
|
|
181
|
+
const idempotent = semanticWrites.every((w) => w.idempotent === true) &&
|
|
182
|
+
networkEffects.every((n) => n.idempotent === true);
|
|
183
|
+
return {
|
|
184
|
+
risk_level: finalRiskLevel,
|
|
185
|
+
requires_confirmation: requiresConfirmation,
|
|
186
|
+
idempotent,
|
|
187
|
+
side_effects: [...sideEffects],
|
|
188
|
+
reads,
|
|
189
|
+
writes,
|
|
190
|
+
...(networkEffects.length > 0 ? { network: networkEffects } : {}),
|
|
191
|
+
...(executionMode ? { execution_mode: executionMode } : {}),
|
|
192
|
+
...(requiresSecrets ? { requires_secrets: requiresSecrets } : {}),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=policy-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-runtime.js","sourceRoot":"","sources":["../../src/generated/policy-runtime.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,yEAAyE;AA2HzE,mEAAmE;AAEnE,MAAM,UAAU,GAA8B;IAC5C,GAAG,EAAE,CAAC;IACN,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;IACP,QAAQ,EAAE,CAAC;CACZ,CAAC;AAEF,SAAS,YAAY,CAAC,GAAG,MAAmB;IAC1C,IAAI,GAAG,GAAc,KAAK,CAAC;IAC3B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,UAAU,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACxC,GAAG,GAAG,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,mEAAmE;AAEnE,MAAM,UAAU,cAAc,CAC5B,UAAkB,EAClB,KAAc,EACd,SAAkB;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
+
export declare const commandDefinitions: {
|
|
4
|
+
readonly render: {
|
|
5
|
+
readonly effects: {
|
|
6
|
+
readonly risk_level: "low";
|
|
7
|
+
readonly writes: readonly [{
|
|
8
|
+
readonly target: "output file";
|
|
9
|
+
readonly description: "Writes the rendered result to a file (when -o is specified).";
|
|
10
|
+
readonly overwrite: true;
|
|
11
|
+
readonly idempotent: true;
|
|
12
|
+
readonly idempotent_note: "Produces identical output given the same input and settings.";
|
|
13
|
+
}];
|
|
14
|
+
};
|
|
15
|
+
readonly options: readonly [{
|
|
16
|
+
readonly name: "output";
|
|
17
|
+
readonly schema: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
};
|
|
20
|
+
readonly file: {
|
|
21
|
+
readonly mode: "write";
|
|
22
|
+
};
|
|
23
|
+
}, {
|
|
24
|
+
readonly name: "pipeline";
|
|
25
|
+
readonly schema: {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
};
|
|
28
|
+
}, {
|
|
29
|
+
readonly name: "theme";
|
|
30
|
+
readonly schema: {
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
};
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "template";
|
|
35
|
+
readonly schema: {
|
|
36
|
+
readonly type: "string";
|
|
37
|
+
};
|
|
38
|
+
readonly file: {
|
|
39
|
+
readonly mode: "read";
|
|
40
|
+
readonly exists: true;
|
|
41
|
+
readonly media_type: "text/html";
|
|
42
|
+
};
|
|
43
|
+
}, {
|
|
44
|
+
readonly name: "styles";
|
|
45
|
+
readonly schema: {
|
|
46
|
+
readonly type: "array";
|
|
47
|
+
readonly items: {
|
|
48
|
+
readonly type: "string";
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "scripts";
|
|
53
|
+
readonly schema: {
|
|
54
|
+
readonly type: "array";
|
|
55
|
+
readonly items: {
|
|
56
|
+
readonly type: "string";
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
}, {
|
|
60
|
+
readonly name: "paper-size";
|
|
61
|
+
readonly schema: {
|
|
62
|
+
readonly type: "string";
|
|
63
|
+
readonly enum: readonly ["A4", "A3", "Letter", "Legal", "Tabloid"];
|
|
64
|
+
readonly default: "A4";
|
|
65
|
+
};
|
|
66
|
+
}, {
|
|
67
|
+
readonly name: "landscape";
|
|
68
|
+
readonly schema: {
|
|
69
|
+
readonly type: "boolean";
|
|
70
|
+
readonly default: false;
|
|
71
|
+
};
|
|
72
|
+
}, {
|
|
73
|
+
readonly name: "header";
|
|
74
|
+
readonly schema: {
|
|
75
|
+
readonly type: "string";
|
|
76
|
+
};
|
|
77
|
+
}, {
|
|
78
|
+
readonly name: "viewport";
|
|
79
|
+
readonly schema: {
|
|
80
|
+
readonly type: "string";
|
|
81
|
+
};
|
|
82
|
+
}, {
|
|
83
|
+
readonly name: "margin";
|
|
84
|
+
readonly schema: {
|
|
85
|
+
readonly type: "string";
|
|
86
|
+
};
|
|
87
|
+
}];
|
|
88
|
+
};
|
|
89
|
+
readonly init: {
|
|
90
|
+
readonly effects: {
|
|
91
|
+
readonly risk_level: "medium";
|
|
92
|
+
readonly writes: readonly [{
|
|
93
|
+
readonly target: "md-pipe.config.yml";
|
|
94
|
+
readonly description: "Generates a config file template.";
|
|
95
|
+
}];
|
|
96
|
+
};
|
|
97
|
+
readonly options: readonly [{
|
|
98
|
+
readonly name: "theme";
|
|
99
|
+
readonly schema: {
|
|
100
|
+
readonly type: "string";
|
|
101
|
+
readonly default: "default";
|
|
102
|
+
};
|
|
103
|
+
}, {
|
|
104
|
+
readonly name: "force";
|
|
105
|
+
readonly schema: {
|
|
106
|
+
readonly type: "boolean";
|
|
107
|
+
readonly default: false;
|
|
108
|
+
};
|
|
109
|
+
readonly effects: {
|
|
110
|
+
readonly risk_level: "high";
|
|
111
|
+
readonly overwrites: true;
|
|
112
|
+
};
|
|
113
|
+
}];
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
export declare function deriveCommandPolicy(command_id: string, optionValues: Record<string, unknown>): IntrospectionResult;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// Auto-generated by cli-contracts. Do not edit.
|
|
2
|
+
import { derivePolicy, isOptionActive } from "./policy-runtime.js";
|
|
3
|
+
export const commandDefinitions = {
|
|
4
|
+
"render": {
|
|
5
|
+
"effects": {
|
|
6
|
+
"risk_level": "low",
|
|
7
|
+
"writes": [
|
|
8
|
+
{
|
|
9
|
+
"target": "output file",
|
|
10
|
+
"description": "Writes the rendered result to a file (when -o is specified).",
|
|
11
|
+
"overwrite": true,
|
|
12
|
+
"idempotent": true,
|
|
13
|
+
"idempotent_note": "Produces identical output given the same input and settings."
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"options": [
|
|
18
|
+
{
|
|
19
|
+
"name": "output",
|
|
20
|
+
"schema": {
|
|
21
|
+
"type": "string"
|
|
22
|
+
},
|
|
23
|
+
"file": {
|
|
24
|
+
"mode": "write"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "pipeline",
|
|
29
|
+
"schema": {
|
|
30
|
+
"type": "string"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "theme",
|
|
35
|
+
"schema": {
|
|
36
|
+
"type": "string"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "template",
|
|
41
|
+
"schema": {
|
|
42
|
+
"type": "string"
|
|
43
|
+
},
|
|
44
|
+
"file": {
|
|
45
|
+
"mode": "read",
|
|
46
|
+
"exists": true,
|
|
47
|
+
"media_type": "text/html"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "styles",
|
|
52
|
+
"schema": {
|
|
53
|
+
"type": "array",
|
|
54
|
+
"items": {
|
|
55
|
+
"type": "string"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "scripts",
|
|
61
|
+
"schema": {
|
|
62
|
+
"type": "array",
|
|
63
|
+
"items": {
|
|
64
|
+
"type": "string"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"name": "paper-size",
|
|
70
|
+
"schema": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"enum": [
|
|
73
|
+
"A4",
|
|
74
|
+
"A3",
|
|
75
|
+
"Letter",
|
|
76
|
+
"Legal",
|
|
77
|
+
"Tabloid"
|
|
78
|
+
],
|
|
79
|
+
"default": "A4"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "landscape",
|
|
84
|
+
"schema": {
|
|
85
|
+
"type": "boolean",
|
|
86
|
+
"default": false
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "header",
|
|
91
|
+
"schema": {
|
|
92
|
+
"type": "string"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"name": "viewport",
|
|
97
|
+
"schema": {
|
|
98
|
+
"type": "string"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"name": "margin",
|
|
103
|
+
"schema": {
|
|
104
|
+
"type": "string"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
"init": {
|
|
110
|
+
"effects": {
|
|
111
|
+
"risk_level": "medium",
|
|
112
|
+
"writes": [
|
|
113
|
+
{
|
|
114
|
+
"target": "md-pipe.config.yml",
|
|
115
|
+
"description": "Generates a config file template."
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
"options": [
|
|
120
|
+
{
|
|
121
|
+
"name": "theme",
|
|
122
|
+
"schema": {
|
|
123
|
+
"type": "string",
|
|
124
|
+
"default": "default"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"name": "force",
|
|
129
|
+
"schema": {
|
|
130
|
+
"type": "boolean",
|
|
131
|
+
"default": false
|
|
132
|
+
},
|
|
133
|
+
"effects": {
|
|
134
|
+
"risk_level": "high",
|
|
135
|
+
"overwrites": true
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
export function deriveCommandPolicy(command_id, optionValues) {
|
|
142
|
+
const def = commandDefinitions[command_id];
|
|
143
|
+
if (!def)
|
|
144
|
+
throw new Error(`Unknown command: ${command_id}`);
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
146
|
+
const cmdDef = def;
|
|
147
|
+
const options = {};
|
|
148
|
+
const active_options = [];
|
|
149
|
+
for (const optDef of cmdDef.options ?? []) {
|
|
150
|
+
const value = optionValues[optDef.name];
|
|
151
|
+
const specified = optDef.name in optionValues && value !== undefined;
|
|
152
|
+
options[optDef.name] = { value, specified, definition: optDef };
|
|
153
|
+
if (isOptionActive(optDef, value, specified)) {
|
|
154
|
+
active_options.push(optDef.name);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const policy = derivePolicy({
|
|
158
|
+
command_id,
|
|
159
|
+
command_effects: cmdDef.effects,
|
|
160
|
+
options,
|
|
161
|
+
env: cmdDef.env,
|
|
162
|
+
});
|
|
163
|
+
return { command: command_id, active_options, policy };
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/generated/policy.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAKnE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,QAAQ,EAAE;QACR,SAAS,EAAE;YACT,YAAY,EAAE,KAAK;YACnB,QAAQ,EAAE;gBACR;oBACE,QAAQ,EAAE,aAAa;oBACvB,a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MAAM,CAAC,IAAI,IAAI,YAAY,IAAI,KAAK,KAAK,SAAS,CAAC;QACrE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAChE,IAAI,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;YAC7C,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,YAAY,CAAC;QAC1B,UAAU;QACV,eAAe,EAAE,MAAM,CAAC,OAAO;QAC/B,OAAO;QACP,GAAG,EAAE,MAAM,CAAC,GAAG;KAChB,CAAC,CAAC;IAEH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
export interface CommandHandlers {
|
|
3
|
+
render: (input: string | undefined, options: {
|
|
4
|
+
output?: string;
|
|
5
|
+
pipeline?: string;
|
|
6
|
+
theme?: string;
|
|
7
|
+
template?: string;
|
|
8
|
+
styles?: string;
|
|
9
|
+
scripts?: string;
|
|
10
|
+
paperSize?: string;
|
|
11
|
+
landscape?: boolean;
|
|
12
|
+
header?: string;
|
|
13
|
+
viewport?: string;
|
|
14
|
+
margin?: string;
|
|
15
|
+
}, parentOpts: Record<string, unknown>) => Promise<void>;
|
|
16
|
+
init: (options: {
|
|
17
|
+
theme?: string;
|
|
18
|
+
force?: boolean;
|
|
19
|
+
}, parentOpts: Record<string, unknown>) => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export declare function createProgram(handlers: CommandHandlers, version: string): Command;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Auto-generated by cli-contracts. Do not edit.
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { deriveCommandPolicy } from "./policy.js";
|
|
4
|
+
export function createProgram(handlers, version) {
|
|
5
|
+
const program = new Command();
|
|
6
|
+
program
|
|
7
|
+
.name("md-pipe")
|
|
8
|
+
.version(version, "-V, --version")
|
|
9
|
+
.description("Extended Markdown rendering toolchain.");
|
|
10
|
+
program.option("-c, --config <value>", "Path to the project config file. Auto-detects md-pipe.config.yml when omitted.");
|
|
11
|
+
program.option("-v, --verbose", "Enable verbose logging.", false);
|
|
12
|
+
program.option("--strict", "Treat undefined directives as errors. Overrides the config strictDirectives setting. Recommended for CI usage.\n", false);
|
|
13
|
+
program.option("--introspect", "Output derived policy as JSON without executing the command");
|
|
14
|
+
program
|
|
15
|
+
.command("render", { isDefault: true, hidden: true })
|
|
16
|
+
.description("Render a Markdown file through the pipeline.")
|
|
17
|
+
.argument("[input]", "Input Markdown file. Reads from stdin when omitted.")
|
|
18
|
+
.option("-o, --output <value>", "Output file path. Writes to stdout when omitted.")
|
|
19
|
+
.option("-p, --pipeline <value>", "Pipeline range in [start.]end format. Omitting start begins from the .md source. Examples: .html (source→html), .pdf (source→pdf), .render (source→render), render.html, transform.pdf, html.pdf. When omitted, inferred from -o extension (.html → html, .pdf → pdf). When -o is also omitted, follows frontmatter / config (default: html).\n")
|
|
20
|
+
.option("-t, --theme <value>", "Theme name. Applies a preset defined in the project config themes section. Overrides frontmatter theme setting.\n")
|
|
21
|
+
.option("--template <value>", "Path to a Handlebars template file for the html stage. The template receives {{{body}}}, {{{styles}}}, {{{scripts}}}, and {{title}} as variables. When omitted, a built-in minimal HTML shell is used.\n")
|
|
22
|
+
.option("--styles <value>", "Additional CSS file paths. Multiple values allowed. Appended after theme assets in load order.\n")
|
|
23
|
+
.option("--scripts <value>", "Additional JavaScript file paths. Multiple values allowed. Appended after theme assets in load order.\n")
|
|
24
|
+
.option("--paper-size <value>", "Paper size for the pdf stage. Overrides frontmatter paper.size.", "A4")
|
|
25
|
+
.option("--landscape", "Landscape orientation for the pdf stage.", false)
|
|
26
|
+
.option("--header <value>", "Page header text for the pdf stage.")
|
|
27
|
+
.option("--viewport <value>", "Viewport size for the pdf stage in WIDTHxHEIGHT format (e.g. 1024x768). Controls Puppeteer's page.setViewport() and the viewport meta tag in the default HTML template. When omitted, the default HTML template uses width=device-width, initial-scale=1 and Puppeteer uses its default (800x600).\n")
|
|
28
|
+
.option("--margin <value>", "Page margin for the pdf stage. Example: 16mm, 18mm.")
|
|
29
|
+
.action(async (input, opts, cmd) => {
|
|
30
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
31
|
+
if (globalOpts.introspect) {
|
|
32
|
+
const policy = deriveCommandPolicy("render", opts);
|
|
33
|
+
console.log(JSON.stringify(policy, null, 2));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
await handlers.render(input, opts, globalOpts);
|
|
37
|
+
});
|
|
38
|
+
program
|
|
39
|
+
.command("init")
|
|
40
|
+
.description("Initialize a md-pipe project.")
|
|
41
|
+
.option("-t, --theme <value>", "Initial theme name to scaffold.", "default")
|
|
42
|
+
.option("-f, --force", "Overwrite existing config file.", false)
|
|
43
|
+
.action(async (opts, cmd) => {
|
|
44
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
45
|
+
if (globalOpts.introspect) {
|
|
46
|
+
const policy = deriveCommandPolicy("init", opts);
|
|
47
|
+
console.log(JSON.stringify(policy, null, 2));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
await handlers.init(opts, globalOpts);
|
|
51
|
+
});
|
|
52
|
+
return program;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=program.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program.js","sourceRoot":"","sources":["../../src/generated/program.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAsB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOtE,MAAM,UAAU,aAAa,CAC3B,QAAyB,EACzB,OAAe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ly properties: {
|
|
6
|
+
readonly message: {
|
|
7
|
+
readonly type: "string";
|
|
8
|
+
readonly description: "Error message.";
|
|
9
|
+
};
|
|
10
|
+
readonly file: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly description: "File path where the error occurred.";
|
|
13
|
+
};
|
|
14
|
+
readonly line: {
|
|
15
|
+
readonly type: "integer";
|
|
16
|
+
readonly description: "Line number where the error occurred.";
|
|
17
|
+
};
|
|
18
|
+
readonly detail: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
readonly description: "Detailed error information.";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare const renderExitCodes: readonly [0, 1, 2];
|
|
26
|
+
export declare const initExitCodes: readonly [0, 1, 3];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Auto-generated by cli-contracts. Do not edit.
|
|
2
|
+
export const schemas = {
|
|
3
|
+
ErrorMessage: {
|
|
4
|
+
"type": "object",
|
|
5
|
+
"required": [
|
|
6
|
+
"message"
|
|
7
|
+
],
|
|
8
|
+
"properties": {
|
|
9
|
+
"message": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Error message."
|
|
12
|
+
},
|
|
13
|
+
"file": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "File path where the error occurred."
|
|
16
|
+
},
|
|
17
|
+
"line": {
|
|
18
|
+
"type": "integer",
|
|
19
|
+
"description": "Line number where the error occurred."
|
|
20
|
+
},
|
|
21
|
+
"detail": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"description": "Detailed error information."
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export const renderExitCodes = [0, 1, 2];
|
|
29
|
+
export const initExitCodes = [0, 1, 3];
|
|
30
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/generated/schemas.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,YAAY,EAAE;QACZ,MAAM,EAAE,QAAQ;QAChB,UAAU,EAAE;YACV,SAAS;SACV;QACD,YAAY,EAAE;YACZ,SAAS,EAAE;gBACT,MAAM,EAAE,QAAQ;gBAChB,aAAa,EAAE,gBAAgB;aAChC;YACD,MAAM,EAAE;gBACN,MAAM,EAAE,QAAQ;gBAChB,aAAa,EAAE,qCAAqC;aACrD;YACD,MAAM,EAAE;gBACN,MAAM,EAAE,SAAS;gBACjB,aAAa,EAAE,uCAAuC;aACvD;YACD,QAAQ,EAAE;gBACR,MAAM,EAAE,QAAQ;gBAChB,aAAa,EAAE,6BAA6B;aAC7C;SACF;KACF;CACO,CAAC;AAEX,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAU,CAAC;AAClD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAU,CAAC"}
|