flex-md 3.2.0 → 4.0.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/README.md +423 -39
- package/dist/__tests__/structural.test.js +28 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +108 -0
- package/dist/index.cjs +62 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/md/outline.d.ts +6 -3
- package/dist/md/outline.js +28 -50
- package/dist/md/parse.js +15 -4
- package/dist/ofs/parser.js +31 -10
- package/dist/tokens/auto-fix.d.ts +10 -0
- package/dist/tokens/auto-fix.js +56 -0
- package/dist/tokens/cognitive-cost.d.ts +10 -0
- package/dist/tokens/cognitive-cost.js +205 -0
- package/dist/tokens/compliance.d.ts +10 -0
- package/dist/tokens/compliance.js +70 -0
- package/dist/tokens/confidence.d.ts +6 -0
- package/dist/tokens/confidence.js +332 -0
- package/dist/tokens/estimator.d.ts +12 -0
- package/dist/tokens/estimator.js +138 -0
- package/dist/tokens/improvements.d.ts +10 -0
- package/dist/tokens/improvements.js +697 -0
- package/dist/tokens/index.d.ts +24 -0
- package/dist/tokens/index.js +31 -0
- package/dist/tokens/parser.d.ts +3 -0
- package/dist/tokens/parser.js +97 -0
- package/dist/tokens/patterns.d.ts +9 -0
- package/dist/tokens/patterns.js +20 -0
- package/dist/tokens/smart-report.d.ts +10 -0
- package/dist/tokens/smart-report.js +187 -0
- package/dist/tokens/spec-estimator.d.ts +7 -0
- package/dist/tokens/spec-estimator.js +68 -0
- package/dist/tokens/types.d.ts +185 -0
- package/dist/tokens/validator.d.ts +16 -0
- package/dist/tokens/validator.js +59 -0
- package/dist/validate/connection.d.ts +12 -0
- package/dist/validate/connection.js +44 -0
- package/docs/Recommended New Strategies for AI Request Builder.md +691 -0
- package/package.json +8 -3
- package/dist/detection/detector.d.ts +0 -6
- package/dist/detection/detector.js +0 -104
- package/dist/detection/extractor.d.ts +0 -10
- package/dist/detection/extractor.js +0 -54
- package/dist/issues/build.d.ts +0 -26
- package/dist/issues/build.js +0 -62
- package/dist/md/lists.d.ts +0 -14
- package/dist/md/lists.js +0 -33
- package/dist/md/tables.d.ts +0 -25
- package/dist/md/tables.js +0 -72
- package/dist/ofs/extractor.d.ts +0 -9
- package/dist/ofs/extractor.js +0 -75
- package/dist/ofs/issues.d.ts +0 -14
- package/dist/ofs/issues.js +0 -92
- package/dist/ofs/validator.d.ts +0 -10
- package/dist/ofs/validator.js +0 -91
- package/dist/outline/builder.d.ts +0 -10
- package/dist/outline/builder.js +0 -85
- package/dist/outline/renderer.d.ts +0 -6
- package/dist/outline/renderer.js +0 -23
- package/dist/parser.d.ts +0 -2
- package/dist/parser.js +0 -199
- package/dist/parsers/lists.d.ts +0 -6
- package/dist/parsers/lists.js +0 -36
- package/dist/parsers/tables.d.ts +0 -10
- package/dist/parsers/tables.js +0 -58
- package/dist/stringify.d.ts +0 -2
- package/dist/stringify.js +0 -110
- package/dist/test-pipeline.js +0 -53
- package/dist/test-runner.js +0 -331
- package/dist/test-strictness.d.ts +0 -1
- package/dist/test-strictness.js +0 -213
- package/dist/util.d.ts +0 -5
- package/dist/util.js +0 -64
- package/dist/validate/policy.d.ts +0 -10
- package/dist/validate/policy.js +0 -17
- package/dist/validator.d.ts +0 -2
- package/dist/validator.js +0 -80
- /package/dist/{test-pipeline.d.ts → __tests__/structural.test.d.ts} +0 -0
- /package/dist/{test-runner.d.ts → tokens/types.js} +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { parseSystemPart } from './parser.js';
|
|
2
|
+
export function validateSystemParts(spec) {
|
|
3
|
+
const errors = [];
|
|
4
|
+
const warnings = [];
|
|
5
|
+
for (const section of spec.sections) {
|
|
6
|
+
const isRequired = section.required !== false;
|
|
7
|
+
const kind = section.kind || 'text';
|
|
8
|
+
if (!section.instruction) {
|
|
9
|
+
if (isRequired) {
|
|
10
|
+
warnings.push({
|
|
11
|
+
sectionName: section.name,
|
|
12
|
+
message: 'Required section has no instruction. Token estimation will use fallback.'
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const systemPart = parseSystemPart(section.instruction, kind);
|
|
18
|
+
if (!systemPart) {
|
|
19
|
+
warnings.push({
|
|
20
|
+
sectionName: section.name,
|
|
21
|
+
message: `No valid system part found. Expected pattern for '${kind}' kind.`
|
|
22
|
+
});
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
// Validate ranges
|
|
26
|
+
if (systemPart.parsed.type === 'items' || systemPart.parsed.type === 'lines') {
|
|
27
|
+
const { min, max } = systemPart.parsed;
|
|
28
|
+
if (max !== null && max < min) {
|
|
29
|
+
errors.push({
|
|
30
|
+
sectionName: section.name,
|
|
31
|
+
message: `Invalid range: max (${max}) is less than min (${min})`,
|
|
32
|
+
instruction: section.instruction
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (systemPart.parsed.type === 'table') {
|
|
37
|
+
const { rows, columns } = systemPart.parsed;
|
|
38
|
+
if (rows.max !== null && rows.max < rows.min) {
|
|
39
|
+
errors.push({
|
|
40
|
+
sectionName: section.name,
|
|
41
|
+
message: `Invalid rows range: max (${rows.max}) < min (${rows.min})`,
|
|
42
|
+
instruction: section.instruction
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (columns.max !== null && columns.max < columns.min) {
|
|
46
|
+
errors.push({
|
|
47
|
+
sectionName: section.name,
|
|
48
|
+
message: `Invalid columns range: max (${columns.max}) < min (${columns.min})`,
|
|
49
|
+
instruction: section.instruction
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
valid: errors.length === 0,
|
|
56
|
+
errors,
|
|
57
|
+
warnings
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ConnectionResult {
|
|
2
|
+
connected: boolean;
|
|
3
|
+
key: string;
|
|
4
|
+
normalizedKey: string;
|
|
5
|
+
path?: string[];
|
|
6
|
+
alternativeMatches?: string[];
|
|
7
|
+
suggestion?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Checks if a specific key (section) is "connected" in the given markdown.
|
|
11
|
+
*/
|
|
12
|
+
export declare function checkConnection(md: string, key: string): ConnectionResult;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { buildOutline } from "../md/outline.js";
|
|
2
|
+
import { normalizeName } from "../md/parse.js";
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a specific key (section) is "connected" in the given markdown.
|
|
5
|
+
*/
|
|
6
|
+
export function checkConnection(md, key) {
|
|
7
|
+
const outline = buildOutline(md);
|
|
8
|
+
const normKey = normalizeName(key);
|
|
9
|
+
const path = [];
|
|
10
|
+
// Breadth-first search for the key
|
|
11
|
+
const queue = outline.nodes.map(n => ({ node: n, currentPath: [n.title] }));
|
|
12
|
+
const alternatives = [];
|
|
13
|
+
while (queue.length > 0) {
|
|
14
|
+
const { node, currentPath } = queue.shift();
|
|
15
|
+
if (node.key === normKey) {
|
|
16
|
+
return {
|
|
17
|
+
connected: true,
|
|
18
|
+
key,
|
|
19
|
+
normalizedKey: normKey,
|
|
20
|
+
path: currentPath
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// Collect alternatives (any heading that exists)
|
|
24
|
+
alternatives.push(node.title);
|
|
25
|
+
for (const child of node.children) {
|
|
26
|
+
queue.push({ node: child, currentPath: [...currentPath, child.title] });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Not found, look for fuzzy matches or common issues
|
|
30
|
+
const suggestions = [];
|
|
31
|
+
if (alternatives.length === 0) {
|
|
32
|
+
suggestions.push("The document appears to have no headings.");
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
suggestions.push(`Available sections: ${alternatives.join(", ")}`);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
connected: false,
|
|
39
|
+
key,
|
|
40
|
+
normalizedKey: normKey,
|
|
41
|
+
alternativeMatches: alternatives,
|
|
42
|
+
suggestion: suggestions.join(" ")
|
|
43
|
+
};
|
|
44
|
+
}
|